24 if (args.
bars && args.
n > 0) {
27 static_cast<std::size_t
>(args.
n));
37 retained_ = std::move(next);
38 retained_n_ = retained_.bars.size();
39 confirmed_input_bars_ = {};
40 confirmed_input_next_ = 0;
41 confirmed_input_count_ = 0;
42 confirmed_open_input_bars_ = {};
43 confirmed_open_input_next_ = 0;
44 confirmed_open_input_count_ = 0;
45 reset_consumed_digests();
49 if (retained_.is_stream)
return;
50 fold_consumed_digests();
54void PineScheduler::reset_consumed_digests() noexcept {
55 consumed_script_cursor_.reset();
56 consumed_bars_folded_ = 0;
57 consumed_bars_digest_ = 1469598103934665603ULL;
58 consumed_completes_folded_ = 0;
59 consumed_completes_digest_ = 1469598103934665603ULL;
60 consumed_boundaries_folded_ = 0;
61 consumed_boundaries_digest_ = 1469598103934665603ULL;
64void PineScheduler::reset_language() {
77 current_script_open_ms_ = 0; saw_open_fill_ =
false; open_point_fills_ = 0;
78 current_script_bar_ = {}; current_script_bar_valid_ =
false;
79 source_bar_count_ = 0; expected_source_bars_ = 0; applied_cursor_ = 0;
80 coof_callback_script_open_ = std::numeric_limits<std::int64_t>::min();
81 last_published_script_open_ms_ = std::numeric_limits<std::int64_t>::min();
82 prior_input_script_open_ms_ = std::numeric_limits<std::int64_t>::min();
83 awaiting_legacy_script_open_ms_ = std::numeric_limits<std::int64_t>::min();
84 last_stream_input_open_ms_ = std::numeric_limits<std::int64_t>::min();
85 input_script_cursor.reset();
86 input_script_size_ = 0;
87 uses_aux_security_feed_ =
false;
88 input_is_observed_ticks_ =
false;
89 confirmed_input_bars_ = {};
90 confirmed_input_next_ = 0;
91 confirmed_input_count_ = 0;
92 confirmed_open_input_bars_ = {};
93 confirmed_open_input_next_ = 0;
94 confirmed_open_input_count_ = 0;
95 deferred_boundary_input_ = {};
96 reset_consumed_digests();
100 if (language_._src_series_active_) {
101 language_.coof_checkpoint_src_open_ = language_._src_open_;
102 language_.coof_checkpoint_src_high_ = language_._src_high_;
103 language_.coof_checkpoint_src_low_ = language_._src_low_;
104 language_.coof_checkpoint_src_close_ = language_._src_close_;
105 language_.coof_checkpoint_src_volume_ = language_._src_volume_;
106 language_.coof_checkpoint_src_hl2_ = language_._src_hl2_;
107 language_.coof_checkpoint_src_hlc3_ = language_._src_hlc3_;
108 language_.coof_checkpoint_src_ohlc4_ = language_._src_ohlc4_;
109 language_.coof_checkpoint_src_hlcc4_ = language_._src_hlcc4_;
111 language_.coof_checkpoint_prev_chart_close_ = language_.prev_chart_close_;
112 language_.coof_checkpoint_last_chart_close_ = language_.last_chart_close_;
113 language_.coof_checkpoint_contains_current_bar_ =
false;
114 host.snapshot_script_state();
118 if (language_._src_series_active_) {
119 language_._src_open_ = language_.coof_checkpoint_src_open_;
120 language_._src_high_ = language_.coof_checkpoint_src_high_;
121 language_._src_low_ = language_.coof_checkpoint_src_low_;
122 language_._src_close_ = language_.coof_checkpoint_src_close_;
123 language_._src_volume_ = language_.coof_checkpoint_src_volume_;
124 language_._src_hl2_ = language_.coof_checkpoint_src_hl2_;
125 language_._src_hlc3_ = language_.coof_checkpoint_src_hlc3_;
126 language_._src_ohlc4_ = language_.coof_checkpoint_src_ohlc4_;
127 language_._src_hlcc4_ = language_.coof_checkpoint_src_hlcc4_;
129 language_.prev_chart_close_ = language_.coof_checkpoint_prev_chart_close_;
130 language_.last_chart_close_ = language_.coof_checkpoint_last_chart_close_;
131 host.restore_script_state();
135 if (language_._src_series_active_) {
136 language_.coof_checkpoint_src_open_ = language_._src_open_;
137 language_.coof_checkpoint_src_high_ = language_._src_high_;
138 language_.coof_checkpoint_src_low_ = language_._src_low_;
139 language_.coof_checkpoint_src_close_ = language_._src_close_;
140 language_.coof_checkpoint_src_volume_ = language_._src_volume_;
141 language_.coof_checkpoint_src_hl2_ = language_._src_hl2_;
142 language_.coof_checkpoint_src_hlc3_ = language_._src_hlc3_;
143 language_.coof_checkpoint_src_ohlc4_ = language_._src_ohlc4_;
144 language_.coof_checkpoint_src_hlcc4_ = language_._src_hlcc4_;
146 language_.coof_checkpoint_prev_chart_close_ = language_.prev_chart_close_;
147 language_.coof_checkpoint_last_chart_close_ = language_.last_chart_close_;
148 language_.coof_checkpoint_contains_current_bar_ =
true;
149 host.commit_script_state();
162int selected_executed_source_bars(
const PineStrategyHost& host,
const NativeRunSpec* spec,
163 const pf_selected_window_config_v1& window,
165 if (spec ==
nullptr) {
167 "selected run begin without a running spec for its "
168 "source tail count");
170 SelectedRetainedRequest
request;
173 request.input_tf = spec->input_tf;
174 request.script_tf = spec->script_tf;
176 request.engine_timezone = spec->timezone;
177 request.session = spec->session;
178 request.feed_tolerant = spec->slot_label_policy == NativeSlotLabelPolicy::FeedTolerant;
179 const SelectedRetainedCount counted =
181 if (counted.status != SelectedPlanStatus::Ok
182 || counted.script_bars >
static_cast<std::uint64_t
>(std::numeric_limits<int>::max())) {
184 "selected run source tail count refused or out of range "
187 return static_cast<int>(counted.script_bars);
193 const bool static_eligible = !retained_.is_stream && !retained_.bar_magnifier
194 && retained_.input_tf.empty() && retained_.script_tf.empty();
195 const auto state = host.native_state();
196 const bool undetected = state.spec && state.spec->timeframe_undetected;
197 const int ratio = undetected || !state.spec ? 1
198 :
tf_ratio(state.spec->input_tf, state.spec->script_tf);
199 const bool needs_aggregation = ratio > 1 || ratio == -1;
200 host.diag_script_tf_ratio_ = ratio;
201 host.diag_needs_aggregation_ = needs_aggregation;
202 input_script_size_ = retained_.bars.size();
203 expected_source_bars_ =
static_cast<int>(input_script_size_);
207 if (needs_aggregation && state.spec) {
208 ScriptBucketCursor counting(*state.spec);
209 expected_source_bars_ = 0;
210 for (std::size_t i = 0; i < input_script_size_; ++i)
211 expected_source_bars_ += counting.next(retained_.bars[i]).complete != 0U ? 1 : 0;
212 input_script_cursor = std::make_unique<ScriptBucketCursor>(*state.spec);
213 consumed_script_cursor_ = std::make_unique<ScriptBucketCursor>(*state.spec);
222 if (!retained_.is_stream && state.phase == NativeRunPhase::Batch) {
224 if (NativeExecutionConsumer::selected_window_admitted(host, &window)) {
225 expected_source_bars_ =
226 selected_executed_source_bars(host, state.spec, window, retained_.bars);
229 host.stream_warmup_mode_ = retained_.is_stream;
230 host.scheduler_prepare_script_run(retained_.bars, static_eligible,
231 expected_source_bars_, !needs_aggregation);
242 if (!retained_.simple_run) host.scheduler_configure_security_evaluators();
243 uses_aux_security_feed_ = host.scheduler_uses_aux_security_feed();
244 host.scheduler_prepare_security_sequence(retained_.bars);
255 const std::int64_t script_open_ms =
256 context.coordinate.provenance == NativePriceProvenance::CarriedOpen
257 ? context.coordinate.open_ms : context.script_bar_open_ms;
258 const bool published = last_published_script_open_ms_ == script_open_ms;
259 const bool coof_published = coof_callback_script_open_ == script_open_ms;
260 if (published || coof_published)
261 return std::max(0, source_bar_count_ - 1);
262 return source_bar_count_;
269 if (!lower)
return nullptr;
271 if (views.lower_path !=
nullptr) {
272 const auto segment = views.lower_segment;
273 if (segment.size == 0)
return nullptr;
274 const auto found = std::lower_bound(
275 segment.data, segment.data + segment.size, context.sub_bar_open_ms,
276 [](
const Bar&
bar, std::int64_t time) { return bar.timestamp < time; });
277 return found != segment.data + segment.size && found->timestamp == context.sub_bar_open_ms
282 const auto found = std::lower_bound(
283 lower->bars.begin(), lower->bars.end(), context.sub_bar_open_ms,
284 [](
const Bar&
bar, std::int64_t time) { return bar.timestamp < time; });
285 if (found == lower->bars.end() || found->timestamp != context.sub_bar_open_ms)
291 if (!retained_.bar_magnifier)
return;
292 saw_open_fill_ =
false;
293 open_point_fills_ = 0;
299bool single_print(
const Bar& bar)
noexcept {
300 return bar.volume == 0.0 && bar.high == bar.open && bar.low == bar.open
301 && bar.close == bar.open;
311 if (!found)
return std::nullopt;
320 const Bar* successor =
nullptr;
321 if (views.lower_path !=
nullptr) {
322 successor = found + 1 < views.lower_segment.data + views.lower_segment.size
323 ? found + 1 : views.lower_path->next_after_segment();
325 const auto& path = spec->intrabar.lower()->bars;
326 if (found + 1 < path.data() + path.size()) successor = found + 1;
329 : std::numeric_limits<double>::quiet_NaN(),
true};
330 if (single_print(*found))
return next_open;
331 const bool high_first = host.adapter_.source_path_uses_high_first(*found);
333 NativePathPhase::Open,
334 high_first ? NativePathPhase::High : NativePathPhase::Low,
335 high_first ? NativePathPhase::Low : NativePathPhase::High,
336 NativePathPhase::Close,
338 const double price[] = {
340 high_first ? found->
high : found->
low,
341 high_first ? found->
low : found->
high,
344 for (
int index = 0; index < 4; ++index) {
345 if (phase[index] != context.coordinate.path_phase)
continue;
349 if (index > 0 && index < 3 && !host.adapter_.coof_fill_at_path_point(
price[index]))
359 if (index == 2 && !host.adapter_.coof_fill_forced_)
369 update_source_series(
bar);
372void PineScheduler::update_source_series(
const Bar& bar) {
377 const double hl2 = (
bar.high +
bar.low) / 2.0;
378 const double hlc3 = (
bar.high +
bar.low +
bar.close) / 3.0;
379 const double ohlc4 = (
bar.open +
bar.high +
bar.low +
bar.close) / 4.0;
380 const double hlcc4 = (
bar.high +
bar.low +
bar.close +
bar.close) / 4.0;
406 if (language_.pos_view_freeze_bar_ ==
bar_index) {
408 return language_.pos_view_frozen_qty_;
410 return -language_.pos_view_frozen_qty_;
420 const std::vector<PyramidEntry>& lots) {
421 if (language_.pos_view_freeze_bar_ ==
bar_index)
return;
422 language_.pos_view_freeze_bar_ =
bar_index;
423 language_.pos_view_frozen_side_ = side;
424 language_.pos_view_frozen_qty_ = quantity;
425 language_.pos_view_frozen_entry_qty_.clear();
426 for (
const auto& lot : lots)
427 language_.pos_view_frozen_entry_qty_[lot.entry_id] += lot.qty;
431 language_.pos_view_freeze_bar_ = -1;
435 if (key ==
"open")
return language_._src_open_;
436 if (key ==
"high")
return language_._src_high_;
437 if (key ==
"low")
return language_._src_low_;
438 if (key ==
"close")
return language_._src_close_;
439 if (key ==
"volume")
return language_._src_volume_;
440 if (key ==
"hl2")
return language_._src_hl2_;
441 if (key ==
"hlc3")
return language_._src_hlc3_;
442 if (key ==
"ohlc4")
return language_._src_ohlc4_;
443 if (key ==
"hlcc4")
return language_._src_hlcc4_;
445 "unknown source series");
449 language_.history_slot_is_new_ = new_history_slot;
450 language_.is_first_tick_ = new_history_slot;
451 update_source_series(
bar);
456 input_is_observed_ticks_ =
false;
459 &&
static_cast<std::size_t
>(context.
input_index) < input_script_size_;
460 ScriptBucketCursor::Flags flags{};
462 const auto index =
static_cast<std::size_t
>(context.
input_index);
463 auto& cursor = *input_script_cursor;
464 if (cursor.position() > index + 1) cursor.reset();
465 while (cursor.position() <= index)
466 (void)cursor.next(retained_.bars[cursor.position()]);
467 flags = cursor.last();
470 struct InputBarIndexScope {
474 : host(value), previous(value.bar_index_) { host.bar_index_ = index; }
475 ~InputBarIndexScope() { host.bar_index_ = previous; }
480 if (uses_aux_security_feed_ || host.security_sites_kernel_routed()) {
484 std::int64_t next_input_ms = 0;
486 && context.
input_index + 1 <
static_cast<int>(retained_.bars.size())) {
487 next_input_ms = retained_.bars[
static_cast<std::size_t
>(context.
input_index + 1)].timestamp;
489 if (retained_.bar_magnifier && deferred_boundary_input_.active
494 const std::int64_t completed_script_open =
495 deferred_boundary_input_.prior_script_open_ms;
496 (void)host.scheduler_feed_security_input(
497 deferred_boundary_input_.bar, deferred_boundary_input_.next_input_ms,
501 deferred_boundary_input_.bar =
bar;
502 deferred_boundary_input_.next_input_ms = next_input_ms;
503 deferred_boundary_input_.prior_script_open_ms = completed_script_open;
504 deferred_boundary_input_.calling_bar_complete =
false;
505 deferred_boundary_input_.all_security_states =
true;
506 deferred_boundary_input_.active =
true;
515 if (!retained_.bar_magnifier && awaiting_legacy_script_open_ms_
516 != std::numeric_limits<std::int64_t>::min()) {
517 deferred_boundary_input_.bar =
bar;
518 deferred_boundary_input_.next_input_ms = next_input_ms;
519 deferred_boundary_input_.prior_script_open_ms = awaiting_legacy_script_open_ms_;
520 deferred_boundary_input_.calling_bar_complete =
false;
521 deferred_boundary_input_.all_security_states =
true;
522 deferred_boundary_input_.active =
true;
528 bool boundary = prior_input_script_open_ms_
529 != std::numeric_limits<std::int64_t>::min()
532 calling_bar_complete = flags.complete != 0U;
533 boundary = flags.boundary != 0U;
534 }
else if (retained_.is_stream && context.
input_index >= 0) {
541 if (retained_.bar_magnifier && next_input_ms == 0)
542 calling_bar_complete =
false;
543 bool security_boundary_ahead =
false;
544 if (retained_.bar_magnifier && next_input_ms != 0) {
546 bar.timestamp, next_input_ms, retained_.script_tf,
547 host.syminfo_.timezone, host.syminfo_.session);
548 if (caller_boundary) {
549 for (
const auto& state : host.security_eval_states_) {
550 if (host.pine_security_state(state.sec_id).publish_gate_tf_seconds > 0) {
551 security_boundary_ahead =
true;
557 if (security_boundary_ahead) {
558 deferred_boundary_input_.bar =
bar;
559 deferred_boundary_input_.next_input_ms = next_input_ms;
561 deferred_boundary_input_.calling_bar_complete =
true;
562 deferred_boundary_input_.all_security_states =
false;
563 deferred_boundary_input_.active =
true;
567 const bool deferred_gate = host.scheduler_feed_security_input(
568 bar, next_input_ms, calling_bar_complete,
569 boundary && !retained_.bar_magnifier);
571 deferred_boundary_input_.bar =
bar;
572 deferred_boundary_input_.next_input_ms = next_input_ms;
573 deferred_boundary_input_.prior_script_open_ms = prior_input_script_open_ms_;
574 deferred_boundary_input_.calling_bar_complete =
false;
575 deferred_boundary_input_.all_security_states =
false;
576 deferred_boundary_input_.active =
true;
578 if (calling_bar_complete && !retained_.bar_magnifier) {
579 awaiting_legacy_script_open_ms_ = boundary
587 if (!retained_.is_stream)
return;
588 input_is_observed_ticks_ =
true;
590 if (last_stream_input_open_ms_ == interval.open_ms)
return;
591 if (prior_input_script_open_ms_ != std::numeric_limits<std::int64_t>::min()
596 host.scheduler_publish_security_boundary();
598 last_stream_input_open_ms_ = interval.
open_ms;
601 (void)host.scheduler_feed_security_input(
602 bar, interval.next_input_open_ms, complete,
false);
603 prior_input_script_open_ms_ = script.open_ms;
610 saw_open_fill_ =
false;
611 open_point_fills_ = 0;
612 coof_callback_script_open_ = std::numeric_limits<std::int64_t>::min();
613 if (host.scheduler_coof_enabled()) snapshot_coof_script_state(host);
615 if (!retained_.is_stream) {
616 current_script_bar_ = value;
618 current_script_bar_valid_ =
true;
634 if (retained_.is_stream && current_script_bar_valid_
639 host.scheduler_record_broker_hash();
642 const bool coof = host.scheduler_coof_enabled();
643 const bool had_coof_recalc = coof_callback_script_open_
645 Bar script_bar = value;
647 if (retained_.is_stream && input_is_observed_ticks_
650 && host.syminfo_.session ==
"1800-1700"
651 && host.syminfo_.timezone ==
"America/New_York") {
656 script_bar.
timestamp = std::max(stamp, next_stamp);
658 current_script_bar_ = script_bar;
659 current_script_bar_valid_ =
true;
660 const bool completes_awaiting_legacy_script = awaiting_legacy_script_open_ms_
662 if (deferred_boundary_input_.active
663 && !deferred_boundary_input_.all_security_states
668 if (!retained_.bar_magnifier)
669 host.scheduler_publish_security_boundary();
674 if (uses_aux_security_feed_ && !had_coof_recalc) host.scheduler_feed_aux_security(chart_index);
676 restore_coof_script_state(host);
677 language_.is_first_tick_ =
true;
678 language_.is_last_tick_ =
true;
679 language_.history_slot_is_new_ =
680 !language_.coof_checkpoint_contains_current_bar_;
682 publish_series(script_bar, host);
689 && !spec->timeframe_undetected && !had_coof_recalc) {
690 host.scheduler_update_session_state();
692 const bool suppress_probe_tail = host.probe_suppress_tail_logic()
693 && expected_source_bars_ > 0
694 && source_bar_count_ + 1 >= expected_source_bars_;
695 if (suppress_probe_tail) host.scheduler_publish_suppressed_tail(script_bar);
697 host.scheduler_publish_source_bar(script_bar,
true, !had_coof_recalc);
700 if (had_coof_recalc) host.prev_bar_timestamp_ = script_bar.
timestamp;
703 if (coof) commit_coof_script_state(host);
704 if (uses_aux_security_feed_) host.scheduler_feed_deferred_aux_security(chart_index);
705 if (deferred_boundary_input_.active
707 if (deferred_boundary_input_.all_security_states) {
708 (void)host.scheduler_feed_security_input(
709 deferred_boundary_input_.bar, deferred_boundary_input_.next_input_ms,
710 deferred_boundary_input_.calling_bar_complete,
false);
712 host.scheduler_feed_deferred_security_input(
713 deferred_boundary_input_.bar, deferred_boundary_input_.next_input_ms);
715 deferred_boundary_input_ = {};
717 if (completes_awaiting_legacy_script) {
718 awaiting_legacy_script_open_ms_ = std::numeric_limits<std::int64_t>::min();
720 if (!had_coof_recalc) ++source_bar_count_;
722 if (!suppress_probe_tail) host.scheduler_record_range_end(current_script_bar_);
723 if (!retained_.is_stream) host.scheduler_finish_security_sequence();
725 host.scheduler_record_broker_hash();
729 if (event.
ordinal <= applied_cursor_)
return;
730 applied_cursor_ =
event.ordinal;
738 if (event.
ordinal != applied_cursor_)
return false;
739 if (!host.scheduler_coof_enabled())
return false;
740 if (host.config_.process_orders_on_close
757 if (host.adapter_.immediate_calculation_close(event, context))
return false;
758 if (host.adapter_.suppress_grouped_stop_recalc(event, context))
return false;
776 const bool bar_known = current_script_bar_valid_
779 && host.adapter_.source_path_uses_high_first(current_script_bar_)
780 ? NativePathPhase::High : NativePathPhase::Low;
788 const bool open_point = path_bar
792 &&
event.cursor.t == 0.0);
793 const bool at_open = open_point && open_point_fills_ < 2;
794 open_point_fills_ = at_open ? open_point_fills_ + 1 : 2;
795 const bool first_open = at_open && !saw_open_fill_;
796 if (at_open) saw_open_fill_ =
true;
797 const bool first_callback = coof_callback_script_open_
799 const bool callback_advances_source_bar = first_callback
800 && !language_.coof_checkpoint_contains_current_bar_;
811 if (uses_aux_security_feed_ && callback_advances_source_bar)
817 Bar callback_bar = current_script_bar_valid_
819 ? current_script_bar_ : host.current_bar_;
821 restore_coof_script_state(host);
822 language_.is_first_tick_ =
true;
823 language_.is_last_tick_ =
true;
824 language_.history_slot_is_new_ =
825 !language_.coof_checkpoint_contains_current_bar_;
826 publish_series(callback_bar, host);
833 && !spec->timeframe_undetected
835 host.scheduler_update_session_state();
846 const std::int64_t previous_bar_timestamp = host.prev_bar_timestamp_;
847 host.adapter_.begin_coof_recalc(
848 event, coof_context, first_open, host.broker_fill_event_seq_);
850 host.scheduler_publish_source_bar(
851 callback_bar,
true, callback_advances_source_bar);
857 host.adapter_.flush_coof_tail(
true);
858 host.adapter_.flush_coof_tail();
860 host.prev_bar_timestamp_ = previous_bar_timestamp;
861 host.adapter_.end_coof_recalc();
864 host.prev_bar_timestamp_ = previous_bar_timestamp;
865 host.adapter_.end_coof_recalc();
866 restore_coof_script_state(host);
869 if (callback_advances_source_bar) ++source_bar_count_;
871 auto newborns = host.adapter_.take_first_open_newborns();
872 for (
const auto& handle : newborns) {
873 (void)host.execute_current({handle, NativeCurrentPriceRule::NearestTick});
877 constexpr std::uint64_t kNoFillEventBudget = std::numeric_limits<std::uint64_t>::max();
882 std::uint64_t budget = kNoFillEventBudget;
883 std::size_t executed = 0;
885 auto newborns = host.adapter_.take_first_open_newborns();
886 if (newborns.empty())
break;
887 for (
const auto& handle : newborns) {
888 if (budget == 0 || executed == kFirstOpenLoopGuard) {
890 "Pine COOF first-open loop guard exhausted");
894 (void)host.execute_current({handle, NativeCurrentPriceRule::NearestTick});
Base with a code: throw coded<std::invalid_argument>(code, {args}, text).
void release_batch_input() noexcept
void tick(const Bar &, const NativeTickContext &, PineStrategyHost &)
void retain_confirmed_input(const Bar &bar, std::int64_t script_open_ms=std::numeric_limits< std::int64_t >::min()) noexcept
void run_begin(PineStrategyHost &)
void input(const Bar &, const NativeInputContext &, PineStrategyHost &)
double script_position_view(int bar_index, PositionSide side, double quantity) const noexcept
bool coof_recalculation_due(const native_order::ExecutionAppliedEvent &, const NativeDecisionContext &, PineStrategyHost &) const
void fixture_publish_source_series(const Bar &, bool new_history_slot)
void recalculate(const native_order::ExecutionAppliedEvent &, const NativeDecisionContext &, PineStrategyHost &)
void clear_script_position_view() noexcept
static bool confirmed_script_interval_complete(const NativeInputContext &context) noexcept
const Series< double > & source_series(const std::string &) const
bool terminal_source_bar() const noexcept
int source_bar_index_for(const NativeDecisionContext &context) const noexcept
void bar_open(const Bar &, const NativeDecisionContext &, PineStrategyHost &)
void sub_bar_complete() noexcept
std::optional< InputWaypoint > next_input_waypoint(const PineStrategyHost &, const NativeDecisionContext &) const noexcept
InputView retained_input() const noexcept
void capture_begin(const NativeBeginArgs &)
void freeze_script_position_view(int bar_index, PositionSide side, double quantity, const std::vector< PyramidEntry > &lots)
void applied(const native_order::ExecutionAppliedEvent &)
void bar(const Bar &, const NativeDecisionContext &, PineStrategyHost &)
const Bar * lower_path_bar_at(const PineStrategyHost &host, const NativeDecisionContext &context) const noexcept
NativePathPhase
Which leg of a modeled OHLC walk a point sits on.
SelectedRetainedCount count_selected_executed_primary(const Bar *rows, std::size_t count, const SelectedRetainedRequest &request)
const NativeRunSpec * run_spec(const NativeStrategyHost &host)
NativeExecutionConsumer & run_consumer(const NativeStrategyHost &host)
constexpr std::uint32_t kCoofLoopGuard
int tf_to_seconds(const std::string &tf)
Convert a TradingView timeframe string to seconds.
int tf_ratio(const std::string &input_tf, const std::string &target_tf)
Compute how many input bars fit into one target bar.
CalendarPeriod calendar_period_for(const std::string &tf)
Determine the calendar period for a target TF string.
bool tf_change(int64_t prev_ms, int64_t curr_ms, const std::string &tf)
Check if prev/curr timestamps cross a timeframe boundary.
int64_t session_period_open_ms(int64_t ms, const std::string &tz, const std::string &session, CalendarPeriod period)
Open (Unix ms) of the symbol's D/W/M bar that contains ms: the day stamp of the period's first sessio...
Selected-window configuration, handed to strategy_set_selected_window_v1().
Borrowed begin-call facts.
MagnifierDistribution magnifier_distribution
int magnifier_volume_weighted_min_samples
int magnifier_volume_weighted_max_samples
bool simple_run
Which public overload began the run: the bare run(bars, n) lifecycle (true) or a timeframe-aware / ma...
bool magnifier_volume_weighted
Accepted input facts presented before the generic consumer aggregates the bar into its script interva...
bool completes_script_interval
native_calendar::NativeInterval script_interval
One accepted realtime print before native matching at its current decision point.
NativeDecisionContext decision
int64_t next_period_open_ms
NativePathPhase path_phase
NativePriceProvenance provenance
native_calendar::NativeInterval input_interval
native_calendar::NativeInterval script_interval
int64_t script_bar_open_ms
NativeCoordinate coordinate
One committed execution: the definition, the cursor, the resolved price and units,...
const lower_tf * lower() const noexcept
The retained finer feed, or nullptr when this is not the lower_tf alternative.
One complete setup value, staged/copied by NativeStrategyHost before it is applied at begin.
Series< double > coof_checkpoint_src_high_
Series< double > _src_low_
Series< double > _src_high_
Series< double > coof_checkpoint_src_open_
bool history_slot_is_new_
Series< double > _src_hlc3_
PositionSide pos_view_frozen_side_
Series< double > _src_volume_
Series< double > _src_open_
Series< double > coof_checkpoint_src_hl2_
Series< double > coof_checkpoint_src_hlcc4_
std::unordered_map< std::string, double > pos_view_frozen_entry_qty_
Series< double > coof_checkpoint_src_close_
Series< double > _src_hl2_
Series< double > coof_checkpoint_src_volume_
Series< double > coof_checkpoint_src_low_
Series< double > _src_close_
bool coof_checkpoint_contains_current_bar_
Series< double > _src_ohlc4_
Series< double > _src_hlcc4_
double pos_view_frozen_qty_
Series< double > coof_checkpoint_src_hlc3_
Series< double > coof_checkpoint_src_ohlc4_