fix: stabilize long-running quote refresh

This commit is contained in:
王鹏
2026-11-09 10:42:08 +08:00
parent b7e0894f4b
commit 5f4df03581
6 changed files with 281 additions and 84 deletions

View File

@@ -5,6 +5,7 @@ import pytest
from grid_trading.domain.models import Instrument
from grid_trading.market.tencent import (
QuoteFetchError,
TENCENT_ENDPOINT,
TencentQuoteProvider,
infer_tencent_symbol,
parse_tencent_response,
@@ -18,6 +19,20 @@ def test_infer_tencent_symbol_from_a_share_code():
assert infer_tencent_symbol("sz000001") == "sz000001"
def test_provider_builds_request_url_for_async_qt_client():
provider = TencentQuoteProvider()
url = provider.build_request_url(
[
Instrument(id=1, code="000001", name="平安银行"),
Instrument(id=2, code="510300", name="沪深300ETF"),
]
)
assert provider.uses_default_fetcher
assert url == f"{TENCENT_ENDPOINT}sz000001,sh510300"
def test_parse_tencent_response_extracts_realtime_fields():
raw = (
'v_sz000001="51~平安银行~000001~10.60~10.47~10.44~0~0~0~'