sim_platform.research.forward¶
Forward testing: run a method on market data as it arrives, in shadow mode.
A forward test is the only fully out-of-sample test: the data did not exist when the
method was built. ForwardTest polls a bar feed; whenever new bars arrive it appends
them to a growing price-bar recording and runs the method over just those bars on the
same simulated account, so positions and cash carry from one segment to the next. Each
segment is an ordinary run with its own lineage, and an append-only arrival log records
when each batch of bars arrived (wall-clock UTC), the recording’s digest at that time
and the run that traded it, so anyone can check that every decision came after its data.
Shadow mode is the only mode: Market Lab has no broker connection, so orders always go to the simulated execution and never to a real market.
A feed is any object with bars(after) returning bar rows (date and, for
intraday bars, time; open, high, low, close, volume) newer than
the ISO date-time text after (None for all). CsvFeed reads a vendor CSV that an
external job keeps up to date. Method state does not carry between segments, except an
Agent’s notes, which it can read back with journal tools; rules start fresh.
- class sim_platform.research.forward.BarFeed(*args, **kwargs)[source]¶
Bases:
ProtocolNew bars after a point in time; may return nothing.
- class sim_platform.research.forward.CsvFeed(path)[source]¶
Bases:
objectBars from a CSV (Date[,Time],Open,High,Low,Close,Volume) that grows over time.
- Parameters:
path (PathInput)
- class sim_platform.research.forward.ForwardTest(platform, profile, account, feed, folder, *, symbol, method='rule', settings=None, agent_id=None, revision=None, configure=None, execution_config=None)[source]¶
Bases:
objectShadow trading on arriving bars: one run per batch, on one account.
- Parameters:
platform (Any) – An open Platform.
profile (str) – Profile that owns the account and Agent.
account (str) – Simulated account that carries positions between segments.
feed (BarFeed) – The bar source (
BarFeed).folder (PathInput) – Where the growing recording and the arrival log are kept.
symbol (str) – The symbol the bars describe.
method (str) – ‘rule’, ‘hold’, ‘model’ or ‘agent’.
settings (Optional[Dict[str, Any]]) – The method’s settings; for an Agent, complete Agent settings whose
start_ns/end_nsare replaced for each segment.agent_id (Optional[str]) – The saved Agent (method ‘agent’).
revision (Optional[int]) – The saved Agent (method ‘agent’).
configure (Optional[Callable[[Any], Any]]) – For an Agent,
configure(experiment)configures its model (for examplelambda e: app.configure_experiment_model(e, profile)).execution_config (Optional[Any]) – Execution settings for every segment.
- segments()[source]¶
Every recorded segment: arrival time, bars, recording digest and run ID.
- Return type:
List[Dict[str, Any]]