PineForge v0.10.14-68-g9734d48
Deterministic PineScript v6 backtest runtime — C ABI reference
Loading...
Searching...
No Matches
Historical to realtime streaming

Warm on confirmed OHLCV and continue the same strategy instance on normalized ordered trades from any data source. More...

Functions

int strategy_stream_begin (pf_strategy_t s, const pf_bar_t *warmup_bars, int n_warmup, const char *input_tf, const char *script_tf)
 Warm a strategy with confirmed OHLCV, then switch the same instance to a realtime trade stream without resetting position, equity, pending orders, Pine variables, TA state, request.security state, or timeframe aggregation.
 
int strategy_stream_push_tick (pf_strategy_t s, const pf_trade_tick_t *tick)
 Push one normalized realtime trade.
 
int strategy_stream_push_ticks (pf_strategy_t s, const pf_trade_tick_t *ticks, int n)
 Push an ordered batch of realtime trades.
 
int strategy_stream_advance_time (pf_strategy_t s, int64_t timestamp_ms)
 Advance the stream clock and close every input bar whose end is <= the supplied time.
 
int strategy_stream_end (pf_strategy_t s, int finalize_partial_input_bar)
 End a realtime stream.
 
int strategy_stream_fill_report (pf_strategy_t s, pf_report_t *out)
 Snapshot the cumulative warmup + realtime report.
 

Detailed Description

Warm on confirmed OHLCV and continue the same strategy instance on normalized ordered trades from any data source.

Function Documentation

◆ strategy_stream_begin()

int strategy_stream_begin ( pf_strategy_t s,
const pf_bar_t * warmup_bars,
int n_warmup,
const char * input_tf,
const char * script_tf )

Warm a strategy with confirmed OHLCV, then switch the same instance to a realtime trade stream without resetting position, equity, pending orders, Pine variables, TA state, request.security state, or timeframe aggregation.

The warmup must contain at least one complete fixed-duration input bar. Normalized ticks start at or after the next input bar's open. This lifecycle uses close-only strategy calculation (the Pine strategy default) while resting broker orders are evaluated on every normalized trade.

Returns
0 on success, -1 on failure. Inspect strategy_get_last_error.

References PF_API.

◆ strategy_stream_push_tick()

int strategy_stream_push_tick ( pf_strategy_t s,
const pf_trade_tick_t * tick )

Push one normalized realtime trade.

Returns 0 on success, -1 on failure.

References PF_API.

◆ strategy_stream_push_ticks()

int strategy_stream_push_ticks ( pf_strategy_t s,
const pf_trade_tick_t * ticks,
int n )

Push an ordered batch of realtime trades.

Semantically identical to repeated strategy_stream_push_tick calls, with lower FFI overhead.

References PF_API.

◆ strategy_stream_advance_time()

int strategy_stream_advance_time ( pf_strategy_t s,
int64_t timestamp_ms )

Advance the stream clock and close every input bar whose end is <= the supplied time.

Quiet in-session intervals become zero-volume carry-forward bars; intervals outside the configured syminfo session are skipped.

References PF_API.

◆ strategy_stream_end()

int strategy_stream_end ( pf_strategy_t s,
int finalize_partial_input_bar )

End a realtime stream.

When finalize_partial_input_bar is non-zero, the currently forming input bar is dispatched before ending; normally callers should first advance to a confirmed boundary and pass zero here.

References PF_API.

◆ strategy_stream_fill_report()

int strategy_stream_fill_report ( pf_strategy_t s,
pf_report_t * out )

Snapshot the cumulative warmup + realtime report.

The embedded arrays are caller-owned after return and must be released with report_free.

References PF_API.