mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 17:13:51 +00:00
ktrade: rounding instead of ceil/floor
This commit is contained in:
parent
1cc285985c
commit
49f7c3de46
|
@ -60,14 +60,14 @@ func (s *Minute) Bind(session *bbgo.ExchangeSession, orderExecutor *bbgo.General
|
|||
// update ask price
|
||||
newAskPrice := s.midPrice.Mul(fixedpoint.NewFromFloat(0.25)).Add(trade.Price.Mul(fixedpoint.NewFromFloat(0.75)))
|
||||
log.Infof("short @ %f", newAskPrice.Float64())
|
||||
s.placeOrder(context.Background(), types.SideTypeSell, s.Quantity, newAskPrice.Ceil(), symbol)
|
||||
s.placeOrder(context.Background(), types.SideTypeSell, s.Quantity, newAskPrice.Round(2, 1), symbol)
|
||||
|
||||
} else if trade.Side == types.SideTypeSell && trade.Price.Compare(s.midPrice) < 0 && trade.Price.Compare(bestBid.Price) >= 0 {
|
||||
_ = s.orderExecutor.GracefulCancel(context.Background())
|
||||
// update bid price
|
||||
newBidPrice := s.midPrice.Mul(fixedpoint.NewFromFloat(0.25)).Add(trade.Price.Mul(fixedpoint.NewFromFloat(0.75)))
|
||||
log.Infof("long @ %f", newBidPrice.Float64())
|
||||
s.placeOrder(context.Background(), types.SideTypeBuy, s.Quantity, newBidPrice.Floor(), symbol)
|
||||
s.placeOrder(context.Background(), types.SideTypeBuy, s.Quantity, newBidPrice.Round(2, 1), symbol)
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user