fix issue

This commit is contained in:
zhangkun9038@dingtalk.com 2025-11-25 21:16:30 +08:00
parent 2efedb9745
commit 9afa0af10b

View File

@ -66,7 +66,7 @@ class SmartBBGrid(IStrategy):
TARGET_ORDERS_PER_PAIR = 27 # 中位数
# 1. 拿到当前钱包总余额
total_balance = self.wallets.get_total_stake_amount()
total_balance = self.wallets.get_total('stake')
# 2. 定义每个币对的资金占比
weights = {
@ -78,8 +78,15 @@ class SmartBBGrid(IStrategy):
# 3. 该币对应该占的总金额
target_for_this_pair = total_balance * weights.get(pair, 0.33)
# 4. 该币对已经占了多少
used_for_this_pair = self.wallets.get_used_for_pair(pair)
# 4. 该币对已经占了多少(通过遍历 self.trades
used_for_this_pair = 0
for trade in self.trades:
if trade.pair == pair and not trade.is_open:
# 已平仓的订单不算
continue
if trade.pair == pair:
# 计算该订单占用的资金
used_for_this_pair += trade.stake_amount
# 5. 还剩多少可以投入
available = target_for_this_pair - used_for_this_pair