بنقرة واحدة
paper-trading
Set up, debug, and validate the paper trading system
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Set up, debug, and validate the paper trading system
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
State persistence, prior transfer, and warmup lifecycle. Read when working on checkpoint/, adding new checkpoint fields, debugging cold starts or stale priors, or understanding serde(default) requirements and backward compatibility rules.
Documents auto_derive.rs first-principles parameter derivation from capital and exchange metadata. Use when onboarding new assets, debugging parameter mismatches, understanding why gamma/max_position/target_liquidity have their values, or adding new derived parameters.
WebSocket management, event loop, rate limiting, reconnection, recovery, metrics, and order execution infrastructure. Use when working on orchestrator/, infra/, messages/, core/, fills/, or execution/ modules, debugging connectivity or order placement, adding message handlers, or investigating stale data and latency issues.
Documents the 9 learning feedback loops, SpreadBandit Thompson Sampling, adaptive ensemble, confidence tracking, and baseline tracker. Use when debugging learning behavior, tuning reward attribution, investigating model weight decay, or understanding how fills translate into parameter updates.
Layered risk system with monitors, circuit breakers, kill switch, and position guards. Use when working on risk/, safety/, or monitoring/ modules, debugging position limits, emergency shutdowns, spread widening, or adding new risk monitors. Covers RiskMonitor trait, severity escalation, and defense-first architecture.
Documents the additive spread composition pipeline from GLFT optimal through to final bid/ask prices. Use when debugging wide spreads, investigating spread component contributions, tuning defensive behavior, or understanding why quotes are wider than expected. Critical for incident triage.
| name | paper-trading |
| description | Set up, debug, and validate the paper trading system |
| disable-model-invocation | true |
| context | fork |
| agent | general-purpose |
| argument-hint | [asset] |
Guide for setting up, debugging, and validating the paper trading system. The paper trader uses simulated fills against real market data to validate strategies without risking capital.
src/bin/paper_trader.rs # Main binary
src/market_maker/simulation/fill_sim.rs # Fill probability simulator
src/market_maker/simulation/outcome.rs # Fill outcome tracking
src/market_maker/simulation/calibration.rs # Fill sim calibration
The paper trader connects to real market data feeds but simulates fills locally:
FillSimulatorKey settings in paper trader config:
ignore_book_depth: true — paper trader orders don't exist in real book, so queue position must use flat modelfill_prob_base — base fill probability (typically 0.3-0.5)adverse_fill_ratio — fraction of fills that are adverse (for testing robustness)These must ALL be working for the paper trader to produce meaningful results. If any is broken, the system won't learn from its simulated experience.
Simulated fill -> estimator.on_own_fill() -> kappa update
on_simulated_fill(), call estimator.on_own_fill(side, price, size, mid)own_fills=0 forever, kappa stuck at prior valuesSimulated fill -> wait 5s -> check mid price -> record_outcome()
PendingFillOutcome deque, checked in update_mid()pre_fill_classifier.record_outcome(was_adverse)kappa_confidence + as_progress -> cal_progress -> cal_gamma
CalibrationController tracks progress via (as_progress + kappa_progress) / 2cal_gamma starts at 0.3 (fill-hungry = tight spreads) and rises toward 1.0CalibrationController imported via market_maker re-exportcalibration_progress stuck at 0.0, gamma never adjustsRoot cause: compute_fill_probability() uses real L2 book depth for queue position, but paper trader orders don't exist in the real book.
Fix: Set ignore_book_depth: true on FillSimulatorConfig. This uses a flat queue model instead of trying to estimate queue position in the real book.
Verify: After fix, you should see fills within 1-2 minutes of starting.
Root cause: update_state() never called, so margin tracking thinks there's no available margin.
Fix: Ensure update_state() is called on position changes to keep margin tracker in sync.
Symptom: kappa_confidence stays at 0, kappa never updates from initial values.
Root cause: estimator.on_own_fill() not being called when simulated fills occur.
Fix: Wire on_own_fill() call in on_simulated_fill() handler.
Symptom: Pre-fill toxicity scores are always near 0.5 (neutral).
Root cause: pre_fill_classifier.record_outcome() never called, so classifier has no training data.
Fix: Implement PendingFillOutcome deque with 5s markout check in update_mid().
Symptom: calibration_progress always 0.0, cal_gamma at initial value.
Root cause: CalibrationController not instantiated or not being updated.
Fix: Import and instantiate CalibrationController, feed it kappa_confidence and as_progress.
After starting the paper trader, verify these within the first 30 minutes:
kappa_confidence increasing from 0calibration_progress > 0# Build
cargo build --release --bin paper_trader
# Run (user executes manually)
RUST_LOG=info ./target/release/paper_trader