Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 74 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,83 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
- name: Checkout
uses: actions/checkout@v6

- name: Resolve QuantPlatformKit ref
id: quant-platform-kit-ref
run: |
set -euo pipefail
ref="main"
for candidate in "${GITHUB_HEAD_REF:-}" "${GITHUB_BASE_REF:-}"; do
if [ -n "$candidate" ] && git ls-remote --exit-code --heads https://github.com/QuantStrategyLab/QuantPlatformKit.git "$candidate" >/dev/null 2>&1; then
ref="$candidate"
break
fi
done
echo "ref=${ref}" >> "$GITHUB_OUTPUT"

- name: Resolve UsEquityStrategies ref
id: us-equity-strategies-ref
run: |
set -euo pipefail
ref="main"
for candidate in "${GITHUB_HEAD_REF:-}" "${GITHUB_BASE_REF:-}"; do
if [ -n "$candidate" ] && git ls-remote --exit-code --heads https://github.com/QuantStrategyLab/UsEquityStrategies.git "$candidate" >/dev/null 2>&1; then
ref="$candidate"
break
fi
done
echo "ref=${ref}" >> "$GITHUB_OUTPUT"

- name: Checkout QuantPlatformKit
uses: actions/checkout@v6
with:
repository: QuantStrategyLab/QuantPlatformKit
ref: ${{ steps.quant-platform-kit-ref.outputs.ref }}
path: external/QuantPlatformKit

- name: Checkout UsEquityStrategies
uses: actions/checkout@v6
with:
repository: QuantStrategyLab/UsEquityStrategies
ref: ${{ steps.us-equity-strategies-ref.outputs.ref }}
path: external/UsEquityStrategies

- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.12"

- name: Install dependencies
run: |
set -euo pipefail
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -r requirements.txt pytest ruff

- name: Smoke import pinned shared packages
run: |
set -euo pipefail
python - <<'PY'
from quant_platform_kit.common.port_adapters import CallableNotificationPort, CallablePortfolioPort
from us_equity_strategies import resolve_canonical_profile

assert CallableNotificationPort
assert CallablePortfolioPort
assert resolve_canonical_profile("russell_top50_leader_rotation") == "russell_top50_leader_rotation"
PY

- name: Install editable shared repositories
run: |
set -euo pipefail
python -m pip install --no-deps -e external/QuantPlatformKit -e external/UsEquityStrategies

- name: Run ruff
run: |
set -euo pipefail
ruff check .

- name: Run tests
run: python -m pytest -q
run: |
set -euo pipefail
PYTHONPATH=. PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python -m pytest -q tests
6 changes: 3 additions & 3 deletions application/execution_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ def execute_value_target_plan(
continue

buy_deltas = [item for item in tradable_deltas if item[1] > 0]
buys_blocked_reason: str | None = None
_buys_blocked_reason: str | None = None
if cash_only_execution and buy_deltas and pending_sell_release_symbols:
estimated_buy_cost = 0.0
for symbol, delta_value, price in buy_deltas:
Expand All @@ -585,7 +585,7 @@ def execute_value_target_plan(
if quantity > 0:
estimated_buy_cost += quantity * limit_price
if estimated_buy_cost > investable_cash:
buys_blocked_reason = "pending_sell_release"
_buys_blocked_reason = "pending_sell_release"
for symbol, _delta_value, _price in buy_deltas:
skipped.append(
{
Expand All @@ -596,7 +596,7 @@ def execute_value_target_plan(
)
buy_deltas = []
elif cash_only_execution and buy_deltas and raw_liquid_cash < 0.0:
buys_blocked_reason = "negative_cash"
_buys_blocked_reason = "negative_cash"
for symbol, _delta_value, _price in buy_deltas:
skipped.append(
{
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ authors = [
dependencies = [
"firstrade==0.0.39",
"quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@b821e8c318e15d40f925c84a007ae335a3415cd5",
"us-equity-strategies @ git+https://github.com/QuantStrategyLab/UsEquityStrategies.git@a7306afc943cad8ddb7e368efd24640e84fd6e3d",
"us-equity-strategies @ git+https://github.com/QuantStrategyLab/UsEquityStrategies.git@07232b0",
"google-cloud-storage",
"requests",
]
Expand Down Expand Up @@ -47,3 +47,7 @@ testpaths = ["tests"]
[tool.ruff]
target-version = "py311"
line-length = 100

[tool.ruff.lint.per-file-ignores]
"tests/**" = ["E402", "F841"]