diff --git a/autoRSA.py b/autoRSA.py index e1e9368e..ba423096 100644 --- a/autoRSA.py +++ b/autoRSA.py @@ -2,6 +2,7 @@ # Script to automate RSA stock purchases # Import libraries +import asyncio import os import sys import traceback @@ -233,7 +234,7 @@ async def help(ctx): @bot.command(name="rsa") async def rsa(ctx, *args): discOrdObj = await bot.loop.run_in_executor(None, argParser, args) - loop = asyncio.get_event_loop() + event_loop = asyncio.get_event_loop() try: # Login to brokers await bot.loop.run_in_executor(None, fun_run, discOrdObj, "_init") @@ -242,11 +243,11 @@ async def rsa(ctx, *args): # Get holdings or complete transaction if discOrdObj.get_holdings(): await bot.loop.run_in_executor( - None, fun_run, discOrdObj, "_holdings", loop + None, fun_run, discOrdObj, "_holdings", event_loop ) else: await bot.loop.run_in_executor( - None, fun_run, discOrdObj, "_transaction", loop + None, fun_run, discOrdObj, "_transaction", event_loop ) # Kill Drivers for b in discOrdObj.get_logged_in(): diff --git a/schwabAPI.py b/schwabAPI.py index b3ff4891..034c6115 100644 --- a/schwabAPI.py +++ b/schwabAPI.py @@ -82,10 +82,10 @@ def schwab_holdings(schwab_o: Brokerage, loop=None): schwab_o.set_holdings(key, account, sym, qty, current_price) except Exception as e: printAndDiscord(f"{key} {account}: Error getting holdings: {e}", loop) + printHoldings(schwab_o, loop) if SCHWAB_BETA: print(f"Closing session for {key}") obj.close_session() - printHoldings(schwab_o, loop) def schwab_transaction(schwab_o: Brokerage, orderObj: stockOrder, loop=None):