PineForge v0.13.1-379-g9b50973
Deterministic PineScript v6 backtest runtime — C ABI reference
Loading...
Searching...
No Matches
order_priority.hpp
Go to the documentation of this file.
1#pragma once
2#include <cmath>
3#include <cstdint>
4#include <limits>
5#include <optional>
6#include <string>
7#include <vector>
8
10
12
13// Adapter-owned facts for the one retained-child/fresh-parent ordering
14// exception. The native matcher sees only handles and ordinary request
15// ordering; no source identity or policy predicate crosses this boundary.
16enum class OrderPriorityKind : std::uint8_t { Entry = 0, Exit = 1, Other = 2 };
17
19 bool broker_flat = false;
21 bool calc_on_order_fills = false;
24 bool stream_warmup_mode = false;
25 bool stream_idle = true;
26 int bar_index = -1;
27};
28
32 std::string id;
33 std::string from_entry;
34 int created_bar = -1;
35 std::uint64_t source_sequence = 0;
36 std::uint64_t predecessor = 0;
38 std::uint64_t named_cancel_surviving_exit = 0;
39 bool created_flat = false;
40 bool birth_from_fill = false;
41 bool prior_close = false;
42 bool at_entry_capacity = false;
44 bool default_quantity = false;
45 double requested_qty = std::numeric_limits<double>::quiet_NaN();
46 double qty_percent = std::numeric_limits<double>::quiet_NaN();
47 double stop = std::numeric_limits<double>::quiet_NaN();
48 double limit = std::numeric_limits<double>::quiet_NaN();
49 double trail_points = std::numeric_limits<double>::quiet_NaN();
50 double trail_price = std::numeric_limits<double>::quiet_NaN();
51 double trail_offset = std::numeric_limits<double>::quiet_NaN();
52 double profit_ticks = std::numeric_limits<double>::quiet_NaN();
53 double loss_ticks = std::numeric_limits<double>::quiet_NaN();
54 std::string oca_name;
55 int oca_type = 0;
56};
57
62
64public:
65 static constexpr uint64_t schema_version = 1;
66 void attach() { attached_ = true; }
67 bool attached() const { return attached_; }
68 bool retained_parent_first() const { return retained_parent_first_; }
69 void metadata(const std::string& key, double value) {
70 // One declaration owner, including values received while detached.
71 // Metadata never selects Pine execution. Reattachment preserves off.
72 if (key == "flat_retained_child_fresh_parent_order")
73 retained_parent_first_ = std::isfinite(value) && value > 0.0;
74 }
75 std::optional<OrderPriorityDecision> select(
76 const OrderPriorityContext& ctx,
77 const std::vector<OrderPriorityCandidate>& candidates) const;
78private:
79 bool attached_ = false;
80 bool retained_parent_first_ = true;
81};
82
83} // namespace pineforge::compat::pine
static constexpr uint64_t schema_version
void metadata(const std::string &key, double value)
std::optional< OrderPriorityDecision > select(const OrderPriorityContext &ctx, const std::vector< OrderPriorityCandidate > &candidates) const