-
Notifications
You must be signed in to change notification settings - Fork 3
/
investors_exchange_data.go
209 lines (188 loc) · 5.79 KB
/
investors_exchange_data.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
package goiex
import (
"net/http"
"net/url"
)
// InvestorsExchangeData struct to interface with InvestorsExchangeData endpoints
type InvestorsExchangeData struct {
iex
}
// TOPSParams required/optional query parameters
type TOPSParams struct {
Symbols string `url:"symbols"`
}
// LastParams required/optional query parameters
type LastParams struct {
Symbols string `url:"symbols"`
}
// DEEPParams required/optional query parameters
type DEEPParams struct {
Symbols string `url:"symbols"`
}
// TOPS struct
type TOPS []struct {
Symbol string `json:"symbol"`
BidSize int `json:"bidSize"`
BidPrice float64 `json:"bidPrice"`
AskSize int `json:"askSize"`
AskPrice float64 `json:"askPrice"`
Volume int `json:"volume"`
LastSalePrice float64 `json:"lastSalePrice"`
LastSaleSize int `json:"lastSaleSize"`
LastSaleTime int64 `json:"lastSaleTime"`
LastUpdated int64 `json:"lastUpdated"`
Sector string `json:"sector"`
SecurityType string `json:"securityType"`
}
// Last struct
type Last []struct {
Symbol string `json:"symbol"`
Price float64 `json:"price"`
Size int `json:"size"`
Time int64 `json:"time"`
}
// DEEP struct
type DEEP struct {
Symbol string `json:"symbol"`
MarketPercent float64 `json:"marketPercent"`
Volume int `json:"volume"`
LastSalePrice float64 `json:"lastSalePrice"`
LastSaleSize int `json:"lastSaleSize"`
LastSaleTime int64 `json:"lastSaleTime"`
LastUpdated int64 `json:"lastUpdated"`
Bids []struct {
Price float64 `json:"price"`
Size int `json:"size"`
Timestamp int64 `json:"timestamp"`
} `json:"bids"`
Asks []struct {
Price float64 `json:"price"`
Size int `json:"size"`
Timestamp int64 `json:"timestamp"`
} `json:"asks"`
SystemEvent struct {
SystemEvent string `json:"systemEvent"`
Timestamp int64 `json:"timestamp"`
} `json:"systemEvent"`
TradingStatus struct {
Status string `json:"status"`
Reason string `json:"reason"`
Timestamp int64 `json:"timestamp"`
} `json:"tradingStatus"`
OpHaltStatus struct {
IsHalted bool `json:"isHalted"`
Timestamp int64 `json:"timestamp"`
} `json:"opHaltStatus"`
SsrStatus struct {
IsSSR bool `json:"isSSR"`
Detail string `json:"detail"`
Timestamp int64 `json:"timestamp"`
} `json:"ssrStatus"`
SecurityEvent struct {
SecurityEvent string `json:"securityEvent"`
Timestamp int64 `json:"timestamp"`
} `json:"securityEvent"`
Trades []struct {
Price float64 `json:"price"`
Size int `json:"size"`
TradeID int `json:"tradeId"`
IsISO bool `json:"isISO"`
IsOddLot bool `json:"isOddLot"`
IsOutsideRegularHours bool `json:"isOutsideRegularHours"`
IsSinglePriceCross bool `json:"isSinglePriceCross"`
IsTradeThroughExempt bool `json:"isTradeThroughExempt"`
Timestamp int64 `json:"timestamp"`
} `json:"trades"`
TradeBreaks []struct {
Price float64 `json:"price"`
Size int `json:"size"`
TradeID int `json:"tradeId"`
IsISO bool `json:"isISO"`
IsOddLot bool `json:"isOddLot"`
IsOutsideRegularHours bool `json:"isOutsideRegularHours"`
IsSinglePriceCross bool `json:"isSinglePriceCross"`
IsTradeThroughExempt bool `json:"isTradeThroughExempt"`
Timestamp int64 `json:"timestamp"`
} `json:"tradeBreaks"`
Auction struct {
AuctionType string `json:"auctionType"`
PairedShares int `json:"pairedShares"`
ImbalanceShares int `json:"imbalanceShares"`
ReferencePrice float64 `json:"referencePrice"`
IndicativePrice float64 `json:"indicativePrice"`
AuctionBookPrice float64 `json:"auctionBookPrice"`
CollarReferencePrice float64 `json:"collarReferencePrice"`
LowerCollarPrice float64 `json:"lowerCollarPrice"`
UpperCollarPrice float64 `json:"upperCollarPrice"`
ExtensionNumber int `json:"extensionNumber"`
StartTime string `json:"startTime"`
LastUpdate int64 `json:"lastUpdate"`
} `json:"auction"`
}
// NewInvestorsExchangeData return new InvestorsExchangeData
func NewInvestorsExchangeData(
token, version string,
base *url.URL,
httpClient *http.Client,
options ...IEXOption,
) *InvestorsExchangeData {
apiurl, err := url.Parse("")
if err != nil {
panic(err)
}
ied := &InvestorsExchangeData{
iex: iex{
token: token,
version: version,
url: base,
apiurl: apiurl,
client: httpClient,
},
}
for _, option := range options {
err := option(&ied.iex)
if err != nil {
return nil
}
}
return ied
}
// Token return token string
func (ied *InvestorsExchangeData) Token() string {
return ied.token
}
// Version return version string
func (ied *InvestorsExchangeData) Version() string {
return ied.version
}
// URL return URL base
func (ied *InvestorsExchangeData) URL() *url.URL {
return ied.url
}
// APIURL return APIURL
func (ied *InvestorsExchangeData) APIURL() *url.URL {
return ied.apiurl
}
// Client return HTTP client
func (ied *InvestorsExchangeData) Client() *http.Client {
return ied.client
}
// Retry return Retry struct that implements Retryer
func (ied *InvestorsExchangeData) Retry() *Retry {
return ied.iex.Retry
}
// TOPS GET /tops?{params}
func (ied *InvestorsExchangeData) TOPS(params *TOPSParams) (tops TOPS, err error) {
get(ied, &tops, "tops", params)
return
}
// Last GET /tops/last?{params}
func (ied *InvestorsExchangeData) Last(params *LastParams) (l Last, err error) {
get(ied, &l, "tops/last", params)
return
}
// DEEP GET /deep?symbols={params}
func (ied *InvestorsExchangeData) DEEP(params *DEEPParams) (d *DEEP, err error) {
get(ied, &d, "deep", params)
return
}