mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
xdepthmaker: add lastOrderReplenishTime to prevent replacing orders too frequent
This commit is contained in:
parent
de7eb8453b
commit
cedd790066
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user