Skip to content

Upgrade BTC oracle to Fire Horse v10 architecture#5

Open
jpbpari-sys wants to merge 1 commit intomainfrom
codex/add-live-trading-functionality
Open

Upgrade BTC oracle to Fire Horse v10 architecture#5
jpbpari-sys wants to merge 1 commit intomainfrom
codex/add-live-trading-functionality

Conversation

@jpbpari-sys
Copy link
Copy Markdown
Owner

Motivation

  • Replace the previous simple polling/threaded oracle with a single-file, production-oriented async architecture that supports live websocket ingestion, richer spectral/evolution engines, risk-aware sizing, telemetry and airdrop accounting.
  • Provide a plug‑and‑play path for optional live trading via CCXT while keeping a realistic position simulator and persistent logging for reproducible backtesting and observability.

Description

  • Reworked btc_agentic_oracle.py into 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.
  • Added portfolio and position logic including PortfolioManager, a position simulator (fees/slippage/drawdown), live-trade hooks using ccxt.async_support and simulate_trade for paper mode.
  • Added SQLite-backed telemetry with init_db, log_trade, log_metrics, and log_airdrop and new FastAPI endpoints GET /api/trades, GET /api/metrics, and GET /api/airdrops for the dashboard.
  • Upgraded the web UI served at / to a richer dashboard (Chart.js charts, websocket updates, airdrop display) and changed the boot path to call init_db() and start fetch_live_tick() before running the server.

Testing

  • Ran python -m py_compile btc_agentic_oracle.py and it succeeded with no syntax errors.
  • Attempted to run python btc_agentic_oracle.py to start the full app but it failed in this environment with ModuleNotFoundError: No module named 'aiohttp', so the live async stack could not be launched here; install aiohttp (and other runtime deps) to run the server end-to-end.
  • Basic static inspection and lightweight runtime checks (imports/structure) performed during development; no further automated integration tests were executed in this environment.

Codex Task

Copy link
Copy Markdown

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

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: 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".

Comment on lines +531 to +533
if ENABLE_LIVE:
action = await execute_real_trade(sig, price, size)
else:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment on lines +353 to +354
returns_fast = (returns_fast - returns_fast.mean()) / (returns_fast.std() + 1e-8)
returns_slow = (returns_slow - returns_slow.mean()) / (returns_slow.std() + 1e-8)
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 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 👍 / 👎.

Comment on lines +886 to 888
loop = asyncio.get_event_loop()
loop.create_task(fetch_live_tick())
uvicorn.run(app, host="0.0.0.0", port=8000)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant