PineForge HPO 0.1.0
Native hyperparameter optimization for PineForge strategies
Loading...
Searching...
No Matches
pineforge::hpo::StrategyPlugin Class Referencefinal

RAII wrapper around one compiled PineForge strategy plugin. More...

#include <pineforge/hpo/strategy_plugin.hpp>

Public Member Functions

 StrategyPlugin (std::filesystem::path path)
 Loads path and resolves the required PineForge strategy symbols.
 
 ~StrategyPlugin ()
 
 StrategyPlugin (const StrategyPlugin &)=delete
 
StrategyPluginoperator= (const StrategyPlugin &)=delete
 
 StrategyPlugin (StrategyPlugin &&other) noexcept
 
StrategyPluginoperator= (StrategyPlugin &&other) noexcept
 
const std::filesystem::path & path () const noexcept
 Returns the dynamic-library path supplied at construction.
 
int abi_version () const noexcept
 Returns the ABI version reported by the validated plugin.
 
pf_strategy_t create_strategy () const
 Creates a fresh strategy handle owned by the caller.
 
void free_strategy (pf_strategy_t strategy) const noexcept
 Releases a handle returned by create_strategy(); safe to call during cleanup.
 
void set_input (pf_strategy_t strategy, const std::string &key, const std::string &value) const
 Applies one serialized Pine input before the backtest starts.
 
void set_override (pf_strategy_t strategy, const std::string &key, const std::string &value) const
 Applies one serialized runtime strategy override before the backtest starts.
 
void set_chart_timezone (pf_strategy_t strategy, const std::string &timezone) const
 Sets the chart timezone when non-empty and supported by the plugin.
 
void run_backtest_full (pf_strategy_t strategy, const pf_bar_t *bars, int bar_count, const std::string &input_timeframe, const std::string &script_timeframe, bool bar_magnifier, int magnifier_samples, pf_magnifier_distribution_t magnifier_distribution, pf_report_t *report) const
 Invokes the plugin's full backtest entry point using immutable OHLCV input.
 
std::string last_error (pf_strategy_t strategy) const
 Returns the plugin's last error for strategy, or an empty string when none exists.
 
void free_report (pf_report_t *report) const noexcept
 Releases report-owned allocations populated by run_backtest_full().
 

Detailed Description

RAII wrapper around one compiled PineForge strategy plugin.

The dynamic library is loaded and ABI-validated once. It may serve concurrent calls made with distinct strategy handles, but each pf_strategy_t must remain confined to one trial. Reports and strategy handles must be released through this wrapper before the plugin is destroyed.

Definition at line 16 of file strategy_plugin.hpp.

Constructor & Destructor Documentation

◆ StrategyPlugin() [1/3]

pineforge::hpo::StrategyPlugin::StrategyPlugin ( std::filesystem::path  path)
explicit

Loads path and resolves the required PineForge strategy symbols.

Exceptions
std::invalid_argumentwhen the path is empty.
std::runtime_errorwhen loading, symbol resolution, or ABI validation fails.

◆ ~StrategyPlugin()

pineforge::hpo::StrategyPlugin::~StrategyPlugin ( )

◆ StrategyPlugin() [2/3]

pineforge::hpo::StrategyPlugin::StrategyPlugin ( const StrategyPlugin )
delete

◆ StrategyPlugin() [3/3]

pineforge::hpo::StrategyPlugin::StrategyPlugin ( StrategyPlugin &&  other)
noexcept

Member Function Documentation

◆ abi_version()

int pineforge::hpo::StrategyPlugin::abi_version ( ) const
inlinenoexcept

Returns the ABI version reported by the validated plugin.

Definition at line 32 of file strategy_plugin.hpp.

◆ create_strategy()

pf_strategy_t pineforge::hpo::StrategyPlugin::create_strategy ( ) const

Creates a fresh strategy handle owned by the caller.

Exceptions
std::runtime_errorwhen the plugin returns a null handle.

◆ free_report()

void pineforge::hpo::StrategyPlugin::free_report ( pf_report_t *  report) const
noexcept

Releases report-owned allocations populated by run_backtest_full().

◆ free_strategy()

void pineforge::hpo::StrategyPlugin::free_strategy ( pf_strategy_t  strategy) const
noexcept

Releases a handle returned by create_strategy(); safe to call during cleanup.

◆ last_error()

std::string pineforge::hpo::StrategyPlugin::last_error ( pf_strategy_t  strategy) const

Returns the plugin's last error for strategy, or an empty string when none exists.

Exceptions
std::invalid_argumentfor a null handle.

◆ operator=() [1/2]

StrategyPlugin & pineforge::hpo::StrategyPlugin::operator= ( const StrategyPlugin )
delete

◆ operator=() [2/2]

StrategyPlugin & pineforge::hpo::StrategyPlugin::operator= ( StrategyPlugin &&  other)
noexcept

◆ path()

const std::filesystem::path & pineforge::hpo::StrategyPlugin::path ( ) const
inlinenoexcept

Returns the dynamic-library path supplied at construction.

Definition at line 30 of file strategy_plugin.hpp.

◆ run_backtest_full()

void pineforge::hpo::StrategyPlugin::run_backtest_full ( pf_strategy_t  strategy,
const pf_bar_t *  bars,
int  bar_count,
const std::string &  input_timeframe,
const std::string &  script_timeframe,
bool  bar_magnifier,
int  magnifier_samples,
pf_magnifier_distribution_t  magnifier_distribution,
pf_report_t *  report 
) const

Invokes the plugin's full backtest entry point using immutable OHLCV input.

The report remains caller-owned and must later be released with free_report().

Exceptions
std::invalid_argumentfor invalid pointers/counts or embedded-NUL timeframes.

◆ set_chart_timezone()

void pineforge::hpo::StrategyPlugin::set_chart_timezone ( pf_strategy_t  strategy,
const std::string &  timezone 
) const

Sets the chart timezone when non-empty and supported by the plugin.

An empty timezone is a no-op. A non-empty value requires the optional strategy_set_chart_timezone symbol.

Exceptions
std::invalid_argumentfor a null handle or embedded NUL.
std::runtime_errorwhen the loaded plugin lacks timezone support.

◆ set_input()

void pineforge::hpo::StrategyPlugin::set_input ( pf_strategy_t  strategy,
const std::string &  key,
const std::string &  value 
) const

Applies one serialized Pine input before the backtest starts.

Exceptions
std::invalid_argumentfor a null handle or an embedded NUL in key/value.

◆ set_override()

void pineforge::hpo::StrategyPlugin::set_override ( pf_strategy_t  strategy,
const std::string &  key,
const std::string &  value 
) const

Applies one serialized runtime strategy override before the backtest starts.

Exceptions
std::invalid_argumentfor a null handle or an embedded NUL in key/value.

The documentation for this class was generated from the following file: