Overall Statistics
Total Trades
14
Average Win
0.09%
Average Loss
-0.36%
Compounding Annual Return
51.545%
Drawdown
1.300%
Expectancy
-0.005
Net Profit
7.078%
Sharpe Ratio
4.73
Probabilistic Sharpe Ratio
93.122%
Loss Rate
20%
Win Rate
80%
Profit-Loss Ratio
0.24
Alpha
0.145
Beta
0.61
Annual Standard Deviation
0.073
Annual Variance
0.005
Information Ratio
0.278
Tracking Error
0.059
Treynor Ratio
0.569
Total Fees
$66.04
Estimated Strategy Capacity
$550000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
from datetime import timedelta
class MOMAlphaModel(AlphaModel): 
    def __init__(self):
        self.mom = []
    def OnSecuritiesChanged(self, algorithm, changes):
        for security in changes.AddedSecurities:
            symbol = security.Symbol
            self.mom.append({"symbol":symbol, "indicator":algorithm.MOM(symbol, 14, Resolution.Daily)})
    def Update(self, algorithm, data):
        ordered = sorted(self.mom, key=lambda kv: kv["indicator"].Current.Value, reverse=True)
        return Insight.Group([Insight.Price(ordered[0]['symbol'], timedelta(1), InsightDirection.Up), Insight.Price(ordered[1]['symbol'], timedelta(1), InsightDirection.Flat) ])
 
class FrameworkAlgorithm(QCAlgorithm):
    
    def Initialize(self):
        self.SetStartDate(2013, 10, 1)   
        self.SetEndDate(2013, 12, 1)    
        self.SetCash(100000)           
        symbols = [Symbol.Create("SPY", SecurityType.Equity, Market.USA),  Symbol.Create("BND", SecurityType.Equity, Market.USA)]
        self.UniverseSettings.Resolution = Resolution.Daily
        self.SetUniverseSelection(ManualUniverseSelectionModel(symbols))
        self.SetAlpha(MOMAlphaModel())
        self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())
        self.SetRiskManagement(MaximumDrawdownPercentPerSecurity(0.02))
        
        #1. Set the Execution Model to an Immediate Execution Model
        self.SetExecution(ImmediateExecutionModel())