Esempio n. 1
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);
        }
Esempio n. 2
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);
        }