Skip to content

Instantly share code, notes, and snippets.

@trepidity
Created July 19, 2020 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trepidity/5ea20a5a2e79911ecabe949eaf16be87 to your computer and use it in GitHub Desktop.
Save trepidity/5ea20a5a2e79911ecabe949eaf16be87 to your computer and use it in GitHub Desktop.
Pull the current TD Positions for all accounts
# 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