Overall Statistics |
Total Trades 6 Average Win 0.32% Average Loss 0% Compounding Annual Return 53.503% Drawdown 3.600% Expectancy 0 Net Profit 20.101% Sharpe Ratio 2.998 Probabilistic Sharpe Ratio 87.044% Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0.519 Beta -0.083 Annual Standard Deviation 0.144 Annual Variance 0.021 Information Ratio -1.765 Tracking Error 0.344 Treynor Ratio -5.244 Total Fees $6.05 |
class GetCurrentPositions(QCAlgorithm): def Initialize(self): self.SetStartDate(2019, 2, 19) # Set Start Date self.SetStartDate(2020, 3, 19) # Set Start Date self.SetCash(100000) # Set Strategy Cash self.SPYSecurity = self.AddEquity("SPY", Resolution.Daily) self.isFirst = True self.Schedule.On(self.DateRules.EveryDay(self.SPYSecurity.Symbol) , self.TimeRules.AfterMarketOpen(self.SPYSecurity.Symbol, 1) , self.__TestCB) self.month = None def OnData(self, data): '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. Arguments: data: Slice object keyed by symbol containing the stock data ''' if self.isFirst: self.SetHoldings(self.SPYSecurity.Symbol, 0.5); self.isFirst = False for symbol, securityHolding in self.Portfolio.items(): # securityEquity = securityHolding.AveragePrice * securityHolding.Quantity securityEquity = securityHolding.AveragePrice * securityHolding.Quantity + securityHolding.TotalCloseProfit() self.Log("symbol: {} ratio: {}".format(symbol, securityEquity / self.Portfolio.TotalPortfolioValue)) # if not self.Portfolio.Invested: # self.SetHoldings("SPY", 1) def __TestCB(self): if not self.month == self.Time.month: self.month = self.Time.month self.SetHoldings(self.SPYSecurity.Symbol, 0.5); self.Log("After rebalance")