Upgrade BTC oracle to Fire Horse v10 architecture#5
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9377d7c539
ℹ️ 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".
| if ENABLE_LIVE: | ||
| action = await execute_real_trade(sig, price, size) | ||
| else: |
There was a problem hiding this comment.
Gate live orders on position state before create_order
In live mode this branch submits execute_real_trade(sig, ...) on every cooldown cycle without checking whether the current position already matches sig, unlike simulate_trade which suppresses duplicate same-side entries. With a persistent LONG/SHORT signal, this will place repeated market orders every 5 seconds and unintentionally stack exposure instead of holding or flipping once.
Useful? React with 👍 / 👎.
| returns_fast = (returns_fast - returns_fast.mean()) / (returns_fast.std() + 1e-8) | ||
| returns_slow = (returns_slow - returns_slow.mean()) / (returns_slow.std() + 1e-8) |
There was a problem hiding this comment.
Classify volatility regime before normalizing returns
returns_fast is z-score normalized here, but regime detection later uses np.std(signal) thresholds to decide LOW/MID/HIGH volatility. After this normalization, the standard deviation is almost always ~1, so the strategy will stay in MID_VOL nearly all the time and the low/high-volatility control paths (confidence scaling and signal gating) are effectively disabled.
Useful? React with 👍 / 👎.
| loop = asyncio.get_event_loop() | ||
| loop.create_task(fetch_live_tick()) | ||
| uvicorn.run(app, host="0.0.0.0", port=8000) |
There was a problem hiding this comment.
Run tick stream task on Uvicorn's event loop
The tick ingestor is scheduled on the loop returned by asyncio.get_event_loop() immediately before uvicorn.run(...); on current Uvicorn versions, run starts the server with its own event loop, so this pre-created task is not driven. In that runtime configuration, market websocket ingestion never starts and the oracle pipeline stays idle.
Useful? React with 👍 / 👎.
Motivation
Description
btc_agentic_oracle.pyinto the “Fire Horse v10” architecture by adding an async Binance websocket pipeline that produces dual-timeframe returns and feeds the spectral ridge/ridge-swarm engine and evolutionary agents; the core spectral and ridge logic remains but is integrated into the async flow.PortfolioManager, a position simulator (fees/slippage/drawdown), live-trade hooks usingccxt.async_supportandsimulate_tradefor paper mode.init_db,log_trade,log_metrics, andlog_airdropand new FastAPI endpointsGET /api/trades,GET /api/metrics, andGET /api/airdropsfor the dashboard./to a richer dashboard (Chart.js charts, websocket updates, airdrop display) and changed the boot path to callinit_db()and startfetch_live_tick()before running the server.Testing
python -m py_compile btc_agentic_oracle.pyand it succeeded with no syntax errors.python btc_agentic_oracle.pyto start the full app but it failed in this environment withModuleNotFoundError: No module named 'aiohttp', so the live async stack could not be launched here; installaiohttp(and other runtime deps) to run the server end-to-end.Codex Task