Exemplo n.º 1
0
        internal static decimal CalculateInterestPerLot(Order order, decimal historyInterestPerLot, TradeDayInfo dayInfo)
        {
            decimal result = historyInterestPerLot;

            if (dayInfo.Settings.IsInterestUseAccountCurrency)
            {
                if (order.InterestValueDate == null || order.InterestValueDate <= dayInfo.TradeDay)
                {
                    if (dayInfo.Instrument.InterestFormula > 0)
                    {
                        result += InterestAndStorageCalculater.CalculateInterestPerLot((int)dayInfo.Instrument.InterestFormula, order.ExecutePrice, dayInfo.Settings.BuyPrice, dayInfo.Settings.SellPrice, dayInfo.Settings.IsUseSettlementPriceForInterest, dayInfo.Settings.InterestMultiple, dayInfo.Instrument.InterestYearDays, dayInfo.Settings.InterestRateBuy, dayInfo.Settings.InterestRateSell, order.IsBuy, order.Owner.ContractSize(dayInfo.TradeDay), dayInfo.RateSetting.RoundDecimals.Instrument);
                    }
                    else
                    {
                        decimal interestPerLot = InterestAndStorageCalculater.CalculateInterestPerLot((int)dayInfo.Instrument.InterestFormula, order.ExecutePrice, dayInfo.Settings.BuyPrice, dayInfo.Settings.SellPrice, dayInfo.Settings.IsUseSettlementPriceForInterest, dayInfo.Settings.InterestMultiple, dayInfo.Instrument.InterestYearDays, dayInfo.Settings.InterestRateBuy, dayInfo.Settings.InterestRateSell, order.IsBuy, order.Owner.ContractSize(dayInfo.TradeDay), dayInfo.RateSetting.RoundDecimals.Max);
                        result += interestPerLot.Exchange(1 / dayInfo.RateSetting.RateIn, 1 / dayInfo.RateSetting.RateOut, dayInfo.RateSetting.RoundDecimals.Max, null);
                    }
                }
            }
            else
            {
                if (order.InterestValueDate == null || order.InterestValueDate <= dayInfo.TradeDay)
                {
                    result += InterestAndStorageCalculater.CalculateInterestPerLot((int)dayInfo.Instrument.InterestFormula, order.ExecutePrice, dayInfo.Settings.BuyPrice, dayInfo.Settings.SellPrice, dayInfo.Settings.IsUseSettlementPriceForInterest, dayInfo.Settings.InterestMultiple, dayInfo.Instrument.InterestYearDays, dayInfo.Settings.InterestRateBuy, dayInfo.Settings.InterestRateSell, order.IsBuy, order.Owner.ContractSize(dayInfo.TradeDay), dayInfo.RateSetting.RoundDecimals.Instrument);
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        private TradeDayCommonResult CalculateCommonForOrder(Order order, DateTime tradeDay)
        {
            TradeDayCommonResult result          = new TradeDayCommonResult();
            OrderDayHistory      orderDayHistory = ResetManager.Default.GetOrderDayHistory(order.Id, tradeDay.AddDays(-1));

            result.StoragePerLot     = InterestAndStorageCalculater.CalculateStoragePerLot(order, orderDayHistory == null ? 0m : orderDayHistory.StoragePerLot, _info);
            result.InterestPerLot    = InterestAndStorageCalculater.CalculateInterestPerLot(order, orderDayHistory == null ? 0m : orderDayHistory.InterestPerLot, _info);
            result.InterestYearDays  = _info.Instrument.InterestYearDays;
            result.InterestValueDate = order.InterestValueDate;
            if (order.IsPhysical)
            {
                this.CalculateCommonForPhysicalOrder((PhysicalOrder)order, result);
            }
            return(result);
        }
Exemplo n.º 3
0
        internal static decimal CalculateStoragePerLot(Order order, decimal historyStoragePerLot, TradeDayInfo data)
        {
            decimal result = historyStoragePerLot;

            if (data.Settings.IsInterestUseAccountCurrency)
            {
                decimal storagePerLot = InterestAndStorageCalculater.CalculateStoragePerLot(data.Settings.InterestMultiple, data.Settings.StoragePerLotInterestRateBuy, data.Settings.StoragePerLotInterestRateSell, order.IsBuy);
                result += storagePerLot.Exchange(1 / data.RateSetting.RateIn, 1 / data.RateSetting.RateOut, data.RateSetting.RoundDecimals.Max, null);
            }
            else
            {
                var storagePerLot = InterestAndStorageCalculater.CalculateStoragePerLot(data.Settings.InterestMultiple, data.Settings.StoragePerLotInterestRateBuy, data.Settings.StoragePerLotInterestRateSell, order.IsBuy);
                result += Math.Round(storagePerLot, data.RateSetting.RoundDecimals.Instrument, MidpointRounding.AwayFromZero);
            }
            return(result);
        }