value method
Implementation
@override
Future<MatexProfitAndLossResult> value() async {
final exchangeProvider = config.exchangeProvider;
if (isValid && exchangeProvider != null) {
await setExchangeRates();
final result = profitAndLoss(defaultState: state).value();
final baseListedSecond = state.baseListedSecond!;
final counterAccountCurrencyPairExchangeRate =
state.counterAccountCurrencyPairExchangeRate!;
if (baseListedSecond) {
return convertResultWithRate(result, 1);
} else if (counterAccountCurrencyPairExchangeRate == 0) {
final tradingPairExchangeRate = state.tradingPairExchangeRate!;
return convertResultWithRate(result, tradingPairExchangeRate);
}
final dInvertedRate = Decimal.one /
MatexDecimal.fromDouble(
counterAccountCurrencyPairExchangeRate,
);
return convertResultWithRate(result, dInvertedRate.toDouble());
}
return const MatexProfitAndLossResult();
}