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); }
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); }