feat(longbridge-cli): add order rejection diagnosis reference + price adjustment

- 港股 9 档保护规则 (买入价不得高于卖1价 9档 / 低于买1价 24档)
- 长桥 CLI/SDK 不返回拒绝原因, 需查 App 或客服
- helper 新增 get_depth() + adjust_price_for_order()
- hk_intraday_cli.py 自动调整价格到合法范围
- 实测: 9988.HK 112.70 → 调整到 ask1 108.00 → 下单成功

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-07-09 18:25:13 +08:00
co-authored by Claude
parent 32d5d7dc0b
commit a437510a9b
3 changed files with 132 additions and 0 deletions
+29
View File
@@ -280,6 +280,35 @@ for ch in positions.channels:
For full API surface, see `references/api-reference.md`.
## Python SDK still works for read-only — for orders, use the CLI helper
As of 2026-07-09, `submit_order()` and `cancel_order()` from the Python SDK still hit 602315 even with the full three-piece recipe. The verified path is the **CLI** (one-off manual orders). For Python code that needs to actually place orders, use `scripts/longbridge_cli_helper.py` in the `longbridge-cli` skill — it provides SDK-shaped functions (`account_balance`, `stock_positions`, `submit_order`, `cancel_order`, `OrderType` / `OrderSide` / `TimeInForceType` enums) that internally shell out to the CLI binary. Pattern:
```python
# In any Python script that needs to trade:
import sys
sys.path.insert(0, '/home/openclaw/.hermes/scripts')
import longbridge_cli_helper as _helper
# Inject as fake 'longport' module so existing code can keep importing
fake = type(sys)('longport')
fake.openapi = _helper
sys.modules['longport'] = fake
sys.modules['longport.openapi'] = _helper
from longport import openapi # now openapi is the CLI-backed helper
# All SDK-shaped calls work and route to CLI:
ctx = openapi.QuoteContext(config=None) # Yahoo Finance fallback for quotes
bals = openapi.account_balance() # via longbridge balance
positions = openapi.stock_positions() # via longbridge positions
resp = openapi.submit_order( # via longbridge buy --profile lb_real
symbol="RGTI.US", order_type=openapi.OrderType.LO,
side=openapi.OrderSide.Buy, submitted_quantity=1, time_in_force=openapi.TimeInForceType.Day,
submitted_price=15.40,
)
```
This is the migration path for any cron script that used to call `trade_ctx.submit_order()` directly. **Read operations** (quote, candlesticks, balance, positions) still work fine through the Python SDK — keep them. Only the order placement needs the helper.
## Common Pitfalls
## Valuation Metrics (calc_indexes)