crypto_trader
Cryptocurrency Trading Bot API Documentation
Loading...
Searching...
No Matches
crypto_trader::strategies::HodlStrategy Class Reference

Implements a "Buy and Hold" strategy with dynamic adjustments based on price movements. More...

#include <hodl.h>

Inheritance diagram for crypto_trader::strategies::HodlStrategy:
Inheritance graph
Collaboration diagram for crypto_trader::strategies::HodlStrategy:
Collaboration graph

Public Member Functions

 HodlStrategy (const HodlStrategyConfig &config, traders::EventPositionManager &positionManager)
 Constructs a HodlStrategy.
 ~HodlStrategy ()
 Destructor for HodlStrategy.
void handleNewData (const nlohmann::json &data) override
 Handles new market data received by the strategy.
void on_trade (const common::Trade &trade) override
 Callback method invoked when a trade is executed.
void on_position_update (const std::string &symbol, double new_position) override
 Callback method invoked when a position update occurs.
Public Member Functions inherited from crypto_trader::protocols::Strategy
 Strategy (const common::Emit &emit)
 Constructs a Strategy object.
virtual ~Strategy ()=0
 Destructor for the Strategy interface.
Public Member Functions inherited from crypto_trader::protocols::Observer
virtual ~Observer ()=default

Additional Inherited Members

Protected Attributes inherited from crypto_trader::protocols::Strategy
common::Emit d_emit
 Function to emit trading actions.

Detailed Description

Implements a "Buy and Hold" strategy with dynamic adjustments based on price movements.

This strategy aims to buy on dips and potentially sell on significant gains.

Constructor & Destructor Documentation

◆ HodlStrategy()

crypto_trader::strategies::HodlStrategy::HodlStrategy ( const HodlStrategyConfig & config,
traders::EventPositionManager & positionManager )

Constructs a HodlStrategy.

Parameters
configThe configuration for the strategy.
positionManagerA reference to the EventPositionManager for tracking positions.

◆ ~HodlStrategy()

crypto_trader::strategies::HodlStrategy::~HodlStrategy ( )

Destructor for HodlStrategy.

Member Function Documentation

◆ handleNewData()

void crypto_trader::strategies::HodlStrategy::handleNewData ( const nlohmann::json & data)
overridevirtual

Handles new market data received by the strategy.

Parameters
dataThe new market data, typically in JSON format.

Implements crypto_trader::protocols::Strategy.

◆ on_position_update()

void crypto_trader::strategies::HodlStrategy::on_position_update ( const std::string & symbol,
double new_position )
overridevirtual

Callback method invoked when a position update occurs.

Parameters
symbolThe trading symbol.
new_positionThe updated position quantity for the symbol.

Implements crypto_trader::protocols::Observer.

◆ on_trade()

void crypto_trader::strategies::HodlStrategy::on_trade ( const common::Trade & trade)
overridevirtual

Callback method invoked when a trade is executed.

Parameters
tradeThe details of the executed trade.

Implements crypto_trader::protocols::Observer.


The documentation for this class was generated from the following files:
  • /home/runner/work/crypto_trader/crypto_trader/strategies/hodl.h
  • /home/runner/work/crypto_trader/crypto_trader/strategies/hodl.cpp