PineForge v0.13.1-379-g9b50973
Deterministic PineScript v6 backtest runtime — C ABI reference
Loading...
Searching...
No Matches
native_host.hpp File Reference
#include <pineforge/engine.hpp>
#include <pineforge/market_driver.hpp>
#include <pineforge/native_fx_curve.hpp>
#include <pineforge/native_order.hpp>
#include <pineforge/native_run_spec.hpp>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <optional>
#include <string>
#include <string_view>
#include <type_traits>
#include <variant>
#include <vector>
Include dependency graph for native_host.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pineforge::engine_script_run_v18::NativeInRunCause
 The event ordinal a failure was caused by, 0 when absent. More...
 
struct  pineforge::engine_script_run_v18::NativeInRunRecipient
 The request incarnation a failure was addressed to, 0 when absent. More...
 
struct  pineforge::engine_script_run_v18::NativeInRunCursor
 Where on the modeled path a failure happened: the driver point's coordinate and its interpolation position t. More...
 
struct  pineforge::engine_script_run_v18::NativeFailureContext
 The three in-run facts a failure may carry, tagged by kind. More...
 
struct  pineforge::engine_script_run_v18::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  pineforge::engine_script_run_v18::NativeUnconfigured
 The NativeLifecycle alternatives, one per NativeLifecycleKind. More...
 
struct  pineforge::engine_script_run_v18::NativeReady
 
struct  pineforge::engine_script_run_v18::NativeRunning
 
struct  pineforge::engine_script_run_v18::NativeCompleted
 
struct  pineforge::engine_script_run_v18::NativeFailed
 
struct  pineforge::engine_script_run_v18::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...
 
struct  pineforge::engine_script_run_v18::NativePhysicalPosition
 The book as one aggregate: signed units, the volume-weighted average entry price and the number of open physical lots. More...
 
struct  pineforge::engine_script_run_v18::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  pineforge::engine_script_run_v18::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  pineforge::engine_script_run_v18::NativeMarketEvent
 One owning row of native_events(after_ordinal): a command event, a driver point or an account observation, tagged by kind. More...
 
struct  pineforge::engine_script_run_v18::NativeSetupResult
 What configure_native answers: the status and, on refusal, the first error field validate_native_run_spec found. More...
 
struct  pineforge::engine_script_run_v18::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  pineforge::engine_script_run_v18::NativeExecutionTermsFacts
 Read-only owning-value facts for one candidate. More...
 
struct  pineforge::engine_script_run_v18::NativePrecommitView
 Ephemeral factual view of one prepared execution before any physical effect. More...
 
struct  pineforge::engine_script_run_v18::NativeMarginCallView
 Ephemeral factual view of one kernel-issued liquidation before its units are fixed. More...
 
struct  pineforge::engine_script_run_v18::NativeMarginCheckPoint
 Ephemeral factual view of one kernel check point, offered to the host before the check runs. More...
 
struct  pineforge::engine_script_run_v18::NativeMarginRequirementView
 Ephemeral factual view of the numbers the kernel is about to compare, at one check point, BEFORE the breach test. More...
 
struct  pineforge::engine_script_run_v18::NativeMarginDecision
 The host's answer to one requirement view. More...
 
struct  pineforge::engine_script_run_v18::NativeAnchoredLevelView
 Ephemeral read-only facts of one anchored-leg materialization (L7b), offered to the host exactly once, before the ArmedEvent is built. More...
 
struct  pineforge::engine_script_run_v18::NativeRiskState
 The run's generic risk ledger (L9), as the kernel holds it. More...
 
struct  pineforge::engine_script_run_v18::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  pineforge::engine_script_run_v18::NativeTrailState
 Read-only projection of a live generic Trail request. More...
 
struct  pineforge::engine_script_run_v18::NativeWorkingRequest
 Owning value row for one live request, copied at query time. More...
 
struct  pineforge::engine_script_run_v18::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  pineforge::engine_script_run_v18::NativeCurrentExecutionPreview
 Recomputed observations, never an apply token. More...
 
struct  pineforge::engine_script_run_v18::NativeBeginArgs
 Borrowed begin-call facts. More...
 
struct  pineforge::engine_script_run_v18::NativeInputContext
 Accepted input facts presented before the generic consumer aggregates the bar into its script interval or evaluates any matching point. More...
 
struct  pineforge::engine_script_run_v18::NativeTickContext
 One accepted realtime print before native matching at its current decision point. More...
 
struct  pineforge::engine_script_run_v18::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...
 
class  pineforge::engine_script_run_v18::NativeStrategyHost
 The public native host: an abstract subclass of BacktestEngine with no PineScript on it. More...
 

Namespaces

namespace  pineforge
 
namespace  pineforge::engine_script_run_v18
 

Macros

#define PINEFORGE_HAS_NATIVE_STRATEGY_HOST_V18   1
 

Typedefs

using pineforge::engine_script_run_v18::NativeLifecycle
 The lifecycle as one value. Exhaustive over the five alternatives above.
 
using pineforge::engine_script_run_v18::NativeCurrentExecutionResult
 What execute_current answers: a refusal, or the applied outcome.
 

Enumerations

enum class  pineforge::engine_script_run_v18::NativeLifecycleKind : std::uint8_t {
  pineforge::engine_script_run_v18::Unconfigured = 0 ,
  pineforge::engine_script_run_v18::Ready = 1 ,
  pineforge::engine_script_run_v18::Running = 2 ,
  pineforge::engine_script_run_v18::Completed = 3 ,
  pineforge::engine_script_run_v18::Failed = 4
}
 Where a host stands. More...
 
enum class  pineforge::engine_script_run_v18::NativeRunPhase : std::uint8_t {
  pineforge::engine_script_run_v18::Batch = 0 ,
  pineforge::engine_script_run_v18::Warmup = 1 ,
  pineforge::engine_script_run_v18::Realtime = 2
}
 Which driving is Running: a batch run(), a stream's internal warmup, or its realtime leg. More...
 
enum class  pineforge::engine_script_run_v18::NativeCompletion : std::uint8_t {
  pineforge::engine_script_run_v18::BatchComplete = 0 ,
  pineforge::engine_script_run_v18::StreamEnded = 1
}
 How a Completed run ended: a batch reached the last bar, or a stream was ended. More...
 
enum class  pineforge::engine_script_run_v18::NativeFailureCode : std::uint16_t {
  pineforge::engine_script_run_v18::None = 0 ,
  pineforge::engine_script_run_v18::InvalidSpecification = 1 ,
  pineforge::engine_script_run_v18::Contract = 2 ,
  pineforge::engine_script_run_v18::Preflight = 3 ,
  pineforge::engine_script_run_v18::UnsupportedSource = 4 ,
  pineforge::engine_script_run_v18::CallbackException = 5 ,
  pineforge::engine_script_run_v18::SettlementFailure = 6 ,
  pineforge::engine_script_run_v18::Allocation = 7 ,
  pineforge::engine_script_run_v18::CounterExhausted = 8 ,
  pineforge::engine_script_run_v18::Aborted = 9 ,
  pineforge::engine_script_run_v18::ProjectionMismatch = 10 ,
  pineforge::engine_script_run_v18::Calendar = 11 ,
  pineforge::engine_script_run_v18::Unexpected = 12
}
 The durable first failure of a run, in NativeFailure::code. More...
 
enum class  pineforge::engine_script_run_v18::NativeFailureOperation : std::uint16_t {
  pineforge::engine_script_run_v18::None = 0 ,
  pineforge::engine_script_run_v18::Configure = 1 ,
  pineforge::engine_script_run_v18::Begin = 2 ,
  pineforge::engine_script_run_v18::Command = 3 ,
  pineforge::engine_script_run_v18::Input = 4 ,
  pineforge::engine_script_run_v18::Callback = 5 ,
  pineforge::engine_script_run_v18::Settlement = 6 ,
  pineforge::engine_script_run_v18::Mutation = 7 ,
  pineforge::engine_script_run_v18::Stream = 8
}
 Which operation was in flight when the failure latched — the second half of "what went wrong", beside NativeFailureCode. More...
 
enum class  pineforge::engine_script_run_v18::NativeFailureContextKind : std::uint8_t {
  pineforge::engine_script_run_v18::None = 0 ,
  pineforge::engine_script_run_v18::Cause = 1 ,
  pineforge::engine_script_run_v18::Recipient = 2 ,
  pineforge::engine_script_run_v18::CauseRecipient = 3 ,
  pineforge::engine_script_run_v18::Cursor = 4 ,
  pineforge::engine_script_run_v18::CauseCursor = 5 ,
  pineforge::engine_script_run_v18::RecipientCursor = 6 ,
  pineforge::engine_script_run_v18::CauseRecipientCursor = 7
}
 In-run failure references. More...
 
enum class  pineforge::engine_script_run_v18::NativeEventKind : std::uint8_t {
  pineforge::engine_script_run_v18::Command = 0 ,
  pineforge::engine_script_run_v18::Driver = 1 ,
  pineforge::engine_script_run_v18::Account = 2
}
 Which of NativeMarketEvent's three alternatives is populated. More...
 
enum class  pineforge::engine_script_run_v18::NativeSetupStatus : std::uint8_t {
  pineforge::engine_script_run_v18::Applied = 0 ,
  pineforge::engine_script_run_v18::Failed = 1
}
 Whether a setup call applied its value or refused it. More...
 
enum class  pineforge::engine_script_run_v18::NativeCurrentPriceRule : std::uint8_t {
  pineforge::engine_script_run_v18::AsPresented = 0 ,
  pineforge::engine_script_run_v18::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  pineforge::engine_script_run_v18::NativeCurrentQuoteKind : std::uint8_t {
  pineforge::engine_script_run_v18::MarketDecision = 0 ,
  pineforge::engine_script_run_v18::ExecutionAnchor = 1
}
 Where a price came from: the callback's own market decision point, or the execution it is anchored to. More...
 
enum class  pineforge::engine_script_run_v18::NativePrecommitVerdict : std::uint8_t {
  pineforge::engine_script_run_v18::Admit = 0 ,
  pineforge::engine_script_run_v18::Proceed = Admit ,
  pineforge::engine_script_run_v18::Refuse = 1 ,
  pineforge::engine_script_run_v18::AdmitWithHostMargin = 2
}
 The host is consulted before generic opening-margin admission. More...
 
enum class  pineforge::engine_script_run_v18::NativeMarginCheckKind : std::uint32_t {
  pineforge::engine_script_run_v18::BarOpen = 0 ,
  pineforge::engine_script_run_v18::AfterApplied = 1 ,
  pineforge::engine_script_run_v18::Calculation = 2 ,
  pineforge::engine_script_run_v18::FxRoll = 3
}
 Which kernel check point is about to test the maintenance requirement. More...
 
enum class  pineforge::engine_script_run_v18::NativeAnchoredTrigger : std::uint8_t {
  pineforge::engine_script_run_v18::Limit = 0 ,
  pineforge::engine_script_run_v18::Stop = 1 ,
  pineforge::engine_script_run_v18::TrailArm = 2
}
 Which trigger of an anchored leg the owner's fill is about to supply. More...
 
enum class  pineforge::engine_script_run_v18::NativeRequestField : std::uint8_t {
  pineforge::engine_script_run_v18::Comment = 0 ,
  pineforge::engine_script_run_v18::Label = 1
}
 Which of a request's two free-text identity fields a bulk predicate reads. More...
 
enum class  pineforge::engine_script_run_v18::NativeCurrentRefusal : std::uint8_t {
  pineforge::engine_script_run_v18::NoExecutionContext = 0 ,
  pineforge::engine_script_run_v18::Reentrant = 1 ,
  pineforge::engine_script_run_v18::InvalidHandle = 2 ,
  pineforge::engine_script_run_v18::NotWorking = 3 ,
  pineforge::engine_script_run_v18::NotAcceptedInCallback = 4 ,
  pineforge::engine_script_run_v18::UnsupportedRequest = 5 ,
  pineforge::engine_script_run_v18::UnreadyOwner = 6 ,
  pineforge::engine_script_run_v18::InvalidSelection = 7 ,
  pineforge::engine_script_run_v18::ConfigurationMismatch = 8
}
 Why a current-execution command cannot be consumed here. More...
 
enum class  pineforge::engine_script_run_v18::NativeCalculationReason : std::uint8_t {
  pineforge::engine_script_run_v18::BarClose = 0 ,
  pineforge::engine_script_run_v18::OrderFill = 1 ,
  pineforge::engine_script_run_v18::Tick = 2 ,
  pineforge::engine_script_run_v18::SubBar = 3
}
 Why the kernel is asking the host to calculate. More...
 

Functions

constexpr std::uint8_t pineforge::engine_script_run_v18::native_failure_context_bits (NativeFailureContextKind kind) noexcept
 The bit-union under NativeFailureContextKind: Cause=1, Recipient=2, Cursor=4.
 
constexpr bool pineforge::engine_script_run_v18::native_failure_has_cause (NativeFailureContextKind kind) noexcept
 Whether a context of this kind populates its NativeInRunCause.
 
constexpr bool pineforge::engine_script_run_v18::native_failure_has_recipient (NativeFailureContextKind kind) noexcept
 Whether a context of this kind populates its NativeInRunRecipient.
 
constexpr bool pineforge::engine_script_run_v18::native_failure_has_cursor (NativeFailureContextKind kind) noexcept
 Whether a context of this kind populates its NativeInRunCursor.
 
constexpr bool pineforge::engine_script_run_v18::native_failure_has_cause (const NativeFailureContext &context) noexcept
 Whether this context populates its NativeInRunCause.
 
constexpr bool pineforge::engine_script_run_v18::native_failure_has_recipient (const NativeFailureContext &context) noexcept
 Whether this context populates its NativeInRunRecipient.
 
constexpr bool pineforge::engine_script_run_v18::native_failure_has_cursor (const NativeFailureContext &context) noexcept
 Whether this context populates its NativeInRunCursor.
 
constexpr NativeFailureContextKind pineforge::engine_script_run_v18::native_failure_context_kind (bool cause, bool recipient, bool cursor) noexcept
 The kind that says exactly these three alternatives are populated.
 
NativeFailureContext pineforge::engine_script_run_v18::native_failure_cause (std::uint64_t ordinal) noexcept
 A context carrying one causing event ordinal.
 
NativeFailureContext pineforge::engine_script_run_v18::native_failure_recipient (std::uint64_t incarnation) noexcept
 A context carrying one addressed request incarnation.
 
NativeFailureContext pineforge::engine_script_run_v18::native_failure_cursor (NativeCoordinate point, double t=0.0) noexcept
 A context carrying one path cursor.
 
NativeFailureContext pineforge::engine_script_run_v18::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::RunIdentitypineforge::engine_script_run_v18::native_failed_run_identity (const NativeFailed &failed) noexcept
 The RunIdentity the failed spec carried, or nullptr when configure failed before staging one.
 

Macro Definition Documentation

◆ PINEFORGE_HAS_NATIVE_STRATEGY_HOST_V18

#define PINEFORGE_HAS_NATIVE_STRATEGY_HOST_V18   1

Definition at line 770 of file native_host.hpp.