Skip to content

Commit

Permalink
Merge pull request #133 from NelsonDane/develop-schwab
Browse files Browse the repository at this point in the history
Fallback to Schwab v1 if v2 fails
  • Loading branch information
NelsonDane authored Jan 18, 2024
2 parents 1d03339 + a774432 commit ac8e4c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ Required `.env` variables:

To get your TOTP secret, follow this [guide](guides/schwabSetup.md).

Note: If you are using Windows, you will need to install playwright manually. See [this guide](guides/playwrightWindows.md) for more information.
Note 1: Think or Swim must be enabled on all accounts. To enable, go to `Trade` > `Trading Platforms` > `Learn how to enable thinkorswim`. Then press `Continue` and expand the `thinkorswim Access Agreement` and accept it. Then press `Continue` again. Then select the checkbox for all available accounts and press `Submit`. It may take a day or two for the accounts to be enabled.

Note 2: If you are using Windows, you may need to install playwright manually. See [this guide](guides/playwrightWindows.md) for more information.

### Tradier
Made by yours truly using the official [Tradier API](https://documentation.tradier.com/brokerage-api/trading/getting-started). Consider giving me a ⭐
Expand Down
16 changes: 15 additions & 1 deletion schwabAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,24 @@ def schwab_transaction(schwab_o: Brokerage, orderObj: stockOrder, loop=None):
f"{key} account {print_account}: The order verification was "
+ "successful"
if success
else "unsuccessful",
else "unsuccessful, retrying...",
loop,
)
if not success:
messages, success = obj.trade(
ticker=s,
side=orderObj.get_action().capitalize(),
qty=orderObj.get_amount(),
account_id=account,
dry_run=orderObj.get_dry(),
)
printAndDiscord(
f"{key} account {print_account}: The order verification was "
+ "retry successful"
if success
else "retry unsuccessful",
loop,
)
printAndDiscord(
f"{key} account {print_account}: The order verification produced the following messages: {messages}",
loop,
Expand Down

0 comments on commit ac8e4c2

Please sign in to comment.