Add Firstrade strategy precheck runtime reports#90
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50f9914475
ℹ️ 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".
| return replace( | ||
| settings, | ||
| dry_run_only=bool(dry_run_override), | ||
| live_trading_enabled=False if dry_run_override else settings.live_trading_enabled, | ||
| runtime_target=runtime_target, |
There was a problem hiding this comment.
Disable precheck strategy-state persistence
When FIRSTRADE_PERSIST_STRATEGY_RUNS=true, forcing dry_run_only here still leaves persist_strategy_runs enabled for /precheck. run_strategy_cycle then writes a dry-run latest.json to the same strategy-run key used by live idempotency, and application/strategy_run_persistence.py:is_duplicate_live_run ignores dry_run_only states, so a scheduled precheck after a live terminal run can make the next live /run in that period submit again instead of being skipped as a duplicate. Disable strategy-run state persistence for forced prechecks while still persisting the runtime report.
Useful? React with 👍 / 👎.
|
|
||
|
|
||
| def _build_run_id() -> str: | ||
| return datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ") |
There was a problem hiding this comment.
Use unique IDs for runtime reports
This run ID only has one-second resolution, but persist_runtime_report derives the local/GCS report path from run_id. If Cloud Run handles two requests for the same strategy/account in the same second (for example a scheduler retry overlapping a manual /run, with concurrency enabled), the later report overwrites the earlier one, losing one runtime record. Include a unique suffix such as a UUID or request ID in addition to the timestamp.
Useful? React with 👍 / 👎.
Summary
Config
Tests