Overall Statistics
Total Trades
322
Average Win
1.63%
Average Loss
-0.71%
Compounding Annual Return
33.154%
Drawdown
15.600%
Expectancy
0.930
Net Profit
331.909%
Sharpe Ratio
1.754
Probabilistic Sharpe Ratio
92.395%
Loss Rate
41%
Win Rate
59%
Profit-Loss Ratio
2.30
Alpha
0.29
Beta
-0.049
Annual Standard Deviation
0.161
Annual Variance
0.026
Information Ratio
0.517
Tracking Error
0.239
Treynor Ratio
-5.723
Total Fees
$11630.65
Estimated Strategy Capacity
$600000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
class PriceActionLSSPY(QCAlgorithm):
    
    def Initialize(self):
        
        self.SetStartDate(2016, 6, 1)  
        self.SetEndDate(2021, 7, 12)  
        self.SetCash(1000000)  
        self.AddEquity("SPY", Resolution.Daily)  
        self.SetBenchmark("SPY")
        self.SetBrokerageModel(BrokerageName.AlphaStreams)
        self.SetExecution(ImmediateExecutionModel())
        self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())
        
        symbol = [Symbol.Create("SPY", SecurityType.Equity, Market.USA)]
        self.AddUniverseSelection(ManualUniverseSelectionModel(symbol))
        
        self.AddAlpha(PriceActionLSSPYAlphaModel("SPY"))
        
        
class PriceActionLSSPYAlphaModel(AlphaModel):
    
    def __init__(self, tkr):
        self.period = timedelta(1)
        self.symbol = tkr
    
    def Update(self, algorithm,data):
        insights = []
        
        HO = 0.0
        OL = 0.0
        
        if data.ContainsKey(self.symbol):
            Open  = data[self.symbol].Open
            High  = data[self.symbol].High
            Low   = data[self.symbol].Low
            Close = data[self.symbol].Close
            Volume = data[self.symbol].Volume
            
            HO = High -  Open
            OL = abs(Open - Low)
            HC = High - Close
            CL = abs(Close - Low)
            
            if Close > Open:
                if HO > OL:
                    insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Up, 1, None))
                
            if Close < Open:
                if HO < OL:
                    insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Up, 1, None))
                if HO > OL:
                    insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Down, 1, None))
                if HO == OL:
                    insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Up, 1, None))
                    
            if Close == Open:
                if HO < OL:
                    insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Up, 1, None))
                if HO > OL:
                    insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Down, 1, None))
                if HO == OL:
                    insights.append(Insight(self.symbol, self.period, InsightType.Price, InsightDirection.Flat, 1, None))
                
        return insights
        
    def OnSecuritiesChanged(self, algorithm, changes):
        self.changes =  changes