logged_in = api_inst.login(
File "../../git/schwab-api/schwab_api/authentication.py", line 171, in login
self.page.goto("https://www.schwab.com/")
File "../lib/python3.9/site-packages/playwright/sync_api/_generated.py", line 9312, in goto
self._sync(
File "../lib/python3.9/site-packages/playwright/_impl/_sync_base.py", line 115, in _sync
return task.result()
File "../lib/python3.9/site-packages/playwright/_impl/_page.py", line 475, in goto
return await self._main_frame.goto(**locals_to_params(locals()))
File "../lib/python3.9/site-packages/playwright/_impl/_frame.py", line 139, in goto
await self._channel.send("goto", locals_to_params(locals()))
File "../lib/python3.9/site-packages/playwright/_impl/_connection.py", line 62, in send
return await self._connection.wrap_api_call(
File "../lib/python3.9/site-packages/playwright/_impl/_connection.py", line 492, in wrap_api_call
return await cb()
File "../lib/python3.9/site-packages/playwright/_impl/_connection.py", line 100, in inner_send
result = next(iter(done)).result()
playwright._impl._errors.TimeoutError: Timeout 30000ms exceeded.
the setup of default valid_return_codes ={0,10} may result in order_v2 buy fail but didn't tell why it failed (sell is successful and is not impacted).
valid_return_codes (set) - Schwab returns an orderReturnCode in the response to both
the verification and execution requests, and it appears to be the
"severity" for the highest severity message.
Verification response messages with severity 10 include:
- The market is now closed. This order will be placed for the next
trading day
- You are purchasing an ETF...please read the prospectus
- It is your responsibility to choose the cost basis method
appropriate to your tax situation
- Quote at the time of order verification: $xx.xx
Verification response messages with severity 20 include at least:
- Insufficient settled funds (different from insufficient buying power)
Verification response messages with severity 25 include at least:
- This order is executable because the buy (or sell) limit is higher
(lower) than the ask (bid) price.
For the execution response, the orderReturnCode is typically 0 for a
successfully placed order.
Execution response messages with severity 30 include:
- Order Affirmation required (This means Schwab wants you to confirm
that you really meant to place this order as-is since something about
it meets Schwab's criteria for requiring verification. This is
usually analogous to a checkbox you would need to check when using
the web interface)
The issue can be resolved by forcing the below code in the screenshot
and dry_run
but it's not desired. It's better to specify the type of valid_return_codes as example code below.
messages, success = api.trade_v2(
ticker="AAPL",
side='Buy', #or Sell
qty=sharesNum,
account_id=account_id, # Replace with your account number
dry_run=False, # If dry_run=True, we won't place the order, we'll just verify it.
valid_return_codes = {0,10,20}
)
Before this code update, it's not obvious why this buy fail happened. So this fix add this message and also append the missing messages from dry_run to final order place.
The issue can be resolved by forcing the below code in the screenshot
Before this code update, it's not obvious why this buy fail happened. So this fix add this message and also append the missing messages from dry_run to final order place.