Enforce risk limits on all order types; fix stale UAT hostname tests - #1
Open
michaelthomas7470-pixel wants to merge 3 commits into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
max_order_quantity, notional, and symbol-whitelist limits entirely, and AMOUNT-denominated stock/crypto orders had no notional cap at all.place_stock_combo_ordervalidated legs against the wrong shape (validate_combo_orderexpects{combo_type, orders: [...]}, but was called once per leg), so per-legside/order_type/time_in_forcewere silently never checked.test_sdk_client.pyassertions left over from the UAT endpoint migration (bc8e3c8) and the addition ofeu/za/auregions.UAT_ENDPOINTS["region_mapping"]["za"]incorrectly aliasing"au"'s sandbox hostnames verbatim (copy-paste bug from14e43f0), even though ZA and AU have distinct 2FA doc-link domains and separateRegionConfiginstances elsewhere in the same commit.Changes
guards.py: add quantity/notional/whitelist checks tovalidate_option_order,validate_option_strategy_order,validate_combo_order, andvalidate_algo_order; addvalidate_combo_legfor the actual per-leg calling convention; add_validate_cash_amountfor AMOUNT entrust_type orders.place_option_single_order,place_option_strategy_order,place_stock_combo_order,place_algo_order,place_crypto_order(AMOUNT branch was previously skipped), andplace_event_order(also addsorder_type/time_in_forceenum checks, previously missing).test_sdk_client.py: update hostname/region assertions to match currentUAT_ENDPOINTS; addeu/au/zacoverage plus a regression guard assertingzaandauendpoint blocks are distinct.sdk_client.py: fixzaUAT sandbox hostnames toza-api.uat.webullbroker.com/za-events-api.uat.webullbroker.com, matching the naming convention used by every other region.Test plan
pytestrun locally: 565 passed, 10 failed (all 10 pre-existing, reproduced identically onmainbefore this change — Windows/Python 3.12asyncioevent-loop and file-permission issues unrelated to this diff).test_guards.py, newtest_event_order_guards.py) and for the ZA/AU endpoint fix (test_sdk_client.py).