Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees $0.00 |
import numpy as np class OptimizedVerticalRadiator(QCAlgorithm): def Initialize(self): self.SetStartDate(2019, 4, 1) # Set Start Date self.SetEndDate(2019, 7, 1) self.SetCash(100000) # Set Strategy Cash self.equity_symbols = [ "AAPL", "FB", "TSLA", "AMD", "AMZN", "BABA", "BAC", "BYND", "MSFT", "NFLX", "MU", "NVDA", "SNAP", "GE", "DIS", "T", "BA", "ROKU", "UBER", "NIO", "CRM", "INTC", "X", "TWTR", "QCOM", "CSCO", "JPM", "CZR", "WDC", "JD", "GOOGL", "TEVA", "F", "WMT", "PCG", "C", "SQ", "FCX", "ADBE", "LYFT", "CGC", "ORCL", "OXY", "V", "PFE", "QSR", "S", "VZ", "LULU", "AVGO", "BMY", "MPC", "BB", "WFC", "CVS", "IQ", "BX", "BIDU", "GOLD", "KO", "SBUX", "ABBV", "ACB", "PYPL", "CNC", "TWLO", "CRON", "FDX", "UNH", "NKE", "CMG", "MRK", "TLRY", "HAL", "GM", "HD", "GS", "SHOP", "GOOG", "CHK", "XOM", "MA", "AAL", "CAT", "PBR", "RIG", "ZM", "CLF", "M", "WYNN", "JNJ", "KR", "IBM", "DISH", "MO", "TGT", "DELL", "DBX", "COST", "CMCSA", "KHC", "PG", "BHC", "EA", "OSTK", "SLB", "TRP", "JCI", "LVS", "AMAT", "MCD", "CVX", "CELG", "TTD", "AGN", "QD", "DOCU", "CLDR", "BCE", "LEN", "EBAY", "GME", "APC", "DAL", "XLNX", "AMGN", "AMRN", "NEM", "ATVI", "WBA", "OKTA", "KMI", "CTL", "SFIX", "LNG", "BP", "MDR", "GILD", "STZ", "UPS", "AXP", "GRUB", "BNS", "HOME", "PWR", "NOK", "UNP", "ACN", "APA", "DHI" ] # suppose you want to get the true range of previous 90 days self.lookback = 90 # store the TRs of given symbols self.tr = {} for ticker in self.equity_symbols: self.AddEquity(ticker, Resolution.Daily) def OnData(self, data): # get the previous 90 days of data for given symbols history = self.History(self.equity_symbols, self.lookback, Resolution.Daily) for ticker in self.equity_symbols: # if the ticker has data if data.ContainsKey(ticker): # true value = max(high) - min(low) self.tr[ticker] = history.loc[ticker]['high'].max() - history.loc[ticker]['low'].min() # print out the TR of AAPL for validation if ticker == "AAPL": self.Log(f"{ticker}'s TR Value: {self.tr[ticker]}")