Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OptionChain"/> class
        /// </summary>
        /// <param name="canonicalOptionSymbol">The symbol for this chain.</param>
        /// <param name="time">The time of this chain</param>
        /// <param name="underlying">The most recent underlying trade data</param>
        /// <param name="trades">All trade data for the entire option chain</param>
        /// <param name="quotes">All quote data for the entire option chain</param>
        /// <param name="contracts">All contrains for this option chain</param>
        public OptionChain(Symbol canonicalOptionSymbol, DateTime time, BaseData underlying, IEnumerable <BaseData> trades, IEnumerable <BaseData> quotes, IEnumerable <OptionContract> contracts, IEnumerable <Symbol> filteredContracts)
        {
            Time              = time;
            Underlying        = underlying;
            Symbol            = canonicalOptionSymbol;
            DataType          = MarketDataType.OptionChain;
            FilteredContracts = filteredContracts.ToHashSet();

            Ticks     = new Ticks(time);
            TradeBars = new TradeBars(time);
            QuoteBars = new QuoteBars(time);
            Contracts = new OptionContracts(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;
            }
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OptionChain"/> class
 /// </summary>
 /// <param name="canonicalOptionSymbol">The symbol for this chain.</param>
 /// <param name="time">The time of this chain</param>
 public OptionChain(Symbol canonicalOptionSymbol, DateTime time)
 {
     Time              = time;
     Symbol            = canonicalOptionSymbol;
     DataType          = MarketDataType.OptionChain;
     Ticks             = new Ticks(time);
     TradeBars         = new TradeBars(time);
     QuoteBars         = new QuoteBars(time);
     Contracts         = new OptionContracts(time);
     FilteredContracts = new HashSet <Symbol>();
 }
Exemple #3
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>();
 }
Exemple #4
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 contracts for this futures chain</param>
        /// <param name="filteredContracts">The filtered list of contracts 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;
#if NETCORE
            FilteredContracts = LinqExtensions.ToHashSet(filteredContracts);
#else
            FilteredContracts = filteredContracts.ToHashSet();
#endif

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