a
This commit is contained in:
parent
651e736474
commit
a7e1e6ca0a
|
|
@ -883,7 +883,12 @@ const ConfigPanel = () => {
|
||||||
{currentAccountMeta && currentAccountMeta.status === 'active' ? (
|
{currentAccountMeta && currentAccountMeta.status === 'active' ? (
|
||||||
<div className="system-section">
|
<div className="system-section">
|
||||||
<div className="system-header">
|
<div className="system-header">
|
||||||
<h3 onClick={console.log(currentAccountMeta)}>我的交易进程(当前账号 #{accountId})</h3>
|
<h3>我的交易进程(当前账号 #{accountId})</h3>
|
||||||
|
<button type="button" className="system-btn" onClick={() => {
|
||||||
|
console.log(currentAccountMeta)
|
||||||
|
}} title="打印当前账号信息">
|
||||||
|
打印当前账号信息
|
||||||
|
</button>
|
||||||
<div className="system-status">
|
<div className="system-status">
|
||||||
<span className={`system-status-badge ${accountTradingStatus?.running ? 'running' : 'stopped'}`}>
|
<span className={`system-status-badge ${accountTradingStatus?.running ? 'running' : 'stopped'}`}>
|
||||||
{accountTradingStatus?.running ? '运行中' : '未运行/未知'}
|
{accountTradingStatus?.running ? '运行中' : '未运行/未知'}
|
||||||
|
|
|
||||||
|
|
@ -1294,8 +1294,13 @@ class PositionManager:
|
||||||
f"剩余数量: {remaining_quantity:.4f})"
|
f"剩余数量: {remaining_quantity:.4f})"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
new_stop_loss = entry_price - (remaining_pnl - protect_amount) / remaining_quantity
|
# 做空:止损价 = 开仓价 + (剩余盈亏 - 保护金额) / 剩余数量
|
||||||
if new_stop_loss < position_info['stopLoss']:
|
# 注意:对于做空,止损价应该高于开仓价,所以用加法
|
||||||
|
# 移动止损只应该在盈利时激活
|
||||||
|
new_stop_loss = entry_price + (remaining_pnl - protect_amount) / remaining_quantity
|
||||||
|
# 对于做空,止损价应该越来越高(更宽松),所以检查 new_stop_loss > 当前止损
|
||||||
|
# 同时,移动止损只应该在盈利时激活
|
||||||
|
if new_stop_loss > position_info['stopLoss'] and remaining_pnl > 0:
|
||||||
position_info['stopLoss'] = new_stop_loss
|
position_info['stopLoss'] = new_stop_loss
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{symbol} 移动止损更新(剩余仓位): {new_stop_loss:.4f} "
|
f"{symbol} 移动止损更新(剩余仓位): {new_stop_loss:.4f} "
|
||||||
|
|
@ -1317,9 +1322,14 @@ class PositionManager:
|
||||||
f"(保护{trailing_protect*100:.1f}% of margin = {protect_amount:.4f} USDT)"
|
f"(保护{trailing_protect*100:.1f}% of margin = {protect_amount:.4f} USDT)"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# 做空:止损价 = 开仓价 - (当前盈亏 - 保护金额) / 数量
|
# 做空:止损价 = 开仓价 + (当前盈亏 - 保护金额) / 数量
|
||||||
new_stop_loss = entry_price - (pnl_amount - protect_amount) / quantity
|
# 注意:对于做空,止损价应该高于开仓价,所以用加法
|
||||||
if new_stop_loss < position_info['stopLoss']:
|
# 当盈利时(pnl_amount > 0),止损价应该往上移(更宽松)
|
||||||
|
# 当亏损时(pnl_amount < 0),不应该移动止损(保持初始止损)
|
||||||
|
new_stop_loss = entry_price + (pnl_amount - protect_amount) / quantity
|
||||||
|
# 对于做空,止损价应该越来越高(更宽松),所以检查 new_stop_loss > 当前止损
|
||||||
|
# 同时,移动止损只应该在盈利时激活,不应该在亏损时把止损往下移
|
||||||
|
if new_stop_loss > position_info['stopLoss'] and pnl_amount > 0:
|
||||||
position_info['stopLoss'] = new_stop_loss
|
position_info['stopLoss'] = new_stop_loss
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{symbol} 移动止损更新: {new_stop_loss:.4f} "
|
f"{symbol} 移动止损更新: {new_stop_loss:.4f} "
|
||||||
|
|
@ -2488,9 +2498,14 @@ class PositionManager:
|
||||||
f"(保护{trailing_protect*100:.1f}% of margin = {protect_amount:.4f} USDT)"
|
f"(保护{trailing_protect*100:.1f}% of margin = {protect_amount:.4f} USDT)"
|
||||||
)
|
)
|
||||||
else: # SELL
|
else: # SELL
|
||||||
# 做空:止损价 = 开仓价 - (当前盈亏 - 保护金额) / 数量
|
# 做空:止损价 = 开仓价 + (当前盈亏 - 保护金额) / 数量
|
||||||
new_stop_loss = entry_price - (pnl_amount - protect_amount) / quantity
|
# 注意:对于做空,止损价应该高于开仓价,所以用加法
|
||||||
if new_stop_loss < position_info['stopLoss']:
|
# 当盈利时(pnl_amount > 0),止损价应该往上移(更宽松)
|
||||||
|
# 当亏损时(pnl_amount < 0),不应该移动止损(保持初始止损)
|
||||||
|
new_stop_loss = entry_price + (pnl_amount - protect_amount) / quantity
|
||||||
|
# 对于做空,止损价应该越来越高(更宽松),所以检查 new_stop_loss > 当前止损
|
||||||
|
# 同时,移动止损只应该在盈利时激活,不应该在亏损时把止损往下移
|
||||||
|
if new_stop_loss > position_info['stopLoss'] and pnl_amount > 0:
|
||||||
position_info['stopLoss'] = new_stop_loss
|
position_info['stopLoss'] = new_stop_loss
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{symbol} [实时监控] 移动止损更新: {new_stop_loss:.4f} "
|
f"{symbol} [实时监控] 移动止损更新: {new_stop_loss:.4f} "
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user