PineForge v1.5.0-rc.1-2-g90c12b98
Deterministic PineScript v6 backtest runtime — C ABI reference
Loading...
Searching...
No Matches
selected_window_plan.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: Apache-2.0
3 *
4 * selected_window_plan.h - public C bridge to the selected primary planner
5 * (pineforge::plan_selected_primary, selected_window_plan.hpp), version 1.
6 *
7 * The definitions live in the standalone window-plan shared library (a CMake
8 * target named in CMakeLists.txt, installed as a shared object on
9 * Linux). It links only the kernel archive: it is not a strategy library, loads
10 * no strategy, runs no host or library callback and exports nothing of the
11 * compiled-strategy ABI in pineforge.h. A caller names the helper by an absolute
12 * path from its own pinned build. C++ callers may keep linking PineForge::kernel
13 * and call the C++ planner directly.
14 *
15 * Layout: natural C alignment, fixed-width scalars, no struct packing. The
16 * caller presets struct_size to sizeof of its declaration and version to 1 in
17 * both descriptors. Expected LP64 sizes are 80 (request) and 248 (result).
18 *
19 * Rows: a read-only array of pf_bar_t (pineforge.h: five doubles, then the int64
20 * Unix-millisecond timestamp), which the bridge reads in place as the identical
21 * pineforge::Bar. Only the timestamps are read; no row is copied. The array and
22 * all five strings need only stay valid for the duration of the call; the bridge
23 * keeps nothing, owns nothing it hands back, and has no free function.
24 */
25
26#ifndef PINEFORGE_SELECTED_WINDOW_PLAN_H
27#define PINEFORGE_SELECTED_WINDOW_PLAN_H
28
29#include <stdint.h>
30
31#include <pineforge/pineforge.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37/** One selected-window planning request. Field meanings are those of the C++
38 * SelectedPlanRequest: start_ms (T), end_ms (E) and fed_start_ms (F) are
39 * Unix milliseconds, preroll_bars is N, and the five strings are the input
40 * timeframe, the script timeframe, the chart and engine timezones and the
41 * session.
42 *
43 * All five strings must be non-NULL, NUL-terminated UTF-8. They are copied
44 * during the call. An empty chart_timezone, engine_timezone or session keeps
45 * the C++ default meaning; an empty timeframe is a planner refusal, not a
46 * bridge failure. feed_tolerant is exactly 0 or 1. */
48 uint32_t struct_size;
49 uint32_t version;
50 int64_t start_ms;
51 int64_t end_ms;
52 int64_t fed_start_ms;
53 uint32_t preroll_bars;
54 uint32_t feed_tolerant;
55 const char *input_tf;
56 const char *script_tf;
57 const char *chart_timezone;
58 const char *engine_timezone;
59 const char *session;
61
62/** One complete planner result, plain data, written whole by a successful call.
63 *
64 * status is the C++ SelectedPlanStatus mapped explicitly, not inferred from the
65 * enumerator's width: 0 Ok, 1 RequestInvalid, 2 CalendarUnsupported,
66 * 3 BoundaryUnaligned, 4 FeedRangeInvalid, 5 RowsUnordered, 6 InternalError.
67 * bound is -1 (no boundary detail), 0 (T), 1 (E) or 2 (F). Every other field
68 * has the meaning and the equalities of the C++ SelectedPrimaryPlan.
69 *
70 * present_mask bit i (0..7) says whether the i-th of the eight optional
71 * timestamps is present, in their field order below: preroll_first_bar_ms,
72 * preroll_last_bar_ms, supplied_first_data_ms, supplied_last_data_ms,
73 * fed_first_data_ms, fed_last_data_ms, window_first_data_ms,
74 * window_last_data_ms. An absent timestamp is zero, and a zero with its bit set
75 * is a real timestamp. shortfall and complete_pending_preroll_at_horizon are
76 * exactly 0 or 1; reserved is 0. option is ASCII, NUL-terminated and
77 * zero-padded (the C++ option string, at most 31 characters). */
112
113/** Returns the selected-planner C bridge version, 1. */
115
116/** Plans the primary rows of one selected-window request.
117 *
118 * Returns 0 when one whole result was written to *out, INCLUDING every planner
119 * refusal (a refusal is carried in out->status, never in the return value).
120 * Returns -1 for a NULL request or output, a wrong struct_size or version in
121 * either descriptor, a NULL string pointer, a feed_tolerant other than 0 or 1,
122 * or a count that does not fit size_t; -2 when memory could not be allocated;
123 * -3 for any other bridge failure or broken bridge invariant (for example a
124 * planner option longer than 31 characters, which is never truncated). On every
125 * negative return a valid caller output is byte-unchanged.
126 *
127 * rows may be NULL only with count 0. A NULL rows with a positive count is not
128 * dereferenced by the bridge: the planner refuses it as RequestInvalid. The
129 * bridge builds a local result and commits it to *out with one assignment, calls
130 * no host or library callback, and lets no exception cross C. */
132 const pf_bar_t *rows, uint64_t count,
134
135#ifdef __cplusplus
136} /* extern "C" */
137#endif
138
139#endif /* PINEFORGE_SELECTED_WINDOW_PLAN_H */
#define PF_API
Definition pineforge.h:83
int pf_plan_selected_primary_v1(const pf_selected_plan_request_v1 *, const pf_bar_t *rows, uint64_t count, pf_selected_plan_result_v1 *)
Plans the primary rows of one selected-window request.
uint32_t pf_selected_plan_version(void)
Returns the selected-planner C bridge version, 1.
Single OHLCV bar pushed into the engine.
Definition pineforge.h:140
One selected-window planning request.
One complete planner result, plain data, written whole by a successful call.