This commit is contained in:
薇薇安 2026-01-17 21:33:20 +08:00
parent 098132bda6
commit 39e6a46bd3
3 changed files with 57 additions and 18 deletions

View File

@ -447,12 +447,32 @@
grid-column: span 2;
}
.param-item.limit-price.highlight {
background-color: #e3f2fd;
border: 2px solid #2196F3;
border-radius: 6px;
padding: 10px;
margin: 5px 0;
}
.param-item.limit-price.highlight label {
color: #1976d2;
font-weight: bold;
font-size: 13px;
}
.limit-price-value {
display: flex;
flex-direction: column;
gap: 4px;
}
.limit-price-value.highlight-price {
font-size: 18px;
font-weight: bold;
color: #1976d2;
}
.price-diff {
font-size: 11px;
color: #666;

View File

@ -377,14 +377,14 @@ function Recommendations() {
<div className="suggested-params">
<div className="param-item order-type">
<label>订单类型:</label>
<span className={`order-type-badge ${(rec.order_type || 'LIMIT').toLowerCase()}`}>
{rec.order_type === 'LIMIT' ? '限价单' : '市价单'}
<span className="order-type-badge limit">
限价单
</span>
</div>
{rec.order_type === 'LIMIT' && rec.suggested_limit_price && (
<div className="param-item limit-price">
{rec.suggested_limit_price && (
<div className="param-item limit-price highlight">
<label>建议挂单价:</label>
<span className="limit-price-value">
<span className="limit-price-value highlight-price">
{parseFloat(rec.suggested_limit_price || 0).toFixed(4)} USDT
{rec.current_price && (
<span className="price-diff">

View File

@ -466,7 +466,7 @@ class TradeRecommender:
# 生成用户指南(人话版计划)
user_guide = self._generate_user_guide(
symbol, direction, suggested_limit_price, stop_loss_price, take_profit_1, take_profit_2,
simple_reason, expected_hold_time, risk_warning, recommendation_category
simple_reason, expected_hold_time, risk_warning, recommendation_category, current_price
)
# 基础推荐数据
@ -512,27 +512,20 @@ class TradeRecommender:
'max_hold_days': 3 # 最大持仓天数(超过此天数建议平仓)
}
# 限价单推荐
# 限价单推荐(唯一推荐类型)
limit_recommendation = base_data.copy()
limit_recommendation.update({
'order_type': 'LIMIT',
'suggested_limit_price': suggested_limit_price
})
# 市价单推荐
market_recommendation = base_data.copy()
market_recommendation.update({
'order_type': 'MARKET',
'suggested_limit_price': None
})
logger.debug(
f"✓ 生成推荐: {symbol} {direction} "
f"(信号强度: {signal_strength}/10, 胜率预估: {estimated_win_rate:.1f}%, "
f"分类: {recommendation_category}, 风险: {risk_level})"
)
return [limit_recommendation, market_recommendation]
return [limit_recommendation]
except Exception as e:
logger.error(f"创建推荐失败 {symbol_info.get('symbol', 'unknown')}: {e}", exc_info=True)
@ -641,7 +634,8 @@ class TradeRecommender:
simple_reason: str,
expected_hold_time: str,
risk_warning: str,
category: str
category: str,
current_price: float
) -> str:
"""
生成用户指南人话版计划
@ -657,27 +651,52 @@ class TradeRecommender:
expected_hold_time: 预期持仓时间
risk_warning: 风险警告
category: 推荐分类
current_price: 当前价格用于计算反向波动
Returns:
用户指南文本
"""
direction_cn = "买入" if direction == 'BUY' else "卖出"
direction_action = "挂单买入" if direction == 'BUY' else "挂单卖出"
# 计算反向波动阈值2%
if direction == 'BUY':
# 买单如果价格下跌超过2%,建议取消
reverse_threshold = current_price * 0.98
reverse_direction = "下跌"
else:
# 卖单如果价格上涨超过2%,建议取消
reverse_threshold = current_price * 1.02
reverse_direction = "上涨"
user_guide = f"""【操作计划】{direction_cn} {symbol}
推荐类型{category}
核心理由{simple_reason}
明确的入场价
建议在 {limit_price:.4f} USDT 附近{direction_action}
具体点位
入场价限价单: {limit_price:.4f} USDT
建议挂单价: {limit_price:.4f} USDT
止损价: {stop_loss:.4f} USDT
第一目标: {tp1:.4f} USDT盈亏比1:1
第二目标: {tp2:.4f} USDT盈亏比2.5:1
持仓周期{expected_hold_time}
退出条件
触及止损立即平仓
触及第一目标可部分止盈或全部止盈
触及第二目标建议全部止盈
持仓超过3天未触及第一目标建议平仓离场重新评估
关键提醒{risk_warning}"""
订单失效条件
此限价单建议当日有效若价格未触及挂单价但价格直接{reverse_direction}超过2%{reverse_threshold:.4f} USDT则建议取消订单等待新信号
关键提醒{risk_warning}
给主动交易者的提示
如果您确信趋势已启动也可考虑以市价单立即入场但需承受更高滑点成本且务必设置好止损"""
return user_guide