redis 入场信号记录更多信息
This commit is contained in:
parent
12773a40a5
commit
e6ff91504b
@ -954,7 +954,19 @@ class FreqaiPrimer(IStrategy):
|
||||
# 获取Redis客户端
|
||||
redis_client = self._get_redis_client()
|
||||
if redis_client:
|
||||
# 准备要存储的信号数据
|
||||
# 构建详细的条件分析
|
||||
detailed_conditions = []
|
||||
for name, value, operator, threshold, result in conditions_summary:
|
||||
condition_detail = {
|
||||
'name': name,
|
||||
'value': float(value) if value is not None else None,
|
||||
'threshold': float(threshold) if threshold is not None else None,
|
||||
'operator': operator,
|
||||
'satisfied': bool(result)
|
||||
}
|
||||
detailed_conditions.append(condition_detail)
|
||||
|
||||
# 准备要存储的详细信号数据
|
||||
signal_data = {
|
||||
'signal_strength': float(dataframe.loc[last_idx, 'signal_strength']) if 'signal_strength' in dataframe.columns else 0.0,
|
||||
'entry_tag': str(dataframe.loc[last_idx, 'entry_tag']) if 'entry_tag' in dataframe.columns else str(entry_tag),
|
||||
@ -963,14 +975,39 @@ class FreqaiPrimer(IStrategy):
|
||||
'timestamp': timestamp_ms,
|
||||
'pair': str(pair),
|
||||
'hostname': str(hostname),
|
||||
'immediate_entry': bool(dataframe.loc[last_idx, 'immediate_entry']) if 'immediate_entry' in dataframe.columns else False
|
||||
'immediate_entry': bool(dataframe.loc[last_idx, 'immediate_entry']) if 'immediate_entry' in dataframe.columns else False,
|
||||
'conditions_analysis': {
|
||||
'total_conditions': len(conditions_summary),
|
||||
'satisfied_count': sum(1 for _, _, _, _, result in conditions_summary if result),
|
||||
'failed_count': sum(1 for _, _, _, _, result in conditions_summary if not result),
|
||||
'detailed_conditions': detailed_conditions
|
||||
},
|
||||
'current_market_data': {
|
||||
'close_price': float(dataframe.loc[last_idx, 'close']),
|
||||
'ema50': float(dataframe.loc[last_idx, 'ema50']) if 'ema50' in dataframe.columns else None,
|
||||
'ema200': float(dataframe.loc[last_idx, 'ema200']) if 'ema200' in dataframe.columns else None,
|
||||
'bb_lower': float(dataframe.loc[last_idx, 'bb_lowerband']) if 'bb_lowerband' in dataframe.columns else None,
|
||||
'bb_upper': float(dataframe.loc[last_idx, 'bb_upperband']) if 'bb_upperband' in dataframe.columns else None,
|
||||
'rsi': float(dataframe.loc[last_idx, 'rsi']) if 'rsi' in dataframe.columns else None,
|
||||
'volume': float(dataframe.loc[last_idx, 'volume']) if 'volume' in dataframe.columns else None
|
||||
},
|
||||
'strategy_parameters': {
|
||||
'buy_threshold_min': float(self.buy_threshold_min),
|
||||
'buy_threshold_max': float(self.buy_threshold_max),
|
||||
'trend_bullish_threshold': int(self.TREND_BULLISH_THRESHOLD),
|
||||
'trend_bearish_threshold': int(self.TREND_BEARISH_THRESHOLD),
|
||||
'green_channel_discount': float(self.GREEN_CHANNEL_DISCOUNT),
|
||||
'entry_discount_bull_normal': float(self.entry_discount_bull_normal.value),
|
||||
'entry_discount_ranging': float(self.entry_discount_ranging.value),
|
||||
'entry_discount_bearish': float(self.entry_discount_bearish.value)
|
||||
}
|
||||
}
|
||||
|
||||
# 将信号数据序列化为JSON字符串
|
||||
signal_json = json.dumps(signal_data)
|
||||
signal_json = json.dumps(signal_data, ensure_ascii=False, indent=2)
|
||||
|
||||
# 存储到Redis,设置24小时过期时间
|
||||
redis_client.setex(redis_key, 86400, signal_json)
|
||||
# 存储到Redis,设置300天过期时间(25920000秒)
|
||||
redis_client.setex(redis_key, 25920000, signal_json)
|
||||
|
||||
logger.info(f"[Redis] ✅ 实际入场信号已记录: {redis_key}, 信号强度: {signal_data['signal_strength']:.2f}, 趋势: {signal_data['entry_tag']}")
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user