crypto.ai/cryptoai/routes/alltick.py
2025-06-03 16:55:34 +08:00

27 lines
835 B
Python

from fastapi import APIRouter, Depends, HTTPException, status, Body, Query, Path
import logging
from cryptoai.api.alltick_api import AllTickAPI
import json
# 创建路由
router = APIRouter()
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
api_key = "6c7ba077eee07f6f270e219d4848700e-c-app"
@router.get("/stock/kline")
async def get_stock_kline(symbol: str, interval: str, limit: int = 200):
api = AllTickAPI(api_key=api_key)
result = api.get_stock_klines(symbol, interval, limit)
return json.loads(result.to_json(orient="records"))
@router.get("/common/kline")
async def get_common_kline(symbol: str, interval: str, limit: int = 200):
api = AllTickAPI(api_key=api_key)
result = api.get_common_klines(symbol, interval, limit)
return json.loads(result.to_json(orient="records"))