Skip to content

Commit

Permalink
Merge remote-tracking branch 'MaxxRK/develop-schwab-api2' into develo…
Browse files Browse the repository at this point in the history
…p-schwab
  • Loading branch information
NelsonDane committed Oct 10, 2023
2 parents 0d09526 + d571fa6 commit 7d03f27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.8
selenium==4.12.0
tastytrade==6.1
webdriver-manager==4.0.0
13 changes: 7 additions & 6 deletions schwabAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand All @@ -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"
Expand All @@ -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:
Expand All @@ -128,3 +128,4 @@ def schwab_transaction(schwab_o: Brokerage, orderObj: stockOrder, loop=None):
continue
sleep(1)
print()
obj.close_session()

0 comments on commit 7d03f27

Please sign in to comment.