|
PineForge v0.13.1-379-g9b50973
Deterministic PineScript v6 backtest runtime — C ABI reference
|
A generic per-side broker margin model (L4). More...
#include <native_run_spec.hpp>
Data Fields | |
| double | initial_long = 0.0 |
| double | initial_short = 0.0 |
| std::optional< double > | maintenance_long |
| std::optional< double > | maintenance_short |
| NativeLiquidationSizing | sizing = NativeLiquidationSizing::RestoreMinimum |
| double | shortfall_multiple = 1.0 |
| std::optional< double > | liquidation_min_units |
| NativeLiquidationCheck | check = NativeLiquidationCheck::PathAdverseExtreme |
| NativeMarginEquityBasis | basis = NativeMarginEquityBasis::MarkedEquity |
| NativeLiquidationLevelBase | level_base = NativeLiquidationLevelBase::MarkedEquity |
| std::string | liquidation_label |
| std::string | liquidation_comment |
A generic per-side broker margin model (L4).
It is entirely opt-in: a spec that leaves NativeRunSpec::margin unset keeps the one-scalar initial_margin_fraction gate and has no liquidation path at all.
initial_long / initial_short are the opening-admission fractions (not percents) applied to the resulting absolute notional of an opening, per side. Both must be finite and never negative.
ZERO is the MAINTENANCE-ONLY spelling for that side: the kernel enforces no opening requirement on it, at the candidate gate and at placement alike, and the HOST owns opening admission there. Opening admission and liquidation are two different broker functions: a host that runs its own pre-trade check (and says so at the candidate gate by answering NativePrecommitVerdict::AdmitWithHostMargin) still wants the kernel's liquidation mechanism, and this is how it asks for one without the other. A side may waive either function but not both: initial_* == 0.0 is legal only where that side's maintenance_* is set (and positive), and a side with neither is refused as MarginSideUndeclared. A model whose initial_* are positive behaves exactly as it always has.
maintenance_long / maintenance_short are the liquidation fractions. Absent means that side never liquidates. Present means the kernel solves for the liquidation level – the price at which the marked equity falls below the maintenance requirement – and rests a kernel-originated Reduce with Stop{level} while the requirement is breached on the modeled path. A maintenance fraction equal to 1.0 has no finite level for a LONG: at full maintenance a long's equity and requirement move together, so the breach is a constant and no price solves it. That degenerate slope rests nothing under PathAdverseExtreme – there is no price to rest at – while PathAdverseExtremeMark, which never solves a level, still measures the breach at the adverse mark and still consults the host's requirement hook. Source-language money rules beyond that are source-layer policy, never spelled here.
liquidation_min_units is the broker's minimum liquidation trade: a computed reduction below it flattens the position instead.
basis and level_base are the two places brokers legitimately disagree about money: which equity the requirement is tested against, and which base the reported level is solved from. Both default to the marked-equity model the kernel has always used, and both fold into the run spec's digest only when moved off it.
liquidation_label / liquidation_comment name the TICKET the kernel's own liquidation is booked under. A broker's forced liquidation carries the broker's identifiers, and a reporting layer that classifies a closed row by its ticket id – which is the ordinary way to say "this row was a margin
call" – can only do so if those identifiers are the broker's. Empty keeps the kernel's own ("__kernel_liquidation__" / "Margin liquidation"); a set value is used verbatim for the request's label and comment and therefore for the closed row's exit id and comment. Like the two money bases, each folds into the model's digest only when set, so a model that does not name its ticket digests exactly as it did before they existed.
Definition at line 239 of file native_run_spec.hpp.
| double pineforge::native_run_spec_v3::NativeMarginModel::initial_long = 0.0 |
Definition at line 240 of file native_run_spec.hpp.
Referenced by pineforge::source::PineExecutionAdapter::project().
| double pineforge::native_run_spec_v3::NativeMarginModel::initial_short = 0.0 |
Definition at line 241 of file native_run_spec.hpp.
Referenced by pineforge::source::PineExecutionAdapter::project().
| std::optional<double> pineforge::native_run_spec_v3::NativeMarginModel::maintenance_long |
Definition at line 242 of file native_run_spec.hpp.
Referenced by pineforge::source::PineExecutionAdapter::project().
| std::optional<double> pineforge::native_run_spec_v3::NativeMarginModel::maintenance_short |
Definition at line 243 of file native_run_spec.hpp.
Referenced by pineforge::source::PineExecutionAdapter::project().
| NativeLiquidationSizing pineforge::native_run_spec_v3::NativeMarginModel::sizing = NativeLiquidationSizing::RestoreMinimum |
Definition at line 244 of file native_run_spec.hpp.
| double pineforge::native_run_spec_v3::NativeMarginModel::shortfall_multiple = 1.0 |
Definition at line 245 of file native_run_spec.hpp.
| std::optional<double> pineforge::native_run_spec_v3::NativeMarginModel::liquidation_min_units |
Definition at line 246 of file native_run_spec.hpp.
| NativeLiquidationCheck pineforge::native_run_spec_v3::NativeMarginModel::check = NativeLiquidationCheck::PathAdverseExtreme |
Definition at line 247 of file native_run_spec.hpp.
Referenced by pineforge::source::PineExecutionAdapter::project().
| NativeMarginEquityBasis pineforge::native_run_spec_v3::NativeMarginModel::basis = NativeMarginEquityBasis::MarkedEquity |
Definition at line 248 of file native_run_spec.hpp.
Referenced by pineforge::source::PineExecutionAdapter::project().
| NativeLiquidationLevelBase pineforge::native_run_spec_v3::NativeMarginModel::level_base = NativeLiquidationLevelBase::MarkedEquity |
Definition at line 249 of file native_run_spec.hpp.
Referenced by pineforge::source::PineExecutionAdapter::project().
| std::string pineforge::native_run_spec_v3::NativeMarginModel::liquidation_label |
Definition at line 250 of file native_run_spec.hpp.
Referenced by pineforge::source::PineExecutionAdapter::project().
| std::string pineforge::native_run_spec_v3::NativeMarginModel::liquidation_comment |
Definition at line 251 of file native_run_spec.hpp.
Referenced by pineforge::source::PineExecutionAdapter::project().