|
crypto_trader
Cryptocurrency Trading Bot API Documentation
|
A concrete implementation of the Executor protocol for paper (simulated) trading. More...
#include <paper_trading_executor.h>


Public Member Functions | |
| PaperTradingExecutor (const PaperTradingExecutorConfig &config, traders::EventPositionManager &positionManager) | |
| Constructs a PaperTradingExecutor. | |
| ~PaperTradingExecutor ()=default | |
| Destructor for PaperTradingExecutor. | |
| common::TradeResult | buy (const std::string_view &product, double quantity) override |
| Executes a simulated buy order. | |
| common::TradeResult | sell (const std::string_view &product, double quantity) override |
| Executes a simulated sell order. | |
| double | getBalance (const std::string_view ¤cy) const override |
| Gets the current balance of a currency. | |
| std::optional< double > | getPosition (const std::string_view &product) const override |
| Gets the current position for a given product. | |
| void | processTickerData (const std::string_view &product, double price, const T::Timestamp ×tamp) override |
| Processes new ticker data to update internal market prices. | |
| double | getRealizedPnl (const std::string_view &product) const |
| Gets the total realized Profit and Loss for the configured product. | |
| double | balance () const |
| Returns the current cash balance. | |
| std::optional< double > | pnl (const std::string_view &product, bool realize) const |
| Returns either the realized or unrealized PnL for the given product. | |
| std::optional< double > | getAverageCostBasis (const std::string_view &product) const |
| Gets the average cost basis for a given product. | |
| Public Member Functions inherited from crypto_trader::protocols::Executor< T > | |
| virtual | ~Executor ()=default |
| Destructor for the Executor interface. | |
A concrete implementation of the Executor protocol for paper (simulated) trading.
This executor manages an internal cash balance and positions, simulating trade executions without interacting with real exchanges.
| T | The MarketData type that the executor processes. |
| crypto_trader::executors::PaperTradingExecutor< T >::PaperTradingExecutor | ( | const PaperTradingExecutorConfig & | config, |
| traders::EventPositionManager & | positionManager ) |
Constructs a PaperTradingExecutor.
| config | The configuration for the executor. |
| positionManager | A reference to the EventPositionManager for tracking positions. |
|
default |
Destructor for PaperTradingExecutor.
| double crypto_trader::executors::PaperTradingExecutor< T >::balance | ( | ) | const |
Returns the current cash balance.
|
overridevirtual |
Executes a simulated buy order.
| product | The symbol of the product to buy. |
| quantity | The amount of the product to buy. |
Implements crypto_trader::protocols::Executor< T >.
| std::optional< double > crypto_trader::executors::PaperTradingExecutor< T >::getAverageCostBasis | ( | const std::string_view & | product | ) | const |
Gets the average cost basis for a given product.
| product | The symbol of the product. |
|
overridevirtual |
Gets the current balance of a currency.
| currency | The symbol of the currency (e.g., "USD"). |
Implements crypto_trader::protocols::Executor< T >.
|
overridevirtual |
Gets the current position for a given product.
| product | The symbol of the product. |
Implements crypto_trader::protocols::Executor< T >.
| double crypto_trader::executors::PaperTradingExecutor< T >::getRealizedPnl | ( | const std::string_view & | product | ) | const |
Gets the total realized Profit and Loss for the configured product.
| product | The symbol of the product. |
| std::optional< double > crypto_trader::executors::PaperTradingExecutor< T >::pnl | ( | const std::string_view & | product, |
| bool | realize ) const |
Returns either the realized or unrealized PnL for the given product.
| product | The symbol of the product. |
| realize | If true, returns realized PnL; otherwise, returns unrealized PnL. |
|
overridevirtual |
Processes new ticker data to update internal market prices.
| product | The symbol of the product for the ticker. |
| price | The latest price of the product. |
| timestamp | The timestamp of the ticker data. |
Implements crypto_trader::protocols::Executor< T >.
|
overridevirtual |
Executes a simulated sell order.
| product | The symbol of the product to sell. |
| quantity | The amount of the product to sell. |
Implements crypto_trader::protocols::Executor< T >.