Skip to main content

Module loaders

Module loaders 

Source
Expand description

Candle series loaders for backtests.

Phase 4b ships a single loader: a CSV reader with a fixed column layout. Parquet, JSON-lines, and exchange-native dumps are out-of-scope for v0.1 — they’re easy enough for users to write against crate::Backtest::with_candles.

§CSV format

time,open,high,low,close,volume
1700000000000,42000.0,42100.0,41900.0,42050.0,123.4
1700000060000,42050.0,42200.0,42030.0,42180.0,98.7
...
  • time is milliseconds since the UNIX epoch (i64).
  • The header row is required and column order is fixed.
  • Empty rows and rows beginning with # are skipped.

§Sort order

Candles are returned in the order they appear in the file. The Backtest engine assumes chronological order (oldest first); use sort_chronological if your source is newest-first.

Functions§

load_csv
Load candles from a CSV file. See the module docs for the expected format.
load_csv_str
Load candles from a CSV string (in-memory). Mostly useful for tests.
sort_chronological
Sort candles by time ascending. Stable — preserves order for candles with identical timestamps (rare, but exchange ticks sometimes coincide).