mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
grid2: use profit to buy more inventory
This commit is contained in:
parent
d5cf1a7311
commit
9bb628328c
|
@ -142,6 +142,10 @@ func (s *Strategy) handleOrderFilled(o types.Order) {
|
||||||
newPrice = fixedpoint.Value(pin)
|
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:
|
case types.SideTypeBuy:
|
||||||
newSide = types.SideTypeSell
|
newSide = types.SideTypeSell
|
||||||
if pin, ok := s.grid.NextHigherPin(newPrice); ok {
|
if pin, ok := s.grid.NextHigherPin(newPrice); ok {
|
||||||
|
@ -156,8 +160,8 @@ func (s *Strategy) handleOrderFilled(o types.Order) {
|
||||||
Price: newPrice,
|
Price: newPrice,
|
||||||
Side: newSide,
|
Side: newSide,
|
||||||
TimeInForce: types.TimeInForceGTC,
|
TimeInForce: types.TimeInForceGTC,
|
||||||
Tag: "grid",
|
|
||||||
Quantity: newQuantity,
|
Quantity: newQuantity,
|
||||||
|
Tag: "grid",
|
||||||
}
|
}
|
||||||
|
|
||||||
s.logger.Infof("SUBMIT ORDER: %s", orderForm.String())
|
s.logger.Infof("SUBMIT ORDER: %s", orderForm.String())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user