|
PineForge unreleased
Deterministic PineScript v6 backtest runtime — C ABI reference
|
Namespaces | |
| namespace | detail |
| namespace | multi_day_detail |
| namespace | value_field |
The closed vocabulary of field: "<sink>.<argument>". | |
Typedefs | |
| using | SourceId = std::string |
| using | PineNativeHost = PineStrategyHost |
| using | FixtureIntentRow = PineStrategyHost::FixtureIntentRow |
| using | FixtureIntentKind = PineStrategyHost::FixtureIntentKind |
Enumerations | |
| enum class | PineOrderFamily : std::uint8_t { Entry = 0 , Close = 1 , CloseAll = 2 , ExitLimit = 3 , ExitStop = 4 , ExitTrail = 5 , Order = 6 , Margin = 7 , Risk = 8 } |
| enum class | PineCancellationCause : std::int32_t { None = 0 , Replacement = 1 , Dependency = 2 , Admission = 3 , Explicit = 4 } |
| enum class | StrategyValueReason { nonfinite , invalid_unicode , numeric_overflow } |
Functions | |
| std::string | tradingview_intrabar_timeframe (std::string_view chart_tf) |
The intrabar timeframe TradingView's bar magnifier walks on a chart of chart_tf, from the table in TradingView's help centre ("What is bar
magnifier backtesting mode"), each row covering the chart timeframes from it up to the next one: below 30S 1S, 30S 5S, 1 10S, 5 30S, 10 1, 15 2, 30 5, 60 10, 240 30, 1D 60, 3D 240, 1W and up 1D. | |
| std::vector< Bar > | tradingview_magnifier_bars (const Bar *bars, int n, const std::string &input_tf, const std::string &script_tf, const std::string &session, const std::string &timezone) |
The lower-timeframe path TradingView's bar magnifier walks for every chart bar of a run whose chart bars are aggregated from bars (input timeframe input_tf, chart timeframe script_tf, the symbol's session in timezone), as bars for IntrabarPath::lower_tf on the input's own grid. | |
| std::unique_ptr< NativeLowerPathSource > | make_magnifier_path_source (const Bar *bars, int n, const std::string &input_tf, const std::string &script_tf, const std::string &session, const std::string &timezone) |
| The same logical path without retaining the input or a whole-run path. | |
| bool | modeled_pine_input (NativePriceProvenance provenance) noexcept |
| double | tv_money_round (double value) |
| double | tv_money_floor_lot (double qty, double step) |
| const std::string & | pine_enum_str_at (const std::string *table, std::size_t n, int idx) |
| bool | same_calendar_timeframe (const native_calendar::Timeframe &requested, const native_calendar::Timeframe &chart) noexcept |
| int | simple_ta_length (double value, const char *function, const char *argument) |
| int | simple_ta_length (int value, const char *function, const char *argument) |
| int | simple_ta_length (std::int64_t value, const char *function, const char *argument) |
| double | ta_number (double value) |
| double | ta_number (int value) |
| double | ta_number (std::int64_t value) |
| std::shared_ptr< TimeframeAggregator::PeriodSource > | make_multi_day_period_source (const MultiDayFeeds &feeds) |
The N-day partition of feeds, or null where TradingView's rule yields none: fewer than two days, a session that does not parse, no held session day, no period opening at or before the first held day, an open that does not come after the one before it, or a date whose local noon does not exist. | |
| const char * | instrument_feed_field_name (NativeRunSpecField field) noexcept |
| RunFailureValue | run_spec_field_failure (NativeRunSpecField field) noexcept |
| std::optional< double > | checked_mul (double left, double right) noexcept |
| std::optional< double > | checked_div (double left, double right) noexcept |
| std::optional< double > | checked_add (double left, double right) noexcept |
| void | admit_strategy_entry (const std::string &id, bool, double limit_price, double stop_price, double, const std::string &comment, const std::string &oca_name, int, int) |
| void | admit_strategy_close (const std::string &id, const std::string &comment, double, double, bool) |
| void | admit_strategy_close_token (const std::string &id, const std::string &comment, double qty, double qty_percent, bool immediately, std::uint64_t) |
| void | admit_strategy_close_all () noexcept |
| void | admit_strategy_exit (const std::string &id, const std::string &from_entry, double limit_price, double, double, double trail_offset, double trail_price, double, const std::string &comment, double, const std::string &oca_name, double profit_ticks, double loss_ticks) |
| void | admit_strategy_exit_cancel_bracket (const std::string &exit_id, const std::string &from_entry, const std::string &comment) |
| void | admit_strategy_cancel (const std::string &id) |
| void | admit_strategy_cancel_all () noexcept |
| void | admit_strategy_order (const std::string &id, bool, double, double limit_price, double stop_price, const std::string &oca_name, int) |
| const char * | strategy_value_reason_name (StrategyValueReason reason) noexcept |
| void | throw_strategy_value_invalid (const char *field, StrategyValueReason reason) |
| The coded failure of a source-owned invalid actionable value. | |
| bool | declaration_value_is_invalid (double value) noexcept |
| void | admit_strategy_declaration (const PineStrategyConfig &config) |
| void | admit_pine_risk_max_drawdown (double value, bool) |
| void | admit_pine_risk_max_intraday_loss (double value, bool) |
| void | admit_pine_risk_max_position_size (double value) |
| void | assert_admitted_pine_replay_risk_config (const PineReplayRiskConfig &snapshot) |
Variables | |
| constexpr char | kSourceAdapterDomain [] = "pineforge-source-adapter/v4" |
| constexpr char | kMarginCallLabel [] = "__margin_call__" |
| constexpr char | kIntradayLossComment [] = "Close Position (Max intraday Loss)" |
| constexpr char | kFillCapCommentPrefix [] |
| constexpr std::uint32_t | kCoofLoopGuard = 1U << 20 |
| constexpr char | kSourceSecurityDomain [] = "pineforge-source-security/v6" |
| constexpr char | kSourceSymbolDataDomain [] = "pineforge-source-symbol-data/v1" |
| constexpr std::size_t | kMultiDayWindow = 16 |
| The most period opens a multi-day period source holds at once: the recent ones it answers short questions from, and the next one ahead. | |
| constexpr std::size_t | kUnorderedRescanDays = 366 |
| Bounds the fallback's retained trading-date slots to one calendar year, including a leap year; N-day counting restarts each year. | |
| constexpr bool | kDeclarationNanIsInvalid = false |
| using pineforge::source::SourceId = std::string |
Definition at line 42 of file pine_adapter.hpp.
Definition at line 10 of file pine_native_host.hpp.
Definition at line 11 of file pine_native_host.hpp.
Definition at line 12 of file pine_native_host.hpp.
|
strong |
| Enumerator | |
|---|---|
| Entry | |
| Close | |
| CloseAll | |
| ExitLimit | |
| ExitStop | |
| ExitTrail | |
| Order | |
| Margin | |
| Risk | |
Definition at line 133 of file pine_adapter.hpp.
|
strong |
| Enumerator | |
|---|---|
| None | |
| Replacement | |
| Dependency | |
| Admission | |
| Explicit | |
Definition at line 155 of file pine_adapter.hpp.
|
strong |
| Enumerator | |
|---|---|
| nonfinite | |
| invalid_unicode | |
| numeric_overflow | |
Definition at line 17 of file pine_value_admission.hpp.
| std::string pineforge::source::tradingview_intrabar_timeframe | ( | std::string_view | chart_tf | ) |
The intrabar timeframe TradingView's bar magnifier walks on a chart of chart_tf, from the table in TradingView's help centre ("What is bar
magnifier backtesting mode"), each row covering the chart timeframes from it up to the next one: below 30S 1S, 30S 5S, 1 10S, 5 30S, 10 1, 15 2, 30 5, 60 10, 240 30, 1D 60, 3D 240, 1W and up 1D.
Empty for a literal that does not parse. R5 lane MAG-INTRABAR measured every row the population uses against TradingView's own request.security_lower_tf bars and magnified tapes (tests/fixtures/magnifier_intrabars).
Definition at line 45 of file magnifier_intrabars.cpp.
Referenced by tradingview_magnifier_bars().
| std::vector< Bar > pineforge::source::tradingview_magnifier_bars | ( | const Bar * | bars, |
| int | n, | ||
| const std::string & | input_tf, | ||
| const std::string & | script_tf, | ||
| const std::string & | session, | ||
| const std::string & | timezone ) |
The lower-timeframe path TradingView's bar magnifier walks for every chart bar of a run whose chart bars are aggregated from bars (input timeframe input_tf, chart timeframe script_tf, the symbol's session in timezone), as bars for IntrabarPath::lower_tf on the input's own grid.
TradingView's intrabars are the symbol's regular bars at the table's timeframe: anchored at the session day's open, cut at its close, and each owned by the chart bar that holds its LAST minute, so on a 15-minute chart a 2-minute intrabar that straddles a chart boundary belongs to the later bar. A chart bar's path is its own open, its owned intrabars (each open a discrete point, then its extremes and close), then its own close. Here that is:
The input bars come back unchanged when the table's intrabar is the input timeframe itself (a 10-minute chart on 1-minute bars), cannot be built from it (a 1- or 5-minute chart needs 10- or 30-second bars), or when a bar's calendar interval cannot be resolved.
Definition at line 73 of file magnifier_intrabars.cpp.
References pineforge::Bar::close, pineforge::Bar::high, pineforge::input, pineforge::Bar::low, pineforge::Bar::open, pineforge::Bar::timestamp, tradingview_intrabar_timeframe(), and pineforge::Bar::volume.
Referenced by pineforge::source::PineExecutionAdapter::project().
| std::unique_ptr< NativeLowerPathSource > pineforge::source::make_magnifier_path_source | ( | const Bar * | bars, |
| int | n, | ||
| const std::string & | input_tf, | ||
| const std::string & | script_tf, | ||
| const std::string & | session, | ||
| const std::string & | timezone ) |
The same logical path without retaining the input or a whole-run path.
Input stays immutable and alive through the consumer's public run exit. Construction decides whole-input fallback and caches count; whole walks have independent cursors, and segment storage survives all const reads.
Definition at line 437 of file magnifier_intrabars.cpp.
Referenced by pineforge::source::PineExecutionAdapter::project().
|
inlinenoexcept |
Definition at line 7 of file pine_input_domain.hpp.
|
inline |
Definition at line 9 of file pine_policy_support.hpp.
|
inline |
Definition at line 17 of file pine_policy_support.hpp.
|
inline |
Definition at line 28 of file pine_policy_support.hpp.
|
inlinenoexcept |
Definition at line 7 of file pine_security_timeframe.hpp.
| int pineforge::source::simple_ta_length | ( | double | value, |
| const char * | function, | ||
| const char * | argument ) |
Definition at line 81 of file pine_ta_length.cpp.
Referenced by pineforge::source::PineSupertrend::compute().
| int pineforge::source::simple_ta_length | ( | int | value, |
| const char * | function, | ||
| const char * | argument ) |
Definition at line 88 of file pine_ta_length.cpp.
References pineforge::is_na().
| int pineforge::source::simple_ta_length | ( | std::int64_t | value, |
| const char * | function, | ||
| const char * | argument ) |
Definition at line 94 of file pine_ta_length.cpp.
References pineforge::is_na().
|
inline |
Definition at line 57 of file pine_ta_length.hpp.
|
inline |
Definition at line 58 of file pine_ta_length.hpp.
References pineforge::is_na(), and pineforge::na< double >().
|
inline |
Definition at line 61 of file pine_ta_length.hpp.
References pineforge::is_na(), and pineforge::na< double >().
|
inline |
The N-day partition of feeds, or null where TradingView's rule yields none: fewer than two days, a session that does not parse, no held session day, no period opening at or before the first held day, an open that does not come after the one before it, or a date whose local noon does not exist.
Ordered planning walks the feeds twice (the first and last held day, then every period once to prove the partition whole). An unordered feed instead uses full-feed rescans with at most kUnorderedRescanDays retained date slots; neither path keeps a table of all held days.
Definition at line 719 of file multi_day_periods.hpp.
References pineforge::source::MultiDayFeeds::aux, pineforge::source::MultiDayFeeds::chart, pineforge::source::MultiDayFeeds::daily_chart, pineforge::source::MultiDayFeeds::days, pineforge::source::MultiDayFeeds::exchange_calendar, pineforge::source::MultiDayFeeds::n_aux, pineforge::source::MultiDayFeeds::n_chart, pineforge::source::MultiDayFeeds::session, pineforge::source::MultiDayFeeds::tz, and pineforge::native_calendar::native_calendar_v2::NativeCivilDate::year.
|
noexcept |
|
noexcept |
Definition at line 2807 of file pine_adapter.cpp.
References pineforge::engine_invariant, F, instrument_feed_field_name(), pineforge::lot_grid_rejected, pineforge::make_run_failure(), pineforge::out_of_memory, pineforge::run_options_rejected, pineforge::strategy_settings_rejected, pineforge::symbol, pineforge::symbol_feeds_refused, and pineforge::symbol_metadata_rejected.
Referenced by pineforge::source::PineExecutionAdapter::project().
|
inlinenoexcept |
Definition at line 12 of file pine_checked_arith.hpp.
|
inlinenoexcept |
Definition at line 19 of file pine_checked_arith.hpp.
|
inlinenoexcept |
Definition at line 26 of file pine_checked_arith.hpp.
| void pineforge::source::admit_strategy_entry | ( | const std::string & | id, |
| bool | , | ||
| double | limit_price, | ||
| double | stop_price, | ||
| double | , | ||
| const std::string & | comment, | ||
| const std::string & | oca_name, | ||
| int | , | ||
| int | ) |
Definition at line 69 of file pine_value_admission.cpp.
References pineforge::source::value_field::entry_comment, pineforge::source::value_field::entry_id, pineforge::source::value_field::entry_limit_price, pineforge::source::value_field::entry_oca_name, and pineforge::source::value_field::entry_stop_price.
| void pineforge::source::admit_strategy_close | ( | const std::string & | id, |
| const std::string & | comment, | ||
| double | , | ||
| double | , | ||
| bool | ) |
Definition at line 81 of file pine_value_admission.cpp.
References pineforge::source::value_field::close_comment, and pineforge::source::value_field::close_id.
Referenced by admit_strategy_close_token().
| void pineforge::source::admit_strategy_close_token | ( | const std::string & | id, |
| const std::string & | comment, | ||
| double | qty, | ||
| double | qty_percent, | ||
| bool | immediately, | ||
| std::uint64_t | ) |
Definition at line 87 of file pine_value_admission.cpp.
References admit_strategy_close().
|
noexcept |
Definition at line 93 of file pine_value_admission.cpp.
| void pineforge::source::admit_strategy_exit | ( | const std::string & | id, |
| const std::string & | from_entry, | ||
| double | limit_price, | ||
| double | , | ||
| double | , | ||
| double | trail_offset, | ||
| double | trail_price, | ||
| double | , | ||
| const std::string & | comment, | ||
| double | , | ||
| const std::string & | oca_name, | ||
| double | profit_ticks, | ||
| double | loss_ticks ) |
Definition at line 95 of file pine_value_admission.cpp.
References pineforge::source::value_field::exit_comment, pineforge::source::value_field::exit_from_entry, pineforge::source::value_field::exit_id, pineforge::source::value_field::exit_limit_price, pineforge::source::value_field::exit_loss_ticks, pineforge::source::value_field::exit_oca_name, pineforge::source::value_field::exit_profit_ticks, pineforge::source::value_field::exit_trail_offset, and pineforge::source::value_field::exit_trail_price.
| void pineforge::source::admit_strategy_exit_cancel_bracket | ( | const std::string & | exit_id, |
| const std::string & | from_entry, | ||
| const std::string & | comment ) |
| void pineforge::source::admit_strategy_cancel | ( | const std::string & | id | ) |
Definition at line 122 of file pine_value_admission.cpp.
References pineforge::source::value_field::cancel_id.
|
noexcept |
Definition at line 126 of file pine_value_admission.cpp.
| void pineforge::source::admit_strategy_order | ( | const std::string & | id, |
| bool | , | ||
| double | , | ||
| double | limit_price, | ||
| double | stop_price, | ||
| const std::string & | oca_name, | ||
| int | ) |
|
inlinenoexcept |
Definition at line 19 of file pine_value_admission.hpp.
References invalid_unicode, nonfinite, and numeric_overflow.
Referenced by throw_strategy_value_invalid().
|
inline |
The coded failure of a source-owned invalid actionable value.
Thrown, so the existing exception path classifies it (RunFailureInfo wins over the type).
Definition at line 30 of file pine_value_admission.hpp.
References pineforge::strategy_value_invalid, and strategy_value_reason_name().
Referenced by admit_pine_risk_max_drawdown(), admit_pine_risk_max_intraday_loss(), admit_pine_risk_max_position_size(), and admit_strategy_declaration().
|
inlinenoexcept |
Definition at line 16 of file pine_value_admit_decl.hpp.
References kDeclarationNanIsInvalid.
Referenced by admit_strategy_declaration().
|
inline |
Definition at line 23 of file pine_value_admit_decl.hpp.
References declaration_value_is_invalid(), pineforge::source::PineStrategyConfig::default_qty_value, pineforge::source::PineStrategyConfig::margin_long, pineforge::source::PineStrategyConfig::margin_short, nonfinite, pineforge::source::value_field::strategy_default_qty_value, pineforge::source::value_field::strategy_margin_long, pineforge::source::value_field::strategy_margin_short, and throw_strategy_value_invalid().
Referenced by pineforge::source::PineStrategyHost::configure_pine_strategy().
|
inline |
Definition at line 15 of file pine_value_admit_risk.hpp.
References nonfinite, pineforge::source::value_field::risk_max_drawdown, and throw_strategy_value_invalid().
Referenced by assert_admitted_pine_replay_risk_config(), and pineforge::source::PineStrategyHost::set_pine_risk_max_drawdown().
|
inline |
Definition at line 21 of file pine_value_admit_risk.hpp.
References nonfinite, pineforge::source::value_field::risk_max_intraday_loss, and throw_strategy_value_invalid().
Referenced by assert_admitted_pine_replay_risk_config(), and pineforge::source::PineStrategyHost::set_pine_risk_max_intraday_loss().
|
inline |
Definition at line 27 of file pine_value_admit_risk.hpp.
References nonfinite, pineforge::source::value_field::risk_max_position_size, and throw_strategy_value_invalid().
Referenced by assert_admitted_pine_replay_risk_config(), and pineforge::source::PineStrategyHost::set_pine_risk_max_position_size().
|
inline |
Definition at line 41 of file pine_value_admit_risk.hpp.
References admit_pine_risk_max_drawdown(), admit_pine_risk_max_intraday_loss(), and admit_pine_risk_max_position_size().
|
inlineconstexpr |
Definition at line 59 of file pine_adapter.hpp.
Referenced by pineforge::source::PineStrategyHost::hash_host_extension(), and pineforge::source::PineExecutionAdapter::hash_state().
|
inlineconstexpr |
Definition at line 65 of file pine_adapter.hpp.
Referenced by pineforge::source::detail::PositionTailSpill::append(), and pineforge::source::PineStrategyHost::on_native_applied().
|
inlineconstexpr |
Definition at line 66 of file pine_adapter.hpp.
Referenced by pineforge::source::PineStrategyHost::on_native_applied().
|
inlineconstexpr |
Definition at line 69 of file pine_adapter.hpp.
Referenced by pineforge::source::PineStrategyHost::on_native_applied().
|
inlineconstexpr |
Definition at line 76 of file pine_adapter.hpp.
Referenced by pineforge::source::PineExecutionAdapter::project(), and pineforge::source::PineScheduler::recalculate().
|
inlineconstexpr |
Definition at line 33 of file pine_strategy_host.hpp.
Referenced by pineforge::source::PineStrategyHost::hash_host_extension().
|
inlineconstexpr |
Definition at line 39 of file pine_strategy_host.hpp.
Referenced by pineforge::source::PineStrategyHost::hash_host_extension().
|
inlineconstexpr |
The most period opens a multi-day period source holds at once: the recent ones it answers short questions from, and the next one ahead.
Definition at line 74 of file multi_day_periods.hpp.
|
inlineconstexpr |
Bounds the fallback's retained trading-date slots to one calendar year, including a leap year; N-day counting restarts each year.
Clock changes (also through the legacy coverage clock) normally regress dates by about a day. No distance bound is assumed: full-feed rescans remain exact even beyond this window, replacing the slots rather than accumulating years.
Definition at line 81 of file multi_day_periods.hpp.
Referenced by pineforge::source::multi_day_detail::RescannedHeldDays::find().
|
inlineconstexpr |
Definition at line 14 of file pine_value_admit_decl.hpp.
Referenced by declaration_value_is_invalid().