fix dryrun.sh & import redis

This commit is contained in:
Ubuntu 2025-08-14 21:35:22 +08:00
parent bf3fa8cf25
commit 9e4ed2be25
3 changed files with 7 additions and 25 deletions

View File

@ -34,11 +34,11 @@
"LDO/USDT",
"LINK/USDT",
"LTC/USDT",
"OKB/USDT",
"OP/USDT",
"PENGU/USDT",
"PEPE/USDT",
"PI/USDT",
"RAY/USDT",
"SOL/USDT",
"SUI/USDT",
"TON/USDT",

View File

@ -5,6 +5,7 @@ import datetime
import os
import json
import glob
import redis
from functools import reduce
from freqtrade.persistence import Trade
import talib.abstract as ta
@ -12,6 +13,7 @@ from pandas import DataFrame
import pandas as pd
from typing import Dict
from freqtrade.strategy import (DecimalParameter, IStrategy, IntParameter)
from datetime import datetime
logger = logging.getLogger(__name__)
@ -1042,8 +1044,7 @@ class FreqaiPrimer(IStrategy):
"""
获取趋势得分优先从 Redis 缓存中读取如果缓存未命中则计算并存储到 Redis
"""
import redis
from datetime import datetime
# 创建 Redis 客户端
if not hasattr(self, 'redis_client') and self.redis_url:
@ -1093,9 +1094,9 @@ class FreqaiPrimer(IStrategy):
# 获取历史数据片段
hist_df = dataframe.iloc[:i+1] if i != -1 else dataframe
if len(hist_df) > 0:
# 使用新的 get_trend_score_with_cache 方法替代直接调用 get_market_trend
timestamp = int(hist_df.index[-1].timestamp()) # 获取时间戳
score = self.get_trend_score_with_cache(pair=pair, timeframe=self.timeframe, timestamp=timestamp, dataframe=hist_df, metadata=metadata)
# 使用新的 get_trend_score_with_cache 方法替代直接调用 get_market_trend
timestamp = int(hist_df.index[-1].timestamp()) # 获取时间戳
score = self.get_trend_score_with_cache(pair=pair, timeframe=self.timeframe, timestamp=timestamp, dataframe=hist_df, metadata=metadata)
trend_scores_20.append(score)
else:
trend_scores_20.append(50) # 默认值

View File

@ -237,24 +237,6 @@ echo "准备启动容器: $CONTAINER_NAME" >&2
remove_existing_container "$CONTAINER_NAME"
# 启动新容器
echo "启动容器: $CONTAINER_NAME" >&2
docker-compose run -d --rm \
--name "$CONTAINER_NAME" \
-p 8080:8080 \
freqtrade trade \
--logfile /freqtrade/user_data/logs/freqtrade.log \
--db-url sqlite:////freqtrade/user_data/tradesv3.sqlite \
--freqaimodel LightGBMRegressorMultiTarget \
--fee 0.0008 \
--dry-run \
--config /freqtrade/config_examples/$CONFIG_FILE \
--config /freqtrade/templates/${PARAMS_NAME}.json \
--config /freqtrade/config_examples/live.json \
--strategy $STRATEGY_NAME \
--config /freqtrade/freqtrade/templates/${STRATEGY_NAME}.json \
--fee 0.0008 \
--strategy-path /freqtrade/templates"
docker-compose run -d --rm --name freqtrade-dryrun-${GIT_COMMIT_SHORT} -p 8080:8080 freqtrade trade \
$PAIRS_FLAG \
--logfile /freqtrade/user_data/logs/freqtrade.log \
@ -262,7 +244,6 @@ docker-compose run -d --rm --name freqtrade-dryrun-${GIT_COMMIT_SHORT} -p 8080:8
--dry-run \
--freqaimodel LightGBMRegressorMultiTarget \
--config /freqtrade/config_examples/$CONFIG_FILE \
--enable-protections \
--strategy $STRATEGY_NAME \
--fee 0.0008 \
--strategy-path /freqtrade/templates