PineForge v0.13.1-379-g9b50973
Deterministic PineScript v6 backtest runtime — C ABI reference
Loading...
Searching...
No Matches
pineforge Namespace Reference

Namespaces

namespace  admission
 
namespace  broker
 
namespace  compat
 
namespace  detail
 
namespace  engine_script_run_v18
 
namespace  execution
 
namespace  exit_legs
 
namespace  internal
 
namespace  math
 
namespace  metrics
 
namespace  native_calendar
 
namespace  native_driver_v5
 
namespace  native_fx_curve_v1
 
namespace  native_module
 
namespace  native_order
 
namespace  native_run_spec_v3
 
namespace  native_toolkit
 
namespace  order_action
 
namespace  order_cancellation_v1
 
namespace  pine_color
 
namespace  reservation_expansion_v1
 
namespace  source
 
namespace  ta
 

Data Structures

struct  AggregatedBar
 
class  BacktestEngine
 
struct  Bar
 
class  BirthCursor
 
struct  Box
 
struct  BoxRec
 
class  BrokerStateHashProvider
 
class  BrokerStateHashSink
 
struct  CancellationTarget
 
struct  ChartPoint
 
struct  ClosedLotExcursion
 
struct  ClosedLotExcursionFacts
 
class  DrawingArena
 
class  DynamicRingBuffer
 
class  ExitLegActivation
 
struct  ExitLegActivationBounds
 
class  GenericMatrix
 
class  GenericMatrix< bool >
 
class  IExecutionConsumer
 
class  INativeDriverSink
 
struct  IntrabarPath
 An owned lower-timeframe execution path. More...
 
class  KahanWindowSum
 
struct  Label
 
struct  LabelRec
 
struct  Line
 
struct  Linefill
 
struct  LinefillRec
 
struct  LineRec
 
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  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  NativeBeginArgs
 Borrowed begin-call facts. More...
 
struct  NativeCompleted
 
struct  NativeCoordinate
 Everything the kernel knows about WHERE a point is, as one owning value: its event ordinal, the interval index, the nominal and scheduled-eligible opens, the last traded close, the next period and next input opens, the effective time the account converts and hashes at, the source price time, and the three classifications above. More...
 
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  NativeDayPartition
 
class  NativeDayPartitionScope
 
struct  NativeDecisionContext
 
struct  NativeDriverPoint
 One point the driver produced: its coordinate, the raw price before slippage or any grid, the provider's sequence for an observed print (nullopt otherwise), and whether the point is a matching point, an excursion sample, or both. More...
 
struct  NativeDriverStatistics
 
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  NativeFxCurve
 An immutable account-currency FX curve: parallel arrays of effective-from timestamps in epoch milliseconds and the account-currency units per one unit of the symbol's quote currency. 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  NativeFxCurveValidation
 What validate_native_fx_curve and configure_native_fx_curve report: the error and the index of the element that failed. 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  NativeInputPreflightResult
 What preflight_native_inputs answers: the error and the first offending bar's index, or -1 when the refusal is not about one bar. 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  NativeLossLimit
 One risk threshold (L9). 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  NativeMarginModel
 A generic per-side broker margin model (L4). 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  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  NativeRiskState
 The run's generic risk ledger (L9), as the kernel holds it. More...
 
struct  NativeRunning
 
struct  NativeRunSpec
 One complete setup value, staged/copied by NativeStrategyHost before it is applied at begin. More...
 
struct  NativeRunSpecValidation
 Allocation-free facts suitable for the host's durable failure variant. More...
 
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  NativeTimeframeSubscription
 
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...
 
class  NumericMatrix
 
class  OrderBirth
 
class  OrderCancellationReceipt
 
struct  pine_drawing_error
 
class  PineMap
 
struct  PyramidEntry
 
class  QuantityIntent
 
class  QuantityRequest
 
struct  QuantityReservation
 
struct  ReportC
 
class  ReservationExpansion
 
struct  ReservationExpansionCapture
 
class  ReservationGrowthSource
 
struct  SecurityDiagC
 
class  Series
 
struct  StreamOrderAction
 
struct  SymInfo
 
class  TimeframeAggregator
 
struct  TraceEntryC
 
struct  Trade
 
struct  TradeC
 
struct  TradeTick
 

Typedefs

using PineExitActivationPolicy = compat::pine::ExitActivationPolicy
 
using PineHistoricalBirthReach = compat::pine::HistoricalBirthReach
 
using LotExcursionHook = std::function<ClosedLotExcursion(const ClosedLotExcursionFacts&)>
 
using ExitLegLifecycle = exit_legs::Lifecycle
 
using InputsMap = std::unordered_map<std::string, std::string>
 
template<typename T>
using PineGenericMatrix = GenericMatrix<T>
 
using PineMatrix = NumericMatrix
 
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.
 
using NativeLegacyTolerance = NativeFeedTolerance
 Deprecated spelling of the tolerance type.
 
using MarketAdmissionDraft = admission::Draft
 
using MarketAdmissionJournal = admission::Journal
 

Enumerations

enum class  XLoc : int {
  bar_index = 0 ,
  bar_time = 1
}
 
enum class  YLoc : int {
  price = 0 ,
  abovebar = 1 ,
  belowbar = 2
}
 
enum class  PositionSide {
  FLAT ,
  LONG ,
  SHORT
}
 
enum class  QtyType {
  FIXED = 0 ,
  PERCENT_OF_EQUITY = 1 ,
  CASH = 2
}
 
enum class  CommissionType {
  PERCENT = 0 ,
  CASH_PER_ORDER = 1 ,
  CASH_PER_CONTRACT = 2
}
 
enum class  MagnifierDistribution {
  UNIFORM ,
  COSINE ,
  TRIANGLE ,
  ENDPOINTS ,
  FRONT_LOADED ,
  BACK_LOADED
}
 
enum class  NativePriceProvenance : std::uint8_t {
  Confirmed = 0 ,
  ObservedPrint = 1 ,
  ModeledOHLCOpen = 2 ,
  ModeledOHLCClose = 3 ,
  CarriedOpen = 4 ,
  AfterCalculationClose = 5 ,
  PartialFinalized = 6 ,
  Calculation = 7 ,
  CurrentExecution = 8
}
 Where a driver point's price came from. More...
 
enum class  NativePathPhase : std::uint8_t {
  None = 0 ,
  Open = 1 ,
  High = 2 ,
  Low = 3 ,
  Close = 4
}
 Which leg of a modeled OHLC walk a point sits on. More...
 
enum class  NativeCompletionKind : std::uint8_t {
  Confirmed = 0 ,
  LazyComplete = 1 ,
  SessionShortened = 2 ,
  PartialFinalized = 3
}
 How a script interval or a higher-timeframe bucket was closed. More...
 
enum class  NativeInputPolicy : std::uint8_t {
  Batch = 0 ,
  StreamWarmup = 1
}
 
enum class  NativeInputPreflightError : std::uint16_t {
  None = 0 ,
  NullArray = 1 ,
  InvalidCount = 2 ,
  StructuralInvalid = 3 ,
  Unaligned = 4 ,
  OffGridLabel = 5 ,
  NotStrictlyIncreasing = 6 ,
  OverlappingSlot = 7 ,
  InSessionGap = 8 ,
  CalendarFailure = 9 ,
  TimestampDeltaOverflow = 10
}
 Why a bar array was refused before the run touched anything. More...
 
enum class  NativeFxCurveError : std::uint8_t {
  None = 0 ,
  LengthMismatch = 1 ,
  NotStrictlyIncreasing = 2 ,
  NotFinitePositive = 3 ,
  AllocationFailure = 4 ,
  WrongPhase = 5
}
 Why a curve was refused. More...
 
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...
 
enum class  NativeFeeKind : std::uint32_t {
  Percent = 0 ,
  CashPerUnit = 1 ,
  CashPerExecution = 2
}
 Encodings coincide with the versioned native-v1 C transport. More...
 
enum class  NativeCloseExecution : std::uint32_t {
  NextEligiblePoint = 0 ,
  AfterCalculation = 1
}
 When a request born at a script calculation may first match. More...
 
enum class  NativeAbortReporting : std::uint32_t {
  Error = 0 ,
  Quiet = 1
}
 Abort presentation is a run-level policy rather than an exception-path convention. More...
 
enum class  NativeReportPolicy : std::uint32_t {
  HostRecorded = 0 ,
  KernelRecorded = 1 ,
  KernelRecordedAtHostMarks = 2
}
 Who records the per-script-bar report series. More...
 
enum class  NativeOpenDirections : std::uint32_t {
  None = 0 ,
  Long = 1 ,
  Short = 2 ,
  Both = 3
}
 Which opening directions the run admits at all. More...
 
enum class  NativeCalculationTrigger : std::uint32_t {
  BarClose = 0 ,
  BarCloseAndFills = 1 ,
  EveryModeledPoint = 2
}
 When the kernel asks the host to calculate. More...
 
enum class  NativeOpenBarView : std::uint32_t {
  Complete = 0 ,
  OpenOnly = 1
}
 What a bar-open callback is handed. More...
 
enum class  NativePriceGrid : std::uint32_t {
  None = 0 ,
  QuantizeFills = 1 ,
  QuantizeFillsAndTriggers = 2
}
 A generic instrument price grid. More...
 
enum class  NativeGridRounding : std::uint32_t {
  HalfUp = 0 ,
  Directional = 1
}
 HalfUp is the nearest tick with ties away from zero. More...
 
enum class  NativeLiquidationSizing : std::uint32_t {
  RestoreMinimum = 0 ,
  ShortfallMultiple = 1 ,
  Flatten = 2
}
 Which units a kernel-issued liquidation reduces (L4). More...
 
enum class  NativeLiquidationCheck : std::uint32_t {
  PathAdverseExtreme = 0 ,
  CalculationOnly = 1 ,
  PathAdverseExtremeMark = 2
}
 When the kernel tests the maintenance requirement. More...
 
enum class  NativeMarginEquityBasis : std::uint32_t {
  MarkedEquity = 0 ,
  MarkedEquityBeforeOpenCommission = 1
}
 Which equity the maintenance requirement is tested against. More...
 
enum class  NativeLiquidationLevelBase : std::uint32_t {
  MarkedEquity = 0 ,
  RealizedOnly = 1
}
 Which base the liquidation level is solved from. More...
 
enum class  NativeRiskDay : std::uint32_t {
  SessionDay = 0 ,
  CalendarDayInTimezone = 1
}
 Which day a risk limit's "day" is. More...
 
enum class  NativeRiskAction : std::uint32_t {
  BlockOpenings = 0 ,
  FlattenAndBlock = 1
}
 What a breach does. More...
 
enum class  NativeSlotLabelPolicy : std::uint32_t {
  Canonical = 0 ,
  FeedTolerant = 1 ,
  LegacyTolerant = FeedTolerant
}
 Native hosts normally require every confirmed bar to name a canonical input slot. More...
 
enum class  NativePathOrder : std::uint32_t {
  Auto = 0 ,
  HighFirst = 1 ,
  LowFirst = 2
}
 Generic ordering for a modeled OHLC path. More...
 
enum class  NativeFeedTolerance : std::uint32_t {
  None = 0 ,
  BatchStructuralBars = 1u << 0 ,
  WarmupNonNegativeOHLC = 1u << 1
}
 Explicit, opt-in admission exceptions for a tolerated input-feed shape. More...
 
enum class  NativeSeriesSource : std::uint8_t {
  Input = 0 ,
  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  NativeRunSpecField : std::uint8_t {
  None ,
  SessionKey ,
  RunNumber ,
  InputTimeframe ,
  ScriptTimeframe ,
  Ticker ,
  TickerId ,
  Type ,
  Currency ,
  BaseCurrency ,
  Description ,
  VolumeType ,
  Timezone ,
  Session ,
  ChartTimezone ,
  InitialCapital ,
  PointValue ,
  AccountFx ,
  PriceTick ,
  SlippageTicks ,
  FeeKind ,
  FeeValue ,
  QuantityGrid ,
  CloseExecution ,
  AbortReporting ,
  MaxAbsUnits ,
  MaxOpenLots ,
  AllowedOpenDirections ,
  InitialMarginFraction ,
  IntrabarTimeframe ,
  IntrabarSamples ,
  IntrabarDistribution ,
  IntrabarVolumeSamples ,
  IntrabarSampleEligibility ,
  TimeframeUndetected ,
  SlotLabelPolicy ,
  LegacyTolerance ,
  PathOrder ,
  ReportPolicy ,
  PriceGrid ,
  GridRounding ,
  SubscriptionTimeframe ,
  SubscriptionBars ,
  MarginModel ,
  MarginInitial ,
  MarginMaintenance ,
  MarginSizing ,
  MarginShortfallMultiple ,
  MarginMinUnits ,
  MarginCheck ,
  MarginEquityBasis ,
  MarginLevelBase ,
  Calculation ,
  OpenBarView ,
  RiskLimits ,
  RiskDrawdown ,
  RiskIntradayLoss ,
  RiskLossDays ,
  RiskFillsPerDay ,
  RiskDayBasis ,
  RiskAction ,
  AuxiliaryFeedTimeframe ,
  AuxiliaryFeedBars ,
  SubscriptionSource
}
 Which field a validation refused, in deterministic first-error order. More...
 
enum class  NativeRunSpecError : std::uint8_t {
  None ,
  EmptyRequiredString ,
  EmbeddedNul ,
  InvalidUtf8 ,
  ZeroRunNumber ,
  InvalidTimeframe ,
  IncompatibleTimeframes ,
  UnresolvedTimezone ,
  InvalidSession ,
  NotFinitePositive ,
  SlippageOutOfRange ,
  UnknownFeeKind ,
  NotFiniteNonnegative ,
  UnknownCloseExecution ,
  UnknownAbortReporting ,
  UnknownOpenDirections ,
  ZeroLotLimit ,
  AllocationFailure ,
  CalendarFailure ,
  InvalidIntrabarPath ,
  UnknownIntrabarSampleEligibility ,
  InvalidUndetectedTimeframe ,
  UnknownSlotLabelPolicy ,
  UnknownLegacyTolerance ,
  UnknownPathOrder ,
  UnknownReportPolicy ,
  UnknownPriceGrid ,
  UnknownGridRounding ,
  GridRequiresPriceTick ,
  InvalidSubscriptionTimeframe ,
  SubscriptionFinerThanInput ,
  DuplicateSubscriptionTimeframe ,
  UnorderedSubscriptionBars ,
  SubscriptionWithoutTimeframe ,
  MarginModelConflict ,
  UnknownLiquidationSizing ,
  UnknownLiquidationCheck ,
  UnknownMarginEquityBasis ,
  UnknownLiquidationLevelBase ,
  UnknownCalculationTrigger ,
  UnknownOpenBarView ,
  UnknownRiskDay ,
  UnknownRiskAction ,
  ZeroRiskLimit ,
  MarginSideUndeclared ,
  InvalidAuxiliaryFeedTimeframe ,
  AuxiliaryFeedNotFinerThanInput ,
  UnorderedAuxiliaryFeedBars ,
  InvalidAuxiliaryFeedBar ,
  AuxiliaryFeedWithoutTimeframe ,
  UnknownSeriesSource ,
  SubscriptionWithoutAuxiliaryFeed ,
  SubscriptionFinerThanAuxiliaryFeed
}
 Why a field was refused. More...
 
enum class  BirthCursorDomain : int32_t {
  None ,
  HistoricalPath ,
  MagnifierTicks
}
 
enum class  BirthCursorPosition : int32_t {
  None ,
  Point ,
  Segment
}
 
enum class  OrderBirthCause : int32_t {
  Unattributed ,
  DirectCommand ,
  ChartEvaluation ,
  FillEvaluation
}
 
enum class  CancellationCause : int32_t {
  None = 0 ,
  Replacement = 1 ,
  Dependency = 2
}
 
enum class  CancellationState : int32_t {
  Live = 0 ,
  Cancelled = 1
}
 
enum class  CloseClaimRelease : int32_t {
  Unbound = 0 ,
  NotApplicable = 1 ,
  Pending = 2 ,
  Released = 3
}
 
enum class  CancellationResult : int32_t {
  Applied = 0 ,
  Replay = 1 ,
  AlreadyTerminal = 2 ,
  Invalid = 3
}
 
enum class  QuantityIntentKind {
  Units ,
  Fraction ,
  All
}
 
enum class  CalendarPeriod {
  NONE ,
  DAY ,
  WEEK ,
  MONTH
}
 

Functions

bool is_na (const Line &h)
 
bool is_na (const Box &h)
 
bool is_na (const Label &h)
 
bool is_na (const Linefill &h)
 
bool is_na (const ChartPoint &p)
 
template<class Rec, class Handle>
Rec & pf_require_live (DrawingArena< Rec > &a, Handle h)
 
int64_t pf_point_x (const ChartPoint &p, XLoc xloc)
 
Line pf_line_new (DrawingArena< LineRec > &a, int64_t x1, double y1, int64_t x2, double y2, XLoc xloc=XLoc::bar_index, bool el=false, bool er=false)
 
Line pf_line_new_pts (DrawingArena< LineRec > &a, ChartPoint p1, ChartPoint p2, XLoc xloc=XLoc::bar_index)
 
int64_t pf_line_get_x1 (DrawingArena< LineRec > &a, Line h)
 
int64_t pf_line_get_x2 (DrawingArena< LineRec > &a, Line h)
 
double pf_line_get_y1 (DrawingArena< LineRec > &a, Line h)
 
double pf_line_get_y2 (DrawingArena< LineRec > &a, Line h)
 
void pf_line_set_x1 (DrawingArena< LineRec > &a, Line h, int64_t v)
 
void pf_line_set_x2 (DrawingArena< LineRec > &a, Line h, int64_t v)
 
void pf_line_set_y1 (DrawingArena< LineRec > &a, Line h, double v)
 
void pf_line_set_y2 (DrawingArena< LineRec > &a, Line h, double v)
 
void pf_line_set_xy1 (DrawingArena< LineRec > &a, Line h, int64_t x, double y)
 
void pf_line_set_xy2 (DrawingArena< LineRec > &a, Line h, int64_t x, double y)
 
void pf_line_set_first_point (DrawingArena< LineRec > &a, Line h, ChartPoint p)
 
void pf_line_set_second_point (DrawingArena< LineRec > &a, Line h, ChartPoint p)
 
void pf_line_set_xloc (DrawingArena< LineRec > &a, Line h, int64_t x1, int64_t x2, XLoc xloc)
 
double pf_line_get_price (DrawingArena< LineRec > &a, Line h, int64_t x)
 
Line pf_line_copy (DrawingArena< LineRec > &a, Line h)
 
void pf_line_delete (DrawingArena< LineRec > &a, Line h)
 
Box pf_box_new (DrawingArena< BoxRec > &a, int64_t left, double top, int64_t right, double bottom, XLoc xloc=XLoc::bar_index)
 
Box pf_box_new_pts (DrawingArena< BoxRec > &a, ChartPoint top_left, ChartPoint bottom_right, XLoc xloc=XLoc::bar_index)
 
int64_t pf_box_get_left (DrawingArena< BoxRec > &a, Box h)
 
int64_t pf_box_get_right (DrawingArena< BoxRec > &a, Box h)
 
double pf_box_get_top (DrawingArena< BoxRec > &a, Box h)
 
double pf_box_get_bottom (DrawingArena< BoxRec > &a, Box h)
 
void pf_box_set_left (DrawingArena< BoxRec > &a, Box h, int64_t v)
 
void pf_box_set_right (DrawingArena< BoxRec > &a, Box h, int64_t v)
 
void pf_box_set_top (DrawingArena< BoxRec > &a, Box h, double v)
 
void pf_box_set_bottom (DrawingArena< BoxRec > &a, Box h, double v)
 
void pf_box_set_lefttop (DrawingArena< BoxRec > &a, Box h, int64_t left, double top)
 
void pf_box_set_rightbottom (DrawingArena< BoxRec > &a, Box h, int64_t right, double bottom)
 
void pf_box_set_top_left_point (DrawingArena< BoxRec > &a, Box h, ChartPoint p)
 
void pf_box_set_bottom_right_point (DrawingArena< BoxRec > &a, Box h, ChartPoint p)
 
void pf_box_set_xloc (DrawingArena< BoxRec > &a, Box h, int64_t left, int64_t right, XLoc xloc)
 
Box pf_box_copy (DrawingArena< BoxRec > &a, Box h)
 
void pf_box_delete (DrawingArena< BoxRec > &a, Box h)
 
Label pf_label_new (DrawingArena< LabelRec > &a, int64_t x, double y, std::string text, XLoc xloc=XLoc::bar_index, YLoc yloc=YLoc::price)
 
Label pf_label_new_pt (DrawingArena< LabelRec > &a, ChartPoint point, std::string text, YLoc yloc=YLoc::price)
 
int64_t pf_label_get_x (DrawingArena< LabelRec > &a, Label h)
 
double pf_label_get_y (DrawingArena< LabelRec > &a, Label h)
 
std::string pf_label_get_text (DrawingArena< LabelRec > &a, Label h)
 
void pf_label_set_x (DrawingArena< LabelRec > &a, Label h, int64_t v)
 
void pf_label_set_y (DrawingArena< LabelRec > &a, Label h, double v)
 
void pf_label_set_xy (DrawingArena< LabelRec > &a, Label h, int64_t x, double y)
 
void pf_label_set_point (DrawingArena< LabelRec > &a, Label h, ChartPoint p)
 
void pf_label_set_xloc (DrawingArena< LabelRec > &a, Label h, int64_t x, XLoc xloc)
 
void pf_label_set_yloc (DrawingArena< LabelRec > &a, Label h, YLoc yloc)
 
void pf_label_set_text (DrawingArena< LabelRec > &a, Label h, std::string text)
 
Label pf_label_copy (DrawingArena< LabelRec > &a, Label h)
 
void pf_label_delete (DrawingArena< LabelRec > &a, Label h)
 
Linefill pf_linefill_new (DrawingArena< LinefillRec > &a, Line l1, Line l2)
 
Line pf_linefill_get_line1 (DrawingArena< LinefillRec > &a, Linefill h)
 
Line pf_linefill_get_line2 (DrawingArena< LinefillRec > &a, Linefill h)
 
void pf_linefill_delete (DrawingArena< LinefillRec > &a, Linefill h)
 
template<class... A>
void pf_noop (A &&...)
 
std::unique_ptr< IExecutionConsumermake_native_execution_consumer ()
 
template<typename T>
bool is_na (const GenericMatrix< T > &matrix) noexcept
 
void pine_log_info (const std::string &msg)
 
void pine_log_warning (const std::string &msg)
 
void pine_log_error (const std::string &msg)
 
void pine_runtime_error (const std::string &msg)
 
double path_at (double t, double p0, double p1, double p2, double p3, double len0, double len1, double len2, double total)
 Maps parameter t in [0,1] to a price on the 3-segment path.
 
std::vector< double > sample_price_path (const Bar &bar, int n_samples, MagnifierDistribution dist=MagnifierDistribution::ENDPOINTS)
 Sample n_samples points along the OHLC price path of the bar.
 
void sample_price_path (const Bar &bar, int n_samples, MagnifierDistribution dist, std::vector< double > &out)
 Out-parameter overload of sample_price_path.
 
std::vector< double > sample_price_path_volume_weighted (const Bar &bar, int base_samples, double mean_volume, int min_samples=2, int max_samples=64, MagnifierDistribution dist=MagnifierDistribution::ENDPOINTS)
 Sample n_samples points along the OHLC price path, weighting the sample density by the ratio of this bar's volume to a reference mean_volume.
 
void sample_price_path_volume_weighted (const Bar &bar, int base_samples, double mean_volume, int min_samples, int max_samples, MagnifierDistribution dist, std::vector< double > &out)
 Out-parameter overload of sample_price_path_volume_weighted.
 
template<typename Key, typename Value>
bool is_na (const PineMap< Key, Value > &map) noexcept
 
bool native_bar_structurally_valid (const Bar &bar) noexcept
 Whether a bar can be admitted at all: finite positive OHLC with high >= max(open, close) and low <= min(open, close), and a finite nonnegative volume.
 
bool native_confirmed_bar_label_admitted (const native_calendar::NativeInterval &interval, int64_t timestamp) noexcept
 
int64_t native_canonical_input_completion (const native_calendar::NativeInterval &interval) noexcept
 
NativeInputPreflightResult preflight_native_inputs (const NativeRunSpec &spec, const Bar *bars, int n, NativeInputPolicy policy)
 Judge a whole bar array against a run spec before any of it is consumed, under NativeInputPolicy::Batch (sparse input is admitted; missing in-session slots are legal) or StreamWarmup (every provided slot must be a complete confirmed interval and an in-session gap is refused).
 
double deterministic_random (double lo, uint32_t call_site, double hi, uint32_t seed, int bar_index)
 
double pine_random (double lo, uint32_t call_site, double hi, uint32_t seed, int bar_index)
 
bool is_na (const NumericMatrix &matrix) noexcept
 
template<typename T>
na ()
 
template<>
double na< double > ()
 
template<>
int na< int > ()
 
template<>
int64_t na< int64_t > ()
 
template<>
bool na< bool > ()
 
bool is_na (double v)
 
template<typename T, typename = std::enable_if_t<std::is_integral_v<T> && !std::is_same_v<T, bool>>>
bool is_na (T v)
 
NativeFxCurveValidation validate_native_fx_curve (const NativeFxCurve &curve) noexcept
 
std::uint64_t native_fx_curve_digest (const NativeFxCurve &curve) noexcept
 
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::RunIdentitynative_failed_run_identity (const NativeFailed &failed) noexcept
 The RunIdentity the failed spec carried, or nullptr when configure failed before staging one.
 
constexpr bool native_feed_tolerance_enabled (NativeFeedTolerance enabled, NativeFeedTolerance requested) noexcept
 Whether one NativeFeedTolerance bit is set in a run's mask.
 
constexpr bool native_legacy_tolerance_enabled (NativeFeedTolerance enabled, NativeFeedTolerance requested) noexcept
 Deprecated spelling of native_feed_tolerance_enabled.
 
NativeRunSpecValidation validate_native_run_spec (const NativeRunSpec &spec) noexcept
 Complete validation, with deterministic first-error field order.
 
NativeRunSpecValidation 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 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 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 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 native_intrabar_path_digest (const IntrabarPath &path) noexcept
 Exact FNV-1a content digest for a retained intrabar path.
 
std::uint64_t native_timeframe_subscriptions_digest (const std::vector< NativeTimeframeSubscription > &subscriptions) noexcept
 Exact FNV-1a content digest for the declared higher-timeframe series.
 
std::uint64_t 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 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 native_margin_model_digest (const NativeMarginModel &margin) noexcept
 Exact FNV-1a content digest for the generic margin model.
 
std::uint64_t native_risk_limits_digest (const NativeRiskLimits &risk) noexcept
 Exact FNV-1a content digest for the generic risk limits.
 
std::string normalize_timezone_for_posix (const std::string &tz)
 
int64_t timeframe_time (int64_t bar_ms, const std::string &tf, const std::string &session, const std::string &tz, const std::string &chart_tf, const std::string &syminfo_tz=std::string())
 
int64_t timeframe_time_close (int64_t bar_ms, const std::string &tf, const std::string &session, const std::string &tz, const std::string &chart_tf, const std::string &syminfo_tz=std::string())
 
int64_t timeframe_time (int64_t bar_ms, const std::string &tf, const std::string &session, const std::string &tz, const std::string &chart_tf, const std::string &sym_tz, const std::string &sym_session)
 
int64_t timeframe_time_close (int64_t bar_ms, const std::string &tf, const std::string &session, const std::string &tz, const std::string &chart_tf, const std::string &sym_tz, const std::string &sym_session)
 
int hhmm_to_minutes (const std::string &hhmm)
 
int local_hour (int64_t bar_ms, const std::string &tz)
 
int local_minute (int64_t bar_ms, const std::string &tz)
 
int local_second (int64_t bar_ms, const std::string &tz)
 
int local_dayofmonth (int64_t bar_ms, const std::string &tz)
 
int local_dayofweek (int64_t bar_ms, const std::string &tz)
 
int local_month (int64_t bar_ms, const std::string &tz)
 
int local_year (int64_t bar_ms, const std::string &tz)
 
int local_weekofyear (int64_t bar_ms, const std::string &tz)
 
bool local_time_in_session_windows (const std::string &windows_body, const struct tm &local_tm)
 
bool passes_session_filter (const std::string &session, const std::string &tz, int64_t bar_ms)
 
int64_t calendar_day_open_local_ms (int64_t bar_ms, const std::string &tz)
 
int64_t session_trading_day_open_ms (int64_t bar_ms, const std::string &session, const std::string &tz)
 
bool session_in_market (const std::string &session, const std::string &tz, int64_t bar_ms)
 
bool session_in_premarket (const std::string &session, const std::string &tz, int64_t bar_ms)
 
bool session_in_postmarket (const std::string &session, const std::string &tz, int64_t bar_ms)
 
bool session_in_market (const std::string &session, const std::string &tz, int64_t bar_ms, const std::string &chart_tf)
 
bool session_in_premarket (const std::string &session, const std::string &tz, int64_t bar_ms, const std::string &chart_tf)
 
bool session_in_postmarket (const std::string &session, const std::string &tz, int64_t bar_ms, const std::string &chart_tf)
 
int64_t pine_time (int64_t bar_ms, const std::string &tf, const std::string &session, const std::string &tz, const std::string &chart_tf, const std::string &syminfo_tz=std::string())
 
int64_t pine_time (int64_t bar_ms, const std::string &tf, const std::string &session, const std::string &tz, const std::string &chart_tf, const std::string &sym_tz, const std::string &sym_session)
 
int64_t pine_time_close (int64_t bar_ms, const std::string &tf, const std::string &session, const std::string &tz, const std::string &chart_tf, const std::string &syminfo_tz=std::string())
 
int64_t pine_time_close (int64_t bar_ms, const std::string &tf, const std::string &session, const std::string &tz, const std::string &chart_tf, const std::string &sym_tz, const std::string &sym_session)
 
int pine_hour (int64_t bar_ms, const std::string &tz)
 
int pine_minute (int64_t bar_ms, const std::string &tz)
 
int pine_second (int64_t bar_ms, const std::string &tz)
 
int pine_dayofmonth (int64_t bar_ms, const std::string &tz)
 
int pine_dayofweek (int64_t bar_ms, const std::string &tz)
 
int pine_month (int64_t bar_ms, const std::string &tz)
 
int pine_year (int64_t bar_ms, const std::string &tz)
 
int pine_weekofyear (int64_t bar_ms, const std::string &tz)
 
int64_t pine_time_tradingday (int64_t bar_ms, const std::string &session, const std::string &tz)
 
bool pine_session_ismarket (const std::string &session, const std::string &tz, int64_t bar_ms)
 
bool pine_session_ispremarket (const std::string &session, const std::string &tz, int64_t bar_ms)
 
bool pine_session_ispostmarket (const std::string &session, const std::string &tz, int64_t bar_ms)
 
bool pine_session_ismarket (const std::string &session, const std::string &tz, int64_t bar_ms, const std::string &chart_tf)
 
bool pine_session_ispremarket (const std::string &session, const std::string &tz, int64_t bar_ms, const std::string &chart_tf)
 
bool pine_session_ispostmarket (const std::string &session, const std::string &tz, int64_t bar_ms, const std::string &chart_tf)
 
bool pine_float_eq (double a, double b)
 
bool pine_float_ne (double a, double b)
 
bool pine_float_gt (double a, double b)
 
bool pine_float_lt (double a, double b)
 
bool pine_float_ge (double a, double b)
 
bool pine_float_le (double a, double b)
 
std::string str_format (const std::string &fmt, const std::vector< std::string > &args)
 
std::string str_format_time (long long timestamp_ms, const std::string &format, const std::string &timezone)
 
std::string str_match (const std::string &source, const std::string &regex_pattern)
 
std::vector< std::string > str_split (const std::string &source, const std::string &separator)
 
std::string str_tostring (double value, const std::string &format_mode="", double mintick=0.0)
 
std::string pine_str_format (const std::string &fmt, const std::vector< std::string > &args)
 
std::string pine_str_format_time (long long timestamp_ms, const std::string &format, const std::string &timezone)
 
std::string pine_str_match (const std::string &source, const std::string &regex_pattern)
 
std::vector< std::string > pine_str_split (const std::string &source, const std::string &separator)
 
std::string pine_str_tostring (double value, const std::string &format_mode="", double mintick=0.0)
 
bool float_band_eq (double a, double b)
 
bool float_band_ne (double a, double b)
 
bool float_band_gt (double a, double b)
 
bool float_band_lt (double a, double b)
 
bool float_band_ge (double a, double b)
 
bool float_band_le (double a, double b)
 
int tf_to_seconds (const std::string &tf)
 Convert a TradingView timeframe string to seconds.
 
int tf_multiplier (const std::string &tf)
 Extract the numeric multiplier from a TF string (e.g. "15" -> 15, "D" -> 1).
 
bool tf_is_intraday (const std::string &tf)
 
bool tf_is_daily (const std::string &tf)
 
bool tf_is_weekly (const std::string &tf)
 
bool tf_is_monthly (const std::string &tf)
 
bool tf_is_seconds (const std::string &tf)
 
bool tf_change (int64_t prev_ms, int64_t curr_ms, const std::string &tf)
 Check if prev/curr timestamps cross a timeframe boundary.
 
int tf_ratio (const std::string &input_tf, const std::string &target_tf)
 Compute how many input bars fit into one target bar.
 
std::string detect_timeframe (const Bar *bars, int n, int max_samples=100)
 Detect the timeframe string from an array of bars by computing the median timestamp delta and mapping to the nearest standard TF.
 
CalendarPeriod calendar_period_for (const std::string &tf)
 Determine the calendar period for a target TF string.
 
bool tf_is_daily_or_higher (const std::string &tf)
 True for a daily-or-higher chart timeframe ("D", "1D", "2D", "W", "M"): a bar that covers whole session days rather than a time of day (the aggregation path's CALENDAR classification).
 
bool crosses_boundary (int64_t prev_ms, int64_t curr_ms, CalendarPeriod period)
 Check if two timestamps (Unix milliseconds) fall in different calendar periods.
 
bool crosses_boundary (int64_t prev_ms, int64_t curr_ms, CalendarPeriod period, const std::string &tz, const std::string &session)
 Timezone/session-aware variants.
 
bool tf_change (int64_t prev_ms, int64_t curr_ms, const std::string &tf, const std::string &tz, const std::string &session)
 
int64_t session_day_index (int64_t ms, const std::string &tz, const std::string &session)
 Ordinal of the session day containing ms (days since epoch on the session clock).
 
int64_t session_period_open_ms (int64_t ms, const std::string &tz, const std::string &session, CalendarPeriod period)
 Open (Unix ms) of the symbol's D/W/M bar that contains ms: the day stamp of the period's first session-day (17:00 ET on OANDA 1800-1700, the session open elsewhere).
 
int64_t session_intraday_bucket_open_ms (int64_t ms, int64_t bucket_sec, const std::string &tz, const std::string &session)
 Open (Unix ms) of the bucket_sec-wide intraday bucket that contains ms on the symbol's day-stamp-anchored grid: exchange-tz time since local midnight + day stamp, floored to the bucket width.
 
int64_t session_covered_instant_ms (int64_t ms, const std::string &tz, const std::string &session)
 The session instant a native CALENDAR chart stamp covers.
 
int64_t session_period_close_ms (int64_t ms, const std::string &tz, const std::string &session, CalendarPeriod period)
 Exclusive close (Unix ms) of the symbol's D/W/M bar that contains ms: DAY -> session-day open + session length (16:00 ET on equities, the next 17:00 ET on forex, next midnight on 24x7); WEEK / MONTH -> the open of the next period's first session-day.
 
int64_t session_period_last_traded_close_ms (int64_t ms, const std::string &tz, const std::string &session, CalendarPeriod period)
 Exclusive close (Unix ms) of the LAST TRADED session-day of the D/W/M bar that contains ms: DAY is session_period_close_ms; WEEK / MONTH step back from the period's last session-day over weekend TRADING dates (Saturday / Sunday never hold a session on exchange-calendar symbols), so an equity week ends Friday 16:00 ET, a month whose last calendar day is a weekend ends on its last Friday, and the forex week ends Friday 17:00 ET (the Friday-open session is Saturday's trading date).
 
bool build_native_day_partition (NativeDayPartition &out, const std::string &tz, const std::string &session, const std::vector< int64_t > &stamps, const Bar *input_bars, int n_input)
 Build the partition for the symbol clock (tz, session) from the native daily stamps and the chart's input bars (the trade instants: the last input bar before the next stamp, bounded by the last stamp's nominal session-day close; the stamp itself when no input bar lies in the period).
 
int native_day_partition_index (const NativeDayPartition &p, int64_t ms)
 Index of the native period holding ms under p: -1 before the first stamp and at / after the last stamp's nominal session-day close.
 
const NativeDayPartitionset_active_native_day_partition (const NativeDayPartition *p)
 The calling thread's active chart partition, read by session_day_index / session_period_open_ms / session_period_close_ms / session_period_last_traded_close_ms / crosses_boundary (and so by tf_change, the symbol-clock pine_time forms and ta::VWAP's session anchor) whenever their (tz, session) equal the partition's.
 
const NativeDayPartitionactive_native_day_partition ()
 
static int safe_tf_to_seconds (const std::string &tf)
 
static void sort_same_bar_exit_trades (std::vector< Trade > &, source::PineExecutionAdapter &)
 

Variables

template<typename T>
constexpr bool is_pine_map_snapshot_value_v
 
constexpr const char * kNativeDriverSemanticVersion = "native-driver/v5"
 
constexpr const char * kNativeConsumerSemanticVersion = "native-consumer/v7"
 
constexpr const char * kNativeCalendarSemanticVersion = "native-calendar/v1"
 
constexpr double kPineFloatEqualityBand = kFloatCompareBand
 
constexpr double kFloatCompareBand = 1e-10
 
constexpr int64_t kSecPerDay = 86400
 
constexpr int64_t kMsPerDay = 86400000
 

Typedef Documentation

◆ PineExitActivationPolicy

◆ PineHistoricalBirthReach

◆ LotExcursionHook

Definition at line 112 of file engine.hpp.

◆ ExitLegLifecycle

Definition at line 276 of file engine.hpp.

◆ InputsMap

using pineforge::InputsMap = std::unordered_map<std::string, std::string>

Definition at line 309 of file engine.hpp.

◆ PineGenericMatrix

template<typename T>
using pineforge::PineGenericMatrix = GenericMatrix<T>

Definition at line 694 of file generic_matrix.hpp.

◆ PineMatrix

Definition at line 159 of file matrix.hpp.

◆ MarketAdmissionDraft

◆ MarketAdmissionJournal

Enumeration Type Documentation

◆ XLoc

enum class pineforge::XLoc : int
strong
Enumerator
bar_index 
bar_time 

Definition at line 32 of file drawing.hpp.

◆ YLoc

enum class pineforge::YLoc : int
strong
Enumerator
price 
abovebar 
belowbar 

Definition at line 33 of file drawing.hpp.

◆ PositionSide

enum class pineforge::PositionSide
strong
Enumerator
FLAT 
LONG 
SHORT 

Definition at line 54 of file engine.hpp.

◆ QtyType

enum class pineforge::QtyType
strong
Enumerator
FIXED 
PERCENT_OF_EQUITY 
CASH 

Definition at line 279 of file engine.hpp.

◆ CommissionType

enum class pineforge::CommissionType
strong
Enumerator
PERCENT 
CASH_PER_ORDER 
CASH_PER_CONTRACT 

Definition at line 282 of file engine.hpp.

◆ MagnifierDistribution

Enumerator
UNIFORM 
COSINE 
TRIANGLE 
ENDPOINTS 
FRONT_LOADED 
BACK_LOADED 

Definition at line 7 of file magnifier.hpp.

◆ BirthCursorDomain

enum class pineforge::BirthCursorDomain : int32_t
strong
Enumerator
None 
HistoricalPath 
MagnifierTicks 

Definition at line 10 of file order_birth.hpp.

◆ BirthCursorPosition

enum class pineforge::BirthCursorPosition : int32_t
strong
Enumerator
None 
Point 
Segment 

Definition at line 11 of file order_birth.hpp.

◆ OrderBirthCause

enum class pineforge::OrderBirthCause : int32_t
strong
Enumerator
Unattributed 
DirectCommand 
ChartEvaluation 
FillEvaluation 

Definition at line 12 of file order_birth.hpp.

◆ QuantityIntentKind

enum class pineforge::QuantityIntentKind
strong
Enumerator
Units 
Fraction 
All 

Definition at line 10 of file quantity_intent.hpp.

◆ CalendarPeriod

enum class pineforge::CalendarPeriod
strong
Enumerator
NONE 
DAY 
WEEK 
MONTH 

Definition at line 81 of file timeframe.hpp.

Function Documentation

◆ is_na() [1/10]

bool pineforge::is_na ( const Line & h)
inline

Definition at line 42 of file drawing.hpp.

References pineforge::Line::id.

Referenced by is_na(), and pf_label_new_pt().

◆ is_na() [2/10]

bool pineforge::is_na ( const Box & h)
inline

Definition at line 43 of file drawing.hpp.

References pineforge::Box::id.

◆ is_na() [3/10]

bool pineforge::is_na ( const Label & h)
inline

Definition at line 44 of file drawing.hpp.

References pineforge::Label::id.

◆ is_na() [4/10]

bool pineforge::is_na ( const Linefill & h)
inline

Definition at line 45 of file drawing.hpp.

References pineforge::Linefill::id.

◆ is_na() [5/10]

bool pineforge::is_na ( const ChartPoint & p)
inline

◆ pf_require_live()

◆ pf_point_x()

◆ pf_line_new()

Line pineforge::pf_line_new ( DrawingArena< LineRec > & a,
int64_t x1,
double y1,
int64_t x2,
double y2,
XLoc xloc = XLoc::bar_index,
bool el = false,
bool er = false )
inline

Definition at line 146 of file drawing.hpp.

References pineforge::DrawingArena< Rec >::alloc(), and bar_index.

◆ pf_line_new_pts()

Line pineforge::pf_line_new_pts ( DrawingArena< LineRec > & a,
ChartPoint p1,
ChartPoint p2,
XLoc xloc = XLoc::bar_index )
inline

◆ pf_line_get_x1()

int64_t pineforge::pf_line_get_x1 ( DrawingArena< LineRec > & a,
Line h )
inline

Definition at line 157 of file drawing.hpp.

References pf_require_live().

◆ pf_line_get_x2()

int64_t pineforge::pf_line_get_x2 ( DrawingArena< LineRec > & a,
Line h )
inline

Definition at line 158 of file drawing.hpp.

References pf_require_live().

◆ pf_line_get_y1()

double pineforge::pf_line_get_y1 ( DrawingArena< LineRec > & a,
Line h )
inline

Definition at line 159 of file drawing.hpp.

References pf_require_live().

◆ pf_line_get_y2()

double pineforge::pf_line_get_y2 ( DrawingArena< LineRec > & a,
Line h )
inline

Definition at line 160 of file drawing.hpp.

References pf_require_live().

◆ pf_line_set_x1()

void pineforge::pf_line_set_x1 ( DrawingArena< LineRec > & a,
Line h,
int64_t v )
inline

Definition at line 162 of file drawing.hpp.

References pf_require_live().

◆ pf_line_set_x2()

void pineforge::pf_line_set_x2 ( DrawingArena< LineRec > & a,
Line h,
int64_t v )
inline

Definition at line 163 of file drawing.hpp.

References pf_require_live().

◆ pf_line_set_y1()

void pineforge::pf_line_set_y1 ( DrawingArena< LineRec > & a,
Line h,
double v )
inline

Definition at line 164 of file drawing.hpp.

References pf_require_live().

◆ pf_line_set_y2()

void pineforge::pf_line_set_y2 ( DrawingArena< LineRec > & a,
Line h,
double v )
inline

Definition at line 165 of file drawing.hpp.

References pf_require_live().

◆ pf_line_set_xy1()

void pineforge::pf_line_set_xy1 ( DrawingArena< LineRec > & a,
Line h,
int64_t x,
double y )
inline

Definition at line 166 of file drawing.hpp.

References pf_require_live().

◆ pf_line_set_xy2()

void pineforge::pf_line_set_xy2 ( DrawingArena< LineRec > & a,
Line h,
int64_t x,
double y )
inline

Definition at line 169 of file drawing.hpp.

References pf_require_live().

◆ pf_line_set_first_point()

void pineforge::pf_line_set_first_point ( DrawingArena< LineRec > & a,
Line h,
ChartPoint p )
inline

Definition at line 172 of file drawing.hpp.

References pf_point_x(), pf_require_live(), and pineforge::ChartPoint::price.

◆ pf_line_set_second_point()

void pineforge::pf_line_set_second_point ( DrawingArena< LineRec > & a,
Line h,
ChartPoint p )
inline

Definition at line 175 of file drawing.hpp.

References pf_point_x(), pf_require_live(), and pineforge::ChartPoint::price.

◆ pf_line_set_xloc()

void pineforge::pf_line_set_xloc ( DrawingArena< LineRec > & a,
Line h,
int64_t x1,
int64_t x2,
XLoc xloc )
inline

Definition at line 178 of file drawing.hpp.

References pf_require_live().

◆ pf_line_get_price()

double pineforge::pf_line_get_price ( DrawingArena< LineRec > & a,
Line h,
int64_t x )
inline

◆ pf_line_copy()

◆ pf_line_delete()

void pineforge::pf_line_delete ( DrawingArena< LineRec > & a,
Line h )
inline

Definition at line 199 of file drawing.hpp.

References pineforge::DrawingArena< Rec >::erase(), and pineforge::Line::id.

◆ pf_box_new()

Box pineforge::pf_box_new ( DrawingArena< BoxRec > & a,
int64_t left,
double top,
int64_t right,
double bottom,
XLoc xloc = XLoc::bar_index )
inline

Definition at line 202 of file drawing.hpp.

References pineforge::DrawingArena< Rec >::alloc(), and bar_index.

◆ pf_box_new_pts()

Box pineforge::pf_box_new_pts ( DrawingArena< BoxRec > & a,
ChartPoint top_left,
ChartPoint bottom_right,
XLoc xloc = XLoc::bar_index )
inline

◆ pf_box_get_left()

int64_t pineforge::pf_box_get_left ( DrawingArena< BoxRec > & a,
Box h )
inline

Definition at line 212 of file drawing.hpp.

References pf_require_live().

◆ pf_box_get_right()

int64_t pineforge::pf_box_get_right ( DrawingArena< BoxRec > & a,
Box h )
inline

Definition at line 213 of file drawing.hpp.

References pf_require_live().

◆ pf_box_get_top()

double pineforge::pf_box_get_top ( DrawingArena< BoxRec > & a,
Box h )
inline

Definition at line 214 of file drawing.hpp.

References pf_require_live().

◆ pf_box_get_bottom()

double pineforge::pf_box_get_bottom ( DrawingArena< BoxRec > & a,
Box h )
inline

Definition at line 215 of file drawing.hpp.

References pf_require_live().

◆ pf_box_set_left()

void pineforge::pf_box_set_left ( DrawingArena< BoxRec > & a,
Box h,
int64_t v )
inline

Definition at line 217 of file drawing.hpp.

References pf_require_live().

◆ pf_box_set_right()

void pineforge::pf_box_set_right ( DrawingArena< BoxRec > & a,
Box h,
int64_t v )
inline

Definition at line 218 of file drawing.hpp.

References pf_require_live().

◆ pf_box_set_top()

void pineforge::pf_box_set_top ( DrawingArena< BoxRec > & a,
Box h,
double v )
inline

Definition at line 219 of file drawing.hpp.

References pf_require_live().

◆ pf_box_set_bottom()

void pineforge::pf_box_set_bottom ( DrawingArena< BoxRec > & a,
Box h,
double v )
inline

Definition at line 220 of file drawing.hpp.

References pf_require_live().

◆ pf_box_set_lefttop()

void pineforge::pf_box_set_lefttop ( DrawingArena< BoxRec > & a,
Box h,
int64_t left,
double top )
inline

Definition at line 221 of file drawing.hpp.

References pf_require_live().

◆ pf_box_set_rightbottom()

void pineforge::pf_box_set_rightbottom ( DrawingArena< BoxRec > & a,
Box h,
int64_t right,
double bottom )
inline

Definition at line 224 of file drawing.hpp.

References pf_require_live().

◆ pf_box_set_top_left_point()

void pineforge::pf_box_set_top_left_point ( DrawingArena< BoxRec > & a,
Box h,
ChartPoint p )
inline

Definition at line 227 of file drawing.hpp.

References pf_point_x(), pf_require_live(), and pineforge::ChartPoint::price.

◆ pf_box_set_bottom_right_point()

void pineforge::pf_box_set_bottom_right_point ( DrawingArena< BoxRec > & a,
Box h,
ChartPoint p )
inline

Definition at line 230 of file drawing.hpp.

References pf_point_x(), pf_require_live(), and pineforge::ChartPoint::price.

◆ pf_box_set_xloc()

void pineforge::pf_box_set_xloc ( DrawingArena< BoxRec > & a,
Box h,
int64_t left,
int64_t right,
XLoc xloc )
inline

Definition at line 233 of file drawing.hpp.

References pf_require_live().

◆ pf_box_copy()

◆ pf_box_delete()

void pineforge::pf_box_delete ( DrawingArena< BoxRec > & a,
Box h )
inline

Definition at line 242 of file drawing.hpp.

References pineforge::DrawingArena< Rec >::erase(), and pineforge::Box::id.

◆ pf_label_new()

Label pineforge::pf_label_new ( DrawingArena< LabelRec > & a,
int64_t x,
double y,
std::string text,
XLoc xloc = XLoc::bar_index,
YLoc yloc = YLoc::price )
inline

Definition at line 251 of file drawing.hpp.

References pineforge::DrawingArena< Rec >::alloc(), bar_index, and price.

◆ pf_label_new_pt()

◆ pf_label_get_x()

int64_t pineforge::pf_label_get_x ( DrawingArena< LabelRec > & a,
Label h )
inline

Definition at line 263 of file drawing.hpp.

References pf_require_live().

◆ pf_label_get_y()

double pineforge::pf_label_get_y ( DrawingArena< LabelRec > & a,
Label h )
inline

Definition at line 264 of file drawing.hpp.

References pf_require_live().

◆ pf_label_get_text()

std::string pineforge::pf_label_get_text ( DrawingArena< LabelRec > & a,
Label h )
inline

Definition at line 265 of file drawing.hpp.

References pf_require_live().

◆ pf_label_set_x()

void pineforge::pf_label_set_x ( DrawingArena< LabelRec > & a,
Label h,
int64_t v )
inline

Definition at line 267 of file drawing.hpp.

References pf_require_live().

◆ pf_label_set_y()

void pineforge::pf_label_set_y ( DrawingArena< LabelRec > & a,
Label h,
double v )
inline

Definition at line 268 of file drawing.hpp.

References pf_require_live().

◆ pf_label_set_xy()

void pineforge::pf_label_set_xy ( DrawingArena< LabelRec > & a,
Label h,
int64_t x,
double y )
inline

Definition at line 269 of file drawing.hpp.

References pf_require_live().

◆ pf_label_set_point()

void pineforge::pf_label_set_point ( DrawingArena< LabelRec > & a,
Label h,
ChartPoint p )
inline

Definition at line 272 of file drawing.hpp.

References pf_point_x(), pf_require_live(), and pineforge::ChartPoint::price.

◆ pf_label_set_xloc()

void pineforge::pf_label_set_xloc ( DrawingArena< LabelRec > & a,
Label h,
int64_t x,
XLoc xloc )
inline

Definition at line 275 of file drawing.hpp.

References pf_require_live().

◆ pf_label_set_yloc()

void pineforge::pf_label_set_yloc ( DrawingArena< LabelRec > & a,
Label h,
YLoc yloc )
inline

Definition at line 278 of file drawing.hpp.

References pf_require_live().

◆ pf_label_set_text()

void pineforge::pf_label_set_text ( DrawingArena< LabelRec > & a,
Label h,
std::string text )
inline

Definition at line 281 of file drawing.hpp.

References pf_require_live().

◆ pf_label_copy()

◆ pf_label_delete()

void pineforge::pf_label_delete ( DrawingArena< LabelRec > & a,
Label h )
inline

Definition at line 290 of file drawing.hpp.

References pineforge::DrawingArena< Rec >::erase(), and pineforge::Label::id.

◆ pf_linefill_new()

Linefill pineforge::pf_linefill_new ( DrawingArena< LinefillRec > & a,
Line l1,
Line l2 )
inline

Definition at line 293 of file drawing.hpp.

References pineforge::DrawingArena< Rec >::alloc(), and pineforge::Line::id.

◆ pf_linefill_get_line1()

Line pineforge::pf_linefill_get_line1 ( DrawingArena< LinefillRec > & a,
Linefill h )
inline

Definition at line 298 of file drawing.hpp.

References pf_require_live().

◆ pf_linefill_get_line2()

Line pineforge::pf_linefill_get_line2 ( DrawingArena< LinefillRec > & a,
Linefill h )
inline

Definition at line 301 of file drawing.hpp.

References pf_require_live().

◆ pf_linefill_delete()

void pineforge::pf_linefill_delete ( DrawingArena< LinefillRec > & a,
Linefill h )
inline

◆ pf_noop()

template<class... A>
void pineforge::pf_noop ( A && ...)
inline

Definition at line 309 of file drawing.hpp.

◆ is_na() [6/10]

template<typename T>
bool pineforge::is_na ( const GenericMatrix< T > & matrix)
inlinenoexcept

Definition at line 685 of file generic_matrix.hpp.

◆ pine_log_info()

void pineforge::pine_log_info ( const std::string & msg)
inline

Definition at line 8 of file log.hpp.

◆ pine_log_warning()

void pineforge::pine_log_warning ( const std::string & msg)
inline

Definition at line 9 of file log.hpp.

◆ pine_log_error()

void pineforge::pine_log_error ( const std::string & msg)
inline

Definition at line 10 of file log.hpp.

◆ pine_runtime_error()

void pineforge::pine_runtime_error ( const std::string & msg)
inline

Definition at line 11 of file log.hpp.

◆ path_at()

double pineforge::path_at ( double t,
double p0,
double p1,
double p2,
double p3,
double len0,
double len1,
double len2,
double total )

Maps parameter t in [0,1] to a price on the 3-segment path.

Segments: p0->p1, p1->p2, p2->p3 with arc lengths len0, len1, len2.

◆ sample_price_path() [1/2]

std::vector< double > pineforge::sample_price_path ( const Bar & bar,
int n_samples,
MagnifierDistribution dist = MagnifierDistribution::ENDPOINTS )

Sample n_samples points along the OHLC price path of the bar.

The first leg follows TradingView-style open proximity: O -> H -> L -> C when open is nearer high, otherwise O -> L -> H -> C (ties low-first). First sample is always O, last is always C. Minimum 2 samples.

References ENDPOINTS.

◆ sample_price_path() [2/2]

void pineforge::sample_price_path ( const Bar & bar,
int n_samples,
MagnifierDistribution dist,
std::vector< double > & out )

Out-parameter overload of sample_price_path.

Writes the sampled prices into out (cleared first; retained capacity is reused), avoiding a per-call heap allocation in hot sampling loops. Behaviour is identical to the value-returning overload.

◆ sample_price_path_volume_weighted() [1/2]

std::vector< double > pineforge::sample_price_path_volume_weighted ( const Bar & bar,
int base_samples,
double mean_volume,
int min_samples = 2,
int max_samples = 64,
MagnifierDistribution dist = MagnifierDistribution::ENDPOINTS )

Sample n_samples points along the OHLC price path, weighting the sample density by the ratio of this bar's volume to a reference mean_volume.

A bar with 2x average volume receives up to 2x as many samples as a bar at average volume, clamped within [min_samples, max_samples].

Intended for magnifier modes that should simulate denser tick streams when volume is higher (more trades per bar → more fill opportunities).

References ENDPOINTS.

◆ sample_price_path_volume_weighted() [2/2]

void pineforge::sample_price_path_volume_weighted ( const Bar & bar,
int base_samples,
double mean_volume,
int min_samples,
int max_samples,
MagnifierDistribution dist,
std::vector< double > & out )

Out-parameter overload of sample_price_path_volume_weighted.

Writes into out (cleared first; retained capacity reused). Behaviour is identical to the value-returning overload.

◆ is_na() [7/10]

template<typename Key, typename Value>
bool pineforge::is_na ( const PineMap< Key, Value > & map)
inlinenoexcept

Definition at line 394 of file map.hpp.

◆ deterministic_random()

double pineforge::deterministic_random ( double lo,
uint32_t call_site,
double hi,
uint32_t seed,
int bar_index )
inline

Definition at line 9 of file math.hpp.

References bar_index.

Referenced by pine_random().

◆ pine_random()

double pineforge::pine_random ( double lo,
uint32_t call_site,
double hi,
uint32_t seed,
int bar_index )
inline

Definition at line 24 of file math.hpp.

References bar_index, and deterministic_random().

◆ is_na() [8/10]

bool pineforge::is_na ( const NumericMatrix & matrix)
inlinenoexcept

Definition at line 151 of file matrix.hpp.

◆ na()

◆ na< double >()

template<>
double pineforge::na< double > ( )
inline

◆ na< int >()

◆ na< int64_t >()

template<>
int64_t pineforge::na< int64_t > ( )
inline

Definition at line 19 of file na.hpp.

◆ na< bool >()

template<>
bool pineforge::na< bool > ( )
inline

Definition at line 20 of file na.hpp.

◆ is_na() [9/10]

bool pineforge::is_na ( double v)
inline

Definition at line 22 of file na.hpp.

◆ is_na() [10/10]

template<typename T, typename = std::enable_if_t<std::is_integral_v<T> && !std::is_same_v<T, bool>>>
bool pineforge::is_na ( T v)
inline

Definition at line 26 of file na.hpp.

◆ normalize_timezone_for_posix()

std::string pineforge::normalize_timezone_for_posix ( const std::string & tz)

◆ timeframe_time() [1/2]

int64_t pineforge::timeframe_time ( int64_t bar_ms,
const std::string & tf,
const std::string & session,
const std::string & tz,
const std::string & chart_tf,
const std::string & syminfo_tz = std::string() )

Referenced by pine_time(), and pine_time().

◆ timeframe_time_close() [1/2]

int64_t pineforge::timeframe_time_close ( int64_t bar_ms,
const std::string & tf,
const std::string & session,
const std::string & tz,
const std::string & chart_tf,
const std::string & syminfo_tz = std::string() )

Referenced by pine_time_close(), and pine_time_close().

◆ timeframe_time() [2/2]

int64_t pineforge::timeframe_time ( int64_t bar_ms,
const std::string & tf,
const std::string & session,
const std::string & tz,
const std::string & chart_tf,
const std::string & sym_tz,
const std::string & sym_session )

◆ timeframe_time_close() [2/2]

int64_t pineforge::timeframe_time_close ( int64_t bar_ms,
const std::string & tf,
const std::string & session,
const std::string & tz,
const std::string & chart_tf,
const std::string & sym_tz,
const std::string & sym_session )

◆ hhmm_to_minutes()

int pineforge::hhmm_to_minutes ( const std::string & hhmm)

◆ local_hour()

int pineforge::local_hour ( int64_t bar_ms,
const std::string & tz )

Referenced by pine_hour().

◆ local_minute()

int pineforge::local_minute ( int64_t bar_ms,
const std::string & tz )

Referenced by pine_minute().

◆ local_second()

int pineforge::local_second ( int64_t bar_ms,
const std::string & tz )

Referenced by pine_second().

◆ local_dayofmonth()

int pineforge::local_dayofmonth ( int64_t bar_ms,
const std::string & tz )

Referenced by pine_dayofmonth().

◆ local_dayofweek()

int pineforge::local_dayofweek ( int64_t bar_ms,
const std::string & tz )

Referenced by pine_dayofweek().

◆ local_month()

int pineforge::local_month ( int64_t bar_ms,
const std::string & tz )

Referenced by pine_month().

◆ local_year()

int pineforge::local_year ( int64_t bar_ms,
const std::string & tz )

Referenced by pine_year().

◆ local_weekofyear()

int pineforge::local_weekofyear ( int64_t bar_ms,
const std::string & tz )

Referenced by pine_weekofyear().

◆ local_time_in_session_windows()

bool pineforge::local_time_in_session_windows ( const std::string & windows_body,
const struct tm & local_tm )

◆ passes_session_filter()

bool pineforge::passes_session_filter ( const std::string & session,
const std::string & tz,
int64_t bar_ms )

◆ calendar_day_open_local_ms()

int64_t pineforge::calendar_day_open_local_ms ( int64_t bar_ms,
const std::string & tz )

◆ session_trading_day_open_ms()

int64_t pineforge::session_trading_day_open_ms ( int64_t bar_ms,
const std::string & session,
const std::string & tz )

Referenced by pine_time_tradingday().

◆ session_in_market() [1/2]

bool pineforge::session_in_market ( const std::string & session,
const std::string & tz,
int64_t bar_ms )

◆ session_in_premarket() [1/2]

bool pineforge::session_in_premarket ( const std::string & session,
const std::string & tz,
int64_t bar_ms )

◆ session_in_postmarket() [1/2]

bool pineforge::session_in_postmarket ( const std::string & session,
const std::string & tz,
int64_t bar_ms )

◆ session_in_market() [2/2]

bool pineforge::session_in_market ( const std::string & session,
const std::string & tz,
int64_t bar_ms,
const std::string & chart_tf )

◆ session_in_premarket() [2/2]

bool pineforge::session_in_premarket ( const std::string & session,
const std::string & tz,
int64_t bar_ms,
const std::string & chart_tf )

◆ session_in_postmarket() [2/2]

bool pineforge::session_in_postmarket ( const std::string & session,
const std::string & tz,
int64_t bar_ms,
const std::string & chart_tf )

◆ pine_time() [1/2]

int64_t pineforge::pine_time ( int64_t bar_ms,
const std::string & tf,
const std::string & session,
const std::string & tz,
const std::string & chart_tf,
const std::string & syminfo_tz = std::string() )
inline

Definition at line 206 of file session_time.hpp.

References timeframe_time().

◆ pine_time() [2/2]

int64_t pineforge::pine_time ( int64_t bar_ms,
const std::string & tf,
const std::string & session,
const std::string & tz,
const std::string & chart_tf,
const std::string & sym_tz,
const std::string & sym_session )
inline

Definition at line 213 of file session_time.hpp.

References timeframe_time().

◆ pine_time_close() [1/2]

int64_t pineforge::pine_time_close ( int64_t bar_ms,
const std::string & tf,
const std::string & session,
const std::string & tz,
const std::string & chart_tf,
const std::string & syminfo_tz = std::string() )
inline

Definition at line 220 of file session_time.hpp.

References timeframe_time_close().

Referenced by pineforge::source::PineStrategyHost::time_close().

◆ pine_time_close() [2/2]

int64_t pineforge::pine_time_close ( int64_t bar_ms,
const std::string & tf,
const std::string & session,
const std::string & tz,
const std::string & chart_tf,
const std::string & sym_tz,
const std::string & sym_session )
inline

Definition at line 227 of file session_time.hpp.

References timeframe_time_close().

◆ pine_hour()

int pineforge::pine_hour ( int64_t bar_ms,
const std::string & tz )
inline

Definition at line 234 of file session_time.hpp.

References local_hour().

◆ pine_minute()

int pineforge::pine_minute ( int64_t bar_ms,
const std::string & tz )
inline

Definition at line 235 of file session_time.hpp.

References local_minute().

◆ pine_second()

int pineforge::pine_second ( int64_t bar_ms,
const std::string & tz )
inline

Definition at line 236 of file session_time.hpp.

References local_second().

◆ pine_dayofmonth()

int pineforge::pine_dayofmonth ( int64_t bar_ms,
const std::string & tz )
inline

Definition at line 237 of file session_time.hpp.

References local_dayofmonth().

◆ pine_dayofweek()

int pineforge::pine_dayofweek ( int64_t bar_ms,
const std::string & tz )
inline

Definition at line 238 of file session_time.hpp.

References local_dayofweek().

◆ pine_month()

int pineforge::pine_month ( int64_t bar_ms,
const std::string & tz )
inline

Definition at line 239 of file session_time.hpp.

References local_month().

◆ pine_year()

int pineforge::pine_year ( int64_t bar_ms,
const std::string & tz )
inline

Definition at line 240 of file session_time.hpp.

References local_year().

◆ pine_weekofyear()

int pineforge::pine_weekofyear ( int64_t bar_ms,
const std::string & tz )
inline

Definition at line 241 of file session_time.hpp.

References local_weekofyear().

◆ pine_time_tradingday()

int64_t pineforge::pine_time_tradingday ( int64_t bar_ms,
const std::string & session,
const std::string & tz )
inline

Definition at line 243 of file session_time.hpp.

References session_trading_day_open_ms().

◆ pine_session_ismarket() [1/2]

bool pineforge::pine_session_ismarket ( const std::string & session,
const std::string & tz,
int64_t bar_ms )
inline

◆ pine_session_ispremarket() [1/2]

bool pineforge::pine_session_ispremarket ( const std::string & session,
const std::string & tz,
int64_t bar_ms )
inline

◆ pine_session_ispostmarket() [1/2]

bool pineforge::pine_session_ispostmarket ( const std::string & session,
const std::string & tz,
int64_t bar_ms )
inline

◆ pine_session_ismarket() [2/2]

bool pineforge::pine_session_ismarket ( const std::string & session,
const std::string & tz,
int64_t bar_ms,
const std::string & chart_tf )
inline

Definition at line 263 of file session_time.hpp.

References session_in_market().

◆ pine_session_ispremarket() [2/2]

bool pineforge::pine_session_ispremarket ( const std::string & session,
const std::string & tz,
int64_t bar_ms,
const std::string & chart_tf )
inline

Definition at line 268 of file session_time.hpp.

References session_in_premarket().

◆ pine_session_ispostmarket() [2/2]

bool pineforge::pine_session_ispostmarket ( const std::string & session,
const std::string & tz,
int64_t bar_ms,
const std::string & chart_tf )
inline

Definition at line 273 of file session_time.hpp.

References session_in_postmarket().

◆ pine_float_eq()

bool pineforge::pine_float_eq ( double a,
double b )
inline

Definition at line 19 of file pine_float_compare.hpp.

References float_band_eq().

◆ pine_float_ne()

bool pineforge::pine_float_ne ( double a,
double b )
inline

Definition at line 20 of file pine_float_compare.hpp.

References float_band_ne().

◆ pine_float_gt()

bool pineforge::pine_float_gt ( double a,
double b )
inline

Definition at line 21 of file pine_float_compare.hpp.

References float_band_gt().

◆ pine_float_lt()

bool pineforge::pine_float_lt ( double a,
double b )
inline

Definition at line 22 of file pine_float_compare.hpp.

References float_band_lt().

◆ pine_float_ge()

bool pineforge::pine_float_ge ( double a,
double b )
inline

Definition at line 23 of file pine_float_compare.hpp.

References float_band_ge().

◆ pine_float_le()

bool pineforge::pine_float_le ( double a,
double b )
inline

Definition at line 24 of file pine_float_compare.hpp.

References float_band_le().

◆ str_format()

std::string pineforge::str_format ( const std::string & fmt,
const std::vector< std::string > & args )

Referenced by pine_str_format().

◆ str_format_time()

std::string pineforge::str_format_time ( long long timestamp_ms,
const std::string & format,
const std::string & timezone )

Referenced by pine_str_format_time().

◆ str_match()

std::string pineforge::str_match ( const std::string & source,
const std::string & regex_pattern )

Referenced by pine_str_match().

◆ str_split()

std::vector< std::string > pineforge::str_split ( const std::string & source,
const std::string & separator )

Referenced by pine_str_split().

◆ str_tostring()

std::string pineforge::str_tostring ( double value,
const std::string & format_mode = "",
double mintick = 0.0 )

Referenced by pine_str_tostring().

◆ pine_str_format()

std::string pineforge::pine_str_format ( const std::string & fmt,
const std::vector< std::string > & args )
inline

Definition at line 27 of file str_utils.hpp.

References str_format().

◆ pine_str_format_time()

std::string pineforge::pine_str_format_time ( long long timestamp_ms,
const std::string & format,
const std::string & timezone )
inline

Definition at line 32 of file str_utils.hpp.

References str_format_time().

◆ pine_str_match()

std::string pineforge::pine_str_match ( const std::string & source,
const std::string & regex_pattern )
inline

Definition at line 38 of file str_utils.hpp.

References str_match().

◆ pine_str_split()

std::vector< std::string > pineforge::pine_str_split ( const std::string & source,
const std::string & separator )
inline

Definition at line 43 of file str_utils.hpp.

References str_split().

◆ pine_str_tostring()

std::string pineforge::pine_str_tostring ( double value,
const std::string & format_mode = "",
double mintick = 0.0 )
inline

Definition at line 48 of file str_utils.hpp.

References str_tostring().

◆ float_band_eq()

bool pineforge::float_band_eq ( double a,
double b )
inline

◆ float_band_ne()

bool pineforge::float_band_ne ( double a,
double b )
inline

Definition at line 45 of file ta_compare_band.hpp.

References float_band_eq().

Referenced by pine_float_ne().

◆ float_band_gt()

bool pineforge::float_band_gt ( double a,
double b )
inline

Definition at line 50 of file ta_compare_band.hpp.

References float_band_eq().

Referenced by pine_float_gt().

◆ float_band_lt()

bool pineforge::float_band_lt ( double a,
double b )
inline

Definition at line 55 of file ta_compare_band.hpp.

References float_band_eq().

Referenced by pine_float_lt().

◆ float_band_ge()

bool pineforge::float_band_ge ( double a,
double b )
inline

Definition at line 60 of file ta_compare_band.hpp.

References float_band_eq().

Referenced by pine_float_ge().

◆ float_band_le()

bool pineforge::float_band_le ( double a,
double b )
inline

Definition at line 65 of file ta_compare_band.hpp.

References float_band_eq().

Referenced by pine_float_le().

◆ tf_to_seconds()

int pineforge::tf_to_seconds ( const std::string & tf)

Convert a TradingView timeframe string to seconds.

Minute-based: "1","5","15","30","60","120","240" => minutes * 60 Day-based: "D","1D" => 86400 Week-based: "W","1W" => 604800 Month-based: "M","1M" => -1 (calendar-based, not fixed seconds)

Referenced by pineforge::source::PineScheduler::bar(), safe_tf_to_seconds(), pineforge::source::PineStrategyHost::set_aux_security_feed(), tf_is_daily(), tf_is_intraday(), and pineforge::source::PineStrategyHost::validate_security_timeframes().

◆ tf_multiplier()

int pineforge::tf_multiplier ( const std::string & tf)
inline

Extract the numeric multiplier from a TF string (e.g. "15" -> 15, "D" -> 1).

Definition at line 32 of file timeframe.hpp.

◆ tf_is_intraday()

bool pineforge::tf_is_intraday ( const std::string & tf)
inline

Definition at line 41 of file timeframe.hpp.

References kSecPerDay, and tf_to_seconds().

◆ tf_is_daily()

bool pineforge::tf_is_daily ( const std::string & tf)
inline

Definition at line 46 of file timeframe.hpp.

References kSecPerDay, and tf_to_seconds().

◆ tf_is_weekly()

bool pineforge::tf_is_weekly ( const std::string & tf)
inline

Definition at line 50 of file timeframe.hpp.

◆ tf_is_monthly()

bool pineforge::tf_is_monthly ( const std::string & tf)
inline

Definition at line 54 of file timeframe.hpp.

◆ tf_is_seconds()

bool pineforge::tf_is_seconds ( const std::string & tf)
inline

Definition at line 58 of file timeframe.hpp.

◆ tf_change() [1/2]

bool pineforge::tf_change ( int64_t prev_ms,
int64_t curr_ms,
const std::string & tf )

Check if prev/curr timestamps cross a timeframe boundary.

Referenced by pineforge::source::PineScheduler::input(), and pineforge::source::PineScheduler::run_begin().

◆ tf_ratio()

int pineforge::tf_ratio ( const std::string & input_tf,
const std::string & target_tf )

Compute how many input bars fit into one target bar.

Returns positive int for ratio-based, -1 for calendar-based (month), -2 if target < input (error).

Referenced by pineforge::source::PineScheduler::bar(), pineforge::source::PineStrategyHost::prepare_native_begin(), pineforge::source::PineExecutionAdapter::project(), and pineforge::source::PineScheduler::run_begin().

◆ detect_timeframe()

std::string pineforge::detect_timeframe ( const Bar * bars,
int n,
int max_samples = 100 )

Detect the timeframe string from an array of bars by computing the median timestamp delta and mapping to the nearest standard TF.

Returns a TradingView-style TF string (e.g. "1", "5", "15", "60", "D", "W"). Uses up to the first max_samples bars for detection. Returns "1" if detection fails (< 2 bars or irregular data).

Referenced by pineforge::source::PineStrategyHost::prepare_native_begin(), and pineforge::source::PineExecutionAdapter::project().

◆ calendar_period_for()

CalendarPeriod pineforge::calendar_period_for ( const std::string & tf)

Determine the calendar period for a target TF string.

Referenced by tf_is_daily_or_higher().

◆ tf_is_daily_or_higher()

bool pineforge::tf_is_daily_or_higher ( const std::string & tf)
inline

True for a daily-or-higher chart timeframe ("D", "1D", "2D", "W", "M"): a bar that covers whole session days rather than a time of day (the aggregation path's CALENDAR classification).

Intraday timeframes and an empty (undetected) one are false.

Definition at line 90 of file timeframe.hpp.

References calendar_period_for(), and NONE.

◆ crosses_boundary() [1/2]

bool pineforge::crosses_boundary ( int64_t prev_ms,
int64_t curr_ms,
CalendarPeriod period )

Check if two timestamps (Unix milliseconds) fall in different calendar periods.

◆ crosses_boundary() [2/2]

bool pineforge::crosses_boundary ( int64_t prev_ms,
int64_t curr_ms,
CalendarPeriod period,
const std::string & tz,
const std::string & session )

Timezone/session-aware variants.

The tz-less forms above evaluate the calendar in UTC and intraday buckets on the epoch grid — exactly TV's behavior for 24x7 symbols (the corpus regime). Session symbols (equities RTH, forex) anchor HTF buckets on the exchange clock instead: daily boundaries at symbol-local midnight, intraday buckets offset by the symbol's day stamp – the session open, except OANDA's 1800-1700 metals session whose day (and TradingView's "45"/"240" grid) rolls at the 17:00 ET forex roll one hour before it opens (session_day_stamp_offset_minutes in timeframe.cpp cites the pin). With tz="UTC" and session ""/"24x7" these are bit-identical to the UTC forms, so existing callers are unaffected.

◆ tf_change() [2/2]

bool pineforge::tf_change ( int64_t prev_ms,
int64_t curr_ms,
const std::string & tf,
const std::string & tz,
const std::string & session )

◆ session_day_index()

int64_t pineforge::session_day_index ( int64_t ms,
const std::string & tz,
const std::string & session )

Ordinal of the session day containing ms (days since epoch on the session clock).

UTC + no session: ms / kMsPerDay.

◆ session_period_open_ms()

int64_t pineforge::session_period_open_ms ( int64_t ms,
const std::string & tz,
const std::string & session,
CalendarPeriod period )

Open (Unix ms) of the symbol's D/W/M bar that contains ms: the day stamp of the period's first session-day (17:00 ET on OANDA 1800-1700, the session open elsewhere).

CalendarPeriod::NONE returns ms unchanged.

◆ session_intraday_bucket_open_ms()

int64_t pineforge::session_intraday_bucket_open_ms ( int64_t ms,
int64_t bucket_sec,
const std::string & tz,
const std::string & session )

Open (Unix ms) of the bucket_sec-wide intraday bucket that contains ms on the symbol's day-stamp-anchored grid: exchange-tz time since local midnight + day stamp, floored to the bucket width.

This is THE intraday HTF grid — request.security's ratio buckets (TimeframeAggregator::bucket_open_ms), tf_change and time("<intraday tf>") / time_close all read it (pin-time-hours: time("60") on NYSE:F is 09:30 / 10:30 / .. / 15:30 ET, time("240") on NSE:NIFTY 09:15 / 13:15 IST, on OANDA:XAUUSD 17:00 ET + 4h*k). With tz="UTC" and session ""/"24x7" it is the epoch grid, bit-identical to the tz-less forms. bucket_sec <= 0 returns ms.

◆ session_covered_instant_ms()

int64_t pineforge::session_covered_instant_ms ( int64_t ms,
const std::string & tz,
const std::string & session )

The session instant a native CALENDAR chart stamp covers.

A stamp inside its session (open to exclusive close) returns unchanged. A stamp in the inter-session gap – before its session-day's open (the 1800-1700 day stamp hour) or at / after its close – covers the session about to open – OANDA stamps daily FX/metal bars at the 17:00 ET break under an 1800-1700 session – and rolls forward to that session's open. ""/24x7 sessions have no gap and always return ms unchanged.

◆ session_period_close_ms()

int64_t pineforge::session_period_close_ms ( int64_t ms,
const std::string & tz,
const std::string & session,
CalendarPeriod period )

Exclusive close (Unix ms) of the symbol's D/W/M bar that contains ms: DAY -> session-day open + session length (16:00 ET on equities, the next 17:00 ET on forex, next midnight on 24x7); WEEK / MONTH -> the open of the next period's first session-day.

CalendarPeriod::NONE returns ms.

◆ session_period_last_traded_close_ms()

int64_t pineforge::session_period_last_traded_close_ms ( int64_t ms,
const std::string & tz,
const std::string & session,
CalendarPeriod period )

Exclusive close (Unix ms) of the LAST TRADED session-day of the D/W/M bar that contains ms: DAY is session_period_close_ms; WEEK / MONTH step back from the period's last session-day over weekend TRADING dates (Saturday / Sunday never hold a session on exchange-calendar symbols), so an equity week ends Friday 16:00 ET, a month whose last calendar day is a weekend ends on its last Friday, and the forex week ends Friday 17:00 ET (the Friday-open session is Saturday's trading date).

Exchange holidays are not modelled. CalendarPeriod::NONE returns ms.

◆ build_native_day_partition()

bool pineforge::build_native_day_partition ( NativeDayPartition & out,
const std::string & tz,
const std::string & session,
const std::vector< int64_t > & stamps,
const Bar * input_bars,
int n_input )

Build the partition for the symbol clock (tz, session) from the native daily stamps and the chart's input bars (the trade instants: the last input bar before the next stamp, bounded by the last stamp's nominal session-day close; the stamp itself when no input bar lies in the period).

Returns false – and leaves out empty – for no stamps or non-increasing stamps.

◆ native_day_partition_index()

int pineforge::native_day_partition_index ( const NativeDayPartition & p,
int64_t ms )

Index of the native period holding ms under p: -1 before the first stamp and at / after the last stamp's nominal session-day close.

◆ set_active_native_day_partition()

const NativeDayPartition * pineforge::set_active_native_day_partition ( const NativeDayPartition * p)

The calling thread's active chart partition, read by session_day_index / session_period_open_ms / session_period_close_ms / session_period_last_traded_close_ms / crosses_boundary (and so by tf_change, the symbol-clock pine_time forms and ta::VWAP's session anchor) whenever their (tz, session) equal the partition's.

nullptr (the default) leaves every rule nominal. set_ returns the previous pointer; BacktestEngine::run installs its chart partition through NativeDayPartitionScope for exactly the run's bar loop.

Referenced by pineforge::NativeDayPartitionScope::NativeDayPartitionScope(), and pineforge::NativeDayPartitionScope::~NativeDayPartitionScope().

◆ active_native_day_partition()

const NativeDayPartition * pineforge::active_native_day_partition ( )

◆ safe_tf_to_seconds()

static int pineforge::safe_tf_to_seconds ( const std::string & tf)
static

◆ sort_same_bar_exit_trades()

static void pineforge::sort_same_bar_exit_trades ( std::vector< Trade > & trades,
source::PineExecutionAdapter & adapter )
static

Variable Documentation

◆ is_pine_map_snapshot_value_v

template<typename T>
bool pineforge::is_pine_map_snapshot_value_v
inlineconstexpr
Initial value:

Definition at line 82 of file map.hpp.

◆ kPineFloatEqualityBand

double pineforge::kPineFloatEqualityBand = kFloatCompareBand
inlineconstexpr

Definition at line 17 of file pine_float_compare.hpp.

◆ kFloatCompareBand

double pineforge::kFloatCompareBand = 1e-10
inlineconstexpr

Definition at line 36 of file ta_compare_band.hpp.

Referenced by float_band_eq().

◆ kSecPerDay

int64_t pineforge::kSecPerDay = 86400
inlineconstexpr

Definition at line 11 of file timeframe.hpp.

Referenced by tf_is_daily(), and tf_is_intraday().

◆ kMsPerDay

int64_t pineforge::kMsPerDay = 86400000
inlineconstexpr

Definition at line 12 of file timeframe.hpp.