xdepthmaker: add lastOrderReplenishTime to prevent replacing orders too frequent

This commit is contained in:
c9s 2023-12-11 17:02:17 +08:00
parent de7eb8453b
commit cedd790066
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -399,6 +399,7 @@ func (s *Strategy) CrossRun(
s.updateQuote(ctx, 0)
lastOrderReplenishTime := time.Now()
for {
select {
@ -412,6 +413,7 @@ func (s *Strategy) CrossRun(
case <-fullReplenishTicker.C:
s.updateQuote(ctx, 0)
lastOrderReplenishTime = time.Now()
case sig, ok := <-s.pricingBook.C:
// when any book change event happened
@ -419,6 +421,10 @@ func (s *Strategy) CrossRun(
return
}
if time.Since(lastOrderReplenishTime) < time.Minute {
continue
}
switch sig.Type {
case types.BookSignalSnapshot:
s.updateQuote(ctx, 0)
@ -427,6 +433,8 @@ func (s *Strategy) CrossRun(
s.updateQuote(ctx, 5)
}
lastOrderReplenishTime = time.Now()
case <-posTicker.C:
// For positive position and positive covered position:
// uncover position = +5 - +3 (covered position) = 2