grid2: add earnBase option

This commit is contained in:
c9s 2022-12-03 16:40:40 +08:00
parent 5f7ad125c6
commit 64d8a30ecc
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -152,7 +152,7 @@ func (s *Strategy) handleOrderFilled(o types.Order) {
}
// use the profit to buy more inventory in the grid
if s.Compound {
if s.Compound || s.EarnBase {
quoteQuantity := o.Quantity.Mul(o.Price)
newQuantity = quoteQuantity.Div(newPrice)
}
@ -162,6 +162,11 @@ func (s *Strategy) handleOrderFilled(o types.Order) {
if pin, ok := s.grid.NextHigherPin(newPrice); ok {
newPrice = fixedpoint.Value(pin)
}
if s.EarnBase {
quoteQuantity := o.Quantity.Mul(o.Price)
newQuantity = quoteQuantity.Div(newPrice)
}
}
orderForm := types.SubmitOrder{