BetaTrader
A HFT Eco-System
Loading...
Searching...
No Matches
ohlc::CandleAggregator Class Reference

Aggregates trade updates into OHLC candles and persists them. More...

#include <CandleAggregator.h>

Collaboration diagram for ohlc::CandleAggregator:
Collaboration graph

Classes

struct  Aggregate
 

Public Types

using CandleCallback = std::function< void(int interval, const Candle &)>
 

Public Member Functions

 CandleAggregator (MarketHistoryRepository &repo)
 
 ~CandleAggregator ()=default
 
void onTrade (const std::string &symbol, double price, uint64_t qty, int64_t timestampNs)
 
void setCandleCallback (CandleCallback cb)
 

Private Member Functions

void updateAggregate (Aggregate &agg, int interval, const std::string &symbol, double price, uint64_t qty, int64_t timestampNs)
 

Private Attributes

std::map< std::string, std::map< int, Aggregate > > mAggregates
 
CandleCallback mCallback
 
std::mutex mMutex
 
MarketHistoryRepositorymRepo
 

Detailed Description

Aggregates trade updates into OHLC candles and persists them.

Member Typedef Documentation

◆ CandleCallback

using ohlc::CandleAggregator::CandleCallback = std::function<void(int interval, const Candle&)>

Constructor & Destructor Documentation

◆ CandleAggregator()

ohlc::CandleAggregator::CandleAggregator ( MarketHistoryRepository repo)

◆ ~CandleAggregator()

ohlc::CandleAggregator::~CandleAggregator ( )
default

Member Function Documentation

◆ onTrade()

void ohlc::CandleAggregator::onTrade ( const std::string &  symbol,
double  price,
uint64_t  qty,
int64_t  timestampNs 
)
Here is the call graph for this function:

◆ setCandleCallback()

void ohlc::CandleAggregator::setCandleCallback ( CandleCallback  cb)
inline

◆ updateAggregate()

void ohlc::CandleAggregator::updateAggregate ( Aggregate agg,
int  interval,
const std::string &  symbol,
double  price,
uint64_t  qty,
int64_t  timestampNs 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mAggregates

std::map<std::string, std::map<int, Aggregate> > ohlc::CandleAggregator::mAggregates
private

◆ mCallback

CandleCallback ohlc::CandleAggregator::mCallback
private

◆ mMutex

std::mutex ohlc::CandleAggregator::mMutex
private

◆ mRepo

MarketHistoryRepository& ohlc::CandleAggregator::mRepo
private

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