update
This commit is contained in:
parent
551efd5d80
commit
1eeb2c1bee
Binary file not shown.
@ -109,9 +109,10 @@ class CryptoAgent:
|
||||
data = self.binance_api.get_historical_klines(
|
||||
symbol=symbol,
|
||||
interval=self.time_interval,
|
||||
start_str=start_str
|
||||
start_str=start_str,
|
||||
limit=200
|
||||
)
|
||||
|
||||
print(f"Binance获取数据: {data}")
|
||||
if data.empty:
|
||||
# 如果从Binance获取失败,尝试从OKX获取
|
||||
print(f"从Binance获取数据失败,尝试从OKX获取{symbol}的K线数据...")
|
||||
|
||||
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: int = 200) -> pd.DataFrame:
|
||||
"""
|
||||
获取历史K线数据
|
||||
|
||||
@ -106,6 +106,7 @@ class BinanceAPI:
|
||||
limit=limit,
|
||||
klines_type=HistoricalKlinesType.FUTURES
|
||||
)
|
||||
print(f"Binance获取数据: {klines}")
|
||||
|
||||
# 转换为DataFrame
|
||||
df = pd.DataFrame(klines, columns=[
|
||||
|
||||
@ -4,7 +4,7 @@ services:
|
||||
cryptoai-task:
|
||||
build: .
|
||||
container_name: cryptoai-task
|
||||
image: cryptoai:0.0.17
|
||||
image: cryptoai:0.0.18
|
||||
restart: always
|
||||
volumes:
|
||||
- ./cryptoai/data:/app/cryptoai/data
|
||||
|
||||
12
test.py
12
test.py
@ -5,6 +5,16 @@ from time import sleep
|
||||
from cryptoai.models.token import TokenManager
|
||||
from cryptoai.utils.db_manager import get_db_context
|
||||
from cryptoai.tasks.user import task_run
|
||||
from cryptoai.agents.crypto_agent import CryptoAgent
|
||||
|
||||
if __name__ == "__main__":
|
||||
task_run()
|
||||
CryptoAgent().start_agent()
|
||||
|
||||
# data = get_binance_api().get_historical_klines(
|
||||
# symbol="BTCUSDT",
|
||||
# interval="1h",
|
||||
# start_str="2024-01-01",
|
||||
# end_str="2024-01-02",
|
||||
# limit=100
|
||||
# )
|
||||
# print(data)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user