PineForge v1.4.0-4-g873b25da
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...

Data Structures

struct  pf_stream_order_action_t
 One physical emulator lot action. 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_api_version (void)
 Native live extension version (1).
 
int strategy_stream_push_bar (pf_strategy_t s, const pf_bar_t *bar)
 Consume one confirmed input-timeframe bar.
 
int strategy_stream_order_actions_len (pf_strategy_t s)
 Queued physical fills since the last clear, in execution order.
 
int strategy_stream_order_action_get (pf_strategy_t s, int index, pf_stream_order_action_t *out)
 Copy one action; return 0 on success, -1 on invalid handle/index/output.
 
void strategy_stream_order_actions_clear (pf_strategy_t s)
 Clear observed events after the caller durably journals them.
 
uint64_t strategy_stream_state_hash (pf_strategy_t s)
 Versioned deterministic fingerprint of observable broker/stream state.
 
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.

A generated Pine strategy using this entry point rejects calc_on_order_fills, historical probe/tail overrides, timestamped FX and auxiliary/native security feeds. A C native host can also use this entry point and accepts the native FX curve, auxiliary feeds and calculation trigger where its run specification permits them.

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

References PF_API.

◆ strategy_stream_api_version()

int strategy_stream_api_version ( void )

Native live extension version (1).

Additive to ABI v4; callers must probe this symbol before using the confirmed-bar/action API in older modules.

References PF_API.

◆ strategy_stream_push_bar()

int strategy_stream_push_bar ( pf_strategy_t s,
const pf_bar_t * bar )

Consume one confirmed input-timeframe bar.

Its script-timeframe aggregate uses the existing batch OHLC fill kernel when complete. Close-only strategy calculation; no bar magnifier or synthetic trade ticks. The first tick/bar locks the feed mode. Off-grid/out-of-order data, invalid OHLCV and missing in-session bars fail. Calendar-closed intervals may be skipped. No padding. Returns 0/-1. On ANY input-processing failure discard/recover the instance: the operation is not transactional and can have advanced native state.

References PF_API.

◆ strategy_stream_order_actions_len()

int strategy_stream_order_actions_len ( pf_strategy_t s)

Queued physical fills since the last clear, in execution order.

Historical warmup and report-only range-end rows never enqueue. Sequence starts at 1 after warmup and is not reset by clear. Returns -1 on a null handle.

References PF_API.

◆ strategy_stream_order_action_get()

int strategy_stream_order_action_get ( pf_strategy_t s,
int index,
pf_stream_order_action_t * out )

Copy one action; return 0 on success, -1 on invalid handle/index/output.

References PF_API.

◆ strategy_stream_order_actions_clear()

void strategy_stream_order_actions_clear ( pf_strategy_t s)

Clear observed events after the caller durably journals them.

References PF_API.

◆ strategy_stream_state_hash()

uint64_t strategy_stream_state_hash ( pf_strategy_t s)

Versioned deterministic fingerprint of observable broker/stream state.

Excludes the consumable queue and arbitrary private strategy members. This is a replay check, not a complete state snapshot or cryptographic hash. Fresh replay must use deterministic strategy code, the same pinned engine build and configuration. The fingerprint's recipe belongs to the script ABI epoch: from 1.0.0 it is fixed for every 1.x engine (engine_script_run_v19), and a new recipe is a new epoch; a value from a build before 1.0.0 is not comparable. Returns 0 for NULL.

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, or with strategy_native_report_free_v1 by a host that links the kernel archive, which has no report_free.

References PF_API.