Overall Statistics
Total Trades
9
Average Win
1.13%
Average Loss
-4.84%
Compounding Annual Return
-37.561%
Drawdown
7.800%
Expectancy
-0.074
Net Profit
-3.797%
Sharpe Ratio
-1.758
Probabilistic Sharpe Ratio
13.754%
Loss Rate
25%
Win Rate
75%
Profit-Loss Ratio
0.23
Alpha
-0.326
Beta
-0.214
Annual Standard Deviation
0.178
Annual Variance
0.032
Information Ratio
-0.871
Tracking Error
0.284
Treynor Ratio
1.461
Total Fees
$13.22
from dateutil import parser
class ResistanceUncoupledThrustAssembly(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 8, 13)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        self.spy = self.AddEquity('SPY', Resolution.Daily).Symbol
        
    def OnData(self, data):
        if not self.Portfolio.Invested:
            self.SetHoldings(self.spy, 1)
            self.ObjectStore.Save(str(self.spy), str(self.Time))
        else:
            if self.ObjectStore.ContainsKey(str(self.spy)):
                date = self.ObjectStore.Read(str(self.spy))
                date = parser.parse(date)
                
                if (self.Time - date).days >= 5:
                    self.Liquidate(self.spy)
                    self.ObjectStore.Delete(str(self.spy))