Created
July 19, 2020 02:21
-
-
Save trepidity/5ea20a5a2e79911ecabe949eaf16be87 to your computer and use it in GitHub Desktop.
Pull the current TD Positions for all accounts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import the client | |
from td.client import TDClient | |
import pprint | |
from datetime import datetime | |
from datetime import timedelta | |
pp = pprint.PrettyPrinter(indent=4) | |
# Create a new session, credentials path is optional. | |
TDSession = TDClient( | |
client_id='xxxxx', | |
redirect_uri='https://test/callback', | |
credentials_path='.credentials' | |
) | |
# Login to the session | |
TDSession.login() | |
# Option Chain Example | |
opt_chain = { | |
'symbol':'MSFT', | |
'contractType':'CALL', | |
'optionType':'S', | |
'fromDate':'2020-04-01', | |
'afterDate':'2020-05-01', | |
'strikeCount':4, | |
'includeQuotes':True, | |
'range':'ITM', | |
'strategy':'ANALYTICAL', | |
'volatility': 29.0 | |
} | |
pp.pprint(TDSession.get_accounts( | |
account='all', | |
fields=['orders'] | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment