public RevenueCurrencyConvertingMarkingCloseCalculator(
     Domain.Core.Financial.Money.Currency targetCurrency,
     ICurrencyConverterService currencyConverterService,
     IMarketTradingHoursService tradingHoursService,
     ILogger <RevenueCurrencyConvertingCalculator> logger)
     : base(targetCurrency, currencyConverterService, tradingHoursService, logger)
 {
 }
 public IRevenueCalculator RevenueCurrencyConvertingMarketClosureCalculator(Domain.Core.Financial.Money.Currency currency)
 {
     return(new RevenueCurrencyConvertingMarkingCloseCalculator(
                currency,
                this._currencyConverterService,
                this._tradingHoursService,
                this._currencyConvertingLogger));
 }
示例#3
0
 public ExchangeRateProfitBreakdown(
     ITradePosition positionCost,
     ITradePosition positionRevenue,
     decimal positionCostWer,
     decimal positionRevenueWer,
     Domain.Core.Financial.Money.Currency fixedCurrency,
     Domain.Core.Financial.Money.Currency variableCurrency)
 {
     this.PositionCost       = positionCost;
     this.PositionRevenue    = positionRevenue;
     this.PositionCostWer    = positionCostWer;
     this.PositionRevenueWer = positionRevenueWer;
     this.FixedCurrency      = fixedCurrency;
     this.VariableCurrency   = variableCurrency;
 }
        public async Task <ExchangeRateProfitBreakdown> ExchangeRateMovement(
            ITradePosition positionCost,
            ITradePosition positionRevenue,
            Domain.Core.Financial.Money.Currency variableCurrency,
            ISystemProcessOperationRunRuleContext ruleCtx)
        {
            if (string.IsNullOrEmpty(variableCurrency.Code))
            {
                this._logger.LogInformation(
                    "ExchangeRateProfitCalculator ExchangeRateMovement had a null or empty variable currency. Returning null.");
                return(null);
            }

            var orderCurrency = positionCost.Get()
                                .FirstOrDefault(pos => !string.IsNullOrWhiteSpace(pos.OrderCurrency.Code))?.OrderCurrency;

            if (string.Equals(orderCurrency?.Code, variableCurrency.Code, StringComparison.InvariantCultureIgnoreCase))
            {
                this._logger.LogInformation(
                    "ExchangeRateProfitCalculator ExchangeRateMovement could not find an order currency. Returning null.");
                return(null);
            }

            if (string.IsNullOrWhiteSpace(orderCurrency.GetValueOrDefault().Code))
            {
                orderCurrency = positionRevenue.Get()
                                .FirstOrDefault(pos => !string.IsNullOrWhiteSpace(pos.OrderCurrency.Code))?.OrderCurrency;
            }

            var costRates =
                await this._werExchangeRateService.WeightedExchangeRate(positionCost, variableCurrency, ruleCtx);

            var revenueRates = await this._werExchangeRateService.WeightedExchangeRate(
                positionRevenue,
                variableCurrency,
                ruleCtx);

            var breakdown = new ExchangeRateProfitBreakdown(
                positionCost,
                positionRevenue,
                costRates,
                revenueRates,
                orderCurrency.GetValueOrDefault(),
                variableCurrency);

            return(breakdown);
        }
示例#5
0
 public ICostCalculator CurrencyConvertingCalculator(Domain.Core.Financial.Money.Currency currency)
 {
     return(new CostCurrencyConvertingCalculator(this._currencyConverterService, currency, this._currencyLogger));
 }