feat: complete advisory market data refresh pipeline
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Synchronize public fund NAV history into the additive advisory history store."""
|
||||
"""Synchronize public fund history into the additive advisory history store."""
|
||||
|
||||
import asyncio
|
||||
from collections.abc import Callable
|
||||
@@ -24,7 +24,7 @@ class ProductHistorySyncResult:
|
||||
|
||||
|
||||
class ProductHistorySyncService:
|
||||
"""Writes fund NAV observations only; it never writes immutable baseline tables."""
|
||||
"""Write NAV observations and verified exchange turnover only."""
|
||||
|
||||
SOURCE = "eastmoney_hq_nav"
|
||||
|
||||
@@ -110,12 +110,21 @@ class ProductHistorySyncService:
|
||||
return None
|
||||
if close_price <= 0:
|
||||
return None
|
||||
turnover = raw.get("turnover_amount")
|
||||
parsed_turnover: Decimal | None = None
|
||||
if turnover not in (None, ""):
|
||||
try:
|
||||
parsed_turnover = Decimal(str(turnover))
|
||||
except InvalidOperation:
|
||||
parsed_turnover = None
|
||||
if parsed_turnover is not None and parsed_turnover < 0:
|
||||
parsed_turnover = None
|
||||
return {
|
||||
"product_id": product_id,
|
||||
"trade_date": trade_date,
|
||||
"price_kind": "fund_nav",
|
||||
"close_price": close_price,
|
||||
"turnover_amount": None,
|
||||
"turnover_amount": parsed_turnover,
|
||||
"source": cls.SOURCE,
|
||||
"source_updated_at": now,
|
||||
"created_at": now,
|
||||
|
||||
Reference in New Issue
Block a user