From d4de0f3cf4061685e7edc2c5b946e0a2f529331c Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Sat, 27 Jun 2026 14:22:36 +0800 Subject: [PATCH 1/4] Align pyproject pin and strengthen CI to match other platforms. Co-authored-by: Cursor --- .github/workflows/ci.yml | 78 +++++++++++++++++++++++++++++++++++++--- pyproject.toml | 2 +- 2 files changed, 75 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e5ddc1..11443e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/pyproject.toml b/pyproject.toml index f69ee7d..c004f96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", ] From fff4afc326bfd08e6c25bc415fb2623e22339a57 Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Sat, 27 Jun 2026 14:25:38 +0800 Subject: [PATCH 2/4] Ignore test-only ruff rules blocked by import stubs. Co-authored-by: Cursor --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index c004f96..44c4410 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,3 +47,7 @@ testpaths = ["tests"] [tool.ruff] target-version = "py311" line-length = 100 + +[tool.ruff.lint.per-file-ignores] +"tests/**" = ["E402", "F841"] + From 2107259e883f8ee8693bac57b9462e471ce7dedd Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Sat, 27 Jun 2026 14:28:49 +0800 Subject: [PATCH 3/4] Silence unused buys_blocked_reason assignment for ruff. Co-authored-by: Cursor --- application/execution_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/execution_service.py b/application/execution_service.py index f23b95d..d656dfb 100644 --- a/application/execution_service.py +++ b/application/execution_service.py @@ -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: From efda3fe863eb02ecf1e8ac0b2b649b79b555a73b Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Sat, 27 Jun 2026 14:31:08 +0800 Subject: [PATCH 4/4] Fix remaining buys_blocked_reason ruff assignments. Rename pending_sell_release and negative_cash assignments to _buys_blocked_reason so ruff F841 passes consistently. Co-authored-by: Cursor --- application/execution_service.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/execution_service.py b/application/execution_service.py index d656dfb..86be628 100644 --- a/application/execution_service.py +++ b/application/execution_service.py @@ -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( { @@ -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( {