Skip to content

Add strategy-aware Firstrade session check policy#62

Merged
Pigbibi merged 1 commit into
mainfrom
feat/firstrade-session-check-auto-policy
Jun 3, 2026
Merged

Add strategy-aware Firstrade session check policy#62
Pigbibi merged 1 commit into
mainfrom
feat/firstrade-session-check-auto-policy

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add FIRSTRADE_SESSION_CHECK_POLICY with auto/always/skip handling for /session-check
  • in auto mode, throttle monthly snapshot strategies to one real maintenance check per calendar month when GCS state is available
  • keep daily and daily-canary strategies running every scheduler hit, and run conservatively when state or strategy context is unavailable
  • document the new env var and add session-check policy tests

Validation

  • uv run --no-project --with pytest --with pandas --with requests --with google-cloud-storage --with firstrade==0.0.38 pytest tests/test_runtime_broker_adapters.py tests/test_firstrade_client.py tests/test_rebalance_service.py tests/test_session_check_service.py -q
  • uv run --no-project --with ruff ruff check application/session_check_service.py tests/test_session_check_service.py main.py

@Pigbibi Pigbibi merged commit b9a1f28 into main Jun 3, 2026
1 check passed
@Pigbibi Pigbibi deleted the feat/firstrade-session-check-auto-policy branch June 3, 2026 04:43

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e567ea5e60

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +163 to +164
account_selector = str(env("FIRSTRADE_ACCOUNT", "") or "").strip()
account_key = _safe_key(mask_account_id(account_selector)) if account_selector else "auto"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scope auto session-check markers per account identity

When FIRSTRADE_ACCOUNT is unset (which is a supported single-account setup), every deployment for the same strategy writes and reads session-checks/auto/.... If two Firstrade credentials share the same GCS bucket/prefix and strategy, the first account's monthly marker causes the other account's /session-check to skip without ever connecting, so its session/account maintenance is suppressed for the rest of the period. Include a stable credential/account scope in the key even for the auto account case, or avoid skipping when the account scope is ambiguous.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant