RHOQHxgO9m
(Inactive Member)
October 25, 2021, 4:04pm
1
I am facing problem with market data websocket for fyers V2
I am able to get live data on the console and the same is getting logged in the log folder path.
But unable to get call for the custom_message function, where I want to process the live data before further usage.
I dont see this **custom_message **function getting called, below is code I am using for this purpose
def custom_message(self):
** print("Custom: " + str(self.response))**
ws.websocket_data = custom_message
feedtoken = app_id + ā:ā + access_key
data_type = āsymbolDataā
symbol = [āMCX:CRUDEOIL21NOVFUTā]
fyersSocket = ws.FyersSocket(access_token=feedtoken, run_background=False, log_path=āC:/python_projectā)
fyersSocket.subscribe(symbol=symbol, data_type=data_type)
time.sleep(300)
fyersSocket.keep_running()
WH9N49RaFa
(Inactive Member)
November 3, 2021, 11:33am
2
facing a similar problem⦠**custom_***message function is not getting called for *orderUpdate
WH9N49RaFa
(Inactive Member)
November 3, 2021, 12:26pm
3
This worked for me try if it helps you,
custom message is not working with fyers-apiv2=2.0.5
try installing previous version **fyers-apiv2=2.0.4 ā**custom function is working fine with this versionā
Even Iām facing this issue with custom_message. However, if you go to 2.0.4 then ModuleNotFoundError: No module named 'fyers_api.Websocket ā will pop up
WH9N49RaFa
(Inactive Member)
November 8, 2021, 11:55am
5
# use this
import ws from fyers_api.websocket
instead of
Websocket with āWā capital
WH9N49RaFa
(Inactive Member)
November 30, 2021, 2:24am
6
Can you tell me exactly what you want to achive with custom function? May be I can help.
Currently I am using it to insert data into MySQL and I am not facing any issue with using version 2.0.4
WH9N49RaFa
(Inactive Member)
November 30, 2021, 2:53am
7
For Order Update Websocket,
Data we recieve is in string format, can use json.loads() to convert it to python dictionary.
import json
def custom_message(self):
data = json.loads(self)
After converting to it to dictionary you can insert it into dataframe
What about data websocket?
WH9N49RaFa
(Inactive Member)
November 30, 2021, 3:33am
9
For data websocket, data is in dictionary format. We have to use for loop, to loop through each symbol we subscribed.
def custom_message(self):
insert_ticks(self.response)
def insert_ticks(ticks):
for tick in ticks:
ltp = tick['ltp']
time_stamp = tick['last_traded_time']
Iām aware of this issue sir. I have written to the Fyers team as well that the *def custom_message(self) *is more like a dummy statement.
Thanks for the workaround. Makes sense. Anyway, Iām going to wait for Fyers to do it the right way.
qe60S4eBYu
(Inactive Member)
December 29, 2021, 4:21pm
12
above code to start new thread did not work for me. is it working?
vtowF9GQLQ
(Inactive Member)
January 18, 2022, 7:05am
13
Iām having the same issue. I strictly followed docs but Itās not calling the custom_message( ) functions
Didnāt work for me either.
Lg2SvlKtl7
(Inactive Member)
February 8, 2022, 9:02am
15
fs = ws.FyersSocket(access_token=access_token, run_background=True, log_path=" " )
Change run_background to False
and in custom_message(msg) use json.load(msg) and assign it some value and do your parsing.
**import **json
**def **custom_message(msg):
print(f"Custom:{msg}")
data = json.loads(msg)
print(data)
print(data.get('s'))
print(data.get('d'))
This works for meā¦
Hope it helps for you as wellā¦
If run background is false, the code after invoking the WebSocket will not run. The code will stop there itself.
Lg2SvlKtl7
(Inactive Member)
February 9, 2022, 10:19am
17
I tried this with orderupdate, when ever there is change in order. scripts works for me.
Note: Created Weebhook for pending, rejected, cancelled, traded
E46UbOMMXH
(Inactive Member)
March 24, 2022, 7:36am
18
@**Bikram Raj Kapoor **
which Fyers version are you using ? 2.0.4 or 2.0.5?
golu_vora
(golu vora)
April 7, 2022, 4:46am
19
Hi Vishnu,
Any response from Fyers?
I am still facing this issue.
If you found any work around then please share. Thanks in advance.
shivanium
(shiv rathore)
January 20, 2023, 6:46am
20
I also got this error but I fix it
https://github.com/SHIVANIUM-GIT/fyer_api_websocket
if you face any problem again message me