forked from thrasher-corp/gocryptotrader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ticker_types.go
65 lines (57 loc) · 1.79 KB
/
ticker_types.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package ticker
import (
"sync"
"time"
"github.com/gofrs/uuid"
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/dispatch"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
)
// const values for the ticker package
const (
ErrExchangeNameUnset = "ticker exchange name not set"
errPairNotSet = "ticker currency pair not set"
errAssetTypeNotSet = "ticker asset type not set"
errTickerPriceIsNil = "ticker price is nil"
)
// Vars for the ticker package
var (
service *Service
)
// Service holds ticker information for each individual exchange
type Service struct {
Tickers map[string]map[*currency.Item]map[*currency.Item]map[asset.Item]*Ticker
Exchange map[string]uuid.UUID
mux *dispatch.Mux
sync.Mutex
}
// Price struct stores the currency pair and pricing information
type Price struct {
Last float64 `json:"Last"`
High float64 `json:"High"`
Low float64 `json:"Low"`
Bid float64 `json:"Bid"`
Ask float64 `json:"Ask"`
Volume float64 `json:"Volume"`
QuoteVolume float64 `json:"QuoteVolume"`
PriceATH float64 `json:"PriceATH"`
Open float64 `json:"Open"`
Close float64 `json:"Close"`
Pair currency.Pair `json:"Pair"`
ExchangeName string `json:"exchangeName"`
AssetType asset.Item `json:"assetType"`
LastUpdated time.Time
// Funding rate field variables
FlashReturnRate float64
BidPeriod float64
BidSize float64
AskPeriod float64
AskSize float64
FlashReturnRateAmount float64
}
// Ticker struct holds the ticker information for a currency pair and type
type Ticker struct {
Price
Main uuid.UUID
Assoc []uuid.UUID
}