mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-13 02:23:51 +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)
|
s.updateQuote(ctx, 0)
|
||||||
|
|
||||||
|
lastOrderReplenishTime := time.Now()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
|
||||||
|
@ -412,6 +413,7 @@ func (s *Strategy) CrossRun(
|
||||||
|
|
||||||
case <-fullReplenishTicker.C:
|
case <-fullReplenishTicker.C:
|
||||||
s.updateQuote(ctx, 0)
|
s.updateQuote(ctx, 0)
|
||||||
|
lastOrderReplenishTime = time.Now()
|
||||||
|
|
||||||
case sig, ok := <-s.pricingBook.C:
|
case sig, ok := <-s.pricingBook.C:
|
||||||
// when any book change event happened
|
// when any book change event happened
|
||||||
|
@ -419,6 +421,10 @@ func (s *Strategy) CrossRun(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if time.Since(lastOrderReplenishTime) < time.Minute {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
switch sig.Type {
|
switch sig.Type {
|
||||||
case types.BookSignalSnapshot:
|
case types.BookSignalSnapshot:
|
||||||
s.updateQuote(ctx, 0)
|
s.updateQuote(ctx, 0)
|
||||||
|
@ -427,6 +433,8 @@ func (s *Strategy) CrossRun(
|
||||||
s.updateQuote(ctx, 5)
|
s.updateQuote(ctx, 5)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastOrderReplenishTime = time.Now()
|
||||||
|
|
||||||
case <-posTicker.C:
|
case <-posTicker.C:
|
||||||
// For positive position and positive covered position:
|
// For positive position and positive covered position:
|
||||||
// uncover position = +5 - +3 (covered position) = 2
|
// uncover position = +5 - +3 (covered position) = 2
|
||||||
|
|
Loading…
Reference in New Issue
Block a user