a
This commit is contained in:
parent
9442fb632b
commit
5030cbcc98
|
|
@ -202,6 +202,7 @@ defaults = {
|
||||||
'PRIMARY_INTERVAL': '1h',
|
'PRIMARY_INTERVAL': '1h',
|
||||||
'CONFIRM_INTERVAL': '4h',
|
'CONFIRM_INTERVAL': '4h',
|
||||||
'ENTRY_INTERVAL': '15m',
|
'ENTRY_INTERVAL': '15m',
|
||||||
|
'LIMIT_ORDER_OFFSET_PCT': 0.5, # 限价单偏移百分比(默认0.5%)
|
||||||
}
|
}
|
||||||
for key, value in defaults.items():
|
for key, value in defaults.items():
|
||||||
if key not in TRADING_CONFIG:
|
if key not in TRADING_CONFIG:
|
||||||
|
|
|
||||||
|
|
@ -282,6 +282,15 @@ class TradeRecommender:
|
||||||
position_multiplier = min(1.0 + (signal_strength - 5) * 0.1, 1.5)
|
position_multiplier = min(1.0 + (signal_strength - 5) * 0.1, 1.5)
|
||||||
suggested_position_pct = base_position_pct * position_multiplier
|
suggested_position_pct = base_position_pct * position_multiplier
|
||||||
|
|
||||||
|
# 计算建议的挂单价(使用限价单,而不是市价单)
|
||||||
|
# 对于做多:建议价格略低于当前价格(当前价格的99.5%),以便在回调时买入
|
||||||
|
# 对于做空:建议价格略高于当前价格(当前价格的100.5%),以便在反弹时卖出
|
||||||
|
limit_price_offset_pct = config.TRADING_CONFIG.get('LIMIT_ORDER_OFFSET_PCT', 0.5) # 默认0.5%
|
||||||
|
if direction == 'BUY':
|
||||||
|
suggested_limit_price = current_price * (1 - limit_price_offset_pct / 100)
|
||||||
|
else: # SELL
|
||||||
|
suggested_limit_price = current_price * (1 + limit_price_offset_pct / 100)
|
||||||
|
|
||||||
# 准备推荐数据
|
# 准备推荐数据
|
||||||
recommendation_data = {
|
recommendation_data = {
|
||||||
'symbol': symbol,
|
'symbol': symbol,
|
||||||
|
|
@ -307,7 +316,9 @@ class TradeRecommender:
|
||||||
'suggested_position_percent': suggested_position_pct,
|
'suggested_position_percent': suggested_position_pct,
|
||||||
'suggested_leverage': config.TRADING_CONFIG.get('LEVERAGE', 10),
|
'suggested_leverage': config.TRADING_CONFIG.get('LEVERAGE', 10),
|
||||||
'volume_24h': symbol_info.get('volume24h'),
|
'volume_24h': symbol_info.get('volume24h'),
|
||||||
'volatility': symbol_info.get('volatility')
|
'volatility': symbol_info.get('volatility'),
|
||||||
|
'order_type': 'LIMIT', # 使用限价单
|
||||||
|
'suggested_limit_price': suggested_limit_price # 建议的挂单价
|
||||||
}
|
}
|
||||||
|
|
||||||
# 不再自动保存到数据库,只返回推荐数据
|
# 不再自动保存到数据库,只返回推荐数据
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user