-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from dalenguyen/dev
Dev
- Loading branch information
Showing
9 changed files
with
214 additions
and
122 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,45 @@ | ||
from loguru import logger | ||
from stockai import WealthSimple | ||
import sys | ||
sys.path.append('../stockai') | ||
|
||
from stockai import WealthSimple | ||
|
||
email: str = '' | ||
password: str = '' | ||
|
||
|
||
def prepare_credentails(): | ||
global email, password | ||
print('Prepare credentials') | ||
while not email: | ||
email = str(input("Enter email: \n>>> ")) | ||
while not password: | ||
password = str(input("Enter password: \n>>> ")) | ||
global email, password | ||
|
||
logger.debug('Prepare credentials') | ||
|
||
while not email: | ||
email = str(input("Enter email: \n>>> ")) | ||
while not password: | ||
password = str(input("Enter password: \n>>> ")) | ||
|
||
|
||
def init(): | ||
global username, password | ||
global username, password | ||
|
||
ws = WealthSimple(email, password) | ||
|
||
logger.debug('Get me...') | ||
me = ws.get_me() | ||
print(me) | ||
|
||
ws = WealthSimple(email, password) | ||
logger.debug('Get accounts') | ||
accounts = ws.get_accounts() | ||
print(accounts) | ||
|
||
print('Get me...\n') | ||
me = ws.get_me() | ||
print(me) | ||
logger.debug('Refresh tokens\n) | ||
ws.refresh_tokens() | ||
|
||
print('Get accounts\n') | ||
accounts = ws.get_accounts() | ||
print(accounts) | ||
print(ws.session.headers['Authorization']) | ||
|
||
logger.debug('Get security') | ||
TSLA = ws.get_security('TSLA') | ||
print(TSLA) | ||
|
||
print('Get security \n') | ||
TSLA = ws.get_security('TSLA') | ||
print(TSLA) | ||
|
||
prepare_credentails() | ||
init() | ||
|
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
|
||
setup( | ||
name="stockai", | ||
version="1.4.0", | ||
version="1.5.0", | ||
author="Dale Nguyen", | ||
author_email="[email protected]", | ||
description="Get stock info from Yahoo! Finance", | ||
|
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 |
---|---|---|
@@ -1,30 +1,31 @@ | ||
import requests | ||
|
||
|
||
class WSAPIRequest: | ||
""" | ||
Handle API requests for WealthSimple | ||
""" | ||
|
||
def __init__(self, session, WS_URL): | ||
def __init__(self, session, ws_url): | ||
self.session = session | ||
self.WS_URL = WS_URL | ||
self.WS_URL = ws_url | ||
|
||
def request(self, method, endpoint, params=None): | ||
url = self.WS_URL + endpoint | ||
|
||
if method == 'POST': | ||
return self.post(url, params) | ||
return self.__post(url, params) | ||
elif method == 'GET': | ||
return self.get(url, params) | ||
return self.__get(url, params) | ||
else: | ||
raise Exception('Invalid request method: {method}') | ||
|
||
def post(self, url, params=None): | ||
def __post(self, url, params=None): | ||
try: | ||
return self.session.post(url, params) | ||
except Exception as error: | ||
print(error) | ||
|
||
def get(self, url, payload=None): | ||
auth = self.session.headers['Authorization'] | ||
return requests.get(url, headers = { 'Authorization': auth }) | ||
def __get(self, url, payload=None): | ||
auth = self.session.headers['Authorization'] | ||
return requests.get(url, headers={'Authorization': auth}) |
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
Oops, something went wrong.