Hi
I am running below code but i am getting error - Can someone pls guide me.
ERR: logEntryFunc: get_profile : [Errno 30] Read-only file system: ‘/2022-12-31.txt’
{‘s’: ‘error’, ‘code’: 500, ‘message’: ‘Looks like you are passing an invalid entry’}
ERR: logEntryFunc: orderBook : [Errno 30] Read-only file system: ‘/2022-12-31.txt’
{‘s’: ‘error’, ‘code’: 500, ‘message’: ‘Looks like you are passing an invalid entry’}
Code
from fyers_api.Websocket import ws
from fyers_api import fyersModel
from fyers_api.Websocket import ws
import datetime
import time
import threading
import pandas as pd
from fyers_api import accessToken
from fyers_api import fyersModel
from datetime import datetime
import time
import threading
import pandas as pd
from fyers_api import accessToken
from fyers_api import fyersModel
from datetime import datetime
import pytz
from zoneinfo import ZoneInfo
from datetime import datetime, timedelta
import pandas as pd
import numpy as np
from datetime import datetime
import math
import fyers_api
import requests
import threading
import requests
import urllib.request, urllib.response
from urllib.request import Request, urlopen
import json
import ast
import fyers_api
import re
import requests
import threading
import csv
import fyerscred
fyers = fyersModel.FyersModel(token=“access_token as defined in main block”,is_async=False,client_id=“client_id(APP_ID)”) ## Create a fyersModel object if in any scenario you want to call the trading and data apis when certain condiiton in websocket data is met so that can be triggered by calling the method/object after subscribing and before the keep_running method as shown in run_process_background_symbol_data
def run_process_background_symbol_data(access_token):
data_type = “symbolData”
symbol =[“NSE:SBIN-EQ”,“NSE:HDFC-EQ”,“NSE:IOC-EQ”]
fs = ws.FyersSocket(access_token=access_token,run_background=False,log_path=“/Users/nitinbakshi/Downloads/python/New”)
fs.websocket_data = custom_message
fs.subscribe(symbol=symbol,data_type=data_type)
print(fyers.get_profile())
print(fyers.orderbook())
fs.keep_running()
def run_process_background_order_update(access_token):
data_type = “orderUpdate”
fs = ws.FyersSocket(access_token=access_token,run_background=False,log_path=“/Users/nitinbakshi/Downloads/python/New”)
fs.websocket_data = custom_message
fs.subscribe(data_type=data_type)
fs.keep_running()
def custom_message(msg): ### This function can be anything which you want to configure at your end
print (f"Custom:{msg}")
def main():
access_token = “eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcGkuZnllcnMuaW4iLCJpYXQiOjE2NzI0NjA2OTYsImV4cCI6MTY3MjUzMzA1NiwibmJmIjoxNjcyNDYwNjk2LCJhdWQiOlsieDowIiwieDoxIiwieDoyIiwiZDoxIiwiZDoyIiwieDoxIiwieDowIl0sInN1YiI6ImFjY2Vzc190b2tlbiIsImF0X2hhc2giOiJnQUFBQUFCanI3bVlDR3g2WmtmRVRhRVhRWTJveENLNFJLNG1UQ3lWbEQ5WEhpOTRWb0NXalpMd2Uzb1pIeXMzMWlPMHlFbUhXR0YwV2RUb2tkNHU0VXQzYnFPbFRmMlFyTE5hTWtadjFwOVp5anFfZ2tFSXZRUT0iLCJkaXNwbGF5X25hbWUiOiJOSVRJTiBCQUtTSEkiLCJvbXMiOm51bGwsImZ5X2lkIjoiWE4xNjU0NSIsImFwcFR5cGUiOjEwMCwicG9hX2ZsYWciOiJOIn0.hwwvcrlYQReycmXn9MNOy-svucYrlTuZHfEAWCqz2G8”
For regular api calls you the access_token as mentioned above
Insert the accessToken and app_id over here in the following format for subscribing the websocket data (APP_ID:access_token)
access_token_websocket= “HA******ZB5-100:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcGkuZnllcnMuaW4iLCJpYXQiOjE2NzI0NjA2OTYsImV4cCI6MTY3MjUzMzA1NiwibmJmIjoxNjcyNDYwNjk2LCJhdWQiOlsieDowIiwieDoxIiwieDoyIiwiZDoxIiwiZDoyIiwieDoxIiwieDowIl0sInN1YiI6ImFjY2Vzc190b2tlbiIsImF0X2hhc2giOiJnQUFBQUFCanI3bVlDR3g2WmtmRVRhRVhRWTJveENLNFJLNG1UQ3lWbEQ5WEhpOTRWb0NXalpMd2Uzb1pIeXMzMWlPMHlFbUhXR0YwV2RUb2tkNHU0VXQzYnFPbFRmMlFyTE5hTWtadjFwOVp5anFfZ2tFSXZRUT0iLCJkaXNwbGF5X25hbWUiOiJOSVRJTiBCQUtTSEkiLCJvbXMiOm51bGwsImZ5X2lkIjoiWE4xNjU0NSIsImFwcFR5cGUiOjEwMCwicG9hX2ZsYWciOiJOIn0.hwwvcrlYQReycmXn9MNOy-svucYrlTuZHfEAWCqz2G8”
run_process_background_symbol_data(access_token_websocket)
run_process_background_order_update(access_token_websocket)
if name == ‘main’:
main()