crypto_trader
Cryptocurrency Trading Bot API Documentation
Loading...
Searching...
No Matches
crypto_trader::common::Accounting Class Reference

Manages the accounting of trading activities, tracking positions and PnL. More...

#include <Accounting.h>

Collaboration diagram for crypto_trader::common::Accounting:
Collaboration graph

Public Types

using PositionMap

Public Member Functions

void apply_event (const Event &e)
 Applies a single trade event to update the accounting state.
const PositionMapsnapshot () const
 Provides a const reference to the current snapshot of all positions.
void replay_events (const std::vector< Event > &events)
 Replays a vector of historical events to reconstruct the accounting state. Clears all current positions and event logs before replaying.
 Accounting ()=default
 Constructs an empty Accounting object.

Detailed Description

Manages the accounting of trading activities, tracking positions and PnL.

This class processes trade events to maintain an accurate record of holdings, average prices, and realized profit/loss for various trading symbols.

Member Typedef Documentation

◆ PositionMap

Initial value:
std::map<std::string, SymbolPositions>

Map from symbol string to its aggregated positions.

Constructor & Destructor Documentation

◆ Accounting()

crypto_trader::common::Accounting::Accounting ( )
default

Constructs an empty Accounting object.

Member Function Documentation

◆ apply_event()

void crypto_trader::common::Accounting::apply_event ( const Event & e)

Applies a single trade event to update the accounting state.

Parameters
eThe trade event to apply.

◆ replay_events()

void crypto_trader::common::Accounting::replay_events ( const std::vector< Event > & events)

Replays a vector of historical events to reconstruct the accounting state. Clears all current positions and event logs before replaying.

Parameters
eventsA vector of historical trade events.

◆ snapshot()

const Accounting::PositionMap & crypto_trader::common::Accounting::snapshot ( ) const

Provides a const reference to the current snapshot of all positions.

Returns
A const reference to the map of symbol positions.

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