You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Has anyone been able to get messages (specifically the stream.account_activity() function) writing to the CSV using the Streaming API? I confirmed that level 1 and level 2 quote streams are writing properly but not the account activity. The code I'm running is:
import pprint
# Import connection parameters for TD Ameritrade Account & App
from config import TD_ACCOUNT, CLIENT_ID, REDIRECT_URI, CREDENTIALS_PATH
# Bring in TD-AMERITRADE-PYTHON-API
from td.client import TDClient
# Create a new instance of the client
td_client = TDClient(
client_id = CLIENT_ID,
redirect_uri = REDIRECT_URI,
credentials_path = CREDENTIALS_PATH
)
# Log in to a new session
td_client.login()
td_stream_client = td_client.create_streaming_session()
# Specify the write behavior of the stream
td_stream_client.write_behavior(
write='csv',
file_path = 'stream_data_messages.csv',
append_mode = True
)
# Level 1 Quotes
td_stream_client.level_one_quotes(symbols=['MSFT'], fields=list(range(0,38)))
# Account Activity
td_stream_client.account_activity()
# Start the Stream
td_stream_client.stream()
If I run as is I don't get any information logged to the CSV but I am seeing both quotes and account messages in the console. If I comment out the line td_stream_client.account_activity() then the MSFT quotes get logged to the CSV. If I comment out the level one quotes but leave the account_activity line uncommented I get nothing logged to the CSV.
I spent some time digging through the stream.py starting to build in support for this portion of the API but thought I'd check if this is something anyone else has started/completed.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
Has anyone been able to get messages (specifically the stream.account_activity() function) writing to the CSV using the Streaming API? I confirmed that level 1 and level 2 quote streams are writing properly but not the account activity. The code I'm running is:
If I run as is I don't get any information logged to the CSV but I am seeing both quotes and account messages in the console. If I comment out the line
td_stream_client.account_activity()
then the MSFT quotes get logged to the CSV. If I comment out the level one quotes but leave the account_activity line uncommented I get nothing logged to the CSV.I spent some time digging through the stream.py starting to build in support for this portion of the API but thought I'd check if this is something anyone else has started/completed.
Beta Was this translation helpful? Give feedback.
All reactions