private async Task <Money?> CalculateRealisedRevenue
            (IList <Order> activeFulfilledTradeOrders,
            Domain.Core.Financial.Money.Currency targetCurrency,
            DateTime universeDateTime,
            ISystemProcessOperationRunRuleContext ruleCtx)
        {
            if (!activeFulfilledTradeOrders?.Any() ?? true)
            {
                return(null);
            }

            var filledOrders =
                activeFulfilledTradeOrders
                .Where(afto => afto.OrderDirection == OrderDirections.SELL ||
                       afto.OrderDirection == OrderDirections.SHORT)
                .Select(afto =>
                        new Money(
                            afto.OrderFilledVolume.GetValueOrDefault(0) * afto.OrderAverageFillPrice.GetValueOrDefault().Value,
                            afto.OrderCurrency))
                .ToList();

            var conversion = await _currencyConverterService.Convert(filledOrders, targetCurrency, universeDateTime, ruleCtx);

            return(conversion);
        }
 public CostCurrencyConvertingCalculator(
     ICurrencyConverterService currencyConverterService,
     Domain.Core.Financial.Money.Currency targetCurrency,
     ILogger <CostCurrencyConvertingCalculator> logger)
 {
     this._currencyConverterService = currencyConverterService
                                      ?? throw new ArgumentNullException(nameof(currencyConverterService));
     this._targetCurrency = targetCurrency;
     this._logger         = logger ?? throw new ArgumentNullException(nameof(logger));
 }
 public RevenueCurrencyConvertingCalculator(
     Domain.Core.Financial.Money.Currency targetCurrency,
     ICurrencyConverterService currencyConverterService,
     IMarketTradingHoursService tradingHoursService,
     ILogger <RevenueCurrencyConvertingCalculator> logger)
 {
     _targetCurrency           = targetCurrency;
     _currencyConverterService = currencyConverterService ?? throw new ArgumentNullException(nameof(currencyConverterService));
     TradingHoursService       = tradingHoursService ?? throw new ArgumentNullException(nameof(tradingHoursService));
     Logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }