Skip to content

Enforce risk limits on all order types; fix stale UAT hostname tests - #1

Open
michaelthomas7470-pixel wants to merge 3 commits into
webull-inc:mainfrom
michaelthomas7470-pixel:fix/order-risk-limits
Open

Enforce risk limits on all order types; fix stale UAT hostname tests#1
michaelthomas7470-pixel wants to merge 3 commits into
webull-inc:mainfrom
michaelthomas7470-pixel:fix/order-risk-limits

Conversation

@michaelthomas7470-pixel

@michaelthomas7470-pixel michaelthomas7470-pixel commented Jul 20, 2026

Copy link
Copy Markdown

Summary

  • Options, option strategies, combo orders, and event contracts could previously bypass the configured max_order_quantity, notional, and symbol-whitelist limits entirely, and AMOUNT-denominated stock/crypto orders had no notional cap at all.
  • Fixes a call-site bug where place_stock_combo_order validated legs against the wrong shape (validate_combo_order expects {combo_type, orders: [...]}, but was called once per leg), so per-leg side/order_type/time_in_force were silently never checked.
  • Fixes stale test_sdk_client.py assertions left over from the UAT endpoint migration (bc8e3c8) and the addition of eu/za/au regions.
  • Fixes UAT_ENDPOINTS["region_mapping"]["za"] incorrectly aliasing "au"'s sandbox hostnames verbatim (copy-paste bug from 14e43f0), even though ZA and AU have distinct 2FA doc-link domains and separate RegionConfig instances elsewhere in the same commit.

Changes

  • guards.py: add quantity/notional/whitelist checks to validate_option_order, validate_option_strategy_order, validate_combo_order, and validate_algo_order; add validate_combo_leg for the actual per-leg calling convention; add _validate_cash_amount for AMOUNT entrust_type orders.
  • Wire the above into place_option_single_order, place_option_strategy_order, place_stock_combo_order, place_algo_order, place_crypto_order (AMOUNT branch was previously skipped), and place_event_order (also adds order_type/time_in_force enum checks, previously missing).
  • test_sdk_client.py: update hostname/region assertions to match current UAT_ENDPOINTS; add eu/au/za coverage plus a regression guard asserting za and au endpoint blocks are distinct.
  • sdk_client.py: fix za UAT sandbox hostnames to za-api.uat.webullbroker.com / za-events-api.uat.webullbroker.com, matching the naming convention used by every other region.

Test plan

  • pytest run locally: 565 passed, 10 failed (all 10 pre-existing, reproduced identically on main before this change — Windows/Python 3.12 asyncio event-loop and file-permission issues unrelated to this diff).
  • New/extended tests added for every changed validation path (test_guards.py, new test_event_order_guards.py) and for the ZA/AU endpoint fix (test_sdk_client.py).

michaelthomas7470-pixel and others added 3 commits July 20, 2026 13:33
Options, option strategies, combo orders, and event contracts could
previously bypass the configured max_order_quantity, notional, and
symbol-whitelist limits entirely, and AMOUNT-denominated stock/crypto
orders had no notional cap at all. Also fixes a call-site bug where
place_stock_combo_order validated legs against the wrong shape
(validate_combo_order expects {combo_type, orders: [...]}, but was
called once per leg), so per-leg side/order_type/time_in_force were
silently never checked.

- guards.py: add quantity/notional/whitelist checks to
  validate_option_order, validate_option_strategy_order,
  validate_combo_order, and validate_algo_order; add
  validate_combo_leg for the actual per-leg calling convention; add
  _validate_cash_amount for AMOUNT entrust_type orders.
- Wire the above into place_option_single_order,
  place_option_strategy_order, place_stock_combo_order,
  place_algo_order, place_crypto_order (AMOUNT branch was previously
  skipped), and place_event_order (also adds order_type/time_in_force
  enum checks, previously missing).
- Add test coverage for all of the above in test_guards.py and new
  test_event_order_guards.py.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
UAT_ENDPOINTS was updated (eu/za/au regions added, US UAT endpoints
migrated to api.sandbox.webull.com in bc8e3c8) but these tests still
asserted the old us-openapi-alb.uat.webullbroker.com hostnames and an
incomplete region list, so they failed against current sdk_client.py.
Also adds per-region hostname tests for eu/au to match the existing
jp/hk pattern.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
UAT_ENDPOINTS["region_mapping"]["za"] was byte-for-byte identical to
"au" (au-api.uat.webullbroker.com / au-events-api.uat.webullbroker.com),
breaking the {region}-api.uat.webullbroker.com naming convention every
other region follows. Introduced in 14e43f0 ("feat: Add AU mcp
features") by copy-pasting the au block as a template for za and not
renaming the hostnames.

Confirmed as a bug, not shared infra: the same commit added a distinct
_2FA_GUIDE_LINKS domain for za (developer.webull.co.za) vs au
(developer.webull.com.au), and region_config.py defines a fully
separate ZA_REGION_CONFIG instance. Fixed to za-api.uat.webullbroker.com
/ za-events-api.uat.webullbroker.com, matching the pattern used by
every other region (e.g. eu).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant