Skip to content

fix(strategy): unify Hong Kong pool, position and execution identities - #415

Merged
brokermr810 merged 113 commits into
mainfrom
test
Nov 27, 2026
Merged

brokermr810 merged 113 commits into
mainfrom
test

Conversation

@brokermr810

Copy link
Copy Markdown
Collaborator

Root cause

Hong Kong pool members and historical positions could use numeric/HK-prefixed aliases while broker execution required a five-digit .HK identity. The mismatch could fail deployment validation or hide an existing position from the strategy's canonical lookup.

Changes

  • Canonicalize aliases only in an explicit HKStock context across strategy parsing, backtest/factor universes and live candidate refresh.
  • Deduplicate HK aliases while preserving historical membership periods; retain held instruments outside the current universe.
  • Recognize legacy live/virtual position keys without rewriting historical source records. Reject conflicting virtual allocations instead of silently merging them.
  • Apply the same instrument rules to AI authoring/repair contracts and document the behavior in English/Chinese.
  • Keep US share classes, futures, Crypto-routed products, account eligibility and board-lot safeguards unchanged.

Verification

  • Core Linux Docker regression: 75 passed.
  • Expanded Linux Docker regression: 342 passed, 1 deselected. The existing SUPERTREND/TA-Lib test failed in the older test image because that image lacks the function; it was explicitly excluded from the second expanded run, not suppressed in source. The newer local application image reports TA-Lib 0.8.2 with SUPERTREND support.
  • Containers were disposable, network-disabled and mounted current source read-only; no live orders or existing-service restarts.
  • Ruff, backend quality, encoding, version and diff checks passed.
  • Desktop 885 tests passed, mobile 265 tests passed, both production builds passed.
  • Desktop lint: 0 errors, 1,407 existing warnings. Existing bundle-size/Browserslist warnings remain.
  • Website: all seven changed Markdown files match backend source; their links, anchors, JSON-LD and search entries passed. The full-site checker still reports pre-existing unrelated mirrored-document drift and two non-public audit documents; this round does not claim that full-site check passed.

Companion commits

Deployment / risk

No database migration, bulk data rewrite, expanded broker support or automatic futures enablement. Deploy backend/runtime workers consistently with the companion clients. Existing duplicate alias allocations require review rather than automatic merging. Automated tests are not live-broker certification.

PR #414 was already merged. The merged main tree exactly matched the pre-change test baseline; the signed history-sync commit changes no files.

tianhe added 30 commits November 1, 2026 17:17
Signed-off-by: TIANHE <[email protected]>

# Conflicts:
#	backend_api_python/app/routes/community.py
tianhe and others added 25 commits November 23, 2026 02:33
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]>
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]>
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]>
The main tree matches the pre-fix test tree exactly. Record the squash-merge ancestry while preserving the verified broker fixes.

Signed-off-by: TIANHE <[email protected]>
The main tree exactly matches the pre-fix test tree. Record the merged ancestry while preserving the verified fee fixes.

Signed-off-by: TIANHE <[email protected]>
The merged main tree exactly matches the pre-change test tree; preserve the verified HK identity fixes while recording merge ancestry.

Signed-off-by: TIANHE <[email protected]>
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]>
@sonarqubecloud

Copy link
Copy Markdown

@brokermr810
brokermr810 merged commit f17ba93 into main Nov 27, 2026
15 checks passed
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.

4 participants