|
OpenPine C++ API
C++ wrapper for the OpenPine Pine Script VM
|
Represents a compiled, executable Pine Script instance. More...
#include <instance.hpp>
Public Types | |
| using | RunCallback = std::function<void(const Result&)> |
| Callback invoked when run() completes. | |
| using | EventCallback = std::function<void(const ffi::CEvent&)> |
| Callback invoked for each event during run(). | |
Public Member Functions | |
| Chart | chart () const |
| Returns the chart produced by the last completed run(). | |
| ScriptInfo | scriptInfo () const |
| Returns the script metadata. | |
| void | run (std::string_view symbol, std::string_view timeframe, int64_t from_time, RunCallback callback, EventCallback event_callback=nullptr) |
| Starts asynchronous execution and returns immediately. | |
| Instance (Instance &&)=default | |
| Instance & | operator= (Instance &&)=default |
Static Public Member Functions | |
| static Instance | create (const CreateInstanceOptions &options) |
| Creates a new Instance. | |
Represents a compiled, executable Pine Script instance.
Definition at line 235 of file instance.hpp.
| using openpine::Instance::EventCallback = std::function<void(const ffi::CEvent&)> |
Callback invoked for each event during run().
The CEvent pointer is valid only for the duration of the callback.
Definition at line 251 of file instance.hpp.
| using openpine::Instance::RunCallback = std::function<void(const Result&)> |
Callback invoked when run() completes.
Called on the OS thread that drives the VM execution (not the caller's thread). result is valid only for the duration of the callback. Copy any error message you need before returning.
Definition at line 244 of file instance.hpp.
|
default |
References Instance().
Referenced by create(), Instance(), and operator=().
|
inline |
Returns the chart produced by the last completed run().
Definition at line 260 of file instance.hpp.
|
inlinestatic |
Creates a new Instance.
| Error | if compilation fails. |
Definition at line 338 of file instance.hpp.
References Instance().
References Instance().
|
inline |
Starts asynchronous execution and returns immediately.
The VM pulls candlestick data from the DataProvider injected via CreateInstanceOptions::setDataProvider(). When execution completes (or fails), callback is invoked on a separate OS thread.
The Instance must remain valid until callback fires.
| symbol | Main chart symbol (e.g. "NASDAQ:AAPL"). |
| timeframe | Main chart timeframe (e.g. "1D"). |
| from_time | Start time in epoch milliseconds (0 = beginning). |
| callback | Invoked with the result on the execution thread. |
| event_callback | Optional per-event callback. Pass nullptr to skip. |
| Error | if the run cannot be started (e.g. bad symbol/timeframe). |
Definition at line 396 of file instance.hpp.
References run().
Referenced by run().
|
inline |
Returns the script metadata.
Definition at line 263 of file instance.hpp.