OpenPine C++ API
C++ wrapper for the OpenPine Pine Script VM
Loading...
Searching...
No Matches
openpine::DataProvider Class Referenceabstract

Abstract base class for supplying candlestick data and symbol metadata to the VM. More...

#include <instance.hpp>

Public Member Functions

virtual ~DataProvider ()=default
virtual PartialSymbolInfo symbolInfo (std::string_view symbol)=0
 Returns symbol metadata. Throw on failure.
virtual ffi::CandlestickStream * candlesticksOpen (std::string_view symbol, std::string_view timeframe, int64_t from_time)=0
 Opens a candlestick stream.

Detailed Description

Abstract base class for supplying candlestick data and symbol metadata to the VM.

Implement this class and pass a pointer to CreateInstanceOptions::setDataProvider(). The C++ wrapper bridges to ffi::DataProvider internally.

Both symbolInfo and candlesticksOpen are called from the VM's execution thread. candlesticksOpen must return a ffi::CandlestickStream* created via CandlestickStream::release(). Bars may be pushed from any thread.

class MyProvider : public openpine::DataProvider {
public:
PartialSymbolInfo symbolInfo(std::string_view) override {
return {}; // defaults
}
ffi::CandlestickStream* candlesticksOpen(
std::string_view symbol, std::string_view timeframe,
int64_t from_time) override {
auto stream = std::make_unique<CandlestickStream>(symbol, timeframe,
from_time);
for (auto& b : get_bars(symbol, timeframe))
stream->push(b);
stream->finish();
return stream->release();
}
};
virtual PartialSymbolInfo symbolInfo(std::string_view symbol)=0
Returns symbol metadata. Throw on failure.

Definition at line 154 of file instance.hpp.

Constructor & Destructor Documentation

◆ ~DataProvider()

virtual openpine::DataProvider::~DataProvider ( )
virtualdefault

Member Function Documentation

◆ candlesticksOpen()

virtual ffi::CandlestickStream * openpine::DataProvider::candlesticksOpen ( std::string_view symbol,
std::string_view timeframe,
int64_t from_time )
pure virtual

Opens a candlestick stream.

Create a CandlestickStream, push data (synchronously or from another thread), call finish(), and return the raw handle via release().

The VM takes ownership of the returned pointer.

◆ symbolInfo()

virtual PartialSymbolInfo openpine::DataProvider::symbolInfo ( std::string_view symbol)
pure virtual

Returns symbol metadata. Throw on failure.

Parameters
symbolSymbol string (e.g. "NASDAQ:AAPL").

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