/// <summary>
        /// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
        /// </summary>
        /// <param name="data">Slice object keyed by symbol containing the stock data</param>
        public override void OnData(Slice data)
        {
            if (!Portfolio.Invested)
            {
                SetHoldings("SPY", 1);
            }

            if (Time.Day == 11)
            {
                return;
            }
            if (!ActiveSecurities.ContainsKey("AIG"))
            {
                var aig = AddEquity("AIG", Resolution.Minute);

                var ticket = MarketOrder("AIG", 1);

                if (ticket.Status != OrderStatus.Invalid)
                {
                    throw new Exception("Expected order to always be invalid because there is no data yet!");
                }
            }
            else
            {
                RemoveSecurity("AIG");
            }
        }
示例#2
0
        public override void OnData(Slice data)
        {
            if (!Portfolio.Invested && Transactions.GetOpenOrders().Count == 0)
            {
                var aapl = QuantConnect.Symbol.Create("AAPL", SecurityType.Equity, Market.USA);
                SetHoldings(aapl, 0.5);
            }

            foreach (var customSymbol in _customSymbols)
            {
                if (!ActiveSecurities.ContainsKey(customSymbol.Underlying))
                {
                    throw new Exception($"Custom data underlying ({customSymbol.Underlying}) Symbol was not found in active securities");
                }
            }
        }