PineForge v0.13.1-379-g9b50973
Deterministic PineScript v6 backtest runtime — C ABI reference
Loading...
Searching...
No Matches
metrics.hpp
Go to the documentation of this file.
1#pragma once
2// Pure metric computations over closed-trade arrays and equity curves.
3// No BacktestEngine dependency: unit-testable standalone, called by
4// fill_report. Conventions (NaN rules, positive-magnitude losses, even-
5// trade handling) are documented per-field in <pineforge/pineforge.h>.
6// pineforge.h MUST precede engine.hpp (PINEFORGE_NO_STRATEGY_DECLS; see engine.hpp).
8#include <pineforge/engine.hpp> // TradeC
9#include <string>
10
11namespace pineforge {
12namespace metrics {
13
14enum class TradeFilter { ALL, LONG, SHORT };
15
17 TradeFilter filter, double initial_capital);
18
19// Acquires the global timezone lock (tz_util::ScopedTimezone) when chart_tz
20// is non-UTC; MUST NOT be called while already holding a ScopedTimezone
21// (non-recursive mutex -- deadlock). See src/timezone.hpp.
23 double initial_capital,
24 const std::string& chart_tz,
25 double first_open, double last_close,
26 int64_t bars_in_market, double net_profit);
27
28} // namespace metrics
29} // namespace pineforge
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_trade_stats_t compute_trade_stats(const TradeC *trades, int n, TradeFilter filter, double initial_capital)
Single per-script-bar equity point.
Definition pineforge.h:325
Equity-curve-derived statistics (all-trades only, like TV).
Definition pineforge.h:259
Trade-level statistics block — computed once each for all / long / short.
Definition pineforge.h:196