mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
bbgo: optimize AdjustQuantityByMaxAmount, early return
This commit is contained in:
parent
31358a69d1
commit
8ada9eef02
|
@ -18,12 +18,12 @@ var (
|
|||
func AdjustQuantityByMaxAmount(quantity, currentPrice, maxAmount fixedpoint.Value) fixedpoint.Value {
|
||||
// modify quantity for the min amount
|
||||
amount := currentPrice.Mul(quantity)
|
||||
if amount > maxAmount {
|
||||
ratio := maxAmount.Div(amount)
|
||||
quantity = quantity.Mul(ratio)
|
||||
if amount < maxAmount {
|
||||
return quantity
|
||||
}
|
||||
|
||||
return quantity
|
||||
ratio := maxAmount.Div(amount)
|
||||
return quantity.Mul(ratio)
|
||||
}
|
||||
|
||||
// AdjustQuantityByMinAmount adjusts the quantity to make the amount greater than the given minAmount
|
||||
|
|
Loading…
Reference in New Issue
Block a user