Currency ¶
- class Currency ( unicode code , uint8_t precision , uint16_t iso4217 , unicode name , CurrencyType currency_type ) ¶
-
Bases:
object
Represents a medium of exchange in a specified denomination with a fixed decimal precision.
Handles up to 9 decimals of precision.
- Parameters :
-
-
code ( str ) – The currency code.
-
precision ( uint8 ) – The currency decimal precision.
-
iso4217 ( uint16 ) – The currency ISO 4217 code.
-
name ( str ) – The currency name.
-
currency_type ( CurrencyType ) – The currency type.
-
- Raises :
-
-
ValueError – If code is not a valid string.
-
OverflowError – If precision is negative (< 0).
-
ValueError – If precision greater than 9.
-
ValueError – If name is not a valid string.
-
- code ¶
-
Return the currency code.
- Returns :
-
str
- currency_type ¶
-
Return the currency type.
- Returns :
-
CurrencyType
- static from_str ( unicode code , bool strict=False ) ¶
-
Parse a currency from the given string (if found).
- Parameters :
-
-
code ( str ) – The code of the currency.
-
strict ( bool , default False ) – If not strict mode then an unknown currency will very likely be a Cryptocurrency, so for robustness will then return a new Currency object using the given code with a default precision of 8.
-
- Returns :
-
Currency or
None
- static is_crypto ( unicode code ) ¶
-
Return whether a currency with the given code is
CRYPTO
.- Parameters :
-
code ( str ) – The code of the currency.
- Returns :
-
bool – True if
CRYPTO
, else False. - Raises :
-
ValueError – If code is not a valid string.
- static is_fiat ( unicode code ) ¶
-
Return whether a currency with the given code is
FIAT
.- Parameters :
-
code ( str ) – The code of the currency.
- Returns :
-
bool – True if
FIAT
, else False. - Raises :
-
ValueError – If code is not a valid string.
- iso4217 ¶
-
Return the currency ISO 4217 code.
- Returns :
-
str
- name ¶
-
Return the currency name.
- Returns :
-
str
- precision ¶
-
Return the currency decimal precision.
- Returns :
-
uint8