Hi everyone, I'm trying to calculate volatility by dividing ATR by the stock's price, but I keep getting the error that I can't divide AverageTrueRange Object by float. The relevant code and the whole program is attached below. Thanks to anyone who can help!


for ticker in symbols:
self.tickers[ticker] = self.ATR(ticker, 14, MovingAverageType.Simple, Resolution.Minute)/self.Securities[ticker].Price 

class EmotionalFluorescentPinkSalmon(QCAlgorithm):

def Initialize(self):
self.SetStartDate(2018, 1, 1)
self.SetEndDate(2021, 11, 1)
self.SetCash(100000)

self.tickers = {}

symbols = ["AMZN", "MSFT", "AAPL"]

for ticker in symbols:
self.tickers[ticker] = self.ATR(ticker, 14, MovingAverageType.Simple, Resolution.Minute)/self.Securities[ticker].Price

self.tickers = {k: v for k, v in sorted(self.tickers.items(), key=lambda item: item[1], reverse=True)[:1]}

self.portfolio_targets = []

for stock, volt in self.tickers.items():
self.stock = self.AddEquity(stock, Resolution.Minute).Symbol
self.portfolio_targets.append(self.stock)

self.spy = self.AddEquity("SPY", Resolution.Minute).Symbol
self.SetWarmUp(1, Resolution.Daily)
self.yest_close = self.SMA(self.spy, 1, Resolution.Daily, Field.Close)

"""
Figure out universe selection error
"""

def OnData(self, data):

if self.IsWarmingUp or not self.yest_close.IsReady or not len(data.Bars) > 0:
return

# If SPY is above yesterday's close at 9:45, go long all stocks in ticker_symbols
if self.Time.hour == 9 and self.Time.minute == 45:
for stock in self.portfolio_targets:
price = self.Securities[self.spy].Price
yest_close = self.yest_close.Current.Value

if price < yest_close:
self.SetHoldings(stock, 1/len(self.portfolio_targets))

if self.Time.hour == 15 and self.Time.minute == 45:
self.Liquidate()