Keep OKX as a market data source only, and move simulated trading fully local.
The revised project must:
This revision does not include:
fetch-history uses public OKX market data and must not require API credentialsbacktest uses public OKX market data and must not require API credentialsanalyze uses public OKX market data and local codexpaper-order uses local state onlypositions uses local state onlyThe local paper engine stores one JSON file at:
/home/lxy/okx-codex-trader/paper_state.jsonThe file contains:
Initial state rules:
paper-order and positions initialize it implicitly10_000 USDT0fetch-historyUnchanged behavior:
BTC-USDT-SWAP or ETH-USDT-SWAPbacktestUnchanged behavior:
10/20 SMA backtestanalyzeUnchanged behavior:
codexpaper-orderChanged behavior:
--signal-filepaper_state.jsonRules:
action = flat
action = long
action = short
entry_price if provided--margin-usdtmargin_usdt * leveragenotional / pricemargin_usdtmargin_usdt, failState updates:
margin_usdtThis v1 paper engine does not:
positionsChanged behavior:
paper_state.jsonAdd local paper engine models:
PaperPosition
symbolsidequantityavg_entry_pricemargin_usedPaperState
cash_usdtrealized_pnlpositionsupdated_atAllowed failures:
codex executable for analyzeNo fallback logic.
Add tests for:
paper-order initializes missing paper_state.jsonpaper-order uses explicit entry_price when presentpaper-order uses latest public market price when entry_price = nullpaper-order reduces cash by exact margin_usdtpaper-order increases matching local positionpaper-order recomputes average entry price when adding to same sidepaper-order rejects when local cash is insufficientpositions reads local state instead of OKX account positions