OpenApi-5p / py5paisa

Official Python SDK for 5paisa APIs natively written in VB .NET
https://5paisa.github.io
89 stars 65 forks source link

Ticker Data #41

Open prasunanand opened 3 years ago

prasunanand commented 3 years ago

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 commented 3 years ago

Let me know if you are looking for contributions .

coder-amogh commented 3 years ago

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.

anilgupta83 commented 3 years ago

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.

coder-amogh commented 3 years ago

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?

anilgupta83 commented 3 years ago

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"}}

coder-amogh commented 3 years ago

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 commented 3 years ago

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?

anilgupta83 commented 3 years ago

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.

coder-amogh commented 3 years ago

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

anilgupta83 commented 3 years ago

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.

coder-amogh commented 3 years ago

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

coder-amogh commented 3 years ago

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

Still no help.

coder-amogh commented 3 years ago

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:

rishabhmaniyar commented 3 years ago

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

coder-amogh commented 3 years ago

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.

rishabhmaniyar commented 3 years ago

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!

coder-amogh commented 3 years ago

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 commented 3 years ago

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!

rishabhmaniyar commented 3 years ago

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.

coder-amogh commented 3 years ago

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?

rishabhmaniyar commented 3 years ago

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.

anilgupta83 commented 3 years ago

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.

coder-amogh commented 3 years ago

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.

rishabhmaniyar commented 3 years ago

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

anilgupta83 commented 3 years ago

@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.

coder-amogh commented 3 years ago

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 commented 3 years ago

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

pushand commented 3 years ago

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

coder-amogh commented 3 years ago

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.

pushand commented 3 years ago

@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