1515#include < vector>
1616
1717namespace pineforge {
18- inline namespace engine_script_run_v16 {
18+ inline namespace engine_script_run_v17 {
1919
2020enum class NativeLifecycleKind : std::uint8_t {
2121 Unconfigured = 0 ,
@@ -345,12 +345,32 @@ using NativeCurrentExecutionResult = std::variant<NativeCurrentRefusal,
345345 native_order::ExecutionAppliedEvent, native_order::NoEffectEvent,
346346 native_order::MatchRejectedEvent, native_order::CancelledEvent>;
347347
348+ // Borrowed begin-call facts. The bar/input/override pointers expire when
349+ // prepare_native_begin returns; retained configuration must copy them by
350+ // value (for example into NativeRunSpec::intrabar).
351+ struct NativeBeginArgs {
352+ const Bar* bars = nullptr ;
353+ int n = 0 ;
354+ std::string input_tf;
355+ std::string script_tf;
356+ bool bar_magnifier = false ;
357+ int magnifier_samples = 4 ;
358+ MagnifierDistribution magnifier_distribution = MagnifierDistribution::ENDPOINTS ;
359+ bool magnifier_volume_weighted = false ;
360+ int magnifier_volume_weighted_min_samples = 2 ;
361+ int magnifier_volume_weighted_max_samples = 64 ;
362+ const InputsMap* inputs = nullptr ;
363+ const void * overrides_opaque = nullptr ;
364+ bool is_stream = false ;
365+ int warmup_n = 0 ;
366+ };
367+
348368// Most-derived native strategy host. Binds NativeExecutionConsumer in the
349369// protected engine constructor. Noncopyable and nonmovable. Lives in the
350370// same inline engine epoch as BacktestEngine so old-header/new-library
351371// linkage cannot resolve an unversioned constructor against a different
352372// base layout.
353- #define PINEFORGE_HAS_NATIVE_STRATEGY_HOST_V16 1
373+ #define PINEFORGE_HAS_NATIVE_STRATEGY_HOST_V17 1
354374class NativeStrategyHost : public BacktestEngine {
355375public:
356376 NativeStrategyHost ();
@@ -362,7 +382,11 @@ class NativeStrategyHost : public BacktestEngine {
362382
363383 void on_bar (const Bar& bar) final ;
364384
385+ virtual void prepare_native_begin (const NativeBeginArgs&) {}
365386 virtual void on_native_run_begin () {}
387+ // Precedes the matching pass at the script bar's open decision point.
388+ // inspect_current_execution/execute_current are legal in this hook.
389+ virtual void on_native_bar_open (const Bar&, const NativeDecisionContext&) {}
366390 virtual void on_native_bar (const Bar& bar, const NativeDecisionContext& context) = 0;
367391
368392 virtual void on_native_applied (const native_order::ExecutionAppliedEvent&,
@@ -393,6 +417,9 @@ class NativeStrategyHost : public BacktestEngine {
393417 native_order::ReplaceResult replace_market (const native_order::RequestHandle& target,
394418 const native_order::Request& request);
395419 native_order::CancelResult cancel (const native_order::RequestHandle& target);
420+ native_order::CohortHandle cohort_open ();
421+ void cohort_add (native_order::CohortHandle cohort, native_order::RequestHandle origin);
422+ void cohort_remove (native_order::CohortHandle cohort, native_order::RequestHandle origin);
396423
397424 NativePhysicalPosition physical_position () const ;
398425 double native_marked_equity (double mark) const ;
@@ -406,5 +433,5 @@ class NativeStrategyHost : public BacktestEngine {
406433 friend class NativeExecutionConsumer ;
407434};
408435
409- } // inline namespace engine_script_run_v16
436+ } // inline namespace engine_script_run_v17
410437} // namespace pineforge
0 commit comments