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(); }
/// <summary> /// Adds a new alpha model /// </summary> /// <param name="alpha">Model that generates alpha to add</param> public void AddAlpha(IAlphaModel alpha) { if (Alpha.GetType() != typeof(NullAlphaModel)) { var compositeAlphaModel = Alpha as CompositeAlphaModel; if (compositeAlphaModel != null) { compositeAlphaModel.AddAlpha(alpha); } else { Alpha = new CompositeAlphaModel(Alpha, alpha); } } else { Alpha = alpha; } }