From 9bb628328c25949bd3f277abd55f60aeed81add3 Mon Sep 17 00:00:00 2001 From: c9s Date: Sat, 3 Dec 2022 15:18:47 +0800 Subject: [PATCH] grid2: use profit to buy more inventory --- pkg/strategy/grid2/strategy.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/strategy/grid2/strategy.go b/pkg/strategy/grid2/strategy.go index c7dc66d9b..41638fbc9 100644 --- a/pkg/strategy/grid2/strategy.go +++ b/pkg/strategy/grid2/strategy.go @@ -142,6 +142,10 @@ func (s *Strategy) handleOrderFilled(o types.Order) { newPrice = fixedpoint.Value(pin) } + // use the profit to buy more inventory in the grid + quoteQuantity := o.Quantity.Mul(o.Price) + newQuantity = quoteQuantity.Div(newPrice) + case types.SideTypeBuy: newSide = types.SideTypeSell if pin, ok := s.grid.NextHigherPin(newPrice); ok { @@ -156,8 +160,8 @@ func (s *Strategy) handleOrderFilled(o types.Order) { Price: newPrice, Side: newSide, TimeInForce: types.TimeInForceGTC, - Tag: "grid", Quantity: newQuantity, + Tag: "grid", } s.logger.Infof("SUBMIT ORDER: %s", orderForm.String())