Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming API #16

Open
bosohn opened this issue Jun 12, 2020 · 3 comments
Open

Streaming API #16

bosohn opened this issue Jun 12, 2020 · 3 comments

Comments

@bosohn
Copy link

bosohn commented Jun 12, 2020

Hi,

First of all, thanks for the package. It is simple to use and works great.

Can you add streaming API assuming TD supports streaming?

Streaming API allows

  • user to specify list of symbols and callback methods which can be called from another thread
    user can decide whether to use queue, messaging, etc. on callback
  • user can update the list of instruments, adding or removing to subscribed symbols
  • prefer to have real-time callback

Thanks for your consideration,
Brian

@man910
Copy link

man910 commented Apr 14, 2022

Yes, thanks for the library!

I was able to extend it to get the Streaming API to work and forward it to TWS API so I can do some paper trading. However, it seems like TD Ameritrade will not allow you to connect for longer than 1.5 days. It varies. I can sometimes maintain streaming for as long as 2.5 days but no more. I have code there that handles reconnections (e.g., when I kill my network connection) and works, but for some reason after 1.5 days or so, it won't work.

My guess is that this is a TD Ameritrade limitation. What is perplexing, however, is that if I stop my app and then restart it, I can start streaming again. My first thought was to make sure OkHttpClient, which HttpTdaClient also uses, clears any cache, cookies, etc. That still doesn't help. Assuming it's OkHttpClient, there must be a way to totally re-initialize it.

Has anyone run into this issue? Or have any ideas on totally re-initializing OkHttpClient like maybe reloading any system libraries?

@studerw
Copy link
Owner

studerw commented Apr 14, 2022

Hi @ma would you be willing to show me your streaming code or do a pull request?

I would like to test it out, and then I can see if I also get kicked off after 1.5 days or so. Maybe it's just a "You" issue and not the rest of us (e.g. you're not as good of a stonk trader as we are, lol - just kidding).

Anyway, let me see the code and if we can figure out that it's a OKHttp issue, then there is a possibility we can change the OKHttp lib to use a newer version, because they aren't even really updating any longer the version that is used for this TDA Client.

Thanks!

@man910
Copy link

man910 commented Apr 15, 2022

Sure, but it may be confusing / too much since a lot of it is to adapt the TDA request / response to TWS. If you still want it, I can attach it later. Otherwise, when I have time, I can strip it down to the bare bones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants