From 6b8fd8f2f00c32e295c44afadbda5261aa8b17c2 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 02:20:11 +0000 Subject: [PATCH 1/3] style: format code with Black and isort This commit fixes the style issues introduced in de11c7e according to the output from Black and isort. Details: None --- vanguardAPI.py | 51 +++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/vanguardAPI.py b/vanguardAPI.py index be6171a1..b499c259 100644 --- a/vanguardAPI.py +++ b/vanguardAPI.py @@ -6,9 +6,9 @@ import pprint import traceback +from dotenv import load_dotenv from vanguard import account as vg_account from vanguard import order, session -from dotenv import load_dotenv from helperAPI import ( Brokerage, @@ -20,18 +20,14 @@ ) -def vanguard_run( - orderObj: stockOrder, command=None, botObj=None, loop=None -): +def vanguard_run(orderObj: stockOrder, command=None, botObj=None, loop=None): # Initialize .env file load_dotenv() # Import Vanguard account if not os.getenv("VANGUARD"): print("Vanguard not found, skipping...") return None - accounts = ( - os.environ["VANGUARD"].strip().split(",") - ) + accounts = os.environ["VANGUARD"].strip().split(",") # Set the functions to be run _, second_command = command @@ -64,7 +60,7 @@ def vanguard_init(account, index, botObj=None, loop=None): title=f"Vanguard_{index}", headless=True, profile_path="./creds", - debug=debug + debug=debug, ) need_second = vg_session.login(account[0], account[1], account[2]) if need_second: @@ -75,7 +71,9 @@ def vanguard_init(account, index, botObj=None, loop=None): getOTPCodeDiscord(botObj, name, timeout=120, loop=loop), loop ).result() if sms_code is None: - raise Exception(f"Vanguard {index} code not received in time...", loop) + raise Exception( + f"Vanguard {index} code not received in time...", loop + ) vg_session.login_two(sms_code) all_accounts = vg_account.AllAccount(vg_session) success = all_accounts.get_account_ids() @@ -86,7 +84,9 @@ def vanguard_init(account, index, botObj=None, loop=None): print_accounts = [] for acct in all_accounts.account_totals.keys(): vanguard_obj.set_account_number(name, acct) - vanguard_obj.set_account_totals(name, acct, all_accounts.account_totals[acct]) + vanguard_obj.set_account_totals( + name, acct, all_accounts.account_totals[acct] + ) print_accounts.append(acct) print(f"The following Vanguard accounts were found: {print_accounts}") except Exception as e: @@ -111,7 +111,13 @@ def vanguard_holdings(vanguard_o: Brokerage, loop=None): for type in all_accounts.accounts_positions[account].keys(): for stock in all_accounts.accounts_positions[account][type]: if float(stock["quantity"]) != 0: - vanguard_o.set_holdings(key, account, stock["symbol"], stock["quantity"], stock["price"]) + vanguard_o.set_holdings( + key, + account, + stock["symbol"], + stock["quantity"], + stock["price"], + ) else: raise Exception("Vanguard-api failed to retrieve holdings.") except Exception as e: @@ -161,16 +167,21 @@ def vanguard_transaction(vanguard_o: Brokerage, orderObj: stockOrder, loop=None) dry_run=orderObj.get_dry(), ) print("The order verification produced the following messages: ") - if messages["ORDER CONFIRMATION"] == "No order confirmation page found. Order Failed.": - printAndDiscord("Market order failed placing limit order.", loop) + if ( + messages["ORDER CONFIRMATION"] + == "No order confirmation page found. Order Failed." + ): + printAndDiscord( + "Market order failed placing limit order.", loop + ) price_type = order.PriceType.LIMIT price = vg_order.get_quote(s) + 0.01 messages = vg_order.place_order( account_id=account, - quantity=int(orderObj.get_amount()), - price_type=price_type, - symbol=s, - duration=order.Duration.DAY, + quantity=int(orderObj.get_amount()), + price_type=price_type, + symbol=s, + duration=order.Duration.DAY, order_type=order_type, limit_price=price, dry_run=orderObj.get_dry(), @@ -225,11 +236,13 @@ def vanguard_transaction(vanguard_o: Brokerage, orderObj: stockOrder, loop=None) loop, ) except Exception as e: - printAndDiscord(f"{key} {print_account}: Error submitting order: {e}", loop) + printAndDiscord( + f"{key} {print_account}: Error submitting order: {e}", loop + ) print(traceback.format_exc()) continue obj.close_browser() printAndDiscord( "All Vanguard transactions complete", loop, - ) \ No newline at end of file + ) From abf3a1f3ce884e5fc0930d49ec9bbd84bdcec5e2 Mon Sep 17 00:00:00 2001 From: Nelson Dane <47427072+NelsonDane@users.noreply.github.com> Date: Sun, 9 Jun 2024 22:28:13 -0400 Subject: [PATCH 2/3] deepsource fixes --- vanguardAPI.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/vanguardAPI.py b/vanguardAPI.py index b499c259..89ba58c2 100644 --- a/vanguardAPI.py +++ b/vanguardAPI.py @@ -82,7 +82,7 @@ def vanguard_init(account, index, botObj=None, loop=None): print("Logged in to Vanguard!") vanguard_obj.set_logged_in_object(name, vg_session) print_accounts = [] - for acct in all_accounts.account_totals.keys(): + for acct in all_accounts.account_totals: vanguard_obj.set_account_number(name, acct) vanguard_obj.set_account_totals( name, acct, all_accounts.account_totals[acct] @@ -107,9 +107,9 @@ def vanguard_holdings(vanguard_o: Brokerage, loop=None): raise Exception("Error getting account details") success = all_accounts.get_holdings() if success: - for account in all_accounts.accounts_positions.keys(): - for type in all_accounts.accounts_positions[account].keys(): - for stock in all_accounts.accounts_positions[account][type]: + for account in all_accounts.accounts_positions: + for account_type in all_accounts.accounts_positions[account].keys(): + for stock in all_accounts.accounts_positions[account][account_type]: if float(stock["quantity"]) != 0: vanguard_o.set_holdings( key, @@ -202,8 +202,8 @@ def vanguard_transaction(vanguard_o: Brokerage, orderObj: stockOrder, loop=None) loop, ) if ( - not messages["ORDER INVALID"] - == "No invalid order message found." + messages["ORDER INVALID"] + != "No invalid order message found." ): printAndDiscord( f"{key} account {print_account}: The order verification produced the following messages: {messages['ORDER INVALID']}", @@ -228,8 +228,8 @@ def vanguard_transaction(vanguard_o: Brokerage, orderObj: stockOrder, loop=None) loop, ) if ( - not messages["ORDER INVALID"] - == "No invalid order message found." + messages["ORDER INVALID"] + != "No invalid order message found." ): printAndDiscord( f"{key} account {print_account}: The order verification produced the following messages: {messages['ORDER INVALID']}", From b64e28859b9ff219fbf69e1658ff6eb35edc04d4 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 02:28:25 +0000 Subject: [PATCH 3/3] style: format code with Black and isort This commit fixes the style issues introduced in abf3a1f according to the output from Black and isort. Details: https://github.com/NelsonDane/auto-rsa/pull/256 --- vanguardAPI.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vanguardAPI.py b/vanguardAPI.py index 89ba58c2..ec0cc248 100644 --- a/vanguardAPI.py +++ b/vanguardAPI.py @@ -109,7 +109,9 @@ def vanguard_holdings(vanguard_o: Brokerage, loop=None): if success: for account in all_accounts.accounts_positions: for account_type in all_accounts.accounts_positions[account].keys(): - for stock in all_accounts.accounts_positions[account][account_type]: + for stock in all_accounts.accounts_positions[account][ + account_type + ]: if float(stock["quantity"]) != 0: vanguard_o.set_holdings( key,