ATS
An algorithmic trading system completely written in C++
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ats::Strategy Class Referenceabstract

Defines an abstract interface for trading strategies. More...

#include <Strategy.h>

Public Member Functions

 Strategy (std::string symbol, MarketData &data, OrderManager &orderManager, std::vector< double > prices={})
 Constructs a Strategy object. More...
 
virtual ~Strategy ()
 Destructs the Strategy object.
 
virtual void start ()
 Starts the strategy thread.
 
virtual void run ()
 Runs the strategy.
 
virtual void stop ()
 Stops the strategy.
 
bool isRunning ()
 Returns whether the strategy is running. More...
 

Protected Member Functions

virtual void updatePrice ()=0
 Updates the historical price vector.
 
virtual double getSignal ()=0
 Gets the trading signal. More...
 
virtual void buy ()=0
 Sends a buy order to the OrderManager.
 
virtual void sell ()=0
 Sends a sell order to the OrderManager.
 

Protected Attributes

MarketDatamData
 MarketData object to get market information.
 
OrderManagermOrderManager
 OrderManager object to create and manage orders.
 
std::string mSymbol
 The symbol the strategy is trading.
 
std::vector< double > mPrices
 Vector of historical prices.
 
std::thread mStrategyThread
 Thread for running the strategy.
 
bool mRunning
 Flag indicating if the strategy is running.
 

Detailed Description

Defines an abstract interface for trading strategies.

Constructor & Destructor Documentation

◆ Strategy()

ats::Strategy::Strategy ( std::string  symbol,
MarketData data,
OrderManager orderManager,
std::vector< double >  prices = {} 
)

Constructs a Strategy object.

Parameters
symbolThe symbol the strategy will trade
dataMarketData object to get market information
orderManagerOrderManager object to create and manage orders
pricesVector of historical prices (default empty)

Member Function Documentation

◆ getSignal()

virtual double ats::Strategy::getSignal ( )
protectedpure virtual

Gets the trading signal.

Returns
True if the strategy signals to buy, false if the strategy signals to sell

◆ isRunning()

bool ats::Strategy::isRunning ( )

Returns whether the strategy is running.

Returns
True if the strategy is running, false otherwise

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