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

@@ -15,11 +15,11 @@
- Create `src/grid_trading/market/__init__.py`: market package marker.
- Create `src/grid_trading/market/tencent.py`: Tencent symbol inference, response parsing, and HTTP quote provider.
- Modify `src/grid_trading/domain/models.py`: add `QuoteSnapshot`.
- Modify `src/grid_trading/domain/calculations.py`: let quote snapshots override manual price when computing positions.
- Modify `src/grid_trading/domain/calculations.py`: let quote snapshots supply current price when computing positions.
- Modify `src/grid_trading/services/trading_service.py`: add quote provider injection, `refresh_quotes`, and quote cache use in summaries.
- Modify `src/grid_trading/ui/main_window.py`: make the toolbar refresh action fetch Tencent quotes and display quote refresh errors.
- Create `tests/test_tencent_quotes.py`: parser and symbol inference tests.
- Modify `tests/test_calculations.py`: verify quote price overrides manual price.
- Modify `tests/test_calculations.py`: verify quote price supplies current price.
- Modify `tests/test_services.py`: verify service refresh uses fake quote provider and summaries use realtime price.
## Tasks
@@ -98,7 +98,7 @@ git commit -m "feat: add Tencent quote parser"
- [ ] **Step 1: Write failing calculation and service tests**
Add a calculation test where an `Instrument` has `manual_price=Decimal("9")`, a `QuoteSnapshot(price=Decimal("10"))` is passed, and `PositionSummary.current_price` becomes `10` with `price_source == "tencent"`.
Add a calculation test where a `QuoteSnapshot(price=Decimal("10"))` is passed, and `PositionSummary.current_price` becomes `10` with `price_source == "tencent"`.
Add a service test with a fake provider: