firstrade 0.0.19__py3-none-any.whl → 0.0.20__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
firstrade/order.py CHANGED
@@ -86,11 +86,6 @@ class Order:
86
86
  Order:order_confirmation: Dictionary containing the order confirmation data.
87
87
  """
88
88
 
89
- if dry_run:
90
- previewOrders = "1"
91
- else:
92
- previewOrders = ""
93
-
94
89
  if price_type == PriceType.MARKET:
95
90
  price = ""
96
91
 
@@ -100,8 +95,8 @@ class Order:
100
95
  "orderbar_accountid": "",
101
96
  "notional": "yes" if notional else "",
102
97
  "stockorderpage": "yes",
103
- "submitOrders": "1",
104
- "previewOrders": previewOrders,
98
+ "submitOrders": "",
99
+ "previewOrders": "1",
105
100
  "lotMethod": "1",
106
101
  "accountType": "1",
107
102
  "quoteprice": "",
@@ -133,6 +128,30 @@ class Order:
133
128
  "xml",
134
129
  )
135
130
  order_confirmation = {}
131
+ cdata = order_data.find("actiondata").string
132
+ cdata_soup = BeautifulSoup(cdata, "html.parser")
133
+ span = (
134
+ cdata_soup.find("div", class_="msg_bg")
135
+ .find("div", class_="yellow box")
136
+ .find("div", class_="error_msg")
137
+ .find("div", class_="outbox")
138
+ .find("div", class_="inbox")
139
+ .find("span")
140
+ )
141
+ if span:
142
+ order_warning = span.text.strip()
143
+ order_confirmation["warning"] = order_warning
144
+ data["viewederror"] = "1"
145
+ if not dry_run:
146
+ data["previewOrders"] = ""
147
+ data["submitOrders"] = "1"
148
+ order_data = BeautifulSoup(
149
+ self.ft_session.post(
150
+ url=urls.orderbar(), headers=urls.session_headers(), data=data
151
+ ).text,
152
+ "xml",
153
+ )
154
+
136
155
  order_success = order_data.find("success").text.strip()
137
156
  order_confirmation["success"] = order_success
138
157
  action_data = order_data.find("actiondata").text.strip()
@@ -177,48 +196,56 @@ def get_orders(ft_session, account):
177
196
 
178
197
  # Data dictionary to send with the request
179
198
  data = {
180
- 'accountId': account,
199
+ "accountId": account,
181
200
  }
182
201
 
183
202
  # Post request to retrieve the order data
184
- response = ft_session.post(url=urls.order_list(), headers=urls.session_headers(), data=data).text
203
+ response = ft_session.post(
204
+ url=urls.order_list(), headers=urls.session_headers(), data=data
205
+ ).text
185
206
 
186
207
  # Parse the response using BeautifulSoup
187
208
  soup = BeautifulSoup(response, "html.parser")
188
209
 
189
210
  # Find the table containing orders
190
- table = soup.find('table', class_='tablesorter')
211
+ table = soup.find("table", class_="tablesorter")
191
212
  if not table:
192
213
  return []
193
214
 
194
- rows = table.find_all('tr')[1:] # skip the header row
215
+ rows = table.find_all("tr")[1:] # skip the header row
195
216
 
196
217
  orders = []
197
218
  for row in rows:
198
219
  try:
199
- cells = row.find_all('td')
200
- tooltip_content = row.find('a', {'class': 'info'}).get('onmouseover')
201
- tooltip_soup = BeautifulSoup(tooltip_content.split('tooltip.show(')[1].strip("');"), 'html.parser')
202
- order_ref = tooltip_soup.find(text=lambda text: 'Order Ref' in text)
203
- order_ref_number = order_ref.split('#: ')[1] if order_ref else None
220
+ cells = row.find_all("td")
221
+ tooltip_content = row.find("a", {"class": "info"}).get("onmouseover")
222
+ tooltip_soup = BeautifulSoup(
223
+ tooltip_content.split("tooltip.show(")[1].strip("');"), "html.parser"
224
+ )
225
+ order_ref = tooltip_soup.find(text=lambda text: "Order Ref" in text)
226
+ order_ref_number = order_ref.split("#: ")[1] if order_ref else None
204
227
  status = cells[8]
205
228
  # print(status)
206
- sub_status = status.find('strong')
229
+ sub_status = status.find("strong")
207
230
  # print(sub_status)
208
231
  sub_status = sub_status.get_text(strip=True)
209
232
  # print(sub_status)
210
- status = status.find('strong').get_text(strip=True) if status.find('strong') else status.get_text(strip=True)
233
+ status = (
234
+ status.find("strong").get_text(strip=True)
235
+ if status.find("strong")
236
+ else status.get_text(strip=True)
237
+ )
211
238
  order = {
212
- 'Date/Time': cells[0].get_text(strip=True),
213
- 'Reference': order_ref_number,
214
- 'Transaction': cells[1].get_text(strip=True),
215
- 'Quantity': int(cells[2].get_text(strip=True)),
216
- 'Symbol': cells[3].get_text(strip=True),
217
- 'Type': cells[4].get_text(strip=True),
218
- 'Price': float(cells[5].get_text(strip=True)),
219
- 'Duration': cells[6].get_text(strip=True),
220
- 'Instr.': cells[7].get_text(strip=True),
221
- 'Status': status,
239
+ "Date/Time": cells[0].get_text(strip=True),
240
+ "Reference": order_ref_number,
241
+ "Transaction": cells[1].get_text(strip=True),
242
+ "Quantity": int(cells[2].get_text(strip=True)),
243
+ "Symbol": cells[3].get_text(strip=True),
244
+ "Type": cells[4].get_text(strip=True),
245
+ "Price": float(cells[5].get_text(strip=True)),
246
+ "Duration": cells[6].get_text(strip=True),
247
+ "Instr.": cells[7].get_text(strip=True),
248
+ "Status": status,
222
249
  }
223
250
  orders.append(order)
224
251
  except Exception as e:
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: firstrade
3
- Version: 0.0.19
3
+ Version: 0.0.20
4
4
  Summary: An unofficial API for Firstrade
5
5
  Home-page: https://github.com/MaxxRK/firstrade-api
6
- Download-URL: https://github.com/MaxxRK/firstrade-api/archive/refs/tags/0019.tar.gz
6
+ Download-URL: https://github.com/MaxxRK/firstrade-api/archive/refs/tags/0020.tar.gz
7
7
  Author: MaxxRK
8
8
  Author-email: maxxrk@pm.me
9
9
  License: MIT
@@ -0,0 +1,10 @@
1
+ firstrade/__init__.py,sha256=fNiWYgSTjElY1MNv0Ug-sVLMTR2z_Ngri_FY7Pekdrw,95
2
+ firstrade/account.py,sha256=xDgTMXDy2UWUNi4kboXAKKBrbmZGpXLJ11MCHlMvzB0,9218
3
+ firstrade/order.py,sha256=chDqutqA3H7_5NMnleGoqD3OdHms4iTCRZ34lKZ1_FU,8507
4
+ firstrade/symbols.py,sha256=tZD7jexvyvh1rTaOdAKv_vyZWzpjffvl_nPwBe1QaiA,3633
5
+ firstrade/urls.py,sha256=OrfXGDsNpA2rTm4o55KAQzpeigG_pxufWyTDBlbhJYQ,1248
6
+ firstrade-0.0.20.dist-info/LICENSE,sha256=wPEQjDqm5zMBmEcZp219Labmq_YIjhudpZiUzyVKaFA,1057
7
+ firstrade-0.0.20.dist-info/METADATA,sha256=9Uhmo3S2cvYc5fyTpyACPxHTpCIS5p1GgBOqb2csZ-A,2399
8
+ firstrade-0.0.20.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
9
+ firstrade-0.0.20.dist-info/top_level.txt,sha256=tdA8v-KDxU1u4VV6soiNWGBlni4ojv_t_j2wFn5nZcs,10
10
+ firstrade-0.0.20.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.1.0)
2
+ Generator: setuptools (70.3.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,10 +0,0 @@
1
- firstrade/__init__.py,sha256=fNiWYgSTjElY1MNv0Ug-sVLMTR2z_Ngri_FY7Pekdrw,95
2
- firstrade/account.py,sha256=xDgTMXDy2UWUNi4kboXAKKBrbmZGpXLJ11MCHlMvzB0,9218
3
- firstrade/order.py,sha256=BK2OmIOr_LO4SrNRVWjkydaoc_4fLkl6Rr7_LCRTyLE,7635
4
- firstrade/symbols.py,sha256=tZD7jexvyvh1rTaOdAKv_vyZWzpjffvl_nPwBe1QaiA,3633
5
- firstrade/urls.py,sha256=OrfXGDsNpA2rTm4o55KAQzpeigG_pxufWyTDBlbhJYQ,1248
6
- firstrade-0.0.19.dist-info/LICENSE,sha256=wPEQjDqm5zMBmEcZp219Labmq_YIjhudpZiUzyVKaFA,1057
7
- firstrade-0.0.19.dist-info/METADATA,sha256=apZ7RN0uTgzdVp90m3LeQyZcs34zBtWtUTFmxK7akFA,2399
8
- firstrade-0.0.19.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
9
- firstrade-0.0.19.dist-info/top_level.txt,sha256=tdA8v-KDxU1u4VV6soiNWGBlni4ojv_t_j2wFn5nZcs,10
10
- firstrade-0.0.19.dist-info/RECORD,,