示例#1
0
        private decimal RecoverOrderDayHistory(DateTime tradeDay, List <Guid> affectedOrders)
        {
            var                settingInstrument         = _setting.GetInstrument(_instrumentId, tradeDay);
            var                instrumentTradeDaySetting = ResetManager.Default.LoadInstrumentHistorySettingAndData(_account.Id, _instrumentId, tradeDay);
            TradeDayInfo       tradeDayInfo       = new TradeDayInfo(_account, _instrumentId, tradeDay, instrumentTradeDaySetting, affectedOrders, _setting);
            var                closeQuotation     = _InstrumentDayClosePriceFactory.GetQuotation(settingInstrument, tradeDay);
            TradeDayCalculator tradeDayCalculator = TradeDayCalculatorFactory.CreateForHistoryOrder(tradeDayInfo, closeQuotation);

            tradeDayCalculator.Calculate();
            var resetResults = tradeDayCalculator.ResetResults;

            if (resetResults == null)
            {
                return(0m);
            }
            OrderDayHistorySaver.Save(_account, _account.GetInstrument(_instrumentId), tradeDayCalculator, tradeDayInfo, settingInstrument);
            return(tradeDayCalculator.ValuedPLForBook);
        }
示例#2
0
        internal static void Save(Account account, AccountClass.Instrument instrument, TradeDayCalculator calculator, TradeDayInfo tradeDayInfo, Settings.Instrument settingInstrument)
        {
            InstrumentResetItem resetItem = CreateInstrumentResetItem(tradeDayInfo.TradeDay, instrument, calculator.ResetResults, tradeDayInfo.Settings.BuyPrice, tradeDayInfo.Settings.SellPrice);

            resetItem.ResetBalance = calculator.Balance;
            instrument.AddResetItem(tradeDayInfo.TradeDay, resetItem);
            AddOrderResetToAccount(account, calculator.ResetResults);
            AddResetResultToOrderDayHistory(account, calculator.ResetResults);
        }