py5paisa icon indicating copy to clipboard operation
py5paisa copied to clipboard

Ticker Data

Open prasunanand opened this issue 4 years ago • 30 comments

How do we query ticker data ?

I found out that we need to query https://www.5paisa.com/developerapi/websocketformarketfeeds for live market feeds by accessing the APIs. How do we do it via sdk ?

prasunanand avatar Feb 04 '21 16:02 prasunanand

Let me know if you are looking for contributions .

prasunanand avatar Feb 09 '21 12:02 prasunanand

I found out that we need to query https://www.5paisa.com/developerapi/websocketformarketfeeds for live market feeds by accessing the APIs. How do we do it via sdk ?

I don't think there is any code written to do it via Python SDK, I think each one will have to code it normally through Python code using websockets. Have you written any code and would like to share here? Thanks.

coder-amogh avatar Feb 24 '21 04:02 coder-amogh

Well, their websocket feed API seems to be broken at the moment. A month ago I put together some code and managed to connect and receive stock ticker data and it worked, however the index ticker wasn't working so I raised a support request for the same. They assured me to address the "issue" on "priority" but on the contrary a few days later websocket connection stopped working altogether. If I receive a positive response from them I'll post it here.

anilgupta83 avatar Feb 24 '21 05:02 anilgupta83

Well, their websocket feed API seems to be broken at the moment. A month ago I put together some code and managed to connect and receive stock ticker data and it worked, however the index ticker wasn't working so I raised a support request for the same. They assured me to address the "issue" on "priority" but on the contrary a few days later websocket connection stopped working altogether. If I receive a positive response from them I'll post it here.

LIVE NEWS: NSE has stopped that trading system. BSE is working fine. Maybe that's why it's not working?

coder-amogh avatar Feb 24 '21 07:02 coder-amogh

This is not about today. It hasn't been working for a while. Specifically, the LoginCheck API mentioned at [https://www.5paisa.com/developerapi/websocketformarketfeeds] now returns either {"Message":"An error has occurred."} or {"body":{"Message":"Incorect Credentials","Status":1},"head":{"responseCode":"5PLoginCheck","status":0,"statusDescription":"Success"}}

anilgupta83 avatar Feb 24 '21 08:02 anilgupta83

This is not about today. It hasn't been working for a while. [...]

Hmm... well, then I think you should raise support request via email referencing this issue. I'll try this tomorrow morning, currently there's no data that's possible to stream! Hopefully it works and they get a function to us, so we stop re-inventing the wheel again and again... :disappointed:

coder-amogh avatar Feb 24 '21 12:02 coder-amogh

Nah, it's not working. When they mean "Pass the SessionID", what do they mean exactly? Pass what? Or login first, obtain a session id and then pass that? @anilgupta83 what had you passed when it was working?

coder-amogh avatar Mar 01 '21 11:03 coder-amogh

The documentation on websocket is kind of sketchy. By session id they mean the cookie named '5paisacookie', this cookie is emitted on login and must be available on py5paisa client as something like client.session.cookies['5paisacookie']. My code is in golang which won't help much if I shared it here.

anilgupta83 avatar Mar 01 '21 12:03 anilgupta83

Yes, client.session.cookies["5paisacookie"] gives me the cookie name, but it still doesn't work with that... So what are you doing now after it's stopped working? You tried something else or the task is still on hold? @anilgupta83

coder-amogh avatar Mar 01 '21 12:03 coder-amogh

Well, as I have mentioned earlier I have a ticket open with them for about a month. I keep pinging them in between, that's all we can do if the provider API is broken, no? :-) 3 days ago they told me that the concerned team is looking into the issue. If they provide a solution I'll post the detail here.

anilgupta83 avatar Mar 01 '21 13:03 anilgupta83

I just contacted them via support ticket, hopefully they'll help...

coder-amogh avatar Mar 01 '21 14:03 coder-amogh

I just contacted them via support ticket, hopefully they'll help...

Still no help.

coder-amogh avatar Mar 10 '21 10:03 coder-amogh

And now they aren't even replying to the follow-up emails! :rofl: It's been more than 25 days I'm struggling to deal with getting real-time data with websocket.

Firstly they have the Python SDK, but don't have any websocket classes created in it. And secondly now the login API doesn't work. Thirdly it is impossible to contact them (after the initial message).

Great! What should we do now? :disappointed:

coder-amogh avatar Mar 18 '21 05:03 coder-amogh

Hey @coder-amogh Trying to get that started soon. There was some issue which is now being solved. Soon will add it to the SDK as well

rishabhmaniyar avatar Mar 31 '21 16:03 rishabhmaniyar

Hey @coder-amogh Trying to get that started soon. There was some issue which is now being solved. Soon will add it to the SDK as well

I don't mind if it's added to SDK few months later. For now, I need to get the websocket working... There are bunch of projects I want to do with this APIs and I won't be able to do any of them because the websocket is not working. Can't something be done to this that the websocket APIs are started first and then the SDKs are been focused? To me, the API uptime is more important than the SDK.

coder-amogh avatar Apr 04 '21 12:04 coder-amogh

Hey @coder-amogh , I got it! It's highly prioritised even from our end web socket issue is being solved. Check it next Friday hopefully you see changes done!

rishabhmaniyar avatar Apr 04 '21 12:04 rishabhmaniyar

Thank you so much! At least a timeframe was definitely expected. Thanks again.

On Sun, 4 Apr 2021, 18:13 rishabhmaniyar, @.***> wrote:

Hey @coder-amogh https://github.com/coder-amogh , I got it! It's highly prioritised even from our end web socket issue is being solved. Check it next Friday hopefully you see changes done!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/5paisa/py5paisa/issues/41#issuecomment-813026657, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALPNBP7FTH32PCMBVDFLQCDTHBNFLANCNFSM4XDDQF6A .

coder-amogh avatar Apr 04 '21 12:04 coder-amogh

5Paisa support replied that the issue is resolved, but it's not. Also a sample code is really appreciated. I cannot find literally, literally any single working piece of code of this websocket. It's not Friday yet, so I'm waiting. Hopefully it gets resolved by Friday. Excited!

coder-amogh avatar Apr 07 '21 08:04 coder-amogh

Hey @coder-amogh , I have checked for web socket update but I guess there is still some issue with the connection. I will have to update by timeline shared to next week sadly. For the code in python I can suggest going through - https://pypi.org/project/websocket-client/ Soon after sharing web socket on developer page. I will be pushing web socket functionality into our sdk as well. Sorry for the delay! Regards.

rishabhmaniyar avatar Apr 08 '21 15:04 rishabhmaniyar

How many number of scrips you can request the LTP and Volume for? I tried a bunch of data today and it failed. When I tried just 10, it worked perfectly. What's the maximum number of scrips? Please mention it in the documentation: https://www.5paisa.com/developerapi/currentmarketdata

Also, just now (when the market is open), how to get the opening price of any stock? I can only get the last closing price (of the previous trading day), today's high and low, LTP and volume. I cannot get the opening price, although in the documentation OpenRate key is mentioned. Please fix it!

Also, just had a query, what happens when there's dividend distribution or when the stock's split, is the closing price adjusted according to it?

coder-amogh avatar Apr 08 '21 16:04 coder-amogh

Hey @coder-amogh , It works fine for about 50 request as per our API limit, anyways if you want to have more requests made anyway looping could help if evenly timed. I also checked the data and found it is perfect and has no issues in there. Open Rate is not coming in response that is true will get that checked again.

rishabhmaniyar avatar Apr 10 '21 05:04 rishabhmaniyar

So they have closed my ticket as "resolved" and now https://www.5paisa.com/developerapi/websocketformarketfeeds page is gone. It appears they have withdrawn support for websocket feed.

anilgupta83 avatar Apr 24 '21 05:04 anilgupta83

So they have closed my ticket as "resolved" and now https://www.5paisa.com/developerapi/websocketformarketfeeds page is gone. It appears they have withdrawn support for websocket feed.

Same here. I'm in touch with them, they're saying its taking time. My project is stuck and I'm checking it almost everyday, but it's not working anyway. You can open another support ticket though.

coder-amogh avatar Apr 24 '21 05:04 coder-amogh

Hey guys,

Sorry for long time getting response to web socket issue. We are making some fundamental changes to the web sockets so that this change stays and is useful. You all can check Python sdk which is upgraded completely.

Do share feedback

rishabhmaniyar avatar Apr 24 '21 05:04 rishabhmaniyar

@coder-amogh Naah not going to follow up with support anymore, all they have is canned responses. I am using ticker data from another broker. https://developers.stocknote.com/api/#streaming-market-data Occasionally it lags by 10-15 seconds that is why I was interested in 5paisa implementation. It is getting the job done though, for now. @rishabhmaniyar Thanks, hope that the new version would work well. Also, if possible please provide an API to retrieve option chain along with the OI data.

anilgupta83 avatar Apr 24 '21 06:04 anilgupta83

Naah not going to follow up with support anymore, all they have is canned responses. I am using ticker data from another broker. https://developers.stocknote.com/api/#streaming-market-data Occasionally it lags by 10-15 seconds that is why I was interested in 5paisa implementation. It is getting the job done though, for now.

Yeah, 5paisa's response is really really fast, almost equal to the one which were on localhost. I guess I'll have to too set a deadline for myself. If the API doesn't get back within next week or something, I should be switching to a different broker. I can't just keep waiting for the 5paisa's API to be up. They might just keep waiting for the next few weeks or month, we don't know.

coder-amogh avatar Apr 24 '21 06:04 coder-amogh

It has started working as expected! This issue can be closed now.

coder-amogh avatar May 12 '21 02:05 coder-amogh

Hey @coder-amogh is python WebSocket API working as of now? I keep getting bad handshake

pushand avatar Jun 08 '21 05:06 pushand

Hey @coder-amogh is python WebSocket API working as of now?

Yes, it's working. You can share the code, so the team can help find the issue you are facing.

coder-amogh avatar Jun 08 '21 07:06 coder-amogh

@coder-amogh I have shared, link below. Its Go lang I have got all API working except for websocket in Go

https://github.com/5paisa/go5paisa/issues/8#issue-913559231

pushand avatar Jun 08 '21 07:06 pushand