feat: add guarded vn.py simulated market data integration#118
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
CI installs requirements.txt only, so vnpy is absent there. Three test
modules imported it at module scope, which raises during *collection* and
aborts the whole pytest session -- 0 of ~1030 tests ran, and because the
Render deploy hook gates on backend tests passing on main, that also blocks
prod deploys.
Gate them the way the optional discord dep already is (importorskip), and
skip only the two engine cases that build a provider so the argparse --help
contract test keeps running where vnpy is absent -- that CLI surface ships
in a vnpy-less deploy, so it should be verified in one.
test_enabled_simulation_is_passed_to_background_runner had the same latent
assumption: it asserted 200 while the endpoint correctly returns 503 when
find_spec("vnpy") is None, so it only passed on a machine with vnpy
installed. Substitute validate_market_data_source (real allow-list + feature
gate, minus the dependency probe) so the pass-through wiring is verified on
CI too; the probe itself stays covered by the dedicated 503 test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Widening _llm_run_metadata() into a shared _run_metadata() for all three runs kept the LLM-shaped keys in it. run_agent_backtest() runs first, so by the time the baselines call it, use_llm / prompt_adaptations / pipeline are populated -- a Buy & Hold row that made zero model calls was recording llm_max_output_tokens plus a full copy of the agent's pipeline, duplicated across three rows per backtest. Split it: _run_metadata() is provenance only (baselines), and _agent_run_metadata() adds the effective LLM/pipeline config on top. The wiring guard needed retargeting too -- "metadata=self._run_metadata()" still appears in engine.py because the baselines call it, so the old grep would have kept passing while no longer guarding the agent run it names. Also restore the blank line before run_agent_backtest (PEP 8 E301). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
backtest_status["data_source"] was set by the background runner and never read by anything, and it was the one key the finally block didn't reset, so it held the last run's source indefinitely. A run's provenance is already durable in the agent_runs metadata column and returned by the run endpoints and POST /backtest/run, so this was dead state, not a second source of truth. Document ENABLE_VNPY_SIMULATION in .env.example next to the other env knobs, and record the optional-dep test rule in CLAUDE.md so the next optional dependency doesn't rediscover the collection-abort failure mode. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The source-text guards pinned exact CSS/JS formatting, so a reformat or a quote-style change would turn them red with no behavior change. Match declarations inside a brace-counted @media block, and identifiers inside expressions, instead of literal substrings. Also record what these cannot do: CSS text proves a rule exists, not that anything renders. test_mobile_backtest_keeps_setup_controls_visible passed while the setup panel stayed hidden from 901-1200px (a pre-existing .left-panel display:none at max-width:1200px that the 900px rules never reach), so the old name overstated it. Renamed and documented. Split the "option is not hardcoded in markup" assertion into its own case -- it guards the feature gate, not the presence of controls. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Reviewed, and pushed fixes rather than sending it back — 4 commits, Was blockingCI was red, and had never run this PR's tests at all. Three modules import Gated them the way the optional
Also fixed
Left for you
Correction to my first readI initially flagged The boundary itself is good work — three-tier gate mapping cleanly to 422/403/503, laziness proven in a subprocess rather than by reading, SHA-256 instead of |
|
Merged as The three follow-ups above are now tracked, since notes on a merged PR don't get re-read:
One correction to my note above: after bar 78 the return is |
Summary
Scope
This PR covers simulated market data only. It does not connect TWS, IB Gateway, vnpy_ib, live quotes, or real order execution.
Safety
Test plan