Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move to HTTPX+authlib (pending PRs merging upstream), add asynchronous support to main client. Also, JSON for creds storage * use httpx, fix user-agent issue * update docs * full test suite for both async and sync clients * minor renaming, add some docs * minor renaming, add some docs * use AsyncMock from stdlib instead of asynctest module * use authlib-httpx * improve workflow and messaging * update test * fix docs * add auth lib to repo, adjust utilities for httpx, etc * stale import * birthdays have no place here * update readme * show how to use async; remove unnecessary print * no longer consuming this package * Add note about not using more than one client per token file * restore missing underscore * change SyncClient back to Client, move oauth2lib to 3rd-party folder * add __init__.py to third_party folder * add notes about why this exists * make sphinx error on warnings * fix more underscores * split client.py
- Loading branch information
1 parent
e4254dd
commit 20bbcf7
Showing
26 changed files
with
938 additions
and
449 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from urllib.request import urlopen | ||
|
||
import atexit | ||
import datetime | ||
import dateutil | ||
import sys | ||
import tda | ||
|
||
API_KEY = 'XXXXXX@AMER.OAUTHAP' | ||
REDIRECT_URI = 'http://localhost:8080/' | ||
TOKEN_PATH = 'ameritrade-credentials.json' | ||
|
||
|
||
def make_webdriver(): | ||
# Import selenium here because it's slow to import | ||
from selenium import webdriver | ||
|
||
driver = webdriver.Chrome() | ||
atexit.register(lambda: driver.quit()) | ||
return driver | ||
|
||
|
||
# Create a new client | ||
client = tda.auth.easy_client( | ||
API_KEY, | ||
REDIRECT_URI, | ||
TOKEN_PATH, | ||
make_webdriver, asyncio=True) | ||
|
||
async def main(): | ||
r = await client.get_quote("AAPL") | ||
print(r.json()) | ||
|
||
if __name__ == '__main__': | ||
import asyncio | ||
asyncio.run(main()) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from urllib.request import urlopen | ||
|
||
import atexit | ||
import datetime | ||
import dateutil | ||
import sys | ||
import tda | ||
|
||
API_KEY = 'XXXXXX@AMER.OAUTHAP' | ||
REDIRECT_URI = 'http://localhost:8080/' | ||
TOKEN_PATH = 'ameritrade-credentials.json' | ||
|
||
def make_webdriver(): | ||
# Import selenium here because it's slow to import | ||
from selenium import webdriver | ||
|
||
driver = webdriver.Chrome() | ||
atexit.register(lambda: driver.quit()) | ||
return driver | ||
|
||
|
||
# Create a new client | ||
client = tda.auth.easy_client( | ||
API_KEY, | ||
REDIRECT_URI, | ||
TOKEN_PATH, | ||
make_webdriver) | ||
|
||
|
||
r = client.get_quote("AAPL") | ||
print(r.json()) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
asynctest | ||
colorama | ||
coverage | ||
requests_oauthlib | ||
tox | ||
authlib==0.14.3 | ||
httpx==0.14.3 | ||
python-dateutil | ||
pytest | ||
pytz | ||
|
This file contains 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
Oops, something went wrong.