Exemplo n.º 1
0
    def Initialize(self):

        self.SetStartDate(2013, 10, 7)  #Set Start Date
        self.SetEndDate(2013, 10, 11)  #Set End Date
        self.SetCash(100000)  #Set Strategy Cash

        # 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
        self.AddEquity("SPY")
        self.AddEquity("IBM")
        self.AddEquity("BAC")
        self.AddEquity("AIG")

        # define a manual universe of all the securities we manually registered
        self.SetUniverseSelection(ManualUniverseSelectionModel())

        # define alpha model as a composite of the rsi and ema cross models
        self.SetAlpha(
            CompositeAlphaModel(RsiAlphaModel(), EmaCrossAlphaModel()))

        # default models for the rest
        self.SetPortfolioConstruction(
            EqualWeightingPortfolioConstructionModel())
        self.SetExecution(ImmediateExecutionModel())
        self.SetRiskManagement(NullRiskManagementModel())
    def Initialize(self):
        self.SetStartDate(2013, 10, 7)
        self.SetEndDate(2013, 10, 11)

        self.SetUniverseSelection(
            ManualUniverseSelectionModel([
                Symbol.Create('AIG', SecurityType.Equity, Market.USA),
                Symbol.Create('BAC', SecurityType.Equity, Market.USA),
                Symbol.Create('IBM', SecurityType.Equity, Market.USA),
                Symbol.Create('SPY', SecurityType.Equity, Market.USA)
            ]))

        # using hourly rsi to generate more insights
        self.SetAlpha(RsiAlphaModel(14, Resolution.Hour))
        self.SetPortfolioConstruction(
            EqualWeightingPortfolioConstructionModel())
        self.SetExecution(SpreadExecutionModel())

        self.InsightsGenerated += self.OnInsightsGenerated
Exemplo n.º 3
0
    def Initialize(self):
        ''' Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''

        # Set requested data resolution
        self.UniverseSettings.Resolution = Resolution.Minute

        self.SetStartDate(2013,10,7)
        self.SetEndDate(2013,10,11)
        self.SetCash(1000000)

        self.SetUniverseSelection(ManualUniverseSelectionModel([
            Symbol.Create('AIG', SecurityType.Equity, Market.USA),
            Symbol.Create('BAC', SecurityType.Equity, Market.USA),
            Symbol.Create('IBM', SecurityType.Equity, Market.USA),
            Symbol.Create('SPY', SecurityType.Equity, Market.USA)
        ]))

        self.SetAlpha(RsiAlphaModel(14, Resolution.Hour))
        self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())
        self.SetExecution(StandardDeviationExecutionModel())