-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.go
39 lines (34 loc) · 1.07 KB
/
model.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// internal/models/orderbook.go
package models
import (
"sync"
"time"
)
type OrderBookEntry struct {
Price float64 `json:"price"`
Quantity float64 `json:"quantity"`
Timestamp time.Time `json:"timestamp"`
}
type OrderBook struct {
Symbol string `json:"symbol"`
LastUpdateID int64 `json:"last_update_id"`
Bids []OrderBookEntry `json:"bids"`
Asks []OrderBookEntry `json:"asks"`
Timestamp time.Time `json:"timestamp"`
mutex sync.RWMutex
}
type OrderBookUpdate struct {
Symbol string `json:"symbol"`
UpdateID int64 `json:"update_id"`
Bids []OrderBookEntry `json:"bids"`
Asks []OrderBookEntry `json:"asks"`
Timestamp time.Time `json:"timestamp"`
}
// OrderBookSnapshot represents a point-in-time copy of the order book
type OrderBookSnapshot struct {
Symbol string `json:"symbol"`
Sequence int64 `json:"sequence"`
Bids []OrderBookEntry `json:"bids"`
Asks []OrderBookEntry `json:"asks"`
Timestamp time.Time `json:"timestamp"`
}