Overall Statistics
Total Trades
46
Average Win
1.19%
Average Loss
-1.48%
Compounding Annual Return
11.817%
Drawdown
4.200%
Expectancy
0.174
Net Profit
5.793%
Sharpe Ratio
1.181
Probabilistic Sharpe Ratio
53.840%
Loss Rate
35%
Win Rate
65%
Profit-Loss Ratio
0.80
Alpha
0.127
Beta
-0.08
Annual Standard Deviation
0.083
Annual Variance
0.007
Information Ratio
-1.215
Tracking Error
0.209
Treynor Ratio
-1.231
Total Fees
$70.76
class TransdimensionalNadionPrism(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 6, 1)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        
        self.profits = {}
        
        spy = self.AddEquity("SPY", Resolution.Daily).Symbol
        self.sma = self.SMA('SPY', 10, Resolution.Daily)
        
    def OnData(self, data):
        if not data.Bars.ContainsKey('SPY'):
            return
        
        if self.sma.Current.Value > data['SPY'].Close and not self.Portfolio.Invested:
            self.SetHoldings('SPY', 1)
        else:
            self.Liquidate('SPY')
            
    def OnOrderEvent(self, orderEvent):
        if orderEvent.Status == OrderStatus.Filled:
            profit = self.Portfolio[orderEvent.Symbol].LastTradeProfit
            
            # this prevents trades that open a position from adding a duplicate value
            if self.profits[orderEvent.Symbol].Count == 0 or profit != self.profits[orderEvent.Symbol][0]:
                self.profits[orderEvent.Symbol].Add(profit)
                if self.profits[orderEvent.Symbol].IsReady:
                    self.Plot('5th profit', 'value', self.profits[orderEvent.Symbol][4])
    def OnSecuritiesChanged(self, changed):
        for security in changed.AddedSecurities:
            sym = security.Symbol
            if sym not in self.profits:
                self.profits[sym] = RollingWindow[float](10)
        
        for security in changed.RemovedSecurities:
            self.Liduidate(security.Symbol)
            self.profits.pop(security.Symbol, None)