ATS
An algorithmic trading system completely written in C++
Public Member Functions | List of all members
ats::MarketData Class Reference

Handles the streaming of market data for the trading system. More...

#include <MarketData.h>

Public Member Functions

 MarketData (ExchangeManager &ems, time_t updateInterval=1)
 Constructs a new MarketData object. More...
 
 ~MarketData ()
 Destroys the MarketData object.
 
 MarketData (const std::vector< std::string > &symbols, ExchangeManager &ems, time_t updateInterval=1)
 Constructs a new MarketData object. More...
 
void start ()
 Starts the market data stream.
 
void run ()
 Runs the market data stream.
 
void stop ()
 Stops the market data stream.
 
bool isRunning ()
 Checks whether the market data stream is running. More...
 
void subscribe (const std::string &symbol, std::string interval="3m")
 Subscribes to a symbol for market data. More...
 
void unsubscribe (const std::string &symbol)
 Unsubscribes from a symbol for market data. More...
 
double getPrice (const std::string &symbol)
 Retrieves the current price for a symbol. More...
 
std::vector< double > getPrices (const std::string &symbol)
 Returns prices recorded for a symbol. More...
 
std::vector< TradegetTradeHistory (const std::string &symbol)
 Returns trade history for a symbol. More...
 
double getQtyForPrice (const std::string &symbol, double price)
 Retrieves the quantity for a given price and symbol. More...
 
std::map< std::string, double > getBalances ()
 Retrives user's balances. More...
 
std::string getOrderStatus (long id, const std::string &symbol)
 Retrieves order status. More...
 
OrderBook getOrderBook (const std::string &symbol)
 Retrieves the OrderBook. More...
 
Klines getKlines (const std::string &symbol, const std::string &interval)
 Retrieves Kline data. More...
 

Detailed Description

Handles the streaming of market data for the trading system.

Constructor & Destructor Documentation

◆ MarketData() [1/2]

ats::MarketData::MarketData ( ExchangeManager ems,
time_t  updateInterval = 1 
)

Constructs a new MarketData object.

Parameters
emsA reference to the ExchangeManager object used to retrieve market data.
updateIntervalThe interval between updates of local data, defaults to 1s.

◆ MarketData() [2/2]

ats::MarketData::MarketData ( const std::vector< std::string > &  symbols,
ExchangeManager ems,
time_t  updateInterval = 1 
)
explicit

Constructs a new MarketData object.

Parameters
symbolsA vector of symbols to subscribe to for market data.
emsA reference to the ExchangeManager object used to retrieve market data.
updateIntervalThe interval between updates of local data, defaults to 1s.

Member Function Documentation

◆ getBalances()

std::map< std::string, double > ats::MarketData::getBalances ( )

Retrives user's balances.

Returns
Map of pairs {asset, balance}.

◆ getKlines()

Klines ats::MarketData::getKlines ( const std::string &  symbol,
const std::string &  interval 
)

Retrieves Kline data.

Parameters
symbolSymbol for which to get the Kline data.
intervalInterval for the Klines.
Returns
The requested Kline data.

◆ getOrderBook()

OrderBook ats::MarketData::getOrderBook ( const std::string &  symbol)

Retrieves the OrderBook.

Parameters
symbolSymbol for which to get the order book.
Returns
Current OrderBook.

◆ getOrderStatus()

std::string ats::MarketData::getOrderStatus ( long  id,
const std::string &  symbol 
)

Retrieves order status.

Parameters
IdClient-side order Id.
Returns
Order status

◆ getPrice()

double ats::MarketData::getPrice ( const std::string &  symbol)

Retrieves the current price for a symbol.

Parameters
symbolThe symbol to retrieve the price for.
Returns
The current price for the symbol.

◆ getPrices()

std::vector< double > ats::MarketData::getPrices ( const std::string &  symbol)

Returns prices recorded for a symbol.

Parameters
symbolThe symbol to retrieve the prices for.
Returns
The vector of prices recorded.

◆ getQtyForPrice()

double ats::MarketData::getQtyForPrice ( const std::string &  symbol,
double  price 
)

Retrieves the quantity for a given price and symbol.

Parameters
symbolThe symbol to retrieve the quantity for.
priceThe price to retrieve the quantity for.
Returns
The quantity for the given price and symbol.

◆ getTradeHistory()

std::vector< Trade > ats::MarketData::getTradeHistory ( const std::string &  symbol)

Returns trade history for a symbol.

Parameters
symbolThe symbol to retrieve the history for.
Returns
The vector of trades.

◆ isRunning()

bool ats::MarketData::isRunning ( )

Checks whether the market data stream is running.

Returns
True if the market data stream is running, false otherwise.

◆ subscribe()

void ats::MarketData::subscribe ( const std::string &  symbol,
std::string  interval = "3m" 
)

Subscribes to a symbol for market data.

Parameters
symbolThe symbol to subscribe to.
intervalThe interval for the Kline we want to subscribe to

◆ unsubscribe()

void ats::MarketData::unsubscribe ( const std::string &  symbol)

Unsubscribes from a symbol for market data.

Parameters
symbolThe symbol to unsubscribe from.

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