I am struggling with an error:
tried finding solutions but none worked. Can you help?
I tried changing Python version. I also created a separate environment. Doesn’t help.
Here is my code simplified for testing:
from fyers_api.Websocket import ws
import os
access_token = “eyJ0eXAiOi*****”
app_id= “9y***-100”
access_token = f’{app_id}:{access_token}’
def custom_message(msg):
symbol = msg[0][‘symbol’]
ltp = msg[0][‘ltp’]
high = msg[0][‘high_price’]
low = msg[0][‘low_price’]
print(f"Symbol: {symbol}, LTP: {ltp}, High: {high}, Low: {low}")
def create_watchlist(access_token):
data_type = “symbolData”
symbols = [“NSE:HDFC-EQ”] # I TRIED USING “NSE:HDFCBANK-EQ” and “NSE:SBIN-EQ”
fs = ws.FyersSocket(access_token=access_token,run_background=False, log_path=“/Users/Documents/Algo_trading/”)
fs.websocket_data = custom_message
fs.subscribe(symbol=symbols, data_type=data_type)
fs.keep_running()
create_watchlist(access_token)
{‘s’: ‘error’, ‘code’: -300, ‘message’: ‘Please provide a valid symbol’}