mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
xmaker: keep rate reservation token
This commit is contained in:
parent
1b27c4e9c4
commit
3907f99e70
|
@ -99,6 +99,7 @@ type Strategy struct {
|
|||
activeMakerOrders *bbgo.LocalActiveOrderBook
|
||||
|
||||
hedgeErrorLimiter *rate.Limiter
|
||||
hedgeErrorRateReservation *rate.Reservation
|
||||
|
||||
orderStore *bbgo.OrderStore
|
||||
tradeCollector *bbgo.TradeCollector
|
||||
|
@ -510,12 +511,13 @@ func (s *Strategy) Hedge(ctx context.Context, pos fixedpoint.Value) {
|
|||
return
|
||||
}
|
||||
|
||||
/*
|
||||
if !s.hedgeErrorLimiter.Allow() {
|
||||
log.Warn("rate limit hit, not allowed to hedge again, skip")
|
||||
return
|
||||
if s.hedgeErrorRateReservation != nil {
|
||||
if !s.hedgeErrorRateReservation.OK() {
|
||||
return
|
||||
}
|
||||
time.Sleep(s.hedgeErrorRateReservation.Delay())
|
||||
s.hedgeErrorRateReservation = nil
|
||||
}
|
||||
*/
|
||||
|
||||
log.Infof("submitting %s hedge order %s %f", s.Symbol, side.String(), quantity.Float64())
|
||||
s.Notifiability.Notify("Submitting %s hedge order %s %f", s.Symbol, side.String(), quantity.Float64())
|
||||
|
@ -529,7 +531,7 @@ func (s *Strategy) Hedge(ctx context.Context, pos fixedpoint.Value) {
|
|||
})
|
||||
|
||||
if err != nil {
|
||||
s.hedgeErrorLimiter.Reserve()
|
||||
s.hedgeErrorRateReservation = s.hedgeErrorLimiter.Reserve()
|
||||
log.WithError(err).Errorf("market order submit error: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user