mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
pivotshort: quantity calculation -- sub debt
This commit is contained in:
parent
76def2fe9d
commit
54affd2f99
|
@ -374,16 +374,18 @@ func useQuantityOrBaseBalance(session *bbgo.ExchangeSession, market types.Market
|
||||||
}
|
}
|
||||||
|
|
||||||
// spot margin use the equity value, so we use the total quote balance here
|
// spot margin use the equity value, so we use the total quote balance here
|
||||||
maxPositionQuantity := risk.CalculateMaxPosition(price, accountValue, leverage)
|
maxPosition := risk.CalculateMaxPosition(price, accountValue, leverage)
|
||||||
|
debt := baseBalance.Debt()
|
||||||
|
|
||||||
log.Infof("margin leverage: calculated maxPositionQuantity=%f price=%f accountValue=%f %s leverage=%f",
|
log.Infof("margin leverage: calculated maxPosition=%f debt=%f price=%f accountValue=%f %s leverage=%f",
|
||||||
maxPositionQuantity.Float64(),
|
maxPosition.Float64(),
|
||||||
|
debt.Float64(),
|
||||||
price.Float64(),
|
price.Float64(),
|
||||||
accountValue.Float64(),
|
accountValue.Float64(),
|
||||||
market.QuoteCurrency,
|
market.QuoteCurrency,
|
||||||
leverage.Float64())
|
leverage.Float64())
|
||||||
|
|
||||||
return maxPositionQuantity, nil
|
return maxPosition.Sub(debt), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if session.Futures || session.IsolatedFutures {
|
if session.Futures || session.IsolatedFutures {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user