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