172#ifndef PINEFORGE_NATIVE_C_API_H
173#define PINEFORGE_NATIVE_C_API_H
184#define PINEFORGE_HAS_NATIVE_C_API_V1 1
188#define PF_NATIVE_API_VERSION 1
202#define PF_NATIVE_OK 0
203#define PF_NATIVE_E_HANDLE -1
204#define PF_NATIVE_E_STRUCT -2
205#define PF_NATIVE_E_TAG -3
206#define PF_NATIVE_E_ARGUMENT -4
207#define PF_NATIVE_E_STATE -5
209#define PF_NATIVE_E_REJECTED -6
210#define PF_NATIVE_E_UNSUPPORTED -7
211#define PF_NATIVE_E_EXCEPTION -8
212#define PF_NATIVE_E_NOT_WORKING -9
213#define PF_NATIVE_E_INVALID_TARGET -10
214#define PF_NATIVE_E_RUN_FAILED -11
215#define PF_NATIVE_E_REFUSED -12
223#define PF_NATIVE_ABSENT 1
228#define PF_NATIVE_FAILURE_CALLBACK 5
236typedef enum pf_native_intent_e {
249typedef enum pf_native_reduction_e {
256typedef enum pf_native_scope_claim_e {
262typedef enum pf_native_side_e {
268typedef enum pf_native_size_basis_e {
274typedef enum pf_native_size_time_e {
280typedef enum pf_native_grid_policy_e {
286typedef enum pf_native_trigger_e {
295typedef enum pf_native_anchor_e {
303typedef enum pf_native_anchor_rounding_e {
315typedef enum pf_native_arm_visibility_e {
321typedef enum pf_native_capacity_e {
327typedef enum pf_native_owner_e {
342typedef enum pf_native_group_e {
348typedef enum pf_native_group_effect_e {
359typedef enum pf_native_request_field_e {
365typedef enum pf_native_price_rule_e {
371typedef enum pf_native_execute_outcome_e {
381typedef enum pf_native_refusal_e {
394typedef enum pf_native_lifecycle_e {
415typedef enum pf_native_event_kind_e {
442typedef enum pf_native_risk_limit_e {
452typedef enum pf_native_risk_day_e {
461typedef enum pf_native_risk_action_e {
467typedef enum pf_native_remaining_e {
476typedef enum pf_native_trigger_state_e {
489typedef enum pf_native_spec_ext_mask_e {
514typedef enum pf_native_series_source_e {
526typedef enum pf_native_size_price_e {
537typedef enum pf_native_scope_basis_e {
545typedef enum pf_native_liquidation_check_e {
553typedef enum pf_native_margin_equity_basis_e {
560typedef enum pf_native_margin_level_base_e {
570typedef enum pf_native_intrabar_kind_e {
579typedef enum pf_native_sample_eligibility_e {
587typedef enum pf_native_slot_label_e {
595typedef enum pf_native_feed_tolerance_e {
606typedef enum pf_native_path_order_e {
613typedef enum pf_native_abort_reporting_e {
622typedef enum pf_native_calc_reason_e {
633typedef enum pf_native_margin_check_kind_e {
654typedef enum pf_native_answer_e {
1060#define PF_NATIVE_REQUEST_V1_BASE_SIZE \
1061 ((uint32_t)offsetof(pf_native_request_v1, anchor_rounding))
1067#define PF_NATIVE_REQUEST_V1_ANCHOR_SIZE \
1068 ((uint32_t)offsetof(pf_native_request_v1, size_price))
1231#define PF_NATIVE_RUN_SPEC_EXT_V1_BASE_SIZE \
1232 ((uint32_t)offsetof(pf_native_run_spec_ext_v1, risk_has_max_drawdown))
1236#define PF_NATIVE_RUN_SPEC_EXT_V1_RISK_SIZE \
1237 ((uint32_t)offsetof(pf_native_run_spec_ext_v1, intrabar_kind))
1243#define PF_NATIVE_RUN_SPEC_EXT_V1_POLICY_SIZE \
1244 ((uint32_t)offsetof(pf_native_run_spec_ext_v1, auxiliary_tf))
1278 int32_t completes_script_interval);
1285 uint32_t completion, int64_t delivered_at_ms);
1351 double* favorable,
double* adverse);
1370#define PF_NATIVE_CALLBACKS_V1_BASE_SIZE \
1371 ((uint32_t)offsetof(pf_native_callbacks_v1, on_recalculate))
1432 uint64_t* incarnation, uint32_t* reject);
1451 uint64_t* successor);
1503 uint32_t price_rule, uint32_t* refusal);
1508 double* average_price, uint64_t* lots);
1649 uint64_t incarnation);
1653 uint64_t incarnation);
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_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_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 at the current cursor — 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_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_cancel_v1(pf_strategy_t s, uint64_t incarnation)
Cancel one live request.
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_state_v1(pf_strategy_t s, pf_native_state_v1 *out)
Read the run's lifecycle and typed failure into out.
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_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_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_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_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_liquidation_check_t
When the kernel tests the maintenance requirement — NativeLiquidationCheck, the margin_check field of...
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_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_abort_reporting_t
How a cooperative abort is presented — NativeAbortReporting.
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_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_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_price_rule_t
Price rule of an immediate execution.
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_request_field_t
Which identity text strategy_native_cancel_where_v1 compares.
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_capacity_t
Capacity — the alternative index of native_order::Capacity.
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_anchor_rounding_t
How a materialized anchored level snaps onto the run's price tick ladder — native_order::NativeAnchor...
pf_native_margin_level_base_t
Which base the liquidation level is solved from — NativeLiquidationLevelBase.
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_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_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
The cohort close, and nothing else; see PF_NATIVE_OWNER_BIND_COHORT.
@ PF_NATIVE_INTENT_FLATTEN
Close the whole book.
@ PF_NATIVE_INTENT_REVERSE_TO
intent_value target signed exposure.
@ 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_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_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_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_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_INTRABAR
The retained intrabar execution path.
@ 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_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_SIZE_PRICE_RESOLVED
@ PF_NATIVE_SIZE_PRICE_SIGNAL
@ PF_NATIVE_SIZE_PRICE_SIGNAL_ON_TICK
@ 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_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_PRICE_AS_PRESENTED
@ PF_NATIVE_PRICE_NEAREST_TICK
@ PF_NATIVE_MARGIN_EQUITY_BEFORE_OPEN_COMMISSION
@ PF_NATIVE_MARGIN_EQUITY_MARKED
@ PF_NATIVE_FIELD_COMMENT
@ 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_CAPACITY_IMMEDIATE
Whole remaining at one point.
@ PF_NATIVE_CAPACITY_POINT_BUDGET
capacity_units per matching point.
@ 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_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_MARGIN_LEVEL_MARKED_EQUITY
@ PF_NATIVE_MARGIN_LEVEL_REALIZED_ONLY
@ 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_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.
@ PF_NATIVE_TRIGGER_STOP
p1 = price.
@ PF_NATIVE_TRIGGER_STOP_LIMIT
p1 = stop, p2 = limit.
@ PF_NATIVE_TRIGGER_MARKET
p1, p2 ignored.
@ PF_NATIVE_SCOPE_NET_OF_SIBLINGS
@ 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_MARGIN_CALL
@ 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_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.
Single OHLCV bar pushed into the engine.
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
AppliedTerminalReason, 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)
uint32_t version
PF_NATIVE_API_VERSION.
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_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,...
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_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.
int64_t cursor_effective_time_ms
uint64_t incarnation
The request being resolved.
uint32_t version
PF_NATIVE_API_VERSION.
Where the kernel is, presented to every callback.
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 effective_time_ms
The point's effective decision time.
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_bar_open_ms
Open of the script bar under delivery.
uint8_t completion
NativeCompletionKind.
uint8_t path_phase
NativePathPhase.
uint32_t version
PF_NATIVE_API_VERSION.
uint8_t quote_kind
NativeCurrentQuoteKind; 0 when price is NaN.
uint8_t provenance
NativePriceProvenance.
double price
Current quote, NaN outside an execution point.
int64_t sub_bar_open_ms
Open of the sub-bar under delivery.
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 NativePriceProvenance.
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 NativePathPhase.
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.
uint8_t entry_bar_low_masked
The entry bar's low is not this trade's.
The host's answer to one requirement view — NativeMarginDecision.
uint32_t force_breach
0/1.
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
NativePriceProvenance.
double required
Maintenance requirement of the whole position at mark.
uint8_t cursor_path_phase
NativePathPhase.
uint32_t version
PF_NATIVE_API_VERSION.
uint32_t kind
pf_native_margin_check_kind_t.
double signed_units
The book being measured.
int32_t cursor_interval_index
int64_t cursor_effective_time_ms
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.
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.
int64_t group_cohort
MEMBER only.
uint32_t reduce_claim
pf_native_scope_claim_t, SCOPE_FRACTION only.
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 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).
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.
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
NativePriceGrid.
uint32_t reserved1
Must be 0.
double margin_maintenance_short
uint32_t report_open_position_at_end
0/1; KernelRecorded only.
uint32_t risk_has_max_intraday_loss
0/1.
const char * intrabar_tf
The finer timeframe; LOWER_TF only, non-NULL.
double margin_maintenance_long
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 margin_has_maintenance_long
uint32_t open_bar_view
NativeOpenBarView.
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
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.
uint32_t margin_has_maintenance_short
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 report_policy
NativeReportPolicy.
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
NativeLiquidationSizing.
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
NativeCalculationTrigger.
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 margin_has_min_units
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
NativeGridRounding.
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.
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
NativeFailureOperation.
uint32_t phase
NativeRunPhase while Running.
uint32_t lifecycle
pf_native_lifecycle_t.
int64_t decision_floor_ms
uint32_t failure_discriminator
uint32_t completion
NativeCompletion once Completed.
uint32_t struct_size
sizeof(pf_native_state_v1).
uint32_t failure_code
NativeFailureCode; PF_NATIVE_FAILURE_CALLBACK 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
0 = barmerge.gaps_off, 1 = gaps_on.
uint32_t lookahead
0 = barmerge.lookahead_off, 1 = lookahead_on.
int32_t authoritative_n
Length of authoritative_bars.
const char * tf
Non-NULL timeframe literal.
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).
double capacity_units
Point budget, 0 for immediate capacity.
double p1
Trigger level 1 (limit / stop / trail offset).
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 origin
RequestOrigin: 0 host, 1 kernel liquidation, 2 kernel risk.
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.
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.
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 trigger_state
pf_native_trigger_state_t.
Backtest report filled by run_backtest / run_backtest_full.