Skip to content

Commit 17decfc

Browse files
Pigbibiclaude
andcommitted
feat: add HK safe-haven symbols + lot-size rounding helper
- Add _HK_SAFE_HAVEN_SYMBOLS (02800 TraHK, 82800 RMB counter) - _symbol_role() now recognizes HK safe-haven symbols - Add _floor_lot_quantity() for HK board lot rounding Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6e28c2e commit 17decfc

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

application/execution_service.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,12 @@ def _floor_whole_share_quantity(quantity):
574574
return normalize_order_quantity(floor_to_quantity_step(quantity, 1.0))
575575

576576

577+
def _floor_lot_quantity(quantity, *, lot_size: int = 100):
578+
"""Floor to the nearest board lot for HK stocks."""
579+
step = float(max(1, int(lot_size)))
580+
return normalize_order_quantity(floor_to_quantity_step(float(quantity), step))
581+
582+
577583
def _normalize_trade_quantity(quantity):
578584
raw_quantity = max(0.0, float(quantity or 0.0))
579585
if raw_quantity <= 0.0:

decision_mapper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
from strategy_registry import LONGBRIDGE_PLATFORM, resolve_strategy_definition
1818

1919
_SAFE_HAVEN_SYMBOLS = frozenset({"BOXX", "BIL"})
20+
_HK_SAFE_HAVEN_SYMBOLS = frozenset({"02800", "82800"}) # TraHK (HKD + RMB counters)
2021
_INCOME_SYMBOLS = frozenset({"QQQI", "SPYI"})
2122
_DEFAULT_MIN_TRADE_FLOOR = 100.0
23+
_DEFAULT_HK_LOT_SIZE = 100 # most HK stocks trade in lots of 100 shares
2224
_DEFAULT_REBALANCE_THRESHOLD_RATIO = 0.01
2325
_SNAPSHOT_DIAGNOSTIC_FIELDS = (
2426
"snapshot_manifest_price_as_of",
@@ -190,7 +192,7 @@ def _cash_by_currency_from_snapshot(snapshot: Any | None) -> dict[str, float]:
190192

191193
def _symbol_role(symbol: str) -> str | None:
192194
normalized = str(symbol or "").strip().upper()
193-
if normalized in _SAFE_HAVEN_SYMBOLS:
195+
if normalized in _SAFE_HAVEN_SYMBOLS or normalized in _HK_SAFE_HAVEN_SYMBOLS:
194196
return "safe_haven"
195197
if normalized in _INCOME_SYMBOLS:
196198
return "income"

0 commit comments

Comments
 (0)