示例#1
0
 private static TradeDayCalculator CreateCommon(TradeDayInfo tradeDayInfo, InstrumentCloseQuotation closeQuotation, bool isReset)
 {
     if (closeQuotation != null)
     {
         tradeDayInfo.UpdateInstrumentDayClosePrice(closeQuotation.BuyPrice, closeQuotation.SellPrice);
     }
     return(new TradeDayCalculator(tradeDayInfo, isReset));
 }
        private InstrumentCloseQuotation GetQuotation(Settings.Instrument instrument, List <InstrumentCloseQuotation> quotations)
        {
            if (quotations.Count == 0)
            {
                return(null);
            }
            Dictionary <Guid, InstrumentCloseQuotation> quotationPerQuotePolicy = new Dictionary <Guid, InstrumentCloseQuotation>();

            foreach (var eachQuotation in quotations)
            {
                if (!quotationPerQuotePolicy.ContainsKey(eachQuotation.QuotePolicyId))
                {
                    quotationPerQuotePolicy.Add(eachQuotation.QuotePolicyId, eachQuotation);
                }
            }
            InstrumentCloseQuotation result = ((IQuotePolicyProvider)_account).Get <InstrumentCloseQuotation>(delegate(Guid id, out InstrumentCloseQuotation q)
            {
                return(quotationPerQuotePolicy.TryGetValue(id, out q));
            });

            return(result);
        }
        private void DoResetPerTradeDay(AccountClass.Instrument instrument, TradeDayInfo eachResetHistorySetting, InstrumentCloseQuotation closeQuotation)
        {
            var settingInstrument = Settings.Setting.Default.GetInstrument(instrument.Id, eachResetHistorySetting.TradeDay);
            var calculator        = TradeDayCalculatorFactory.CreateForReset(eachResetHistorySetting, closeQuotation, Settings.Setting.Default);

            calculator.Calculate();
            _account.AddBalance(settingInstrument.CurrencyId, calculator.Balance, calculator.ResetTime);
            OrderDayHistorySaver.Save(_account, instrument, calculator, eachResetHistorySetting, settingInstrument);
        }
示例#4
0
 internal static TradeDayCalculator CreateForHistoryOrder(TradeDayInfo tradeDayInfo, InstrumentCloseQuotation closeQuotation)
 {
     return(CreateCommon(tradeDayInfo, closeQuotation, false));
 }
示例#5
0
 internal static TradeDayCalculator CreateForReset(TradeDayInfo tradeDayInfo, InstrumentCloseQuotation closeQuotation)
 {
     return(CreateCommon(tradeDayInfo, closeQuotation, true));
 }