pub trait CurrencyConverter {
// Required method
fn convert<'life0, 'async_trait>(
&'life0 self,
value: f64,
from: Currency,
to: Currency,
) -> Pin<Box<dyn Future<Output = Option<f64>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Converts monetary values between currencies.
Used by strategy.convert_to_account() and
strategy.convert_to_symbol(). The default implementation
(IdentityCurrencyConverter) returns the input value unchanged, which
is correct when the symbol currency equals the account currency.
Supply a custom implementation via
InstanceBuilder::with_currency_converter() to enable cross-currency
backtesting.
Required Methods§
Sourcefn convert<'life0, 'async_trait>(
&'life0 self,
value: f64,
from: Currency,
to: Currency,
) -> Pin<Box<dyn Future<Output = Option<f64>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn convert<'life0, 'async_trait>(
&'life0 self,
value: f64,
from: Currency,
to: Currency,
) -> Pin<Box<dyn Future<Output = Option<f64>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Converts value expressed in from currency to to currency.
Returns None if the conversion is not possible (e.g. missing rate).