fix: separate trade price from realtime price

This commit is contained in:
王鹏
2026-07-09 10:45:27 +08:00
parent 5bbc4e607a
commit 15636fb910
9 changed files with 105 additions and 55 deletions

View File

@@ -6,7 +6,7 @@ Date: 2026-07-08
Add Tencent A-share quote integration so the GUI holdings table displays realtime prices from `http://qt.gtimg.cn/q=<symbol>`.
The first implementation is manual refresh only. It does not auto-refresh, generate buy/sell grid orders, or overwrite user-entered manual prices.
The first implementation is manual refresh only. It does not auto-refresh, generate buy/sell grid orders, persist quote prices, or use trade-entry prices as current prices.
## Confirmed Decision
@@ -45,14 +45,12 @@ Add a `market` package with a Tencent quote client. The client converts local in
`TradingService` keeps an in-memory quote cache. When the user clicks refresh in the GUI, the service fetches quotes for all active instruments and stores them in memory.
Position calculations will prefer prices in this order:
Position calculations will treat Tencent quotes as the only current-price source:
1. Tencent realtime quote
2. Manual price
3. Last trade price
4. Empty value
2. Empty value
The holdings table and account summary will immediately reflect quote prices after refresh. Quote prices are not persisted to SQLite in this step, so stale prices do not silently survive app restarts.
The holdings table and account summary will immediately reflect quote prices after refresh. Quote prices are not persisted to SQLite in this step, so stale prices do not silently survive app restarts. Trade-entry prices remain historical成交价 only and never become current-price fallbacks.
## Error Handling
@@ -65,6 +63,6 @@ The holdings table and account summary will immediately reflect quote prices aft
- Unit-test Tencent response parsing with a fixture response.
- Unit-test symbol inference.
- Unit-test position calculations with a realtime quote overriding manual price.
- Unit-test position calculations with a realtime quote supplying current price and a missing quote leaving current price empty.
- Unit-test service quote refresh using a fake quote provider.
- Keep existing GUI smoke tests passing.