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

Go to the source code of this file.

Data Structures

struct  pineforge::native_run_spec_v3::NativeMarginModel
 A generic per-side broker margin model (L4). More...
 
struct  pineforge::native_run_spec_v3::NativeLossLimit
 One risk threshold (L9). More...
 
struct  pineforge::native_run_spec_v3::NativeRiskLimits
 Generic account risk limits (L9), entirely opt-in: a spec that leaves NativeRunSpec::risk unset evaluates nothing, appends no event and folds nothing into the continuation digest. More...
 
struct  pineforge::native_run_spec_v3::IntrabarPath
 An owned lower-timeframe execution path. More...
 
struct  pineforge::native_run_spec_v3::IntrabarPath::none
 No intrabar path: the confirmed OHLC waypoints are the whole modeled walk, and on_native_sub_bar never fires. More...
 
struct  pineforge::native_run_spec_v3::IntrabarPath::lower_tf
 A RETAINED finer feed: the host's own lower-timeframe bars, the literal they are at, and the sampling policy over them. More...
 
struct  pineforge::native_run_spec_v3::IntrabarPath::synthesized
 A synthesized path has no retained lower feed. More...
 
struct  pineforge::native_run_spec_v3::NativeTimeframeSubscription
 
struct  pineforge::native_run_spec_v3::NativeAuxiliaryFeed
 An auxiliary feed of the run's OWN symbol at a timeframe strictly finer than the input: the bars the input feed does not have. More...
 
struct  pineforge::native_run_spec_v3::NativeRunSpec
 One complete setup value, staged/copied by NativeStrategyHost before it is applied at begin. More...
 
struct  pineforge::native_run_spec_v3::NativeRunSpecValidation
 Allocation-free facts suitable for the host's durable failure variant. More...
 

Namespaces

namespace  pineforge
 
namespace  pineforge::native_run_spec_v3
 

Typedefs

using pineforge::native_run_spec_v3::NativeLegacyTolerance = NativeFeedTolerance
 Deprecated spelling of the tolerance type.
 

Enumerations

enum class  pineforge::native_run_spec_v3::NativeFeeKind : std::uint32_t {
  pineforge::native_run_spec_v3::Percent = 0 ,
  pineforge::native_run_spec_v3::CashPerUnit = 1 ,
  pineforge::native_run_spec_v3::CashPerExecution = 2
}
 Encodings coincide with the versioned native-v1 C transport. More...
 
enum class  pineforge::native_run_spec_v3::NativeCloseExecution : std::uint32_t {
  pineforge::native_run_spec_v3::NextEligiblePoint = 0 ,
  pineforge::native_run_spec_v3::AfterCalculation = 1
}
 When a request born at a script calculation may first match. More...
 
enum class  pineforge::native_run_spec_v3::NativeAbortReporting : std::uint32_t {
  pineforge::native_run_spec_v3::Error = 0 ,
  pineforge::native_run_spec_v3::Quiet = 1
}
 Abort presentation is a run-level policy rather than an exception-path convention. More...
 
enum class  pineforge::native_run_spec_v3::NativeReportPolicy : std::uint32_t {
  pineforge::native_run_spec_v3::HostRecorded = 0 ,
  pineforge::native_run_spec_v3::KernelRecorded = 1 ,
  pineforge::native_run_spec_v3::KernelRecordedAtHostMarks = 2
}
 Who records the per-script-bar report series. More...
 
enum class  pineforge::native_run_spec_v3::NativeOpenDirections : std::uint32_t {
  pineforge::native_run_spec_v3::None = 0 ,
  pineforge::native_run_spec_v3::Long = 1 ,
  pineforge::native_run_spec_v3::Short = 2 ,
  pineforge::native_run_spec_v3::Both = 3
}
 Which opening directions the run admits at all. More...
 
enum class  pineforge::native_run_spec_v3::NativeCalculationTrigger : std::uint32_t {
  pineforge::native_run_spec_v3::BarClose = 0 ,
  pineforge::native_run_spec_v3::BarCloseAndFills = 1 ,
  pineforge::native_run_spec_v3::EveryModeledPoint = 2
}
 When the kernel asks the host to calculate. More...
 
enum class  pineforge::native_run_spec_v3::NativeOpenBarView : std::uint32_t {
  pineforge::native_run_spec_v3::Complete = 0 ,
  pineforge::native_run_spec_v3::OpenOnly = 1
}
 What a bar-open callback is handed. More...
 
enum class  pineforge::native_run_spec_v3::NativePriceGrid : std::uint32_t {
  pineforge::native_run_spec_v3::None = 0 ,
  pineforge::native_run_spec_v3::QuantizeFills = 1 ,
  pineforge::native_run_spec_v3::QuantizeFillsAndTriggers = 2
}
 A generic instrument price grid. More...
 
enum class  pineforge::native_run_spec_v3::NativeGridRounding : std::uint32_t {
  pineforge::native_run_spec_v3::HalfUp = 0 ,
  pineforge::native_run_spec_v3::Directional = 1
}
 HalfUp is the nearest tick with ties away from zero. More...
 
enum class  pineforge::native_run_spec_v3::NativeLiquidationSizing : std::uint32_t {
  pineforge::native_run_spec_v3::RestoreMinimum = 0 ,
  pineforge::native_run_spec_v3::ShortfallMultiple = 1 ,
  pineforge::native_run_spec_v3::Flatten = 2
}
 Which units a kernel-issued liquidation reduces (L4). More...
 
enum class  pineforge::native_run_spec_v3::NativeLiquidationCheck : std::uint32_t {
  pineforge::native_run_spec_v3::PathAdverseExtreme = 0 ,
  pineforge::native_run_spec_v3::CalculationOnly = 1 ,
  pineforge::native_run_spec_v3::PathAdverseExtremeMark = 2
}
 When the kernel tests the maintenance requirement. More...
 
enum class  pineforge::native_run_spec_v3::NativeMarginEquityBasis : std::uint32_t {
  pineforge::native_run_spec_v3::MarkedEquity = 0 ,
  pineforge::native_run_spec_v3::MarkedEquityBeforeOpenCommission = 1
}
 Which equity the maintenance requirement is tested against. More...
 
enum class  pineforge::native_run_spec_v3::NativeLiquidationLevelBase : std::uint32_t {
  pineforge::native_run_spec_v3::MarkedEquity = 0 ,
  pineforge::native_run_spec_v3::RealizedOnly = 1
}
 Which base the liquidation level is solved from. More...
 
enum class  pineforge::native_run_spec_v3::NativeRiskDay : std::uint32_t {
  pineforge::native_run_spec_v3::SessionDay = 0 ,
  pineforge::native_run_spec_v3::CalendarDayInTimezone = 1
}
 Which day a risk limit's "day" is. More...
 
enum class  pineforge::native_run_spec_v3::NativeRiskAction : std::uint32_t {
  pineforge::native_run_spec_v3::BlockOpenings = 0 ,
  pineforge::native_run_spec_v3::FlattenAndBlock = 1
}
 What a breach does. More...
 
enum class  pineforge::native_run_spec_v3::NativeSlotLabelPolicy : std::uint32_t {
  pineforge::native_run_spec_v3::Canonical = 0 ,
  pineforge::native_run_spec_v3::FeedTolerant = 1 ,
  pineforge::native_run_spec_v3::LegacyTolerant = FeedTolerant
}
 Native hosts normally require every confirmed bar to name a canonical input slot. More...
 
enum class  pineforge::native_run_spec_v3::NativePathOrder : std::uint32_t {
  pineforge::native_run_spec_v3::Auto = 0 ,
  pineforge::native_run_spec_v3::HighFirst = 1 ,
  pineforge::native_run_spec_v3::LowFirst = 2
}
 Generic ordering for a modeled OHLC path. More...
 
enum class  pineforge::native_run_spec_v3::NativeFeedTolerance : std::uint32_t {
  pineforge::native_run_spec_v3::None = 0 ,
  pineforge::native_run_spec_v3::BatchStructuralBars = 1u << 0 ,
  pineforge::native_run_spec_v3::WarmupNonNegativeOHLC = 1u << 1
}
 Explicit, opt-in admission exceptions for a tolerated input-feed shape. More...
 
enum class  pineforge::native_run_spec_v3::NativeSeriesSource : std::uint8_t {
  pineforge::native_run_spec_v3::Input = 0 ,
  pineforge::native_run_spec_v3::AuxiliaryFeed = 1
}
 One declared higher-timeframe series of the run's own symbol, the native equivalent of request.security(syminfo.tickerid, tf, ...). More...
 
enum class  pineforge::native_run_spec_v3::NativeRunSpecField : std::uint8_t {
  pineforge::native_run_spec_v3::None ,
  pineforge::native_run_spec_v3::SessionKey ,
  pineforge::native_run_spec_v3::RunNumber ,
  pineforge::native_run_spec_v3::InputTimeframe ,
  pineforge::native_run_spec_v3::ScriptTimeframe ,
  pineforge::native_run_spec_v3::Ticker ,
  pineforge::native_run_spec_v3::TickerId ,
  pineforge::native_run_spec_v3::Type ,
  pineforge::native_run_spec_v3::Currency ,
  pineforge::native_run_spec_v3::BaseCurrency ,
  pineforge::native_run_spec_v3::Description ,
  pineforge::native_run_spec_v3::VolumeType ,
  pineforge::native_run_spec_v3::Timezone ,
  pineforge::native_run_spec_v3::Session ,
  pineforge::native_run_spec_v3::ChartTimezone ,
  pineforge::native_run_spec_v3::InitialCapital ,
  pineforge::native_run_spec_v3::PointValue ,
  pineforge::native_run_spec_v3::AccountFx ,
  pineforge::native_run_spec_v3::PriceTick ,
  pineforge::native_run_spec_v3::SlippageTicks ,
  pineforge::native_run_spec_v3::FeeKind ,
  pineforge::native_run_spec_v3::FeeValue ,
  pineforge::native_run_spec_v3::QuantityGrid ,
  pineforge::native_run_spec_v3::CloseExecution ,
  pineforge::native_run_spec_v3::AbortReporting ,
  pineforge::native_run_spec_v3::MaxAbsUnits ,
  pineforge::native_run_spec_v3::MaxOpenLots ,
  pineforge::native_run_spec_v3::AllowedOpenDirections ,
  pineforge::native_run_spec_v3::InitialMarginFraction ,
  pineforge::native_run_spec_v3::IntrabarTimeframe ,
  pineforge::native_run_spec_v3::IntrabarSamples ,
  pineforge::native_run_spec_v3::IntrabarDistribution ,
  pineforge::native_run_spec_v3::IntrabarVolumeSamples ,
  pineforge::native_run_spec_v3::IntrabarSampleEligibility ,
  pineforge::native_run_spec_v3::TimeframeUndetected ,
  pineforge::native_run_spec_v3::SlotLabelPolicy ,
  pineforge::native_run_spec_v3::LegacyTolerance ,
  pineforge::native_run_spec_v3::PathOrder ,
  pineforge::native_run_spec_v3::ReportPolicy ,
  pineforge::native_run_spec_v3::PriceGrid ,
  pineforge::native_run_spec_v3::GridRounding ,
  pineforge::native_run_spec_v3::SubscriptionTimeframe ,
  pineforge::native_run_spec_v3::SubscriptionBars ,
  pineforge::native_run_spec_v3::MarginModel ,
  pineforge::native_run_spec_v3::MarginInitial ,
  pineforge::native_run_spec_v3::MarginMaintenance ,
  pineforge::native_run_spec_v3::MarginSizing ,
  pineforge::native_run_spec_v3::MarginShortfallMultiple ,
  pineforge::native_run_spec_v3::MarginMinUnits ,
  pineforge::native_run_spec_v3::MarginCheck ,
  pineforge::native_run_spec_v3::MarginEquityBasis ,
  pineforge::native_run_spec_v3::MarginLevelBase ,
  pineforge::native_run_spec_v3::Calculation ,
  pineforge::native_run_spec_v3::OpenBarView ,
  pineforge::native_run_spec_v3::RiskLimits ,
  pineforge::native_run_spec_v3::RiskDrawdown ,
  pineforge::native_run_spec_v3::RiskIntradayLoss ,
  pineforge::native_run_spec_v3::RiskLossDays ,
  pineforge::native_run_spec_v3::RiskFillsPerDay ,
  pineforge::native_run_spec_v3::RiskDayBasis ,
  pineforge::native_run_spec_v3::RiskAction ,
  pineforge::native_run_spec_v3::AuxiliaryFeedTimeframe ,
  pineforge::native_run_spec_v3::AuxiliaryFeedBars ,
  pineforge::native_run_spec_v3::SubscriptionSource
}
 Which field a validation refused, in deterministic first-error order. More...
 
enum class  pineforge::native_run_spec_v3::NativeRunSpecError : std::uint8_t {
  pineforge::native_run_spec_v3::None ,
  pineforge::native_run_spec_v3::EmptyRequiredString ,
  pineforge::native_run_spec_v3::EmbeddedNul ,
  pineforge::native_run_spec_v3::InvalidUtf8 ,
  pineforge::native_run_spec_v3::ZeroRunNumber ,
  pineforge::native_run_spec_v3::InvalidTimeframe ,
  pineforge::native_run_spec_v3::IncompatibleTimeframes ,
  pineforge::native_run_spec_v3::UnresolvedTimezone ,
  pineforge::native_run_spec_v3::InvalidSession ,
  pineforge::native_run_spec_v3::NotFinitePositive ,
  pineforge::native_run_spec_v3::SlippageOutOfRange ,
  pineforge::native_run_spec_v3::UnknownFeeKind ,
  pineforge::native_run_spec_v3::NotFiniteNonnegative ,
  pineforge::native_run_spec_v3::UnknownCloseExecution ,
  pineforge::native_run_spec_v3::UnknownAbortReporting ,
  pineforge::native_run_spec_v3::UnknownOpenDirections ,
  pineforge::native_run_spec_v3::ZeroLotLimit ,
  pineforge::native_run_spec_v3::AllocationFailure ,
  pineforge::native_run_spec_v3::CalendarFailure ,
  pineforge::native_run_spec_v3::InvalidIntrabarPath ,
  pineforge::native_run_spec_v3::UnknownIntrabarSampleEligibility ,
  pineforge::native_run_spec_v3::InvalidUndetectedTimeframe ,
  pineforge::native_run_spec_v3::UnknownSlotLabelPolicy ,
  pineforge::native_run_spec_v3::UnknownLegacyTolerance ,
  pineforge::native_run_spec_v3::UnknownPathOrder ,
  pineforge::native_run_spec_v3::UnknownReportPolicy ,
  pineforge::native_run_spec_v3::UnknownPriceGrid ,
  pineforge::native_run_spec_v3::UnknownGridRounding ,
  pineforge::native_run_spec_v3::GridRequiresPriceTick ,
  pineforge::native_run_spec_v3::InvalidSubscriptionTimeframe ,
  pineforge::native_run_spec_v3::SubscriptionFinerThanInput ,
  pineforge::native_run_spec_v3::DuplicateSubscriptionTimeframe ,
  pineforge::native_run_spec_v3::UnorderedSubscriptionBars ,
  pineforge::native_run_spec_v3::SubscriptionWithoutTimeframe ,
  pineforge::native_run_spec_v3::MarginModelConflict ,
  pineforge::native_run_spec_v3::UnknownLiquidationSizing ,
  pineforge::native_run_spec_v3::UnknownLiquidationCheck ,
  pineforge::native_run_spec_v3::UnknownMarginEquityBasis ,
  pineforge::native_run_spec_v3::UnknownLiquidationLevelBase ,
  pineforge::native_run_spec_v3::UnknownCalculationTrigger ,
  pineforge::native_run_spec_v3::UnknownOpenBarView ,
  pineforge::native_run_spec_v3::UnknownRiskDay ,
  pineforge::native_run_spec_v3::UnknownRiskAction ,
  pineforge::native_run_spec_v3::ZeroRiskLimit ,
  pineforge::native_run_spec_v3::MarginSideUndeclared ,
  pineforge::native_run_spec_v3::InvalidAuxiliaryFeedTimeframe ,
  pineforge::native_run_spec_v3::AuxiliaryFeedNotFinerThanInput ,
  pineforge::native_run_spec_v3::UnorderedAuxiliaryFeedBars ,
  pineforge::native_run_spec_v3::InvalidAuxiliaryFeedBar ,
  pineforge::native_run_spec_v3::AuxiliaryFeedWithoutTimeframe ,
  pineforge::native_run_spec_v3::UnknownSeriesSource ,
  pineforge::native_run_spec_v3::SubscriptionWithoutAuxiliaryFeed ,
  pineforge::native_run_spec_v3::SubscriptionFinerThanAuxiliaryFeed
}
 Why a field was refused. More...
 

Functions

constexpr bool pineforge::native_run_spec_v3::native_feed_tolerance_enabled (NativeFeedTolerance enabled, NativeFeedTolerance requested) noexcept
 Whether one NativeFeedTolerance bit is set in a run's mask.
 
constexpr bool pineforge::native_run_spec_v3::native_legacy_tolerance_enabled (NativeFeedTolerance enabled, NativeFeedTolerance requested) noexcept
 Deprecated spelling of native_feed_tolerance_enabled.
 
NativeRunSpecValidation pineforge::native_run_spec_v3::validate_native_run_spec (const NativeRunSpec &spec) noexcept
 Complete validation, with deterministic first-error field order.
 
NativeRunSpecValidation pineforge::native_run_spec_v3::normalize_native_run_spec (NativeRunSpec &spec) noexcept
 Validate the WHOLE value first, then canonicalize its admitted numeric negative zero (fee_value) to positive zero.
 
NativeRunSpecValidation pineforge::native_run_spec_v3::validate_native_timeframe_subscriptions (const std::vector< NativeTimeframeSubscription > &subscriptions, const std::string &input_tf, bool timeframe_undetected) noexcept
 Exactly the part of validate_native_run_spec that judges declared higher-timeframe series, against a stated input timeframe: the pairing rule (as script_tf pairs, never strictly finer), the literals, the order of any authoritative bars, the one conflicting-feed refusal, and the undetected-timeframe rule.
 
NativeRunSpecValidation pineforge::native_run_spec_v3::validate_native_timeframe_subscriptions (const std::vector< NativeTimeframeSubscription > &subscriptions, const std::string &input_tf, bool timeframe_undetected, const std::optional< NativeAuxiliaryFeed > &auxiliary_feed) noexcept
 The same judgement for a run that declares an auxiliary feed: the feed is judged first (validate_native_auxiliary_feed), then every series, a series built from the feed pairing with the FEED's timeframe.
 
NativeRunSpecValidation pineforge::native_run_spec_v3::validate_native_auxiliary_feed (const std::optional< NativeAuxiliaryFeed > &auxiliary_feed, const std::string &input_tf, bool timeframe_undetected) noexcept
 Exactly the part of validate_native_run_spec that judges the auxiliary feed, against a stated input timeframe: the literal, the strictly-finer pairing under the input, the order and structure of its bars, and the undetected-timeframe rule.
 
std::uint64_t pineforge::native_run_spec_v3::native_intrabar_path_digest (const IntrabarPath &path) noexcept
 Exact FNV-1a content digest for a retained intrabar path.
 
std::uint64_t pineforge::native_run_spec_v3::native_timeframe_subscriptions_digest (const std::vector< NativeTimeframeSubscription > &subscriptions) noexcept
 Exact FNV-1a content digest for the declared higher-timeframe series.
 
std::uint64_t pineforge::native_run_spec_v3::native_auxiliary_feed_digest (const NativeAuxiliaryFeed &feed) noexcept
 Exact FNV-1a content digest for the declared auxiliary feed: its timeframe literal and every bar in caller order, so a continuation cannot silently reuse another begin's feed.
 
std::uint64_t pineforge::native_run_spec_v3::native_run_spec_digest (const NativeRunSpec &spec) noexcept
 Machine-independent digest of a run spec: exactly the fields the consumer folds into the continuation identity for the spec, and nothing else — no timezone resources, no session identity beyond the spec's own.
 
std::uint64_t pineforge::native_run_spec_v3::native_margin_model_digest (const NativeMarginModel &margin) noexcept
 Exact FNV-1a content digest for the generic margin model.
 
std::uint64_t pineforge::native_run_spec_v3::native_risk_limits_digest (const NativeRiskLimits &risk) noexcept
 Exact FNV-1a content digest for the generic risk limits.