PineForge unreleased
Deterministic PineScript v6 backtest runtime — C ABI reference
Loading...
Searching...
No Matches
pf_native_decision_v1 Struct Reference

Where the kernel is, presented to every callback. More...

#include <native_c_api.h>

Data Fields

uint32_t struct_size
 sizeof(pf_native_decision_v1).
 
uint32_t version
 PF_NATIVE_API_VERSION.
 
uint64_t ordinal
 Matching-point ordinal.
 
int32_t interval_index
 Script interval index.
 
int32_t sub_index
 Sub-bar index inside the script bar.
 
int32_t sub_count
 Sub-bars in this script bar (1 when unmagnified).
 
int32_t is_terminal_sub_bar
 1 on the script bar's last sub-bar.
 
int64_t effective_time_ms
 The point's effective decision time.
 
int64_t script_bar_open_ms
 Open of the script bar under delivery.
 
int64_t sub_bar_open_ms
 Open of the sub-bar under delivery.
 
int64_t decision_floor_ms
 Lower bound a new request may be matched at.
 
double price
 Current quote, NaN outside an execution point.
 
uint8_t provenance
 pf_native_price_provenance_t.
 
uint8_t path_phase
 pf_native_path_phase_t.
 
uint8_t completion
 pf_native_completion_kind_t.
 
uint8_t quote_kind
 pf_native_quote_kind_t; 0 when price is NaN.
 
uint8_t session_facts
 1 when the three bytes below are written.
 
uint8_t in_session
 The script bar is in session.
 
uint8_t opens_session_day
 It opens its session day.
 
uint8_t closes_session_day
 It closes its session day.
 
int64_t script_interval_open_ms
 The script interval's nominal origin.
 
int64_t script_interval_eligible_open_ms
 Its first in-session instant.
 
int64_t script_interval_last_traded_close_ms
 Its exclusive end of trading.
 
int64_t script_interval_next_period_open_ms
 The next interval's nominal open, a closed slot included.
 
int64_t script_interval_next_input_open_ms
 The next actual eligible input open at or after that close: closed time skipped.
 
int64_t session_day_ordinal
 The session day of script_interval_open_ms – on a 1D script, of script_interval_eligible_open_ms when that is later (a D bar a daily stamp dates before its session opens): days since 1970-01-01 of its trading date.
 
int64_t next_input_session_day_ordinal
 The session day of script_interval_next_input_open_ms.
 
uint8_t has_script_interval
 1 when the point has a script interval; the seven fields above are 0 otherwise.
 
uint8_t has_session_day
 1 when the calendar keyed session_day_ordinal.
 
uint8_t has_next_input_session_day
 1 when it keyed next_input_session_day_ordinal.
 
uint8_t reserved0 [5]
 Always 0.
 

Detailed Description

Where the kernel is, presented to every callback.

A read-only snapshot of NativeDecisionContext plus the current quote: price is current_execution_point()'s price (the bar's own close at its close calculation) and NaN only where that answers nullopt.

It has TWO published layouts. A callback table sent at PF_NATIVE_CALLBACKS_V1_POLICY_SIZE or the current sizeof receives the whole struct and its session tail. A table sent at an earlier published length receives struct_size = PF_NATIVE_DECISION_V1_BASE_SIZE — the sizeof that earlier caller's header compiled — and nothing past it is filled. A caller reads a field only below the presented struct_size.

The four session-day bytes after quote_kind (R5 lane F5) sit in what was the base layout's tail padding: its size and every offset before them are the ones a caller compiled against the first layout reads, so that caller keeps working unchanged, and a table of either length is handed them. session_facts is 1 when the runtime wrote the three after it, and 0 from a runtime that predates them. Each is 0 or 1, and every callback of one script bar carries the same values:

  • in_session: the script bar's label is in session on the run's own calendar (session / timezone);
  • opens_session_day: in session, and the bar before it is not, or is on another session day;
  • closes_session_day: in session, and the bar after it is not, or is on another session day. The session day is the run calendar's (it rolls at the first window's start and is keyed to its trading date, so an overnight session is one day across local midnight). The bar before / after is the one the run holds – the batch input or stream warmup – and otherwise the calendar's slot one script width away; a run's first bar opens its day and a batch's final bar closes it. A D/W/M bar holds whole days: all three are 1. The C++ context's fourth fact, closes_session_day_open_ended, has no byte here: it differs only on a batch's final bar, for a host that recomputes a batch whose last input is still forming, and a C host's live edge is a stream, whose closes_session_day already reads the calendar.

The session tail is the script interval under delivery and the session day of its open (on a 1D script, of its first in-session instant when that is later) and of the NEXT input's open, on the run's own calendar (its session and timezone): the calendar facts under the session-day bytes above, for a host that applies a rule of its own. On the calendar alone, a script bar is the last of its session day when next_input_session_day_ordinal differs from session_day_ordinal, and the first when the bar before it was the last.

Definition at line 1491 of file native_c_api.h.

Field Documentation

◆ struct_size

uint32_t pf_native_decision_v1::struct_size

sizeof(pf_native_decision_v1).

Definition at line 1492 of file native_c_api.h.

◆ version

uint32_t pf_native_decision_v1::version

PF_NATIVE_API_VERSION.

Definition at line 1493 of file native_c_api.h.

◆ ordinal

uint64_t pf_native_decision_v1::ordinal

Matching-point ordinal.

Definition at line 1494 of file native_c_api.h.

◆ interval_index

int32_t pf_native_decision_v1::interval_index

Script interval index.

Definition at line 1495 of file native_c_api.h.

◆ sub_index

int32_t pf_native_decision_v1::sub_index

Sub-bar index inside the script bar.

Definition at line 1496 of file native_c_api.h.

◆ sub_count

int32_t pf_native_decision_v1::sub_count

Sub-bars in this script bar (1 when unmagnified).

Definition at line 1497 of file native_c_api.h.

◆ is_terminal_sub_bar

int32_t pf_native_decision_v1::is_terminal_sub_bar

1 on the script bar's last sub-bar.

Definition at line 1498 of file native_c_api.h.

◆ effective_time_ms

int64_t pf_native_decision_v1::effective_time_ms

The point's effective decision time.

Definition at line 1499 of file native_c_api.h.

◆ script_bar_open_ms

int64_t pf_native_decision_v1::script_bar_open_ms

Open of the script bar under delivery.

Definition at line 1500 of file native_c_api.h.

◆ sub_bar_open_ms

int64_t pf_native_decision_v1::sub_bar_open_ms

Open of the sub-bar under delivery.

Definition at line 1501 of file native_c_api.h.

◆ decision_floor_ms

int64_t pf_native_decision_v1::decision_floor_ms

Lower bound a new request may be matched at.

Definition at line 1502 of file native_c_api.h.

◆ price

double pf_native_decision_v1::price

Current quote, NaN outside an execution point.

Definition at line 1503 of file native_c_api.h.

◆ provenance

uint8_t pf_native_decision_v1::provenance

pf_native_price_provenance_t.

Definition at line 1504 of file native_c_api.h.

◆ path_phase

uint8_t pf_native_decision_v1::path_phase

pf_native_path_phase_t.

Definition at line 1505 of file native_c_api.h.

◆ completion

uint8_t pf_native_decision_v1::completion

pf_native_completion_kind_t.

Definition at line 1506 of file native_c_api.h.

◆ quote_kind

uint8_t pf_native_decision_v1::quote_kind

pf_native_quote_kind_t; 0 when price is NaN.

Definition at line 1507 of file native_c_api.h.

◆ session_facts

uint8_t pf_native_decision_v1::session_facts

1 when the three bytes below are written.

Definition at line 1508 of file native_c_api.h.

◆ in_session

uint8_t pf_native_decision_v1::in_session

The script bar is in session.

Definition at line 1509 of file native_c_api.h.

◆ opens_session_day

uint8_t pf_native_decision_v1::opens_session_day

It opens its session day.

Definition at line 1510 of file native_c_api.h.

◆ closes_session_day

uint8_t pf_native_decision_v1::closes_session_day

It closes its session day.

Definition at line 1511 of file native_c_api.h.

◆ script_interval_open_ms

int64_t pf_native_decision_v1::script_interval_open_ms

The script interval's nominal origin.

Definition at line 1515 of file native_c_api.h.

◆ script_interval_eligible_open_ms

int64_t pf_native_decision_v1::script_interval_eligible_open_ms

Its first in-session instant.

Definition at line 1516 of file native_c_api.h.

◆ script_interval_last_traded_close_ms

int64_t pf_native_decision_v1::script_interval_last_traded_close_ms

Its exclusive end of trading.

Definition at line 1517 of file native_c_api.h.

◆ script_interval_next_period_open_ms

int64_t pf_native_decision_v1::script_interval_next_period_open_ms

The next interval's nominal open, a closed slot included.

Definition at line 1518 of file native_c_api.h.

◆ script_interval_next_input_open_ms

int64_t pf_native_decision_v1::script_interval_next_input_open_ms

The next actual eligible input open at or after that close: closed time skipped.

Definition at line 1520 of file native_c_api.h.

◆ session_day_ordinal

int64_t pf_native_decision_v1::session_day_ordinal

The session day of script_interval_open_ms – on a 1D script, of script_interval_eligible_open_ms when that is later (a D bar a daily stamp dates before its session opens): days since 1970-01-01 of its trading date.

Definition at line 1523 of file native_c_api.h.

◆ next_input_session_day_ordinal

int64_t pf_native_decision_v1::next_input_session_day_ordinal

The session day of script_interval_next_input_open_ms.

Definition at line 1531 of file native_c_api.h.

◆ has_script_interval

uint8_t pf_native_decision_v1::has_script_interval

1 when the point has a script interval; the seven fields above are 0 otherwise.

Definition at line 1533 of file native_c_api.h.

◆ has_session_day

uint8_t pf_native_decision_v1::has_session_day

1 when the calendar keyed session_day_ordinal.

Definition at line 1536 of file native_c_api.h.

◆ has_next_input_session_day

uint8_t pf_native_decision_v1::has_next_input_session_day

1 when it keyed next_input_session_day_ordinal.

Definition at line 1538 of file native_c_api.h.

◆ reserved0

uint8_t pf_native_decision_v1::reserved0[5]

Always 0.

Definition at line 1540 of file native_c_api.h.


The documentation for this struct was generated from the following file: