-
Notifications
You must be signed in to change notification settings - Fork 0
/
message.go
121 lines (108 loc) · 2.18 KB
/
message.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Go ddfplus API
//
// Copyright 2019 Barchart.com, Inc. All rights reserved.
//
// This Source Code Form is subject to the terms of the GNU license
// available at https://github.com/barchart/go-ddfplus-api/blob/master/LICENSE.
package ddf
import "time"
type MessageType int
const (
BidAsk MessageType = iota
Refresh
Timestamp
Trade
)
type DDFMessageInfo struct {
BaseCode string
Exchange string
Delay int
Record byte
Subrecord byte
DayCode byte
Session byte
}
type Message interface {
Type() MessageType
}
type MessageBidAsk struct {
Symbol string
Info DDFMessageInfo
Bid float64
BidSize int64
Ask float64
AskSize int64
Timestamp time.Time
}
func (m MessageBidAsk) Type() MessageType {
return BidAsk
}
type MessageRefresh struct {
Symbol string
Name string
Exchange string
BaseCode string
PointValue float64
TickIncrement int
DDFExchange string
LastUpdate time.Time
Bid float64
BidSize int64
Ask float64
AskSize int64
CurrentSession struct {
Day string
Session string
Timestamp time.Time
Open float64
High float64
Low float64
Last float64
Previous float64
Settlement float64
TradeSize int64
Volume int64
OpenInterest int64
NumTrades int64
PriceVolume float64
TradeTime time.Time
Ticks string
}
PreviousSession struct {
Day string
Session string
Timestamp time.Time
Open float64
High float64
Low float64
Last float64
Previous float64
Settlement float64
TradeSize int64
Volume int64
OpenInterest int64
NumTrades int64
PriceVolume float64
TradeTime time.Time
Ticks string
}
}
func (m MessageRefresh) Type() MessageType {
return Refresh
}
type MessageTimestamp struct {
Timestamp time.Time
}
func (m MessageTimestamp) Type() MessageType {
return Timestamp
}
type MessageTrade struct {
Symbol string
Info DDFMessageInfo
Trade float64
TradeSize int64
Timestamp time.Time
}
func (m MessageTrade) Type() MessageType {
return Trade
}