Skip to content

Commit

Permalink
Merge pull request #26 from MaxxRK/deepsource-transform-79de08ca
Browse files Browse the repository at this point in the history
style: format code with Black and isort
  • Loading branch information
MaxxRK authored Aug 1, 2024
2 parents 961ce5f + 9eab237 commit d338538
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
26 changes: 12 additions & 14 deletions vanguard/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from enum import Enum
from time import sleep

from playwright.sync_api import expect, TimeoutError as PlaywrightTimeoutError
from playwright.sync_api import TimeoutError as PlaywrightTimeoutError
from playwright.sync_api import expect

from .session import VanguardSession
from .urls import order_page
Expand Down Expand Up @@ -142,7 +143,9 @@ def place_order(
except PlaywrightTimeoutError:
pass
if order_type == "BUY":
buy_btn = self.session.page.wait_for_selector("xpath=//label/span[text()='Buy']")
buy_btn = self.session.page.wait_for_selector(
"xpath=//label/span[text()='Buy']"
)
buy_btn.click()
elif order_type == "SELL":
sell_btn = self.session.page.wait_for_selector(
Expand All @@ -167,8 +170,7 @@ def place_order(
)
return order_messages
self.session.page.wait_for_selector(
"//label/span[text()='Limit']",
timeout=3000
"//label/span[text()='Limit']", timeout=3000
).click()
elif price_type == "STOP":
if duration not in ["DAY", "GOOD_TILL_CANCELLED"]:
Expand All @@ -177,8 +179,7 @@ def place_order(
)
return order_messages
self.session.page.wait_for_selector(
"//label/span[text()='Stop']",
timeout=3000
"//label/span[text()='Stop']", timeout=3000
).click()
elif price_type == "STOP_LIMIT":
if duration not in ["DAY", "GOOD_TILL_CANCELLED"]:
Expand All @@ -187,8 +188,7 @@ def place_order(
)
return order_messages
self.session.page.wait_for_selector(
"//label/span[text()='Stop Limit']",
timeout=3000
"//label/span[text()='Stop Limit']", timeout=3000
).click()
if price_type in ["LIMIT", "STOP_LIMIT"]:
self.session.page.fill("#limitPrice", str(limit_price))
Expand Down Expand Up @@ -223,10 +223,10 @@ def place_order(
warning_items_locator = self.session.page.get_by_role("main")
warning_items = warning_items_locator.locator("li").all()
warning_text = {warning_header: []}
for i,item in enumerate(warning_items):
for i, item in enumerate(warning_items):
if i == 0:
warning_text[warning_header].append(item.text_content())
if warning_text[warning_header][i-1] != item.text_content():
warning_text[warning_header].append(item.text_content())
if warning_text[warning_header][i - 1] != item.text_content():
warning_text[warning_header].append(item.text_content())
order_messages["ORDER INVALID"] = warning_text
return order_messages
Expand All @@ -240,9 +240,7 @@ def place_order(
pass
if after_hours:
try:
after_button = self.session.page.get_by_role(
"button", name="Continue"
)
after_button = self.session.page.get_by_role("button", name="Continue")
expect(after_button).to_be_visible(timeout=3000)
after_button.click()
except (AssertionError, PlaywrightTimeoutError):
Expand Down
1 change: 0 additions & 1 deletion vanguard/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ def holdings_page():

def order_page():
return "https://etfs-stocks.web.vanguard.com/c/trade/ticket"

0 comments on commit d338538

Please sign in to comment.