コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FuturesChain"/> class
        /// </summary>
        /// <param name="canonicalFutureSymbol">The symbol for this chain.</param>
        /// <param name="time">The time of this chain</param>
        /// <param name="trades">All trade data for the entire futures chain</param>
        /// <param name="quotes">All quote data for the entire futures chain</param>
        /// <param name="contracts">All contrains for this futures chain</param>
        public FuturesChain(Symbol canonicalFutureSymbol, DateTime time, IEnumerable <BaseData> trades, IEnumerable <BaseData> quotes, IEnumerable <FuturesContract> contracts, IEnumerable <Symbol> filteredContracts)
        {
            Time              = time;
            Symbol            = canonicalFutureSymbol;
            DataType          = MarketDataType.FuturesChain;
            FilteredContracts = filteredContracts.ToHashSet();

            Ticks     = new Ticks(time);
            TradeBars = new TradeBars(time);
            QuoteBars = new QuoteBars(time);
            Contracts = new FuturesContracts(time);

            foreach (var trade in trades)
            {
                var tick = trade as Tick;
                if (tick != null)
                {
                    List <Tick> ticks;
                    if (!Ticks.TryGetValue(tick.Symbol, out ticks))
                    {
                        ticks = new List <Tick>();
                        Ticks[tick.Symbol] = ticks;
                    }
                    ticks.Add(tick);
                    continue;
                }
                var bar = trade as TradeBar;
                if (bar != null)
                {
                    TradeBars[trade.Symbol] = bar;
                }
            }

            foreach (var quote in quotes)
            {
                var tick = quote as Tick;
                if (tick != null)
                {
                    List <Tick> ticks;
                    if (!Ticks.TryGetValue(tick.Symbol, out ticks))
                    {
                        ticks = new List <Tick>();
                        Ticks[tick.Symbol] = ticks;
                    }
                    ticks.Add(tick);
                    continue;
                }
                var bar = quote as QuoteBar;
                if (bar != null)
                {
                    QuoteBars[quote.Symbol] = bar;
                }
            }

            foreach (var contract in contracts)
            {
                Contracts[contract.Symbol] = contract;
            }
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FuturesChain"/> class
 /// </summary>
 /// <param name="canonicalFutureSymbol">The symbol for this chain.</param>
 /// <param name="time">The time of this chain</param>
 public FuturesChain(Symbol canonicalFutureSymbol, DateTime time)
 {
     Time              = time;
     Symbol            = canonicalFutureSymbol;
     DataType          = MarketDataType.FuturesChain;
     Ticks             = new Ticks(time);
     TradeBars         = new TradeBars(time);
     QuoteBars         = new QuoteBars(time);
     Contracts         = new FuturesContracts(time);
     FilteredContracts = new HashSet <Symbol>();
 }