update
This commit is contained in:
parent
a5b25d6482
commit
e799afccc3
Binary file not shown.
@ -84,7 +84,7 @@ class BinanceAPI:
|
||||
print(f"获取交易对大户持仓多空比时出错: {e}")
|
||||
return 0
|
||||
|
||||
def get_historical_klines(self, symbol: str, interval: str, start_str: Optional[str] = None, end_str: Optional[str] = None, limit: Optional[int] = None) -> pd.DataFrame:
|
||||
def get_historical_klines(self, symbol: str, interval: str, start_str: Optional[str] = None, end_str: Optional[str] = None, limit: Optional[int] = None, ts_transform: bool = True) -> pd.DataFrame:
|
||||
"""
|
||||
获取历史K线数据
|
||||
|
||||
@ -114,6 +114,7 @@ class BinanceAPI:
|
||||
])
|
||||
|
||||
# 转换数据类型
|
||||
if ts_transform:
|
||||
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms', utc=True).map(lambda x: x.tz_convert('Asia/Shanghai'))
|
||||
df['close_time'] = pd.to_datetime(df['close_time'], unit='ms', utc=True).map(lambda x: x.tz_convert('Asia/Shanghai'))
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ async def get_crypto_kline(symbol: str, timeframe: Optional[str] = None, limit:
|
||||
|
||||
binance_api = get_binance_api()
|
||||
|
||||
kline = binance_api.get_historical_klines(symbol=symbol, interval=timeframe, limit=limit)
|
||||
kline = binance_api.get_historical_klines(symbol=symbol, interval=timeframe, limit=limit, ts_transform=False)
|
||||
|
||||
data_processor = DataProcessor()
|
||||
|
||||
@ -47,6 +47,51 @@ async def get_crypto_kline(symbol: str, timeframe: Optional[str] = None, limit:
|
||||
return result
|
||||
|
||||
|
||||
@router.post("/analysis_v2")
|
||||
async def analysis_crypto_v2(request: CryptoAnalysisRequest,
|
||||
current_user: dict = Depends(get_current_user)):
|
||||
|
||||
if request.symbol.endswith("USDT"):
|
||||
symbol = request.symbol
|
||||
else:
|
||||
symbol = request.symbol + "USDT"
|
||||
|
||||
url = 'https://mate.aimateplus.com/v1/workflows/run'
|
||||
token = 'app-BbaqIAMPi0ktgaV9IizMlc2N'
|
||||
headers = {
|
||||
'Authorization': f'Bearer {token}',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
data = {
|
||||
"inputs" : {
|
||||
"symbol" : symbol,
|
||||
"timeframe" : request.timeframe
|
||||
},
|
||||
"response_mode": "streaming",
|
||||
"user": current_user["mail"]
|
||||
}
|
||||
|
||||
# 保存用户提问
|
||||
get_db_manager().save_user_question(current_user["id"], symbol, "请分析以下加密货币:" + symbol + ",并给出分析报告。")
|
||||
|
||||
response = requests.post(url, headers=headers, json=data, stream=True)
|
||||
|
||||
# 如果响应不成功,返回错误
|
||||
if response.status_code != 200:
|
||||
raise HTTPException(
|
||||
status_code=response.status_code,
|
||||
detail=f"Failed to get response from Dify API: {response.text}"
|
||||
)
|
||||
|
||||
# 获取response的stream
|
||||
def stream_response():
|
||||
for chunk in response.iter_content(chunk_size=1024):
|
||||
if chunk:
|
||||
yield chunk
|
||||
|
||||
return StreamingResponse(stream_response(), media_type="text/plain")
|
||||
|
||||
@router.post("/analysis")
|
||||
async def analysis_crypto(request: CryptoAnalysisRequest,
|
||||
current_user: dict = Depends(get_current_user)):
|
||||
|
||||
@ -29,7 +29,7 @@ services:
|
||||
cryptoai-api:
|
||||
build: .
|
||||
container_name: cryptoai-api
|
||||
image: cryptoai-api:0.0.26
|
||||
image: cryptoai-api:0.0.27
|
||||
restart: always
|
||||
ports:
|
||||
- "8000:8000"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user