Skip to content

Commit e09e2df

Browse files
authored
Merge pull request #834 from c9s/strategy/pivotshort
fix: strategy/pivotshort: add trade loss to the account value calculation
2 parents 8c61f68 + 15879ad commit e09e2df

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/strategy/pivotshort/breaklow.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,14 @@ func useQuantityOrBaseBalance(session *bbgo.ExchangeSession, market types.Market
261261
baseBalanceValue := baseBalance.Net().Mul(price)
262262
accountValue := baseBalanceValue.Add(quoteBalance.Net())
263263

264+
// avoid using all account value since there will be some trade loss for interests and the fee
265+
accountValue = accountValue.Mul(one.Sub(fixedpoint.NewFromFloat(0.01)))
266+
264267
log.Infof("calculated account value %f %s", accountValue.Float64(), market.QuoteCurrency)
265268

266269
if session.IsolatedMargin {
267270
originLeverage := leverage
268-
leverage = fixedpoint.Max(leverage, fixedpoint.NewFromInt(10))
271+
leverage = fixedpoint.Min(leverage, fixedpoint.NewFromInt(10)) // max leverage is 10
269272
log.Infof("using isolated margin, maxLeverage=10 originalLeverage=%f currentLeverage=%f",
270273
originLeverage.Float64(),
271274
leverage.Float64())

0 commit comments

Comments
 (0)