mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
types: add last update time field to orderbook
This commit is contained in:
parent
09592755cc
commit
915f2c7476
|
@ -2,6 +2,7 @@ package types
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
|
@ -13,6 +14,7 @@ type RBTOrderBook struct {
|
|||
Symbol string
|
||||
Bids *RBTree
|
||||
Asks *RBTree
|
||||
LastUpdateTime time.Time
|
||||
|
||||
loadCallbacks []func(book *RBTOrderBook)
|
||||
updateCallbacks []func(book *RBTOrderBook)
|
||||
|
@ -116,12 +118,14 @@ func (b *RBTOrderBook) updateBids(pvs PriceVolumeSlice) {
|
|||
func (b *RBTOrderBook) update(book SliceOrderBook) {
|
||||
b.updateBids(book.Bids)
|
||||
b.updateAsks(book.Asks)
|
||||
b.LastUpdateTime = time.Now()
|
||||
}
|
||||
|
||||
func (b *RBTOrderBook) load(book SliceOrderBook) {
|
||||
b.Reset()
|
||||
b.updateBids(book.Bids)
|
||||
b.updateAsks(book.Asks)
|
||||
b.LastUpdateTime = time.Now()
|
||||
}
|
||||
|
||||
func (b *RBTOrderBook) Copy() OrderBook {
|
||||
|
|
Loading…
Reference in New Issue
Block a user