Example #1
0
        public override void Initialize()
        {
            SetStartDate(2013, 10, 07);
            SetEndDate(2013, 10, 11);

            // even though we're using a framework algorithm, we can still add our securities
            // using the AddEquity/Forex/Crypto/ect methods and then pass them into a manual
            // universe selection model using Securities.Keys
            AddEquity("SPY");
            AddEquity("IBM");
            AddEquity("BAC");
            AddEquity("AIG");

            // define a manual universe of all the securities we manually registered
            UniverseSelection = new ManualUniverseSelectionModel(Securities.Keys);

            // define alpha model as a composite of the rsi and ema cross models
            Alpha = new CompositeAlphaModel(
                new RsiAlphaModel(),
                new EmaCrossAlphaModel()
                );

            // default models for the rest
            PortfolioConstruction = new EqualWeightingPortfolioConstructionModel();
            Execution             = new ImmediateExecutionModel();
            RiskManagement        = new NullRiskManagementModel();
        }
Example #2
0
        public override void Initialize()
        {
            SetStartDate(2013, 10, 07);
            SetEndDate(2013, 10, 11);

            var bac = AddEquity("BAC");
            var aig = AddEquity("AIG");

            UniverseSelection     = new ManualUniverseSelectionModel(Securities.Keys);
            Alpha                 = new PairsTradingAlphaModel(bac.Symbol, aig.Symbol);
            PortfolioConstruction = new EqualWeightingPortfolioConstructionModel();
            Execution             = new ImmediateExecutionModel();
            RiskManagement        = new NullRiskManagementModel();
        }
        public void ExcludesCanonicalSymbols()
        {
            var symbols = new[]
            {
                Symbols.SPY,
                Symbol.CreateOption(Symbols.SPY, Market.USA, default(OptionStyle), default(OptionRight), 0m, SecurityIdentifier.DefaultDate, "?SPY")
            };

            var model           = new ManualUniverseSelectionModel(symbols);
            var universe        = model.CreateUniverses(new QCAlgorithmFramework()).Single();
            var selectedSymbols = universe.SelectSymbols(default(DateTime), null).ToList();

            Assert.AreEqual(1, selectedSymbols.Count);
            Assert.AreEqual(Symbols.SPY, selectedSymbols[0]);
            Assert.IsFalse(selectedSymbols.Any(s => s.IsCanonical()));
        }
        public override void Initialize()
        {
            UniverseSettings.Resolution = Resolution.Minute;

            SetStartDate(2013, 10, 07);
            SetEndDate(2013, 10, 11);
            SetCash(1000000);

            UniverseSelection = new ManualUniverseSelectionModel(
                QuantConnect.Symbol.Create("AIG", SecurityType.Equity, Market.USA),
                QuantConnect.Symbol.Create("BAC", SecurityType.Equity, Market.USA),
                QuantConnect.Symbol.Create("IBM", SecurityType.Equity, Market.USA),
                QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA)
                );

            // using hourly rsi to generate more insights
            Alpha = new RsiAlphaModel(14, Resolution.Hour);
            PortfolioConstruction = new EqualWeightingPortfolioConstructionModel();
            Execution             = new StandardDeviationExecutionModel();
        }
Example #5
0
        /// <summary>
        /// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
        /// </summary>
        public override void Initialize()
        {
            // Set requested data resolution
            UniverseSettings.Resolution = Resolution.Minute;

            SetStartDate(2013, 10, 07);  //Set Start Date
            SetEndDate(2013, 10, 11);    //Set End Date
            SetCash(100000);             //Set Strategy Cash

            // Find more symbols here: http://quantconnect.com/data
            // Forex, CFD, Equities Resolutions: Tick, Second, Minute, Hour, Daily.
            // Futures Resolution: Tick, Second, Minute
            // Options Resolution: Minute Only.

            // set algorithm framework models
            UniverseSelection     = new ManualUniverseSelectionModel(QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA));
            Alpha                 = new ConstantAlphaModel(InsightType.Price, InsightDirection.Up, TimeSpan.FromMinutes(20), 0.025, null);
            PortfolioConstruction = new EqualWeightingPortfolioConstructionModel();
            Execution             = new ImmediateExecutionModel();
            RiskManagement        = new MaximumDrawdownPercentPerSecurity(0.01m);
        }
        public override void Initialize()
        {
            UniverseSettings.Resolution = Resolution.Minute;

            SetStartDate(2013, 10, 07);
            SetEndDate(2013, 10, 11);
            SetCash(1000000);

            UniverseSelection = new ManualUniverseSelectionModel(
                QuantConnect.Symbol.Create("AIG", SecurityType.Equity, Market.USA),
                QuantConnect.Symbol.Create("BAC", SecurityType.Equity, Market.USA),
                QuantConnect.Symbol.Create("IBM", SecurityType.Equity, Market.USA),
                QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA)
                );

            // using hourly rsi to generate more insights
            Alpha = new RsiAlphaModel(14, Resolution.Hour);
            PortfolioConstruction = new EqualWeightingPortfolioConstructionModel();
            Execution             = new VolumeWeightedAveragePriceExecutionModel();

            InsightsGenerated += (algorithm, data) => Log($"{Time}: {string.Join(" | ", data.Insights)}");
        }
Example #7
0
        /// <summary>
        /// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
        /// </summary>
        public override void Initialize()
        {
            // Set requested data resolution
            UniverseSettings.Resolution = Resolution.Minute;

            SetStartDate(2016, 10, 7);  //Set Start Date
            SetEndDate(2016, 10, 7);    //Set End Date
            SetCash(100000);            //Set Strategy Cash

            // Find more symbols here: http://quantconnect.com/data
            // Forex, CFD, Equities Resolutions: Tick, Second, Minute, Hour, Daily.
            // Futures Resolution: Tick, Second, Minute
            // Options Resolution: Minute Only.

            SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash);

            // set algorithm framework models
            UniverseSelection     = new ManualUniverseSelectionModel(QuantConnect.Symbol.Create("BTCUSD", SecurityType.Crypto, Market.GDAX));
            Alpha                 = new ConstantAlphaModel(InsightType.Price, InsightDirection.Up, TimeSpan.FromMinutes(20), 0.025, null);
            PortfolioConstruction = new EqualWeightingPortfolioConstructionModel();
            Execution             = new ImmediateExecutionModel();
            RiskManagement        = new Algorithm.Framework.Risk.NullRiskManagementModel();
        }