Overall Statistics |
Total Trades 2 Average Win 7.74% Average Loss 0% Compounding Annual Return 1.250% Drawdown 6.600% Expectancy 0 Net Profit 7.743% Sharpe Ratio 0.251 Probabilistic Sharpe Ratio 1.415% Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0.003 Beta 0.065 Annual Standard Deviation 0.037 Annual Variance 0.001 Information Ratio -0.607 Tracking Error 0.147 Treynor Ratio 0.144 Total Fees $15.27 Estimated Strategy Capacity $15000000.00 Lowest Capacity Asset KO R735QTJ8XC9X |
# region imports from AlgorithmImports import * # endregion class TimeInvested(QCAlgorithm): def Initialize(self): self.SetStartDate(2015, 1, 1) # Set Start Date self.SetEndDate(2021, 1, 1) self.SetCash(100000) # Set Strategy Cash self.AddEquity("KO", Resolution.Daily) self.invest = True def OnData(self, data: Slice): if not self.Portfolio.Invested and self.invest: self.SetHoldings("KO", 0.5) self.invested_time = self.Time #Liquidate after 1000 days self.Log(self.Time - self.invested_time) #self.Log(self.Portfolio['KO'].Price) time_diff = (self.Time - self.invested_time).days if time_diff > 1000: self.Liquidate("KO") self.invest = False