PineForge unreleased
Deterministic PineScript v6 backtest runtime — C ABI reference
Loading...
Searching...
No Matches
native_c_api.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: Apache-2.0
3 *
4 * native_c_api.h — versioned C-level native host API (R5 lane L13).
5 *
6 * A host that is not written in C++ drives the kernel through this header:
7 * it hands the runtime a callback table, runs a batch of bars, and submits,
8 * replaces, cancels or executes order requests from inside those callbacks.
9 * It drives the same kernel as <pineforge/native_host.hpp>'s NativeStrategyHost;
10 * the C++ it does not spell in 1.0 is docs/pages/native-engine.md's boundary table.
11 *
12 * SCOPE
13 * ─────
14 * ✓ Create / free a native host backed by a C callback table
15 * ✓ Run a batch of OHLCV bars and fill a pf_report_t
16 * ✓ submit / replace / cancel / cancel_all / cancel_where / execute_current
17 * ✓ Read the physical position, the live working book, the open lots (the
18 * book lot by lot, marked at a price — strategy.opentrades.* for a C host)
19 * and the event history
20 * ✓ Read, at every decision point, the script interval and the session day
21 * of its open and of the next input — the facts session-day flags are
22 * derived from
23 * ✓ Read the run's lifecycle state and its typed failure
24 * ✓ Read a margin call's whole economics — equity, requirement and the
25 * position on either side of it — by its event ordinal
26 * ✓ Read a closed row's own identifiers — its entry and exit ticket, its exit
27 * comment and its close cause — with the pineforge.h accessors, which take
28 * any handle this header produces
29 * ✓ Arm a WAIT_FOR_APPLIED child after its owner's print, or bound to the
30 * whole book, and size its close with on_close_units
31 * ✓ Ask the kernel what a SIZED request would resolve to, before submitting
32 * ✓ Extend the run specification with the fields pf_native_run_spec_v1 predates
33 * ✓ Declare an auxiliary finer feed — up front, or from `on_run_begin` —
34 * build a series from it, and append its later bars to a realtime stream,
35 * each refusal named by the kernel's own typed answer
36 * ✓ Declare, from `on_applied`, where a lot's opening fill sat on its entry
37 * bar, for a host that owns its lots' excursions
38 *
39 * ✗ Streaming has no new symbols: strategy_stream_begin / _push_bar /
40 * _push_tick / _advance_time / _end / _fill_report take any handle this
41 * header produces, unchanged.
42 * ✓ Answer the kernel's policy hooks: a host-sized close's units
43 * (on_close_units), a candidate's settlement price and opening shape
44 * (on_execution_terms), the last gate before a fill (on_precommit), where
45 * an anchored leg is armed (on_anchored_level), and the host's own state
46 * folded into the broker-state hash (on_hash_extension). The per-bar hash
47 * rows need no new symbol: `report_policy` =
48 * PF_NATIVE_REPORT_KERNEL_RECORDED with
49 * strategy_set_broker_state_hash_recording fills
50 * pf_report_t::broker_state_hash, one row per script bar.
51 *
52 * COVERAGE
53 * ────────
54 * Every public member of NativeStrategyHost, and either its C spelling or the
55 * reason it has none. scripts/check_native_c_api_surface.py proves this list is
56 * exactly that class's public surface: a member added there without a row here,
57 * or a row here naming a member that no longer exists, fails CI.
58 *
59 * [C] on_bar strategy_native_run_v1 / the strategy_stream_* ingress
60 * [--] prepare_native_begin borrows the codegen ingress (InputsMap, SymInfo, the opaque
61 * overrides) that no C host supplies; a C run is declared up front
62 * with strategy_configure_native_ext_v1
63 * [C] on_native_run_begin pf_native_callbacks_v1::on_run_begin
64 * [C] on_native_input pf_native_callbacks_v1::on_input
65 * [C] on_native_tick pf_native_callbacks_v1::on_tick
66 * [C] on_native_timeframe_bar pf_native_callbacks_v1::on_timeframe_bar; its
67 * NativeTimeframeBarContext::interval is read inside
68 * that callback with strategy_native_timeframe_bar_interval_v1
69 * [C] on_native_bar_open pf_native_callbacks_v1::on_bar_open
70 * [C] on_native_bar pf_native_callbacks_v1::on_bar
71 * [C] on_native_recalculate pf_native_callbacks_v1::on_recalculate
72 * [C] on_native_sub_bar pf_native_callbacks_v1::on_sub_bar
73 * [C] on_native_applied pf_native_callbacks_v1::on_applied
74 * [C] on_native_margin_call pf_native_callbacks_v1::on_margin_call -- the call's whole
75 * MarginCallEvent is strategy_native_margin_call_v1, by the
76 * ordinal the hook is handed
77 * [C] resolve_execution_terms pf_native_callbacks_v1::on_close_units (the units of a host-sized
78 * close) and pf_native_callbacks_v1::on_execution_terms (the price,
79 * the opening shape and the grid policy)
80 * [C] validate_execution_precommit pf_native_callbacks_v1::on_precommit -- the plan, the inspection
81 * and the projected account flattened into
82 * pf_native_precommit_view_v1, the closed rows' P&L borrowed
83 * [C] resolve_anchored_level pf_native_callbacks_v1::on_anchored_level
84 * [C] resolve_margin_requirement pf_native_callbacks_v1::on_margin_requirement
85 * [C] margin_check_allowed pf_native_callbacks_v1::on_margin_check
86 * [C] resolve_margin_call_units pf_native_callbacks_v1::on_margin_call_units
87 * [C] owns_lot_excursions pf_native_callbacks_v1::on_lot_excursion -- installing it IS
88 * declaring ownership
89 * [C] closed_lot_excursion pf_native_callbacks_v1::on_lot_excursion
90 * [C] declare_native_bar_open_hook pf_native_callbacks_v1::on_bar_open -- a table without it
91 * declares none, once, when the host is created
92 * [C] declare_native_precommit_hook pf_native_callbacks_v1::on_precommit -- a table without it
93 * declares none, once, when the host is created
94 * [C] current_partial_bar strategy_native_partial_bar_v1
95 * [C] native_recalculation_count strategy_native_recalculations_v1
96 * [C] native_recalculations_skipped strategy_native_recalculations_v1
97 * [C] current_execution_point pf_native_decision_v1::price / ::quote_kind, on every callback;
98 * its script interval and session days are the decision's
99 * session tail
100 * [C] trail_state strategy_native_trail_state_v1
101 * [--] inspect_current_execution scheduled for 1.1.0 (C-SURFACE-2): C has no non-mutating call,
102 * and strategy_native_execute_current_v1 applies the command, so
103 * it is no preview; the preview's refusal, readiness, account
104 * projection and closed-row P&L have no size-prefixed POD in 1.0
105 * [C] execute_current strategy_native_execute_current_v1
106 * [--] mark_native_report_point the C spec does not name KernelRecordedAtHostMarks,
107 * so a C host cannot select its mark cadence
108 * [C] native_series_bar strategy_native_series_bar_v1
109 * [C] declare_timeframe_subscriptions strategy_native_declare_subscriptions_v1 -- a row is
110 * pf_native_subscription_v1, whose `lookahead` / `gaps` bools are
111 * pf_native_lookahead_e / pf_native_gaps_e words
112 * [C] declare_timeframe_subscriptions_result strategy_native_declare_subscriptions_ext_v1 -- the
113 * same call, its NativeRunSpecValidation written to `error` /
114 * `field` (pf_native_spec_error_e / pf_native_spec_field_e), plus
115 * a series source per row
116 * [C] declare_auxiliary_feed strategy_native_declare_auxiliary_feed_v1 -- a NULL `tf`
117 * withdraws the staged feed
118 * [C] declare_auxiliary_feed_result strategy_native_declare_auxiliary_feed_v1, whose `error` /
119 * `field` out-parameters are the typed answer
120 * [C] append_auxiliary_bars strategy_native_append_auxiliary_bars_v1
121 * [C] append_auxiliary_bars_result strategy_native_append_auxiliary_bars_ext_v1 --
122 * NativeAuxiliaryAppendError (pf_native_append_error_e) and the
123 * bar of the call it stopped on
124 * [C] configure_native strategy_configure_native_v1 / strategy_configure_native_ext_v1 /
125 * strategy_configure_native_ext_result_v1 -- the last writes
126 * NativeRunSpecError / NativeRunSpecField out-parameters;
127 * the two specs' enum-valued words are pf_native_fee_kind_e,
128 * pf_native_close_execution_e, pf_native_open_directions_e,
129 * pf_native_report_policy_e, pf_native_price_grid_e,
130 * pf_native_grid_rounding_e, pf_native_calc_trigger_e,
131 * pf_native_open_bar_view_e, pf_native_liquidation_sizing_e
132 * and pf_native_event_retention_e words
133 * [C] configure_native_fx_curve strategy_configure_native_fx_curve_v1 (pineforge.h)
134 * [C] native_state strategy_native_state_v1
135 * [C] submit strategy_native_submit_v1 -- a WAIT_FOR_APPLIED child's
136 * first_match / scope are pf_native_request_v1::arm_first_match /
137 * arm_scope
138 * [C] replace strategy_native_replace_v1, or strategy_native_replace_ext_v1
139 * for the ReplaceResult::reason the first one drops
140 * [--] submit_market a C++ convenience that REFUSES non-market extras instead of dropping
141 * them; the same request is strategy_native_submit_v1 with
142 * PF_NATIVE_TRIGGER_MARKET and a zero-filled struct
143 * [--] replace_market the same convenience for a replace; see submit_market
144 * [C] cancel strategy_native_cancel_v1
145 * [C] native_working_requests strategy_native_working_len_v1 / strategy_native_working_get_v1;
146 * a Trail's arm_price presence is
147 * pf_native_working_v1::trail_has_arm_price, the anchor and
148 * owner relation are pf_native_working_v1::anchor .. arm_scope
149 * [--] visit_native_working_requests C++ callback traversal with ScratchStatus; C reads indexed working rows
150 * [--] native_visit_working_requests C++ callback traversal; C reads indexed working rows
151 * [--] native_working_request C++ handle lookup; C finds the handle among indexed working rows
152 * [C] native_open_lots strategy_native_open_lot_count_v1 / strategy_native_open_lot_get_v1
153 * [--] visit_native_open_lots C++ borrowed-row traversal with ScratchStatus; C reads indexed open lots
154 * [--] native_visit_open_lots C++ borrowed-row traversal; C reads indexed open lots
155 * [--] visit_native_open_lot_values C++ scalar callback traversal; C reads indexed open-lot values
156 * [C] cancel_all strategy_native_cancel_all_v1
157 * [C] cancel_where strategy_native_cancel_where_v1
158 * [C] cohort_open strategy_native_cohort_open_v1
159 * [C] cohort_add strategy_native_cohort_add_v1
160 * [C] cohort_remove strategy_native_cohort_remove_v1
161 * [C] physical_position strategy_native_position_v1
162 * [C] native_marked_equity strategy_native_marked_equity_v1
163 * [C] native_liquidation_price strategy_native_liquidation_price_v1
164 * [--] native_aggregates_input_bars its one reader is the Pine host, which re-dates a closed row
165 * onto the aggregated script bar TradingView reports; a C host
166 * reads the rows the kernel books as they are, and names both
167 * timeframes in its own spec
168 * [C] native_risk_state strategy_native_risk_state_v1
169 * [C] native_events strategy_native_events_v1
170 * [C] native_acknowledge_events strategy_native_acknowledge_events_v1
171 * [C] native_event_window_start strategy_native_event_window_v1
172 * [C] native_decision_floor pf_native_state_v1::decision_floor_ms
173 * [C] native_consumed_high_water pf_native_state_v1::consumed_high_water
174 * [C] native_continuation_hash strategy_native_continuation_hash_v1
175 * [--] native_closed_rows_amended a C host reads the closed rows and never writes one -- the kernel
176 * books them -- so it has no amendment to name
177 * [C] native_sized_units strategy_native_sized_units_v1 -- a PF_NATIVE_INTENT_SIZED
178 * pf_native_request_v1 is the Sized basis; its sizing block is
179 * read, nothing is submitted
180 *
181 * Three asymmetries this list does not reach, recorded here because a C host
182 * will look for them; the 1.0 C boundary table lists every other one.
183 *
184 * pf_native_working_v1 has two trigger numbers, p1 and p2 -- plus, in its own
185 * additive tail, trail_has_arm_price, which tells an absent arm from an arm at
186 * 0.0 -- while a trail now has three numbers: offset, arm price and
187 * pf_native_request_v1::trail_best_seed. The readback keeps the first two and
188 * the presence flag; it does NOT carry the seed. The seed is a SUBMISSION
189 * input -- a floor on where the ride starts, consumed once at the arm -- and
190 * what a host wants back afterwards is the ride itself, which
191 * strategy_native_trail_state_v1 already answers as best_price and
192 * current_level. Another readout tail would cost every caller that sends the
193 * current sizeof a recompile, for a number the caller wrote.
194 * Executed by the trail-seed and arm-presence scenarios of
195 * tests/test_native_c_api.c.
196 *
197 * pf_trade_t carries no exit ticket. That POD is the codegen
198 * ABI's, runtime-allocated and iterated with the caller's own sizeof, so a
199 * tail costs a PF_ABI_VERSION bump for every existing consumer — and it needs
200 * none. strategy_closed_trade_entry_id / _exit_id / _exit_comment /
201 * _close_cause (pineforge.h) index exactly the rows of pf_report_t::trades,
202 * are implemented in the kernel archive, and take any handle, so a C host
203 * reads back the ticket its own margin model declared
204 * (pf_native_run_spec_ext_v1::margin_liquidation_label) without a new symbol.
205 * Executed by the fx-roll scenario of tests/test_native_c_api.c.
206 *
207 * pf_native_decision_v1 carries three of NativeDecisionContext's four
208 * session-day facts (in_session, opens_session_day, closes_session_day, in
209 * the base layout's former tail padding, so a table of every published length
210 * is handed them) and not the fourth, closes_session_day_open_ended. That one
211 * differs from closes_session_day on a batch's final bar alone, for a host
212 * that recomputes a batch whose last input is still forming; a C host's live
213 * edge is the strategy_stream_* ingress, whose bars already read the calendar
214 * there, and that padding holds exactly the three facts and their presence
215 * byte. Executed by the session-day scenario of tests/test_native_c_api.c.
216 *
217 * BASE-CLASS SEAMS
218 * ────────────────
219 * The rows at the top of this block census NativeStrategyHost's own surface. A BacktestEngine member a host calls
220 * or overrides is opted in one by one: engine.hpp marks it `@host-seam`, and scripts/check_native_c_api_surface.py
221 * proves this list is exactly the marked set, each with a C spelling or a reason. A new one takes the marker and a row.
222 *
223 * [C] declare_opened_lot_entry_bar_mask strategy_native_declare_opened_lot_entry_bar_mask_v1 -- legal
224 * inside on_applied alone; executed by the entry-bar mask
225 * scenario of tests/test_native_c_api.c
226 * [C] hash_host_extension pf_native_callbacks_v1::on_hash_extension -- the host folds a
227 * 64-bit digest of its own state after the kernel's bytes
228 * [--] hash_source_extension the deprecated spelling of hash_host_extension, kept for C++ subclasses
229 * written against it; a C host has only the current one, on_hash_extension
230 * [--] declare_outputs C++ only in outputs v1: the record's slots, outputs and run constants, once
231 * [--] output_run_begin C++ only in outputs v1: the boundary of each run; C reads strategy_outputs_*
232 * [--] output_bar C++ only in outputs v1: one row per bar the host publishes, keyed by its open
233 * [--] output_value C++ only in outputs v1: one double in a slot of the open row
234 * [--] output_event C++ only in outputs v1: an event of the open row, with an optional message
235 * [--] output_constant C++ only in outputs v1: one value per declared index per run
236 *
237 * HARDENING RULES
238 * ───────────────
239 * - Every struct is tagged and size-prefixed: `struct_size` is the exact
240 * sizeof of the version the caller compiled against, `version` is that
241 * layout's version constant. A mismatch is refused with PF_NATIVE_E_STRUCT
242 * and mutates nothing. The exception is a deliberately additive tail: a
243 * struct that grew one publishes every earlier layout's length as a
244 * `*_SIZE` constant and the runtime accepts each — pf_native_request_v1,
245 * pf_native_run_spec_ext_v1 and pf_native_callbacks_v1 as inputs,
246 * pf_native_working_v1 as a readout. A readout is written only as far as
247 * the length its caller sent. A struct the runtime PRESENTS to a callback
248 * (pf_native_decision_v1) is presented at the layout the caller's
249 * callback table was published with, and its `struct_size` says so.
250 * - Every enum-valued field is translated by an exhaustive switch. A value
251 * outside its enumeration is refused with PF_NATIVE_E_TAG; a value this
252 * version deliberately cannot represent is refused with
253 * PF_NATIVE_E_UNSUPPORTED. No C value is ever cast onto a C++ variant.
254 * - C callbacks must not unwind. A callback that returns non-zero latches
255 * NativeFailureCode::CallbackException (PF_NATIVE_FAILURE_CALLBACK) and the
256 * run ends Failed; the code is readable with strategy_native_state_v1.
257 * - Commands follow the kernel's existing legality rule: inside a callback,
258 * or between realtime inputs. A command issued anywhere else returns
259 * PF_NATIVE_E_STATE and changes nothing.
260 *
261 * STABILITY
262 * ─────────
263 * Same guarantee as <pineforge/pineforge.h>: within a major version the
264 * layouts below are append-only and the signatures never change. A field is
265 * appended one of two ways. A deliberately additive tail (HARDENING RULES
266 * above) keeps the version constant: the struct publishes every earlier
267 * layout's length as a `*_SIZE` constant and the runtime accepts each, so a
268 * caller compiled against an earlier layout keeps working unchanged, and a
269 * readout is written only as far as the length that caller sent. Any other
270 * layout change is a new revision that raises the version constant; there
271 * the size prefix keeps an old caller refused rather than silently misread.
272 */
273
274#ifndef PINEFORGE_NATIVE_C_API_H
275#define PINEFORGE_NATIVE_C_API_H
276
277#include <stdint.h>
278#include <stddef.h>
279
280/* pf_strategy_t, pf_bar_t, pf_report_t, PF_API. pineforge.h includes this
281 * header back at its end; both guards make either include order work. */
282#include <pineforge/pineforge.h>
283
284/** Feature probe for the C-level native host API.
285 * When defined, #strategy_native_host_create_v1 is available. */
286#define PINEFORGE_HAS_NATIVE_C_API_V1 1
287
288/** Monotonic version of this header's native-C layouts. Every versioned
289 * struct below carries it in its `version` field. */
290#define PF_NATIVE_API_VERSION 1
291
292#ifdef __cplusplus
293extern "C" {
294#endif
295
296/** @defgroup pf_native_c_status Status codes
297 * @brief Every `int`-returning symbol here answers 0 or one of these.
298 *
299 * Negative values are errors. A C-layer validation refusal does not mutate
300 * native run state; a kernel-origin refusal can latch Failed, as the
301 * configure-reuse and reentrant-append contracts below specify.
302 * Non-negative values are outcomes: 0 is success everywhere, and
303 * #strategy_native_execute_current_v1 additionally answers the positive
304 * #pf_native_execute_outcome_t codes.
305 * @{ */
306#define PF_NATIVE_OK 0 /**< Success. */
307#define PF_NATIVE_E_HANDLE -1 /**< NULL handle, or not a C-callback native host. */
308#define PF_NATIVE_E_STRUCT -2 /**< `struct_size` / `version` mismatch. */
309#define PF_NATIVE_E_TAG -3 /**< An enum field outside its enumeration. */
310#define PF_NATIVE_E_ARGUMENT -4 /**< NULL output, negative count, out-of-range index. */
311#define PF_NATIVE_E_STATE -5 /**< Illegal here: the command legality rule, or the
312 * kernel's own lifecycle, refused it. */
313#define PF_NATIVE_E_REJECTED -6 /**< The kernel rejected the request (reason written out). */
314#define PF_NATIVE_E_UNSUPPORTED -7 /**< A tag this API version cannot represent. */
315#define PF_NATIVE_E_EXCEPTION -8 /**< A C++ exception was contained at the boundary. */
316#define PF_NATIVE_E_NOT_WORKING -9 /**< A nonzero target incarnation is not live, whether it was retired or never issued. */
317#define PF_NATIVE_E_INVALID_TARGET -10 /**< Malformed target: incarnation 0. C commands pair an incarnation with this handle's current run identity, so they cannot pass a foreign run identity. */
318#define PF_NATIVE_E_RUN_FAILED -11 /**< The run did not reach Completed; read the state. */
319#define PF_NATIVE_E_REFUSED -12 /**< execute_current refused; see pf_native_refusal_e. */
320/** Non-negative outcome: the kernel HAS no answer here and the output was
321 * left at its documented empty. It is not an error — the C++ spelling of
322 * each accessor that returns it is a `std::optional`, whose empty is a
323 * legitimate answer (no path walk, an unarmed trail, a series that has not
324 * delivered, a run with no margin model). Only the accessors whose own
325 * documentation names it can return it; #strategy_native_execute_current_v1
326 * never does, its positive codes being #pf_native_execute_outcome_t. */
327#define PF_NATIVE_ABSENT 1
328/** @} */
329
330/** `NativeFailureCode::CallbackException` — the code latched when a C callback
331 * returns non-zero. The historical spelling of
332 * #PF_NATIVE_FAILURE_CALLBACK_EXCEPTION, kept for the callers written
333 * against it; pinned by a static_assert. */
334#define PF_NATIVE_FAILURE_CALLBACK 5
335
336/** @defgroup pf_native_c_enums Translated enumerations
337 * @brief Every value below is the exact integer of the C++ alternative it
338 * names, pinned by static_asserts in src/native_c_host.cpp.
339 * @{ */
340
341/** Order intent — the alternative index of `native_order::OrderIntent`. */
342typedef enum pf_native_intent_e {
343 PF_NATIVE_INTENT_FLATTEN = 0, /**< Close the whole book. */
344 PF_NATIVE_INTENT_REDUCE = 1, /**< Reduce; see #pf_native_reduction_t. */
345 PF_NATIVE_INTENT_TRANSACT = 2, /**< `intent_value` signed units. */
346 PF_NATIVE_INTENT_REVERSE_TO = 3, /**< `intent_value` target signed exposure. */
347 PF_NATIVE_INTENT_HOST_SIZED = 4, /**< A close sized by on_close_units: the
348 * cohort close (#PF_NATIVE_OWNER_BIND_COHORT)
349 * or a WAIT_FOR_APPLIED child that carries
350 * the arm tail (#pf_native_arm_scope_t;
351 * the kernel admits it under BOOK only).
352 * Refused PF_NATIVE_E_UNSUPPORTED under
353 * any other owner. */
354 PF_NATIVE_INTENT_SIZED = 5 /**< Kernel-sized opening (L3). */
356
357/** Reduction size — the alternative index of `native_order::ReductionSize`. */
358typedef enum pf_native_reduction_e {
359 PF_NATIVE_REDUCE_EXPLICIT_UNITS = 0, /**< `intent_value` units. */
360 PF_NATIVE_REDUCE_OWNER_OPENED = 1, /**< Exactly what the owner opened. */
361 PF_NATIVE_REDUCE_SCOPE_FRACTION = 2 /**< `intent_value` fraction in (0, 1]. */
363
364/** Scope claim of a fractional reduce. */
369
370/** Side of a kernel-sized opening. */
371typedef enum pf_native_side_e {
375
376/** Sizing basis — the alternative index of `native_order::SizeBasis`. */
377typedef enum pf_native_size_basis_e {
378 PF_NATIVE_SIZE_BASIS_CASH = 0, /**< `intent_value` account-currency cash. */
379 PF_NATIVE_SIZE_BASIS_EQUITY_FRACTION = 1 /**< `intent_value` fraction of marked equity. */
381
382/** When a sizing basis resolves. */
387
388/** Whether resolved sizing snaps onto the run's quantity grid. */
389typedef enum pf_native_grid_policy_e {
393
394/** Trigger — the alternative index of `native_order::Trigger`. */
395typedef enum pf_native_trigger_e {
396 PF_NATIVE_TRIGGER_MARKET = 0, /**< p1, p2 ignored. */
397 PF_NATIVE_TRIGGER_LIMIT = 1, /**< p1 = price; `fill_through` makes it market-if-touched. */
398 PF_NATIVE_TRIGGER_STOP = 2, /**< p1 = price. */
399 PF_NATIVE_TRIGGER_STOP_LIMIT = 3, /**< p1 = stop, p2 = limit. */
400 PF_NATIVE_TRIGGER_TRAIL = 4 /**< p1 = offset, p2 = arm price when `trail_has_arm_price`;
401 * `trail_best_seed` when `trail_has_best_seed`. */
403
404/** Where a trigger level comes from — `native_order::TriggerAnchor` (L7). */
405typedef enum pf_native_anchor_e {
406 PF_NATIVE_ANCHOR_ABSOLUTE = 0, /**< The level written in the trigger. */
407 PF_NATIVE_ANCHOR_FROM_OWNER_FILL = 1 /**< owner fill + `anchor_offset` (signed). */
409
410/** How a materialized anchored level snaps onto the run's price tick ladder —
411 * `native_order::NativeAnchorRounding` (L7b). RAW is the established
412 * behaviour; the other two need `price_tick > 0` at acceptance. */
413typedef enum pf_native_anchor_rounding_e {
414 PF_NATIVE_ANCHOR_ROUNDING_RAW = 0, /**< fill + offset exactly. */
415 PF_NATIVE_ANCHOR_ROUNDING_HALF_UP = 1, /**< Nearest tick, ties away from zero. */
416 PF_NATIVE_ANCHOR_ROUNDING_DIRECTIONAL = 2 /**< Toward the region the leg needs. */
418
419/** Whether a WAIT_FOR_APPLIED child is a working order before its arm —
420 * `native_order::NativeArmVisibility` (L7b). PENDING_UNTIL_ARMED keeps it
421 * out of #strategy_native_working_len_v1 / #strategy_native_working_get_v1
422 * until its ArmedEvent; it stays a live request the whole time (replace,
423 * cancel, cancel_all still address it, and it never matches before the arm
424 * under either value). */
429
430/** Whether an armed WAIT_FOR_APPLIED child may trade on its owner's own fill
431 * print — `native_order::NativeArmFirstMatch`. AT_ARM_PRINT (the default) is
432 * the established book: the armed child is a candidate at that very cursor,
433 * so a level the print already satisfies matches there. AFTER_ARM_PRINT
434 * gives it the birth rule of a request submitted from the owner's own
435 * `on_applied`: on the point that armed it, it sees only the path after the
436 * print. It governs a priced trigger's level test; a market trigger has no
437 * level. Both are broker models. */
442
443/** What an armed CLOSING child (REDUCE, FLATTEN, a host-sized close) closes —
444 * `native_order::NativeArmScope`. OWNER_LOT (the default) is the lot its
445 * owner's fill opened, and nothing a later add brings. BOOK binds it, at the
446 * arm, to the whole position that fill left, so a protective leg placed with
447 * its entry covers later adds. A host-sized close may wait for its owner only
448 * under BOOK (its units are #pf_native_callbacks_v1::on_close_units'); a
449 * waiting transaction closes nothing and must keep OWNER_LOT. */
454
455/** Capacity — the alternative index of `native_order::Capacity`. */
456typedef enum pf_native_capacity_e {
457 PF_NATIVE_CAPACITY_IMMEDIATE = 0, /**< Whole remaining at one point. */
458 PF_NATIVE_CAPACITY_POINT_BUDGET = 1 /**< `capacity_units` per matching point. */
460
461/** Owner — the alternative index of `native_order::Owner`. */
462typedef enum pf_native_owner_e {
463 PF_NATIVE_OWNER_INDEPENDENT = 0, /**< No owner. */
464 PF_NATIVE_OWNER_WAIT_FOR_APPLIED = 1, /**< One parent in `owner_incarnations`. */
465 PF_NATIVE_OWNER_BIND_OPENING = 2, /**< One opening + `owner_cycle`. */
466 PF_NATIVE_OWNER_BIND_OPENINGS = 3, /**< `owner_n` openings + `owner_cycle`. */
467 /** `cohort` from #strategy_native_cohort_open_v1. The kernel pairs this
468 * owner with exactly one intent — a host-sized CLOSE — so a cohort close
469 * is spelled #PF_NATIVE_INTENT_HOST_SIZED with this owner and no
470 * quantity of its own: the roster's live openings are the target and the
471 * cohort authority decides the units. That pairing is the only shape in
472 * which HOST_SIZED is accepted here. */
475
476/** Group — the alternative index of `native_order::Group`. */
477typedef enum pf_native_group_e {
479 PF_NATIVE_GROUP_MEMBER = 1 /**< `group_id`, `group_cohort`, `group_effect`. */
481
482/** What a filled group member does to its siblings. */
483typedef enum pf_native_group_effect_e {
487
488/** Which identity text #strategy_native_cancel_where_v1 compares.
489 *
490 * Both are the free text the request carried: `comment` is the established
491 * selector, `label` is where a host that names its orders puts its own id,
492 * so LABEL is the one call that withdraws every live request issued under
493 * one such id. Neither is indexed; both walk the live book once. */
494typedef enum pf_native_request_field_e {
498
499/** Price rule of an immediate execution. */
504
505/** Outcome of #strategy_native_execute_current_v1 (non-negative returns). */
506typedef enum pf_native_execute_outcome_e {
507 PF_NATIVE_EXECUTED_APPLIED = 0, /**< An execution was applied. */
508 PF_NATIVE_EXECUTED_NO_EFFECT = 1, /**< Legal, nothing to execute. */
509 PF_NATIVE_EXECUTED_MATCH_REJECTED = 2, /**< Terms/admission rejected it. */
510 PF_NATIVE_EXECUTED_CANCELLED = 3 /**< The request was cancelled instead. */
512
513/** Why execute_current refused. Written to `*refusal`, if supplied, when
514 * #strategy_native_execute_current_v1 answers PF_NATIVE_E_REFUSED. Mirrors
515 * `NativeCurrentRefusal`. */
527
528/** Lifecycle of the native run — mirrors `NativeLifecycleKind`. */
536
537/** Event tag of #pf_native_event_v1.
538 *
539 * 1..18 are the first eighteen alternatives of `native_order::CommandEvent`,
540 * in variant order plus one; 19 and 20 are the driver-point and account
541 * observations `native_events()` also carries. 21 is L9's `NativeRiskEvent`,
542 * the nineteenth CommandEvent alternative: it was added after this header
543 * froze, so it keeps a tag of its own past the two observations rather than
544 * taking 19 and renumbering them. A reader compiled before it skips it by
545 * tag, exactly as it must skip any tag it does not know.
546 *
547 * One kind named in the design is NOT represented and never appears here: a
548 * completed higher-timeframe bucket, delivered only through
549 * `on_timeframe_bar` and never recorded in the event history. */
573
574/** Which generic risk limit a #PF_NATIVE_EVENT_RISK event reports — the
575 * `reason` field of #pf_native_event_v1, mirroring
576 * `native_order::RiskLimitKind` (L9). */
583
584/** Which day a risk limit's "day" is — `NativeRiskDay`. SESSION is the run's
585 * own session calendar (an overnight session is one day); CALENDAR_TIMEZONE
586 * is the civil date in the spec's scheduling timezone. */
591
592/** What a breach does — `NativeRiskAction`. BLOCK_OPENINGS refuses every
593 * opening while the block lasts and leaves the live book alone;
594 * FLATTEN_AND_BLOCK first closes the book with one kernel-originated
595 * Flatten. */
600
601/** Remaining projection of a live request — `native_order::RemainingProjection`. */
609
610/** Trigger state of a live request — `native_order::TriggerState`. */
622
623/** What one execution costs — `NativeFeeKind`, the `fee_kind` word of
624 * #pf_native_run_spec_v1, charged at its `fee_value`. */
625typedef enum pf_native_fee_kind_e {
626 PF_NATIVE_FEE_PERCENT = 0, /**< `fee_value` percent of |units| × price ×
627 * point value × account FX (the default). */
628 PF_NATIVE_FEE_CASH_PER_UNIT = 1, /**< `fee_value` account currency per unit. */
629 PF_NATIVE_FEE_CASH_PER_EXECUTION = 2 /**< `fee_value` account currency per execution. */
631
632/** When a request born at a script calculation may first match —
633 * `NativeCloseExecution`, the `close_execution` word of
634 * #pf_native_run_spec_v1. */
635typedef enum pf_native_close_execution_e {
636 PF_NATIVE_CLOSE_EXECUTION_NEXT_ELIGIBLE_POINT = 0, /**< A later eligible point — the
637 * next modeled opening, an
638 * observed print or a carried
639 * open — never the bar's
640 * presented prices (the
641 * default). */
642 PF_NATIVE_CLOSE_EXECUTION_AFTER_CALCULATION = 1 /**< Also a modeled close point
643 * right after that
644 * calculation. */
646
647/** Which opening directions the run admits — `NativeOpenDirections`, the
648 * `allowed_open_directions` word of #pf_native_run_spec_v1; BOTH is
649 * LONG | SHORT. A refused opening is a match rejection of the whole
650 * transaction, and a pure reduction stays legal under NONE. Zero is NOT the
651 * kernel's default here, unlike every other word these enumerations type: a
652 * zero-filled spec admits no opening at all. */
659
660/** Who records the per-script-bar report series — `NativeReportPolicy`, the
661 * `report_policy` word of #pf_native_run_spec_ext_v1. The kernel's third
662 * policy, `KernelRecordedAtHostMarks`, has no C value: under it the host
663 * names each report point itself, from inside its own callbacks, and the
664 * callback table carries no call that marks one — a C host could only
665 * declare a series nobody records. Its integer, 2, is PF_NATIVE_E_TAG like
666 * any other word outside this enumeration. */
667typedef enum pf_native_report_policy_e {
668 PF_NATIVE_REPORT_HOST_RECORDED = 0, /**< The host's; the kernel appends no point
669 * (the default). */
670 PF_NATIVE_REPORT_KERNEL_RECORDED = 1 /**< One equity point per script calculation;
671 * `report_open_position_at_end` applies. */
673
674/** A generic instrument price grid — `NativePriceGrid`, the `price_grid`
675 * word of #pf_native_run_spec_ext_v1. Both quantizing values need
676 * `price_tick > 0`. */
677typedef enum pf_native_price_grid_e {
678 PF_NATIVE_PRICE_GRID_NONE = 0, /**< Every price booked as the
679 * path presents it (the
680 * default). */
681 PF_NATIVE_PRICE_GRID_QUANTIZE_FILLS = 1, /**< Each fill booked on the
682 * tick ladder. */
683 PF_NATIVE_PRICE_GRID_QUANTIZE_FILLS_AND_TRIGGERS = 2 /**< And each resting trigger
684 * tested against the
685 * quantized path. */
687
688/** How a quantizing grid rounds — `NativeGridRounding`, the `grid_rounding`
689 * word of #pf_native_run_spec_ext_v1, read beside `price_grid`. */
690typedef enum pf_native_grid_rounding_e {
691 PF_NATIVE_GRID_ROUNDING_HALF_UP = 0, /**< The nearest tick, ties away from zero
692 * (the default). */
693 PF_NATIVE_GRID_ROUNDING_DIRECTIONAL = 1 /**< Toward the region the order needs: a
694 * buy limit down and a sell limit up, a
695 * stop the other way, a market fill to
696 * its adverse side. */
698
699/** When the kernel asks the host to calculate — `NativeCalculationTrigger`,
700 * the `calculation` word of #pf_native_run_spec_ext_v1. Each value is a
701 * strict superset of the one before it. */
702typedef enum pf_native_calc_trigger_e {
703 PF_NATIVE_CALC_TRIGGER_BAR_CLOSE = 0, /**< Once per script bar, at its close
704 * (the default). */
705 PF_NATIVE_CALC_TRIGGER_BAR_CLOSE_AND_FILLS = 1, /**< And at each applied execution's
706 * cursor, bounded by
707 * `max_recalculations_per_point`. */
708 PF_NATIVE_CALC_TRIGGER_EVERY_MODELED_POINT = 2 /**< And at every modeled point and
709 * every observed print. */
711
712/** What #pf_native_callbacks_v1::on_bar_open is handed — `NativeOpenBarView`,
713 * the `open_bar_view` word of #pf_native_run_spec_ext_v1. Neither value
714 * changes a match, a fill or any other callback. */
715typedef enum pf_native_open_bar_view_e {
716 PF_NATIVE_OPEN_BAR_VIEW_COMPLETE = 0, /**< The whole script bar (the default). */
717 PF_NATIVE_OPEN_BAR_VIEW_OPEN_ONLY = 1 /**< Its lookahead masked: H = L = C = open,
718 * volume 0. */
720
721/** Which units a kernel-issued liquidation reduces —
722 * `NativeLiquidationSizing`, the `margin_sizing` word of
723 * #pf_native_run_spec_ext_v1. Clamped to the position held;
724 * #pf_native_callbacks_v1::on_margin_call_units has the last word. */
725typedef enum pf_native_liquidation_sizing_e {
726 PF_NATIVE_LIQUIDATION_SIZING_RESTORE_MINIMUM = 0, /**< The fewest units that restore
727 * the requirement at the sizing
728 * mark (the default). */
730 * `margin_shortfall_multiple`. */
731 PF_NATIVE_LIQUIDATION_SIZING_FLATTEN = 2 /**< The whole position. */
733
734/** Which extension blocks of #pf_native_run_spec_ext_v1 are meaningful. */
735typedef enum pf_native_spec_ext_mask_e {
742 /** L9's generic risk limits. Only a caller whose
743 * pf_native_run_spec_ext_v1 carries the risk tail may set this bit; a
744 * caller sending the base layout is refused with PF_NATIVE_E_STRUCT. */
746 /** The retained intrabar execution path. Needs the N8 tail. */
748 /** The four feed-shape and presentation policies: slot labels, feed
749 * tolerance, the forced path order and abort reporting. Needs the N8
750 * tail. */
752 /** The auxiliary finer feed. Only a caller whose
753 * pf_native_run_spec_ext_v1 carries the auxiliary tail may set this bit;
754 * a caller sending any earlier layout is refused with
755 * PF_NATIVE_E_STRUCT. */
757 /** What the run keeps of its event record (`event_retention`). Only a
758 * caller whose pf_native_run_spec_ext_v1 carries the retention tail may
759 * set this bit; a caller sending any earlier layout is refused with
760 * PF_NATIVE_E_STRUCT. Without it the run keeps
761 * #PF_NATIVE_EVENT_RETENTION_FULL. */
763 /** The settlement's quantity tolerance (`quantity_tolerance`). Only a
764 * caller whose pf_native_run_spec_ext_v1 carries the tolerance tail may
765 * set this bit; a caller sending any earlier layout is refused with
766 * PF_NATIVE_E_STRUCT. Without it the settlement stays exact. */
769
770/** What a run keeps of its event record — `NativeRunSpec::event_retention`,
771 * the `event_retention` word of #pf_native_run_spec_ext_v1, read under
772 * #PF_NATIVE_SPEC_EXT_EVENT_RETENTION.
773 *
774 * WINDOW keeps the command journal only until the host has read it: a host
775 * that polls #strategy_native_events_v1 acknowledges what it has read
776 * (#strategy_native_acknowledge_events_v1) and the kernel drops the
777 * acknowledged events at the next script-bar boundary, while a host that
778 * never acknowledges is served by its callbacks alone and its window closes
779 * at every script-bar end. No driver point and no account row is kept.
780 * COMMANDS keeps the whole command journal and every account row, and no
781 * driver point. FULL keeps everything, O(run) in memory.
782 *
783 * A C host that does not set the bit -- every caller of
784 * #strategy_configure_native_v1, and every caller of an earlier
785 * pf_native_run_spec_ext_v1 layout -- runs under FULL, the record its
786 * layout was published with, so reading a whole run's events after it has
787 * ended keeps working unchanged. The C++ default is WINDOW. */
788typedef enum pf_native_event_retention_e {
789 PF_NATIVE_EVENT_RETENTION_WINDOW = 0, /**< The unread journal only. */
790 PF_NATIVE_EVENT_RETENTION_FULL = 1, /**< Journal, driver points, account rows. */
791 PF_NATIVE_EVENT_RETENTION_COMMANDS = 2 /**< Journal and account rows. */
793
794/** The bars a declared series is built from — `NativeSeriesSource`. */
795typedef enum pf_native_series_source_e {
796 PF_NATIVE_SERIES_SOURCE_INPUT = 0, /**< The accepted input (the default). */
797 PF_NATIVE_SERIES_SOURCE_AUXILIARY_FEED = 1 /**< The run's auxiliary finer feed. */
799
800/** When a declared series delivers a completed bucket —
801 * `NativeTimeframeSubscription::lookahead`, the `lookahead` word of
802 * #pf_native_subscription_v1. AT_FIRST_INPUT resolves the historical input
803 * ahead; a stream's live inputs have nothing ahead to resolve, so under
804 * either value they deliver each bucket at its completion. */
805typedef enum pf_native_lookahead_e {
806 PF_NATIVE_LOOKAHEAD_AT_COMPLETION = 0, /**< On the input that completes the
807 * bucket (the default). */
808 PF_NATIVE_LOOKAHEAD_AT_FIRST_INPUT = 1 /**< The bucket's final values, on its
809 * first contributing input. */
811
812/** What a declared series holds on an accepted input that delivers no bucket
813 * of it — `NativeTimeframeSubscription::gaps`, the `gaps` word of
814 * #pf_native_subscription_v1. Neither value changes which buckets complete,
815 * when they are delivered or what they contain. */
816typedef enum pf_native_gaps_e {
817 PF_NATIVE_GAPS_HOLD = 0, /**< The last delivered bucket, until the next
818 * delivery replaces it (the default). */
819 PF_NATIVE_GAPS_CLEAR = 1 /**< Nothing: #strategy_native_series_bar_v1
820 * answers #PF_NATIVE_ABSENT on that input. */
822
823/** WHICH price a kernel-sized basis converts at — `native_order::SizePrice`
824 * (L3b). RESOLVED is the established behaviour: the price the kernel would
825 * otherwise settle at. SIGNAL is the decision-point price at placement,
826 * carried to the expected fill by the side's slippage and rounded onto the
827 * run's fill grid. SIGNAL_ON_TICK is that same rule measured on the
828 * INSTRUMENT's own tick ladder (`price_tick`) instead of the fill grid,
829 * rounded before the slippage as well as after. */
835
836/** WHICH measurement of the bound scope a fractional reduce takes its
837 * fraction of — `native_order::ScopeBasis`. AT_MATCH reads the scope as it
838 * stands at the matching candidate. AT_ACCEPTANCE freezes the scope SIZE
839 * when the request is accepted, so two 50 % siblings on one 10-unit lot both
840 * claim 5 under GROSS even after the first has executed. */
845
846/** When the kernel tests the maintenance requirement —
847 * `NativeLiquidationCheck`, the `margin_check` field of
848 * #pf_native_run_spec_ext_v1. */
849typedef enum pf_native_liquidation_check_e {
850 PF_NATIVE_LIQUIDATION_PATH_ADVERSE_EXTREME = 0, /**< Solve and rest at the level. */
851 PF_NATIVE_LIQUIDATION_CALCULATION_ONLY = 1, /**< Test the mark; rest nothing. */
852 PF_NATIVE_LIQUIDATION_PATH_ADVERSE_EXTREME_MARK = 2 /**< Rest AT the adverse mark. */
854
855/** Which equity the maintenance requirement is tested against —
856 * `NativeMarginEquityBasis`. */
861
862/** Which base the liquidation level is solved from —
863 * `NativeLiquidationLevelBase`. */
868
869/** Which intrabar execution path the run retains — the alternative of
870 * `IntrabarPath`. NONE is the whole default surface. LOWER_TF retains the
871 * caller's own finer bars (and is the one mode that delivers
872 * #pf_native_callbacks_v1::on_sub_bar). SYNTHESIZED samples each script
873 * bar's own OHLC path through the generic sampler and retains no feed. */
879
880/** Whether matching stays continuous between generated samples —
881 * `IntrabarPath::SampleEligibility`. LOWER_TF only; a synthesized path's
882 * point-only eligibility is inherent to that mode. */
887
888/** Whether a confirmed bar must name a canonical input slot —
889 * `NativeSlotLabelPolicy`. A feed-shape policy, not a source-language one;
890 * the two modes never share a continuation. */
895
896/** Opt-in admission exceptions for a tolerated input-feed shape —
897 * `NativeFeedTolerance`. A BIT MASK, not an enumerator: the values combine,
898 * and any bit outside this set is PF_NATIVE_E_TAG. */
899typedef enum pf_native_feed_tolerance_e {
901 /** Finite OHLC need not be positive; NaN volume means unavailable. */
903 /** Stream warmups admit finite, non-negative interim OHLC. */
906
907/** Generic ordering for a modeled OHLC path — `NativePathOrder`. AUTO keeps
908 * the open-proximity rule; the forced modes make the first excursion
909 * explicit for replay and live hosts. */
915
916/** How a cooperative abort is presented — `NativeAbortReporting`. */
917typedef enum pf_native_abort_reporting_e {
921
922/** Why the kernel is asking the host to calculate — `NativeCalculationReason`
923 * (L5), the `reason` argument of #pf_native_callbacks_v1::on_recalculate.
924 * SUB_BAR is reserved and never delivered there: a lower-timeframe sub-bar
925 * has its own hook, #pf_native_callbacks_v1::on_sub_bar. */
926typedef enum pf_native_calc_reason_e {
927 PF_NATIVE_CALC_BAR_CLOSE = 0, /**< The script bar's own calculation; `cause` NULL. */
928 PF_NATIVE_CALC_ORDER_FILL = 1, /**< At an applied execution's cursor; `cause` is it. */
929 PF_NATIVE_CALC_TICK = 2, /**< At a modeled point or print; `cause` NULL. */
930 PF_NATIVE_CALC_SUB_BAR = 3 /**< Reserved; see on_sub_bar. */
932
933/** Which kernel check point is about to test the maintenance requirement —
934 * `NativeMarginCheckKind` (L4b). These are the kernel's own points; a broker
935 * model that checks somewhere else is host policy, expressed by suppressing
936 * the points it does not share. */
937typedef enum pf_native_margin_check_kind_e {
938 PF_NATIVE_MARGIN_CHECK_BAR_OPEN = 0, /**< The script bar's open. */
939 PF_NATIVE_MARGIN_CHECK_AFTER_APPLIED = 1, /**< The re-arm after a point's fills. */
940 PF_NATIVE_MARGIN_CHECK_CALCULATION = 2, /**< A CalculationOnly model's calculation. */
941 PF_NATIVE_MARGIN_CHECK_FX_ROLL = 3, /**< A step of the run's declared
942 * #pf_native_fx_curve_v1: the first point
943 * the account converts at a new rate,
944 * offered immediately before that point is
945 * matched. A run that declares no curve has
946 * none, and a CalculationOnly model, which
947 * measures at its calculation alone, is not
948 * offered it. */
949 PF_NATIVE_MARGIN_CHECK_INTRABAR_SAMPLE = 4 /**< A delivered sample, after the
950 * script bar's first, of a
951 * #PF_NATIVE_INTRABAR_LOWER_TF path matched as
952 * continuous segments, measured at its own
953 * price immediately before it is matched. A
954 * one-price distribution path and a
955 * CalculationOnly model are not offered it. */
957
958/** What an ANSWERING callback's return value means.
959 *
960 * The four answering hooks of #pf_native_callbacks_v1 do not report success:
961 * their return value selects WHOSE answer the kernel uses, so every value is
962 * in contract and an answering hook can never fail the run. A host that
963 * needs to abort does it from an observation callback, which keeps the
964 * "non-zero ends the run Failed" rule exactly where it already was. */
965typedef enum pf_native_answer_e {
966 PF_NATIVE_ANSWER_DEFAULT = 0, /**< Keep the kernel's own; the output is ignored. */
967 PF_NATIVE_ANSWER_PROVIDED = 1 /**< Use the output. Any non-zero value means this. */
969
970/** Where an opened lot's own fill sits on its entry bar's modeled path —
971 * `OpenedLotFillPoint`, the one fact
972 * #strategy_native_declare_opened_lot_entry_bar_mask_v1 carries. ON_PATH is
973 * a fill at a price the path reaches: the kernel derives which end of the
974 * bar, if either, the path had already reached before it. AFTER_PATH is a
975 * fill at the bar's closing point, after the whole path: both ends precede
976 * it. */
981/* ── The readout words ─────────────────────────────────────────────
982 * Every enumeration below names a word the runtime WRITES for a C host: a
983 * field of a struct it fills or presents, an event's reason, a callback
984 * argument or an out-parameter. The fields stay the integer words they were
985 * published as, so no layout moves; each value is written by an exhaustive
986 * translation of its kernel enumeration, and a kernel value no enumeration
987 * here names cannot build (src/native_c_host.cpp). */
988/** Where a point's price came from — `NativePriceProvenance`: the
989 * `provenance` word of #pf_native_decision_v1 and #pf_native_event_v1 and
990 * #pf_native_margin_view_v1::cursor_provenance. */
991typedef enum pf_native_price_provenance_e {
992 PF_NATIVE_PROVENANCE_CONFIRMED = 0, /**< A confirmed input bar's own label,
993 * or a point on its modeled path. */
994 PF_NATIVE_PROVENANCE_OBSERVED_PRINT = 1, /**< A realtime print. */
995 PF_NATIVE_PROVENANCE_MODELED_OHLC_OPEN = 2, /**< A modeled path's opening point. */
996 PF_NATIVE_PROVENANCE_MODELED_OHLC_CLOSE = 3, /**< A modeled path's closing point. */
997 PF_NATIVE_PROVENANCE_CARRIED_OPEN = 4, /**< A quiet tradable interval's carried
998 * last price. */
999 PF_NATIVE_PROVENANCE_AFTER_CALCULATION_CLOSE = 5, /**< The close point right after a
1000 * calculation. */
1001 PF_NATIVE_PROVENANCE_PARTIAL_FINALIZED = 6, /**< A partially finalized observed slot. */
1002 PF_NATIVE_PROVENANCE_CALCULATION = 7, /**< The script calculation point itself. */
1004 * #strategy_native_execute_current_v1. */
1006
1007/** Which leg of a modeled OHLC walk a point sits on — `NativePathPhase`: the
1008 * `path_phase` word of #pf_native_decision_v1 and #pf_native_event_v1 and
1009 * #pf_native_margin_view_v1::cursor_path_phase. NONE is a discrete point (a
1010 * calculation, an observed print); the other four are the waypoints, in the
1011 * order the run's path order resolves. */
1019
1020/** How a script interval or a higher-timeframe bucket was closed —
1021 * `NativeCompletionKind`: #pf_native_decision_v1::completion and the
1022 * `completion` argument of #pf_native_callbacks_v1::on_timeframe_bar. */
1023typedef enum pf_native_completion_kind_e {
1024 PF_NATIVE_COMPLETION_KIND_CONFIRMED = 0, /**< Its own last contributing bar. */
1025 PF_NATIVE_COMPLETION_KIND_LAZY_COMPLETE = 1, /**< The NEXT interval's first input: a
1026 * session-clipped bar, or a hole over
1027 * the last slot. */
1028 PF_NATIVE_COMPLETION_KIND_SESSION_SHORTENED = 2, /**< The session close clipped it. */
1029 PF_NATIVE_COMPLETION_KIND_PARTIAL_FINALIZED = 3 /**< A stream end finalized a forming
1030 * observed slot. */
1032
1033/** Which quote #pf_native_decision_v1::price is — `NativeCurrentQuoteKind`:
1034 * the callback's own market decision point, or the execution it is anchored
1035 * to (inside `on_applied`). */
1040
1041/** Why an applied execution finished its request —
1042 * `native_order::AppliedTerminalReason`: #pf_native_applied_v1::terminal_reason
1043 * and the `reason` of a terminal #PF_NATIVE_EVENT_APPLIED row. */
1049
1050/** Why the kernel refused a request — `native_order::RequestRejectReason`:
1051 * the `reject` out-parameter of #strategy_native_submit_v1 and
1052 * #strategy_native_replace_ext_v1, and the `reason` of a
1053 * #PF_NATIVE_EVENT_REJECTED or #PF_NATIVE_EVENT_REPLACE_REJECTED row. */
1054typedef enum pf_native_reject_reason_e {
1062 PF_NATIVE_REJECT_PLACEMENT_ADMISSION = 7 /**< A SIZED request resolved at acceptance
1063 * that the run's opening admission
1064 * refuses at the sizing price. */
1066
1067/** Why a live request left the book unfilled — `native_order::CancelReason`:
1068 * the `reason` of a #PF_NATIVE_EVENT_CANCELLED row. */
1069typedef enum pf_native_cancel_reason_e {
1070 PF_NATIVE_CANCEL_USER = 0, /**< The host's own cancel. */
1071 PF_NATIVE_CANCEL_GROUP = 1, /**< A group sibling's fill withdrew it. */
1072 PF_NATIVE_CANCEL_OWNER_GONE = 2, /**< Its owner left the book first. */
1074 PF_NATIVE_CANCEL_SUPERSEDED = 4 /**< A kernel-originated request the kernel
1075 * itself withdrew: its level or units
1076 * moved, or the breach is over. */
1078
1079/** Why a matching candidate was refused — `native_order::MatchRejectReason`:
1080 * the `reason` of a #PF_NATIVE_EVENT_MATCH_REJECTED row. */
1081typedef enum pf_native_match_reject_e {
1083 PF_NATIVE_MATCH_REJECT_OPENING_DIRECTION = 1, /**< `allowed_open_directions`. */
1091 PF_NATIVE_MATCH_REJECT_RISK_LIMIT = 9, /**< An opening refused while a risk
1092 * limit blocks. */
1093 PF_NATIVE_MATCH_REJECT_UNREPRESENTABLE_QUANTITY = 10 /**< A quantity the settlement
1094 * cannot book exactly on
1095 * this book: the request
1096 * ends, nothing moves and
1097 * the run goes on. */
1099
1100/** Which trigger a price reached — `native_order::ActivationKind`: the
1101 * `reason` of a #PF_NATIVE_EVENT_ACTIVATED row. */
1108
1109/** Who issued a live request — `native_order::RequestOrigin`:
1110 * #pf_native_working_v1::origin. */
1111typedef enum pf_native_origin_e {
1113 PF_NATIVE_ORIGIN_KERNEL_LIQUIDATION = 1, /**< The run's margin model. */
1114 PF_NATIVE_ORIGIN_KERNEL_RISK = 2 /**< The run's risk limits. */
1116
1117/** A run's durable first failure — `NativeFailureCode`:
1118 * #pf_native_state_v1::failure_code. #PF_NATIVE_FAILURE_CALLBACK is the
1119 * historical spelling of #PF_NATIVE_FAILURE_CALLBACK_EXCEPTION. */
1135
1136/** Which operation was in flight when the failure latched —
1137 * `NativeFailureOperation`: #pf_native_state_v1::failure_operation. */
1149
1150/** Which driving a Running run is in — `NativeRunPhase`:
1151 * #pf_native_state_v1::phase. */
1152typedef enum pf_native_run_phase_e {
1154 PF_NATIVE_PHASE_WARMUP = 1, /**< A stream's warmup replay. */
1155 PF_NATIVE_PHASE_REALTIME = 2 /**< A stream's realtime leg. */
1157
1158/** How a Completed run ended — `NativeCompletion`:
1159 * #pf_native_state_v1::completion. */
1164/* ── The typed refusal words of a declaration and an append ──────── */
1165/** Why a declaration was refused — `NativeRunSpecError`, the kernel's own
1166 * validation word: the `error` out-parameter of
1167 * #strategy_native_declare_subscriptions_ext_v1,
1168 * #strategy_native_declare_auxiliary_feed_v1 and
1169 * #strategy_configure_native_ext_result_v1. Read beside the
1170 * #pf_native_spec_field_t the same call writes. Every value the run spec's
1171 * validation can answer is named, the ones a begin-time declaration cannot
1172 * reach included, so one enumeration reads every setup refusal. */
1173typedef enum pf_native_spec_error_e {
1174 PF_NATIVE_SPEC_ERROR_NONE = 0, /**< Applied. */
1191 PF_NATIVE_SPEC_ERROR_ALLOCATION_FAILURE = 17, /**< Staging threw. */
1192 PF_NATIVE_SPEC_ERROR_CALENDAR_FAILURE = 18, /**< No calendar resolved it. */
1197 PF_NATIVE_SPEC_ERROR_UNKNOWN_FEED_TOLERANCE = 23, /**< `feed_tolerance`: the
1198 * kernel's
1199 * `legacy_tolerance`. */
1229 PF_NATIVE_SPEC_ERROR_WRONG_PHASE = 53, /**< The CALL was refused
1230 * before any field was
1231 * judged: not in the
1232 * phase it is legal
1233 * in. Read with
1234 * FIELD_NONE. */
1235 PF_NATIVE_SPEC_ERROR_UNKNOWN_EVENT_RETENTION = 54, /**< An `event_retention`
1236 * word outside
1237 * #pf_native_event_retention_t. */
1239 * no reusable spec.
1240 * Defensive: a
1241 * cooperative abort
1242 * latches only while a
1243 * run holds its spec,
1244 * and the Failed state
1245 * keeps it, so no
1246 * public call reaches
1247 * this word. */
1249 * session key changed. */
1251 * run number did not
1252 * exceed its high-water. */
1253 /* 58-66: the instrument-feed refusals of a C++ spec (NativeRunSpec::
1254 * instrument_feeds). A C run spec has no instrument feed, so no C call
1255 * answers them; they are named so the translation stays exhaustive. */
1266
1267/** Where a declaration was refused — `NativeRunSpecField`, the first field
1268 * the kernel's validation found: the `field` out-parameter of
1269 * #strategy_native_declare_subscriptions_ext_v1,
1270 * #strategy_native_declare_auxiliary_feed_v1 and
1271 * #strategy_configure_native_ext_result_v1. */
1272typedef enum pf_native_spec_field_e {
1273 PF_NATIVE_SPEC_FIELD_NONE = 0, /**< Not about one field. */
1309 PF_NATIVE_SPEC_FIELD_FEED_TOLERANCE = 36, /**< `feed_tolerance`: the kernel's
1310 * `legacy_tolerance`. */
1340 /* 66-71: the instrument-feed fields of a C++ spec; see 58-66 above. */
1348
1349/** Why an append was refused — `NativeAuxiliaryAppendError`: the `error`
1350 * out-parameter of #strategy_native_append_auxiliary_bars_ext_v1. None of
1351 * them fails the host but REENTRANT, which latches the contract failure
1352 * every reentrant stream input is, and ALLOCATION_FAILURE. */
1353typedef enum pf_native_append_error_e {
1354 PF_NATIVE_APPEND_ERROR_NONE = 0, /**< Applied. */
1355 PF_NATIVE_APPEND_ERROR_HOST_FAILED = 1, /**< The host had already
1356 * failed. */
1357 PF_NATIVE_APPEND_ERROR_REENTRANT = 2, /**< From inside a callback or
1358 * an in-flight input. */
1359 PF_NATIVE_APPEND_ERROR_NOT_REALTIME = 3, /**< Not on a stream's
1360 * realtime leg. */
1361 PF_NATIVE_APPEND_ERROR_NO_AUXILIARY_FEED = 4, /**< The run declared no
1362 * feed. */
1363 PF_NATIVE_APPEND_ERROR_INVALID_BAR_ARRAY = 5, /**< A NULL array with a
1364 * non-zero count. */
1365 PF_NATIVE_APPEND_ERROR_INVALID_BAR = 6, /**< `index` has invalid
1366 * OHLCV. */
1367 PF_NATIVE_APPEND_ERROR_UNORDERED_BARS = 7, /**< `index` is not strictly
1368 * after its predecessor
1369 * (the feed's last bar
1370 * for index 0). */
1372 * inside an input period
1373 * already accepted. */
1374 PF_NATIVE_APPEND_ERROR_ALLOCATION_FAILURE = 9 /**< Growing the feed threw;
1375 * this fails the host. */
1377/* ── The policy hooks' words ───────────────────────────────────── */
1378/** How an opening settles against an opposite book —
1379 * `native_order::OpeningShape`, #pf_native_terms_v1::shape. Only an OPENING
1380 * may name a shape other than TRANSACT: a kernel-sized one
1381 * (#PF_NATIVE_INTENT_SIZED) that the answer is about; the kernel refuses any
1382 * other with #PF_NATIVE_MATCH_REJECT_INVALID_TERMS. */
1383typedef enum pf_native_opening_shape_e {
1384 PF_NATIVE_OPENING_SHAPE_TRANSACT = 0, /**< Net against the book (the default). */
1385 PF_NATIVE_OPENING_SHAPE_REVERSE_TO = 1, /**< Close the opposite book, then open the
1386 * units. */
1387 PF_NATIVE_OPENING_SHAPE_CLOSE_OPPOSITE = 2 /**< Close the opposite book and open the
1388 * remainder. */
1390
1391/** Which price a matching candidate is at — `native_order::NativeCandidatePriceKind`,
1392 * #pf_native_terms_view_v1::price_kind. */
1393typedef enum pf_native_candidate_price_e {
1394 PF_NATIVE_CANDIDATE_PRICE_POINT_PRICE = 0, /**< The driver point's own price. */
1395 PF_NATIVE_CANDIDATE_PRICE_TRIGGER_LEVEL = 1, /**< A resting level the path crossed. */
1396 PF_NATIVE_CANDIDATE_PRICE_CURRENT_QUOTE = 2 /**< A current execution's quote. */
1398
1399/** Which kind of driver point a candidate matched at —
1400 * `native_order::DriverEligibilityClass`,
1401 * #pf_native_terms_view_v1::driver_class. */
1411
1412/** The settlement shape an execution is about to take — the alternative of
1413 * `native_order::ExecutionPlan`, #pf_native_precommit_view_v1::plan. */
1414typedef enum pf_native_plan_e {
1415 PF_NATIVE_PLAN_FLATTEN = 0, /**< Close the whole book; `plan_units` 0. */
1416 PF_NATIVE_PLAN_REDUCE = 1, /**< Close `plan_units` units. */
1417 PF_NATIVE_PLAN_TRANSACT = 2, /**< Trade `plan_units` signed units. */
1418 PF_NATIVE_PLAN_REVERSE_TO = 3 /**< Reach `plan_units` signed exposure. */
1420
1421/** What #pf_native_callbacks_v1::on_precommit answers —
1422 * `NativePrecommitVerdict`. */
1423typedef enum pf_native_precommit_verdict_e {
1424 PF_NATIVE_PRECOMMIT_ADMIT = 0, /**< The kernel's own path. */
1425 PF_NATIVE_PRECOMMIT_REFUSE = 1, /**< A nonfinancial
1426 * #PF_NATIVE_MATCH_REJECT_HOST_PRECOMMIT. */
1427 PF_NATIVE_PRECOMMIT_ADMIT_WITH_HOST_MARGIN = 2 /**< Admit, and the host owns this one
1428 * opening's margin check: the
1429 * kernel's initial-margin gate is
1430 * skipped for it. */
1432
1433/** Which trigger of an anchored leg the owner's fill supplies —
1434 * `NativeAnchoredTrigger`, #pf_native_anchored_level_view_v1::trigger. */
1440
1441/** @} */ /* end of pf_native_c_enums */
1442
1443/** @defgroup pf_native_c_types Transport types
1444 * @{ */
1445
1446/** Where the kernel is, presented to every callback.
1447 *
1448 * A read-only snapshot of `NativeDecisionContext` plus the current quote:
1449 * `price` is `current_execution_point()`'s price (the bar's own close at its
1450 * close calculation) and NaN only where that answers nullopt.
1451 *
1452 * It has TWO published layouts. A callback table sent at
1453 * #PF_NATIVE_CALLBACKS_V1_POLICY_SIZE or the current `sizeof` receives the
1454 * whole struct and its session tail. A table sent at an earlier published
1455 * length receives `struct_size` = #PF_NATIVE_DECISION_V1_BASE_SIZE — the
1456 * sizeof that earlier caller's header compiled — and nothing past it is
1457 * filled. A caller reads a field only below the presented `struct_size`.
1458 *
1459 * The four session-day bytes after `quote_kind` (R5 lane F5) sit in what
1460 * was the base layout's tail padding: its size and every offset before them
1461 * are the ones a caller compiled against the first layout reads, so that
1462 * caller keeps working unchanged, and a table of either length is handed
1463 * them. `session_facts` is 1 when the runtime wrote the three after it, and
1464 * 0 from a runtime that predates them. Each is 0 or 1, and every callback of
1465 * one script bar carries the same values:
1466 * - `in_session`: the script bar's label is in session on the run's own
1467 * calendar (`session` / `timezone`);
1468 * - `opens_session_day`: in session, and the bar before it is not, or is
1469 * on another session day;
1470 * - `closes_session_day`: in session, and the bar after it is not, or is on
1471 * another session day.
1472 * The session day is the run calendar's (it rolls at the first window's
1473 * start and is keyed to its trading date, so an overnight session is one day
1474 * across local midnight). The bar before / after is the one the run holds --
1475 * the batch input or stream warmup -- and otherwise the calendar's slot one
1476 * script width away; a run's first bar opens its day and a batch's final bar
1477 * closes it. A D/W/M bar holds whole days: all three are 1. The C++ context's
1478 * fourth fact, `closes_session_day_open_ended`, has no byte here: it differs
1479 * only on a batch's final bar, for a host that recomputes a batch whose last
1480 * input is still forming, and a C host's live edge is a stream, whose
1481 * `closes_session_day` already reads the calendar.
1482 *
1483 * The session tail is the script interval under delivery and the session
1484 * day of its open (on a 1D script, of its first in-session instant when
1485 * that is later) and of the NEXT input's open, on the run's own calendar
1486 * (its `session` and `timezone`): the calendar facts under the session-day
1487 * bytes above, for a host that applies a rule of its own. On the calendar
1488 * alone, a script bar is the last of its session day when
1489 * `next_input_session_day_ordinal` differs from `session_day_ordinal`, and
1490 * the first when the bar before it was the last. */
1492 uint32_t struct_size; /**< sizeof(pf_native_decision_v1). */
1493 uint32_t version; /**< PF_NATIVE_API_VERSION. */
1494 uint64_t ordinal; /**< Matching-point ordinal. */
1495 int32_t interval_index; /**< Script interval index. */
1496 int32_t sub_index; /**< Sub-bar index inside the script bar. */
1497 int32_t sub_count; /**< Sub-bars in this script bar (1 when unmagnified). */
1498 int32_t is_terminal_sub_bar; /**< 1 on the script bar's last sub-bar. */
1499 int64_t effective_time_ms; /**< The point's effective decision time. */
1500 int64_t script_bar_open_ms; /**< Open of the script bar under delivery. */
1501 int64_t sub_bar_open_ms; /**< Open of the sub-bar under delivery. */
1502 int64_t decision_floor_ms; /**< Lower bound a new request may be matched at. */
1503 double price; /**< Current quote, NaN outside an execution point. */
1504 uint8_t provenance; /**< #pf_native_price_provenance_t. */
1505 uint8_t path_phase; /**< #pf_native_path_phase_t. */
1506 uint8_t completion; /**< #pf_native_completion_kind_t. */
1507 uint8_t quote_kind; /**< #pf_native_quote_kind_t; 0 when price is NaN. */
1508 uint8_t session_facts; /**< 1 when the three bytes below are written. */
1509 uint8_t in_session; /**< The script bar is in session. */
1510 uint8_t opens_session_day; /**< It opens its session day. */
1511 uint8_t closes_session_day; /**< It closes its session day. */
1512
1513 /* ── The additive session tail (R5 lane F4). Presented to a callback
1514 * table with the policy-hook tail or its successor; see above. ── */
1515 int64_t script_interval_open_ms; /**< The script interval's nominal origin. */
1516 int64_t script_interval_eligible_open_ms; /**< Its first in-session instant. */
1517 int64_t script_interval_last_traded_close_ms; /**< Its exclusive end of trading. */
1518 int64_t script_interval_next_period_open_ms; /**< The next interval's nominal open,
1519 * a closed slot included. */
1520 int64_t script_interval_next_input_open_ms; /**< The next actual eligible input
1521 * open at or after that close:
1522 * closed time skipped. */
1523 int64_t session_day_ordinal; /**< The session day of
1524 * `script_interval_open_ms` -- on a
1525 * 1D script, of
1526 * `script_interval_eligible_open_ms`
1527 * when that is later (a D bar a
1528 * daily stamp dates before its
1529 * session opens): days since
1530 * 1970-01-01 of its trading date. */
1531 int64_t next_input_session_day_ordinal; /**< The session day of
1532 * `script_interval_next_input_open_ms`. */
1533 uint8_t has_script_interval; /**< 1 when the point has a script
1534 * interval; the seven fields above
1535 * are 0 otherwise. */
1536 uint8_t has_session_day; /**< 1 when the calendar keyed
1537 * `session_day_ordinal`. */
1538 uint8_t has_next_input_session_day; /**< 1 when it keyed
1539 * `next_input_session_day_ordinal`. */
1540 uint8_t reserved0[5]; /**< Always 0. */
1542
1543/** Byte length of #pf_native_decision_v1 as the L13 lane first published it,
1544 * before the session tail was appended — the `struct_size` a callback table
1545 * shorter than #PF_NATIVE_CALLBACKS_V1_POLICY_SIZE is presented. It is the
1546 * offset of the first appended field, which is that layout's sizeof on every
1547 * target (it ended in
1548 * padding the tail's first 8-byte field begins after). */
1549#define PF_NATIVE_DECISION_V1_BASE_SIZE \
1550 ((uint32_t)offsetof(pf_native_decision_v1, script_interval_open_ms))
1551
1552/** The calendar interval of the bucket delivered to
1553 * #pf_native_callbacks_v1::on_timeframe_bar. The query that fills this POD is
1554 * valid only while that callback is running; outside it the runtime answers
1555 * #PF_NATIVE_E_STATE. A zero interval is a valid kernel answer when the
1556 * bucket had no calendar lookup. */
1558 uint32_t struct_size; /**< sizeof(pf_native_timeframe_interval_v1). */
1559 uint32_t version; /**< PF_NATIVE_API_VERSION. */
1560 int64_t open_ms;
1566
1567/** One applied execution, presented to `on_applied`. */
1568typedef struct pf_native_applied_v1 {
1569 uint32_t struct_size; /**< sizeof(pf_native_applied_v1). */
1570 uint32_t version; /**< PF_NATIVE_API_VERSION. */
1571 uint64_t ordinal; /**< Event ordinal. */
1572 uint64_t incarnation; /**< The request that executed. */
1573 uint64_t opened_lot_incarnation; /**< The lot this fill opened, 0 when none. */
1574 double raw_price; /**< The path price the match was found at. */
1575 double resolved_price; /**< The booked price after terms and slippage. */
1576 double closed_units; /**< Units closed by this fill. */
1577 double opened_units; /**< Units opened by this fill. */
1578 double filled_working; /**< Working units this fill consumed. */
1579 double ticket; /**< `current_ticket` at the fill. */
1580 int64_t cycle_before; /**< Position cycle before the fill. */
1581 int64_t cycle_after; /**< Position cycle after the fill. */
1582 uint8_t terminal; /**< 1 when the request is finished. */
1583 uint8_t terminal_reason; /**< #pf_native_terminal_reason_t, valid when
1584 * `has_terminal_reason`. */
1585 uint8_t has_terminal_reason; /**< 1 when `terminal_reason` is meaningful. */
1586 uint8_t reserved0;
1588
1589/** One recorded event, read back by #strategy_native_events_v1.
1590 *
1591 * `kind` tags the union: every field below is documented per kind and is
1592 * zero where that kind has no such fact. `reason` is read by the kind's own
1593 * enumeration, and is 0 for a kind that names none.
1594 * - ACCEPTED / ARMED: `incarnation`.
1595 * - REJECTED: `reason` is a #pf_native_reject_reason_t.
1596 * - REPLACE_REJECTED: `incarnation` is the target, `reason` a
1597 * #pf_native_reject_reason_t.
1598 * - REPLACED: `incarnation` is the predecessor, `successor` the new handle.
1599 * - CANCELLED: `reason` is a #pf_native_cancel_reason_t.
1600 * - NOT_WORKING / INVALID_HANDLE: `incarnation` is the target.
1601 * - NO_EFFECT: `incarnation`, cursor fields.
1602 * - MATCH_REJECTED: `reason` is a #pf_native_match_reject_t, cursor fields.
1603 * - APPLIED: every price/unit/cycle field, `terminal`, cursor fields; when
1604 * `terminal` is 1, `reason` is the #pf_native_terminal_reason_t that
1605 * finished the request.
1606 * - CLOSE_BOUND: `reason` is the #pf_native_side_t of the book the close
1607 * bound to, `cycle_after` its cycle, cursor fields.
1608 * - RESERVATION_REDUCED / DEFERRED_GROUP: `incarnation` is the recipient,
1609 * `reason` its #pf_native_group_effect_t, `closed_units` the deduction
1610 * (applied, or deferred); 0 when it was absorbed -- too small to move the
1611 * recipient's remaining units, or its pending total, in binary64, which
1612 * stay as they were (R5 lane K-ULP5).
1613 * - QUANTITY_BOUND: `incarnation`, `opened_units` = the source units.
1614 * - TERMS_RESOLVED: `raw_price`, `resolved_price` (= `price`), cursor fields.
1615 * - MARGIN_CALL: `reason` is the #pf_native_side_t of the liquidated
1616 * position, `price` = mark, `closed_units` = liquidated units,
1617 * `opened_units` = the signed position after it, `raw_price` = the
1618 * re-solved liquidation price. The call's equity, requirement and the
1619 * position before it are #strategy_native_margin_call_v1's.
1620 * - ACTIVATED: `reason` is a #pf_native_activation_t, `price` the reached
1621 * price.
1622 * - DRIVER_POINT: cursor fields and `raw_price`.
1623 * - ACCOUNT: `price` = marked equity, `raw_price` = realized balance,
1624 * `opened_units` = signed position units.
1625 * - RISK: `reason` is a #pf_native_risk_limit_t, `price` = the observed
1626 * value that reached the limit, `raw_price` = the limit it was measured
1627 * against (account currency for the two loss limits — a percent limit is
1628 * already resolved against its basis equity — days or fills for the two
1629 * counts), `cycle_before` = the risk day the breach happened on, on the
1630 * spec's own day basis, `successor` = the cursor's matching-point
1631 * ordinal, cursor fields set. The event names no request: it is an
1632 * account fact, so `incarnation` stays 0. */
1633typedef struct pf_native_event_v1 {
1634 uint32_t struct_size; /**< sizeof(pf_native_event_v1). */
1635 uint32_t version; /**< PF_NATIVE_API_VERSION. */
1636 uint32_t kind; /**< #pf_native_event_kind_t. */
1637 uint32_t reason; /**< Per-kind reason enumerator, 0 when none. */
1638 uint64_t ordinal; /**< Event ordinal; strictly increasing. */
1639 uint64_t incarnation; /**< Subject request, 0 when the kind has none. */
1640 uint64_t successor; /**< REPLACED: the new handle. RISK: the cursor's
1641 * matching-point ordinal. 0 otherwise. */
1644 double price;
1649 int64_t effective_time_ms; /**< Cursor effective time, 0 when the kind has no cursor. */
1650 int32_t interval_index; /**< Cursor interval index. */
1651 uint8_t provenance; /**< Cursor #pf_native_price_provenance_t. */
1652 uint8_t path_phase; /**< Cursor #pf_native_path_phase_t. */
1653 uint8_t terminal; /**< APPLIED only. */
1654 uint8_t reserved0[3];
1656
1657/** One live request, copied out by #strategy_native_working_get_v1.
1658 *
1659 * `label` and `comment` borrow the snapshot taken by the most recent
1660 * #strategy_native_working_len_v1 call on this handle. They stay valid until
1661 * the next call to that function, or until the host is freed; copy them if
1662 * the host keeps them longer.
1663 *
1664 * This readout has THREE published layouts and the runtime fills any: the
1665 * base layout the L13 lane first shipped (#PF_NATIVE_WORKING_V1_BASE_SIZE),
1666 * that plus `trail_has_arm_price` (#PF_NATIVE_WORKING_V1_ARM_SIZE), and the
1667 * current one, which appends the anchor and the owner relation. A caller
1668 * compiled against an earlier layout keeps working unchanged: its row is
1669 * written up to its own length and never past it. Any other `struct_size`
1670 * is PF_NATIVE_E_STRUCT.
1671 *
1672 * The relation tail is the request's own anchor and owner as the kernel
1673 * holds them now: an anchored leg reads FROM_OWNER_FILL, its rounding and
1674 * its offset (a tick-spelled one already resolved to price units at
1675 * acceptance) until its owner fills, and ABSOLUTE with the installed level
1676 * in `p1` / `p2` after; the owner relation names the owner handle, how many
1677 * there are and the bound cycle, and a WAIT_FOR_APPLIED child's visibility,
1678 * first-match rule and scope.
1679 *
1680 * `trail_has_arm_price` is the request's own flag read back, so a TRAIL with
1681 * no arm price and one armed at 0.0 are two different rows even though both
1682 * read `p2` = 0. An anchored trail (#PF_NATIVE_ANCHOR_FROM_OWNER_FILL) reads
1683 * back the spelling it was submitted with until its owner fills; the arm
1684 * then installs the level, and from there it reads 1 with that level in
1685 * `p2`. A tick-spelled offset needs no such flag: acceptance resolves it
1686 * into `p1` as a price distance. */
1687typedef struct pf_native_working_v1 {
1688 uint32_t struct_size; /**< sizeof(pf_native_working_v1). */
1689 uint32_t version; /**< PF_NATIVE_API_VERSION. */
1690 uint64_t incarnation; /**< The request's handle. */
1691 uint32_t intent; /**< #pf_native_intent_t as accepted. */
1692 uint32_t trigger; /**< #pf_native_trigger_t as accepted. */
1693 uint32_t owner; /**< #pf_native_owner_t as accepted. */
1694 uint32_t capacity; /**< #pf_native_capacity_t as accepted. */
1695 uint32_t group_kind; /**< #pf_native_group_t as accepted. */
1696 uint32_t group_effect; /**< #pf_native_group_effect_t, 0 when no group. */
1697 uint32_t remaining_kind; /**< #pf_native_remaining_t. */
1698 uint32_t trigger_state; /**< #pf_native_trigger_state_t. */
1699 uint32_t origin; /**< #pf_native_origin_t. */
1700 uint32_t reserved0;
1701 double intent_value; /**< The intent's own scalar, 0 when it has none. */
1702 double p1; /**< Trigger level 1 (limit / stop / trail offset). */
1703 double p2; /**< Trigger level 2 (stop-limit limit / trail arm
1704 * when `trail_has_arm_price`). */
1705 double capacity_units; /**< Point budget, 0 for immediate capacity. */
1706 double remaining_units; /**< Valid when `remaining_kind` is UNITS. */
1707 uint64_t group_id;
1709 uint64_t acceptance_ordinal; /**< Birth: the accepting event. */
1710 int64_t decision_time_lower_bound; /**< Birth: earliest matchable time. */
1711 const char* label; /**< Borrowed; see the struct note. */
1712 const char* comment; /**< Borrowed; see the struct note. */
1713
1714 /* ── The additive arm-presence tail. Written only when `struct_size` is
1715 * the current sizeof; a caller sending the base layout is filled up to
1716 * `comment` above and never past it. ── */
1717 uint32_t trail_has_arm_price; /**< TRAIL: 1 when `p2` is the arm price, 0 when
1718 * the trail carries none. 0 for every other
1719 * trigger. */
1720 uint32_t reserved1; /**< Always 0. */
1721
1722 /* ── The additive relation tail (R5 lane F4). Written only when
1723 * `struct_size` is the current sizeof; see the struct note. ── */
1724 uint32_t anchor; /**< #pf_native_anchor_t as the request stands. */
1725 uint32_t anchor_rounding; /**< #pf_native_anchor_rounding_t, FROM_OWNER_FILL only. */
1726 double anchor_offset; /**< FROM_OWNER_FILL: the signed offset, price units. */
1727 uint64_t owner_handle; /**< WAIT_FOR_APPLIED: the parent; BIND_OPENING: the
1728 * opening; BIND_OPENINGS: the first of them as
1729 * the kernel ordered the list; BIND_COHORT: the
1730 * cohort; 0 for INDEPENDENT. */
1731 int64_t owner_cycle; /**< BIND_OPENING / BIND_OPENINGS: the bound cycle. */
1732 uint32_t owner_n; /**< How many owner handles the relation names. */
1733 uint32_t visibility; /**< #pf_native_arm_visibility_t, WAIT_FOR_APPLIED only. */
1734 uint32_t arm_first_match; /**< #pf_native_arm_first_match_t, WAIT_FOR_APPLIED only. */
1735 uint32_t arm_scope; /**< #pf_native_arm_scope_t, WAIT_FOR_APPLIED only. */
1737
1738/** Byte length of #pf_native_working_v1 as the L13 lane first published it,
1739 * before the arm-presence tail was appended. It is the offset of the first
1740 * appended field, so it stays correct on every target this header builds
1741 * for — it is not a literal. #strategy_native_working_get_v1 accepts this
1742 * length as well as the current `sizeof`, and writes no byte past the
1743 * length it was handed, which is what makes a readout's tail additive
1744 * rather than a layout break. */
1745#define PF_NATIVE_WORKING_V1_BASE_SIZE \
1746 ((uint32_t)offsetof(pf_native_working_v1, trail_has_arm_price))
1747
1748/** Byte length of #pf_native_working_v1 with the arm-presence tail but
1749 * without the relation tail — the second of its three published layouts,
1750 * and the `sizeof` every caller compiled before that tail existed sends.
1751 * The offset of the first relation field, for the same reason
1752 * #PF_NATIVE_WORKING_V1_BASE_SIZE is an offset. */
1753#define PF_NATIVE_WORKING_V1_ARM_SIZE \
1754 ((uint32_t)offsetof(pf_native_working_v1, anchor))
1755
1756/** One open physical lot, copied out by #strategy_native_open_lot_get_v1 —
1757 * the C spelling of `NativeOpenLot` (R5 gap lane N18): the book that
1758 * #strategy_native_position_v1 aggregates, lot by lot, marked at the price
1759 * #strategy_native_open_lot_count_v1 was given. Every field is what the
1760 * kernel already holds for the lot; reading it moves nothing.
1761 *
1762 * `unrealized_pnl` is the lot's own term of the marked equity: the move from
1763 * `entry_price` to `mark`, in account currency, less `entry_commission`.
1764 * The two excursions are the largest moves for and against the lot the
1765 * kernel has sampled along the delivered path, in account currency, gross
1766 * of fees, with `mark` folded in. A NaN `mark` keeps every booking fact,
1767 * leaves `unrealized_pnl` NaN and folds nothing into the excursions.
1768 *
1769 * `entry_label` and `entry_comment` borrow the snapshot taken by the most
1770 * recent #strategy_native_open_lot_count_v1 call on this handle. They stay
1771 * valid until the next call to that function, or until the host is freed;
1772 * copy them if the host keeps them longer. */
1774 uint32_t struct_size; /**< sizeof(pf_native_open_lot_v1). */
1775 uint32_t version; /**< PF_NATIVE_API_VERSION. */
1776 uint64_t ordinal; /**< Position in the book, oldest first. */
1777 uint64_t entry_incarnation; /**< The request whose fill opened the lot; never
1778 * reused; 0 only for a legacy synthetic lot. */
1779 int64_t cycle; /**< The position cycle the lot belongs to — the
1780 * `owner_cycle` a BIND_OPENING(S) request names. */
1781 uint32_t side; /**< #pf_native_side_t. */
1782 int32_t entry_bar_index; /**< Script-bar index of the opening fill. */
1783 int64_t entry_time_ms; /**< Effective time of the opening fill. */
1784 double entry_price; /**< Booked entry price. */
1785 double signed_units; /**< Remaining units: > 0 long, < 0 short. */
1786 double entry_commission; /**< Entry fee still on the lot, account currency;
1787 * a partial realization takes its share with it. */
1788 double mark; /**< The price the three fields below were marked at. */
1789 double unrealized_pnl; /**< Fee-net move to `mark`, account currency; NaN for a NaN mark. */
1790 double favorable_excursion; /**< Largest move for the lot so far, account currency, >= 0. */
1791 double adverse_excursion; /**< Largest move against the lot so far, account currency, >= 0. */
1792 const char* entry_label; /**< Borrowed; see the struct note. */
1793 const char* entry_comment; /**< Borrowed; see the struct note. */
1795
1796/** The run's lifecycle and its typed failure. */
1797typedef struct pf_native_state_v1 {
1798 uint32_t struct_size; /**< sizeof(pf_native_state_v1). */
1799 uint32_t version; /**< PF_NATIVE_API_VERSION. */
1800 uint32_t lifecycle; /**< #pf_native_lifecycle_t. */
1801 uint32_t failure_code; /**< #pf_native_failure_code_t;
1802 * PF_NATIVE_FAILURE_CALLBACK_EXCEPTION for a callback
1803 * that returned non-zero. */
1804 uint32_t failure_operation; /**< #pf_native_failure_operation_t. */
1805 uint32_t failure_discriminator; /**< The kernel's own word beside the code, as C++
1806 * `NativeFailure::discriminator` holds it: the
1807 * request core's `native_order::CoreFailure` for a
1808 * refused preparation (CONTRACT or
1809 * SETTLEMENT_FAILURE; 7 is
1810 * `UnrepresentableReservation`), its `InstallError`
1811 * for a refused install (CONTRACT), the settlement's
1812 * `execution::Status` for a failed inspection or
1813 * commit (SETTLEMENT_FAILURE), a staged FX curve's
1814 * `NativeFxCurveError` (INVALID_SPECIFICATION); 0
1815 * when the failure carries none, as every completed
1816 * run does. */
1817 uint64_t failure_ordinal; /**< The point the failure was latched at, 0 when absent. */
1820 uint32_t phase; /**< #pf_native_run_phase_t while Running. */
1821 uint32_t completion; /**< #pf_native_completion_t once Completed. */
1823
1824/** The trail projection of #strategy_native_trail_state_v1 — the C spelling
1825 * of `NativeTrailState`. Before the arm is reached `activated` is 0 and
1826 * every other field is 0; once armed, `best_price` and `current_level` are
1827 * the exact raw matcher values and `activation_ordinal` identifies the
1828 * TrailArm event that began tracking. */
1830 uint32_t struct_size; /**< sizeof(pf_native_trail_state_v1). */
1831 uint32_t version; /**< PF_NATIVE_API_VERSION. */
1832 uint32_t activated; /**< 0/1: the arm price has been reached. */
1833 uint32_t reserved0;
1834 double best_price; /**< Running best; 0 before the arm. */
1835 double current_level; /**< The stop the best is riding; 0 before the arm. */
1836 uint64_t activation_ordinal; /**< The TrailArm event; 0 before the arm. */
1838
1839/** The facts one margin hook is handed — the C spelling of
1840 * `NativeMarginRequirementView`, `NativeMarginCheckPoint` and
1841 * `NativeMarginCallView`, which differ only in which of these facts they
1842 * carry. Every field is documented per hook and is zero where that hook has
1843 * no such fact, exactly as #pf_native_event_v1's union is:
1844 *
1845 * - on_margin_check: `kind`, `liquidation_resting`, the position, `mark`
1846 * and the cursor. `equity` and `required` are 0 — nothing has been
1847 * evaluated yet at that point.
1848 * - on_margin_requirement: `kind`, the position, `mark`, and the two
1849 * numbers the kernel is ABOUT to compare (`equity`, `required`) — exactly
1850 * what it would compare if the host answered PF_NATIVE_ANSWER_DEFAULT.
1851 * - on_margin_call_units: the position being liquidated, the sizing `mark`,
1852 * the `equity` and `required` measured there, and the cursor. `kind` and
1853 * `liquidation_resting` are 0: a call is not a check point. */
1855 uint32_t struct_size; /**< sizeof(pf_native_margin_view_v1). */
1856 uint32_t version; /**< PF_NATIVE_API_VERSION. */
1857 uint32_t kind; /**< #pf_native_margin_check_kind_t. */
1858 uint32_t liquidation_resting; /**< 0/1: a liquidation rests from an earlier point. */
1859 double signed_units; /**< The book being measured. */
1861 uint64_t lot_count;
1862 double mark; /**< The price the breach is measured at. */
1863 double equity; /**< Marked equity on the model's basis. */
1864 double required; /**< Maintenance requirement of the whole position at `mark`. */
1867 double cursor_t;
1869 uint8_t cursor_provenance; /**< #pf_native_price_provenance_t. */
1870 uint8_t cursor_path_phase; /**< #pf_native_path_phase_t. */
1871 uint8_t reserved0[2];
1873
1874/** The host's answer to one requirement view — `NativeMarginDecision`.
1875 * `required` and `equity` replace the kernel's two numbers for that check
1876 * point only: they are a broker's money rule, never a second account.
1877 * `force_breach` makes the kernel proceed past `required > equity` even when
1878 * the answered numbers do not meet it. Read only when the hook answers
1879 * #PF_NATIVE_ANSWER_PROVIDED; a nonfinite `required` or `equity` is refused
1880 * by the kernel and the check point is abandoned, exactly as in C++. */
1882 uint32_t struct_size; /**< sizeof(pf_native_margin_decision_v1). */
1883 uint32_t version; /**< PF_NATIVE_API_VERSION. */
1884 uint32_t force_breach; /**< 0/1. */
1885 uint32_t reserved0;
1886 double required;
1887 double equity;
1889
1890/** The facts a host-sized CLOSE is resolved from, handed to
1891 * #pf_native_callbacks_v1::on_close_units.
1892 *
1893 * It is the UNITS half of `NativeExecutionTermsFacts`, and only that half:
1894 * `scope_exposure_units` is what the bound scope holds at this candidate —
1895 * for a cohort close, the live units of the roster's own openings and
1896 * nothing else. The price half and the opening shape stay the kernel's. */
1898 uint32_t struct_size; /**< sizeof(pf_native_close_view_v1). */
1899 uint32_t version; /**< PF_NATIVE_API_VERSION. */
1900 uint64_t incarnation; /**< The request being resolved. */
1901 double scope_exposure_units; /**< What the bound scope holds here. */
1902 double default_resolved_price; /**< The price the kernel would settle at. */
1903 double position_units; /**< The whole physical book, signed. */
1906 uint32_t is_buy; /**< 0/1: the side this candidate would trade on. */
1907 uint32_t reserved0;
1909
1910/** One closing lot's booking facts — `ClosedLotExcursionFacts` (RULING A48).
1911 * Handed to #pf_native_callbacks_v1::on_lot_excursion, whose two outputs are
1912 * the favorable and adverse magnitudes the closing row then carries. Facts
1913 * in, magnitudes out: nothing about the host's price model crosses the
1914 * boundary in either direction. The two entry-bar masks are what
1915 * #strategy_native_declare_opened_lot_entry_bar_mask_v1 derived for the lot,
1916 * and 0 for a lot nobody declared. The additive tail's entry_commission is
1917 * the entry-fee share already carried by this closing slice. */
1919 uint32_t struct_size; /**< sizeof(pf_native_lot_excursion_v1). */
1920 uint32_t version; /**< PF_NATIVE_API_VERSION. */
1921 uint64_t entry_incarnation; /**< The lot's opening request. */
1924 double lot_qty; /**< The whole lot. */
1925 double closed_qty; /**< What this fill closes of it. */
1927 double carried_favorable; /**< What the lot carried in, for a partial close. */
1931 uint8_t is_long;
1932 uint8_t entry_bar_high_masked; /**< The entry bar's high is not this trade's. */
1933 uint8_t entry_bar_low_masked; /**< The entry bar's low is not this trade's. */
1934 uint8_t reserved0;
1935 double entry_commission; /**< This closing slice's share of the entry fee,
1936 * in account currency. Present in the additive
1937 * tail of the current layout. */
1939
1940/** Byte length of the first published #pf_native_lot_excursion_v1 layout,
1941 * before #pf_native_lot_excursion_v1::entry_commission was appended. A
1942 * callback table from that layout receives this length in @c struct_size. */
1943#define PF_NATIVE_LOT_EXCURSION_V1_BASE_SIZE \
1944 ((uint32_t)offsetof(pf_native_lot_excursion_v1, entry_commission))
1945
1946/** The facts of one matching candidate, handed to
1947 * #pf_native_callbacks_v1::on_execution_terms — the price half of
1948 * `NativeExecutionTermsFacts`. Every field is what the kernel measured at
1949 * this candidate; `default_resolved_price` is the price it would settle at
1950 * (slippage and the grid applied), i.e. what the host answers DEFAULT to. */
1952 uint32_t struct_size; /**< sizeof(pf_native_terms_view_v1). */
1953 uint32_t version; /**< PF_NATIVE_API_VERSION. */
1954 uint64_t incarnation; /**< The request being resolved. */
1955 uint32_t intent; /**< #pf_native_intent_t of that request. */
1956 uint32_t trigger; /**< #pf_native_trigger_t of that request. */
1957 uint32_t trigger_state; /**< #pf_native_trigger_state_t. */
1958 uint32_t remaining_kind; /**< #pf_native_remaining_t. */
1959 double remaining_units; /**< Valid when `remaining_kind` is UNITS. */
1960 uint32_t driver_class; /**< #pf_native_driver_class_t. */
1961 uint32_t price_kind; /**< #pf_native_candidate_price_t. */
1962 uint32_t quote_kind; /**< #pf_native_quote_kind_t. */
1963 uint32_t price_rule; /**< #pf_native_price_rule_t. */
1964 uint32_t is_buy; /**< 0/1: the side this candidate trades on. */
1965 uint32_t shared_cursor_collision; /**< 0/1: a rounded quote shared with another level. */
1966 double raw_price; /**< The path price the match was found at. */
1967 double trigger_level; /**< The level crossed, when `has_trigger_level`. */
1968 uint32_t has_trigger_level; /**< 0/1. */
1969 uint32_t reserved0; /**< Always 0. */
1970 double default_resolved_price; /**< The kernel's own settlement price. */
1971 double scope_exposure_units; /**< What the bound scope holds here. */
1972 double position_units; /**< The whole physical book, signed. */
1977 int64_t fx_effective_time_ms; /**< Where the account rate is read. */
1978 double active_fx; /**< The account rate there. */
1981 double cursor_t;
1983 uint8_t cursor_provenance; /**< #pf_native_price_provenance_t. */
1984 uint8_t cursor_path_phase; /**< #pf_native_path_phase_t. */
1985 uint8_t reserved1[2]; /**< Always 0. */
1987
1988/** The price half of the terms #pf_native_callbacks_v1::on_execution_terms
1989 * answers — `ExecutionTerms` less its units, which
1990 * #pf_native_callbacks_v1::on_close_units answers for a host-sized close.
1991 * The runtime fills it with the kernel's default (`default_resolved_price`,
1992 * TRANSACT, SNAP) before the call. */
1993typedef struct pf_native_terms_v1 {
1994 uint32_t struct_size; /**< sizeof(pf_native_terms_v1). */
1995 uint32_t version; /**< PF_NATIVE_API_VERSION. */
1996 double resolved_price; /**< The price to settle at. */
1997 uint32_t shape; /**< #pf_native_opening_shape_t. */
1998 uint32_t grid_policy; /**< #pf_native_grid_policy_t. */
2000
2001/** The last facts before one execution's physical effect, handed to
2002 * #pf_native_callbacks_v1::on_precommit — `NativePrecommitView`: the plan,
2003 * the prices, the settlement inspection, and the account the fill would
2004 * leave (the projection's closed rows' P&L, borrowed for the call, in
2005 * roster order). Offered once per ready attempt, never for an inspection,
2006 * and only when the settlement is ready to apply. */
2008 uint32_t struct_size; /**< sizeof(pf_native_precommit_view_v1). */
2009 uint32_t version; /**< PF_NATIVE_API_VERSION. */
2010 uint64_t incarnation; /**< The request about to execute. */
2011 uint32_t intent; /**< #pf_native_intent_t of that request. */
2012 uint32_t plan; /**< #pf_native_plan_t. */
2013 double plan_units; /**< See #pf_native_plan_t. */
2019 uint32_t current; /**< 1 for #strategy_native_execute_current_v1. */
2020 uint32_t would_open; /**< 0/1: the fill opens a lot. */
2021 uint32_t incoming_short; /**< 0/1: the opened lot is short. */
2022 uint32_t reserved0; /**< Always 0. */
2026 double realized_balance; /**< After the fill, account currency. */
2027 double remaining_entry_cost; /**< Paid costs on the resulting book. */
2028 double marked_equity; /**< After the fill, at its price. */
2031 const double* closed_row_pnl; /**< `closed_row_count` values; borrowed. */
2035 double cursor_t;
2037 uint8_t cursor_provenance; /**< #pf_native_price_provenance_t. */
2038 uint8_t cursor_path_phase; /**< #pf_native_path_phase_t. */
2039 uint8_t reserved1[2]; /**< Always 0. */
2041
2042/** One anchored leg's materialization, handed to
2043 * #pf_native_callbacks_v1::on_anchored_level exactly once, before its armed
2044 * event — `NativeAnchoredLevelView`. `kernel_level` is fill + offset after
2045 * the anchor's own rounding: what the host answers DEFAULT to. */
2047 uint32_t struct_size; /**< sizeof(pf_native_anchored_level_view_v1). */
2048 uint32_t version; /**< PF_NATIVE_API_VERSION. */
2049 uint64_t owner; /**< The request whose fill arms the leg. */
2050 uint64_t owner_applied_ordinal; /**< That fill's applied execution. */
2051 uint64_t owner_lot_incarnation; /**< The lot it opened. */
2052 double owner_fill_price; /**< Its resolved price. */
2053 uint64_t leg; /**< The anchored request. */
2054 uint32_t leg_side; /**< #pf_native_side_t the leg trades on. */
2055 uint32_t trigger; /**< #pf_native_anchored_trigger_t. */
2056 double offset; /**< The anchor's offset, price units. */
2057 double price_tick; /**< The run's tick, 0 when none. */
2058 double kernel_level; /**< The level the kernel would install. */
2063 uint8_t owner_cursor_provenance; /**< #pf_native_price_provenance_t. */
2064 uint8_t owner_cursor_path_phase; /**< #pf_native_path_phase_t. */
2065 uint8_t reserved0[2]; /**< Always 0. */
2067
2068/** The run's generic risk ledger — the C spelling of `NativeRiskState` (L9).
2069 *
2070 * Every field is its zero for a run that declares no risk block, exactly as
2071 * the C++ value is. `blocked` is whether openings are refused right now and
2072 * `reason` names the limit that did it (valid only when `has_reason`);
2073 * `day_ordinal` is the risk day the ledger is on, on the spec's own day
2074 * basis, and is meaningful only when `has_day`. Observation only: reading it
2075 * moves nothing. */
2077 uint32_t struct_size; /**< sizeof(pf_native_risk_state_v1). */
2078 uint32_t version; /**< PF_NATIVE_API_VERSION. */
2079 uint32_t blocked; /**< 0/1: openings are refused right now. */
2080 uint32_t has_reason; /**< 0/1: `reason` is meaningful. */
2081 uint32_t reason; /**< #pf_native_risk_limit_t that blocked. */
2082 uint32_t has_day; /**< 0/1: the ledger has reached a day. */
2083 uint32_t consecutive_loss_days; /**< Days that closed with a realized loss. */
2084 uint32_t reserved0;
2085 int64_t day_ordinal; /**< The risk day, on the spec's day basis. */
2086 uint64_t fills_today; /**< Applied fills counted in that day. */
2087 double peak_equity; /**< Running peak of the marked equity. */
2088 double day_open_equity; /**< Equity the current day opened at. */
2090
2091/** One kernel-issued liquidation that filled, whole — the C spelling of
2092 * `native_order::MarginCallEvent`, copied out by
2093 * #strategy_native_margin_call_v1.
2094 *
2095 * It carries the margin facts of that fill, so a host reconstructs the
2096 * outcome without recomputing the account: `mark` is the booked resolved
2097 * price, `equity` and `required` are the marked equity and the maintenance
2098 * requirement of the SURVIVING book at that price, `liquidation_price` is
2099 * the level re-solved for what is left, and `position_before` /
2100 * `position_after` are the signed book on either side of the reduction.
2101 * `applied_ordinal` names the #PF_NATIVE_EVENT_APPLIED row that booked it;
2102 * the cursor is the point it filled at. The #PF_NATIVE_EVENT_MARGIN_CALL row
2103 * of the same `ordinal` carries a subset of these facts. */
2105 uint32_t struct_size; /**< sizeof(pf_native_margin_call_v1). */
2106 uint32_t version; /**< PF_NATIVE_API_VERSION. */
2107 uint64_t ordinal; /**< The call's event ordinal. */
2108 uint64_t incarnation; /**< The kernel's liquidation request. */
2109 uint64_t applied_ordinal; /**< The applied execution that booked it. */
2110 uint32_t side; /**< #pf_native_side_t of the liquidated position. */
2111 uint32_t reserved0; /**< Always 0. */
2112 double mark; /**< The booked resolved price. */
2113 double equity; /**< Marked equity of the surviving book at `mark`. */
2114 double required; /**< Maintenance requirement of the surviving book at `mark`. */
2115 double liquidation_price; /**< The level re-solved for what is left. */
2116 double units; /**< Units liquidated. */
2117 double position_before; /**< Signed book before the reduction. */
2118 double position_after; /**< Signed book after it. */
2121 double cursor_t;
2123 uint8_t cursor_provenance; /**< #pf_native_price_provenance_t. */
2124 uint8_t cursor_path_phase; /**< #pf_native_path_phase_t. */
2125 uint8_t reserved1[2]; /**< Always 0. */
2127
2128/** One order request. Translated field by field into `native_order::Request`;
2129 * it is never cast. Zero-initialise it, set `struct_size` and `version`, then
2130 * set only the fields the chosen `intent` and `trigger` document.
2131 *
2132 * This struct has FIVE published layouts and the runtime accepts any of
2133 * them: the base layout the L13 lane first shipped
2134 * (#PF_NATIVE_REQUEST_V1_BASE_SIZE), that layout plus L7b's anchored-leg
2135 * tail (#PF_NATIVE_REQUEST_V1_ANCHOR_SIZE), that plus L3b's sizing detail
2136 * `size_price`, `reduce_basis` (#PF_NATIVE_REQUEST_V1_SIZING_SIZE), that
2137 * plus E14's trail seed (`trail_best_seed`, `trail_has_best_seed`;
2138 * #PF_NATIVE_REQUEST_V1_SEED_SIZE), and the current one, which appends the
2139 * arm relation (`arm_first_match`, `arm_scope`). A caller compiled against
2140 * an earlier layout keeps working unchanged and simply gets the later tails'
2141 * defaults (RAW, WORKING, RESOLVED, AT_MATCH, no seed, AT_ARM_PRINT,
2142 * OWNER_LOT). Any other `struct_size` is PF_NATIVE_E_STRUCT. Every tail is
2143 * append-only: nothing above it moved. */
2144typedef struct pf_native_request_v1 {
2145 uint32_t struct_size; /**< sizeof(pf_native_request_v1). */
2146 uint32_t version; /**< PF_NATIVE_API_VERSION. */
2147
2148 /* Intent */
2149 uint32_t intent; /**< #pf_native_intent_t. */
2150 uint32_t reduce_size; /**< #pf_native_reduction_t, REDUCE only. */
2151 uint32_t reduce_claim; /**< #pf_native_scope_claim_t, SCOPE_FRACTION only. */
2152 uint32_t side; /**< #pf_native_side_t, SIZED only. */
2153 uint32_t size_basis; /**< #pf_native_size_basis_t, SIZED only. */
2154 uint32_t size_time; /**< #pf_native_size_time_t, SIZED only. */
2155 uint32_t grid_policy; /**< #pf_native_grid_policy_t, SIZED only. */
2156 uint32_t reserve_percent_fee; /**< 0/1, SIZED only. */
2157 double intent_value; /**< The intent's own scalar; see #pf_native_intent_t. */
2158
2159 /* Trigger */
2160 uint32_t trigger; /**< #pf_native_trigger_t. */
2161 uint32_t anchor; /**< #pf_native_anchor_t (L7). */
2162 double p1; /**< Limit/stop price, or trail offset. */
2163 double p2; /**< Stop-limit limit, or trail arm price. */
2164 double anchor_offset; /**< FROM_OWNER_FILL: signed offset. */
2165 uint8_t fill_through; /**< LIMIT only: market-if-touched. */
2166 uint8_t trail_offset_in_ticks; /**< TRAIL: p1 is a tick count, not a distance. */
2167 uint8_t trail_has_arm_price; /**< TRAIL: p2 is the arm price. */
2168 uint8_t anchor_offset_in_ticks; /**< FROM_OWNER_FILL: the offset is a tick count. */
2169
2170 /* Capacity */
2171 uint32_t capacity; /**< #pf_native_capacity_t. */
2172 double capacity_units; /**< POINT_BUDGET only. */
2173
2174 /* Owner */
2175 uint32_t owner; /**< #pf_native_owner_t. */
2176 uint32_t owner_n; /**< Length of `owner_incarnations`. */
2177 const uint64_t* owner_incarnations; /**< Borrowed for the call only. */
2178 int64_t owner_cycle; /**< BIND_OPENING / BIND_OPENINGS. */
2179 uint64_t cohort; /**< BIND_COHORT. */
2180
2181 /* Group */
2182 uint32_t group_kind; /**< #pf_native_group_t. */
2183 uint32_t group_effect; /**< #pf_native_group_effect_t. */
2184 uint64_t group_id; /**< MEMBER only. */
2185 int64_t group_cohort; /**< MEMBER only. */
2186
2187 /* Identity. Both borrowed for the call only; the kernel copies them.
2188 * NULL is the empty string. */
2189 const char* label;
2190 const char* comment;
2191
2192 /* ── The additive anchored-leg tail (L7b). Read only when `struct_size`
2193 * is the current sizeof; a caller sending the base layout stops at
2194 * `comment` above and gets every default (RAW, WORKING). ── */
2195 uint32_t anchor_rounding; /**< #pf_native_anchor_rounding_t, FROM_OWNER_FILL only. */
2196 uint32_t visibility; /**< #pf_native_arm_visibility_t, WAIT_FOR_APPLIED only. */
2197
2198 /* ── The additive sizing-detail tail (L3b). Read only when `struct_size`
2199 * is the current sizeof; a caller sending either earlier layout stops
2200 * above and gets both defaults (RESOLVED, AT_MATCH), which is what every
2201 * request accepted before this tail already resolved as. ── */
2202 uint32_t size_price; /**< #pf_native_size_price_t, SIZED only. */
2203 uint32_t reduce_basis; /**< #pf_native_scope_basis_t, SCOPE_FRACTION only. */
2204
2205 /* ── The additive trail-seed tail (E14). Read only when `struct_size`
2206 * is the current sizeof; a caller sending any earlier layout stops above
2207 * and gets no seed, which is what every trail accepted before this tail
2208 * already rode. ── */
2209 double trail_best_seed; /**< TRAIL: where the running best starts —
2210 * a floor on it, the favourable one of
2211 * this level and the arm's own print.
2212 * Absolute (an anchor moves the arm
2213 * threshold, not this), finite and
2214 * positive, else PF_NATIVE_E_REJECTED.
2215 * It is a submission input: the working
2216 * readback carries the live best, not the
2217 * seed — see the asymmetry note above. */
2218 uint8_t trail_has_best_seed; /**< TRAIL: `trail_best_seed` is set. */
2219 uint8_t reserved2[7]; /**< Must be 0. The seed layout's own padding,
2220 * named so the tail below starts where
2221 * that layout's sizeof ended. */
2222 /* ── The additive arm-relation tail (R5 lane F4). Read only when
2223 * `struct_size` is the current sizeof; a caller sending any earlier
2224 * layout stops above and keeps both defaults (AT_ARM_PRINT, OWNER_LOT),
2225 * which is what every child accepted before this tail already armed as.
2226 * A non-default value is legal under WAIT_FOR_APPLIED alone. ── */
2227 uint32_t arm_first_match; /**< #pf_native_arm_first_match_t. */
2228 uint32_t arm_scope; /**< #pf_native_arm_scope_t. */
2230
2231/** Byte length of #pf_native_request_v1 as the L13 lane first published it,
2232 * before the anchored-leg tail was appended. It is the offset of the first
2233 * appended field, so it stays correct on every target this header builds
2234 * for — it is not a literal. The runtime accepts this length as well as the
2235 * current `sizeof`, which is what makes the tail additive rather than a
2236 * layout break. */
2237#define PF_NATIVE_REQUEST_V1_BASE_SIZE \
2238 ((uint32_t)offsetof(pf_native_request_v1, anchor_rounding))
2239
2240/** Byte length of #pf_native_request_v1 with L7b's anchored-leg tail but
2241 * without L3b's sizing-detail tail — the second of its five published
2242 * layouts. Defined as the offset of the first field appended after it, for
2243 * the same reason #PF_NATIVE_REQUEST_V1_BASE_SIZE is. */
2244#define PF_NATIVE_REQUEST_V1_ANCHOR_SIZE \
2245 ((uint32_t)offsetof(pf_native_request_v1, size_price))
2246
2247/** Byte length of #pf_native_request_v1 with L3b's sizing-detail tail but
2248 * without E14's trail seed — the third of its five published layouts, and
2249 * the `sizeof` every caller compiled before that seed existed sends.
2250 * Defined as the offset of the first field appended after it, for the same
2251 * reason #PF_NATIVE_REQUEST_V1_BASE_SIZE is. */
2252#define PF_NATIVE_REQUEST_V1_SIZING_SIZE \
2253 ((uint32_t)offsetof(pf_native_request_v1, trail_best_seed))
2254
2255/** Byte length of #pf_native_request_v1 with E14's trail seed but without
2256 * the arm-relation tail — the fourth of its five published layouts, and the
2257 * `sizeof` every caller compiled before that tail existed sends. The seed
2258 * layout ended in padding after `trail_has_best_seed`; `reserved2` names
2259 * exactly that padding, so the offset of the first arm field IS that sizeof
2260 * on every target. */
2261#define PF_NATIVE_REQUEST_V1_SEED_SIZE \
2262 ((uint32_t)offsetof(pf_native_request_v1, arm_first_match))
2263
2264/** One declared higher-timeframe series of #pf_native_run_spec_ext_v1.
2265 *
2266 * A row is a series INSTANCE, not a period: several rows may carry the same
2267 * `tf`, each delivered under its own index (the `subscription` argument of
2268 * #pf_native_callbacks_v1::on_timeframe_bar). Same-period rows may not carry
2269 * DIFFERENT `authoritative_bars`.
2270 *
2271 * `gaps` occupies the word this struct published as `reserved0`, which every
2272 * layout required to be zero — so a caller that zero-fills the struct keeps
2273 * PF_NATIVE_GAPS_HOLD, and the struct's size and field offsets are unchanged.
2274 * A value outside either word's enumeration is PF_NATIVE_E_TAG. */
2276 uint32_t struct_size; /**< sizeof(pf_native_subscription_v1). */
2277 uint32_t lookahead; /**< #pf_native_lookahead_t. */
2278 const char* tf; /**< Non-NULL timeframe literal. */
2279 const pf_bar_t* authoritative_bars; /**< Optional exchange bars; copied. */
2280 int32_t authoritative_n; /**< Length of `authoritative_bars`. */
2281 uint32_t gaps; /**< #pf_native_gaps_t. */
2283
2284/** The run-specification fields #pf_native_run_spec_v1 predates.
2285 *
2286 * It is a companion to #pf_native_run_spec_v1, not a second configure step:
2287 * the kernel configures a host exactly once, so both halves are handed to
2288 * #strategy_configure_native_ext_v1 together and that call replaces
2289 * #strategy_configure_native_v1 for a host that needs these fields.
2290 * `present_mask` selects the blocks that are meaningful; an absent block
2291 * keeps the kernel's own default, so an all-zero mask configures exactly
2292 * what #strategy_configure_native_v1 would have.
2293 *
2294 * Every field of NativeRunSpec that is not fixed by
2295 * #pf_native_run_spec_v1 now travels here, except `identity`, which the base
2296 * spec owns, and `timeframe_undetected`: a C run always names both timeframes.
2297 *
2298 * This struct has SIX published layouts and the runtime accepts any of
2299 * them: the base layout the L13 lane first shipped
2300 * (#PF_NATIVE_RUN_SPEC_EXT_V1_BASE_SIZE); that layout plus L9's `risk_*`
2301 * tail (#PF_NATIVE_RUN_SPEC_EXT_V1_RISK_SIZE); that one plus N8's intrabar
2302 * path, the four feed-shape and presentation policies, and the margin
2303 * model's equity basis, level base and liquidation strings
2304 * (#PF_NATIVE_RUN_SPEC_EXT_V1_POLICY_SIZE); that one plus the
2305 * `auxiliary_*` tail (#PF_NATIVE_RUN_SPEC_EXT_V1_AUXILIARY_SIZE); that one
2306 * plus the `event_retention` tail
2307 * (#PF_NATIVE_RUN_SPEC_EXT_V1_RETENTION_SIZE); and the current one, which
2308 * appends the `quantity_tolerance` tail after them. A caller compiled
2309 * against an earlier layout keeps working unchanged and simply cannot set
2310 * the mask bits its struct has no fields for (#PF_NATIVE_SPEC_EXT_RISK,
2311 * #PF_NATIVE_SPEC_EXT_INTRABAR, #PF_NATIVE_SPEC_EXT_FEED_POLICY,
2312 * #PF_NATIVE_SPEC_EXT_AUXILIARY_FEED, #PF_NATIVE_SPEC_EXT_EVENT_RETENTION,
2313 * #PF_NATIVE_SPEC_EXT_QUANTITY_TOLERANCE): doing so is PF_NATIVE_E_STRUCT.
2314 * Any other `struct_size` is PF_NATIVE_E_STRUCT too. Every tail is
2315 * append-only: nothing above them moved. */
2317 uint32_t struct_size; /**< sizeof(pf_native_run_spec_ext_v1). */
2318 uint32_t version; /**< PF_NATIVE_API_VERSION. */
2319 uint32_t present_mask; /**< #pf_native_spec_ext_mask_t bits. */
2320
2321 uint32_t report_policy; /**< #pf_native_report_policy_t. */
2322 uint32_t report_open_position_at_end; /**< 0/1; #PF_NATIVE_REPORT_KERNEL_RECORDED only. */
2323
2324 uint32_t price_grid; /**< #pf_native_price_grid_t. */
2325 uint32_t grid_rounding; /**< #pf_native_grid_rounding_t. */
2326
2327 uint32_t calculation; /**< #pf_native_calc_trigger_t. */
2328 uint32_t max_recalculations_per_point; /**< Fill-cascade bound; 0 is legal. */
2329
2330 uint32_t open_bar_view; /**< #pf_native_open_bar_view_t. */
2331
2332 uint32_t margin_sizing; /**< #pf_native_liquidation_sizing_t. */
2333 uint32_t margin_check; /**< #pf_native_liquidation_check_t. */
2337 double margin_initial_long; /**< 0 = maintenance-only side: no kernel
2338 opening requirement, host owns
2339 admission; legal only with that
2340 side's maintenance set. */
2341 double margin_initial_short; /**< 0 = maintenance-only; see above. */
2344 double margin_shortfall_multiple; /**< The C++ default is 1.0, not 0: a
2345 * PRESENT block has every field read,
2346 * so a zero-filled struct must still
2347 * write it — including under a sizing
2348 * policy that never scales. */
2350
2351 const pf_native_subscription_v1* subscriptions; /**< Borrowed for the call. */
2353 uint32_t reserved0;
2354
2355 /* ── The additive risk tail (L9). Read only when `present_mask` carries
2356 * PF_NATIVE_SPEC_EXT_RISK; a caller sending the base layout stops at
2357 * `reserved0` above. Each limit is opt-in through its own `has_` flag,
2358 * and a block whose four flags are all 0 is a declared-but-empty block —
2359 * which is exactly what the C++ `NativeRiskLimits{}` is. ── */
2360 uint32_t risk_has_max_drawdown; /**< 0/1. */
2361 uint32_t risk_max_drawdown_percent; /**< 0/1: the value is a percent of the
2362 * running equity peak, out of 100. */
2363 double risk_max_drawdown; /**< Threshold; account currency unless percent. */
2364 uint32_t risk_has_max_intraday_loss; /**< 0/1. */
2365 uint32_t risk_max_intraday_loss_percent; /**< 0/1: percent of the day's opening equity. */
2366 double risk_max_intraday_loss; /**< Threshold; account currency unless percent. */
2368 uint32_t risk_max_consecutive_loss_days; /**< Days, when the flag is 1. */
2369 uint32_t risk_has_max_fills_per_day; /**< 0/1. */
2370 uint32_t risk_max_fills_per_day; /**< Applied fills, when the flag is 1. */
2371 uint32_t risk_day_basis; /**< #pf_native_risk_day_t. */
2372 uint32_t risk_action; /**< #pf_native_risk_action_t. */
2373
2374 /* ── The additive intrabar / policy tail (N8). Read only when
2375 * `struct_size` is the current sizeof; a caller sending either earlier
2376 * layout stops at `risk_action` above and keeps every kernel default.
2377 * The two blocks below have mask bits of their own; the four margin
2378 * fields at the end extend the EXISTING PF_NATIVE_SPEC_EXT_MARGIN block
2379 * and are read only when that bit is set AND this tail is present. ── */
2380 uint32_t intrabar_kind; /**< #pf_native_intrabar_kind_t. */
2381 int32_t intrabar_samples; /**< Samples per script bar; LOWER_TF and SYNTHESIZED. */
2382 uint32_t intrabar_distribution; /**< #pf_magnifier_distribution_t. */
2383 uint32_t intrabar_volume_weighted; /**< 0/1. */
2386 uint32_t intrabar_sample_eligibility; /**< #pf_native_sample_eligibility_t, LOWER_TF only. */
2387 int32_t intrabar_n; /**< Length of `intrabar_bars`; LOWER_TF only. */
2388 const char* intrabar_tf; /**< The finer timeframe; LOWER_TF only, non-NULL. */
2389 const pf_bar_t* intrabar_bars; /**< The finer feed; borrowed for the call, copied. */
2390
2391 uint32_t slot_label_policy; /**< #pf_native_slot_label_t. FEED_TOLERANT keeps
2392 * the caller's own labels, and a
2393 * #PF_NATIVE_INTRABAR_LOWER_TF path then
2394 * delivers no sub-bar: its bars are not
2395 * keyed to canonical input slots. */
2396 uint32_t feed_tolerance; /**< #pf_native_feed_tolerance_t bits. */
2397 uint32_t path_order; /**< #pf_native_path_order_t. */
2398 uint32_t abort_reporting; /**< #pf_native_abort_reporting_t. */
2399
2400 uint32_t margin_equity_basis; /**< #pf_native_margin_equity_basis_t. */
2401 uint32_t margin_level_base; /**< #pf_native_margin_level_base_t. */
2402 const char* margin_liquidation_label; /**< Ticket of a kernel liquidation; NULL is "". */
2403 const char* margin_liquidation_comment; /**< Comment of the same; NULL is "". */
2404
2405 /* ── The additive auxiliary-feed tail. Read only when `present_mask`
2406 * carries PF_NATIVE_SPEC_EXT_AUXILIARY_FEED; a caller sending an earlier
2407 * layout stops at `margin_liquidation_comment`, `risk_action` or
2408 * `reserved0` above. The feed is the
2409 * run's own symbol at a timeframe strictly finer than the input, routed
2410 * by time into the series that name it (`NativeAuxiliaryFeed`). ── */
2411 const char* auxiliary_tf; /**< Non-NULL feed timeframe literal. */
2412 const pf_bar_t* auxiliary_bars; /**< Strictly increasing bars; copied. May be
2413 * NULL when `auxiliary_n` is 0. */
2414 int32_t auxiliary_n; /**< Length of `auxiliary_bars`. */
2415 uint32_t reserved1; /**< Must be 0. */
2416 /** Optional, borrowed for the call: `subscriptions_n` entries of
2417 * #pf_native_series_source_t, one per row of `subscriptions`. NULL means
2418 * every series is built from the input. Meaningful only together with
2419 * PF_NATIVE_SPEC_EXT_SUBSCRIPTIONS. */
2420 const uint32_t* subscription_sources;
2421
2422 /* ── The additive event-retention tail (V19-B). Read only when
2423 * `present_mask` carries PF_NATIVE_SPEC_EXT_EVENT_RETENTION; a caller
2424 * sending an earlier layout stops at `subscription_sources` or above and
2425 * runs under PF_NATIVE_EVENT_RETENTION_FULL. ── */
2426 uint32_t event_retention; /**< #pf_native_event_retention_t. */
2427 uint32_t reserved2; /**< Must be 0. */
2428
2429 /* ── The additive quantity-tolerance tail (K-ULP4). Read only when
2430 * `present_mask` carries PF_NATIVE_SPEC_EXT_QUANTITY_TOLERANCE; a caller
2431 * sending an earlier layout stops at `reserved2` or above and keeps the
2432 * exact settlement, in which a quantity it cannot book exactly is that
2433 * request's #PF_NATIVE_MATCH_REJECT_UNREPRESENTABLE_QUANTITY. ── */
2434 double quantity_tolerance; /**< Units, finite and positive:
2435 * `NativeRunSpec::quantity_tolerance`, two
2436 * quantities within it of each other are
2437 * one quantity to the settlement. */
2439
2440/** Byte length of #pf_native_run_spec_ext_v1 as the L13 lane first published
2441 * it, before the `risk_*` tail was appended. It is the offset of the first
2442 * appended field, so it stays correct on every target this header builds for
2443 * — it is not a literal. The runtime accepts this length as well as the
2444 * current `sizeof`, which is what makes the tail additive rather than a
2445 * layout break. */
2446#define PF_NATIVE_RUN_SPEC_EXT_V1_BASE_SIZE \
2447 ((uint32_t)offsetof(pf_native_run_spec_ext_v1, risk_has_max_drawdown))
2448
2449/** Byte length of #pf_native_run_spec_ext_v1 with L9's risk tail but without
2450 * N8's intrabar / policy tail — the second of its six published layouts. */
2451#define PF_NATIVE_RUN_SPEC_EXT_V1_RISK_SIZE \
2452 ((uint32_t)offsetof(pf_native_run_spec_ext_v1, intrabar_kind))
2453
2454/** Byte length of #pf_native_run_spec_ext_v1 with N8's intrabar / policy tail
2455 * but before the `auxiliary_*` tail was appended — the third of its six
2456 * published layouts. It is the offset of the first auxiliary field, for the
2457 * same reason #PF_NATIVE_RUN_SPEC_EXT_V1_BASE_SIZE is an offset. */
2458#define PF_NATIVE_RUN_SPEC_EXT_V1_POLICY_SIZE \
2459 ((uint32_t)offsetof(pf_native_run_spec_ext_v1, auxiliary_tf))
2460
2461/** Byte length of #pf_native_run_spec_ext_v1 with the `auxiliary_*` tail but
2462 * before the `event_retention` tail was appended — the fourth of its six
2463 * published layouts, an offset for the same reason
2464 * #PF_NATIVE_RUN_SPEC_EXT_V1_BASE_SIZE is. */
2465#define PF_NATIVE_RUN_SPEC_EXT_V1_AUXILIARY_SIZE \
2466 ((uint32_t)offsetof(pf_native_run_spec_ext_v1, event_retention))
2467
2468/** Byte length of #pf_native_run_spec_ext_v1 with the `event_retention` tail
2469 * but before the `quantity_tolerance` tail was appended — the fifth of its
2470 * six published layouts, an offset for the same reason
2471 * #PF_NATIVE_RUN_SPEC_EXT_V1_BASE_SIZE is. */
2472#define PF_NATIVE_RUN_SPEC_EXT_V1_RETENTION_SIZE \
2473 ((uint32_t)offsetof(pf_native_run_spec_ext_v1, quantity_tolerance))
2474
2475/** The C host's strategy logic.
2476 *
2477 * Every entry may be NULL, which is exactly the C++ default: the kernel does
2478 * nothing for that hook. `user` is handed back unchanged to every callback.
2479 * A callback must never let an exception, a longjmp or any other non-local
2480 * exit escape.
2481 *
2482 * There are two classes of entry, and they read their return value
2483 * differently. An OBSERVATION callback — everything down to and including
2484 * `on_sub_bar` — returns 0 to continue; any other value ends the run Failed
2485 * with PF_NATIVE_FAILURE_CALLBACK. An ANSWERING callback — every hook from
2486 * `on_margin_requirement` on — returns a #pf_native_answer_t selecting
2487 * WHOSE answer the kernel uses; every value is in contract, so an answering
2488 * hook can never fail the run. That split is deliberate: the answering hooks
2489 * are consulted from kernel paths that are not inside the callback guard, so
2490 * a failure raised there could not be latched without unwinding through
2491 * them. A host that must abort does it from an observation callback.
2492 *
2493 * Commands follow the C++ host's callback guard: they are legal in every
2494 * callback while the kernel is Running, including `on_timeframe_bar` and
2495 * `on_margin_call`. The kernel may still reject a particular request or
2496 * current-execution action for its own reason. The answering hooks must
2497 * only answer their question; they run on paths without the callback guard.
2498 * #strategy_native_declare_opened_lot_entry_bar_mask_v1 is legal inside
2499 * `on_applied` alone.
2500 *
2501 * `on_bar` is also the recalculation hook: with a calculation trigger above
2502 * #PF_NATIVE_CALC_TRIGGER_BAR_CLOSE the kernel calls it again at each fill
2503 * cursor or modeled point, which is exactly what the C++
2504 * `on_native_recalculate` default does. */
2506 uint32_t struct_size; /**< sizeof(pf_native_callbacks_v1). */
2507 uint32_t version; /**< PF_NATIVE_API_VERSION. */
2508 void* user; /**< Opaque; handed back unchanged. */
2509 int (*on_run_begin)(void* user);
2510 int (*on_input)(void* user, const pf_bar_t* bar, int32_t input_index,
2511 int32_t completes_script_interval);
2512 int (*on_bar_open)(void* user, const pf_bar_t* bar, const pf_native_decision_v1* at);
2513 int (*on_bar)(void* user, const pf_bar_t* bar, const pf_native_decision_v1* at);
2514 int (*on_tick)(void* user, const pf_bar_t* bar, const pf_native_decision_v1* at);
2515 int (*on_applied)(void* user, const pf_native_applied_v1* applied,
2516 const pf_native_decision_v1* at);
2517 /** One completed bucket of a declared series. `completion` is a
2518 * #pf_native_completion_kind_t: CONFIRMED when the bucket's own last
2519 * contributing bar closed it, LAZY_COMPLETE when the next period's first
2520 * input did. */
2521 int (*on_timeframe_bar)(void* user, const pf_bar_t* bar, uint32_t subscription,
2522 uint32_t completion, int64_t delivered_at_ms);
2523 int (*on_margin_call)(void* user, const pf_native_event_v1* margin_call);
2524
2525 /* ── The additive hook tail. Read only when `struct_size` is the current
2526 * sizeof; a caller sending the base layout stops at `on_margin_call`
2527 * above and gets exactly the kernel's own defaults for all six, which is
2528 * what every host compiled before this tail already had. ── */
2529 /** EVERY calculation of the run, including the script bar's own close —
2530 * `on_native_recalculate`. `reason` is a #pf_native_calc_reason_t and
2531 * `cause` is the applied execution of an ORDER_FILL recalculation, valid
2532 * only for that call and NULL otherwise. `bar` is the COMPLETE script
2533 * bar even mid-path; #strategy_native_partial_bar_v1 is the
2534 * lookahead-free bar so far. Commands are legal here.
2535 *
2536 * Installing it REPLACES `on_bar` for every calculation, exactly as
2537 * overriding `on_native_recalculate` replaces the C++ default forwarding:
2538 * a host that wants both calls `on_bar` itself from here. Leaving it
2539 * NULL keeps the established contract, where the kernel forwards every
2540 * calculation to `on_bar`. Observation callback: non-zero ends the run. */
2541 int (*on_recalculate)(void* user, const pf_bar_t* bar, const pf_native_decision_v1* at,
2542 uint32_t reason, const pf_native_applied_v1* cause);
2543
2544 /** One completed lower-timeframe sub-bar of a run that retains a lower
2545 * feed — `on_native_sub_bar`. Delivered
2546 * after that sub-bar's whole matching path and before the next one's;
2547 * never called for a run with no retained lower feed. The decision point
2548 * is the sub-bar's last modeled point, so commands and
2549 * #strategy_native_execute_current_v1 are legal.
2550 * Observation callback: non-zero ends the run. */
2551 int (*on_sub_bar)(void* user, const pf_bar_t* sub, const pf_native_decision_v1* at);
2552
2553 /** The two numbers one check point is about to compare —
2554 * `resolve_margin_requirement`. ANSWERING callback: return
2555 * #PF_NATIVE_ANSWER_DEFAULT to keep the kernel's own, any other value to
2556 * use @p out. The kernel keeps the whole mechanism — the level solve,
2557 * the check points, its own request, the receipt, `on_margin_call`; this
2558 * supplies only the money rule brokers legitimately differ on. */
2561
2562 /** Whether this kernel check point is one the host's broker model shares
2563 * — `margin_check_allowed`. ANSWERING callback: return
2564 * #PF_NATIVE_ANSWER_DEFAULT to admit the point (the kernel's own
2565 * answer), any other value to use @p allowed (0 suppresses it). A
2566 * suppressed point is not evaluated, re-armed or withdrawn: the margin
2567 * state is left exactly as the last admitted point left it. */
2568 int (*on_margin_check)(void* user, const pf_native_margin_view_v1* at, int32_t* allowed);
2569
2570 /** The size of a kernel-issued liquidation, before it rests —
2571 * `resolve_margin_call_units`. ANSWERING callback: return
2572 * #PF_NATIVE_ANSWER_DEFAULT to keep the run spec's sizing policy, any
2573 * other value to use @p units, which the kernel clamps into (0, held].
2574 * It has the last word on units, including over a forced breach. */
2576 double* units);
2577
2578 /** The favorable and adverse magnitudes of one closing lot —
2579 * `closed_lot_excursion`. Installing it at all is
2580 * `owns_lot_excursions() == true`: the consumer then stops sampling
2581 * excursion at matched trigger prices for the WHOLE run and every
2582 * closing row takes both magnitudes from here. ANSWERING callback:
2583 * return #PF_NATIVE_ANSWER_DEFAULT to answer the kernel's own zero
2584 * magnitudes — which, ownership having been declared, is what a declined
2585 * lot gets — or any other value to use @p favorable and @p adverse. */
2587 double* favorable, double* adverse);
2588
2589 /** How many units a host-sized CLOSE takes — the units half of
2590 * `resolve_execution_terms` (the price half is `on_execution_terms`).
2591 * Consulted for #PF_NATIVE_INTENT_HOST_SIZED candidates and nothing
2592 * else; without it a cohort close resolves no quantity and stands
2593 * deferred, which is exactly what the C++ default does. ANSWERING
2594 * callback: return #PF_NATIVE_ANSWER_DEFAULT to keep that default, any
2595 * other value to close @p units of
2596 * #pf_native_close_view_v1::scope_exposure_units. */
2597 int (*on_close_units)(void* user, const pf_native_close_view_v1* view, double* units);
2598 /* ── The additive policy-hook tail (R5 lane F4). Read only when
2599 * `struct_size` is the policy layout or the current sizeof; a caller
2600 * sending an earlier layout stops at `on_close_units` (or at
2601 * `on_margin_call`) and gets the kernel's own answers for all four,
2602 * exactly the C++ defaults. All four are ANSWERING callbacks. The
2603 * reserved marker after this tail publishes the current layout whose
2604 * lot-excursion facts include their fee tail. ── */
2605 /** The price half of `resolve_execution_terms`, consulted at EVERY
2606 * matching candidate once installed. ANSWERING callback: return
2607 * #PF_NATIVE_ANSWER_DEFAULT to keep the kernel's terms, any other value
2608 * to settle at @p out's price, shape and grid policy. @p out arrives
2609 * holding the kernel's own. A shape or grid word outside its enumeration
2610 * is the kernel's #PF_NATIVE_MATCH_REJECT_INVALID_TERMS, as is a shape
2611 * other than TRANSACT on anything but an opening. The units half stays
2612 * `on_close_units`'. */
2614 pf_native_terms_v1* out);
2615
2616 /** The last gate before one execution's physical effect —
2617 * `validate_execution_precommit`. ANSWERING callback: return
2618 * #PF_NATIVE_ANSWER_DEFAULT to admit it on the kernel's own path, any
2619 * other value to use @p verdict (#pf_native_precommit_verdict_t). A
2620 * verdict word outside the enumeration refuses, the conservative
2621 * reading of an answer the kernel cannot act on. */
2623 uint32_t* verdict);
2624
2625 /** Where an anchored leg is armed — `resolve_anchored_level`. ANSWERING
2626 * callback: return #PF_NATIVE_ANSWER_DEFAULT to install the kernel's
2627 * level, any other value to install @p level; the kernel's
2628 * representability check still applies. */
2630 double* level);
2631
2632 /** The host's own durable state, folded into the broker-state hash —
2633 * `hash_host_extension`. Called once per hash (every per-bar row, the
2634 * final and the stream hash) after the kernel's own bytes. ANSWERING
2635 * callback: return #PF_NATIVE_ANSWER_DEFAULT to fold nothing more, any
2636 * other value to fold a domain tag and @p digest, a 64-bit digest of
2637 * whatever the host's next decision depends on. It must be a pure
2638 * function of that state. The continuation hash is the kernel's alone
2639 * and does not move. */
2640 int (*on_hash_extension)(void* user, uint64_t* digest);
2641
2642 /* The trailing layout marker lets the runtime distinguish the policy-hook
2643 * layout published by F4 from this layout, whose lot-excursion facts carry
2644 * the additive entry_commission tail. It is reserved and must be zero;
2645 * host creation refuses a nonzero value. */
2646 uint64_t reserved1;
2648
2649/** Byte length of #pf_native_callbacks_v1 as the L13 lane first published it,
2650 * before the six-hook tail was appended. It is the offset of the first
2651 * appended field, so it stays correct on every target — not a literal.
2652 * #strategy_native_host_create_v1 accepts it, #PF_NATIVE_CALLBACKS_V1_HOOKS_SIZE,
2653 * #PF_NATIVE_CALLBACKS_V1_POLICY_SIZE and the current `sizeof`: that is what
2654 * makes each tail additive rather than a layout break. */
2655#define PF_NATIVE_CALLBACKS_V1_BASE_SIZE \
2656 ((uint32_t)offsetof(pf_native_callbacks_v1, on_recalculate))
2657
2658/** Byte length of #pf_native_callbacks_v1 with the six-hook tail but without
2659 * the policy-hook tail — the second of its four published layouts, and the
2660 * `sizeof` every caller compiled before that tail existed sends. */
2661#define PF_NATIVE_CALLBACKS_V1_HOOKS_SIZE \
2662 ((uint32_t)offsetof(pf_native_callbacks_v1, on_execution_terms))
2663
2664/** Byte length of the F4 policy-hook layout, before the reserved marker that
2665 * publishes the current lot-excursion facts layout. */
2666#define PF_NATIVE_CALLBACKS_V1_POLICY_SIZE \
2667 ((uint32_t)offsetof(pf_native_callbacks_v1, reserved1))
2668
2669/** @} */ /* end of pf_native_c_types */
2670
2671/** @defgroup pf_native_c_api Entry points
2672 * @{ */
2673
2674/** This header's layout version. Mirrors #strategy_stream_api_version. */
2676
2677/** Allocate a native host that forwards every kernel callback to @p callbacks.
2678 *
2679 * The table is copied; the caller's struct need not outlive the call. The
2680 * returned handle is a `pf_strategy_t` the existing runtime symbols accept:
2681 * #strategy_configure_native_v1, the whole `strategy_stream_*` family and the
2682 * read-only accessors all take it unchanged.
2683 *
2684 * @return The handle, or NULL for a NULL/mis-sized table, a nonzero
2685 * `reserved1` in the current layout, or an allocation failure. Release it
2686 * with #strategy_native_host_free — never
2687 * #strategy_free, which does not own this allocation. */
2689
2690/** Release a handle from #strategy_native_host_create_v1. NULL is a no-op;
2691 * a handle this API did not create is refused without freeing anything. */
2693
2694/** Run @p n bars as one batch and fill @p out.
2695 *
2696 * The specification must already be Ready (#strategy_configure_native_v1).
2697 * @p out may be NULL to skip reporting; otherwise its arrays are
2698 * heap-allocated and released by #strategy_native_report_free_v1.
2699 *
2700 * A report belongs to THIS attempt or is empty, and a refused attempt never
2701 * answers PF_NATIVE_OK. A call the host refuses without beginning (a handle
2702 * that is not Ready: Unconfigured, already Completed or Failed; a refused bar
2703 * array or run option) leaves the lifecycle, the run identity and the rows
2704 * the handle retains exactly as they were, answers PF_NATIVE_E_RUN_FAILED and
2705 * leaves @p out as the empty report (every array NULL, every count 0),
2706 * overwritten and never freed, so it is safe whether or not the caller
2707 * initialised it and #strategy_native_report_free_v1 on it is a no-op; the
2708 * reason is in #strategy_get_last_error, #strategy_get_last_error_code and
2709 * #strategy_last_run_status (1). A run that began and failed also answers PF_NATIVE_E_RUN_FAILED
2710 * and leaves the handle Failed. It publishes partial rows unless `report_sink_failed` is latched:
2711 * every later read gives the empty report (every array NULL, every count 0), even when the sink
2712 * failed at finish time after run success. Status, code, arguments and message stay in the
2713 * run-failure latch. A Completed handle runs again after #strategy_configure_native_v1
2714 * (or #strategy_configure_native_ext_result_v1) succeeds. Pre-engine PF_NATIVE_E_HANDLE
2715 * and PF_NATIVE_E_ARGUMENT refusals leave @p out untouched. Every run entrypoint uses the
2716 * engine's report reader: a batch refused over a live stream reads empty, and
2717 * #strategy_stream_fill_report keeps the stream's rows, subject to the same sink-failure gate.
2718 * @return PF_NATIVE_OK when this call's run reached Completed; PF_NATIVE_E_RUN_FAILED otherwise
2719 * (read #strategy_native_state_v1 for a Failed code, #strategy_get_last_error for a refusal). */
2721 pf_report_t* out);
2722
2723/** Free the heap arrays inside a report filled by #strategy_native_run_v1.
2724 *
2725 * The unprefixed #report_free is a per-strategy export the transpiler emits,
2726 * so it is absent from a runtime a C host links on its own: this is that
2727 * host's release path. Idempotent; NULL is a no-op. The `pf_report_t` struct
2728 * itself stays caller-owned. */
2730
2731/** Submit @p request.
2732 *
2733 * Legal from inside a native callback; the request joins the working book
2734 * and is matched by the consumer from the next execution point on. The
2735 * handle it answers with is the request's identity for the rest of the run:
2736 * replace, cancel and every event carry it.
2737 *
2738 * @param s The host this run is driving, from #strategy_create.
2739 * @param request Borrowed for the call only; the kernel copies what it
2740 * keeps.
2741 * @param incarnation Optional; receives the accepted request's handle.
2742 * @param reject Optional; receives a #pf_native_reject_reason_t on
2743 * rejection.
2744 * @return PF_NATIVE_OK when accepted, PF_NATIVE_E_REJECTED when the kernel
2745 * rejected it, PF_NATIVE_E_STATE when commands are not legal here.
2746 *
2747 * Exercised by `tests/test_native_c_api.c`. */
2749 uint64_t* incarnation, uint32_t* reject);
2750
2751/** Replace the live request @p incarnation with @p request.
2752 *
2753 * Amendment, not cancel-and-resubmit: the predecessor leaves the book and
2754 * the successor takes its place in one step, and the REPLACED event names
2755 * both. A target that is no longer working is PF_NATIVE_E_NOT_WORKING.
2756 *
2757 * @param s The host this run is driving, from #strategy_create.
2758 * @param incarnation The live request to amend, as #strategy_native_submit_v1
2759 * handed it back.
2760 * @param request Borrowed for the call only.
2761 * @param successor Optional; receives the successor's handle.
2762 * @return PF_NATIVE_OK, PF_NATIVE_E_REJECTED, PF_NATIVE_E_NOT_WORKING,
2763 * PF_NATIVE_E_INVALID_TARGET, or PF_NATIVE_E_STATE.
2764 *
2765 * PF_NATIVE_E_REJECTED is where this signature stops: it has nowhere to put
2766 * the RequestRejectReason that #strategy_native_submit_v1 writes to its
2767 * `reject`, so use #strategy_native_replace_ext_v1 when the reason matters.
2768 *
2769 * Exercised by `tests/test_native_c_api.c`. */
2771 const pf_native_request_v1* request,
2772 uint64_t* successor);
2773
2774/** Replace the live request @p incarnation, reporting a rejection's reason.
2775 *
2776 * The same call as #strategy_native_replace_v1 — same legality, same
2777 * amendment, same verdicts, same successor — with the `reject`
2778 * out-parameter #strategy_native_submit_v1 has always had. That asymmetry
2779 * was the whole gap: a C++ replace answers ReplaceResult::reason and the C
2780 * submit writes it out, while the C replace dropped it, so a C host learned
2781 * "rejected" and no more. (#strategy_native_cancel_v1 needs no such
2782 * spelling: its status IS its reason.)
2783 *
2784 * It is an additional symbol rather than a wider signature because this
2785 * header's STABILITY rule is that a signature never changes within a major
2786 * version — the same reason #strategy_configure_native_ext_v1 exists beside
2787 * #strategy_configure_native_v1. Use either; #strategy_native_replace_v1
2788 * stays exactly what it was and is this call with @p reject NULL.
2789 *
2790 * @param s The host this run is driving, from #strategy_create.
2791 * @param incarnation The live request to amend.
2792 * @param request Borrowed for the call only.
2793 * @param successor Optional; receives the successor's handle. Untouched
2794 * unless the replace is accepted.
2795 * @param reject Optional; receives a #pf_native_reject_reason_t, and only
2796 * on PF_NATIVE_E_REJECTED. Untouched otherwise — including
2797 * for NOT_WORKING and INVALID_TARGET, which are the
2798 * target's verdict and not the request's.
2799 * @return PF_NATIVE_OK, PF_NATIVE_E_REJECTED, PF_NATIVE_E_NOT_WORKING,
2800 * PF_NATIVE_E_INVALID_TARGET, or PF_NATIVE_E_STATE.
2801 *
2802 * Exercised by `tests/test_native_c_api.c`. */
2804 const pf_native_request_v1* request,
2805 uint64_t* successor, uint32_t* reject);
2806
2807/** Cancel one live request.
2808 * @return PF_NATIVE_OK, PF_NATIVE_E_NOT_WORKING, PF_NATIVE_E_INVALID_TARGET
2809 * or PF_NATIVE_E_STATE. */
2811
2812/** Cancel every live request, dependants included.
2813 * @return The number cancelled (>= 0), or PF_NATIVE_E_STATE. */
2815
2816/** Cancel exactly the live requests whose @p field equals @p text.
2817 *
2818 * The C spelling of `NativeStrategyHost::cancel_where`. With
2819 * #PF_NATIVE_FIELD_LABEL it is the one call that withdraws every live
2820 * request a host issued under one of its own order ids; with
2821 * #PF_NATIVE_FIELD_COMMENT it is the established comment predicate. A
2822 * dependant of a cancelled owner still leaves the book, but it is counted
2823 * only when its own field matched. Text that matches nothing is not a
2824 * command.
2825 *
2826 * @param s The host this run is driving, from #strategy_create.
2827 * @param text Borrowed for the call only; "" matches the requests that
2828 * carry no such text. NULL is PF_NATIVE_E_ARGUMENT, not "".
2829 * @param field #pf_native_request_field_t.
2830 * @return The number cancelled (>= 0), PF_NATIVE_E_TAG for a field outside
2831 * the enumeration, PF_NATIVE_E_ARGUMENT for a NULL @p text, or another
2832 * negative status.
2833 *
2834 * Exercised by `tests/test_native_c_api.c`. */
2836 uint32_t field);
2837
2838/** Execute one live request at the current execution point.
2839 *
2840 * Legal only inside a callback the kernel has opened an execution point for
2841 * (`on_bar`, `on_bar_open`, `on_tick`, `on_applied`, `on_recalculate`);
2842 * anywhere else the answer is PF_NATIVE_E_STATE. The request is filled at
2843 * this cursor rather than waiting for the consumer's own matching pass.
2844 *
2845 * @param s The host this run is driving, from #strategy_create.
2846 * @param incarnation The live request to execute, as
2847 * #strategy_native_submit_v1 handed it back. A handle
2848 * that is not in the working book is
2849 * PF_NATIVE_E_INVALID_TARGET.
2850 * @param price_rule #pf_native_price_rule_t.
2851 * @param refusal Optional; receives a #pf_native_refusal_t when the
2852 * return is PF_NATIVE_E_REFUSED.
2853 * @return A non-negative #pf_native_execute_outcome_t, or a negative status.
2854 *
2855 * Exercised by `tests/test_native_c_api.c`. */
2857 uint32_t price_rule, uint32_t* refusal);
2858
2859/** Read the physical position. Every output is optional.
2860 * @return PF_NATIVE_OK, or a negative status. */
2862 double* average_price, uint64_t* lots);
2863
2864/** Snapshot the live working book and return its length.
2865 *
2866 * The snapshot is retained on the handle: #strategy_native_working_get_v1
2867 * reads from it, so a row already copied out is not invalidated by a later
2868 * command. The next call to this function replaces the snapshot.
2869 * @return The row count (>= 0), or a negative status. */
2871
2872/** Copy row @p index of the most recent working snapshot into @p out.
2873 *
2874 * @p out is an in/out size prefix: set `out->struct_size` to
2875 * `sizeof(pf_native_working_v1)` before the call. Everything else is filled.
2876 * A caller built against an earlier layout sends
2877 * #PF_NATIVE_WORKING_V1_BASE_SIZE or #PF_NATIVE_WORKING_V1_ARM_SIZE and is
2878 * filled exactly that far.
2879 * @return PF_NATIVE_OK, PF_NATIVE_E_ARGUMENT for an out-of-range index,
2880 * PF_NATIVE_E_STRUCT for a mis-sized row, or another negative status. */
2883
2884/** Snapshot the open lots marked at @p mark and return their count.
2885 *
2886 * The C spelling of `NativeStrategyHost::native_open_lots(mark)` (R5 gap
2887 * lane N18). The snapshot is retained on the handle:
2888 * #strategy_native_open_lot_get_v1 reads from it, so a row already copied
2889 * out is not invalidated by a later command; the next call to this function
2890 * replaces it. Observation only — it moves no fill, no hash and no row — and
2891 * legal wherever #strategy_native_position_v1 is. A NaN @p mark keeps every
2892 * booking fact and leaves `unrealized_pnl` NaN.
2893 * @return The row count (>= 0), or a negative status. */
2895
2896/** Copy row @p index of the most recent open-lot snapshot into @p out.
2897 *
2898 * @p out is an in/out size prefix: set `out->struct_size` to
2899 * `sizeof(pf_native_open_lot_v1)` before the call. Everything else is filled.
2900 * @return PF_NATIVE_OK, PF_NATIVE_E_ARGUMENT for an out-of-range index,
2901 * PF_NATIVE_E_STRUCT for a mis-sized row, or another negative status. */
2904
2905/** Copy up to @p cap events with an ordinal strictly greater than
2906 * @p after_ordinal into @p out, in the kernel's own recording order.
2907 *
2908 * Ordinals are non-decreasing rather than strictly increasing: an applied
2909 * execution and the account observation it produced carry the same one. A
2910 * page therefore never ends in the middle of such a group (for @p cap >= 2),
2911 * so a poller advances by the last returned `ordinal` without losing or
2912 * repeating a row. The rows are what the run's event retention keeps
2913 * (#pf_native_event_retention_t): under FULL and COMMANDS the history is
2914 * append-only, so the same @p after_ordinal always yields the same rows;
2915 * under WINDOW a read answers what the window still holds, and one from
2916 * below its start (#strategy_native_event_window_v1) starts there.
2917 * @return The number written (>= 0), or a negative status. */
2918PF_API int strategy_native_events_v1(pf_strategy_t s, uint64_t after_ordinal,
2919 pf_native_event_v1* out, int cap);
2920
2921/** The host has read every event through @p through_ordinal —
2922 * `native_acknowledge_events()`.
2923 *
2924 * Under the Window event retention the kernel drops the acknowledged command
2925 * events at the next script-bar boundary and keeps every event above the
2926 * acknowledgement; the first call also marks the host as one that polls, so
2927 * a polling host calls it from `on_run_begin` (0 is legal). A later, smaller
2928 * acknowledgement never lowers an earlier one, one above the event high
2929 * water acknowledges the high water, and outside a running run the call
2930 * records nothing. The Full and Commands retentions keep the whole journal
2931 * whatever is acknowledged.
2932 * @return PF_NATIVE_OK, or a negative status for a bad handle. */
2934
2935/** The oldest ordinal a read can still return — `native_event_window_start()`
2936 * — written to @p out_first_ordinal: every command event at or above it is
2937 * retained, and #strategy_native_events_v1 with an `after_ordinal` below it
2938 * starts there. 1 while nothing was dropped.
2939 * @return PF_NATIVE_OK, PF_NATIVE_E_ARGUMENT for a NULL @p out_first_ordinal,
2940 * or another negative status. */
2941PF_API int strategy_native_event_window_v1(pf_strategy_t s, uint64_t* out_first_ordinal);
2942
2943/** Read the run's lifecycle and typed failure into @p out.
2944 *
2945 * @p out is an in/out size prefix: set `out->struct_size` to
2946 * `sizeof(pf_native_state_v1)` before the call. */
2948
2949/** Declare this run's higher-timeframe series from inside `on_run_begin` —
2950 * `declare_timeframe_subscriptions()`.
2951 *
2952 * The list REPLACES the `subscriptions` staged by
2953 * #strategy_configure_native_ext_v1; the kernel registers from the staged
2954 * spec after the callback returns, so the run's continuation identity folds
2955 * what actually ran. @p n may be 0 (with @p rows NULL), which declares no
2956 * series at all.
2957 * @return PF_NATIVE_OK when the list was staged. Each row is read first:
2958 * PF_NATIVE_E_STRUCT for its `struct_size`, PF_NATIVE_E_ARGUMENT for a NULL
2959 * `tf` or bad authoritative bars (and for a negative @p n or NULL @p rows),
2960 * PF_NATIVE_E_TAG for a `lookahead` / `gaps` word outside its enumeration;
2961 * then PF_NATIVE_E_STATE anywhere but inside `on_run_begin` and for a list this
2962 * run's input timeframe would refuse — the same validation
2963 * #strategy_configure_native_ext_v1 applies. A refusal stages nothing.
2964 * #strategy_native_declare_subscriptions_ext_v1 also names which validation
2965 * refused the list. */
2967 const pf_native_subscription_v1* rows,
2968 int n);
2969
2970/** The same declaration, answered by name — `declare_timeframe_subscriptions_result()`.
2971 *
2972 * The same call as #strategy_native_declare_subscriptions_v1 — same
2973 * legality, same staging, same statuses — with the refusal's words written
2974 * out, and with a series source per row, so a series declared here may be
2975 * built from the auxiliary feed #strategy_native_declare_auxiliary_feed_v1
2976 * staged. #strategy_native_declare_subscriptions_v1 stays exactly what it
2977 * was: this call with @p sources, @p error and @p field NULL.
2978 *
2979 * @param s The host this run is driving.
2980 * @param rows @p n rows, borrowed for the call; NULL when @p n is 0.
2981 * @param n Row count (0 declares no series at all).
2982 * @param sources Optional: @p n #pf_native_series_source_t words, one per
2983 * row. NULL builds every series from the input.
2984 * @param error Optional; receives a #pf_native_spec_error_t whenever the
2985 * kernel judged the call: #PF_NATIVE_SPEC_ERROR_NONE when
2986 * staged, #PF_NATIVE_SPEC_ERROR_WRONG_PHASE outside
2987 * `on_run_begin`, else the first error the list's
2988 * validation found — the validation
2989 * #strategy_configure_native_ext_v1 applies.
2990 * @param field Optional; receives the #pf_native_spec_field_t beside it.
2991 * @return PF_NATIVE_OK when the list was staged; PF_NATIVE_E_STATE for every
2992 * refusal the kernel names in @p error, in which case nothing is staged;
2993 * PF_NATIVE_E_ARGUMENT / E_STRUCT / E_TAG for a row the C layer refuses
2994 * before the kernel sees the list, leaving @p error and @p field untouched.
2995 *
2996 * Exercised by `tests/test_native_c_api.c`. */
2998 const pf_native_subscription_v1* rows,
2999 int n, const uint32_t* sources,
3000 uint32_t* error, uint32_t* field);
3001
3002/** Declare, replace or withdraw this run's auxiliary finer feed from inside
3003 * `on_run_begin` — `declare_auxiliary_feed_result()`.
3004 *
3005 * The feed REPLACES the one staged by #strategy_configure_native_ext_v1's
3006 * auxiliary tail, and the kernel registers from the staged spec after the
3007 * callback returns. It is judged together with the series staged at that
3008 * moment, so a host that declares both here declares the feed first and its
3009 * feed-built series second (#strategy_native_declare_subscriptions_ext_v1).
3010 *
3011 * @param s The host this run is driving.
3012 * @param tf The feed's timeframe literal, or NULL to withdraw the staged
3013 * feed (with @p n 0 and @p bars NULL).
3014 * @param bars @p n strictly increasing bars, copied; NULL when @p n is 0.
3015 * @param n Bar count.
3016 * @param error Optional; receives a #pf_native_spec_error_t whenever the
3017 * kernel judged the call (#PF_NATIVE_SPEC_ERROR_NONE when
3018 * staged, #PF_NATIVE_SPEC_ERROR_WRONG_PHASE outside
3019 * `on_run_begin`).
3020 * @param field Optional; receives the #pf_native_spec_field_t beside it.
3021 * @return PF_NATIVE_OK when the feed was staged or withdrawn;
3022 * PF_NATIVE_E_STATE for every refusal the kernel names in @p error — a feed
3023 * the input timeframe refuses, or a withdrawal that would strand a staged
3024 * feed-built series — changing nothing; PF_NATIVE_E_ARGUMENT for a negative
3025 * @p n, NULL @p bars with @p n > 0, or a withdrawal carrying bars, leaving
3026 * @p error and @p field untouched.
3027 *
3028 * Exercised by `tests/test_native_c_api.c`. */
3030 const pf_bar_t* bars, int32_t n,
3031 uint32_t* error, uint32_t* field);
3032
3033/** The bar so far — `current_partial_bar()`.
3034 *
3035 * Open of the script bar's first modeled point, running high/low, close at
3036 * the last path point the walk has consumed: the cursor itself at a discrete
3037 * point (the open of the bar or of a sub-bar, a distribution sample, an
3038 * observed print), and the segment's origin at a fill inside a segment,
3039 * whose `on_applied` and ORDER_FILL recalculation read the bar before the
3040 * fill price is folded in. Volume is the activity actually consumed so far.
3041 * Valid in the bar-open, applied, tick, sub-bar and recalculation callbacks.
3042 * @return PF_NATIVE_OK when @p out was written, #PF_NATIVE_ABSENT outside a
3043 * path walk — including in the bar's own close calculation, where the
3044 * callback already holds the complete bar — leaving @p out untouched. */
3046
3047/** How many recalculations the kernel drove, and how many it suppressed
3048 * because a point had spent its `max_recalculations_per_point` budget —
3049 * `native_recalculation_count()` / `native_recalculations_skipped()`.
3050 * Either pointer may be NULL. Observation only. */
3052 uint64_t* skipped);
3053
3054/** The trail projection of one live request — `trail_state()`.
3055 *
3056 * @p incarnation names a request this run issued.
3057 * @return PF_NATIVE_OK when @p out was written, #PF_NATIVE_ABSENT when the
3058 * handle is not a live Trail request (unknown, finished, or another
3059 * trigger), leaving @p out untouched. */
3062
3063/** The latest completed bucket of a declared subscription —
3064 * `native_series_bar()`. @p subscription is the row's index in the
3065 * `subscriptions` array #strategy_configure_native_ext_v1 was given (or the
3066 * list #strategy_native_declare_subscriptions_v1 installed). Legal inside
3067 * every callback, `on_timeframe_bar` included.
3068 * @return PF_NATIVE_OK when @p out was written, #PF_NATIVE_ABSENT before the
3069 * series' first delivery, for an unknown index, and on every input bar a
3070 * #PF_NATIVE_GAPS_CLEAR series publishes nothing on — the empty that stands
3071 * for na. */
3073 pf_bar_t* out);
3074
3075/** Read the delivered bucket's own calendar interval from inside
3076 * #pf_native_callbacks_v1::on_timeframe_bar. The returned fields are exactly
3077 * the C++ NativeTimeframeBarContext::interval; no interval is inferred from the
3078 * delivered bar or its delivery timestamp. @p out is size-prefixed.
3079 * @return PF_NATIVE_OK inside that callback, PF_NATIVE_E_STATE elsewhere,
3080 * or PF_NATIVE_E_STRUCT / PF_NATIVE_E_ARGUMENT for an invalid output. */
3083
3084/** The account's marked equity at @p mark — `native_marked_equity()`. */
3086
3087/** The price at which the marked equity falls below the run's maintenance
3088 * requirement for the live position's side — `native_liquidation_price()`.
3089 * @return PF_NATIVE_OK when @p out was written, #PF_NATIVE_ABSENT when the
3090 * run declares no margin model, the side has no maintenance fraction, the
3091 * book is flat, or no finite price solves the breach (a long at full
3092 * maintenance); @p out is then written NaN. */
3094
3095/** The units a kernel-sized request resolves to under this run's spec, as a
3096 * pure query — `native_sized_units()`.
3097 *
3098 * @p sized is a #PF_NATIVE_INTENT_SIZED request, read for its sizing block
3099 * alone (side, basis and its value, reserve, grid policy): units =
3100 * cash / (price * point_value * fx), the cash being the basis value or the
3101 * fraction of @p equity, net of the percent fee reserve when the request
3102 * asks for it, then the grid policy. It is the very function the kernel
3103 * sizes with, at acceptance and at the candidate, so a host that gates a
3104 * command on its quantity reads the number here before it submits.
3105 * Observation only: it moves and freezes nothing.
3106 *
3107 * @param s The host whose run spec sizes the request.
3108 * @param sized The #PF_NATIVE_INTENT_SIZED request to size, borrowed for
3109 * the call.
3110 * @param price The sizing price.
3111 * @param equity The marked equity an EQUITY_FRACTION basis is a share of.
3112 * @param fx The account rate the conversion divides by.
3113 * @param units Receives the units; NaN with #PF_NATIVE_ABSENT.
3114 * @return PF_NATIVE_OK, #PF_NATIVE_ABSENT when the run is not configured or
3115 * the basis is unresolvable there (non-positive money or denominator, a
3116 * below-one-step quotient under a snapping grid), PF_NATIVE_E_ARGUMENT for a
3117 * request that is not SIZED or a NULL pointer, or the request's own
3118 * PF_NATIVE_E_STRUCT / PF_NATIVE_E_TAG.
3119 *
3120 * Exercised by `tests/test_native_c_api.c`. */
3122 double price, double equity, double fx,
3123 double* units);
3124
3125/** The run's generic risk ledger — `native_risk_state()`. Every field is its
3126 * zero for a run that declares no risk block. */
3128
3129/** The whole economics of one margin call — what a C++ host's
3130 * `on_native_margin_call` receives as `MarginCallEvent`.
3131 *
3132 * @p ordinal is the call's event ordinal: the `ordinal` of the
3133 * #pf_native_event_v1 #pf_native_callbacks_v1::on_margin_call is handed, or
3134 * of a #PF_NATIVE_EVENT_MARGIN_CALL row #strategy_native_events_v1 returns.
3135 * Legal inside `on_margin_call` and anywhere the event history is;
3136 * observation only.
3137 *
3138 * @p out is an in/out size prefix: set `out->struct_size` to
3139 * `sizeof(pf_native_margin_call_v1)` before the call.
3140 * @return PF_NATIVE_OK when @p out was written, #PF_NATIVE_ABSENT when no
3141 * margin call of this run has that ordinal (@p out untouched),
3142 * PF_NATIVE_E_STRUCT for a mis-sized row, or another negative status.
3143 *
3144 * Exercised by the fx-roll scenario of `tests/test_native_c_api.c`. */
3147
3148/** The run's continuation identity — `native_continuation_hash()`. Two runs
3149 * driven the same way that folded the same declarations and the same inputs
3150 * answer the same value; a batch and a stream over identical bars booking
3151 * identical trades do NOT, because the driving mode is part of a
3152 * continuation. It is the C spelling of the hash a stream resumes against,
3153 * and the same reason the per-bar broker-state hash is per driving mode
3154 * (`pineforge.h`, `strategy_set_broker_state_hash_recording`). */
3156
3157/** Open a cohort roster for PF_NATIVE_OWNER_BIND_COHORT. */
3159
3160/** Enrol a live request into a cohort roster. */
3162 uint64_t incarnation);
3163
3164/** Remove a request from a cohort roster. */
3166 uint64_t incarnation);
3167
3168/** Configure a native run from the v1 specification plus the extension.
3169 *
3170 * Use this INSTEAD of #strategy_configure_native_v1, not after it: the
3171 * kernel configures a host exactly once and refuses (and fails) a second
3172 * attempt, so this call takes both halves and applies them together.
3173 * @p base is the same #pf_native_run_spec_v1 the other entry point takes.
3174 *
3175 * Refuses without mutation — the handle stays usable — for an
3176 * already-configured handle, a mis-sized struct, an unknown enumerator, or a
3177 * specification the kernel's own validation rejects, which answers
3178 * PF_NATIVE_E_ARGUMENT: the call validates the whole specification before it
3179 * configures, so a rejected one leaves the handle Unconfigured.
3180 * @return PF_NATIVE_OK, or a negative status. */
3182 const pf_native_run_spec_v1* base,
3183 const pf_native_run_spec_ext_v1* ext);
3184
3185/** The typed spelling of #strategy_configure_native_ext_v1: the same inputs,
3186 * plus @p error / @p field, which receive the kernel's
3187 * #pf_native_spec_error_t / #pf_native_spec_field_t pair once the call's
3188 * phase or its specification has been judged.
3189 *
3190 * Whether either out-parameter is non-NULL decides which handles it accepts:
3191 * - both NULL: it is exactly #strategy_configure_native_ext_v1. Only an
3192 * Unconfigured handle is configured; every other phase answers
3193 * #PF_NATIVE_E_STATE without mutation.
3194 * - either non-NULL: it also configures the next run of a Completed handle,
3195 * or of one Failed by a cooperative abort (#PF_NATIVE_FAILURE_ABORTED), as
3196 * #strategy_configure_native_v1 reuses a host. A Ready or Running handle,
3197 * and a handle Failed by anything but an abort, answer #PF_NATIVE_E_STATE
3198 * with #PF_NATIVE_SPEC_ERROR_WRONG_PHASE / #PF_NATIVE_SPEC_FIELD_NONE,
3199 * without mutation. A call from a C hook frame is refused the same way,
3200 * including `on_hash_extension` during a hash read of a Completed host.
3201 *
3202 * On an accepted handle the specification is validated before the kernel
3203 * sees it: a refused value answers #PF_NATIVE_E_ARGUMENT with its pair and
3204 * leaves the handle as it was. A reuse whose session key is not the one the
3205 * handle's runs are bound to, or whose run number does not exceed the highest
3206 * one the handle has run, answers #PF_NATIVE_E_ARGUMENT with
3207 * #PF_NATIVE_SPEC_ERROR_SESSION_KEY_CHANGED_ON_REUSE /
3208 * #PF_NATIVE_SPEC_FIELD_SESSION_KEY or
3209 * #PF_NATIVE_SPEC_ERROR_RUN_NUMBER_NOT_ABOVE_CONSUMED_HIGH_WATER /
3210 * #PF_NATIVE_SPEC_FIELD_RUN_NUMBER. That refusal latches a Completed handle
3211 * Failed with #PF_NATIVE_FAILURE_CONTRACT, which no configure call accepts
3212 * again; an aborted handle keeps its abort and may be configured again.
3213 * #PF_NATIVE_OK writes NONE / NONE and leaves the handle Ready.
3214 *
3215 * C-layer shape refusals leave both out-parameters untouched: a NULL handle
3216 * (#PF_NATIVE_E_HANDLE); NULL @p base, @p ext, or required string member;
3217 * a negative auxiliary count or a NULL subscription timeframe
3218 * (#PF_NATIVE_E_ARGUMENT); a mis-sized struct (#PF_NATIVE_E_STRUCT); or an
3219 * unknown enumerator on an accepted handle (#PF_NATIVE_E_TAG).
3220 *
3221 * Exercised by `tests/test_native_c_api.c`. */
3223 pf_strategy_t s, const pf_native_run_spec_v1* base,
3224 const pf_native_run_spec_ext_v1* ext, uint32_t* error, uint32_t* field);
3225
3226/** Append later bars to the run's declared auxiliary feed on a realtime
3227 * stream (`NativeStrategyHost::append_auxiliary_bars`).
3228 *
3229 * Legal between stream inputs, after #strategy_stream_begin, on a host whose
3230 * specification declared PF_NATIVE_SPEC_EXT_AUXILIARY_FEED. The bars are
3231 * copied, join the feed behind every bar it holds, and ride on the next
3232 * pushed bar whose period they opened before — the routing a batch of the
3233 * same bars applies. @p n of 0 is accepted and appends nothing.
3234 *
3235 * Refused without mutation, the handle staying usable, for bars that are out
3236 * of order or not after the feed's last bar, a bar with invalid OHLCV, a bar
3237 * that opened inside an input period already accepted, a host that declared
3238 * no feed, and a run that is not realtime: PF_NATIVE_E_STATE, the reason
3239 * readable with #strategy_get_last_error and, by name, from
3240 * #strategy_native_append_auxiliary_bars_ext_v1. A call from inside a callback fails the
3241 * run, as every reentrant stream input does.
3242 * @return PF_NATIVE_OK, or a negative status. */
3244 int32_t n);
3245
3246/** The same append, answered by name — `append_auxiliary_bars_result()`.
3247 *
3248 * The same call as #strategy_native_append_auxiliary_bars_v1 — same
3249 * legality, same appended bars, same statuses, the same latched contract
3250 * failure for a call from inside a callback — with the refusal written out.
3251 * #strategy_native_append_auxiliary_bars_v1 stays this call with both
3252 * out-parameters NULL.
3253 *
3254 * @param s The host this run is driving.
3255 * @param bars @p n bars, strictly increasing and after the feed's last
3256 * bar, copied; NULL when @p n is 0.
3257 * @param n Bar count; 0 appends nothing.
3258 * @param error Optional; receives a #pf_native_append_error_t whenever the
3259 * kernel judged the call (#PF_NATIVE_APPEND_ERROR_NONE when
3260 * appended).
3261 * @param index Optional; receives the bar OF THIS CALL the refusal stopped
3262 * on, 0 for a refusal that is not about one bar and for an
3263 * applied append.
3264 * @return PF_NATIVE_OK, PF_NATIVE_E_STATE for every refusal the kernel names
3265 * in @p error, or PF_NATIVE_E_ARGUMENT for a negative @p n or NULL @p bars
3266 * with @p n > 0, which the C layer refuses itself, leaving both
3267 * out-parameters untouched.
3268 *
3269 * Exercised by `tests/test_native_c_api.c`. */
3271 int32_t n, uint32_t* error,
3272 int32_t* index);
3273
3274/** Declare where the fill that opened a lot sits on its entry bar —
3275 * `declare_opened_lot_entry_bar_mask()`, the entry-side half of the
3276 * excursion capability #pf_native_callbacks_v1::on_lot_excursion owns
3277 * (RULING A48).
3278 *
3279 * The host says only WHERE its fill sat. The kernel walks @p entry_bar's
3280 * modeled path in the run's own leg order, the one its matcher walks —
3281 * #pf_native_run_spec_ext_v1::path_order when HIGH_FIRST or LOW_FIRST, and
3282 * under AUTO the high first when |high - open| < |open - low|, the low first
3283 * otherwise — finds where a price is first touched on it, and sets the
3284 * two entry-bar masks of every open lot booked under @p entry_incarnation:
3285 * the ends of the bar the path had already reached before that lot's own
3286 * price. They come back on the lot's closing facts,
3287 * #pf_native_lot_excursion_v1::entry_bar_high_masked and
3288 * `entry_bar_low_masked`. A fill the path never reaches leaves the lot as
3289 * it was, and so does an incarnation that booked no open lot. The masks are
3290 * durable lot state, folded into the broker-state hash.
3291 *
3292 * Legal inside `on_applied` alone — the frame in which a host learns that a
3293 * fill opened a lot (#pf_native_applied_v1::opened_lot_incarnation) — and
3294 * refused with PF_NATIVE_E_STATE everywhere else, changing nothing.
3295 *
3296 * @param s The host this run is driving, from #strategy_create.
3297 * @param entry_incarnation The request whose fill opened the lot.
3298 * @param entry_bar The whole bar the fill sat on; borrowed.
3299 * @param fill_point #pf_native_opened_lot_fill_point_t.
3300 * @return PF_NATIVE_OK, PF_NATIVE_E_ARGUMENT for a NULL @p entry_bar,
3301 * PF_NATIVE_E_TAG for a fill point outside the enumeration,
3302 * PF_NATIVE_E_STATE outside `on_applied`, or another negative status. */
3304 uint64_t entry_incarnation,
3305 const pf_bar_t* entry_bar,
3306 uint32_t fill_point);
3307
3308/** @} */ /* end of pf_native_c_api */
3309
3310#ifdef __cplusplus
3311} /* extern "C" */
3312#endif
3313
3314#endif /* PINEFORGE_NATIVE_C_API_H */
int strategy_native_run_v1(pf_strategy_t s, const pf_bar_t *bars, int n, pf_report_t *out)
Run n bars as one batch and fill out.
int strategy_native_cancel_where_v1(pf_strategy_t s, const char *text, uint32_t field)
Cancel exactly the live requests whose field equals text.
void strategy_native_host_free(pf_strategy_t s)
Release a handle from strategy_native_host_create_v1.
int strategy_native_position_v1(pf_strategy_t s, double *signed_units, double *average_price, uint64_t *lots)
Read the physical position.
int strategy_native_acknowledge_events_v1(pf_strategy_t s, uint64_t through_ordinal)
The host has read every event through through_ordinal — native_acknowledge_events().
int strategy_native_continuation_hash_v1(pf_strategy_t s, uint64_t *out)
The run's continuation identity — native_continuation_hash().
int strategy_native_recalculations_v1(pf_strategy_t s, uint64_t *driven, uint64_t *skipped)
How many recalculations the kernel drove, and how many it suppressed because a point had spent its ma...
int strategy_native_trail_state_v1(pf_strategy_t s, uint64_t incarnation, pf_native_trail_state_v1 *out)
The trail projection of one live request — trail_state().
int strategy_native_cohort_open_v1(pf_strategy_t s, uint64_t *cohort)
Open a cohort roster for PF_NATIVE_OWNER_BIND_COHORT.
int strategy_configure_native_ext_v1(pf_strategy_t s, const pf_native_run_spec_v1 *base, const pf_native_run_spec_ext_v1 *ext)
Configure a native run from the v1 specification plus the extension.
int strategy_native_marked_equity_v1(pf_strategy_t s, double mark, double *out)
The account's marked equity at mark — native_marked_equity().
int strategy_native_api_version(void)
This header's layout version.
int strategy_native_replace_ext_v1(pf_strategy_t s, uint64_t incarnation, const pf_native_request_v1 *request, uint64_t *successor, uint32_t *reject)
Replace the live request incarnation, reporting a rejection's reason.
int strategy_native_declare_subscriptions_v1(pf_strategy_t s, const pf_native_subscription_v1 *rows, int n)
Declare this run's higher-timeframe series from inside on_run_begin — declare_timeframe_subscriptions...
int strategy_native_partial_bar_v1(pf_strategy_t s, pf_bar_t *out)
The bar so far — current_partial_bar().
int strategy_native_append_auxiliary_bars_v1(pf_strategy_t s, const pf_bar_t *bars, int32_t n)
Append later bars to the run's declared auxiliary feed on a realtime stream (NativeStrategyHost::appe...
int strategy_native_open_lot_count_v1(pf_strategy_t s, double mark)
Snapshot the open lots marked at mark and return their count.
int strategy_native_execute_current_v1(pf_strategy_t s, uint64_t incarnation, uint32_t price_rule, uint32_t *refusal)
Execute one live request at the current execution point.
int strategy_native_cohort_add_v1(pf_strategy_t s, uint64_t cohort, uint64_t incarnation)
Enrol a live request into a cohort roster.
int strategy_native_event_window_v1(pf_strategy_t s, uint64_t *out_first_ordinal)
The oldest ordinal a read can still return — native_event_window_start() — written to out_first_ordin...
int strategy_native_timeframe_bar_interval_v1(pf_strategy_t s, pf_native_timeframe_interval_v1 *out)
Read the delivered bucket's own calendar interval from inside pf_native_callbacks_v1::on_timeframe_ba...
int strategy_native_risk_state_v1(pf_strategy_t s, pf_native_risk_state_v1 *out)
The run's generic risk ledger — native_risk_state().
int strategy_native_liquidation_price_v1(pf_strategy_t s, double *out)
The price at which the marked equity falls below the run's maintenance requirement for the live posit...
int strategy_native_events_v1(pf_strategy_t s, uint64_t after_ordinal, pf_native_event_v1 *out, int cap)
Copy up to cap events with an ordinal strictly greater than after_ordinal into out,...
pf_strategy_t strategy_native_host_create_v1(const pf_native_callbacks_v1 *callbacks)
Allocate a native host that forwards every kernel callback to callbacks.
int strategy_native_series_bar_v1(pf_strategy_t s, uint32_t subscription, pf_bar_t *out)
The latest completed bucket of a declared subscription — native_series_bar().
int strategy_native_working_len_v1(pf_strategy_t s)
Snapshot the live working book and return its length.
int strategy_native_declare_subscriptions_ext_v1(pf_strategy_t s, const pf_native_subscription_v1 *rows, int n, const uint32_t *sources, uint32_t *error, uint32_t *field)
The same declaration, answered by name — declare_timeframe_subscriptions_result().
int strategy_native_cancel_v1(pf_strategy_t s, uint64_t incarnation)
Cancel one live request.
int strategy_native_sized_units_v1(pf_strategy_t s, const pf_native_request_v1 *sized, double price, double equity, double fx, double *units)
The units a kernel-sized request resolves to under this run's spec, as a pure query — native_sized_un...
int strategy_native_working_get_v1(pf_strategy_t s, int index, pf_native_working_v1 *out)
Copy row index of the most recent working snapshot into out.
int strategy_native_margin_call_v1(pf_strategy_t s, uint64_t ordinal, pf_native_margin_call_v1 *out)
The whole economics of one margin call — what a C++ host's on_native_margin_call receives as MarginCa...
int strategy_native_state_v1(pf_strategy_t s, pf_native_state_v1 *out)
Read the run's lifecycle and typed failure into out.
int strategy_native_declare_auxiliary_feed_v1(pf_strategy_t s, const char *tf, const pf_bar_t *bars, int32_t n, uint32_t *error, uint32_t *field)
Declare, replace or withdraw this run's auxiliary finer feed from inside on_run_begin — declare_auxil...
int strategy_native_cohort_remove_v1(pf_strategy_t s, uint64_t cohort, uint64_t incarnation)
Remove a request from a cohort roster.
int strategy_configure_native_ext_result_v1(pf_strategy_t s, const pf_native_run_spec_v1 *base, const pf_native_run_spec_ext_v1 *ext, uint32_t *error, uint32_t *field)
The typed spelling of strategy_configure_native_ext_v1: the same inputs, plus error / field,...
int strategy_native_open_lot_get_v1(pf_strategy_t s, int index, pf_native_open_lot_v1 *out)
Copy row index of the most recent open-lot snapshot into out.
int strategy_native_declare_opened_lot_entry_bar_mask_v1(pf_strategy_t s, uint64_t entry_incarnation, const pf_bar_t *entry_bar, uint32_t fill_point)
Declare where the fill that opened a lot sits on its entry bar — declare_opened_lot_entry_bar_mask(),...
int strategy_native_submit_v1(pf_strategy_t s, const pf_native_request_v1 *request, uint64_t *incarnation, uint32_t *reject)
Submit request.
void strategy_native_report_free_v1(pf_report_t *report)
Free the heap arrays inside a report filled by strategy_native_run_v1.
int strategy_native_replace_v1(pf_strategy_t s, uint64_t incarnation, const pf_native_request_v1 *request, uint64_t *successor)
Replace the live request incarnation with request.
int strategy_native_append_auxiliary_bars_ext_v1(pf_strategy_t s, const pf_bar_t *bars, int32_t n, uint32_t *error, int32_t *index)
The same append, answered by name — append_auxiliary_bars_result().
int strategy_native_cancel_all_v1(pf_strategy_t s)
Cancel every live request, dependants included.
pf_native_intent_t
Order intent — the alternative index of native_order::OrderIntent.
pf_native_close_execution_t
When a request born at a script calculation may first match — NativeCloseExecution,...
pf_native_run_phase_t
Which driving a Running run is in — NativeRunPhase: pf_native_state_v1::phase.
pf_native_refusal_t
Why execute_current refused.
pf_native_grid_policy_t
Whether resolved sizing snaps onto the run's quantity grid.
pf_native_size_basis_t
Sizing basis — the alternative index of native_order::SizeBasis.
pf_native_anchored_trigger_t
Which trigger of an anchored leg the owner's fill supplies — NativeAnchoredTrigger,...
pf_native_liquidation_check_t
When the kernel tests the maintenance requirement — NativeLiquidationCheck, the margin_check field of...
pf_native_event_retention_t
What a run keeps of its event record — NativeRunSpec::event_retention, the event_retention word of pf...
pf_native_risk_day_t
Which day a risk limit's "day" is — NativeRiskDay.
pf_native_spec_ext_mask_t
Which extension blocks of pf_native_run_spec_ext_v1 are meaningful.
pf_native_open_directions_t
Which opening directions the run admits — NativeOpenDirections, the allowed_open_directions word of p...
pf_native_execute_outcome_t
Outcome of strategy_native_execute_current_v1 (non-negative returns).
pf_native_scope_basis_t
WHICH measurement of the bound scope a fractional reduce takes its fraction of — native_order::ScopeB...
pf_native_plan_t
The settlement shape an execution is about to take — the alternative of native_order::ExecutionPlan,...
pf_native_grid_rounding_t
How a quantizing grid rounds — NativeGridRounding, the grid_rounding word of pf_native_run_spec_ext_v...
pf_native_abort_reporting_t
How a cooperative abort is presented — NativeAbortReporting.
pf_native_report_policy_t
Who records the per-script-bar report series — NativeReportPolicy, the report_policy word of pf_nativ...
pf_native_liquidation_sizing_t
Which units a kernel-issued liquidation reduces — NativeLiquidationSizing, the margin_sizing word of ...
pf_native_quote_kind_t
Which quote pf_native_decision_v1::price is — NativeCurrentQuoteKind: the callback's own market decis...
pf_native_size_time_t
When a sizing basis resolves.
pf_native_arm_visibility_t
Whether a WAIT_FOR_APPLIED child is a working order before its arm — native_order::NativeArmVisibilit...
pf_native_intrabar_kind_t
Which intrabar execution path the run retains — the alternative of IntrabarPath.
pf_native_candidate_price_t
Which price a matching candidate is at — native_order::NativeCandidatePriceKind, pf_native_terms_view...
pf_native_size_price_t
WHICH price a kernel-sized basis converts at — native_order::SizePrice (L3b).
pf_native_side_t
Side of a kernel-sized opening.
pf_native_sample_eligibility_t
Whether matching stays continuous between generated samples — IntrabarPath::SampleEligibility.
pf_native_series_source_t
The bars a declared series is built from — NativeSeriesSource.
pf_native_completion_kind_t
How a script interval or a higher-timeframe bucket was closed — NativeCompletionKind: pf_native_decis...
pf_native_driver_class_t
Which kind of driver point a candidate matched at — native_order::DriverEligibilityClass,...
pf_native_append_error_t
Why an append was refused — NativeAuxiliaryAppendError: the error out-parameter of strategy_native_ap...
pf_native_origin_t
Who issued a live request — native_order::RequestOrigin: pf_native_working_v1::origin.
pf_native_calc_reason_t
Why the kernel is asking the host to calculate — NativeCalculationReason (L5), the reason argument of...
pf_native_group_t
Group — the alternative index of native_order::Group.
pf_native_match_reject_t
Why a matching candidate was refused — native_order::MatchRejectReason: the reason of a PF_NATIVE_EVE...
pf_native_calc_trigger_t
When the kernel asks the host to calculate — NativeCalculationTrigger, the calculation word of pf_nat...
pf_native_path_phase_t
Which leg of a modeled OHLC walk a point sits on — NativePathPhase: the path_phase word of pf_native_...
pf_native_price_rule_t
Price rule of an immediate execution.
pf_native_cancel_reason_t
Why a live request left the book unfilled — native_order::CancelReason: the reason of a PF_NATIVE_EVE...
pf_native_opening_shape_t
How an opening settles against an opposite book — native_order::OpeningShape, pf_native_terms_v1::sha...
pf_native_margin_equity_basis_t
Which equity the maintenance requirement is tested against — NativeMarginEquityBasis.
pf_native_group_effect_t
What a filled group member does to its siblings.
pf_native_arm_scope_t
What an armed CLOSING child (REDUCE, FLATTEN, a host-sized close) closes — native_order::NativeArmSco...
pf_native_failure_operation_t
Which operation was in flight when the failure latched — NativeFailureOperation: pf_native_state_v1::...
pf_native_arm_first_match_t
Whether an armed WAIT_FOR_APPLIED child may trade on its owner's own fill print — native_order::Nativ...
pf_native_request_field_t
Which identity text strategy_native_cancel_where_v1 compares.
pf_native_precommit_verdict_t
What pf_native_callbacks_v1::on_precommit answers — NativePrecommitVerdict.
pf_native_slot_label_t
Whether a confirmed bar must name a canonical input slot — NativeSlotLabelPolicy.
pf_native_owner_t
Owner — the alternative index of native_order::Owner.
pf_native_price_provenance_t
Where a point's price came from — NativePriceProvenance: the provenance word of pf_native_decision_v1...
pf_native_capacity_t
Capacity — the alternative index of native_order::Capacity.
pf_native_gaps_t
What a declared series holds on an accepted input that delivers no bucket of it — NativeTimeframeSubs...
pf_native_feed_tolerance_t
Opt-in admission exceptions for a tolerated input-feed shape — NativeFeedTolerance.
pf_native_path_order_t
Generic ordering for a modeled OHLC path — NativePathOrder.
pf_native_price_grid_t
A generic instrument price grid — NativePriceGrid, the price_grid word of pf_native_run_spec_ext_v1.
pf_native_anchor_rounding_t
How a materialized anchored level snaps onto the run's price tick ladder — native_order::NativeAnchor...
pf_native_fee_kind_t
What one execution costs — NativeFeeKind, the fee_kind word of pf_native_run_spec_v1,...
pf_native_lookahead_t
When a declared series delivers a completed bucket — NativeTimeframeSubscription::lookahead,...
pf_native_margin_level_base_t
Which base the liquidation level is solved from — NativeLiquidationLevelBase.
pf_native_spec_field_t
Where a declaration was refused — NativeRunSpecField, the first field the kernel's validation found: ...
pf_native_terminal_reason_t
Why an applied execution finished its request — native_order::AppliedTerminalReason: pf_native_applie...
pf_native_spec_error_t
Why a declaration was refused — NativeRunSpecError, the kernel's own validation word: the error out-p...
pf_native_reject_reason_t
Why the kernel refused a request — native_order::RequestRejectReason: the reject out-parameter of str...
pf_native_risk_limit_t
Which generic risk limit a PF_NATIVE_EVENT_RISK event reports — the reason field of pf_native_event_v...
pf_native_margin_check_kind_t
Which kernel check point is about to test the maintenance requirement — NativeMarginCheckKind (L4b).
pf_native_lifecycle_t
Lifecycle of the native run — mirrors NativeLifecycleKind.
pf_native_trigger_t
Trigger — the alternative index of native_order::Trigger.
pf_native_activation_t
Which trigger a price reached — native_order::ActivationKind: the reason of a PF_NATIVE_EVENT_ACTIVAT...
pf_native_opened_lot_fill_point_t
Where an opened lot's own fill sits on its entry bar's modeled path — OpenedLotFillPoint,...
pf_native_completion_t
How a Completed run ended — NativeCompletion: pf_native_state_v1::completion.
pf_native_open_bar_view_t
What pf_native_callbacks_v1::on_bar_open is handed — NativeOpenBarView, the open_bar_view word of pf_...
pf_native_scope_claim_t
Scope claim of a fractional reduce.
pf_native_reduction_t
Reduction size — the alternative index of native_order::ReductionSize.
pf_native_answer_t
What an ANSWERING callback's return value means.
pf_native_anchor_t
Where a trigger level comes from — native_order::TriggerAnchor (L7).
pf_native_event_kind_t
Event tag of pf_native_event_v1.
pf_native_failure_code_t
A run's durable first failure — NativeFailureCode: pf_native_state_v1::failure_code.
pf_native_remaining_t
Remaining projection of a live request — native_order::RemainingProjection.
pf_native_risk_action_t
What a breach does — NativeRiskAction.
pf_native_trigger_state_t
Trigger state of a live request — native_order::TriggerState.
@ PF_NATIVE_INTENT_SIZED
Kernel-sized opening (L3).
@ PF_NATIVE_INTENT_REDUCE
Reduce; see pf_native_reduction_t.
@ PF_NATIVE_INTENT_TRANSACT
intent_value signed units.
@ PF_NATIVE_INTENT_HOST_SIZED
A close sized by on_close_units: the cohort close (PF_NATIVE_OWNER_BIND_COHORT) or a WAIT_FOR_APPLIED...
@ PF_NATIVE_INTENT_FLATTEN
Close the whole book.
@ PF_NATIVE_INTENT_REVERSE_TO
intent_value target signed exposure.
@ PF_NATIVE_CLOSE_EXECUTION_AFTER_CALCULATION
Also a modeled close point right after that calculation.
@ PF_NATIVE_CLOSE_EXECUTION_NEXT_ELIGIBLE_POINT
A later eligible point — the next modeled opening, an observed print or a carried open — never the ba...
@ PF_NATIVE_PHASE_BATCH
@ PF_NATIVE_PHASE_REALTIME
A stream's realtime leg.
@ PF_NATIVE_PHASE_WARMUP
A stream's warmup replay.
@ PF_NATIVE_REFUSAL_NOT_ACCEPTED_IN_CALLBACK
@ PF_NATIVE_REFUSAL_NOT_WORKING
@ PF_NATIVE_REFUSAL_INVALID_HANDLE
@ PF_NATIVE_REFUSAL_INVALID_SELECTION
@ PF_NATIVE_REFUSAL_UNSUPPORTED_REQUEST
@ PF_NATIVE_REFUSAL_NO_EXECUTION_CONTEXT
@ PF_NATIVE_REFUSAL_UNREADY_OWNER
@ PF_NATIVE_REFUSAL_CONFIGURATION_MISMATCH
@ PF_NATIVE_REFUSAL_REENTRANT
@ PF_NATIVE_GRID_SNAP
@ PF_NATIVE_GRID_EXPLICIT_UNITS
@ PF_NATIVE_SIZE_BASIS_EQUITY_FRACTION
intent_value fraction of marked equity.
@ PF_NATIVE_SIZE_BASIS_CASH
intent_value account-currency cash.
@ PF_NATIVE_ANCHORED_TRIGGER_TRAIL_ARM
@ PF_NATIVE_ANCHORED_TRIGGER_LIMIT
@ PF_NATIVE_ANCHORED_TRIGGER_STOP
@ PF_NATIVE_LIQUIDATION_PATH_ADVERSE_EXTREME
Solve and rest at the level.
@ PF_NATIVE_LIQUIDATION_CALCULATION_ONLY
Test the mark; rest nothing.
@ PF_NATIVE_LIQUIDATION_PATH_ADVERSE_EXTREME_MARK
Rest AT the adverse mark.
@ PF_NATIVE_EVENT_RETENTION_WINDOW
The unread journal only.
@ PF_NATIVE_EVENT_RETENTION_FULL
Journal, driver points, account rows.
@ PF_NATIVE_EVENT_RETENTION_COMMANDS
Journal and account rows.
@ PF_NATIVE_RISK_DAY_SESSION
@ PF_NATIVE_RISK_DAY_CALENDAR_TIMEZONE
@ PF_NATIVE_SPEC_EXT_FEED_POLICY
The four feed-shape and presentation policies: slot labels, feed tolerance, the forced path order and...
@ PF_NATIVE_SPEC_EXT_MARGIN
@ PF_NATIVE_SPEC_EXT_QUANTITY_TOLERANCE
The settlement's quantity tolerance (quantity_tolerance).
@ PF_NATIVE_SPEC_EXT_OPEN_BAR_VIEW
@ PF_NATIVE_SPEC_EXT_SUBSCRIPTIONS
@ PF_NATIVE_SPEC_EXT_CALCULATION
@ PF_NATIVE_SPEC_EXT_AUXILIARY_FEED
The auxiliary finer feed.
@ PF_NATIVE_SPEC_EXT_PRICE_GRID
@ PF_NATIVE_SPEC_EXT_REPORT
@ PF_NATIVE_SPEC_EXT_RISK
L9's generic risk limits.
@ PF_NATIVE_SPEC_EXT_EVENT_RETENTION
What the run keeps of its event record (event_retention).
@ PF_NATIVE_SPEC_EXT_INTRABAR
The retained intrabar execution path.
@ PF_NATIVE_OPEN_DIRECTIONS_BOTH
The kernel's default.
@ PF_NATIVE_OPEN_DIRECTIONS_SHORT
@ PF_NATIVE_OPEN_DIRECTIONS_LONG
@ PF_NATIVE_OPEN_DIRECTIONS_NONE
@ PF_NATIVE_EXECUTED_CANCELLED
The request was cancelled instead.
@ PF_NATIVE_EXECUTED_MATCH_REJECTED
Terms/admission rejected it.
@ PF_NATIVE_EXECUTED_NO_EFFECT
Legal, nothing to execute.
@ PF_NATIVE_EXECUTED_APPLIED
An execution was applied.
@ PF_NATIVE_SCOPE_BASIS_AT_MATCH
@ PF_NATIVE_SCOPE_BASIS_AT_ACCEPTANCE
@ PF_NATIVE_PLAN_TRANSACT
Trade plan_units signed units.
@ PF_NATIVE_PLAN_REDUCE
Close plan_units units.
@ PF_NATIVE_PLAN_FLATTEN
Close the whole book; plan_units 0.
@ PF_NATIVE_PLAN_REVERSE_TO
Reach plan_units signed exposure.
@ PF_NATIVE_GRID_ROUNDING_HALF_UP
The nearest tick, ties away from zero (the default).
@ PF_NATIVE_GRID_ROUNDING_DIRECTIONAL
Toward the region the order needs: a buy limit down and a sell limit up, a stop the other way,...
@ PF_NATIVE_ABORT_QUIET
@ PF_NATIVE_ABORT_ERROR
@ PF_NATIVE_REPORT_HOST_RECORDED
The host's; the kernel appends no point (the default).
@ PF_NATIVE_REPORT_KERNEL_RECORDED
One equity point per script calculation; report_open_position_at_end applies.
@ PF_NATIVE_LIQUIDATION_SIZING_RESTORE_MINIMUM
The fewest units that restore the requirement at the sizing mark (the default).
@ PF_NATIVE_LIQUIDATION_SIZING_SHORTFALL_MULTIPLE
That restore times margin_shortfall_multiple.
@ PF_NATIVE_LIQUIDATION_SIZING_FLATTEN
The whole position.
@ PF_NATIVE_QUOTE_MARKET_DECISION
@ PF_NATIVE_QUOTE_EXECUTION_ANCHOR
@ PF_NATIVE_SIZE_AT_ACCEPTANCE
@ PF_NATIVE_SIZE_AT_MATCH
@ PF_NATIVE_ARM_VISIBILITY_WORKING
@ PF_NATIVE_ARM_VISIBILITY_PENDING_UNTIL_ARMED
@ PF_NATIVE_INTRABAR_SYNTHESIZED
@ PF_NATIVE_INTRABAR_NONE
@ PF_NATIVE_INTRABAR_LOWER_TF
@ PF_NATIVE_CANDIDATE_PRICE_CURRENT_QUOTE
A current execution's quote.
@ PF_NATIVE_CANDIDATE_PRICE_TRIGGER_LEVEL
A resting level the path crossed.
@ PF_NATIVE_CANDIDATE_PRICE_POINT_PRICE
The driver point's own price.
@ PF_NATIVE_SIZE_PRICE_RESOLVED
@ PF_NATIVE_SIZE_PRICE_SIGNAL
@ PF_NATIVE_SIZE_PRICE_SIGNAL_ON_TICK
@ PF_NATIVE_SIDE_LONG
@ PF_NATIVE_SIDE_SHORT
@ PF_NATIVE_SAMPLE_DISTRIBUTION_SAMPLES
@ PF_NATIVE_SAMPLE_CONTINUOUS_SEGMENTS
@ PF_NATIVE_SERIES_SOURCE_AUXILIARY_FEED
The run's auxiliary finer feed.
@ PF_NATIVE_SERIES_SOURCE_INPUT
The accepted input (the default).
@ PF_NATIVE_COMPLETION_KIND_SESSION_SHORTENED
The session close clipped it.
@ PF_NATIVE_COMPLETION_KIND_PARTIAL_FINALIZED
A stream end finalized a forming observed slot.
@ PF_NATIVE_COMPLETION_KIND_CONFIRMED
Its own last contributing bar.
@ PF_NATIVE_COMPLETION_KIND_LAZY_COMPLETE
The NEXT interval's first input: a session-clipped bar, or a hole over the last slot.
@ PF_NATIVE_DRIVER_CLASS_CONFIRMED_AFTER_CALCULATION_CLOSE
@ PF_NATIVE_DRIVER_CLASS_CARRIED_OPEN
@ PF_NATIVE_DRIVER_CLASS_CONFIRMED_EXCURSION
@ PF_NATIVE_DRIVER_CLASS_OBSERVED_PRINT
@ PF_NATIVE_DRIVER_CLASS_CURRENT_EXECUTION
@ PF_NATIVE_DRIVER_CLASS_CONFIRMED_OPEN
@ PF_NATIVE_DRIVER_CLASS_TICK_AFTER_CALCULATION
@ PF_NATIVE_APPEND_ERROR_NO_AUXILIARY_FEED
The run declared no feed.
@ PF_NATIVE_APPEND_ERROR_INPUT_PERIOD_ALREADY_ACCEPTED
The first bar opened inside an input period already accepted.
@ PF_NATIVE_APPEND_ERROR_HOST_FAILED
The host had already failed.
@ PF_NATIVE_APPEND_ERROR_INVALID_BAR_ARRAY
A NULL array with a non-zero count.
@ PF_NATIVE_APPEND_ERROR_ALLOCATION_FAILURE
Growing the feed threw; this fails the host.
@ PF_NATIVE_APPEND_ERROR_UNORDERED_BARS
index is not strictly after its predecessor (the feed's last bar for index 0).
@ PF_NATIVE_APPEND_ERROR_NONE
Applied.
@ PF_NATIVE_APPEND_ERROR_NOT_REALTIME
Not on a stream's realtime leg.
@ PF_NATIVE_APPEND_ERROR_INVALID_BAR
index has invalid OHLCV.
@ PF_NATIVE_APPEND_ERROR_REENTRANT
From inside a callback or an in-flight input.
@ PF_NATIVE_ORIGIN_KERNEL_RISK
The run's risk limits.
@ PF_NATIVE_ORIGIN_KERNEL_LIQUIDATION
The run's margin model.
@ PF_NATIVE_ORIGIN_HOST
@ PF_NATIVE_CALC_SUB_BAR
Reserved; see on_sub_bar.
@ PF_NATIVE_CALC_BAR_CLOSE
The script bar's own calculation; cause NULL.
@ PF_NATIVE_CALC_TICK
At a modeled point or print; cause NULL.
@ PF_NATIVE_CALC_ORDER_FILL
At an applied execution's cursor; cause is it.
@ PF_NATIVE_GROUP_MEMBER
group_id, group_cohort, group_effect.
@ PF_NATIVE_GROUP_NONE
@ PF_NATIVE_MATCH_REJECT_OPENING_DIRECTION
allowed_open_directions.
@ PF_NATIVE_MATCH_REJECT_MAX_OPEN_LOTS
@ PF_NATIVE_MATCH_REJECT_INITIAL_MARGIN
@ PF_NATIVE_MATCH_REJECT_INVALID_TERMS
@ PF_NATIVE_MATCH_REJECT_TERMS_UNRESOLVED
@ PF_NATIVE_MATCH_REJECT_HOST_PRECOMMIT
@ PF_NATIVE_MATCH_REJECT_MAX_ABS_UNITS
@ PF_NATIVE_MATCH_REJECT_RISK_LIMIT
An opening refused while a risk limit blocks.
@ PF_NATIVE_MATCH_REJECT_UNREPRESENTABLE_QUANTITY
A quantity the settlement cannot book exactly on this book: the request ends, nothing moves and the r...
@ PF_NATIVE_MATCH_REJECT_NO_OPPOSITE_EXPOSURE
@ PF_NATIVE_MATCH_REJECT_NONPOSITIVE_PRICE
@ PF_NATIVE_CALC_TRIGGER_BAR_CLOSE
Once per script bar, at its close (the default).
@ PF_NATIVE_CALC_TRIGGER_EVERY_MODELED_POINT
And at every modeled point and every observed print.
@ PF_NATIVE_CALC_TRIGGER_BAR_CLOSE_AND_FILLS
And at each applied execution's cursor, bounded by max_recalculations_per_point.
@ PF_NATIVE_PATH_PHASE_OPEN
@ PF_NATIVE_PATH_PHASE_LOW
@ PF_NATIVE_PATH_PHASE_CLOSE
@ PF_NATIVE_PATH_PHASE_NONE
@ PF_NATIVE_PATH_PHASE_HIGH
@ PF_NATIVE_PRICE_AS_PRESENTED
@ PF_NATIVE_PRICE_NEAREST_TICK
@ PF_NATIVE_CANCEL_UNSUPPORTED_RELATION
@ PF_NATIVE_CANCEL_GROUP
A group sibling's fill withdrew it.
@ PF_NATIVE_CANCEL_USER
The host's own cancel.
@ PF_NATIVE_CANCEL_SUPERSEDED
A kernel-originated request the kernel itself withdrew: its level or units moved, or the breach is ov...
@ PF_NATIVE_CANCEL_OWNER_GONE
Its owner left the book first.
@ PF_NATIVE_OPENING_SHAPE_REVERSE_TO
Close the opposite book, then open the units.
@ PF_NATIVE_OPENING_SHAPE_CLOSE_OPPOSITE
Close the opposite book and open the remainder.
@ PF_NATIVE_OPENING_SHAPE_TRANSACT
Net against the book (the default).
@ PF_NATIVE_MARGIN_EQUITY_BEFORE_OPEN_COMMISSION
@ PF_NATIVE_MARGIN_EQUITY_MARKED
@ PF_NATIVE_GROUP_REDUCE
@ PF_NATIVE_GROUP_CANCEL
@ PF_NATIVE_ARM_SCOPE_BOOK
@ PF_NATIVE_ARM_SCOPE_OWNER_LOT
@ PF_NATIVE_OPERATION_CONFIGURE
@ PF_NATIVE_OPERATION_CALLBACK
@ PF_NATIVE_OPERATION_NONE
@ PF_NATIVE_OPERATION_MUTATION
@ PF_NATIVE_OPERATION_INPUT
@ PF_NATIVE_OPERATION_BEGIN
@ PF_NATIVE_OPERATION_SETTLEMENT
@ PF_NATIVE_OPERATION_STREAM
@ PF_NATIVE_OPERATION_COMMAND
@ PF_NATIVE_ARM_FIRST_MATCH_AT_ARM_PRINT
@ PF_NATIVE_ARM_FIRST_MATCH_AFTER_ARM_PRINT
@ PF_NATIVE_FIELD_LABEL
@ PF_NATIVE_FIELD_COMMENT
@ PF_NATIVE_PRECOMMIT_REFUSE
A nonfinancial PF_NATIVE_MATCH_REJECT_HOST_PRECOMMIT.
@ PF_NATIVE_PRECOMMIT_ADMIT
The kernel's own path.
@ PF_NATIVE_PRECOMMIT_ADMIT_WITH_HOST_MARGIN
Admit, and the host owns this one opening's margin check: the kernel's initial-margin gate is skipped...
@ PF_NATIVE_SLOT_LABEL_FEED_TOLERANT
@ PF_NATIVE_SLOT_LABEL_CANONICAL
@ PF_NATIVE_OWNER_WAIT_FOR_APPLIED
One parent in owner_incarnations.
@ PF_NATIVE_OWNER_BIND_COHORT
cohort from strategy_native_cohort_open_v1.
@ PF_NATIVE_OWNER_BIND_OPENINGS
owner_n openings + owner_cycle.
@ PF_NATIVE_OWNER_INDEPENDENT
No owner.
@ PF_NATIVE_OWNER_BIND_OPENING
One opening + owner_cycle.
@ PF_NATIVE_PROVENANCE_MODELED_OHLC_OPEN
A modeled path's opening point.
@ PF_NATIVE_PROVENANCE_AFTER_CALCULATION_CLOSE
The close point right after a calculation.
@ PF_NATIVE_PROVENANCE_CARRIED_OPEN
A quiet tradable interval's carried last price.
@ PF_NATIVE_PROVENANCE_CURRENT_EXECUTION
A synchronous strategy_native_execute_current_v1.
@ PF_NATIVE_PROVENANCE_CALCULATION
The script calculation point itself.
@ PF_NATIVE_PROVENANCE_MODELED_OHLC_CLOSE
A modeled path's closing point.
@ PF_NATIVE_PROVENANCE_PARTIAL_FINALIZED
A partially finalized observed slot.
@ PF_NATIVE_PROVENANCE_OBSERVED_PRINT
A realtime print.
@ PF_NATIVE_PROVENANCE_CONFIRMED
A confirmed input bar's own label, or a point on its modeled path.
@ PF_NATIVE_CAPACITY_IMMEDIATE
Whole remaining at one point.
@ PF_NATIVE_CAPACITY_POINT_BUDGET
capacity_units per matching point.
@ PF_NATIVE_GAPS_CLEAR
Nothing: strategy_native_series_bar_v1 answers PF_NATIVE_ABSENT on that input.
@ PF_NATIVE_GAPS_HOLD
The last delivered bucket, until the next delivery replaces it (the default).
@ PF_NATIVE_FEED_TOLERANCE_WARMUP_NONNEGATIVE
Stream warmups admit finite, non-negative interim OHLC.
@ PF_NATIVE_FEED_TOLERANCE_BATCH_STRUCTURAL
Finite OHLC need not be positive; NaN volume means unavailable.
@ PF_NATIVE_FEED_TOLERANCE_NONE
@ PF_NATIVE_PATH_ORDER_HIGH_FIRST
@ PF_NATIVE_PATH_ORDER_LOW_FIRST
@ PF_NATIVE_PATH_ORDER_AUTO
@ PF_NATIVE_PRICE_GRID_QUANTIZE_FILLS_AND_TRIGGERS
And each resting trigger tested against the quantized path.
@ PF_NATIVE_PRICE_GRID_QUANTIZE_FILLS
Each fill booked on the tick ladder.
@ PF_NATIVE_PRICE_GRID_NONE
Every price booked as the path presents it (the default).
@ PF_NATIVE_ANCHOR_ROUNDING_RAW
fill + offset exactly.
@ PF_NATIVE_ANCHOR_ROUNDING_DIRECTIONAL
Toward the region the leg needs.
@ PF_NATIVE_ANCHOR_ROUNDING_HALF_UP
Nearest tick, ties away from zero.
@ PF_NATIVE_FEE_CASH_PER_UNIT
fee_value account currency per unit.
@ PF_NATIVE_FEE_CASH_PER_EXECUTION
fee_value account currency per execution.
@ PF_NATIVE_FEE_PERCENT
fee_value percent of |units| × price × point value × account FX (the default).
@ PF_NATIVE_LOOKAHEAD_AT_FIRST_INPUT
The bucket's final values, on its first contributing input.
@ PF_NATIVE_LOOKAHEAD_AT_COMPLETION
On the input that completes the bucket (the default).
@ PF_NATIVE_MARGIN_LEVEL_MARKED_EQUITY
@ PF_NATIVE_MARGIN_LEVEL_REALIZED_ONLY
@ PF_NATIVE_SPEC_FIELD_MARGIN_MAINTENANCE
@ PF_NATIVE_SPEC_FIELD_SUBSCRIPTION_INSTRUMENT
@ PF_NATIVE_SPEC_FIELD_INTRABAR_TIMEFRAME
@ PF_NATIVE_SPEC_FIELD_MARGIN_MIN_UNITS
@ PF_NATIVE_SPEC_FIELD_RISK_FILLS_PER_DAY
@ PF_NATIVE_SPEC_FIELD_REPORT_POLICY
@ PF_NATIVE_SPEC_FIELD_RISK_DRAWDOWN
@ PF_NATIVE_SPEC_FIELD_PRICE_TICK
@ PF_NATIVE_SPEC_FIELD_EVENT_RETENTION
@ PF_NATIVE_SPEC_FIELD_CURRENCY
@ PF_NATIVE_SPEC_FIELD_ALLOWED_OPEN_DIRECTIONS
@ PF_NATIVE_SPEC_FIELD_RISK_LIMITS
@ PF_NATIVE_SPEC_FIELD_QUANTITY_TOLERANCE
@ PF_NATIVE_SPEC_FIELD_TICKER
@ PF_NATIVE_SPEC_FIELD_MARGIN_LEVEL_BASE
@ PF_NATIVE_SPEC_FIELD_INITIAL_CAPITAL
@ PF_NATIVE_SPEC_FIELD_INITIAL_MARGIN_FRACTION
@ PF_NATIVE_SPEC_FIELD_ACCOUNT_FX
@ PF_NATIVE_SPEC_FIELD_BASE_CURRENCY
@ PF_NATIVE_SPEC_FIELD_PATH_ORDER
@ PF_NATIVE_SPEC_FIELD_AUXILIARY_FEED_TIMEFRAME
@ PF_NATIVE_SPEC_FIELD_MARGIN_MODEL
@ PF_NATIVE_SPEC_FIELD_MARGIN_EQUITY_BASIS
@ PF_NATIVE_SPEC_FIELD_MARGIN_SIZING
@ PF_NATIVE_SPEC_FIELD_VOLUME_TYPE
@ PF_NATIVE_SPEC_FIELD_MAX_OPEN_LOTS
@ PF_NATIVE_SPEC_FIELD_TIMEFRAME_UNDETECTED
@ PF_NATIVE_SPEC_FIELD_INSTRUMENT_FEED_COLUMNS
@ PF_NATIVE_SPEC_FIELD_SLOT_LABEL_POLICY
@ PF_NATIVE_SPEC_FIELD_INSTRUMENT_FEED_TIMEFRAME
@ PF_NATIVE_SPEC_FIELD_INSTRUMENT_FEED_BARS
@ PF_NATIVE_SPEC_FIELD_ABORT_REPORTING
@ PF_NATIVE_SPEC_FIELD_SESSION_KEY
@ PF_NATIVE_SPEC_FIELD_QUANTITY_GRID
@ PF_NATIVE_SPEC_FIELD_INTRABAR_SAMPLES
@ PF_NATIVE_SPEC_FIELD_DESCRIPTION
@ PF_NATIVE_SPEC_FIELD_INSTRUMENT_FEED_INSTRUMENT
@ PF_NATIVE_SPEC_FIELD_INTRABAR_VOLUME_SAMPLES
@ PF_NATIVE_SPEC_FIELD_SLIPPAGE_TICKS
@ PF_NATIVE_SPEC_FIELD_INSTRUMENT_FEED_CLOSE
@ PF_NATIVE_SPEC_FIELD_NONE
Not about one field.
@ PF_NATIVE_SPEC_FIELD_GRID_ROUNDING
@ PF_NATIVE_SPEC_FIELD_INTRABAR_DISTRIBUTION
@ PF_NATIVE_SPEC_FIELD_CLOSE_EXECUTION
@ PF_NATIVE_SPEC_FIELD_SUBSCRIPTION_TIMEFRAME
@ PF_NATIVE_SPEC_FIELD_MAX_ABS_UNITS
@ PF_NATIVE_SPEC_FIELD_SESSION
@ PF_NATIVE_SPEC_FIELD_TICKER_ID
@ PF_NATIVE_SPEC_FIELD_RISK_DAY_BASIS
@ PF_NATIVE_SPEC_FIELD_PRICE_GRID
@ PF_NATIVE_SPEC_FIELD_CHART_TIMEZONE
@ PF_NATIVE_SPEC_FIELD_RISK_LOSS_DAYS
@ PF_NATIVE_SPEC_FIELD_TYPE
@ PF_NATIVE_SPEC_FIELD_MARGIN_INITIAL
@ PF_NATIVE_SPEC_FIELD_SCRIPT_TIMEFRAME
@ PF_NATIVE_SPEC_FIELD_AUXILIARY_FEED_BARS
@ PF_NATIVE_SPEC_FIELD_CALCULATION
@ PF_NATIVE_SPEC_FIELD_INPUT_TIMEFRAME
@ PF_NATIVE_SPEC_FIELD_SUBSCRIPTION_BARS
@ PF_NATIVE_SPEC_FIELD_RUN_NUMBER
@ PF_NATIVE_SPEC_FIELD_MARGIN_SHORTFALL_MULTIPLE
@ PF_NATIVE_SPEC_FIELD_RISK_INTRADAY_LOSS
@ PF_NATIVE_SPEC_FIELD_SUBSCRIPTION_SOURCE
@ PF_NATIVE_SPEC_FIELD_INTRABAR_SAMPLE_ELIGIBILITY
@ PF_NATIVE_SPEC_FIELD_TIMEZONE
@ PF_NATIVE_SPEC_FIELD_RISK_ACTION
@ PF_NATIVE_SPEC_FIELD_FEE_KIND
@ PF_NATIVE_SPEC_FIELD_OPEN_BAR_VIEW
@ PF_NATIVE_SPEC_FIELD_POINT_VALUE
@ PF_NATIVE_SPEC_FIELD_FEE_VALUE
@ PF_NATIVE_SPEC_FIELD_MARGIN_CHECK
@ PF_NATIVE_SPEC_FIELD_FEED_TOLERANCE
feed_tolerance: the kernel's legacy_tolerance.
@ PF_NATIVE_TERMINAL_WORKING_UNITS_SATISFIED
@ PF_NATIVE_TERMINAL_TARGET_EXHAUSTED
@ PF_NATIVE_TERMINAL_FLATTENED
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_LIQUIDATION_SIZING
@ PF_NATIVE_SPEC_ERROR_ZERO_RUN_NUMBER
@ PF_NATIVE_SPEC_ERROR_UNORDERED_AUXILIARY_FEED_BARS
@ PF_NATIVE_SPEC_ERROR_MARGIN_MODEL_CONFLICT
@ PF_NATIVE_SPEC_ERROR_ZERO_RISK_LIMIT
@ PF_NATIVE_SPEC_ERROR_CALENDAR_FAILURE
No calendar resolved it.
@ PF_NATIVE_SPEC_ERROR_NOT_FINITE_POSITIVE
@ PF_NATIVE_SPEC_ERROR_INVALID_INSTRUMENT_FEED_TIMEFRAME
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_SLOT_LABEL_POLICY
@ PF_NATIVE_SPEC_ERROR_ZERO_LOT_LIMIT
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_OPEN_DIRECTIONS
@ PF_NATIVE_SPEC_ERROR_MARGIN_SIDE_UNDECLARED
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_LIQUIDATION_CHECK
@ PF_NATIVE_SPEC_ERROR_INVALID_AUXILIARY_FEED_TIMEFRAME
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_EVENT_RETENTION
An event_retention word outside pf_native_event_retention_t.
@ PF_NATIVE_SPEC_ERROR_DUPLICATE_INSTRUMENT_FEED
@ PF_NATIVE_SPEC_ERROR_ALLOCATION_FAILURE
Staging threw.
@ PF_NATIVE_SPEC_ERROR_UNORDERED_INSTRUMENT_FEED_BARS
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_RISK_ACTION
@ PF_NATIVE_SPEC_ERROR_INVALID_INSTRUMENT_FEED_BAR
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_INTRABAR_SAMPLE_ELIGIBILITY
@ PF_NATIVE_SPEC_ERROR_ABORTED_HOST_NO_REUSABLE_RUN_SPEC
An aborted host had no reusable spec.
@ PF_NATIVE_SPEC_ERROR_DUPLICATE_SUBSCRIPTION_TIMEFRAME
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_FEED_TOLERANCE
feed_tolerance: the kernel's legacy_tolerance.
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_FEE_KIND
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_SERIES_SOURCE
@ PF_NATIVE_SPEC_ERROR_INVALID_INSTRUMENT_FEED_COLUMN
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_LIQUIDATION_LEVEL_BASE
@ PF_NATIVE_SPEC_ERROR_UNORDERED_SUBSCRIPTION_BARS
@ PF_NATIVE_SPEC_ERROR_SUBSCRIPTION_WITHOUT_INSTRUMENT_FEED
@ PF_NATIVE_SPEC_ERROR_INVALID_TIMEFRAME
@ PF_NATIVE_SPEC_ERROR_SUBSCRIPTION_FINER_THAN_AUXILIARY_FEED
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_ABORT_REPORTING
@ PF_NATIVE_SPEC_ERROR_SESSION_KEY_CHANGED_ON_REUSE
A reused host's session key changed.
@ PF_NATIVE_SPEC_ERROR_INVALID_INSTRUMENT_FEED_CLOSE
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_PRICE_GRID
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_CALCULATION_TRIGGER
@ PF_NATIVE_SPEC_ERROR_WRONG_PHASE
The CALL was refused before any field was judged: not in the phase it is legal in.
@ PF_NATIVE_SPEC_ERROR_INVALID_UNDETECTED_TIMEFRAME
@ PF_NATIVE_SPEC_ERROR_SUBSCRIPTION_WITHOUT_AUXILIARY_FEED
@ PF_NATIVE_SPEC_ERROR_EMPTY_REQUIRED_STRING
@ PF_NATIVE_SPEC_ERROR_EMBEDDED_NUL
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_GRID_ROUNDING
@ PF_NATIVE_SPEC_ERROR_SLIPPAGE_OUT_OF_RANGE
@ PF_NATIVE_SPEC_ERROR_INCOMPATIBLE_TIMEFRAMES
@ PF_NATIVE_SPEC_ERROR_INVALID_INTRABAR_PATH
@ PF_NATIVE_SPEC_ERROR_AUXILIARY_FEED_WITHOUT_TIMEFRAME
@ PF_NATIVE_SPEC_ERROR_UNRESOLVED_TIMEZONE
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_PATH_ORDER
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_CLOSE_EXECUTION
@ PF_NATIVE_SPEC_ERROR_AUXILIARY_FEED_NOT_FINER_THAN_INPUT
@ PF_NATIVE_SPEC_ERROR_NONE
Applied.
@ PF_NATIVE_SPEC_ERROR_INVALID_SESSION
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_MARGIN_EQUITY_BASIS
@ PF_NATIVE_SPEC_ERROR_INSTRUMENT_SUBSCRIPTION_BARS
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_OPEN_BAR_VIEW
@ PF_NATIVE_SPEC_ERROR_GRID_REQUIRES_PRICE_TICK
@ PF_NATIVE_SPEC_ERROR_NOT_FINITE_NONNEGATIVE
@ PF_NATIVE_SPEC_ERROR_INVALID_UTF8
@ PF_NATIVE_SPEC_ERROR_SUBSCRIPTION_WITHOUT_TIMEFRAME
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_RISK_DAY
@ PF_NATIVE_SPEC_ERROR_INVALID_SUBSCRIPTION_TIMEFRAME
@ PF_NATIVE_SPEC_ERROR_INSTRUMENT_ON_NON_INSTRUMENT_SERIES
@ PF_NATIVE_SPEC_ERROR_RUN_NUMBER_NOT_ABOVE_CONSUMED_HIGH_WATER
A reused host's run number did not exceed its high-water.
@ PF_NATIVE_SPEC_ERROR_INVALID_AUXILIARY_FEED_BAR
@ PF_NATIVE_SPEC_ERROR_UNKNOWN_REPORT_POLICY
@ PF_NATIVE_SPEC_ERROR_SUBSCRIPTION_FINER_THAN_INPUT
@ PF_NATIVE_REJECT_INVALID_QUANTITY_BASIS
@ PF_NATIVE_REJECT_OFF_GRID
@ PF_NATIVE_REJECT_INVALID_CAPACITY
@ PF_NATIVE_REJECT_PLACEMENT_ADMISSION
A SIZED request resolved at acceptance that the run's opening admission refuses at the sizing price.
@ PF_NATIVE_REJECT_INVALID_OWNER
@ PF_NATIVE_REJECT_INVALID_TRIGGER
@ PF_NATIVE_REJECT_INVALID_QUANTITY
@ PF_NATIVE_REJECT_INVALID_GROUP
@ PF_NATIVE_RISK_MAX_INTRADAY_LOSS
@ PF_NATIVE_RISK_MAX_CONSECUTIVE_LOSS_DAYS
@ PF_NATIVE_RISK_MAX_FILLS_PER_DAY
@ PF_NATIVE_RISK_MAX_DRAWDOWN
@ PF_NATIVE_MARGIN_CHECK_AFTER_APPLIED
The re-arm after a point's fills.
@ PF_NATIVE_MARGIN_CHECK_FX_ROLL
A step of the run's declared pf_native_fx_curve_v1: the first point the account converts at a new rat...
@ PF_NATIVE_MARGIN_CHECK_CALCULATION
A CalculationOnly model's calculation.
@ PF_NATIVE_MARGIN_CHECK_INTRABAR_SAMPLE
A delivered sample, after the script bar's first, of a PF_NATIVE_INTRABAR_LOWER_TF path matched as co...
@ PF_NATIVE_MARGIN_CHECK_BAR_OPEN
The script bar's open.
@ PF_NATIVE_LIFECYCLE_FAILED
@ PF_NATIVE_LIFECYCLE_RUNNING
@ PF_NATIVE_LIFECYCLE_READY
@ PF_NATIVE_LIFECYCLE_COMPLETED
@ PF_NATIVE_LIFECYCLE_UNCONFIGURED
@ PF_NATIVE_TRIGGER_LIMIT
p1 = price; fill_through makes it market-if-touched.
@ PF_NATIVE_TRIGGER_TRAIL
p1 = offset, p2 = arm price when trail_has_arm_price; trail_best_seed when trail_has_best_seed.
@ PF_NATIVE_TRIGGER_STOP
p1 = price.
@ PF_NATIVE_TRIGGER_STOP_LIMIT
p1 = stop, p2 = limit.
@ PF_NATIVE_TRIGGER_MARKET
p1, p2 ignored.
@ PF_NATIVE_ACTIVATION_TRAIL_TRIGGER
@ PF_NATIVE_ACTIVATION_STOP
@ PF_NATIVE_ACTIVATION_STOP_LIMIT
@ PF_NATIVE_ACTIVATION_TRAIL_ARM
@ PF_NATIVE_OPENED_LOT_FILL_POINT_ON_PATH
@ PF_NATIVE_OPENED_LOT_FILL_POINT_AFTER_PATH
@ PF_NATIVE_COMPLETION_STREAM_ENDED
@ PF_NATIVE_COMPLETION_BATCH_COMPLETE
@ PF_NATIVE_OPEN_BAR_VIEW_OPEN_ONLY
Its lookahead masked: H = L = C = open, volume 0.
@ PF_NATIVE_OPEN_BAR_VIEW_COMPLETE
The whole script bar (the default).
@ PF_NATIVE_SCOPE_NET_OF_SIBLINGS
@ PF_NATIVE_SCOPE_GROSS
@ PF_NATIVE_REDUCE_OWNER_OPENED
Exactly what the owner opened.
@ PF_NATIVE_REDUCE_SCOPE_FRACTION
intent_value fraction in (0, 1].
@ PF_NATIVE_REDUCE_EXPLICIT_UNITS
intent_value units.
@ PF_NATIVE_ANSWER_DEFAULT
Keep the kernel's own; the output is ignored.
@ PF_NATIVE_ANSWER_PROVIDED
Use the output.
@ PF_NATIVE_ANCHOR_FROM_OWNER_FILL
owner fill + anchor_offset (signed).
@ PF_NATIVE_ANCHOR_ABSOLUTE
The level written in the trigger.
@ PF_NATIVE_EVENT_INVALID_HANDLE
@ PF_NATIVE_EVENT_NO_EFFECT
@ PF_NATIVE_EVENT_RISK
@ PF_NATIVE_EVENT_MARGIN_CALL
@ PF_NATIVE_EVENT_ARMED
@ PF_NATIVE_EVENT_CANCELLED
@ PF_NATIVE_EVENT_RESERVATION_REDUCED
@ PF_NATIVE_EVENT_REPLACED
@ PF_NATIVE_EVENT_QUANTITY_BOUND
@ PF_NATIVE_EVENT_REJECTED
@ PF_NATIVE_EVENT_REPLACE_REJECTED
@ PF_NATIVE_EVENT_CLOSE_BOUND
@ PF_NATIVE_EVENT_ACTIVATED
@ PF_NATIVE_EVENT_DRIVER_POINT
@ PF_NATIVE_EVENT_ACCOUNT
@ PF_NATIVE_EVENT_DEFERRED_GROUP
@ PF_NATIVE_EVENT_NOT_WORKING
@ PF_NATIVE_EVENT_MATCH_REJECTED
@ PF_NATIVE_EVENT_TERMS_RESOLVED
@ PF_NATIVE_EVENT_ACCEPTED
@ PF_NATIVE_EVENT_APPLIED
@ PF_NATIVE_FAILURE_CALLBACK_EXCEPTION
A callback returned non-zero.
@ PF_NATIVE_FAILURE_SETTLEMENT_FAILURE
@ PF_NATIVE_FAILURE_INVALID_SPECIFICATION
A spec refused at configure.
@ PF_NATIVE_FAILURE_ABORTED
A cooperative abort.
@ PF_NATIVE_FAILURE_NONE
@ PF_NATIVE_FAILURE_PREFLIGHT
A bar array the driver refused.
@ PF_NATIVE_FAILURE_COUNTER_EXHAUSTED
@ PF_NATIVE_FAILURE_ALLOCATION
@ PF_NATIVE_FAILURE_PROJECTION_MISMATCH
@ PF_NATIVE_FAILURE_UNEXPECTED
@ PF_NATIVE_FAILURE_CONTRACT
A lifecycle misuse.
@ PF_NATIVE_FAILURE_CALENDAR
@ PF_NATIVE_FAILURE_UNSUPPORTED_SOURCE
@ PF_NATIVE_REMAINING_NO_TARGET
@ PF_NATIVE_REMAINING_UNITS
remaining_units is meaningful.
@ PF_NATIVE_REMAINING_FLATTEN_ALL
@ PF_NATIVE_REMAINING_UNBOUND
@ PF_NATIVE_REMAINING_DEFERRED
@ PF_NATIVE_RISK_FLATTEN_AND_BLOCK
@ PF_NATIVE_RISK_BLOCK_OPENINGS
@ PF_NATIVE_TRIGGER_STATE_LIMIT_READY
@ PF_NATIVE_TRIGGER_STATE_STOP_ACTIVE
@ PF_NATIVE_TRIGGER_STATE_STOP_LIMIT_PENDING
@ PF_NATIVE_TRIGGER_STATE_MARKET_READY
@ PF_NATIVE_TRIGGER_STATE_TRAIL_ACTIVE
@ PF_NATIVE_TRIGGER_STATE_TRAIL_WAIT_ARM
@ PF_NATIVE_TRIGGER_STATE_STOP_LIMIT_LIVE
@ PF_NATIVE_TRIGGER_STATE_STOP_IDLE
@ PF_NATIVE_TRIGGER_STATE_TRAIL_TRACK
void * pf_strategy_t
Opaque handle to a compiled strategy instance.
Definition pineforge.h:441
#define PF_API
Definition pineforge.h:83
Single OHLCV bar pushed into the engine.
Definition pineforge.h:140
One anchored leg's materialization, handed to pf_native_callbacks_v1::on_anchored_level exactly once,...
double owner_fill_price
Its resolved price.
uint64_t owner_lot_incarnation
The lot it opened.
uint64_t owner
The request whose fill arms the leg.
uint32_t trigger
pf_native_anchored_trigger_t.
double offset
The anchor's offset, price units.
uint32_t leg_side
pf_native_side_t the leg trades on.
uint64_t owner_applied_ordinal
That fill's applied execution.
uint8_t owner_cursor_path_phase
pf_native_path_phase_t.
double price_tick
The run's tick, 0 when none.
uint64_t leg
The anchored request.
double kernel_level
The level the kernel would install.
uint32_t version
PF_NATIVE_API_VERSION.
uint8_t owner_cursor_provenance
pf_native_price_provenance_t.
uint32_t struct_size
sizeof(pf_native_anchored_level_view_v1).
One applied execution, presented to on_applied.
uint64_t incarnation
The request that executed.
int64_t cycle_after
Position cycle after the fill.
double ticket
current_ticket at the fill.
int64_t cycle_before
Position cycle before the fill.
double resolved_price
The booked price after terms and slippage.
uint8_t terminal
1 when the request is finished.
uint8_t has_terminal_reason
1 when terminal_reason is meaningful.
uint32_t version
PF_NATIVE_API_VERSION.
uint32_t struct_size
sizeof(pf_native_applied_v1).
double closed_units
Units closed by this fill.
uint8_t terminal_reason
pf_native_terminal_reason_t, valid when has_terminal_reason.
uint64_t ordinal
Event ordinal.
double opened_units
Units opened by this fill.
uint64_t opened_lot_incarnation
The lot this fill opened, 0 when none.
double raw_price
The path price the match was found at.
double filled_working
Working units this fill consumed.
The C host's strategy logic.
int(* on_timeframe_bar)(void *user, const pf_bar_t *bar, uint32_t subscription, uint32_t completion, int64_t delivered_at_ms)
One completed bucket of a declared series.
uint32_t version
PF_NATIVE_API_VERSION.
int(* on_hash_extension)(void *user, uint64_t *digest)
The host's own durable state, folded into the broker-state hash — hash_host_extension.
int(* on_anchored_level)(void *user, const pf_native_anchored_level_view_v1 *view, double *level)
Where an anchored leg is armed — resolve_anchored_level.
int(* on_bar_open)(void *user, const pf_bar_t *bar, const pf_native_decision_v1 *at)
int(* on_applied)(void *user, const pf_native_applied_v1 *applied, const pf_native_decision_v1 *at)
int(* on_sub_bar)(void *user, const pf_bar_t *sub, const pf_native_decision_v1 *at)
One completed lower-timeframe sub-bar of a run that retains a lower feed — on_native_sub_bar.
int(* on_execution_terms)(void *user, const pf_native_terms_view_v1 *view, pf_native_terms_v1 *out)
The price half of resolve_execution_terms, consulted at EVERY matching candidate once installed.
int(* on_margin_call)(void *user, const pf_native_event_v1 *margin_call)
int(* on_bar)(void *user, const pf_bar_t *bar, const pf_native_decision_v1 *at)
int(* on_tick)(void *user, const pf_bar_t *bar, const pf_native_decision_v1 *at)
int(* on_run_begin)(void *user)
void * user
Opaque; handed back unchanged.
int(* on_lot_excursion)(void *user, const pf_native_lot_excursion_v1 *facts, double *favorable, double *adverse)
The favorable and adverse magnitudes of one closing lot — closed_lot_excursion.
int(* on_margin_requirement)(void *user, const pf_native_margin_view_v1 *view, pf_native_margin_decision_v1 *out)
The two numbers one check point is about to compare — resolve_margin_requirement.
int(* on_close_units)(void *user, const pf_native_close_view_v1 *view, double *units)
How many units a host-sized CLOSE takes — the units half of resolve_execution_terms (the price half i...
int(* on_input)(void *user, const pf_bar_t *bar, int32_t input_index, int32_t completes_script_interval)
int(* on_recalculate)(void *user, const pf_bar_t *bar, const pf_native_decision_v1 *at, uint32_t reason, const pf_native_applied_v1 *cause)
EVERY calculation of the run, including the script bar's own close — on_native_recalculate.
int(* on_margin_call_units)(void *user, const pf_native_margin_view_v1 *view, double *units)
The size of a kernel-issued liquidation, before it rests — resolve_margin_call_units.
uint32_t struct_size
sizeof(pf_native_callbacks_v1).
int(* on_precommit)(void *user, const pf_native_precommit_view_v1 *view, uint32_t *verdict)
The last gate before one execution's physical effect — validate_execution_precommit.
int(* on_margin_check)(void *user, const pf_native_margin_view_v1 *at, int32_t *allowed)
Whether this kernel check point is one the host's broker model shares — margin_check_allowed.
The facts a host-sized CLOSE is resolved from, handed to pf_native_callbacks_v1::on_close_units.
uint32_t is_buy
0/1: the side this candidate would trade on.
uint32_t struct_size
sizeof(pf_native_close_view_v1).
double position_units
The whole physical book, signed.
double scope_exposure_units
What the bound scope holds here.
double default_resolved_price
The price the kernel would settle at.
uint64_t incarnation
The request being resolved.
uint32_t version
PF_NATIVE_API_VERSION.
Where the kernel is, presented to every callback.
int64_t session_day_ordinal
The session day of script_interval_open_ms – on a 1D script, of script_interval_eligible_open_ms when...
int32_t sub_index
Sub-bar index inside the script bar.
int64_t decision_floor_ms
Lower bound a new request may be matched at.
int64_t next_input_session_day_ordinal
The session day of script_interval_next_input_open_ms.
uint8_t has_session_day
1 when the calendar keyed session_day_ordinal.
uint8_t reserved0[5]
Always 0.
int64_t effective_time_ms
The point's effective decision time.
int64_t script_interval_last_traded_close_ms
Its exclusive end of trading.
int64_t script_interval_eligible_open_ms
Its first in-session instant.
int32_t is_terminal_sub_bar
1 on the script bar's last sub-bar.
int32_t sub_count
Sub-bars in this script bar (1 when unmagnified).
uint32_t struct_size
sizeof(pf_native_decision_v1).
uint64_t ordinal
Matching-point ordinal.
int32_t interval_index
Script interval index.
int64_t script_interval_next_input_open_ms
The next actual eligible input open at or after that close: closed time skipped.
int64_t script_interval_next_period_open_ms
The next interval's nominal open, a closed slot included.
int64_t script_interval_open_ms
The script interval's nominal origin.
int64_t script_bar_open_ms
Open of the script bar under delivery.
uint8_t in_session
The script bar is in session.
uint8_t completion
pf_native_completion_kind_t.
uint8_t path_phase
pf_native_path_phase_t.
uint32_t version
PF_NATIVE_API_VERSION.
uint8_t quote_kind
pf_native_quote_kind_t; 0 when price is NaN.
uint8_t closes_session_day
It closes its session day.
uint8_t has_next_input_session_day
1 when it keyed next_input_session_day_ordinal.
uint8_t provenance
pf_native_price_provenance_t.
double price
Current quote, NaN outside an execution point.
int64_t sub_bar_open_ms
Open of the sub-bar under delivery.
uint8_t session_facts
1 when the three bytes below are written.
uint8_t has_script_interval
1 when the point has a script interval; the seven fields above are 0 otherwise.
uint8_t opens_session_day
It opens its session day.
One recorded event, read back by strategy_native_events_v1.
uint8_t terminal
APPLIED only.
uint64_t successor
REPLACED: the new handle.
uint64_t incarnation
Subject request, 0 when the kind has none.
uint32_t version
PF_NATIVE_API_VERSION.
uint32_t reason
Per-kind reason enumerator, 0 when none.
uint8_t provenance
Cursor pf_native_price_provenance_t.
int32_t interval_index
Cursor interval index.
int64_t effective_time_ms
Cursor effective time, 0 when the kind has no cursor.
uint32_t kind
pf_native_event_kind_t.
uint32_t struct_size
sizeof(pf_native_event_v1).
uint8_t path_phase
Cursor pf_native_path_phase_t.
uint64_t ordinal
Event ordinal; strictly increasing.
One closing lot's booking facts — ClosedLotExcursionFacts (RULING A48).
uint64_t entry_incarnation
The lot's opening request.
double carried_favorable
What the lot carried in, for a partial close.
double closed_qty
What this fill closes of it.
uint32_t struct_size
sizeof(pf_native_lot_excursion_v1).
double lot_qty
The whole lot.
uint8_t entry_bar_high_masked
The entry bar's high is not this trade's.
uint32_t version
PF_NATIVE_API_VERSION.
double entry_commission
This closing slice's share of the entry fee, in account currency.
uint8_t entry_bar_low_masked
The entry bar's low is not this trade's.
One kernel-issued liquidation that filled, whole — the C spelling of native_order::MarginCallEvent,...
double mark
The booked resolved price.
uint64_t incarnation
The kernel's liquidation request.
uint8_t cursor_path_phase
pf_native_path_phase_t.
uint8_t reserved1[2]
Always 0.
uint64_t applied_ordinal
The applied execution that booked it.
uint32_t struct_size
sizeof(pf_native_margin_call_v1).
double position_after
Signed book after it.
uint32_t version
PF_NATIVE_API_VERSION.
double position_before
Signed book before the reduction.
uint32_t reserved0
Always 0.
uint8_t cursor_provenance
pf_native_price_provenance_t.
uint32_t side
pf_native_side_t of the liquidated position.
double required
Maintenance requirement of the surviving book at mark.
uint64_t ordinal
The call's event ordinal.
double liquidation_price
The level re-solved for what is left.
double equity
Marked equity of the surviving book at mark.
double units
Units liquidated.
The host's answer to one requirement view — NativeMarginDecision.
uint32_t struct_size
sizeof(pf_native_margin_decision_v1).
uint32_t version
PF_NATIVE_API_VERSION.
The facts one margin hook is handed — the C spelling of NativeMarginRequirementView,...
uint8_t cursor_provenance
pf_native_price_provenance_t.
double required
Maintenance requirement of the whole position at mark.
uint8_t cursor_path_phase
pf_native_path_phase_t.
uint32_t version
PF_NATIVE_API_VERSION.
uint32_t kind
pf_native_margin_check_kind_t.
double signed_units
The book being measured.
double equity
Marked equity on the model's basis.
double mark
The price the breach is measured at.
uint32_t liquidation_resting
0/1: a liquidation rests from an earlier point.
uint32_t struct_size
sizeof(pf_native_margin_view_v1).
One open physical lot, copied out by strategy_native_open_lot_get_v1 — the C spelling of NativeOpenLo...
uint64_t ordinal
Position in the book, oldest first.
const char * entry_label
Borrowed; see the struct note.
double unrealized_pnl
Fee-net move to mark, account currency; NaN for a NaN mark.
double adverse_excursion
Largest move against the lot so far, account currency, >= 0.
uint32_t struct_size
sizeof(pf_native_open_lot_v1).
double entry_commission
Entry fee still on the lot, account currency; a partial realization takes its share with it.
int64_t entry_time_ms
Effective time of the opening fill.
uint32_t side
pf_native_side_t.
double signed_units
Remaining units: > 0 long, < 0 short.
double entry_price
Booked entry price.
uint32_t version
PF_NATIVE_API_VERSION.
double mark
The price the three fields below were marked at.
const char * entry_comment
Borrowed; see the struct note.
int64_t cycle
The position cycle the lot belongs to — the owner_cycle a BIND_OPENING(S) request names.
int32_t entry_bar_index
Script-bar index of the opening fill.
double favorable_excursion
Largest move for the lot so far, account currency, >= 0.
uint64_t entry_incarnation
The request whose fill opened the lot; never reused; 0 only for a legacy synthetic lot.
The last facts before one execution's physical effect, handed to pf_native_callbacks_v1::on_precommit...
uint32_t would_open
0/1: the fill opens a lot.
uint32_t current
1 for strategy_native_execute_current_v1.
uint8_t reserved1[2]
Always 0.
double realized_balance
After the fill, account currency.
double plan_units
See pf_native_plan_t.
double remaining_entry_cost
Paid costs on the resulting book.
uint8_t cursor_provenance
pf_native_price_provenance_t.
uint64_t incarnation
The request about to execute.
uint32_t reserved0
Always 0.
uint32_t incoming_short
0/1: the opened lot is short.
uint8_t cursor_path_phase
pf_native_path_phase_t.
uint32_t version
PF_NATIVE_API_VERSION.
uint32_t struct_size
sizeof(pf_native_precommit_view_v1).
const double * closed_row_pnl
closed_row_count values; borrowed.
uint32_t plan
pf_native_plan_t.
double marked_equity
After the fill, at its price.
uint32_t intent
pf_native_intent_t of that request.
One order request.
uint32_t reserve_percent_fee
0/1, SIZED only.
uint32_t owner
pf_native_owner_t.
double p1
Limit/stop price, or trail offset.
uint32_t visibility
pf_native_arm_visibility_t, WAIT_FOR_APPLIED only.
uint64_t group_id
MEMBER only.
uint32_t struct_size
sizeof(pf_native_request_v1).
uint32_t owner_n
Length of owner_incarnations.
uint32_t reduce_basis
pf_native_scope_basis_t, SCOPE_FRACTION only.
uint32_t capacity
pf_native_capacity_t.
uint32_t side
pf_native_side_t, SIZED only.
uint32_t intent
pf_native_intent_t.
uint32_t size_time
pf_native_size_time_t, SIZED only.
int64_t owner_cycle
BIND_OPENING / BIND_OPENINGS.
double anchor_offset
FROM_OWNER_FILL: signed offset.
uint32_t group_effect
pf_native_group_effect_t.
uint8_t reserved2[7]
Must be 0.
int64_t group_cohort
MEMBER only.
uint32_t reduce_claim
pf_native_scope_claim_t, SCOPE_FRACTION only.
double trail_best_seed
TRAIL: where the running best starts — a floor on it, the favourable one of this level and the arm's ...
uint8_t fill_through
LIMIT only: market-if-touched.
uint8_t anchor_offset_in_ticks
FROM_OWNER_FILL: the offset is a tick count.
double capacity_units
POINT_BUDGET only.
const uint64_t * owner_incarnations
Borrowed for the call only.
uint8_t trail_offset_in_ticks
TRAIL: p1 is a tick count, not a distance.
uint32_t version
PF_NATIVE_API_VERSION.
double p2
Stop-limit limit, or trail arm price.
uint32_t size_price
pf_native_size_price_t, SIZED only.
double intent_value
The intent's own scalar; see pf_native_intent_t.
uint32_t trigger
pf_native_trigger_t.
uint32_t arm_first_match
pf_native_arm_first_match_t.
uint32_t grid_policy
pf_native_grid_policy_t, SIZED only.
uint32_t reduce_size
pf_native_reduction_t, REDUCE only.
uint8_t trail_has_arm_price
TRAIL: p2 is the arm price.
uint32_t anchor
pf_native_anchor_t (L7).
uint8_t trail_has_best_seed
TRAIL: trail_best_seed is set.
uint64_t cohort
BIND_COHORT.
uint32_t size_basis
pf_native_size_basis_t, SIZED only.
uint32_t anchor_rounding
pf_native_anchor_rounding_t, FROM_OWNER_FILL only.
uint32_t group_kind
pf_native_group_t.
uint32_t arm_scope
pf_native_arm_scope_t.
The run's generic risk ledger — the C spelling of NativeRiskState (L9).
uint32_t has_reason
0/1: reason is meaningful.
uint32_t blocked
0/1: openings are refused right now.
uint32_t version
PF_NATIVE_API_VERSION.
uint32_t reason
pf_native_risk_limit_t that blocked.
double peak_equity
Running peak of the marked equity.
uint64_t fills_today
Applied fills counted in that day.
uint32_t consecutive_loss_days
Days that closed with a realized loss.
double day_open_equity
Equity the current day opened at.
uint32_t has_day
0/1: the ledger has reached a day.
uint32_t struct_size
sizeof(pf_native_risk_state_v1).
int64_t day_ordinal
The risk day, on the spec's day basis.
The run-specification fields pf_native_run_spec_v1 predates.
uint32_t price_grid
pf_native_price_grid_t.
uint32_t reserved1
Must be 0.
uint32_t report_open_position_at_end
0/1; PF_NATIVE_REPORT_KERNEL_RECORDED only.
uint32_t risk_has_max_intraday_loss
0/1.
const char * intrabar_tf
The finer timeframe; LOWER_TF only, non-NULL.
uint32_t abort_reporting
pf_native_abort_reporting_t.
uint32_t present_mask
pf_native_spec_ext_mask_t bits.
const char * margin_liquidation_comment
Comment of the same; NULL is "".
uint32_t intrabar_sample_eligibility
pf_native_sample_eligibility_t, LOWER_TF only.
uint32_t struct_size
sizeof(pf_native_run_spec_ext_v1).
uint32_t open_bar_view
pf_native_open_bar_view_t.
uint32_t risk_has_max_fills_per_day
0/1.
int32_t intrabar_samples
Samples per script bar; LOWER_TF and SYNTHESIZED.
const pf_bar_t * auxiliary_bars
Strictly increasing bars; copied.
int32_t intrabar_volume_weighted_min_samples
uint32_t event_retention
pf_native_event_retention_t.
double risk_max_intraday_loss
Threshold; account currency unless percent.
double margin_initial_long
0 = maintenance-only side: no kernel opening requirement, host owns admission; legal only with that s...
double margin_initial_short
0 = maintenance-only; see above.
uint32_t feed_tolerance
pf_native_feed_tolerance_t bits.
uint32_t intrabar_kind
pf_native_intrabar_kind_t.
double quantity_tolerance
Units, finite and positive: NativeRunSpec::quantity_tolerance, two quantities within it of each other...
uint32_t version
PF_NATIVE_API_VERSION.
const pf_native_subscription_v1 * subscriptions
Borrowed for the call.
uint32_t slot_label_policy
pf_native_slot_label_t.
const uint32_t * subscription_sources
Optional, borrowed for the call: subscriptions_n entries of pf_native_series_source_t,...
const pf_bar_t * intrabar_bars
The finer feed; borrowed for the call, copied.
uint32_t reserved2
Must be 0.
uint32_t report_policy
pf_native_report_policy_t.
double risk_max_drawdown
Threshold; account currency unless percent.
int32_t intrabar_n
Length of intrabar_bars; LOWER_TF only.
uint32_t risk_max_drawdown_percent
0/1: the value is a percent of the running equity peak, out of 100.
uint32_t margin_sizing
pf_native_liquidation_sizing_t.
uint32_t path_order
pf_native_path_order_t.
uint32_t risk_max_intraday_loss_percent
0/1: percent of the day's opening equity.
uint32_t risk_max_fills_per_day
Applied fills, when the flag is 1.
uint32_t calculation
pf_native_calc_trigger_t.
uint32_t risk_max_consecutive_loss_days
Days, when the flag is 1.
double margin_shortfall_multiple
The C++ default is 1.0, not 0: a PRESENT block has every field read, so a zero-filled struct must sti...
uint32_t risk_has_max_consecutive_loss_days
0/1.
uint32_t margin_level_base
pf_native_margin_level_base_t.
int32_t intrabar_volume_weighted_max_samples
const char * margin_liquidation_label
Ticket of a kernel liquidation; NULL is "".
uint32_t intrabar_volume_weighted
0/1.
const char * auxiliary_tf
Non-NULL feed timeframe literal.
uint32_t margin_check
pf_native_liquidation_check_t.
uint32_t risk_has_max_drawdown
0/1.
uint32_t risk_day_basis
pf_native_risk_day_t.
uint32_t risk_action
pf_native_risk_action_t.
uint32_t margin_equity_basis
pf_native_margin_equity_basis_t.
uint32_t grid_rounding
pf_native_grid_rounding_t.
uint32_t intrabar_distribution
pf_magnifier_distribution_t.
int32_t auxiliary_n
Length of auxiliary_bars.
uint32_t max_recalculations_per_point
Fill-cascade bound; 0 is legal.
Versioned native run specification.
Definition pineforge.h:500
The run's lifecycle and its typed failure.
uint64_t consumed_high_water
uint64_t failure_ordinal
The point the failure was latched at, 0 when absent.
uint32_t failure_operation
pf_native_failure_operation_t.
uint32_t phase
pf_native_run_phase_t while Running.
uint32_t lifecycle
pf_native_lifecycle_t.
uint32_t failure_discriminator
The kernel's own word beside the code, as C++ NativeFailure::discriminator holds it: the request core...
uint32_t completion
pf_native_completion_t once Completed.
uint32_t struct_size
sizeof(pf_native_state_v1).
uint32_t failure_code
pf_native_failure_code_t; PF_NATIVE_FAILURE_CALLBACK_EXCEPTION for a callback that returned non-zero.
uint32_t version
PF_NATIVE_API_VERSION.
One declared higher-timeframe series of pf_native_run_spec_ext_v1.
const pf_bar_t * authoritative_bars
Optional exchange bars; copied.
uint32_t struct_size
sizeof(pf_native_subscription_v1).
uint32_t gaps
pf_native_gaps_t.
uint32_t lookahead
pf_native_lookahead_t.
int32_t authoritative_n
Length of authoritative_bars.
const char * tf
Non-NULL timeframe literal.
The price half of the terms pf_native_callbacks_v1::on_execution_terms answers — ExecutionTerms less ...
uint32_t shape
pf_native_opening_shape_t.
uint32_t version
PF_NATIVE_API_VERSION.
double resolved_price
The price to settle at.
uint32_t grid_policy
pf_native_grid_policy_t.
uint32_t struct_size
sizeof(pf_native_terms_v1).
The facts of one matching candidate, handed to pf_native_callbacks_v1::on_execution_terms — the price...
uint8_t cursor_path_phase
pf_native_path_phase_t.
double remaining_units
Valid when remaining_kind is UNITS.
uint32_t trigger
pf_native_trigger_t of that request.
uint32_t shared_cursor_collision
0/1: a rounded quote shared with another level.
uint32_t version
PF_NATIVE_API_VERSION.
double scope_exposure_units
What the bound scope holds here.
double default_resolved_price
The kernel's own settlement price.
double active_fx
The account rate there.
uint32_t driver_class
pf_native_driver_class_t.
uint8_t cursor_provenance
pf_native_price_provenance_t.
double raw_price
The path price the match was found at.
uint8_t reserved1[2]
Always 0.
uint64_t incarnation
The request being resolved.
uint32_t remaining_kind
pf_native_remaining_t.
uint32_t reserved0
Always 0.
uint32_t has_trigger_level
0/1.
double trigger_level
The level crossed, when has_trigger_level.
uint32_t intent
pf_native_intent_t of that request.
uint32_t struct_size
sizeof(pf_native_terms_view_v1).
uint32_t price_rule
pf_native_price_rule_t.
uint32_t quote_kind
pf_native_quote_kind_t.
uint32_t price_kind
pf_native_candidate_price_t.
uint32_t is_buy
0/1: the side this candidate trades on.
uint32_t trigger_state
pf_native_trigger_state_t.
int64_t fx_effective_time_ms
Where the account rate is read.
double position_units
The whole physical book, signed.
The calendar interval of the bucket delivered to pf_native_callbacks_v1::on_timeframe_bar.
uint32_t struct_size
sizeof(pf_native_timeframe_interval_v1).
uint32_t version
PF_NATIVE_API_VERSION.
The trail projection of strategy_native_trail_state_v1 — the C spelling of NativeTrailState.
double best_price
Running best; 0 before the arm.
uint64_t activation_ordinal
The TrailArm event; 0 before the arm.
double current_level
The stop the best is riding; 0 before the arm.
uint32_t struct_size
sizeof(pf_native_trail_state_v1).
uint32_t version
PF_NATIVE_API_VERSION.
uint32_t activated
0/1: the arm price has been reached.
One live request, copied out by strategy_native_working_get_v1.
double p2
Trigger level 2 (stop-limit limit / trail arm when trail_has_arm_price).
double capacity_units
Point budget, 0 for immediate capacity.
uint32_t anchor
pf_native_anchor_t as the request stands.
double p1
Trigger level 1 (limit / stop / trail offset).
uint32_t visibility
pf_native_arm_visibility_t, WAIT_FOR_APPLIED only.
uint32_t anchor_rounding
pf_native_anchor_rounding_t, FROM_OWNER_FILL only.
double remaining_units
Valid when remaining_kind is UNITS.
uint32_t remaining_kind
pf_native_remaining_t.
uint32_t struct_size
sizeof(pf_native_working_v1).
uint32_t trail_has_arm_price
TRAIL: 1 when p2 is the arm price, 0 when the trail carries none.
uint64_t owner_handle
WAIT_FOR_APPLIED: the parent; BIND_OPENING: the opening; BIND_OPENINGS: the first of them as the kern...
uint32_t origin
pf_native_origin_t.
int64_t decision_time_lower_bound
Birth: earliest matchable time.
const char * comment
Borrowed; see the struct note.
uint64_t acceptance_ordinal
Birth: the accepting event.
uint32_t version
PF_NATIVE_API_VERSION.
uint32_t intent
pf_native_intent_t as accepted.
uint32_t group_kind
pf_native_group_t as accepted.
uint32_t arm_scope
pf_native_arm_scope_t, WAIT_FOR_APPLIED only.
double intent_value
The intent's own scalar, 0 when it has none.
uint32_t owner
pf_native_owner_t as accepted.
uint32_t capacity
pf_native_capacity_t as accepted.
uint32_t owner_n
How many owner handles the relation names.
const char * label
Borrowed; see the struct note.
uint64_t incarnation
The request's handle.
uint32_t group_effect
pf_native_group_effect_t, 0 when no group.
uint32_t trigger
pf_native_trigger_t as accepted.
uint32_t reserved1
Always 0.
int64_t owner_cycle
BIND_OPENING / BIND_OPENINGS: the bound cycle.
uint32_t trigger_state
pf_native_trigger_state_t.
double anchor_offset
FROM_OWNER_FILL: the signed offset, price units.
uint32_t arm_first_match
pf_native_arm_first_match_t, WAIT_FOR_APPLIED only.
Backtest report filled by run_backtest / run_backtest_full.
Definition pineforge.h:366