Skip to content

feat: implement spec-02 — signals, CSV loader, BacktestEngine, and CLI#4

Merged
tommed merged 3 commits intomainfrom
feat/spec-02-signals-cli
Apr 6, 2026
Merged

feat: implement spec-02 — signals, CSV loader, BacktestEngine, and CLI#4
tommed merged 3 commits intomainfrom
feat/spec-02-signals-cli

Conversation

@tommed
Copy link
Copy Markdown
Contributor

@tommed tommed commented Apr 6, 2026

Summary

  • Signal system (signals/) — SignalProvider protocol, SignalRegistry, CsvSignalProvider with publication_offset for look-ahead bias prevention
  • BacktestEngine (engines/backtest.py) — DA-only replay with simulated clock, wires signals into TradingContext
  • Analysis (analysis/) — PnL calculation, VWAP benchmark comparison, metrics (win rate, volume, trade count)
  • Data loading (data/) — ParquetLoader for DA clearing prices, standard Parquet schema
  • CLI (cli/main.py) — nexa run command (algo path, exchange, products, date range, data dir)
  • Example (examples/simple_da_algo.py) — runnable algo using a price forecast signal
  • Updated pyproject.toml: promoted pandas and click to core deps, added nexa script entry point, added pandas-stubs dev dep

Test plan

  • make ci passes (lint + typecheck + tests)
  • nexa run examples/simple_da_algo.py --exchange nordpool --products NO1_DA --start 2026-03-01 --end 2026-03-31 --data-dir tests/fixtures runs end-to-end
  • Signal look-ahead bias: values before current_time + publication_offset are not visible
  • CsvSignalProvider correctly parses timezone-aware timestamps

🤖 Generated with Claude Code

Adds the signal system with look-ahead bias prevention via
publication_offset, CsvSignalProvider, SignalRegistry wired into
BacktestEngine and TradingContext, the `nexa run` CLI, full PnL/VWAP/
metrics analysis, and the DA data loading layer.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

tommed and others added 2 commits April 6, 2026 15:16
… _load_module

- cancel_order success path (backtest.py:152-153) was untested
- get_signal_history (backtest.py:250-251) was never called in tests
- spec_from_file_location returning None (cli/main.py:123) was untested

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@tommed tommed merged commit 3c9e547 into main Apr 6, 2026
1 check passed
@tommed tommed deleted the feat/spec-02-signals-cli branch April 6, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant