update
This commit is contained in:
parent
854bf07286
commit
d71d6cca5b
Binary file not shown.
@ -47,6 +47,41 @@ class BinanceAPI:
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def get_top_longshort_position_ratio(self, symbol: str, period: str = '1h') -> float:
|
||||||
|
"""
|
||||||
|
获取交易对大户持仓多空比
|
||||||
|
|
||||||
|
Args:
|
||||||
|
symbol: 交易对符号,例如 'BTCUSDT'
|
||||||
|
period: 时间间隔,例如 '1h', '1d'
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
大户持仓多空比
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
response = self.client.futures_top_longshort_position_ratio(symbol=symbol, period=period)
|
||||||
|
return response
|
||||||
|
except BinanceAPIException as e:
|
||||||
|
print(f"获取交易对大户持仓多空比时出错: {e}")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def get_top_longshort_account_ratio(self, symbol: str, period: str = '1h') -> float:
|
||||||
|
"""
|
||||||
|
获取交易对大户持仓多空比
|
||||||
|
|
||||||
|
Args:
|
||||||
|
symbol: 交易对符号,例如 'BTCUSDT'
|
||||||
|
period: 时间间隔,例如 '1h', '1d'
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
大户持仓多空比
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
response = self.client.futures_top_longshort_account_ratio(symbol=symbol, period=period)
|
||||||
|
return response
|
||||||
|
except BinanceAPIException as e:
|
||||||
|
print(f"获取交易对大户持仓多空比时出错: {e}")
|
||||||
|
return 0
|
||||||
|
|
||||||
def get_historical_klines(self, symbol: str, interval: str, start_str: str, end_str: Optional[str] = None) -> pd.DataFrame:
|
def get_historical_klines(self, symbol: str, interval: str, start_str: str, end_str: Optional[str] = None) -> pd.DataFrame:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -15,6 +15,8 @@ import logging
|
|||||||
from cryptoai.api.deepseek_api import DeepSeekAPI
|
from cryptoai.api.deepseek_api import DeepSeekAPI
|
||||||
from cryptoai.utils.config_loader import ConfigLoader
|
from cryptoai.utils.config_loader import ConfigLoader
|
||||||
from fastapi.responses import StreamingResponse
|
from fastapi.responses import StreamingResponse
|
||||||
|
from cryptoai.routes.user import get_current_user
|
||||||
|
import requests
|
||||||
# 创建路由
|
# 创建路由
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@ -22,13 +24,45 @@ class ChatRequest(BaseModel):
|
|||||||
user_prompt: str
|
user_prompt: str
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/list")
|
||||||
|
async def get_agents(current_user: Dict[str, Any] = Depends(get_current_user)):
|
||||||
|
"""
|
||||||
|
获取所有代理
|
||||||
|
"""
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"id": "1",
|
||||||
|
"name": "二级市场助手",
|
||||||
|
"hello_prompt": "您好,我是二级市场助手,为您提供专业的二级市场分析和建议",
|
||||||
|
"description": "为您提供专业的二级市场分析和建议",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@router.post("/chat")
|
@router.post("/chat")
|
||||||
async def chat(request: ChatRequest):
|
async def chat(request: ChatRequest,current_user: Dict[str, Any] = Depends(get_current_user)):
|
||||||
"""
|
"""
|
||||||
聊天接口
|
聊天接口
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
token = "app-vhJecqbcLukf72g0uxAb9tcz"
|
||||||
|
url = "https://mate.aimateplus.com/v1/chat-messages"
|
||||||
|
headers = {
|
||||||
|
"Authorization": f"Bearer {token}",
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
data = {
|
||||||
|
"inputs" : {},
|
||||||
|
"query" : request.user_prompt,
|
||||||
|
"response_mode" : "streaming",
|
||||||
|
"user" : current_user["mail"]
|
||||||
|
}
|
||||||
|
response = requests.post(url, headers=headers, json=data, stream=True)
|
||||||
|
|
||||||
deepseek_api = DeepSeekAPI()
|
#获取response 的 stream
|
||||||
response = deepseek_api.streaming_call(request.user_prompt)
|
def stream_response():
|
||||||
|
for chunk in response.iter_content(chunk_size=1024):
|
||||||
|
if chunk:
|
||||||
|
yield chunk
|
||||||
|
|
||||||
return StreamingResponse(response, media_type="text/plain")
|
return StreamingResponse(stream_response(), media_type="text/plain")
|
||||||
|
|||||||
@ -25,7 +25,7 @@ def task_start():
|
|||||||
try:
|
try:
|
||||||
|
|
||||||
# GoldAgent().start_agent()
|
# GoldAgent().start_agent()
|
||||||
# CryptoAgent().start_agent()
|
# CryptoAgent().start_agent("WLDUSDT")
|
||||||
# return
|
# return
|
||||||
|
|
||||||
logger.info("🚀 加密货币Agent程序已启动")
|
logger.info("🚀 加密货币Agent程序已启动")
|
||||||
|
|||||||
@ -29,7 +29,7 @@ services:
|
|||||||
cryptoai-api:
|
cryptoai-api:
|
||||||
build: .
|
build: .
|
||||||
container_name: cryptoai-api
|
container_name: cryptoai-api
|
||||||
image: cryptoai-api:0.0.4
|
image: cryptoai-api:0.0.5
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
|
|||||||
8
test.py
Normal file
8
test.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
from cryptoai.api.binance_api import BinanceAPI
|
||||||
|
from cryptoai.utils.config_loader import ConfigLoader
|
||||||
|
|
||||||
|
config = ConfigLoader().get_binance_config()
|
||||||
|
|
||||||
|
binance_api = BinanceAPI(config['api_key'], config['api_secret'])
|
||||||
|
|
||||||
|
print(binance_api.get_top_longshort_position_ratio("BTCUSDT", "1h"))
|
||||||
Loading…
Reference in New Issue
Block a user