algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::Currency Class Reference

A three-letter currency code, such as KRW or USD (ISO 4217 style). More...

#include <algotradelib/src/core/types.hpp>

Public Member Functions

 Currency ()
 Constructs Korean won.
 Currency (std::string_view code)
 Constructs a currency from its code.
std::string str () const
 Returns the code.

Static Public Member Functions

static Currency krw ()
 Returns Korean won.
static Currency usd ()
 Returns United States dollars.

Friends

bool operator== (const Currency &lhs, const Currency &rhs)
 Compares two currencies.

Detailed Description

A three-letter currency code, such as KRW or USD (ISO 4217 style).

Definition at line 234 of file types.hpp.

Constructor & Destructor Documentation

◆ Currency() [1/2]

algotradelib::Currency::Currency ( )
inline

Constructs Korean won.

Definition at line 237 of file types.hpp.

Referenced by krw(), operator==, and usd().

◆ Currency() [2/2]

algotradelib::Currency::Currency ( std::string_view code)
inlineexplicit

Constructs a currency from its code.

Parameters
codeThree uppercase ASCII letters.
Exceptions
std::invalid_argumentif code is not three uppercase ASCII letters.

Definition at line 245 of file types.hpp.

Member Function Documentation

◆ krw()

Currency algotradelib::Currency::krw ( )
inlinestatic

Returns Korean won.

Returns
KRW.

Definition at line 262 of file types.hpp.

◆ str()

std::string algotradelib::Currency::str ( ) const
inline

Returns the code.

Returns
The three letters.

Definition at line 274 of file types.hpp.

◆ usd()

Currency algotradelib::Currency::usd ( )
inlinestatic

Returns United States dollars.

Returns
USD.

Definition at line 268 of file types.hpp.

◆ operator==

bool operator== ( const Currency & lhs,
const Currency & rhs )
friend

Compares two currencies.

Parameters
lhsThe first currency.
rhsThe second currency.
Returns
true if the codes are equal.

Definition at line 282 of file types.hpp.


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