mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
Merge pull request #991 from andycheng123/fix/risk
fix/risk: remove balance check in CalculateBaseQuantity()
This commit is contained in:
commit
79c93e9a0f
|
@ -227,7 +227,6 @@ func CalculateBaseQuantity(session *ExchangeSession, market types.Market, price,
|
|||
}
|
||||
|
||||
baseBalance, hasBaseBalance := session.Account.Balance(market.BaseCurrency)
|
||||
quoteBalance, _ := session.Account.Balance(market.QuoteCurrency)
|
||||
balances := session.Account.Balances()
|
||||
|
||||
usingLeverage := session.Margin || session.IsolatedMargin || session.Futures || session.IsolatedFutures
|
||||
|
@ -321,12 +320,7 @@ func CalculateBaseQuantity(session *ExchangeSession, market types.Market, price,
|
|||
}
|
||||
|
||||
if session.Futures || session.IsolatedFutures {
|
||||
// TODO: get mark price here
|
||||
maxPositionQuantity := risk.CalculateMaxPosition(price, totalUsdValue, leverage)
|
||||
requiredPositionCost := risk.CalculatePositionCost(price, price, maxPositionQuantity, leverage, types.SideTypeSell)
|
||||
if quoteBalance.Available.Compare(requiredPositionCost) < 0 {
|
||||
return maxPositionQuantity, fmt.Errorf("margin total usd value %f is not enough, can not submit order", totalUsdValue.Float64())
|
||||
}
|
||||
|
||||
return maxPositionQuantity, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user