K线数据首选mootdx通达信TCP源,板块数据增加mootdx降级
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
015aeb989a
commit
86535f5de2
@@ -1,7 +1,7 @@
|
||||
"""板块数据路由:行业板块、概念板块"""
|
||||
|
||||
from fastapi import APIRouter, Query, HTTPException
|
||||
from services import eastmoney
|
||||
from services import eastmoney, mootdx
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@@ -14,4 +14,12 @@ async def sector_list(
|
||||
raise HTTPException(status_code=400, detail="板块类型错误,仅支持 industry/concept")
|
||||
|
||||
data = await eastmoney.fetch_sector_list(type)
|
||||
return {"data": data, "count": len(data), "type": type}
|
||||
if data:
|
||||
return {"data": data, "count": len(data), "type": type}
|
||||
|
||||
# 降级:通达信 mootdx(不含实时资金流数据)
|
||||
md_data = await mootdx.fetch_sector_list(type)
|
||||
if md_data:
|
||||
return {"data": md_data, "count": len(md_data), "type": type, "source": "mootdx"}
|
||||
|
||||
return {"data": [], "count": 0, "type": type}
|
||||
|
||||
+11
-4
@@ -3,7 +3,7 @@
|
||||
from fastapi import APIRouter, Query, HTTPException
|
||||
import re
|
||||
|
||||
from services import tencent, sina, eastmoney
|
||||
from services import tencent, sina, eastmoney, mootdx
|
||||
from models import StockSearchResult, StockQuote, KLineData, FundFlowData, FundFlowSummary, CompanyProfile, FinancialReportItem, FinancialDataResponse
|
||||
|
||||
router = APIRouter()
|
||||
@@ -54,21 +54,28 @@ async def stock_history(
|
||||
if not re.match(r"^\d{6}$", code):
|
||||
raise HTTPException(status_code=400, detail="股票代码格式错误,需为6位数字")
|
||||
|
||||
# 主数据源:东方财富 push2his(含成交额/涨跌幅/振幅/换手率,可能被限流)
|
||||
# 主数据源:通达信 mootdx(TCP直连,不被限流,稳定可靠)
|
||||
md_klines = await mootdx.fetch_kline_history(code, days)
|
||||
if md_klines and len(md_klines) >= 2:
|
||||
return {"data": md_klines, "count": len(md_klines), "source": "mootdx"}
|
||||
|
||||
# 降级1:东方财富 push2his(含成交额/涨跌幅/振幅/换手率)
|
||||
em_klines = await eastmoney.fetch_kline_history(code, days)
|
||||
if em_klines and len(em_klines) >= 2:
|
||||
return {"data": em_klines, "count": len(em_klines), "source": "eastmoney"}
|
||||
|
||||
# 降级1:腾讯(含涨跌幅)
|
||||
# 降级2:腾讯(含涨跌幅)
|
||||
tencent_klines = await tencent.fetch_history(code, days)
|
||||
if tencent_klines and len(tencent_klines) >= 2:
|
||||
return {"data": tencent_klines, "count": len(tencent_klines), "source": "tencent"}
|
||||
|
||||
# 降级2:新浪
|
||||
# 降级3:新浪
|
||||
sina_klines = await sina.fetch_history(code, days)
|
||||
if sina_klines:
|
||||
return {"data": sina_klines, "count": len(sina_klines), "source": "sina"}
|
||||
|
||||
if md_klines:
|
||||
return {"data": md_klines, "count": len(md_klines), "source": "mootdx"}
|
||||
if em_klines:
|
||||
return {"data": em_klines, "count": len(em_klines), "source": "eastmoney"}
|
||||
if tencent_klines:
|
||||
|
||||
Reference in New Issue
Block a user