From 41f68984a3fddfca3230c016389164b6afdb9807 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sat, 13 Jul 2024 02:10:57 +0000 Subject: [PATCH] style: format code with Black and isort This commit fixes the style issues introduced in 206c787 according to the output from Black and isort. Details: None --- firstrade/order.py | 67 +++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/firstrade/order.py b/firstrade/order.py index 96e895e..972a8d0 100644 --- a/firstrade/order.py +++ b/firstrade/order.py @@ -86,7 +86,6 @@ def place_order( Order:order_confirmation: Dictionary containing the order confirmation data. """ - if price_type == PriceType.MARKET: price = "" @@ -121,7 +120,7 @@ def place_order( "cond_compare_type0_1": "2", "cond_compare_value0_1": "", } - + order_data = BeautifulSoup( self.ft_session.post( url=urls.orderbar(), headers=urls.session_headers(), data=data @@ -132,12 +131,12 @@ def place_order( cdata = order_data.find("actiondata").string cdata_soup = BeautifulSoup(cdata, "html.parser") span = ( - cdata_soup.find('div', class_='msg_bg') - .find('div', class_='yellow box') - .find('div', class_='error_msg') - .find('div', class_='outbox') - .find('div', class_='inbox') - .find('span') + cdata_soup.find("div", class_="msg_bg") + .find("div", class_="yellow box") + .find("div", class_="error_msg") + .find("div", class_="outbox") + .find("div", class_="inbox") + .find("span") ) if span: order_warning = span.text.strip() @@ -152,7 +151,7 @@ def place_order( ).text, "xml", ) - + order_success = order_data.find("success").text.strip() order_confirmation["success"] = order_success action_data = order_data.find("actiondata").text.strip() @@ -197,48 +196,56 @@ def get_orders(ft_session, account): # Data dictionary to send with the request data = { - 'accountId': account, + "accountId": account, } # Post request to retrieve the order data - response = ft_session.post(url=urls.order_list(), headers=urls.session_headers(), data=data).text + response = ft_session.post( + url=urls.order_list(), headers=urls.session_headers(), data=data + ).text # Parse the response using BeautifulSoup soup = BeautifulSoup(response, "html.parser") # Find the table containing orders - table = soup.find('table', class_='tablesorter') + table = soup.find("table", class_="tablesorter") if not table: return [] - rows = table.find_all('tr')[1:] # skip the header row + rows = table.find_all("tr")[1:] # skip the header row orders = [] for row in rows: try: - cells = row.find_all('td') - tooltip_content = row.find('a', {'class': 'info'}).get('onmouseover') - tooltip_soup = BeautifulSoup(tooltip_content.split('tooltip.show(')[1].strip("');"), 'html.parser') - order_ref = tooltip_soup.find(text=lambda text: 'Order Ref' in text) - order_ref_number = order_ref.split('#: ')[1] if order_ref else None + cells = row.find_all("td") + tooltip_content = row.find("a", {"class": "info"}).get("onmouseover") + tooltip_soup = BeautifulSoup( + tooltip_content.split("tooltip.show(")[1].strip("');"), "html.parser" + ) + order_ref = tooltip_soup.find(text=lambda text: "Order Ref" in text) + order_ref_number = order_ref.split("#: ")[1] if order_ref else None status = cells[8] # print(status) - sub_status = status.find('strong') + sub_status = status.find("strong") # print(sub_status) sub_status = sub_status.get_text(strip=True) # print(sub_status) - status = status.find('strong').get_text(strip=True) if status.find('strong') else status.get_text(strip=True) + status = ( + status.find("strong").get_text(strip=True) + if status.find("strong") + else status.get_text(strip=True) + ) order = { - 'Date/Time': cells[0].get_text(strip=True), - 'Reference': order_ref_number, - 'Transaction': cells[1].get_text(strip=True), - 'Quantity': int(cells[2].get_text(strip=True)), - 'Symbol': cells[3].get_text(strip=True), - 'Type': cells[4].get_text(strip=True), - 'Price': float(cells[5].get_text(strip=True)), - 'Duration': cells[6].get_text(strip=True), - 'Instr.': cells[7].get_text(strip=True), - 'Status': status, + "Date/Time": cells[0].get_text(strip=True), + "Reference": order_ref_number, + "Transaction": cells[1].get_text(strip=True), + "Quantity": int(cells[2].get_text(strip=True)), + "Symbol": cells[3].get_text(strip=True), + "Type": cells[4].get_text(strip=True), + "Price": float(cells[5].get_text(strip=True)), + "Duration": cells[6].get_text(strip=True), + "Instr.": cells[7].get_text(strip=True), + "Status": status, } orders.append(order) except Exception as e: