boyan-soubachov / tastyworks_api

An unofficial, reverse-engineered Python API for tastyworks.
Apache License 2.0
209 stars 79 forks source link

Change in API? #36

Open miked63017 opened 5 years ago

miked63017 commented 5 years ago

Describe the bug Looks like something changed in the websockets, on top of getting this Unknown Client error, I have also experimented manually and found that there are some other odd things going on like not receiving what you subscribe to.

To Reproduce Run example.py with a symbol to quote

miked63017 commented 5 years ago
ip-192-168-1-194:tastyworks mdonlon$ python example.py
2019-02-28 14:19:52,117 Connecting to url: https://tasty.dxfeed.com/live/cometd
2019-02-28 14:19:52,117 Opening client with connection types ['websocket', 'long-polling'] ...
2019-02-28 14:19:52,422 Connection types supported by the server: ['websocket']
2019-02-28 14:19:52,470 Client opened with connection_type 'websocket'
Traceback (most recent call last):
  File "example.py", line 105, in <module>
    main()
  File "example.py", line 87, in main
    streamer = DataStreamer(tasty_client)
  File "/Users/mdonlon/miniconda3/lib/python3.7/site-packages/tastyworks/streamer.py", line 24, in __init__
    self._setup_connection()
  File "/Users/mdonlon/miniconda3/lib/python3.7/asyncio/base_events.py", line 573, in run_until_complete
    return future.result()
  File "/Users/mdonlon/miniconda3/lib/python3.7/site-packages/tastyworks/streamer.py", line 92, in _setup_connection
    await cometd_client.subscribe(dxfeed.DATA_CHANNEL)
  File "/Users/mdonlon/miniconda3/lib/python3.7/site-packages/aiocometd/client.py", line 304, in subscribe
    self._verify_response(response)
  File "/Users/mdonlon/miniconda3/lib/python3.7/site-packages/aiocometd/client.py", line 359, in _verify_response
    self._raise_server_error(response)
  File "/Users/mdonlon/miniconda3/lib/python3.7/site-packages/aiocometd/client.py", line 375, in _raise_server_error
    raise ServerError(message, response)
aiocometd.exceptions.ServerError: ('Subscribe request failed.', {'channel': '/meta/subscribe', 'id': '2', 'error': '402::Unknown client', 'successful': False})
Exception ignored in: <function DataStreamer.__del__ at 0x10a9b57b8>
Traceback (most recent call last):
  File "/Users/mdonlon/miniconda3/lib/python3.7/site-packages/tastyworks/streamer.py", line 29, in __del__
AttributeError: 'NoneType' object has no attribute 'close'
boyan-soubachov commented 5 years ago

Thanks for reporting this @miked63017 , I will have a look later today.

miked63017 commented 5 years ago

Hi @boyan-soubachov are you able to get past this? Am I the only one getting these errors?

I thought I had a workaround, I honestly don't recall what I changed because I was using my own scripts that weren't async, but it seems they changes something again, and now I cannot even sniff the traffic properly :-(

Please let me know if you are able to use their websocket api at all, thanks!

miked63017 commented 5 years ago

Also, AFAICT the added some kind of extra SSL/cert mechanism and I am getting connection closed on the websocket

miked63017 commented 5 years ago

And...it randomly started working again. I didn't change any of the code but I was poking around the dxfeed example pages and using javascript injection via chrome dev tools to test my connection.

https://tools.dxfeed.com/webservice/qtable-demo.jsp

Basically I injected my token and the tasty url, then about an hour later I retested my python script since all the data seemed to look good and it just worked. Even more confused now lol

HyperXewl commented 4 years ago

I was getting this websocket error as well. I was able to fix it by adding a line to the account_events.py file

https://gyazo.com/12448db899e1e8edd89e948795fa8735

fritol commented 3 years ago

And...it randomly started working again. I didn't change any of the code but I was poking around the dxfeed example pages and using javascript injection via chrome dev tools to test my connection.

https://tools.dxfeed.com/webservice/qtable-demo.jsp

Basically I injected my token and the tasty url, then about an hour later I retested my python script since all the data seemed to look good and it just worked. Even more confused now lol

Hi Mike, is this Boyans API still working for you? (It will help me to know so that I dont spend any more time on it coz I have some troubles already (i filed a bug rep 2)). thx

miked63017 commented 3 years ago

I haven't been using it, switched brokers, sorry...

On Fri, Jul 31, 2020, 10:07 AM fritol notifications@github.com wrote:

And...it randomly started working again. I didn't change any of the code but I was poking around the dxfeed example pages and using javascript injection via chrome dev tools to test my connection.

https://tools.dxfeed.com/webservice/qtable-demo.jsp

Basically I injected my token and the tasty url, then about an hour later I retested my python script since all the data seemed to look good and it just worked. Even more confused now lol

Hi Mike, is this Boyans API still working for you? (It will help me to know so that I dont spend any more time on it coz I have some troubles already (i filed a bug rep 2)). thx

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/boyan-soubachov/tastyworks_api/issues/36#issuecomment-667169042, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHG7X6BCMP2ONHTBFXREC3R6LMZTANCNFSM4G26UPYA .

bandwiches commented 3 years ago

I saw something along the lines of this literally yesterday (1/25/21). It doesn't seem to be isolated to this package, it seems like it's an issue on the backend. When I saw this yesterday I was just using a mix of aiohttp calls and Postman and I saw it on both platforms.

Symptom: Tastyworks API websocket errors just begin and end randomly.

My Hunch: Pretty sure this is just instability with Tastyworks API

Evidence: It really doesn't matter what language or product/platform you're using, it just seems to start happening randomly. You can swap from Python (requests/aiohttp) to Postman and you'll get the same websocket error. It just seems to happen. I think it may be how they handle their tokens or "sessions".

Further Investigation: I haven't found a way to truly replicate this, so my troubleshooting has been limited to the tiny windows when it happens.