TypeError: 'NoneType' object is not iterable when fetching websocket data

fyersSocket = ws.FyersSocket(access_token=feedtoken,run_background=True,log_path=‘/content’)

brokerTicks = fyersSocket.subscribe(symbol=symbol,data_type=data_type)

ticks =

for bTick in brokerTicks:

isd = Instruments.getInstrumentDataBySymbol(bTick[‘symbol’])

tradingSymbol = isd[‘symbol’]

tick = TickData(tradingSymbol)

tick.lastTradedPrice = bTick[‘ltp’]

tick.lastTradedQuantity = bTick[‘last_traded_quantity’]

tick.avgTradedPrice = bTick[‘avg_trade_price’]

tick.volume = bTick[‘vol_traded_today’]

tick.totalBuyQuantity = bTick[‘tot_buy_qty’]

tick.totalSellQuantity = bTick[‘tot_sell_qty’]

tick.open = bTick[‘open_price’]

tick.high = bTick[‘high_price’]

tick.low = bTick[‘low_price’]

tick.close = bTick[‘close_price’]

ticks.append(tick)

I am getting error:

File “d:\AlgoTraderFyers\src\ticker[FyersTicker.py](http://FyersTicker.py)”, line 53, in registerSymbols for symbol_data in brokerTicks: TypeError: ‘NoneType’ object is not iterable

Hey Siddharth,

try this, for each tick.variable value have it like this,

tick.lastTradedPrice = bTick['ltp'] or ""

have the same for all the variables, then you will get to know where the data is not coming for.

its not working.. what is the format of websocket response? what response it should get in brokerTicks

brokerTicks = fyersSocket.subscribe(symbol=symbol,data_type=data_type)