This commit is contained in:
aaron 2025-05-14 00:03:22 +08:00
parent a423e729b9
commit a261e92e67
3 changed files with 9 additions and 5 deletions

View File

@ -98,12 +98,12 @@ class AStockAPI:
return pd.DataFrame()
@staticmethod
def get_capital_flow(stock_code: str) -> pd.DataFrame:
def get_capital_flow(stock_code: str, start_date: Optional[str] = None, end_date: Optional[str] = None) -> pd.DataFrame:
"""
获取股票资金流向数据
"""
try:
return adata.stock.market.get_capital_flow(stock_code=stock_code)
return adata.stock.market.get_capital_flow(stock_code=stock_code, start_date=start_date, end_date=end_date)
except Exception as e:
print(f"获取资金流向数据失败: {str(e)}")
return pd.DataFrame()

View File

@ -3,6 +3,7 @@ import logging
from fastapi import APIRouter, Depends, HTTPException, status, Body, Query, Path
from cryptoai.api.adata_api import AStockAPI
from cryptoai.utils.db_manager import get_db_manager
from datetime import datetime
# 创建路由
router = APIRouter()
@ -50,12 +51,15 @@ async def get_stock_data(stock_code: str):
result = {}
try:
start_date = "2025-01-01"
end_date = datetime.now().strftime("%Y-%m-%d")
# 获取市场数据
market_data = api.get_market_data(stock_code)
market_data = api.get_market_data(stock_code, start_date, end_date)
result["market_data"] = json.loads(market_data.to_json(orient="records"))
# 获取资金流向数据
flow_data = api.get_capital_flow(stock_code)
flow_data = api.get_capital_flow(stock_code, start_date, end_date)
result["flow_data"] = json.loads(flow_data.to_json(orient="records"))
except Exception as e:

View File

@ -29,7 +29,7 @@ services:
cryptoai-api:
build: .
container_name: cryptoai-api
image: cryptoai-api:0.0.20
image: cryptoai-api:0.0.21
restart: always
ports:
- "8000:8000"