algo2t / alphatrade

Python APIs for SAS Online Alpha Trade Web platform for creating algo trading using python
https://algo2t.github.io/alphatrade
MIT License
44 stars 22 forks source link

Frequently receiving 'Request Unauthorised' error #38

Closed ronaldpaul closed 1 year ago

ronaldpaul commented 2 years ago

Whenever I try to modify order status or try to square off any positions, I very often receive the error

{"status":"error","message":"Request Unauthorised","data":{}}

I am not sure whether this has something to do with token authorization or any other issues from the broker side. But I receive this very often in the web socket. Please let me know how I can resolve this issue.

An example scenario is, if LTP is greater than specific price, modify a pending order. When I try to do this, I see this error printed in log.

Thanks.

ronaldpaul commented 2 years ago

@algo2t , kindly help in resolving this issue. I checked with SAS Online, they mentioned that the URL alpha.sasonline.in will session out in 75 minutes of inactivity. It appears that they have released new API with the base URL as alphaapi.sasonline.in. If possible, kindly incorporate this URL and routes mentioned in the document https://drive.google.com/file/d/15HMf1ieewe2FgHxZJ-YIGeDtyNVEgCQ2/view.

Thanks a lot for your effort in building this library.

algo2t commented 2 years ago

Their new API is completely different and needs api_secret , I will have to evaluate the effort and then do the update or might think of creating some other package

suresh-n commented 2 years ago

is Access token endpoint: /oauth2/token working ? i get the response code after enter credntial & twfa but when i'm tryign to generate token using the response code getting "Method Not Allowed 405" error.

sasonline support team saying the wont support further on this.

example:

https://alphaapi.sasonline.in/oauth2/token?grant_type=authorization_code &client_id=xxxxx &client_secret=zzzzzzz &code=yyyyyyy &redirect_uri=http://127.0.0.1

ronaldpaul commented 1 year ago

I resolved this 'Request Unauthorised' error by polling the server once for every one hour. It keeps the connection alive. Closed the issue.