Skip to content

fix(grid): resolve orders missing from open orders on verify - #407

Closed
Mystery01092000 wants to merge 1 commit into
OpenByteInc:mainfrom
Mystery01092000:fix/grid-reconcile-canceled-orders
Closed

Mystery01092000 wants to merge 1 commit into
OpenByteInc:mainfrom
Mystery01092000:fix/grid-reconcile-canceled-orders

Conversation

@Mystery01092000

Copy link
Copy Markdown
Contributor

Summary

When the user clicks verify on the grid resting-orders panel, the frontend calls GET /api/strategies/grid-resting-orders?sync=1. That route runs audit_grid_orders, which only fetched the exchange's open-orders snapshot. Any local open order missing from that snapshot was labelled not_open ("未在当前挂单中"), and nothing else happened. The audit never asked the exchange what became of the order, and it never touched the local row. So an order cancelled on Binance stayed open in qd_grid_resting_orders and came back as not_open on every verify, as reported in #404.

The worker's GridFillPoller does query each order, but only for strategies whose runner is registered in that process (_select_orders skips orders without get_runner(sid)). Orders left behind by a stopped, handed-off or restarted bot are never polled. The UI has no delete action for these rows either. The default listing only shows pending/open/partial rows, so the only way to clear one is to move it to a terminal status.

This PR changes the audit so an order missing from open orders gets a per-order status lookup. For Binance USDT-M that is GET /fapi/v1/order, through the existing exchange-aware query_grid_order_fill. The audit reports the real terminal state. A cancel confirmed by the exchange, on an order that never filled, is then applied to the local row.

Related issue

Changes

  • app/services/grid/order_audit.py
    • New _reconcile_missing_order: for a row with an exchange_order_id that is absent from the open-orders snapshot, it calls query_grid_order_fill and reports cancelled / filled / open / partial. If the lookup returns unknown, the result stays not_open.
    • The local row is changed only when all of these hold: the exchange reports cancelled, the exchange-reported filled quantity is 0, the local filled_quantity and processed_fill_qty are 0, and the local status is open. This mirrors the engine's existing _cancel_confirmed_order rule. Orders with fills, including partially filled then cancelled or expired orders, are only reported. Posting their fills to the strategy ledger is still the fill poller's job.
    • Terminal orders count in a new terminal counter and no longer in unknown, so a verify that resolves every order no longer returns grid_exchange_orders_unverified.
  • app/services/grid/resting_orders_repo.py
    • New mark_cancelled_if_unfilled(order_id, exchange_order_id). It is one guarded UPDATE ... WHERE status = 'open' AND exchange_order_id = %s AND filled_quantity = 0 AND processed_fill_qty = 0, so it does nothing if a fill poller or private stream updated the row first.
  • app/routes/strategy_grid_routes.py
    • The summary has a new additive field, exchange_terminal_orders. The row's status in the response already reflects the reconciled value, so the user sees cancelled right away, and the row drops out of the default (open) list on the next refresh.
  • tests/test_grid_order_audit.py: 8 new tests that use a stubbed BinanceFuturesClient (MagicMock(spec=...)) returning GET /fapi/v1/order payloads:
    • CANCELED with no fill: the row is marked cancelled, the audit reports it as terminal and no error is returned (the 网格策略订单在币安已取消,但 QuantDinger 界面仍显示“未在当前挂单中”且无法删除 #404 regression).
    • CANCELED or EXPIRED with executedQty > 0, and FILLED: the status is reported and no ledger write happens.
    • The order lookup fails: the result stays not_open, nothing is written and the error stays grid_exchange_orders_unverified.
    • The guarded update loses a race: no local cancel is reported.
    • The route returns the reconciled status and exchange_terminal_orders.
    • Repository SQL guards.

Behavior notes

  • No schema, migration or route change. The only API change is the additive summary field. The verify request now makes one extra signed GET per order that is missing from open orders. It does not place or cancel any order.
  • Binance does not return orders that are CANCELED/EXPIRED, had no fill, and were created more than 3 days ago. This applies to GET /fapi/v1/order and GET /fapi/v1/allOrders alike, so allOrders would not help with these either. If the reported orders are that old, the lookup returns "order does not exist" and the row stays not_open. I deliberately did not treat "not found" as "cancelled": a changed API key or account could produce the same response for orders that are still live. If maintainers want that case covered, a follow-up could treat Binance error -2013 plus absence from open orders as a zero-fill cancel.
  • Frontend: no change is required for the fix. The frontend repo could show the new exchange_terminal_orders count and the cancelled/filled values of exchange_status, which before this change were only open/partial/not_open/unverified.

Test plan

  • Tested locally with docker compose up -d --build: not done. Reproducing this needs a live Binance futures account with cancelled grid orders, so I verified with stubbed exchange clients instead.
  • Relevant pytest tests pass in Docker (python:3.12, dependencies installed as in basic-ci.yml):
    • tests/test_grid_order_audit.py: 18 passed. On the base commit, 7 of the 8 new tests fail. The 8th (lookup failure keeps not_open) passes on both, as intended.
    • tests/test_grid_*.py tests/test_exchange_cancel_audit.py: 383 passed.
    • Full suite -m "not integration and not stress" without Postgres: 5473 passed, 87 skipped, 26 deselected, 0 failed (Postgres-backed tests skip without QD_TEST_POSTGRES_DSN).
  • ruff check app scripts tests (ruff 0.16.10), py_compile run.py, compileall, scripts/backend_quality_check.py and scripts/check_docs.py pass.

API documentation (if routes/schemas changed)

  • Regenerated docs/api/openapi.yaml: not needed. The route's response schema is the generic HumanSuccessEnvelope, and the change only adds a summary field.
  • Updated docs/agent/agent-openapi.json: not needed, no /api/agent/v1 change.
  • Breaking API changes: none.

Screenshots (if UI change)

Backend only.

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes OpenByteInc#404
@sonarqubecloud

Copy link
Copy Markdown

brokermr810 pushed a commit that referenced this pull request Nov 25, 2026
Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>
brokermr810 added a commit that referenced this pull request Nov 25, 2026
* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
brokermr810 added a commit that referenced this pull request Nov 25, 2026
* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): prevent rebalance replay after worker restart

Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
brokermr810 added a commit that referenced this pull request Nov 27, 2026
…ings (#411)

* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): prevent rebalance replay after worker restart

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): warm NumPy modules before applying isolation

Signed-off-by: TIANHE <[email protected]>

* feat(platform): add Forthright integration and advertisement settings

Add scoped broker access, HK board-lot metadata, dated-futures manual trading, and credential redaction. Keep automated futures strategies disabled. Persist advertisement settings and generate their OpenAPI contract.

Signed-off-by: TIANHE <[email protected]>

* fix(ci): declare Forthright API tags and escape encoding fixtures

Signed-off-by: TIANHE <[email protected]>

* fix(security): bound public inputs and document broker signature risks

Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
brokermr810 added a commit that referenced this pull request Nov 27, 2026
…ory (#413)

* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): prevent rebalance replay after worker restart

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): warm NumPy modules before applying isolation

Signed-off-by: TIANHE <[email protected]>

* feat(platform): add Forthright integration and advertisement settings

Add scoped broker access, HK board-lot metadata, dated-futures manual trading, and credential redaction. Keep automated futures strategies disabled. Persist advertisement settings and generate their OpenAPI contract.

Signed-off-by: TIANHE <[email protected]>

* fix(ci): declare Forthright API tags and escape encoding fixtures

Signed-off-by: TIANHE <[email protected]>

* fix(security): bound public inputs and document broker signature risks

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): preserve equity identity and reconcile account fills

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): normalize HK-prefixed securities and deduplicate search

Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
brokermr810 added a commit that referenced this pull request Nov 27, 2026
…overy (#414)

* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): prevent rebalance replay after worker restart

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): warm NumPy modules before applying isolation

Signed-off-by: TIANHE <[email protected]>

* feat(platform): add Forthright integration and advertisement settings

Add scoped broker access, HK board-lot metadata, dated-futures manual trading, and credential redaction. Keep automated futures strategies disabled. Persist advertisement settings and generate their OpenAPI contract.

Signed-off-by: TIANHE <[email protected]>

* fix(ci): declare Forthright API tags and escape encoding fixtures

Signed-off-by: TIANHE <[email protected]>

* fix(security): bound public inputs and document broker signature risks

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): preserve equity identity and reconcile account fills

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): normalize HK-prefixed securities and deduplicate search

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): reconcile delayed Forthright execution fees

Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
brokermr810 added a commit that referenced this pull request Nov 27, 2026
#415)

* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): prevent rebalance replay after worker restart

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): warm NumPy modules before applying isolation

Signed-off-by: TIANHE <[email protected]>

* feat(platform): add Forthright integration and advertisement settings

Add scoped broker access, HK board-lot metadata, dated-futures manual trading, and credential redaction. Keep automated futures strategies disabled. Persist advertisement settings and generate their OpenAPI contract.

Signed-off-by: TIANHE <[email protected]>

* fix(ci): declare Forthright API tags and escape encoding fixtures

Signed-off-by: TIANHE <[email protected]>

* fix(security): bound public inputs and document broker signature risks

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): preserve equity identity and reconcile account fills

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): normalize HK-prefixed securities and deduplicate search

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): reconcile delayed Forthright execution fees

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): unify HK pool and position identities

Signed-off-by: TIANHE <[email protected]>

* perf(strategy): vectorize causal Bollinger series

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): improve equity warmup caching and quote diagnostics

Keep completed-session and execution-price freshness checks intact, allow eligible newly listed equities to satisfy declared warmup, and fail over HK candle providers with bounded Tencent cooldown.

Validation: 382 focused Linux regression tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
brokermr810 added a commit that referenced this pull request Nov 27, 2026
* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): prevent rebalance replay after worker restart

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): warm NumPy modules before applying isolation

Signed-off-by: TIANHE <[email protected]>

* feat(platform): add Forthright integration and advertisement settings

Add scoped broker access, HK board-lot metadata, dated-futures manual trading, and credential redaction. Keep automated futures strategies disabled. Persist advertisement settings and generate their OpenAPI contract.

Signed-off-by: TIANHE <[email protected]>

* fix(ci): declare Forthright API tags and escape encoding fixtures

Signed-off-by: TIANHE <[email protected]>

* fix(security): bound public inputs and document broker signature risks

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): preserve equity identity and reconcile account fills

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): normalize HK-prefixed securities and deduplicate search

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): reconcile delayed Forthright execution fees

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): unify HK pool and position identities

Signed-off-by: TIANHE <[email protected]>

* perf(strategy): vectorize causal Bollinger series

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): improve equity warmup caching and quote diagnostics

Keep completed-session and execution-price freshness checks intact, allow eligible newly listed equities to satisfy declared warmup, and fail over HK candle providers with bounded Tencent cooldown.

Validation: 382 focused Linux regression tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* feat(trading): configure equity execution quote freshness

Expose a restart-scoped 1-60 minute quote-age setting with a 16-minute default, align equity receipt expiry, retain provider timestamp and session checks, and document delayed-feed risks.

Validation: 215 focused backend tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* test(settings): align curated equity quote policy contract

Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
brokermr810 added a commit that referenced this pull request Nov 27, 2026
)

* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): prevent rebalance replay after worker restart

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): warm NumPy modules before applying isolation

Signed-off-by: TIANHE <[email protected]>

* feat(platform): add Forthright integration and advertisement settings

Add scoped broker access, HK board-lot metadata, dated-futures manual trading, and credential redaction. Keep automated futures strategies disabled. Persist advertisement settings and generate their OpenAPI contract.

Signed-off-by: TIANHE <[email protected]>

* fix(ci): declare Forthright API tags and escape encoding fixtures

Signed-off-by: TIANHE <[email protected]>

* fix(security): bound public inputs and document broker signature risks

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): preserve equity identity and reconcile account fills

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): normalize HK-prefixed securities and deduplicate search

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): reconcile delayed Forthright execution fees

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): unify HK pool and position identities

Signed-off-by: TIANHE <[email protected]>

* perf(strategy): vectorize causal Bollinger series

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): improve equity warmup caching and quote diagnostics

Keep completed-session and execution-price freshness checks intact, allow eligible newly listed equities to satisfy declared warmup, and fail over HK candle providers with bounded Tencent cooldown.

Validation: 382 focused Linux regression tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* feat(trading): configure equity execution quote freshness

Expose a restart-scoped 1-60 minute quote-age setting with a 16-minute default, align equity receipt expiry, retain provider timestamp and session checks, and document delayed-feed risks.

Validation: 215 focused backend tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* test(settings): align curated equity quote policy contract

Signed-off-by: TIANHE <[email protected]>

* fix(trading): coordinate exchange REST limits and startup recovery

Signed-off-by: TIANHE <[email protected]>

* fix(ci): align readiness tests and harden exchange guard identifiers

Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
brokermr810 added a commit that referenced this pull request Nov 27, 2026
* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): prevent rebalance replay after worker restart

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): warm NumPy modules before applying isolation

Signed-off-by: TIANHE <[email protected]>

* feat(platform): add Forthright integration and advertisement settings

Add scoped broker access, HK board-lot metadata, dated-futures manual trading, and credential redaction. Keep automated futures strategies disabled. Persist advertisement settings and generate their OpenAPI contract.

Signed-off-by: TIANHE <[email protected]>

* fix(ci): declare Forthright API tags and escape encoding fixtures

Signed-off-by: TIANHE <[email protected]>

* fix(security): bound public inputs and document broker signature risks

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): preserve equity identity and reconcile account fills

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): normalize HK-prefixed securities and deduplicate search

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): reconcile delayed Forthright execution fees

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): unify HK pool and position identities

Signed-off-by: TIANHE <[email protected]>

* perf(strategy): vectorize causal Bollinger series

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): improve equity warmup caching and quote diagnostics

Keep completed-session and execution-price freshness checks intact, allow eligible newly listed equities to satisfy declared warmup, and fail over HK candle providers with bounded Tencent cooldown.

Validation: 382 focused Linux regression tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* feat(trading): configure equity execution quote freshness

Expose a restart-scoped 1-60 minute quote-age setting with a 16-minute default, align equity receipt expiry, retain provider timestamp and session checks, and document delayed-feed risks.

Validation: 215 focused backend tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* test(settings): align curated equity quote policy contract

Signed-off-by: TIANHE <[email protected]>

* fix(trading): coordinate exchange REST limits and startup recovery

Signed-off-by: TIANHE <[email protected]>

* fix(ci): align readiness tests and harden exchange guard identifiers

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): recover strategies after exchange cooldowns

Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
brokermr810 added a commit that referenced this pull request Nov 28, 2026
* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): prevent rebalance replay after worker restart

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): warm NumPy modules before applying isolation

Signed-off-by: TIANHE <[email protected]>

* feat(platform): add Forthright integration and advertisement settings

Add scoped broker access, HK board-lot metadata, dated-futures manual trading, and credential redaction. Keep automated futures strategies disabled. Persist advertisement settings and generate their OpenAPI contract.

Signed-off-by: TIANHE <[email protected]>

* fix(ci): declare Forthright API tags and escape encoding fixtures

Signed-off-by: TIANHE <[email protected]>

* fix(security): bound public inputs and document broker signature risks

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): preserve equity identity and reconcile account fills

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): normalize HK-prefixed securities and deduplicate search

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): reconcile delayed Forthright execution fees

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): unify HK pool and position identities

Signed-off-by: TIANHE <[email protected]>

* perf(strategy): vectorize causal Bollinger series

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): improve equity warmup caching and quote diagnostics

Keep completed-session and execution-price freshness checks intact, allow eligible newly listed equities to satisfy declared warmup, and fail over HK candle providers with bounded Tencent cooldown.

Validation: 382 focused Linux regression tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* feat(trading): configure equity execution quote freshness

Expose a restart-scoped 1-60 minute quote-age setting with a 16-minute default, align equity receipt expiry, retain provider timestamp and session checks, and document delayed-feed risks.

Validation: 215 focused backend tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* test(settings): align curated equity quote policy contract

Signed-off-by: TIANHE <[email protected]>

* fix(trading): coordinate exchange REST limits and startup recovery

Signed-off-by: TIANHE <[email protected]>

* fix(ci): align readiness tests and harden exchange guard identifiers

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): recover strategies after exchange cooldowns

Signed-off-by: TIANHE <[email protected]>

* fix(ws): use Binance USD-M /market stream path for swap feeds

Signed-off-by: Prakash Jha <[email protected]>
(cherry picked from commit a5c7b82)
Signed-off-by: TIANHE <[email protected]>

* fix(ws): migrate Binance futures private stream routing

Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Signed-off-by: Prakash Jha <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
Co-authored-by: Prakash Jha <[email protected]>
brokermr810 added a commit that referenced this pull request Nov 28, 2026
* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): prevent rebalance replay after worker restart

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): warm NumPy modules before applying isolation

Signed-off-by: TIANHE <[email protected]>

* feat(platform): add Forthright integration and advertisement settings

Add scoped broker access, HK board-lot metadata, dated-futures manual trading, and credential redaction. Keep automated futures strategies disabled. Persist advertisement settings and generate their OpenAPI contract.

Signed-off-by: TIANHE <[email protected]>

* fix(ci): declare Forthright API tags and escape encoding fixtures

Signed-off-by: TIANHE <[email protected]>

* fix(security): bound public inputs and document broker signature risks

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): preserve equity identity and reconcile account fills

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): normalize HK-prefixed securities and deduplicate search

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): reconcile delayed Forthright execution fees

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): unify HK pool and position identities

Signed-off-by: TIANHE <[email protected]>

* perf(strategy): vectorize causal Bollinger series

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): improve equity warmup caching and quote diagnostics

Keep completed-session and execution-price freshness checks intact, allow eligible newly listed equities to satisfy declared warmup, and fail over HK candle providers with bounded Tencent cooldown.

Validation: 382 focused Linux regression tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* feat(trading): configure equity execution quote freshness

Expose a restart-scoped 1-60 minute quote-age setting with a 16-minute default, align equity receipt expiry, retain provider timestamp and session checks, and document delayed-feed risks.

Validation: 215 focused backend tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* test(settings): align curated equity quote policy contract

Signed-off-by: TIANHE <[email protected]>

* fix(trading): coordinate exchange REST limits and startup recovery

Signed-off-by: TIANHE <[email protected]>

* fix(ci): align readiness tests and harden exchange guard identifiers

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): recover strategies after exchange cooldowns

Signed-off-by: TIANHE <[email protected]>

* fix(ws): use Binance USD-M /market stream path for swap feeds

Signed-off-by: Prakash Jha <[email protected]>
(cherry picked from commit a5c7b82)
Signed-off-by: TIANHE <[email protected]>

* fix(ws): migrate Binance futures private stream routing

Signed-off-by: TIANHE <[email protected]>

* fix(streams): recover subscriptions and validate live feed readiness

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reject unsafe sizing and invalid broker order values

Signed-off-by: TIANHE <[email protected]>

* fix(security): return fixed order validation error identifiers

Signed-off-by: TIANHE <[email protected]>

* chore: exclude local design and visual QA artifacts

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): reject non-finite order sizing and arithmetic overflow

Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Signed-off-by: Prakash Jha <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
Co-authored-by: Prakash Jha <[email protected]>
brokermr810 added a commit that referenced this pull request Nov 29, 2026
…ion (#430)

* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): prevent rebalance replay after worker restart

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): warm NumPy modules before applying isolation

Signed-off-by: TIANHE <[email protected]>

* feat(platform): add Forthright integration and advertisement settings

Add scoped broker access, HK board-lot metadata, dated-futures manual trading, and credential redaction. Keep automated futures strategies disabled. Persist advertisement settings and generate their OpenAPI contract.

Signed-off-by: TIANHE <[email protected]>

* fix(ci): declare Forthright API tags and escape encoding fixtures

Signed-off-by: TIANHE <[email protected]>

* fix(security): bound public inputs and document broker signature risks

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): preserve equity identity and reconcile account fills

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): normalize HK-prefixed securities and deduplicate search

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): reconcile delayed Forthright execution fees

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): unify HK pool and position identities

Signed-off-by: TIANHE <[email protected]>

* perf(strategy): vectorize causal Bollinger series

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): improve equity warmup caching and quote diagnostics

Keep completed-session and execution-price freshness checks intact, allow eligible newly listed equities to satisfy declared warmup, and fail over HK candle providers with bounded Tencent cooldown.

Validation: 382 focused Linux regression tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* feat(trading): configure equity execution quote freshness

Expose a restart-scoped 1-60 minute quote-age setting with a 16-minute default, align equity receipt expiry, retain provider timestamp and session checks, and document delayed-feed risks.

Validation: 215 focused backend tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* test(settings): align curated equity quote policy contract

Signed-off-by: TIANHE <[email protected]>

* fix(trading): coordinate exchange REST limits and startup recovery

Signed-off-by: TIANHE <[email protected]>

* fix(ci): align readiness tests and harden exchange guard identifiers

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): recover strategies after exchange cooldowns

Signed-off-by: TIANHE <[email protected]>

* fix(ws): use Binance USD-M /market stream path for swap feeds

Signed-off-by: Prakash Jha <[email protected]>
(cherry picked from commit a5c7b82)
Signed-off-by: TIANHE <[email protected]>

* fix(ws): migrate Binance futures private stream routing

Signed-off-by: TIANHE <[email protected]>

* fix(streams): recover subscriptions and validate live feed readiness

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reject unsafe sizing and invalid broker order values

Signed-off-by: TIANHE <[email protected]>

* fix(security): return fixed order validation error identifiers

Signed-off-by: TIANHE <[email protected]>

* chore: exclude local design and visual QA artifacts

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): reject non-finite order sizing and arithmetic overflow

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): support native trailing stop protection

(cherry picked from commit 76ea213)
Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce and reconcile attached protection across order paths

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): retire protection waits for rejected entries

Signed-off-by: TIANHE <[email protected]>

* fix(trading): verify bracket children and preserve concurrent metadata

Signed-off-by: TIANHE <[email protected]>

* fix(security): return public protection validation codes

Signed-off-by: TIANHE <[email protected]>

* feat(trading): extend native protection and verify broker child orders

Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Signed-off-by: Prakash Jha <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
Co-authored-by: Prakash Jha <[email protected]>
Co-authored-by: Pranav <[email protected]>
brokermr810 added a commit that referenced this pull request Nov 30, 2026
…es (#432)

* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): prevent rebalance replay after worker restart

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): warm NumPy modules before applying isolation

Signed-off-by: TIANHE <[email protected]>

* feat(platform): add Forthright integration and advertisement settings

Add scoped broker access, HK board-lot metadata, dated-futures manual trading, and credential redaction. Keep automated futures strategies disabled. Persist advertisement settings and generate their OpenAPI contract.

Signed-off-by: TIANHE <[email protected]>

* fix(ci): declare Forthright API tags and escape encoding fixtures

Signed-off-by: TIANHE <[email protected]>

* fix(security): bound public inputs and document broker signature risks

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): preserve equity identity and reconcile account fills

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): normalize HK-prefixed securities and deduplicate search

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): reconcile delayed Forthright execution fees

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): unify HK pool and position identities

Signed-off-by: TIANHE <[email protected]>

* perf(strategy): vectorize causal Bollinger series

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): improve equity warmup caching and quote diagnostics

Keep completed-session and execution-price freshness checks intact, allow eligible newly listed equities to satisfy declared warmup, and fail over HK candle providers with bounded Tencent cooldown.

Validation: 382 focused Linux regression tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* feat(trading): configure equity execution quote freshness

Expose a restart-scoped 1-60 minute quote-age setting with a 16-minute default, align equity receipt expiry, retain provider timestamp and session checks, and document delayed-feed risks.

Validation: 215 focused backend tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* test(settings): align curated equity quote policy contract

Signed-off-by: TIANHE <[email protected]>

* fix(trading): coordinate exchange REST limits and startup recovery

Signed-off-by: TIANHE <[email protected]>

* fix(ci): align readiness tests and harden exchange guard identifiers

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): recover strategies after exchange cooldowns

Signed-off-by: TIANHE <[email protected]>

* fix(ws): use Binance USD-M /market stream path for swap feeds

Signed-off-by: Prakash Jha <[email protected]>
(cherry picked from commit a5c7b82)
Signed-off-by: TIANHE <[email protected]>

* fix(ws): migrate Binance futures private stream routing

Signed-off-by: TIANHE <[email protected]>

* fix(streams): recover subscriptions and validate live feed readiness

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reject unsafe sizing and invalid broker order values

Signed-off-by: TIANHE <[email protected]>

* fix(security): return fixed order validation error identifiers

Signed-off-by: TIANHE <[email protected]>

* chore: exclude local design and visual QA artifacts

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): reject non-finite order sizing and arithmetic overflow

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): support native trailing stop protection

(cherry picked from commit 76ea213)
Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce and reconcile attached protection across order paths

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): retire protection waits for rejected entries

Signed-off-by: TIANHE <[email protected]>

* fix(trading): verify bracket children and preserve concurrent metadata

Signed-off-by: TIANHE <[email protected]>

* fix(security): return public protection validation codes

Signed-off-by: TIANHE <[email protected]>

* feat(trading): extend native protection and verify broker child orders

Signed-off-by: TIANHE <[email protected]>

* fix(market-data): batch HK quotes and preserve Tencent timestamps

Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Signed-off-by: Prakash Jha <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
Co-authored-by: Prakash Jha <[email protected]>
Co-authored-by: Pranav <[email protected]>
brokermr810 added a commit that referenced this pull request Nov 30, 2026
* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): prevent rebalance replay after worker restart

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): warm NumPy modules before applying isolation

Signed-off-by: TIANHE <[email protected]>

* feat(platform): add Forthright integration and advertisement settings

Add scoped broker access, HK board-lot metadata, dated-futures manual trading, and credential redaction. Keep automated futures strategies disabled. Persist advertisement settings and generate their OpenAPI contract.

Signed-off-by: TIANHE <[email protected]>

* fix(ci): declare Forthright API tags and escape encoding fixtures

Signed-off-by: TIANHE <[email protected]>

* fix(security): bound public inputs and document broker signature risks

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): preserve equity identity and reconcile account fills

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): normalize HK-prefixed securities and deduplicate search

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): reconcile delayed Forthright execution fees

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): unify HK pool and position identities

Signed-off-by: TIANHE <[email protected]>

* perf(strategy): vectorize causal Bollinger series

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): improve equity warmup caching and quote diagnostics

Keep completed-session and execution-price freshness checks intact, allow eligible newly listed equities to satisfy declared warmup, and fail over HK candle providers with bounded Tencent cooldown.

Validation: 382 focused Linux regression tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* feat(trading): configure equity execution quote freshness

Expose a restart-scoped 1-60 minute quote-age setting with a 16-minute default, align equity receipt expiry, retain provider timestamp and session checks, and document delayed-feed risks.

Validation: 215 focused backend tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* test(settings): align curated equity quote policy contract

Signed-off-by: TIANHE <[email protected]>

* fix(trading): coordinate exchange REST limits and startup recovery

Signed-off-by: TIANHE <[email protected]>

* fix(ci): align readiness tests and harden exchange guard identifiers

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): recover strategies after exchange cooldowns

Signed-off-by: TIANHE <[email protected]>

* fix(ws): use Binance USD-M /market stream path for swap feeds

Signed-off-by: Prakash Jha <[email protected]>
(cherry picked from commit a5c7b82)
Signed-off-by: TIANHE <[email protected]>

* fix(ws): migrate Binance futures private stream routing

Signed-off-by: TIANHE <[email protected]>

* fix(streams): recover subscriptions and validate live feed readiness

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reject unsafe sizing and invalid broker order values

Signed-off-by: TIANHE <[email protected]>

* fix(security): return fixed order validation error identifiers

Signed-off-by: TIANHE <[email protected]>

* chore: exclude local design and visual QA artifacts

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): reject non-finite order sizing and arithmetic overflow

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): support native trailing stop protection

(cherry picked from commit 76ea213)
Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce and reconcile attached protection across order paths

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): retire protection waits for rejected entries

Signed-off-by: TIANHE <[email protected]>

* fix(trading): verify bracket children and preserve concurrent metadata

Signed-off-by: TIANHE <[email protected]>

* fix(security): return public protection validation codes

Signed-off-by: TIANHE <[email protected]>

* feat(trading): extend native protection and verify broker child orders

Signed-off-by: TIANHE <[email protected]>

* fix(market-data): batch HK quotes and preserve Tencent timestamps

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): skip unavailable quotes in daily equity orders

Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Signed-off-by: Prakash Jha <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
Co-authored-by: Prakash Jha <[email protected]>
Co-authored-by: Pranav <[email protected]>
brokermr810 added a commit that referenced this pull request Nov 30, 2026
#434)

* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): prevent rebalance replay after worker restart

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): warm NumPy modules before applying isolation

Signed-off-by: TIANHE <[email protected]>

* feat(platform): add Forthright integration and advertisement settings

Add scoped broker access, HK board-lot metadata, dated-futures manual trading, and credential redaction. Keep automated futures strategies disabled. Persist advertisement settings and generate their OpenAPI contract.

Signed-off-by: TIANHE <[email protected]>

* fix(ci): declare Forthright API tags and escape encoding fixtures

Signed-off-by: TIANHE <[email protected]>

* fix(security): bound public inputs and document broker signature risks

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): preserve equity identity and reconcile account fills

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): normalize HK-prefixed securities and deduplicate search

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): reconcile delayed Forthright execution fees

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): unify HK pool and position identities

Signed-off-by: TIANHE <[email protected]>

* perf(strategy): vectorize causal Bollinger series

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): improve equity warmup caching and quote diagnostics

Keep completed-session and execution-price freshness checks intact, allow eligible newly listed equities to satisfy declared warmup, and fail over HK candle providers with bounded Tencent cooldown.

Validation: 382 focused Linux regression tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* feat(trading): configure equity execution quote freshness

Expose a restart-scoped 1-60 minute quote-age setting with a 16-minute default, align equity receipt expiry, retain provider timestamp and session checks, and document delayed-feed risks.

Validation: 215 focused backend tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* test(settings): align curated equity quote policy contract

Signed-off-by: TIANHE <[email protected]>

* fix(trading): coordinate exchange REST limits and startup recovery

Signed-off-by: TIANHE <[email protected]>

* fix(ci): align readiness tests and harden exchange guard identifiers

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): recover strategies after exchange cooldowns

Signed-off-by: TIANHE <[email protected]>

* fix(ws): use Binance USD-M /market stream path for swap feeds

Signed-off-by: Prakash Jha <[email protected]>
(cherry picked from commit a5c7b82)
Signed-off-by: TIANHE <[email protected]>

* fix(ws): migrate Binance futures private stream routing

Signed-off-by: TIANHE <[email protected]>

* fix(streams): recover subscriptions and validate live feed readiness

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reject unsafe sizing and invalid broker order values

Signed-off-by: TIANHE <[email protected]>

* fix(security): return fixed order validation error identifiers

Signed-off-by: TIANHE <[email protected]>

* chore: exclude local design and visual QA artifacts

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): reject non-finite order sizing and arithmetic overflow

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): support native trailing stop protection

(cherry picked from commit 76ea213)
Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce and reconcile attached protection across order paths

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): retire protection waits for rejected entries

Signed-off-by: TIANHE <[email protected]>

* fix(trading): verify bracket children and preserve concurrent metadata

Signed-off-by: TIANHE <[email protected]>

* fix(security): return public protection validation codes

Signed-off-by: TIANHE <[email protected]>

* feat(trading): extend native protection and verify broker child orders

Signed-off-by: TIANHE <[email protected]>

* fix(market-data): batch HK quotes and preserve Tencent timestamps

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): skip unavailable quotes in daily equity orders

Signed-off-by: TIANHE <[email protected]>

* fix(equities): harden lot sizing, catalog sync and quote diagnostics

Signed-off-by: TIANHE <[email protected]>

* feat(universes): add HK sector and crypto selection pools

Signed-off-by: TIANHE <[email protected]>

* fix(ci): extract broker diagnostics and align quote health tests

Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Signed-off-by: Prakash Jha <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
Co-authored-by: Prakash Jha <[email protected]>
Co-authored-by: Pranav <[email protected]>
brokermr810 added a commit that referenced this pull request Nov 30, 2026
…#435)

* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): prevent rebalance replay after worker restart

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): warm NumPy modules before applying isolation

Signed-off-by: TIANHE <[email protected]>

* feat(platform): add Forthright integration and advertisement settings

Add scoped broker access, HK board-lot metadata, dated-futures manual trading, and credential redaction. Keep automated futures strategies disabled. Persist advertisement settings and generate their OpenAPI contract.

Signed-off-by: TIANHE <[email protected]>

* fix(ci): declare Forthright API tags and escape encoding fixtures

Signed-off-by: TIANHE <[email protected]>

* fix(security): bound public inputs and document broker signature risks

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): preserve equity identity and reconcile account fills

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): normalize HK-prefixed securities and deduplicate search

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): reconcile delayed Forthright execution fees

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): unify HK pool and position identities

Signed-off-by: TIANHE <[email protected]>

* perf(strategy): vectorize causal Bollinger series

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): improve equity warmup caching and quote diagnostics

Keep completed-session and execution-price freshness checks intact, allow eligible newly listed equities to satisfy declared warmup, and fail over HK candle providers with bounded Tencent cooldown.

Validation: 382 focused Linux regression tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* feat(trading): configure equity execution quote freshness

Expose a restart-scoped 1-60 minute quote-age setting with a 16-minute default, align equity receipt expiry, retain provider timestamp and session checks, and document delayed-feed risks.

Validation: 215 focused backend tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* test(settings): align curated equity quote policy contract

Signed-off-by: TIANHE <[email protected]>

* fix(trading): coordinate exchange REST limits and startup recovery

Signed-off-by: TIANHE <[email protected]>

* fix(ci): align readiness tests and harden exchange guard identifiers

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): recover strategies after exchange cooldowns

Signed-off-by: TIANHE <[email protected]>

* fix(ws): use Binance USD-M /market stream path for swap feeds

Signed-off-by: Prakash Jha <[email protected]>
(cherry picked from commit a5c7b82)
Signed-off-by: TIANHE <[email protected]>

* fix(ws): migrate Binance futures private stream routing

Signed-off-by: TIANHE <[email protected]>

* fix(streams): recover subscriptions and validate live feed readiness

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reject unsafe sizing and invalid broker order values

Signed-off-by: TIANHE <[email protected]>

* fix(security): return fixed order validation error identifiers

Signed-off-by: TIANHE <[email protected]>

* chore: exclude local design and visual QA artifacts

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): reject non-finite order sizing and arithmetic overflow

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): support native trailing stop protection

(cherry picked from commit 76ea213)
Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce and reconcile attached protection across order paths

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): retire protection waits for rejected entries

Signed-off-by: TIANHE <[email protected]>

* fix(trading): verify bracket children and preserve concurrent metadata

Signed-off-by: TIANHE <[email protected]>

* fix(security): return public protection validation codes

Signed-off-by: TIANHE <[email protected]>

* feat(trading): extend native protection and verify broker child orders

Signed-off-by: TIANHE <[email protected]>

* fix(market-data): batch HK quotes and preserve Tencent timestamps

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): skip unavailable quotes in daily equity orders

Signed-off-by: TIANHE <[email protected]>

* fix(equities): harden lot sizing, catalog sync and quote diagnostics

Signed-off-by: TIANHE <[email protected]>

* feat(universes): add HK sector and crypto selection pools

Signed-off-by: TIANHE <[email protected]>

* fix(ci): extract broker diagnostics and align quote health tests

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): reconcile live positions and preserve account settings

Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Signed-off-by: Prakash Jha <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
Co-authored-by: Prakash Jha <[email protected]>
Co-authored-by: Pranav <[email protected]>
brokermr810 added a commit that referenced this pull request Dec 3, 2026
…zed asset names (#436)

* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): prevent rebalance replay after worker restart

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): warm NumPy modules before applying isolation

Signed-off-by: TIANHE <[email protected]>

* feat(platform): add Forthright integration and advertisement settings

Add scoped broker access, HK board-lot metadata, dated-futures manual trading, and credential redaction. Keep automated futures strategies disabled. Persist advertisement settings and generate their OpenAPI contract.

Signed-off-by: TIANHE <[email protected]>

* fix(ci): declare Forthright API tags and escape encoding fixtures

Signed-off-by: TIANHE <[email protected]>

* fix(security): bound public inputs and document broker signature risks

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): preserve equity identity and reconcile account fills

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): normalize HK-prefixed securities and deduplicate search

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): reconcile delayed Forthright execution fees

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): unify HK pool and position identities

Signed-off-by: TIANHE <[email protected]>

* perf(strategy): vectorize causal Bollinger series

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): improve equity warmup caching and quote diagnostics

Keep completed-session and execution-price freshness checks intact, allow eligible newly listed equities to satisfy declared warmup, and fail over HK candle providers with bounded Tencent cooldown.

Validation: 382 focused Linux regression tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* feat(trading): configure equity execution quote freshness

Expose a restart-scoped 1-60 minute quote-age setting with a 16-minute default, align equity receipt expiry, retain provider timestamp and session checks, and document delayed-feed risks.

Validation: 215 focused backend tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* test(settings): align curated equity quote policy contract

Signed-off-by: TIANHE <[email protected]>

* fix(trading): coordinate exchange REST limits and startup recovery

Signed-off-by: TIANHE <[email protected]>

* fix(ci): align readiness tests and harden exchange guard identifiers

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): recover strategies after exchange cooldowns

Signed-off-by: TIANHE <[email protected]>

* fix(ws): use Binance USD-M /market stream path for swap feeds

Signed-off-by: Prakash Jha <[email protected]>
(cherry picked from commit a5c7b82)
Signed-off-by: TIANHE <[email protected]>

* fix(ws): migrate Binance futures private stream routing

Signed-off-by: TIANHE <[email protected]>

* fix(streams): recover subscriptions and validate live feed readiness

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reject unsafe sizing and invalid broker order values

Signed-off-by: TIANHE <[email protected]>

* fix(security): return fixed order validation error identifiers

Signed-off-by: TIANHE <[email protected]>

* chore: exclude local design and visual QA artifacts

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): reject non-finite order sizing and arithmetic overflow

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): support native trailing stop protection

(cherry picked from commit 76ea213)
Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce and reconcile attached protection across order paths

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): retire protection waits for rejected entries

Signed-off-by: TIANHE <[email protected]>

* fix(trading): verify bracket children and preserve concurrent metadata

Signed-off-by: TIANHE <[email protected]>

* fix(security): return public protection validation codes

Signed-off-by: TIANHE <[email protected]>

* feat(trading): extend native protection and verify broker child orders

Signed-off-by: TIANHE <[email protected]>

* fix(market-data): batch HK quotes and preserve Tencent timestamps

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): skip unavailable quotes in daily equity orders

Signed-off-by: TIANHE <[email protected]>

* fix(equities): harden lot sizing, catalog sync and quote diagnostics

Signed-off-by: TIANHE <[email protected]>

* feat(universes): add HK sector and crypto selection pools

Signed-off-by: TIANHE <[email protected]>

* fix(ci): extract broker diagnostics and align quote health tests

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): reconcile live positions and preserve account settings

Signed-off-by: TIANHE <[email protected]>

* fix(forthright): calculate stock position PnL and log rejection details

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile broker allocations and suppress repeated exit failures

Signed-off-by: TIANHE <[email protected]>

* fix(ledger): group partial fills by order without changing accounting

Signed-off-by: TIANHE <[email protected]>

* fix(catalog): preserve localized asset names and search active aliases

Signed-off-by: TIANHE <[email protected]>

* fix(openapi): generate localized catalog and grouped trade documentation

Signed-off-by: TIANHE <[email protected]>

* refactor(catalog): simplify localized name return flow

Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Signed-off-by: Prakash Jha <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
Co-authored-by: Prakash Jha <[email protected]>
Co-authored-by: Pranav <[email protected]>
brokermr810 added a commit that referenced this pull request Dec 4, 2026
… protection (#439)

* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): prevent rebalance replay after worker restart

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): warm NumPy modules before applying isolation

Signed-off-by: TIANHE <[email protected]>

* feat(platform): add Forthright integration and advertisement settings

Add scoped broker access, HK board-lot metadata, dated-futures manual trading, and credential redaction. Keep automated futures strategies disabled. Persist advertisement settings and generate their OpenAPI contract.

Signed-off-by: TIANHE <[email protected]>

* fix(ci): declare Forthright API tags and escape encoding fixtures

Signed-off-by: TIANHE <[email protected]>

* fix(security): bound public inputs and document broker signature risks

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): preserve equity identity and reconcile account fills

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): normalize HK-prefixed securities and deduplicate search

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): reconcile delayed Forthright execution fees

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): unify HK pool and position identities

Signed-off-by: TIANHE <[email protected]>

* perf(strategy): vectorize causal Bollinger series

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): improve equity warmup caching and quote diagnostics

Keep completed-session and execution-price freshness checks intact, allow eligible newly listed equities to satisfy declared warmup, and fail over HK candle providers with bounded Tencent cooldown.

Validation: 382 focused Linux regression tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* feat(trading): configure equity execution quote freshness

Expose a restart-scoped 1-60 minute quote-age setting with a 16-minute default, align equity receipt expiry, retain provider timestamp and session checks, and document delayed-feed risks.

Validation: 215 focused backend tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* test(settings): align curated equity quote policy contract

Signed-off-by: TIANHE <[email protected]>

* fix(trading): coordinate exchange REST limits and startup recovery

Signed-off-by: TIANHE <[email protected]>

* fix(ci): align readiness tests and harden exchange guard identifiers

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): recover strategies after exchange cooldowns

Signed-off-by: TIANHE <[email protected]>

* fix(ws): use Binance USD-M /market stream path for swap feeds

Signed-off-by: Prakash Jha <[email protected]>
(cherry picked from commit a5c7b82)
Signed-off-by: TIANHE <[email protected]>

* fix(ws): migrate Binance futures private stream routing

Signed-off-by: TIANHE <[email protected]>

* fix(streams): recover subscriptions and validate live feed readiness

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reject unsafe sizing and invalid broker order values

Signed-off-by: TIANHE <[email protected]>

* fix(security): return fixed order validation error identifiers

Signed-off-by: TIANHE <[email protected]>

* chore: exclude local design and visual QA artifacts

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): reject non-finite order sizing and arithmetic overflow

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): support native trailing stop protection

(cherry picked from commit 76ea213)
Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce and reconcile attached protection across order paths

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): retire protection waits for rejected entries

Signed-off-by: TIANHE <[email protected]>

* fix(trading): verify bracket children and preserve concurrent metadata

Signed-off-by: TIANHE <[email protected]>

* fix(security): return public protection validation codes

Signed-off-by: TIANHE <[email protected]>

* feat(trading): extend native protection and verify broker child orders

Signed-off-by: TIANHE <[email protected]>

* fix(market-data): batch HK quotes and preserve Tencent timestamps

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): skip unavailable quotes in daily equity orders

Signed-off-by: TIANHE <[email protected]>

* fix(equities): harden lot sizing, catalog sync and quote diagnostics

Signed-off-by: TIANHE <[email protected]>

* feat(universes): add HK sector and crypto selection pools

Signed-off-by: TIANHE <[email protected]>

* fix(ci): extract broker diagnostics and align quote health tests

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): reconcile live positions and preserve account settings

Signed-off-by: TIANHE <[email protected]>

* fix(forthright): calculate stock position PnL and log rejection details

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile broker allocations and suppress repeated exit failures

Signed-off-by: TIANHE <[email protected]>

* fix(ledger): group partial fills by order without changing accounting

Signed-off-by: TIANHE <[email protected]>

* fix(catalog): preserve localized asset names and search active aliases

Signed-off-by: TIANHE <[email protected]>

* fix(openapi): generate localized catalog and grouped trade documentation

Signed-off-by: TIANHE <[email protected]>

* refactor(catalog): simplify localized name return flow

Signed-off-by: TIANHE <[email protected]>

* fix(trading): stabilize protection IDs and classify full ADL closes

Signed-off-by: TIANHE <[email protected]>

* fix(trading): throttle broker connection exit retries and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(catalog): recognize Texas listings and skip test exchange codes

Signed-off-by: TIANHE <[email protected]>

* fix(ownership): read equity snapshots from the correct account bucket

Signed-off-by: TIANHE <[email protected]>

* docs(trading): document snapshot and order recovery safeguards

Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Signed-off-by: Prakash Jha <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
Co-authored-by: Prakash Jha <[email protected]>
Co-authored-by: Pranav <[email protected]>
brokermr810 added a commit that referenced this pull request Dec 4, 2026
…ical funding (#442)

* feat: expand factor research and quick trade depth

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): normalize derivative order book units

Signed-off-by: TIANHE <[email protected]>

* docs(api): refresh OpenAPI export

Signed-off-by: TIANHE <[email protected]>

* security: harden secret handling and webhooks

Signed-off-by: TIANHE <[email protected]>

* security: prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* ci: satisfy quick trade size guardrail

Signed-off-by: TIANHE <[email protected]>

* feat(research): add custom factor AI and crypto history paging

Signed-off-by: TIANHE <[email protected]>

* fix(research): avoid backtracking in factor JSON parsing

Signed-off-by: TIANHE <[email protected]>

* feat: harden research, trading, and deployment flows

Signed-off-by: TIANHE <[email protected]>

* fix(ci): restore backend quality gates

Signed-off-by: TIANHE <[email protected]>

* fix(market): preserve exact crypto product identity

Signed-off-by: TIANHE <[email protected]>

* security(api): hide internal exception details

Signed-off-by: TIANHE <[email protected]>

* feat(api): harden analysis reports and public errors

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep fast analysis within quality baseline

Signed-off-by: TIANHE <[email protected]>

* feat(ai): modernize scheduled monitor reports

Signed-off-by: TIANHE <[email protected]>

* feat(market): generate localized share drafts

Signed-off-by: TIANHE <[email protected]>

* fix(security): sanitize share generation errors

Signed-off-by: TIANHE <[email protected]>

* fix(market): satisfy share draft quality checks

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): harden marketplace metrics and evaluator capacity

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent exception detail exposure

Signed-off-by: TIANHE <[email protected]>

* feat: harden asset identity and live recovery

Signed-off-by: TIANHE <[email protected]>

* fix: restore backend CI quality gates

Signed-off-by: TIANHE <[email protected]>

* fix: sanitize asset resolution errors

Signed-off-by: TIANHE <[email protected]>

* fix: align agent contracts and runtime tests

Signed-off-by: TIANHE <[email protected]>

* test: refresh hardened runtime fixtures

Signed-off-by: TIANHE <[email protected]>

* feat: harden strategy candle readiness and recovery

Signed-off-by: TIANHE <[email protected]>

* fix(backtest): align crypto candle coverage boundaries (#359)

Signed-off-by: TIANHE <[email protected]>
Co-authored-by: TIANHE <[email protected]>

* fix(trading): normalize Binance protection orders

Signed-off-by: TIANHE <[email protected]>

* fix(trading): snap Bitget and Bybit native protection prices to the tick

#362 normalized the Binance protection orders, but Bitget (UTA and
classic) and Bybit still sent percentage-derived prices with str(), e.g.
stopLoss=77951.14749999999 for a 2.5% stop on a 76049.9 short. Those are
off the contract tick, so the venue rejects the protection order.

Run the stop-loss, take-profit and trailing activation prices (and the
Bybit trailingStop distance) through each client's _normalize_price, the
same way #362 does for Binance, and raise when the result falls below the
minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: aliassar <[email protected]>

* fix(trading): normalize protection orders across venues

Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce run-scoped liquidation risk stops

Signed-off-by: TIANHE <[email protected]>

* fix(grid): support legacy recovery engines

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): separate strategy lifecycle generations

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile protection fills and spot residuals

Signed-off-by: TIANHE <[email protected]>

* fix(db): prevent runtime lock convoys

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden sandbox and credential redaction

Signed-off-by: TIANHE <[email protected]>

* fix(security): harden strategy execution boundaries

Signed-off-by: TIANHE <[email protected]>

* fix(ci): keep quick trade route within guardrail

Signed-off-by: TIANHE <[email protected]>

* fix(security): document isolated exec boundary

Signed-off-by: TIANHE <[email protected]>

* fix(security): prevent market data error disclosure

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): classify native loader memory failures

Signed-off-by: TIANHE <[email protected]>

* docs: align repository and sandbox architecture maps

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): accept decimal position values

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): allow two-minute sandbox requests and preserve failures

Signed-off-by: TIANHE <[email protected]>

* fix(config): align packaged sandbox environment defaults

Signed-off-by: TIANHE <[email protected]>

* fix(research): support China equities in research reports

Signed-off-by: TIANHE <[email protected]>

* feat(protection): reconcile partial exits and native rule semantics

Signed-off-by: TIANHE <[email protected]>

* feat(library): publish indicator and Strategy API V2 examples

Signed-off-by: TIANHE <[email protected]>

* fix(protection): compare native exit fractions exactly

Signed-off-by: TIANHE <[email protected]>

* fix(research): report A-share evidence and data gaps accurately

Signed-off-by: TIANHE <[email protected]>

* fix(trading): suppress repeated residual exit orders and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(grid): validate funded ladder before initial position

Signed-off-by: TIANHE <[email protected]>

* fix(notifications): unify strategy outcomes and branded multilingual emails

Persist definitive order failure streaks and portfolio batch outcomes, send deduplicated alerts across opted-in channels, and render transactional emails using localized monochrome templates and configured branding.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): correct stop and rebalance notification schema queries

Use the canonical strategy_name column for automatic-stop and rebalance notifications, honor explicit stop-and-close requests, and exercise the production schema and notification delivery paths in regression tests.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve lifetime equity and clear closing precision tails

Keep order sizing aligned with the deployment ledger across restarts. Revalue positions atomically with fills and derive live floating PnL from current quantities so stale residual rows cannot inflate equity. Preserve real small holdings and add cross-path regression coverage.

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reuse confirmed exchange order pnl without expiry

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): acknowledge distributed startup before completing commands

Signed-off-by: TIANHE <[email protected]>

* test(runtime): align command fencing assertions with distributed claims

Signed-off-by: TIANHE <[email protected]>

* perf(runtime): reduce strategy history loading and health query overhead

Signed-off-by: TIANHE <[email protected]>

* fix(trading): preserve grid protection and reconcile uncertain submissions

Signed-off-by: TIANHE <[email protected]>

* fix(research): strengthen cross-market fundamentals and event evidence

Signed-off-by: TIANHE <[email protected]>

* test: align grid recovery regressions

Signed-off-by: TIANHE <[email protected]>

* fix(grid): resolve orders missing from open orders on verify

The grid resting-order audit (verify / re-reconcile in the UI) only read the
exchange open-orders snapshot. An order cancelled on the exchange was
reported as "not_open" forever and its local row stayed open, because the
worker fill poller only polls strategies with a live runner and the UI has
no delete action.

For rows absent from open orders, query the order itself (Binance
GET /fapi/v1/order via query_grid_order_fill) and report its terminal
status. An exchange-confirmed cancel with no fill is applied to the local
row through a guarded update; orders with fills are left to the fill
poller so no fill is dropped from the strategy ledger.

Fixes #404

(cherry picked from commit 46ef975)
Signed-off-by: TIANHE <[email protected]>

* fix(grid): reconcile residual orders in bounded worker audits

Build on PR #407 by preserving confirmed terminal-order lookup and adding asynchronous persisted verification, bounded recovery, stopped-grid accounting without follow-up orders, and regression coverage.

Co-authored-by: Pranav Tomar <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(marketplace): add author filters and balanced recommendations

Signed-off-by: TIANHE <[email protected]>

* fix(ai): keep ordinary crypto strategy generation venue independent

Signed-off-by: TIANHE <[email protected]>

* fix(reports): split oversized PDF table rows across pages

Signed-off-by: TIANHE <[email protected]>

* fix(indicators): align library scripts with safe runtime APIs

Signed-off-by: TIANHE <[email protected]>

* fix(trading): harden session execution and fill reconciliation

Signed-off-by: TIANHE <[email protected]>

* fix(api): keep generated OpenAPI contract in sync

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): prevent rebalance replay after worker restart

Signed-off-by: TIANHE <[email protected]>

* fix(sandbox): warm NumPy modules before applying isolation

Signed-off-by: TIANHE <[email protected]>

* feat(platform): add Forthright integration and advertisement settings

Add scoped broker access, HK board-lot metadata, dated-futures manual trading, and credential redaction. Keep automated futures strategies disabled. Persist advertisement settings and generate their OpenAPI contract.

Signed-off-by: TIANHE <[email protected]>

* fix(ci): declare Forthright API tags and escape encoding fixtures

Signed-off-by: TIANHE <[email protected]>

* fix(security): bound public inputs and document broker signature risks

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): preserve equity identity and reconcile account fills

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): normalize HK-prefixed securities and deduplicate search

Signed-off-by: TIANHE <[email protected]>

* fix(brokers): reconcile delayed Forthright execution fees

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): unify HK pool and position identities

Signed-off-by: TIANHE <[email protected]>

* perf(strategy): vectorize causal Bollinger series

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): improve equity warmup caching and quote diagnostics

Keep completed-session and execution-price freshness checks intact, allow eligible newly listed equities to satisfy declared warmup, and fail over HK candle providers with bounded Tencent cooldown.

Validation: 382 focused Linux regression tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* feat(trading): configure equity execution quote freshness

Expose a restart-scoped 1-60 minute quote-age setting with a 16-minute default, align equity receipt expiry, retain provider timestamp and session checks, and document delayed-feed risks.

Validation: 215 focused backend tests passed; Ruff, backend quality, encoding and version checks passed.
Signed-off-by: TIANHE <[email protected]>

* test(settings): align curated equity quote policy contract

Signed-off-by: TIANHE <[email protected]>

* fix(trading): coordinate exchange REST limits and startup recovery

Signed-off-by: TIANHE <[email protected]>

* fix(ci): align readiness tests and harden exchange guard identifiers

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): recover strategies after exchange cooldowns

Signed-off-by: TIANHE <[email protected]>

* fix(ws): use Binance USD-M /market stream path for swap feeds

Signed-off-by: Prakash Jha <[email protected]>
(cherry picked from commit a5c7b82)
Signed-off-by: TIANHE <[email protected]>

* fix(ws): migrate Binance futures private stream routing

Signed-off-by: TIANHE <[email protected]>

* fix(streams): recover subscriptions and validate live feed readiness

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reject unsafe sizing and invalid broker order values

Signed-off-by: TIANHE <[email protected]>

* fix(security): return fixed order validation error identifiers

Signed-off-by: TIANHE <[email protected]>

* chore: exclude local design and visual QA artifacts

Signed-off-by: TIANHE <[email protected]>

* fix(strategy): reject non-finite order sizing and arithmetic overflow

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): support native trailing stop protection

(cherry picked from commit 76ea213)
Signed-off-by: TIANHE <[email protected]>

* fix(trading): enforce and reconcile attached protection across order paths

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): retire protection waits for rejected entries

Signed-off-by: TIANHE <[email protected]>

* fix(trading): verify bracket children and preserve concurrent metadata

Signed-off-by: TIANHE <[email protected]>

* fix(security): return public protection validation codes

Signed-off-by: TIANHE <[email protected]>

* feat(trading): extend native protection and verify broker child orders

Signed-off-by: TIANHE <[email protected]>

* fix(market-data): batch HK quotes and preserve Tencent timestamps

Signed-off-by: TIANHE <[email protected]>

* fix(runtime): skip unavailable quotes in daily equity orders

Signed-off-by: TIANHE <[email protected]>

* fix(equities): harden lot sizing, catalog sync and quote diagnostics

Signed-off-by: TIANHE <[email protected]>

* feat(universes): add HK sector and crypto selection pools

Signed-off-by: TIANHE <[email protected]>

* fix(ci): extract broker diagnostics and align quote health tests

Signed-off-by: TIANHE <[email protected]>

* fix(quick-trade): reconcile live positions and preserve account settings

Signed-off-by: TIANHE <[email protected]>

* fix(forthright): calculate stock position PnL and log rejection details

Signed-off-by: TIANHE <[email protected]>

* fix(trading): reconcile broker allocations and suppress repeated exit failures

Signed-off-by: TIANHE <[email protected]>

* fix(ledger): group partial fills by order without changing accounting

Signed-off-by: TIANHE <[email protected]>

* fix(catalog): preserve localized asset names and search active aliases

Signed-off-by: TIANHE <[email protected]>

* fix(openapi): generate localized catalog and grouped trade documentation

Signed-off-by: TIANHE <[email protected]>

* refactor(catalog): simplify localized name return flow

Signed-off-by: TIANHE <[email protected]>

* fix(trading): stabilize protection IDs and classify full ADL closes

Signed-off-by: TIANHE <[email protected]>

* fix(trading): throttle broker connection exit retries and alerts

Signed-off-by: TIANHE <[email protected]>

* fix(catalog): recognize Texas listings and skip test exchange codes

Signed-off-by: TIANHE <[email protected]>

* fix(ownership): read equity snapshots from the correct account bucket

Signed-off-by: TIANHE <[email protected]>

* docs(trading): document snapshot and order recovery safeguards

Signed-off-by: TIANHE <[email protected]>

* fix(virtual): keep signal accounts marked, funded and liquidated

Virtual (signal-mode) positions were marked only when their stored
strategy_run_id matched the current runtime run. Every strategy restart
(the trading worker restores runtimes on boot) orphaned the still-open
positions: mark price, unrealized PnL and equity snapshots froze until a
new fill overwrote the row. On the Raspberry Pi deployment strategies 71
and 72 stayed frozen for 28 and 3 days while BTC fell from ~76k/59.6k to
~52k, so the virtual account showed +34k/+569k equity instead of being
liquidated.

- mark every open virtual position for the strategy, regardless of which
  run opened it.
- add maintenance-margin liquidation for virtual perpetual accounts
  (configurable via maintenance_margin_rate, default 0.5%), force close at
  the current mark, and floor the account equity at zero so paper losses
  can never exceed the initial capital.
- accrue settled funding into qd_strategy_funding_fees using public
  Binance/Gate.io funding history and deduct it from the virtual account's
  realised PnL; runs from the strategy loop and from a worker sweep so a
  stopped runtime cannot leave a position unmarked.
- wire the sweep into the pending-order worker (virtual ledgers only; the
  live execution path is untouched).

Tests cover the run-scope regression, maintenance-margin bounds,
settlement-price selection and the Binance->Gate funding fallback.

Co-authored-by: multica-agent <[email protected]>
Signed-off-by: TIANHE <[email protected]>

* fix(virtual): bound funding backfill and reconcile liquidation ledger

- Derive the funding start from the current position cycle by replaying the
  trade ledger, so a partial reduction no longer resets it and the accrual
  never falls back to the strategy creation time.
- Cap every funding backfill window (default 7 days) so a first sweep or a
  long gap cannot back-charge months of settlements at today's size.
- Gate settlements on 8h clock boundaries instead of holding duration.
- Dedupe funding rows per (symbol, minute, side) and only among virtual
  rows so hedged long/short positions both accrue.
- Cancel pending_orders and strategy_order_intents when liquidation cancels
  virtual orders, matching the normal cancellation path.
- Book forgiven loss beyond initial capital as an explicit bad_debt
  adjustment so trade PnL keeps summing to the account's realized PnL.
- Add regression tests for cycle replay, boundary gating, side split,
  three-table liquidation cancel and bad-debt reconciliation.

Signed-off-by: TIANHE <[email protected]>

* test(virtual): cover liquidation idempotency and entry margin guard

Signed-off-by: TIANHE <[email protected]>

* fix(virtual): reconcile historical funding and safely sweep signal accounts

Signed-off-by: TIANHE <[email protected]>

* fix(virtual): run initial maintenance regardless of host uptime

Signed-off-by: TIANHE <[email protected]>

* fix(virtual): protect margin checks and reconcile funding reporting

Signed-off-by: TIANHE <[email protected]>

---------

Signed-off-by: TIANHE <[email protected]>
Signed-off-by: aliassar <[email protected]>
Signed-off-by: Prakash Jha <[email protected]>
Co-authored-by: TIANHE <[email protected]>
Co-authored-by: aliassar <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Pranav Tomar <[email protected]>
Co-authored-by: Prakash Jha <[email protected]>
Co-authored-by: Pranav <[email protected]>
Co-authored-by: mabaojinbj <[email protected]>
Co-authored-by: multica-agent <[email protected]>
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.

网格策略订单在币安已取消,但 QuantDinger 界面仍显示“未在当前挂单中”且无法删除

2 participants