Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data config: validate that the end time is set after the start time #1311

Merged
merged 2 commits into from
Oct 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions nautilus_trader/backtest/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from nautilus_trader.config import BacktestRunConfig
from nautilus_trader.config import BacktestVenueConfig
from nautilus_trader.core.correctness import PyCondition
from nautilus_trader.core.datetime import dt_to_unix_nanos
from nautilus_trader.core.inspect import is_nautilus_class
from nautilus_trader.core.nautilus_pyo3 import DataBackendSession
from nautilus_trader.model.currency import Currency
Expand Down Expand Up @@ -151,6 +152,16 @@ def _validate_configs(self, configs: list[BacktestRunConfig]) -> None:
for data_config in config.data:
if data_config.instrument_id is None:
continue # No instrument associated with data

if data_config.start_time is not None and data_config.end_time is not None:
start = dt_to_unix_nanos(data_config.start_time)
end = dt_to_unix_nanos(data_config.end_time)

if end < start:
raise ValueError(
f"Invalid data config: end_time ({data_config.end_time}) is before start_time ({data_config.start_time}).",
)

instrument_id: InstrumentId = InstrumentId.from_str(data_config.instrument_id)
if instrument_id.venue not in venue_ids:
raise ValueError(
Expand Down
Loading