algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::runner::ChargedCosts Struct Reference

Commission and tax the broker stated on the orders a loop happened to poll (Toss states them; KIS does not). More...

#include <algotradelib/src/runner/loop.hpp>

Classes

struct  StatedTotal
 One currency's running figure and how many statements contributed to it. More...

Public Member Functions

std::optional< Decimal64 > commission_in (const Currency &currency) const
 Returns the commission stated in a currency.
std::optional< Decimal64 > tax_in (const Currency &currency) const
 Returns the tax stated in a currency.
std::size_t commission_statements_in (const Currency &currency) const
 Returns how many commission statements a currency has.
std::size_t tax_statements_in (const Currency &currency) const
 Returns how many tax statements a currency has.
bool add (std::vector< StatedTotal > &totals, const Money &amount)
 Adds an amount to its currency's figure in a list of totals.
ChargedCosts since (const ChargedCosts &before) const
 Returns what was observed since an earlier copy, for one run's report.

Static Public Member Functions

static std::optional< Decimal64 > figure_in (const std::vector< StatedTotal > &totals, const Currency &currency)
 Returns a currency's figure from a list of totals.
static std::size_t statements_in (const std::vector< StatedTotal > &totals, const Currency &currency)
 Returns a currency's statement count from a list of totals.

Public Attributes

std::vector< StatedTotal > commission_
 Commission stated, per currency; a currency with no statement has no entry (not zero).
std::vector< StatedTotal > tax_
 Tax stated, per currency, on the same terms.
std::size_t orders_stating_cost_ {0}
 How many orders have stated a cost (including zero); counted once per order, never decreased.
std::size_t orders_stating_none_ {0}
 How many orders were first seen stating no cost (every KIS order); never decreased, so an order that later states one is counted in both.
std::size_t working_list_disappearances_ {0}
 How many orders left the working-order listing between two polls (filled, cancelled or expired); a diagnostic, not a completeness measure.
std::size_t conflicting_restatements_ {0}
 How many times an order restated a different cost at the same filled quantity; the first figure is kept.
std::size_t unrepresentable_sums_ {0}
 How many additions or subtractions did not fit a Decimal64; nonzero means the figures are short (it counts attempts, and a re-polled row counts again).

Detailed Description

Commission and tax the broker stated on the orders a loop happened to poll (Toss states them; KIS does not).

A subtotal of unknown coverage, not a total: an order that fills and leaves the working-order listing between two polls, or is placed and filled between them, is never seen with its final cost.

Definition at line 303 of file loop.hpp.

Member Function Documentation

◆ add()

bool algotradelib::runner::ChargedCosts::add ( std::vector< StatedTotal > & totals,
const Money & amount )
inline

Adds an amount to its currency's figure in a list of totals.

Parameters
totalscommission_ or tax_.
amountThe amount.
Returns
false (counted in unrepresentable_sums_, figure unchanged) if the sum does not fit; the caller must not then treat the amount as counted.

Definition at line 386 of file loop.hpp.

◆ commission_in()

std::optional< Decimal64 > algotradelib::runner::ChargedCosts::commission_in ( const Currency & currency) const
inline

Returns the commission stated in a currency.

Parameters
currencyThe currency.
Returns
The figure, or std::nullopt if none was stated.

Definition at line 348 of file loop.hpp.

◆ commission_statements_in()

std::size_t algotradelib::runner::ChargedCosts::commission_statements_in ( const Currency & currency) const
inline

Returns how many commission statements a currency has.

Parameters
currencyThe currency.
Returns
The count.

Definition at line 366 of file loop.hpp.

◆ figure_in()

std::optional< Decimal64 > algotradelib::runner::ChargedCosts::figure_in ( const std::vector< StatedTotal > & totals,
const Currency & currency )
inlinestatic

Returns a currency's figure from a list of totals.

Parameters
totalsThe totals.
currencyThe currency.
Returns
The figure, or std::nullopt if none.

Definition at line 409 of file loop.hpp.

Referenced by commission_in(), and tax_in().

◆ since()

ChargedCosts algotradelib::runner::ChargedCosts::since ( const ChargedCosts & before) const
inline

Returns what was observed since an earlier copy, for one run's report.

A currency appears if its statement count rose (so a stated zero is kept). A money delta can be negative if the broker revised a figure down.

Parameters
beforeThe earlier copy.
Returns
The difference; a subtraction that does not fit is counted in unrepresentable_sums_.

Definition at line 448 of file loop.hpp.

Referenced by algotradelib::runner::PollingLoop< Runner, Source, Clock >::run().

◆ statements_in()

std::size_t algotradelib::runner::ChargedCosts::statements_in ( const std::vector< StatedTotal > & totals,
const Currency & currency )
inlinestatic

Returns a currency's statement count from a list of totals.

Parameters
totalsThe totals.
currencyThe currency.
Returns
The count; zero if none.

Definition at line 427 of file loop.hpp.

Referenced by commission_statements_in(), and tax_statements_in().

◆ tax_in()

std::optional< Decimal64 > algotradelib::runner::ChargedCosts::tax_in ( const Currency & currency) const
inline

Returns the tax stated in a currency.

Parameters
currencyThe currency.
Returns
The figure, or std::nullopt if none was stated.

Definition at line 357 of file loop.hpp.

◆ tax_statements_in()

std::size_t algotradelib::runner::ChargedCosts::tax_statements_in ( const Currency & currency) const
inline

Returns how many tax statements a currency has.

Parameters
currencyThe currency.
Returns
The count.

Definition at line 375 of file loop.hpp.

Member Data Documentation

◆ commission_

std::vector<StatedTotal> algotradelib::runner::ChargedCosts::commission_

Commission stated, per currency; a currency with no statement has no entry (not zero).

Definition at line 317 of file loop.hpp.

Referenced by commission_in(), commission_statements_in(), and since().

◆ conflicting_restatements_

std::size_t algotradelib::runner::ChargedCosts::conflicting_restatements_ {0}

How many times an order restated a different cost at the same filled quantity; the first figure is kept.

Definition at line 336 of file loop.hpp.

Referenced by since().

◆ orders_stating_cost_

std::size_t algotradelib::runner::ChargedCosts::orders_stating_cost_ {0}

How many orders have stated a cost (including zero); counted once per order, never decreased.

Definition at line 321 of file loop.hpp.

Referenced by since().

◆ orders_stating_none_

std::size_t algotradelib::runner::ChargedCosts::orders_stating_none_ {0}

How many orders were first seen stating no cost (every KIS order); never decreased, so an order that later states one is counted in both.

Definition at line 326 of file loop.hpp.

Referenced by since().

◆ tax_

std::vector<StatedTotal> algotradelib::runner::ChargedCosts::tax_

Tax stated, per currency, on the same terms.

Definition at line 319 of file loop.hpp.

Referenced by since(), tax_in(), and tax_statements_in().

◆ unrepresentable_sums_

std::size_t algotradelib::runner::ChargedCosts::unrepresentable_sums_ {0}

How many additions or subtractions did not fit a Decimal64; nonzero means the figures are short (it counts attempts, and a re-polled row counts again).

Definition at line 341 of file loop.hpp.

Referenced by add(), and since().

◆ working_list_disappearances_

std::size_t algotradelib::runner::ChargedCosts::working_list_disappearances_ {0}

How many orders left the working-order listing between two polls (filled, cancelled or expired); a diagnostic, not a completeness measure.

Definition at line 331 of file loop.hpp.

Referenced by since().


The documentation for this struct was generated from the following file: