|
PineForge unreleased
Deterministic PineScript v6 backtest runtime — C ABI reference
|
Namespaces | |
| namespace | fold_detail |
Data Structures | |
| class | ArrayCurve |
| Array point source, the first source of 3.3:535-543. More... | |
| struct | EquityFoldSnapshot |
| struct | EquityMetricInputs |
| class | EquityMetricsFold |
| class | EquityMetricsSecondPass |
| struct | EquityRatioResult |
| struct | EquityReturnSummary |
| struct | MetricsExtentPlanV1 |
| struct | MetricsExtentReceiptV1 |
| struct | MetricsExtentV1 |
| struct | MetricsMonthlyResultV1 |
| struct | MetricsRatioCurveV1 |
| struct | MetricsRatioTraceSinkV1 |
| struct | MetricsRatioTraceV1 |
| struct | MetricsStopBoundaryV1 |
| struct | MetricsStreamingConfigV1 |
| struct | MetricsStreamingResultV1 |
| struct | ScratchCurveReader |
| Minimal read boundary for the private binary curve (DESIGN 3.8). More... | |
| struct | ScratchCurveRegion |
| A region of the engine-private scratch file (3.8:902-909). More... | |
| class | SpillCurve |
| Scratch point source (3.3:535-546; 3.8:904-909). More... | |
| class | StreamingEquityRatiosV1 |
| class | TradeStatsAccumulator |
| Report-only O(1) trade fold (DESIGN 3.3:515-533,547-553). More... | |
Typedefs | |
| using | MetricsNeedMaskV1 = std::uint64_t |
| using | MetricsRatioTraceCallbackV1 = void (*)(void*, const MetricsRatioTraceV1&) |
Enumerations | |
| enum class | TradeFilter { ALL , LONG , SHORT } |
| enum class | MetricsStreamingStatusV1 : std::int32_t { Ok = 0 , NotImplemented = -1 , InvalidArgument = -2 , Busy = -3 } |
| enum class | StreamingSharpeV1 : std::uint32_t { Off = 0 , On = 1 } |
| enum class | MetricsRatioRouteV1 : std::uint32_t { Unavailable = 0 , Streaming = 1 , LegacyActualCurve = 2 , LegacyRerun = 3 } |
| enum class | MetricsExtentWitnessV1 : std::uint32_t { NotEvaluated = 0 , Match = 1 , Mismatch = 2 } |
| enum class | MetricsRouteReasonV1 : std::uint32_t { None = 0 , SharpeSwitchOff = 1 , ReturnsNeeded = 2 , CurveNeeded = 3 , PlainNo = 4 , NoExtentProof = 5 , NoRecoveryProof = 6 , NumericGuard = 7 , ExtentMismatch = 8 , LiveSnapshot = 9 , ExistingFailure = 10 , OrderedReplay = 11 , ScratchUnavailable = 12 } |
| enum class | MetricsStopBoundaryKindV1 : std::uint32_t { None = 0 , CompletedMark = 1 , IntraBar = 2 , MarginCallback = 3 } |
Functions | |
| pf_trade_stats_t | compute_trade_stats (const TradeC *trades, int n, TradeFilter filter, double initial_capital) |
| pf_equity_stats_t | compute_equity_stats (const pf_equity_point_t *curve, int64_t n, double initial_capital, const std::string &chart_tz, double first_open, double last_close, int64_t bars_in_market, double net_profit) |
| pf_equity_stats_t | compute_equity_stats (const pf_equity_point_t *curve, int64_t n, double initial_capital, const std::string &chart_tz, double first_open, double last_close, int64_t bars_in_market, double net_profit, int64_t observation_count) |
| std::int64_t | equity_month_key (std::int64_t time_ms, const std::string &chart_timezone) |
| bool | monthly_replay_time_supported_v1 (std::int64_t time_ms) |
| MetricsStreamingStatusV1 | make_streaming_equity_ratios_v1 (const MetricsStreamingConfigV1 &, const MetricsExtentPlanV1 &, MetricsRatioTraceSinkV1, std::unique_ptr< StreamingEquityRatiosV1 > &) |
| MetricsStreamingStatusV1 | enable_streaming_monthly_replay_v1 (StreamingEquityRatiosV1 &) |
| MetricsStreamingStatusV1 | streaming_monthly_result_v1 (const StreamingEquityRatiosV1 &, MetricsMonthlyResultV1 &) |
| pf_equity_stats_t | finalize_equity_metrics (const EquityFoldSnapshot &first, const EquityMetricInputs &inputs, const EquityRatioResult *ratios=nullptr) |
| pf_metrics_t | finalize_metrics (const EquityFoldSnapshot &first, const EquityMetricInputs &inputs, const pf_trade_stats_t &all, const pf_trade_stats_t &longs, const pf_trade_stats_t &shorts, const EquityRatioResult *ratios=nullptr) |
| PF_STATIC_ASSERT (sizeof(pf_equity_point_t)==24) | |
| PF_STATIC_ASSERT (offsetof(pf_equity_point_t, time_ms)==0) | |
| PF_STATIC_ASSERT (offsetof(pf_equity_point_t, equity)==8) | |
| PF_STATIC_ASSERT (offsetof(pf_equity_point_t, open_profit)==16) | |
| template<class PointSource> | |
| pf_equity_stats_t | compute_equity_stats (const PointSource &curve, std::int64_t n, double initial_capital, const std::string &chart_tz, double first_open, double last_close, std::int64_t bars_in_market, double net_profit) |
| Equity computation over the structural point-source interface above (3.3:531-546). | |
| template<class PointSource> | |
| pf_equity_stats_t | compute_equity_stats (const PointSource &curve, std::int64_t n, double initial_capital, const std::string &chart_tz, double first_open, double last_close, std::int64_t bars_in_market, double net_profit, std::int64_t observation_count) |
| Selected source has the final presented anchor and M window points: n=M+1, observation_count=M (including M=0). | |
| pf_equity_stats_t | compute_equity_stats (const report::EquityPointSourceV1 &curve, std::int64_t n, double initial_capital, const std::string &chart_tz, double first_open, double last_close, std::int64_t bars_in_market, double net_profit) |
| pf_equity_stats_t | compute_equity_stats (const report::EquityPointSourceV1 &curve, std::int64_t n, double initial_capital, const std::string &chart_tz, double first_open, double last_close, std::int64_t bars_in_market, double net_profit, std::int64_t observation_count) |
Variables | |
| constexpr MetricsNeedMaskV1 | kMetricsNeedSharpeBarV1 = 1ULL << 0 |
| constexpr MetricsNeedMaskV1 | kMetricsNeedSortinoBarV1 = 1ULL << 1 |
| constexpr MetricsNeedMaskV1 | kMetricsNeedMonthlyRatiosV1 = 1ULL << 2 |
| constexpr MetricsNeedMaskV1 | kMetricsNeedReturnsV1 = 1ULL << 3 |
| constexpr MetricsNeedMaskV1 | kMetricsNeedEquitySummaryV1 = 1ULL << 4 |
| constexpr MetricsNeedMaskV1 | kMetricsNeedTradeStatsV1 = 1ULL << 5 |
| constexpr MetricsNeedMaskV1 | kMetricsNeedCurveV1 = 1ULL << 6 |
| constexpr MetricsNeedMaskV1 | kMetricsNeedAllV1 = (1ULL << 7) - 1 |
| constexpr std::size_t | kMetricsMonthEndLimitV1 = 4096 |
| using pineforge::metrics::MetricsNeedMaskV1 = std::uint64_t |
Definition at line 47 of file metrics_fold.hpp.
| using pineforge::metrics::MetricsRatioTraceCallbackV1 = void (*)(void*, const MetricsRatioTraceV1&) |
Definition at line 179 of file metrics_fold.hpp.
|
strong |
| Enumerator | |
|---|---|
| ALL | |
| LONG | |
| SHORT | |
Definition at line 14 of file metrics.hpp.
|
strong |
| Enumerator | |
|---|---|
| Ok | |
| NotImplemented | |
| InvalidArgument | |
| Busy | |
Definition at line 40 of file metrics_fold.hpp.
|
strong |
| Enumerator | |
|---|---|
| Off | |
| On | |
Definition at line 46 of file metrics_fold.hpp.
|
strong |
| Enumerator | |
|---|---|
| Unavailable | |
| Streaming | |
| LegacyActualCurve | |
| LegacyRerun | |
Definition at line 78 of file metrics_fold.hpp.
|
strong |
| Enumerator | |
|---|---|
| NotEvaluated | |
| Match | |
| Mismatch | |
Definition at line 81 of file metrics_fold.hpp.
|
strong |
| Enumerator | |
|---|---|
| None | |
| SharpeSwitchOff | |
| ReturnsNeeded | |
| CurveNeeded | |
| PlainNo | |
| NoExtentProof | |
| NoRecoveryProof | |
| NumericGuard | |
| ExtentMismatch | |
| LiveSnapshot | |
| ExistingFailure | |
| OrderedReplay | |
| ScratchUnavailable | |
Definition at line 84 of file metrics_fold.hpp.
|
strong |
| Enumerator | |
|---|---|
| None | |
| CompletedMark | |
| IntraBar | |
| MarginCallback | |
Definition at line 90 of file metrics_fold.hpp.
| pf_trade_stats_t pineforge::metrics::compute_trade_stats | ( | const TradeC * | trades, |
| int | n, | ||
| TradeFilter | filter, | ||
| double | initial_capital ) |
| pf_equity_stats_t pineforge::metrics::compute_equity_stats | ( | const pf_equity_point_t * | curve, |
| int64_t | n, | ||
| double | initial_capital, | ||
| const std::string & | chart_tz, | ||
| double | first_open, | ||
| double | last_close, | ||
| int64_t | bars_in_market, | ||
| double | net_profit ) |
| pf_equity_stats_t pineforge::metrics::compute_equity_stats | ( | const pf_equity_point_t * | curve, |
| int64_t | n, | ||
| double | initial_capital, | ||
| const std::string & | chart_tz, | ||
| double | first_open, | ||
| double | last_close, | ||
| int64_t | bars_in_market, | ||
| double | net_profit, | ||
| int64_t | observation_count ) |
| std::int64_t pineforge::metrics::equity_month_key | ( | std::int64_t | time_ms, |
| const std::string & | chart_timezone ) |
|
inline |
Definition at line 31 of file metrics_fold.hpp.
Referenced by pineforge::engine_script_run_v19::BacktestEngine::report_equity_month_key().
| MetricsStreamingStatusV1 pineforge::metrics::make_streaming_equity_ratios_v1 | ( | const MetricsStreamingConfigV1 & | , |
| const MetricsExtentPlanV1 & | , | ||
| MetricsRatioTraceSinkV1 | , | ||
| std::unique_ptr< StreamingEquityRatiosV1 > & | ) |
| MetricsStreamingStatusV1 pineforge::metrics::enable_streaming_monthly_replay_v1 | ( | StreamingEquityRatiosV1 & | ) |
| MetricsStreamingStatusV1 pineforge::metrics::streaming_monthly_result_v1 | ( | const StreamingEquityRatiosV1 & | , |
| MetricsMonthlyResultV1 & | ) |
| pf_equity_stats_t pineforge::metrics::finalize_equity_metrics | ( | const EquityFoldSnapshot & | first, |
| const EquityMetricInputs & | inputs, | ||
| const EquityRatioResult * | ratios = nullptr ) |
Referenced by finalize_metrics().
|
inline |
Definition at line 567 of file metrics_fold.hpp.
References pf_metrics_t::all, and finalize_equity_metrics().
| pineforge::metrics::PF_STATIC_ASSERT | ( | sizeof(pf_equity_point_t) | = =24 | ) |
| pineforge::metrics::PF_STATIC_ASSERT | ( | offsetof(pf_equity_point_t, time_ms) | = =0 | ) |
| pineforge::metrics::PF_STATIC_ASSERT | ( | offsetof(pf_equity_point_t, equity) | = =8 | ) |
| pineforge::metrics::PF_STATIC_ASSERT | ( | offsetof(pf_equity_point_t, open_profit) | = =16 | ) |
| pf_equity_stats_t pineforge::metrics::compute_equity_stats | ( | const PointSource & | curve, |
| std::int64_t | n, | ||
| double | initial_capital, | ||
| const std::string & | chart_tz, | ||
| double | first_open, | ||
| double | last_close, | ||
| std::int64_t | bars_in_market, | ||
| double | net_profit ) |
Equity computation over the structural point-source interface above (3.3:531-546).
Same parameters, guards and formulas as the array overload in metrics.hpp; only curve[i] goes through PointSource. n is the number of points to walk (within source.size()), not an observation denominator. Ordinary calls use observation_count=n; the second overload states it.
Five sequential walks, no growing vectors: drawdown/runup walk, generated month-end returns twice, generated per-bar returns twice. Pass 1 sums and counts; pass 2 accumulates variance/downside in today's exact order, with today's final-n/span risk-free rate. Do not change grouping/rounding or -ffp-contract=off (3.3:518-543). A non-UTC chart holds ONE ScopedTimezone for the whole fill-time walk, never a nested lock (3.3:545-546). These are template declarations, with no metric bodies/instantiations.
| pf_equity_stats_t pineforge::metrics::compute_equity_stats | ( | const PointSource & | curve, |
| std::int64_t | n, | ||
| double | initial_capital, | ||
| const std::string & | chart_tz, | ||
| double | first_open, | ||
| double | last_close, | ||
| std::int64_t | bars_in_market, | ||
| double | net_profit, | ||
| std::int64_t | observation_count ) |
Selected source has the final presented anchor and M window points: n=M+1, observation_count=M (including M=0).
The anchor is the first return's base, not a bar. Only time_in_market_pct uses the observation denominator, as the existing metrics.hpp overload documents (3.6:745-749,769-773). Metrics read the scratch curve at each report read; they do not consume it or change the engine's held point (3.2:499-509).
| pf_equity_stats_t pineforge::metrics::compute_equity_stats | ( | const report::EquityPointSourceV1 & | curve, |
| std::int64_t | n, | ||
| double | initial_capital, | ||
| const std::string & | chart_tz, | ||
| double | first_open, | ||
| double | last_close, | ||
| std::int64_t | bars_in_market, | ||
| double | net_profit ) |
| pf_equity_stats_t pineforge::metrics::compute_equity_stats | ( | const report::EquityPointSourceV1 & | curve, |
| std::int64_t | n, | ||
| double | initial_capital, | ||
| const std::string & | chart_tz, | ||
| double | first_open, | ||
| double | last_close, | ||
| std::int64_t | bars_in_market, | ||
| double | net_profit, | ||
| std::int64_t | observation_count ) |
|
constexpr |
Definition at line 48 of file metrics_fold.hpp.
|
constexpr |
Definition at line 49 of file metrics_fold.hpp.
|
constexpr |
Definition at line 50 of file metrics_fold.hpp.
|
constexpr |
Definition at line 51 of file metrics_fold.hpp.
|
constexpr |
Definition at line 52 of file metrics_fold.hpp.
|
constexpr |
Definition at line 53 of file metrics_fold.hpp.
|
constexpr |
Definition at line 54 of file metrics_fold.hpp.
|
constexpr |
Definition at line 55 of file metrics_fold.hpp.
|
constexpr |
Definition at line 58 of file metrics_fold.hpp.