PineForge
v0.13.1-379-g9b50973
Deterministic PineScript v6 backtest runtime — C ABI reference
Loading...
Searching...
No Matches
native_fx_curve.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <cstddef>
4
#include <cstdint>
5
#include <vector>
6
7
namespace
pineforge
{
8
inline
namespace
native_fx_curve_v1
{
9
10
/// An immutable account-currency FX curve: parallel arrays of effective-from
11
/// timestamps in epoch milliseconds and the account-currency units per one unit of
12
/// the symbol's quote currency. The latest point whose timestamp is at or before
13
/// the current broker event is active, and NativeRunSpec::account_fx is the
14
/// fallback before the first point. Staged with
15
/// NativeStrategyHost::configure_native_fx_curve while the host is Ready, it is
16
/// the run's FX epoch for a batch and a confirmed-bar stream alike, and a step of
17
/// it is a NativeMarginCheckKind::FxRoll check point. Pinned by
18
/// tests/test_native_fx_curve.cpp and tests/test_native_margin_fx_roll.cpp.
19
struct
NativeFxCurve
{
20
std::vector<std::int64_t>
effective_from_ms
;
21
std::vector<double>
account_per_quote
;
22
};
23
24
/// Why a curve was refused. LengthMismatch means the two arrays differ in length
25
/// (reported at index 0); NotStrictlyIncreasing and NotFinitePositive name the
26
/// first bad timestamp or rate; WrongPhase means the host was no longer Ready.
27
/// A refusal leaves the staged curve as it was.
28
enum class
NativeFxCurveError
: std::uint8_t {
29
None
= 0,
30
LengthMismatch
= 1,
31
NotStrictlyIncreasing
= 2,
32
NotFinitePositive
= 3,
33
AllocationFailure
= 4,
34
WrongPhase
= 5,
35
};
36
37
/// What validate_native_fx_curve and configure_native_fx_curve report: the error
38
/// and the index of the element that failed. Success is None at index 0, and so
39
/// is an empty pair of arrays, which clears the curve.
40
struct
NativeFxCurveValidation
{
41
NativeFxCurveError
error
=
NativeFxCurveError::None
;
42
std::size_t
index
= 0;
43
};
44
45
// Empty parallel arrays are valid and represent clearing the curve. Length
46
// mismatch reports index 0; otherwise the first bad element wins, with its
47
// timestamp checked before its rate. Success reports None/index 0.
48
NativeFxCurveValidation
validate_native_fx_curve
(
const
NativeFxCurve
& curve)
noexcept
;
49
50
// Total for any vector lengths: fold both lengths, timestamps first, then
51
// ordered timestamp/rate bit pairs through the shorter vector. Empty arrays
52
// fold two zero lengths. Validation remains the gate for using a curve.
53
std::uint64_t
native_fx_curve_digest
(
const
NativeFxCurve
& curve)
noexcept
;
54
55
}
// inline namespace native_fx_curve_v1
56
}
// namespace pineforge
pineforge::native_fx_curve_v1
Definition
native_fx_curve.hpp:8
pineforge::native_fx_curve_v1::validate_native_fx_curve
NativeFxCurveValidation validate_native_fx_curve(const NativeFxCurve &curve) noexcept
pineforge::native_fx_curve_v1::NativeFxCurveError
NativeFxCurveError
Why a curve was refused.
Definition
native_fx_curve.hpp:28
pineforge::native_fx_curve_v1::NativeFxCurveError::None
@ None
Definition
native_fx_curve.hpp:29
pineforge::native_fx_curve_v1::NativeFxCurveError::NotFinitePositive
@ NotFinitePositive
Definition
native_fx_curve.hpp:32
pineforge::native_fx_curve_v1::NativeFxCurveError::NotStrictlyIncreasing
@ NotStrictlyIncreasing
Definition
native_fx_curve.hpp:31
pineforge::native_fx_curve_v1::NativeFxCurveError::LengthMismatch
@ LengthMismatch
Definition
native_fx_curve.hpp:30
pineforge::native_fx_curve_v1::NativeFxCurveError::AllocationFailure
@ AllocationFailure
Definition
native_fx_curve.hpp:33
pineforge::native_fx_curve_v1::NativeFxCurveError::WrongPhase
@ WrongPhase
Definition
native_fx_curve.hpp:34
pineforge::native_fx_curve_v1::native_fx_curve_digest
std::uint64_t native_fx_curve_digest(const NativeFxCurve &curve) noexcept
pineforge
Definition
bar.hpp:4
pineforge::native_fx_curve_v1::NativeFxCurveValidation
What validate_native_fx_curve and configure_native_fx_curve report: the error and the index of the el...
Definition
native_fx_curve.hpp:40
pineforge::native_fx_curve_v1::NativeFxCurveValidation::error
NativeFxCurveError error
Definition
native_fx_curve.hpp:41
pineforge::native_fx_curve_v1::NativeFxCurveValidation::index
std::size_t index
Definition
native_fx_curve.hpp:42
pineforge::native_fx_curve_v1::NativeFxCurve
An immutable account-currency FX curve: parallel arrays of effective-from timestamps in epoch millise...
Definition
native_fx_curve.hpp:19
pineforge::native_fx_curve_v1::NativeFxCurve::account_per_quote
std::vector< double > account_per_quote
Definition
native_fx_curve.hpp:21
pineforge::native_fx_curve_v1::NativeFxCurve::effective_from_ms
std::vector< std::int64_t > effective_from_ms
Definition
native_fx_curve.hpp:20
include
pineforge
native_fx_curve.hpp
PineForge v0.13.1-379-g9b50973 — Apache-2.0 —
github.com/pineforge-4pass/pineforge-engine