Currencies Module¶
Currency Framework¶
Currency¶
- class pyquantlib.Currency¶
Bases:
pybind11_objectCurrency specification.
usd = ql.USDCurrency()
print(usd.name()) # "U.S. dollar"
print(usd.code()) # "USD"
print(usd.symbol()) # "$"
Available Currencies¶
Region |
Currencies |
|---|---|
Americas |
USD, CAD, MXN, BRL, ARS, CLP, COP, PEN |
Europe |
EUR, GBP, CHF, SEK, NOK, DKK, PLN, CZK, HUF, RON |
Asia-Pacific |
JPY, CNY, CNH, HKD, SGD, AUD, NZD, KRW, TWD, INR, THB, MYR, IDR, PHP |
Middle East/Africa |
AED, SAR, ILS, ZAR, EGP, KES, NGN |
Crypto |
BTC, ETH, LTC, XRP, DASH, ZEC |
Money¶
- class pyquantlib.Money¶
Bases:
pybind11_objectAmount of cash in a specific currency.
- class ConversionType¶
Bases:
pybind11_objectConversion type for money arithmetic.
Members:
NoConversion : Do not perform conversions.
BaseCurrencyConversion : Convert both operands to base currency.
AutomatedConversion : Return result in the currency of the first operand.
- __init__(value: SupportsInt | SupportsIndex) None¶
- AutomatedConversion = <ConversionType.AutomatedConversion: 2>¶
- BaseCurrencyConversion = <ConversionType.BaseCurrencyConversion: 1>¶
- NoConversion = <ConversionType.NoConversion: 0>¶
- Money.ConversionType.name -> str
- property value¶
- class Settings¶
Bases:
pybind11_objectPer-session settings for Money arithmetic.
- static instance() Money.Settings¶
Returns the singleton instance.
- __init__(*args, **kwargs)¶
- property baseCurrency¶
The base currency used for conversions.
- property conversionType¶
The conversion type used for money arithmetic.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__() -> None
Default constructor.
__init__(currency: Currency, value: SupportsFloat | SupportsIndex) -> None
Constructs from currency and value.
__init__(value: SupportsFloat | SupportsIndex, currency: Currency) -> None
Constructs from value and currency.
- AutomatedConversion = <ConversionType.AutomatedConversion: 2>¶
- BaseCurrencyConversion = <ConversionType.BaseCurrencyConversion: 1>¶
- NoConversion = <ConversionType.NoConversion: 0>¶
usd_amount = ql.Money(100.0, ql.USDCurrency())
print(usd_amount.value())
print(usd_amount.currency())
ExchangeRate¶
- class pyquantlib.ExchangeRate¶
Bases:
pybind11_objectExchange rate between two currencies.
- class Type¶
Bases:
pybind11_objectType of exchange rate.
Members:
Direct : Directly quoted rate.
Derived : Rate derived from other rates.
- __init__(value: SupportsInt | SupportsIndex) None¶
- Derived = <Type.Derived: 1>¶
- Direct = <Type.Direct: 0>¶
- ExchangeRate.Type.name -> str
- property value¶
- static chain(r1: ExchangeRate, r2: ExchangeRate) ExchangeRate¶
Creates a derived rate by chaining two rates.
- __init__(source: Currency, target: Currency, rate: SupportsFloat | SupportsIndex) None¶
Constructs an exchange rate from source to target currency.
- type() ExchangeRate.Type¶
Returns the type of the exchange rate.
- Derived = <Type.Derived: 1>¶
- Direct = <Type.Direct: 0>¶
rate = ql.ExchangeRate(ql.EURCurrency(), ql.USDCurrency(), 1.10)
usd_amount = rate.exchange(eur_amount)
ExchangeRateManager¶
- class pyquantlib.ExchangeRateManager¶
Bases:
pybind11_objectGlobal repository for exchange rates.
- static instance() ExchangeRateManager¶
Returns the singleton instance.
- __init__(*args, **kwargs)¶
- add(rate: ExchangeRate, startDate: Date = <Date: January 1st, 1901>, endDate: Date = <Date: December 31st, 2199>) None¶
Adds an exchange rate.
- lookup(source: Currency, target: Currency, date: Date = <Date: null date>, type: ExchangeRate.Type = <Type.Derived: 1>) ExchangeRate¶
Looks up an exchange rate between two currencies.