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 Account Activity issue(SUBS before LOGIN done?) #39

Closed
mdukaczewski opened this issue May 26, 2020 · 4 comments
Closed

Streaming Account Activity issue(SUBS before LOGIN done?) #39

mdukaczewski opened this issue May 26, 2020 · 4 comments

Comments

@mdukaczewski
Copy link

mdukaczewski commented May 26, 2020

First of all, I would like to thank you for publishing your TD Ameritrade Python API!

When I try connect to Account Activity Stream with this code:

TDStreamingClient = TDSession.create_streaming_session()
TDStreamingClient.account_activity()
TDStreamingClient.stream(print_to_console=True)

sometimes it ends up with an error:

Connection established. Streaming will begin shortly.
====================
Message Recieved:

{'response': [{'service': 'ACCT_ACTIVITY', 'requestid': '1', 'command': 'SUBS', 'timestamp': 1590498667548, 'content': {'code': 20, 'msg': 'STREAM CONNECTION NOT FOUND - Please login again.'}}]}
--------------------

====================
Message Recieved:

{'response': [{'service': 'ADMIN', 'requestid': '0', 'command': 'LOGIN', 'timestamp': 1590498667548, 'content': {'code': 0, 'msg': '05-1'}}]}

or:

Connection established. Streaming will begin shortly.
====================
Message Recieved:

{'response': [{'service': 'ACCT_ACTIVITY', 'requestid': '1', 'command': 'SUBS', 'timestamp': 1590498947102, 'content': {'code': 3, 'msg': 'Login Denied. - Please login first.'}}]}
--------------------

====================
Message Recieved:

{'response': [{'service': 'ADMIN', 'requestid': '0', 'command': 'LOGIN', 'timestamp': 1590498947102, 'content': {'code': 0, 'msg': '06-3'}}]}
--------------------

Connection with server closed, beginning close process...

I guess first it should wait for ADMIN LOGIN response, then send ACCT_ACTIVITY SUBS?

@areed1192
Copy link
Owner

Alright, so I'm having a hard time recreating this issue. Could you help me out a little bit and give me some context as to when this issue happens?

For example, could answer the following:

  1. Do you run this during market hours or after market hours?
  2. Are you on Mac or Windows?
  3. Is this the only request you make, or do you this with other requests?

Once I get some of that, I'll try to identify the issue. I will warn you that this endpoint tends to behave erratically, but that's just from my experience.

@comlong
Copy link

comlong commented Jun 21, 2020

Hi Alex,
I use the stream every day. but I used the old version. with

       asyncio.ensure_future(self._receive_message(connection))
        asyncio.ensure_future(self._send_message(login_request))
        asyncio.ensure_future(self._send_message(data_request))

If I run the code, I could get the login denied message. But if I set a breakpoint at the last line, and debug each time, it works well. So I think it should send data request after it receives the login response.
Well, actually, I noticed the issue is still there in the latest version.

@areed1192
Copy link
Owner

@comlong That was addressed in the latest version, you'll need to update the library in order to get the fix. Here is the latest version.

pip install td-ameritrade-python-api==0.2.8

@areed1192
Copy link
Owner

Closing out.

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