PineForge v1.5.0-rc.1-1-g4e01e96b
Deterministic PineScript v6 backtest runtime — C ABI reference
Loading...
Searching...
No Matches
selected_window.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: Apache-2.0
3 *
4 * selected_window.h - public C ABI for the selected-window configuration and
5 * counters, version 1.
6 *
7 * Declarations only. The runtime supplies the definitions.
8 *
9 * Layout: natural C alignment, fixed-width scalars, no struct packing. Each
10 * struct_size must equal sizeof its declaration, and each version must be 1.
11 * Expected LP64 sizes are 24 (configuration) and 80 (counts).
12 */
13
14#ifndef PINEFORGE_SELECTED_WINDOW_H
15#define PINEFORGE_SELECTED_WINDOW_H
16
17#include <stdint.h>
18
19#include <pineforge/pineforge.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/** Selected-window configuration, handed to strategy_set_selected_window_v1().
26 * start_ms and end_ms are signed JSON-safe integer milliseconds with
27 * start_ms < end_ms. The selected window is [start_ms, end_ms); preroll is
28 * before start_ms. */
35
36/** Native-owned counts for the latest attempt, filled by
37 * strategy_selected_window_counts_v1(). run_generation, attempt_serial and
38 * attempt_generation are the three identities the caller correlates with
39 * pf_execution_observation_v1 (see execution_observer.h).
40 *
41 * Counts are facts of actual successful primary input and script consumption,
42 * not caller-provided expectations, and a host's diagnostic presentation does
43 * not rewrite them. On success, fed_input_bars equals preroll_input_bars plus
44 * window_input_bars, and fed_script_bars equals preroll_script_bars plus
45 * window_script_bars. */
59
60/** Returns the selected-window ABI version, 1. */
62
63/** Sets the pending selected-window configuration, or clears it with a NULL
64 * descriptor. A NULL descriptor disables selection for the next admitted
65 * generation. The setter copies only start_ms and end_ms.
66 *
67 * Returns 0 when accepted; -1 for an invalid handle, struct_size, version or
68 * bounds; -2 for an unsupported execution contract (not a purity declaration
69 * or an override detector, and not permission to reject a custom presentation
70 * host); -3 for a nonquiescent or reentrant call; -4 when required private
71 * storage cannot be allocated. Every refusal leaves the configuration
72 * unchanged, and no exception crosses C.
73 *
74 * The setter is quiescent only outside execution, capture and observer
75 * dispatch, including outside the existing preparing_begin, in_callback and
76 * processing_input barriers. Setting or clearing changes pending configuration
77 * only: it never reopens the provenance or results of an existing generation,
78 * rewrites the latest attempt or changes an existing capture. Configuration is
79 * copied into admitted state after the last begin refusal or reset and before
80 * the first admitted host callback, and a refused begin consumes no new
81 * selected generation. Copies and moves that discard the private consumer also
82 * discard pending configuration and any owned result, but preserve closed
83 * provenance. */
86
87/** Copies one complete counts snapshot for the latest attempt into *out. The
88 * caller first sets out->struct_size and out->version.
89 *
90 * Returns 0 with one complete snapshot only when the latest attempt owns a
91 * successful selected Results generation. Returns -1 for a null handle or
92 * output, or a wrong struct_size or version. Returns -2 when no such result
93 * belongs to the latest attempt (fresh, copied, OFF, live, refused, failed,
94 * aborted or observer-faulted). On failure, valid caller storage is unchanged.
95 *
96 * The getter never executes host code, allocates a missing consumer or
97 * materializes a report. Counts do not open early inside the observer, and
98 * these counters never authorize charges. */
101
102#ifdef __cplusplus
103} /* extern "C" */
104#endif
105
106#endif /* PINEFORGE_SELECTED_WINDOW_H */
void * pf_strategy_t
Opaque handle to a compiled strategy instance.
Definition pineforge.h:436
#define PF_API
Definition pineforge.h:83
uint32_t pf_selected_window_version(void)
Returns the selected-window ABI version, 1.
int strategy_set_selected_window_v1(pf_strategy_t, const pf_selected_window_config_v1 *)
Sets the pending selected-window configuration, or clears it with a NULL descriptor.
int strategy_selected_window_counts_v1(pf_strategy_t, pf_selected_window_counts_v1 *)
Copies one complete counts snapshot for the latest attempt into *out.
Selected-window configuration, handed to strategy_set_selected_window_v1().
Native-owned counts for the latest attempt, filled by strategy_selected_window_counts_v1().