forked from marcos-gonalons/tradingview-scraper
/
types.go
42 lines (35 loc) · 948 Bytes
/
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
package tradingview
// SocketInterface ...
type SocketInterface interface {
AddSymbol(symbol string) error
RemoveSymbol(symbol string) error
Init() error
Close() error
}
// SocketMessage ...
type SocketMessage struct {
Message string `json:"m"`
Payload interface{} `json:"p"`
}
// QuoteMessage ...
type QuoteMessage struct {
Symbol string `mapstructure:"n"`
Status string `mapstructure:"s"`
Data *QuoteData `mapstructure:"v"`
}
// QuoteData ...
type QuoteData struct {
Timestamp *int64 `mapstructure:"lp_time"`
Price *float64 `mapstructure:"lp"`
Volume *float64 `mapstructure:"volume"`
Bid *float64 `mapstructure:"bid"`
Ask *float64 `mapstructure:"ask"`
}
// Flags ...
type Flags struct {
Flags []string `json:"flags"`
}
// OnReceiveDataCallback ...
type OnReceiveDataCallback func(symbol string, data *QuoteData)
// OnErrorCallback ...
type OnErrorCallback func(err error, context string)