@@ -66,7 +66,23 @@ def _fetch_sina_raw(sina_code: str) -> Optional[dict]:
|
||||
return None
|
||||
price = float(parts[8])
|
||||
volume = float(parts[14]) if len(parts) > 14 and parts[14] else 0
|
||||
return {"name": parts[0], "price": price, "volume": volume}
|
||||
prev_close = None
|
||||
if len(parts) > 9 and parts[9]:
|
||||
try:
|
||||
prev_close = float(parts[9])
|
||||
except ValueError:
|
||||
pass
|
||||
if prev_close is None and len(parts) > 2 and parts[2]:
|
||||
try:
|
||||
prev_close = float(parts[2])
|
||||
except ValueError:
|
||||
pass
|
||||
return {
|
||||
"name": parts[0],
|
||||
"price": price,
|
||||
"volume": volume,
|
||||
"prev_close": prev_close,
|
||||
}
|
||||
except Exception as exc:
|
||||
logger.debug("sina fetch failed %s: %s", sina_code, exc)
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user