From 34c7915e1e00df0b209df10c41f2af391a6130c7 Mon Sep 17 00:00:00 2001 From: Donald Ryan Gullett <45299186+MaxxRK@users.noreply.github.com> Date: Sun, 8 Oct 2023 18:49:35 -0500 Subject: [PATCH 1/2] schwab fix --- requirements.txt | 2 +- schwabAPI.py | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/requirements.txt b/requirements.txt index 3bdcb585..5c8ca185 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ pyotp==2.9.0 python-dotenv==1.0.0 requests==2.31.0 robin_stocks==3.0.6 -schwab-api==0.2.3 +schwab-api2==0.2.7 selenium==4.12.0 tastytrade==6.1 webdriver-manager==4.0.0 diff --git a/schwabAPI.py b/schwabAPI.py index 3c1fab0b..cca9f1e5 100644 --- a/schwabAPI.py +++ b/schwabAPI.py @@ -6,7 +6,7 @@ from time import sleep from dotenv import load_dotenv -from schwab_api import Schwab +from schwab_api2 import Schwab from helperAPI import Brokerage, printAndDiscord, printHoldings, stockOrder @@ -76,6 +76,7 @@ def schwab_holdings(schwab_o: Brokerage, loop=None): printAndDiscord(f"{key} {account}: Error getting holdings: {e}", loop) continue printHoldings(schwab_o, loop) + obj.close_session() def schwab_transaction(schwab_o: Brokerage, orderObj: stockOrder, loop=None): @@ -102,13 +103,12 @@ def schwab_transaction(schwab_o: Brokerage, orderObj: stockOrder, loop=None): try: messages, success = obj.trade( ticker=s, - side=orderObj.get_action().capitalize(), + action=orderObj.get_action().capitalize(), qty=orderObj.get_amount(), - account_id=account, + order_type="Market", + account_id=str(account), dry_run=orderObj.get_dry(), ) - print("The order verification produced the following messages: ") - pprint.pprint(messages) printAndDiscord( f"{key} account {account}: The order verification was " + "successful" @@ -118,7 +118,7 @@ def schwab_transaction(schwab_o: Brokerage, orderObj: stockOrder, loop=None): ) if not success: printAndDiscord( - f"{key} account {account}: The order verification produced the following messages: {messages}", + f"{key} account {account}: The order verification produced the following messages: {messages['order_messages']}", loop, ) except Exception as e: @@ -128,3 +128,4 @@ def schwab_transaction(schwab_o: Brokerage, orderObj: stockOrder, loop=None): continue sleep(1) print() + obj.close_session() From d571fa63019d638da02457ed2f712e916cde52d8 Mon Sep 17 00:00:00 2001 From: Donald Ryan Gullett <45299186+MaxxRK@users.noreply.github.com> Date: Mon, 9 Oct 2023 09:03:03 -0500 Subject: [PATCH 2/2] updated schwab-api2 version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 5c8ca185..9b51bdd0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ pyotp==2.9.0 python-dotenv==1.0.0 requests==2.31.0 robin_stocks==3.0.6 -schwab-api2==0.2.7 +schwab-api2==0.2.8 selenium==4.12.0 tastytrade==6.1 webdriver-manager==4.0.0