Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return -46.499% Drawdown 50.900% Expectancy 0 Net Profit -25.272% Sharpe Ratio -0.217 Probabilistic Sharpe Ratio 15.674% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.043 Beta -0.201 Annual Standard Deviation 0.688 Annual Variance 0.473 Information Ratio -1.447 Tracking Error 0.765 Treynor Ratio 0.744 Total Fees $10.04 |
class GetCurrentPositions(QCAlgorithm): def Initialize(self): self.SetStartDate(2019, 2, 19) # Set Start Date self.SetStartDate(2020, 3, 19) # Set Start Date self.SetCash(1000000) # Set Strategy Cash self.SPYSecurity = self.AddEquity("AAPL", 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 self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage) 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() securityTotalValue = securityHolding.Price * securityHolding.Quantity # + 0 * securityHolding.TotalCloseProfit() self.Log("symbol: {} ratio: {}".format(symbol, securityTotalValue / 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")