forked from nntaoli-project/goex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMetas.go
301 lines (266 loc) · 6.17 KB
/
Metas.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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
package goex
import (
"net/http"
"time"
"github.com/shopspring/decimal"
)
type Order struct {
Price,
Amount,
AvgPrice,
DealAmount,
Fee float64
OrderID2 string
OrderID int
OrderTime int
Status TradeStatus
Currency CurrencyPair
Side TradeSide
}
type OrderDecimal struct {
Price,
Amount,
AvgPrice,
DealAmount,
Notinal,
DealNotional,
Fee decimal.Decimal
FeeCurrency string
OrderID2 string
OrderID int
ClientOid string
OrderTime int
Timestamp int64
Status TradeStatus
Currency CurrencyPair
Side TradeSide
}
type Trade struct {
Tid int64 `json:"tid"`
Type string `json:"type"`
Amount float64 `json:"amount,string"`
Price float64 `json:"price,string"`
Date int64 `json:"date_ms"`
Time string
}
type TradeDecimal struct {
Tid int64 `json:"tid"`
Type string `json:"type"`
Amount decimal.Decimal `json:"amount"`
Price decimal.Decimal `json:"price"`
Date int64 `json:"date_ms"`
Time string `json:"-"`
}
type SubAccount struct {
Currency Currency
Amount,
ForzenAmount,
LoanAmount float64
}
type Account struct {
Exchange string
Asset float64 //总资产
NetAsset float64 //净资产
SubAccounts map[Currency]SubAccount
}
type SubAccountDecimal struct {
Currency Currency
Amount,
FrozenAmount,
AvailableAmount,
LoanAmount decimal.Decimal
}
type AccountDecimal struct {
Exchange string
Asset decimal.Decimal //总资产
NetAsset decimal.Decimal //净资产
SubAccounts map[Currency]SubAccountDecimal
}
type Ticker struct {
ContractType string `json:"omitempty"`
Pair CurrencyPair `json:"omitempty"`
Last float64 `json:"last"`
Buy float64 `json:"buy"`
Sell float64 `json:"sell"`
High float64 `json:"high"`
Low float64 `json:"low"`
Vol float64 `json:"vol"`
Date uint64 `json:"date"` // 单位:秒(second)
ContractId int64 `json:"omitempty"`
}
type TickerDecimal struct {
ContractType string `json:"omitempty"`
Pair CurrencyPair `json:"omitempty"`
Last decimal.Decimal `json:"last"`
Buy decimal.Decimal `json:"buy"`
Sell decimal.Decimal `json:"sell"`
Open decimal.Decimal `json:"open"`
High decimal.Decimal `json:"high"`
Low decimal.Decimal `json:"low"`
Vol decimal.Decimal `json:"vol"`
Date uint64 `json:"date"` // 单位:秒(second)
ContractId int64 `json:"omitempty"`
}
type DepthRecord struct {
Price,
Amount float64
}
type DepthRecords []DepthRecord
func (dr DepthRecords) Len() int {
return len(dr)
}
func (dr DepthRecords) Swap(i, j int) {
dr[i], dr[j] = dr[j], dr[i]
}
func (dr DepthRecords) Less(i, j int) bool {
return dr[i].Price < dr[j].Price
}
type Depth struct {
ContractType string //for future
InstrumentId string
Symbol string
Pair CurrencyPair
UTime time.Time
AskList,
BidList DepthRecords
}
type DepthRecordDecimal struct {
Price decimal.Decimal `json:"price"`
Amount decimal.Decimal `json:"amount"`
}
type DepthRecordsDecimal []DepthRecordDecimal
func (dr DepthRecordsDecimal) Len() int {
return len(dr)
}
func (dr DepthRecordsDecimal) Swap(i, j int) {
dr[i], dr[j] = dr[j], dr[i]
}
func (dr DepthRecordsDecimal) Less(i, j int) bool {
return dr[i].Price.LessThan(dr[j].Price)
}
type DepthDecimal struct {
ContractType string //for future
InstrumentId string
Pair CurrencyPair
UTime time.Time
AskList,
BidList DepthRecordsDecimal
}
type APIConfig struct {
HttpClient *http.Client
ApiUrl,
AccessKey,
SecretKey string
}
type Kline struct {
Pair CurrencyPair
Timestamp int64
Open,
Close,
High,
Low,
Vol float64
}
type FutureKline struct {
*Kline
Vol2 float64 //个数
}
type FutureSubAccount struct {
Currency Currency
AccountRights float64 //账户权益
KeepDeposit float64 //保证金
ProfitReal float64 //已实现盈亏
ProfitUnreal float64
RiskRate float64 //保证金率
}
type FutureAccount struct {
FutureSubAccounts map[Currency]FutureSubAccount
}
type FutureSubAccountDecimal struct {
Currency Currency
AccountRights decimal.Decimal
KeepDeposit decimal.Decimal
ProfitReal decimal.Decimal
ProfitUnreal decimal.Decimal
RiskRate decimal.Decimal
}
type FutureAccountDecimal struct {
FutureSubAccounts map[Currency]FutureSubAccountDecimal
}
type FutureOrder struct {
Price float64
Amount float64
AvgPrice float64
DealAmount float64
OrderID int64
OrderID2 string
ClientOrderID string
OrderTime int64
Status TradeStatus
Currency CurrencyPair
OType int //1:开多 2:开空 3:平多 4: 平空
Side TradeSide
LeverRate int //倍数
Fee float64 //手续费
ContractName string
}
type FutureOrderDecimal struct {
Price decimal.Decimal
Amount decimal.Decimal
AvgPrice decimal.Decimal
DealAmount decimal.Decimal
OrderID string
ClientOrderID string
OrderTime int64
Status TradeStatus
OType int //1:开多 2:开空 3:平多 4: 平空
Side TradeSide
LeverRate int //倍数
Fee decimal.Decimal //手续费
ContractName string
}
type FuturePosition struct {
BuyAmount float64
BuyAvailable float64
BuyPriceAvg float64
BuyPriceCost float64
BuyProfitReal float64
BuyProfitUnReal float64
CreateDate int64
LeverRate int
SellAmount float64
SellAvailable float64
SellPriceAvg float64
SellPriceCost float64
SellProfitReal float64
SellProfitUnReal float64
Symbol CurrencyPair //btc_usd:比特币,ltc_usd:莱特币
ContractType string
ContractId int64
InstrumentId string
ForceLiquPrice float64 //预估爆仓价
}
type FutureFill struct {
FillId string
OrderId string
ClientOrderId string
Symbol string
Side TradeSide
LastQty int64
LastPrice float64
Price float64
AvgPrice float64
Commission int64
TransactionTime int64
}
type FutureFillDecimal struct {
FillId string
OrderId string
ContractName string
Side TradeSide
Qty decimal.Decimal
Price decimal.Decimal
Fee decimal.Decimal
TransactionTime int64
IsMaker bool
}