-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathstreaming_domain.go
102 lines (85 loc) · 2.89 KB
/
streaming_domain.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package sdk
import "time"
const MaxOrderbookDepth = 20
type CandleInterval string
const (
CandleInterval1Min CandleInterval = "1min"
CandleInterval2Min CandleInterval = "2min"
CandleInterval3Min CandleInterval = "3min"
CandleInterval5Min CandleInterval = "5min"
CandleInterval10Min CandleInterval = "10min"
CandleInterval15Min CandleInterval = "15min"
CandleInterval30Min CandleInterval = "30min"
CandleInterval1Hour CandleInterval = "hour"
CandleInterval2Hour CandleInterval = "2hour"
CandleInterval4Hour CandleInterval = "4hour"
CandleInterval1Day CandleInterval = "day"
CandleInterval1Week CandleInterval = "week"
CandleInterval1Month CandleInterval = "month"
)
type TradingStatus string
const (
BreakInTrading TradingStatus = "BreakInTrading"
NormalTrading TradingStatus = "NormalTrading"
NotAvailableForTrading TradingStatus = "NotAvailableForTrading"
ClosingAuction TradingStatus = "ClosingAuction"
ClosingPeriod TradingStatus = "ClosingPeriod"
DarkPoolAuction TradingStatus = "DarkPoolAuction"
DiscreteAuction TradingStatus = "DiscreteAuction"
OpeningPeriod TradingStatus = "OpeningPeriod"
OpeningAuctionPeriod TradingStatus = "OpeningAuctionPeriod"
TradingAtClosingAuctionPrice TradingStatus = "TradingAtClosingAuctionPrice"
)
type Event struct {
Name string `json:"event"`
}
type FullEvent struct {
Name string `json:"event"`
Time time.Time `json:"time"`
}
type CandleEvent struct {
FullEvent
Candle Candle `json:"payload"`
}
type Candle struct {
FIGI string `json:"figi"`
Interval CandleInterval `json:"interval"`
OpenPrice float64 `json:"o"`
ClosePrice float64 `json:"c"`
HighPrice float64 `json:"h"`
LowPrice float64 `json:"l"`
Volume float64 `json:"v"`
TS time.Time `json:"time"`
}
type OrderBookEvent struct {
FullEvent
OrderBook OrderBook `json:"payload"`
}
type OrderBook struct {
FIGI string `json:"figi"`
Depth int `json:"depth"`
Bids []PriceQuantity `json:"bids"`
Asks []PriceQuantity `json:"asks"`
}
type PriceQuantity [2]float64 // 0 - price, 1 - quantity
type InstrumentInfoEvent struct {
FullEvent
Info InstrumentInfo `json:"payload"`
}
type InstrumentInfo struct {
FIGI string `json:"figi"`
TradeStatus TradingStatus `json:"trade_status"`
MinPriceIncrement float64 `json:"min_price_increment"`
Lot float64 `json:"lot"`
AccruedInterest float64 `json:"accrued_interest,omitempty"`
LimitUp float64 `json:"limit_up,omitempty"`
LimitDown float64 `json:"limit_down,omitempty"`
}
type ErrorEvent struct {
FullEvent
Error Error `json:"payload"`
}
type Error struct {
RequestID string `json:"request_id,omitempty"`
Error string `json:"error"`
}