Skip to content

Commit

Permalink
Merge pull request #23 from MaxxRK/deepsource-transform-7d86940c
Browse files Browse the repository at this point in the history
style: format code with Black and isort
  • Loading branch information
MaxxRK authored Jun 21, 2024
2 parents f0d3cbc + 51a99fd commit 49c4e17
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 29 deletions.
4 changes: 3 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
login_username = login_username.strip()
login_password = input("Input your password: ")
login_password = login_password.strip()
login_input = input("Input last four of your cell phone used to login on vanguard.com: ")
login_input = input(
"Input last four of your cell phone used to login on vanguard.com: "
)
login_input = int(login_input.strip().upper())

profile = input("Input profile name: ")
Expand Down
61 changes: 34 additions & 27 deletions test_limit.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import traceback
from vanguard.session import VanguardSession

from vanguard.account import AllAccount
from vanguard.order import Duration, OrderSide, Order, PriceType
from vanguard.order import Duration, Order, OrderSide, PriceType
from vanguard.session import VanguardSession

login_username = input('Input your username: ')
login_username = input("Input your username: ")
login_username = login_username.strip()
login_password = input('Input your password: ')
login_password = input("Input your password: ")
login_password = login_password.strip()
login_input = input('Input last four of your cell phone used to login on vanguard.com: ')
login_input = input(
"Input last four of your cell phone used to login on vanguard.com: "
)
login_input = int(login_input.strip().upper())

profile = input('Input profile name: ')
profile = input("Input profile name: ")
profile = profile.strip().lower()
session = VanguardSession(title=profile, headless=True)
logged_in = session.login(login_username, login_password, login_input)
Expand All @@ -19,37 +22,41 @@
session.login_two(code)
else:
print("Vanguard logged in without 2fa!")

account_info = AllAccount(session)
account_info.get_account_ids()
account_info.get_holdings()

print(f'Total value: {account_info.total_value}')
print(f'Account numbers/totals: {account_info.account_totals}')
print(f"Total value: {account_info.total_value}")
print(f"Account numbers/totals: {account_info.account_totals}")
for account in account_info.accounts_positions.keys():
print(f'Account: {account}')
print(f"Account: {account}")
for type in account_info.accounts_positions[account].keys():
print(f'Type: {type}')
print(f"Type: {type}")
for stock in account_info.accounts_positions[account][type]:
print(f'{stock["symbol"]} of price {stock["price"]} and quantity {stock["quantity"]}')
print(
f'{stock["symbol"]} of price {stock["price"]} and quantity {stock["quantity"]}'
)
order = Order(session)
price = order.get_quote('INTC')
print(f'Price of INTC: {price}')
price = order.get_quote("INTC")
print(f"Price of INTC: {price}")
for account in account_info.account_numbers:
try:
messages = order.place_order(account,
1,
PriceType.LIMIT,
'INTC',
Duration.DAY,
OrderSide.BUY,
limit_price=price,
after_hours=True,
dry_run=True)

messages = order.place_order(
account,
1,
PriceType.LIMIT,
"INTC",
Duration.DAY,
OrderSide.BUY,
limit_price=price,
after_hours=True,
dry_run=True,
)

if (
messages["ORDER INVALID"] == ""
or messages["ORDER INVALID"] == "No invalid order message found."
messages["ORDER INVALID"] == ""
or messages["ORDER INVALID"] == "No invalid order message found."
or messages["ORDER CONFIRMATION"] != ""
):
print(f'Order preview: {messages["ORDER PREVIEW"]}')
Expand All @@ -60,4 +67,4 @@
traceback.print_exc()
print(f"Script exception: {e}")
print(f'Error placing order for account {account}: {messages["ORDER INVALID"]}')
session.close_browser()
session.close_browser()
4 changes: 3 additions & 1 deletion vanguard/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ def get_account_ids(self):
for j, entry in enumerate(table_entries):
if j == len(table_entries) - 1:
total_row = entry.query_selector_all("tr")
self.account_totals[account_id] = total_row[-1].inner_text().split()
self.account_totals[account_id] = (
total_row[-1].inner_text().split()
)
return True
except PlaywrightTimeoutError:
return False
Expand Down

0 comments on commit 49c4e17

Please sign in to comment.