Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Monetary

Overview

Roboquant comes with several monetary classes that makes trading with multi-currency situations a lot easier.

Currency

A Currency represents a single currency (e.g. USD, EUR, JPY). Predefined currency instances are available as module-level constants and can be used directly. Currencies are not limited to fiat currencies and can be used for cryptocurrencies as well.

Currencies are callable and then create an Amount. Or you can use the ‘@’ operator to achieve the same.

1,000.00@DOGE
1,000.00@DOGE

Amount

An amount hold a monetary value of a single currency. Amounts are immutable. Internally amount values are stored as floats since that is precise enough for trading, and it doesn’t have the overhead of some other types.

Roboquant is not a ledger and for trading it doesn’t need to be.

20.00@USD
20@USD

Wallet

A wallet can contain monetary values of different currencies. A wallet is mutable and acts very much like a dict[Currency, float]

210.0@USD + 140.0@EUR + 800.0@JPY
210@USD + 140@EUR + 800@JPY
210.0 140.0 800.0

CurrencyConverter

If trading in more than one currency, a conversion is required between amounts in the different currencies.

Roboquant comes out of the box with a conversion using the exchange rates as published by the ECB.

USD 420.06087801227363
EUR 291.93194663442466