This runbook covers the live execution path in BinancePlatform.
Primary entrypoints:
main.pyfor live hourly execution.github/workflows/main.ymlfor self-hosted manual/API-triggered runsrun_cycle_replay.pyfor fixed-input dry-run replay
Supporting modules with operational impact:
runtime_config_support.pyfor runtime env parsing and bootstrapdegraded_mode_support.pyfor trend-pool fallback ladder and source metadatatrend_pool_support.pyfor upstream payload validationlive_services.pyfor Firestore and Telegram adapters
BinancePlatform is the downstream execution engine.
It is responsible for:
- consuming upstream live-pool artifacts and Firestore summary payloads
- validating freshness, contract shape, and fallback eligibility
- preserving the accepted upstream
symbolsorder when passing the pool into strategy code - executing orders, persisting runtime state, and emitting minimal operator alerts
It is not responsible for:
- monthly research reporting
- monthly live-pool selection, ranking, or local reranking
- upstream release summaries or review packages
- maintaining a second copy of the upstream publish narrative
- Load runtime credentials and Firestore state.
- Resolve the upstream ordered strategy artifact in this order:
- fresh upstream Firestore payload
- last known good upstream payload from state
- validated local upstream file fallback
- built-in static universe as last resort
- Refresh trend-pool metadata in state.
- Capture Binance balances and market snapshots.
- Run trend rotation, BTC DCA, and earn-buffer maintenance.
- Persist updated state and notifications.
Runtime output should stay operational:
- current upstream source and degraded status
- upstream official pool order and current local execution pool logged as separate concepts
- current execution targets and intents
- explicit gating / no-trade reasons and side-effect suppression counts
- zero-trade diagnostics grouped by BTC core / trend sleeve and gate
- exceptions, circuit breakers, and alert-worthy failures
The monthly execution pool is locked to the accepted upstream version / as_of_date. It refreshes when upstream release metadata changes and otherwise reuses the accepted ordered artifact pool; BinancePlatform should not rebuild the monthly pool with local ranking logic.
main.ymlisworkflow_dispatchonly.- GitHub Actions no longer owns the hourly cadence for runtime execution in this repo.
- Production cadence should come from one external scheduler, for example VPS cron calling the GitHub Actions dispatch API.
- The VPS dispatch guard retries bounded transient failures such as network errors and GitHub
500/502/503/504, but still alerts immediately for configuration and permission failures. - Avoid overlapping dispatches from multiple schedulers or from a second manual run while the current runtime job is still in progress.
Healthy mode:
- Source is
fresh_upstream - New trend entries are allowed
- Monthly pool refresh is allowed
Degraded mode:
- Source is
last_known_good,local_file, orstatic - New trend buys are paused by default
- Set
STRATEGY_ARTIFACT_ALLOW_NEW_ENTRIES_ON_DEGRADED=1only if you intentionally want degraded-mode entries
Interpretation:
last_known_goodmeans fresh upstream validation failed, but a previously accepted upstream payload is still available in statelocal_filemeans upstream live access failed and the runtime fell back to a validated local file from the configuredSTRATEGY_ARTIFACT_FILE, the repo-local artifact, or a compatibleCryptoLivePoolPipelinescheckoutstaticis emergency-only and should be treated as lowest-confidence operation
Use the generic STRATEGY_ARTIFACT_* names for crypto strategy artifacts.
Primary settings:
STRATEGY_PROFILE: live profile selector; current supported value iscrypto_live_pool_rotationSTRATEGY_ARTIFACT_FIRESTORE_COLLECTION: upstream artifact collection, defaultstrategySTRATEGY_ARTIFACT_FIRESTORE_DOCUMENT: upstream artifact document, defaultCRYPTO_LIVE_POOL_ROTATION_LIVE_POOLSTRATEGY_ARTIFACT_FILE: local fallback artifact pathSTRATEGY_ARTIFACT_MAX_AGE_DAYS: freshness window for upstreamas_of_dateSTRATEGY_ARTIFACT_ACCEPTABLE_MODES: comma-separated accepted upstream modesSTRATEGY_ARTIFACT_EXPECTED_SIZE: expected live-pool sizeSTRATEGY_ARTIFACT_ALLOW_NEW_ENTRIES_ON_DEGRADED: explicit degraded-entry override
Expected behavior:
- Runtime does not silently treat stale upstream as healthy
- Falls back to last known good, then local file, then static universe
- State keeps source metadata so the degraded source is visible in audit trails
Operator action:
- Inspect upstream Firestore payload freshness and shape
- Verify the upstream project published the expected
version,mode, andpool_size - Prefer fixing upstream rather than enabling degraded new entries
Expected behavior:
- If state load fails, the cycle aborts before trading
- If trend-pool Firestore read fails but state load works, runtime can still fall back to last known good / local file / static
Operator action:
- Validate
GOOGLE_APPLICATION_CREDENTIALSfor local runs, or validate the GitHub OIDC / Workload Identity binding for the runtime workflow - Check service account validity and Firestore API availability
- Use
run_cycle_replay.pyfor dry-run confirmation while Firestore is unavailable
Expected behavior:
- Client bootstrap retries before aborting
- If connection cannot be established, cycle exits with an error notification and no trades
Operator action:
- Check Binance API key validity, IP restrictions, and runner connectivity
- Re-run manually only after the connectivity issue is confirmed resolved
Expected behavior:
- Telegram send failures should not stop the trading cycle
- The cycle may still finish while alert delivery is degraded
Operator action:
- Verify
TG_TOKEN/TG_CHAT_ID - Treat this as an observability incident, not a trading-signal incident
Preferred local install path:
cd /path/to/BinancePlatform
python3 -m venv venv
source venv/bin/activate
REQ_FILE="requirements-lock.txt"
if [ ! -f "$REQ_FILE" ]; then REQ_FILE="requirements.txt"; fi
pip install -r "$REQ_FILE"Replay one fixed cycle:
python3 run_cycle_replay.py --run-id local-checkRun unit tests:
python3 -m unittest discover -s tests -v- The runtime workflow now authenticates to Google Cloud with GitHub OIDC + Workload Identity Federation.
- For safe runner-side verification, dispatch
main.ymlwithvalidate_only=true; that checks Google Cloud + Firestore auth without running live trades. - Local manual runs can still use
GOOGLE_APPLICATION_CREDENTIALS=/path/to/gcp-sa.jsonwhen needed.
- If the runtime falls to
static, treat it as an operator-visible degraded incident. - If Firestore state cannot load, do not bypass the abort by force-running live trades.
- If upstream remains stale for multiple cycles, coordinate with the upstream publisher before changing degraded-mode buy policy.