|
PineForge v0.13.1-379-g9b50973
Deterministic PineScript v6 backtest runtime — C ABI reference
|
Data Structures | |
| class | BacktestEngine |
| class | BrokerStateHashProvider |
| class | BrokerStateHashSink |
| class | IExecutionConsumer |
| struct | NativeAccountObservation |
| The account row that follows an applied execution in the event history: the shared ordinal, the effective time, the marked equity, the realized balance and the signed book after it. More... | |
| struct | NativeAnchoredLevelView |
| Ephemeral read-only facts of one anchored-leg materialization (L7b), offered to the host exactly once, before the ArmedEvent is built. More... | |
| struct | NativeBeginArgs |
| Borrowed begin-call facts. More... | |
| struct | NativeCompleted |
| struct | NativeCurrentExecution |
| A synchronous execution of one request accepted or replaced in this very callback: a target handle and a price rule, and nothing else. More... | |
| struct | NativeCurrentExecutionPreview |
| Recomputed observations, never an apply token. More... | |
| struct | NativeCurrentPointView |
| What current_execution_point() answers inside a callback: the point's decision context, its price, which quote that price is, and the ordinal the quote came from. More... | |
| struct | NativeExecutionTermsFacts |
| Read-only owning-value facts for one candidate. More... | |
| struct | NativeFailed |
| struct | NativeFailure |
| The durable record native_state().failure answers: the code, the operation it happened in, an optional event ordinal and discriminator, and the allocation-free context. More... | |
| struct | NativeFailureContext |
| The three in-run facts a failure may carry, tagged by kind. More... | |
| struct | NativeFxCurveSetupResult |
| What configure_native_fx_curve answers: the status and, on refusal, the curve validation with the index of the first bad point. More... | |
| struct | NativeInputContext |
| Accepted input facts presented before the generic consumer aggregates the bar into its script interval or evaluates any matching point. More... | |
| struct | NativeInRunCause |
| The event ordinal a failure was caused by, 0 when absent. More... | |
| struct | NativeInRunCursor |
| Where on the modeled path a failure happened: the driver point's coordinate and its interpolation position t. More... | |
| struct | NativeInRunRecipient |
| The request incarnation a failure was addressed to, 0 when absent. More... | |
| struct | NativeMarginCallView |
| Ephemeral factual view of one kernel-issued liquidation before its units are fixed. More... | |
| struct | NativeMarginCheckPoint |
| Ephemeral factual view of one kernel check point, offered to the host before the check runs. More... | |
| struct | NativeMarginDecision |
| The host's answer to one requirement view. More... | |
| struct | NativeMarginRequirementView |
| Ephemeral factual view of the numbers the kernel is about to compare, at one check point, BEFORE the breach test. More... | |
| struct | NativeMarketEvent |
| One owning row of native_events(after_ordinal): a command event, a driver point or an account observation, tagged by kind. More... | |
| struct | NativeOpenLot |
| Owning value row for one open physical lot, copied at query time by native_open_lots(mark) — the lot-by-lot view of the same book physical_position() aggregates. More... | |
| struct | NativePhysicalPosition |
| The book as one aggregate: signed units, the volume-weighted average entry price and the number of open physical lots. More... | |
| struct | NativePrecommitView |
| Ephemeral factual view of one prepared execution before any physical effect. More... | |
| struct | NativeReady |
| struct | NativeRiskState |
| The run's generic risk ledger (L9), as the kernel holds it. More... | |
| struct | NativeRunning |
| struct | NativeSetupResult |
| What configure_native answers: the status and, on refusal, the first error field validate_native_run_spec found. More... | |
| struct | NativeStateView |
| The flattened run state native_state() answers: the lifecycle kind, a borrowed pointer to the staged spec (nullptr when Unconfigured), the phase, how a Completed run ended, the durable failure, the consumed run-number high water and the monotonic decision floor. More... | |
| class | NativeStrategyHost |
| The public native host: an abstract subclass of BacktestEngine with no PineScript on it. More... | |
| struct | NativeTickContext |
| One accepted realtime print before native matching at its current decision point. More... | |
| struct | NativeTimeframeBarContext |
| One completed higher-timeframe bucket of a declared subscription (NativeRunSpec::subscriptions), presented before the calculation of the input bar it is delivered on. More... | |
| struct | NativeTrailState |
| Read-only projection of a live generic Trail request. More... | |
| struct | NativeUnconfigured |
| The NativeLifecycle alternatives, one per NativeLifecycleKind. More... | |
| struct | NativeWorkingRequest |
| Owning value row for one live request, copied at query time. More... | |
Typedefs | |
| using | NativeLifecycle |
| The lifecycle as one value. Exhaustive over the five alternatives above. | |
| using | NativeCurrentExecutionResult |
| What execute_current answers: a refusal, or the applied outcome. | |
Enumerations | |
| enum class | NativeLifecycleKind : std::uint8_t { Unconfigured = 0 , Ready = 1 , Running = 2 , Completed = 3 , Failed = 4 } |
| Where a host stands. More... | |
| enum class | NativeRunPhase : std::uint8_t { Batch = 0 , Warmup = 1 , Realtime = 2 } |
| Which driving is Running: a batch run(), a stream's internal warmup, or its realtime leg. More... | |
| enum class | NativeCompletion : std::uint8_t { BatchComplete = 0 , StreamEnded = 1 } |
| How a Completed run ended: a batch reached the last bar, or a stream was ended. More... | |
| enum class | NativeFailureCode : std::uint16_t { None = 0 , InvalidSpecification = 1 , Contract = 2 , Preflight = 3 , UnsupportedSource = 4 , CallbackException = 5 , SettlementFailure = 6 , Allocation = 7 , CounterExhausted = 8 , Aborted = 9 , ProjectionMismatch = 10 , Calendar = 11 , Unexpected = 12 } |
| The durable first failure of a run, in NativeFailure::code. More... | |
| enum class | NativeFailureOperation : std::uint16_t { None = 0 , Configure = 1 , Begin = 2 , Command = 3 , Input = 4 , Callback = 5 , Settlement = 6 , Mutation = 7 , Stream = 8 } |
| Which operation was in flight when the failure latched — the second half of "what went wrong", beside NativeFailureCode. More... | |
| enum class | NativeFailureContextKind : std::uint8_t { None = 0 , Cause = 1 , Recipient = 2 , CauseRecipient = 3 , Cursor = 4 , CauseCursor = 5 , RecipientCursor = 6 , CauseRecipientCursor = 7 } |
| In-run failure references. More... | |
| enum class | NativeEventKind : std::uint8_t { Command = 0 , Driver = 1 , Account = 2 } |
| Which of NativeMarketEvent's three alternatives is populated. More... | |
| enum class | NativeSetupStatus : std::uint8_t { Applied = 0 , Failed = 1 } |
| Whether a setup call applied its value or refused it. More... | |
| enum class | NativeCurrentPriceRule : std::uint8_t { AsPresented = 0 , NearestTick = 1 } |
| Which price a current execution settles at: the active callback's quote as presented, or that quote on the instrument's nearest tick. More... | |
| enum class | NativeCurrentQuoteKind : std::uint8_t { MarketDecision = 0 , ExecutionAnchor = 1 } |
| Where a price came from: the callback's own market decision point, or the execution it is anchored to. More... | |
| enum class | NativePrecommitVerdict : std::uint8_t { Admit = 0 , Proceed = Admit , Refuse = 1 , AdmitWithHostMargin = 2 } |
| The host is consulted before generic opening-margin admission. More... | |
| enum class | NativeMarginCheckKind : std::uint32_t { BarOpen = 0 , AfterApplied = 1 , Calculation = 2 , FxRoll = 3 } |
| Which kernel check point is about to test the maintenance requirement. More... | |
| enum class | NativeAnchoredTrigger : std::uint8_t { Limit = 0 , Stop = 1 , TrailArm = 2 } |
| Which trigger of an anchored leg the owner's fill is about to supply. More... | |
| enum class | NativeRequestField : std::uint8_t { Comment = 0 , Label = 1 } |
| Which of a request's two free-text identity fields a bulk predicate reads. More... | |
| enum class | NativeCurrentRefusal : std::uint8_t { NoExecutionContext = 0 , Reentrant = 1 , InvalidHandle = 2 , NotWorking = 3 , NotAcceptedInCallback = 4 , UnsupportedRequest = 5 , UnreadyOwner = 6 , InvalidSelection = 7 , ConfigurationMismatch = 8 } |
| Why a current-execution command cannot be consumed here. More... | |
| enum class | NativeCalculationReason : std::uint8_t { BarClose = 0 , OrderFill = 1 , Tick = 2 , SubBar = 3 } |
| Why the kernel is asking the host to calculate. More... | |
Functions | |
| std::unique_ptr< IExecutionConsumer > | make_native_execution_consumer () |
| constexpr std::uint8_t | native_failure_context_bits (NativeFailureContextKind kind) noexcept |
| The bit-union under NativeFailureContextKind: Cause=1, Recipient=2, Cursor=4. | |
| constexpr bool | native_failure_has_cause (NativeFailureContextKind kind) noexcept |
| Whether a context of this kind populates its NativeInRunCause. | |
| constexpr bool | native_failure_has_recipient (NativeFailureContextKind kind) noexcept |
| Whether a context of this kind populates its NativeInRunRecipient. | |
| constexpr bool | native_failure_has_cursor (NativeFailureContextKind kind) noexcept |
| Whether a context of this kind populates its NativeInRunCursor. | |
| constexpr bool | native_failure_has_cause (const NativeFailureContext &context) noexcept |
| Whether this context populates its NativeInRunCause. | |
| constexpr bool | native_failure_has_recipient (const NativeFailureContext &context) noexcept |
| Whether this context populates its NativeInRunRecipient. | |
| constexpr bool | native_failure_has_cursor (const NativeFailureContext &context) noexcept |
| Whether this context populates its NativeInRunCursor. | |
| constexpr NativeFailureContextKind | native_failure_context_kind (bool cause, bool recipient, bool cursor) noexcept |
| The kind that says exactly these three alternatives are populated. | |
| NativeFailureContext | native_failure_cause (std::uint64_t ordinal) noexcept |
| A context carrying one causing event ordinal. | |
| NativeFailureContext | native_failure_recipient (std::uint64_t incarnation) noexcept |
| A context carrying one addressed request incarnation. | |
| NativeFailureContext | native_failure_cursor (NativeCoordinate point, double t=0.0) noexcept |
| A context carrying one path cursor. | |
| NativeFailureContext | native_failure_context_in_run (const native_order::RunIdentity &run, const native_order::EventId *cause, const native_order::RequestHandle *recipient, const native_order::MatchCursor *cursor) noexcept |
| Copies only ordinals/incarnation/cursor scalars. | |
| const native_order::RunIdentity * | native_failed_run_identity (const NativeFailed &failed) noexcept |
| The RunIdentity the failed spec carried, or nullptr when configure failed before staging one. | |
The lifecycle as one value. Exhaustive over the five alternatives above.
Definition at line 256 of file native_host.hpp.
What execute_current answers: a refusal, or the applied outcome.
Execution revalidates, so a preview obtained earlier is an observation and never an apply token.
Definition at line 670 of file native_host.hpp.
|
strong |
Where a host stands.
Read it off native_state().kind; nothing else reports it. Unconfigured is a fresh host, Ready a staged spec, Running a consumed begin (with NativeRunPhase saying which driving), Completed a finished run whose lots and live requests stay visible but not actionable, and Failed a durable first failure: discard the host, replay on a fresh instance, never reconfigure in place. Pinned by tests/test_native_host_repairs.cpp.
| Enumerator | |
|---|---|
| Unconfigured | |
| Ready | |
| Running | |
| Completed | |
| Failed | |
Definition at line 28 of file native_host.hpp.
|
strong |
Which driving is Running: a batch run(), a stream's internal warmup, or its realtime leg.
Folded into native_continuation_hash() on purpose — a consumer mid-warmup and one mid-realtime are not interchangeable continuations — which is why a batch and a stream over identical bars record different per-bar broker-state hashes while booking identical trades.
| Enumerator | |
|---|---|
| Batch | |
| Warmup | |
| Realtime | |
Definition at line 41 of file native_host.hpp.
|
strong |
How a Completed run ended: a batch reached the last bar, or a stream was ended.
Reporting only; the book, the report and every hash are what the run left.
| Enumerator | |
|---|---|
| BatchComplete | |
| StreamEnded | |
Definition at line 50 of file native_host.hpp.
|
strong |
The durable first failure of a run, in NativeFailure::code.
InvalidSpecification is a refused spec at configure, Contract a lifecycle misuse (a second configure, a run number at or under the high water), Preflight a bar array the driver refused, UnsupportedSource a source-only setter or command on a bare host, CallbackException a host callback that threw or a C callback that returned non-zero, and Aborted a cooperative abort. The rest are internal exhaustion states with no rollback promise. Set once and latched: later run / stream_* / configure_native calls refuse.
| Enumerator | |
|---|---|
| None | |
| InvalidSpecification | |
| Contract | |
| Preflight | |
| UnsupportedSource | |
| CallbackException | |
| SettlementFailure | |
| Allocation | |
| CounterExhausted | |
| Aborted | |
| ProjectionMismatch | |
| Calendar | |
| Unexpected | |
Definition at line 63 of file native_host.hpp.
|
strong |
Which operation was in flight when the failure latched — the second half of "what went wrong", beside NativeFailureCode.
Presentation only; the kernel takes no decision on it.
| Enumerator | |
|---|---|
| None | |
| Configure | |
| Begin | |
| Command | |
| Input | |
| Callback | |
| Settlement | |
| Mutation | |
| Stream | |
Definition at line 82 of file native_host.hpp.
|
strong |
In-run failure references.
Identifiers belong to NativeFailed.spec->identity; they never carry a second RunIdentity string. Kind is a bit-union of the typed alternatives below (Cause=1, Recipient=2, Cursor=4).
| Enumerator | |
|---|---|
| None | |
| Cause | |
| Recipient | |
| CauseRecipient | |
| Cursor | |
| CauseCursor | |
| RecipientCursor | |
| CauseRecipientCursor | |
Definition at line 97 of file native_host.hpp.
|
strong |
Which of NativeMarketEvent's three alternatives is populated.
| Enumerator | |
|---|---|
| Command | |
| Driver | |
| Account | |
Definition at line 360 of file native_host.hpp.
|
strong |
Whether a setup call applied its value or refused it.
Failed leaves engine storage untouched.
| Enumerator | |
|---|---|
| Applied | |
| Failed | |
Definition at line 380 of file native_host.hpp.
|
strong |
Which price a current execution settles at: the active callback's quote as presented, or that quote on the instrument's nearest tick.
Configured directional slippage applies once either way.
| Enumerator | |
|---|---|
| AsPresented | |
| NearestTick | |
Definition at line 401 of file native_host.hpp.
|
strong |
Where a price came from: the callback's own market decision point, or the execution it is anchored to.
A current execution inherits its cause's quote, so a chain does not compound slippage.
| Enumerator | |
|---|---|
| MarketDecision | |
| ExecutionAnchor | |
Definition at line 405 of file native_host.hpp.
|
strong |
The host is consulted before generic opening-margin admission.
Admit keeps the native default gate; AdmitWithHostMargin lets a host that owns the source-compatible margin rule take responsibility for that one check. Proceed remains an alias for the v7 spelling used by existing C++ callers.
| Enumerator | |
|---|---|
| Admit | |
| Proceed | |
| Refuse | |
| AdmitWithHostMargin | |
Definition at line 459 of file native_host.hpp.
|
strong |
Which kernel check point is about to test the maintenance requirement.
BarOpen is the script bar's open, after on_native_bar_open and before the bar's own matching; AfterApplied is the re-arm that follows a point's applied fills, which is the kernel's only mid-path check; Calculation is the script calculation of a CalculationOnly model; FxRoll is a step of the run's declared NativeFxCurve: the first driver point the account converts at a different rate than the point before it, offered immediately before that point is matched, with the price where the walk left it – the requirement moved though no price did. A run that declares no curve has no such point, and a CalculationOnly model, which measures at its calculation alone, is not offered it. These are the kernel's own points: a broker model that checks somewhere else is a host policy, expressed by suppressing the points it does not share.
| Enumerator | |
|---|---|
| BarOpen | |
| AfterApplied | |
| Calculation | |
| FxRoll | |
Definition at line 492 of file native_host.hpp.
|
strong |
Which trigger of an anchored leg the owner's fill is about to supply.
| Enumerator | |
|---|---|
| Limit | |
| Stop | |
| TrailArm | |
Definition at line 542 of file native_host.hpp.
|
strong |
Which of a request's two free-text identity fields a bulk predicate reads.
Both are host text the kernel only copies and compares: Comment is the established cancel_where selector and keeps value 0, Label is the field a host that names its orders puts its own id in.
| Enumerator | |
|---|---|
| Comment | |
| Label | |
Definition at line 633 of file native_host.hpp.
|
strong |
Why a current-execution command cannot be consumed here.
Every value is a fact about the command or the phase, never a host verdict: the host's own veto is validate_execution_precommit. strategy_native_execute_current_v1 answers the same verdicts in C.
| Enumerator | |
|---|---|
| NoExecutionContext | |
| Reentrant | |
| InvalidHandle | |
| NotWorking | |
| NotAcceptedInCallback | |
| UnsupportedRequest | |
| UnreadyOwner | |
| InvalidSelection | |
| ConfigurationMismatch | |
Definition at line 639 of file native_host.hpp.
|
strong |
Why the kernel is asking the host to calculate.
BarClose is the script bar's own calculation and is delivered for every run, whatever the spec's NativeCalculationTrigger is: every calculation is routed through on_native_recalculate, whose default forwards to on_native_bar, so a host that only implements on_native_bar sees exactly what it saw before. OrderFill is one recalculation at the cursor of an applied execution (NativeCalculationTrigger::BarCloseAndFills and above) and carries that event as its cause. Tick is one recalculation at a modeled path point or an observed print (NativeCalculationTrigger::EveryModeledPoint). SubBar is reserved: a lower-timeframe sub-bar has its own hook, on_native_sub_bar, and is never delivered through on_native_recalculate.
| Enumerator | |
|---|---|
| BarClose | |
| OrderFill | |
| Tick | |
| SubBar | |
Definition at line 758 of file native_host.hpp.
| std::unique_ptr< IExecutionConsumer > pineforge::engine_script_run_v18::make_native_execution_consumer | ( | ) |
|
constexprnoexcept |
The bit-union under NativeFailureContextKind: Cause=1, Recipient=2, Cursor=4.
Prefer the three predicates below to testing these bits by hand.
Definition at line 141 of file native_host.hpp.
|
constexprnoexcept |
Whether a context of this kind populates its NativeInRunCause.
Definition at line 145 of file native_host.hpp.
|
constexprnoexcept |
Whether a context of this kind populates its NativeInRunRecipient.
Definition at line 149 of file native_host.hpp.
|
constexprnoexcept |
Whether a context of this kind populates its NativeInRunCursor.
Definition at line 153 of file native_host.hpp.
|
constexprnoexcept |
Whether this context populates its NativeInRunCause.
The overload a reader of native_state().failure.context wants.
Definition at line 158 of file native_host.hpp.
|
constexprnoexcept |
Whether this context populates its NativeInRunRecipient.
Definition at line 162 of file native_host.hpp.
|
constexprnoexcept |
Whether this context populates its NativeInRunCursor.
Definition at line 166 of file native_host.hpp.
|
constexprnoexcept |
The kind that says exactly these three alternatives are populated.
Definition at line 171 of file native_host.hpp.
|
inlinenoexcept |
A context carrying one causing event ordinal.
A zero ordinal is "absent" and yields the None kind rather than a Cause with nothing in it.
Definition at line 179 of file native_host.hpp.
|
inlinenoexcept |
A context carrying one addressed request incarnation.
A zero incarnation is "absent", as above.
Definition at line 188 of file native_host.hpp.
|
inlinenoexcept |
A context carrying one path cursor.
A cursor is always meaningful, so there is no absent spelling.
Definition at line 197 of file native_host.hpp.
|
inlinenoexcept |
Copies only ordinals/incarnation/cursor scalars.
Foreign run identities are dropped rather than stored under the failed spec's identity.
Definition at line 207 of file native_host.hpp.
|
inlinenoexcept |
The RunIdentity the failed spec carried, or nullptr when configure failed before staging one.
This is how a caller names the run a failure belongs to without the failure carrying a second identity string of its own.
Definition at line 262 of file native_host.hpp.