-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmargin_results.go
90 lines (82 loc) · 3.51 KB
/
margin_results.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
package okex
import (
sjson "encoding/json"
"time"
)
type MarginCurrency struct {
Available string `json:"available"`
Balance string `json:"balance"`
Borrowed string `json:"borrowed"`
CanWithdraw string `json:"can_withdraw"`
Frozen string `json:"frozen"`
Hold string `json:"hold"`
Holds string `json:"holds"`
LendingFee string `json:"lending_fee"`
}
type GetMarginAccountsItem struct {
CurrencyBTC MarginCurrency `json:"currency:BTC,omitempty"`
CurrencyUSDT MarginCurrency `json:"currency:USDT,omitempty"`
InstrumentID string `json:"instrument_id"`
LiquidationPrice string `json:"liquidation_price"`
MarginRatio string `json:"margin_ratio"`
ProductID string `json:"product_id"`
RiskRate string `json:"risk_rate"`
CurrencyLTC MarginCurrency `json:"currency:LTC,omitempty"`
CurrencyETH MarginCurrency `json:"currency:ETH,omitempty"`
CurrencyETC MarginCurrency `json:"currency:ETC,omitempty"`
CurrencyBCH MarginCurrency `json:"currency:BCH,omitempty"`
CurrencyEOS MarginCurrency `json:"currency:EOS,omitempty"`
CurrencyXRP MarginCurrency `json:"currency:XRP,omitempty"`
CurrencyTRX MarginCurrency `json:"currency:TRX,omitempty"`
CurrencyBSV MarginCurrency `json:"currency:BSV,omitempty"`
CurrencyDASH MarginCurrency `json:"currency:DASH,omitempty"`
CurrencyNEO MarginCurrency `json:"currency:NEO,omitempty"`
CurrencyQTUM MarginCurrency `json:"currency:QTUM,omitempty"`
CurrencyIOST MarginCurrency `json:"currency:IOST,omitempty"`
}
type GetMarginAccountsResult []GetMarginAccountsItem
type MarginNewOrderResult struct {
ClientOid string `json:"client_oid"`
ErrorCode string `json:"error_code"`
ErrorMessage string `json:"error_message"`
OrderID string `json:"order_id"`
Result bool `json:"result"`
}
type MarginGetOrderResult struct {
ClientOid string `json:"client_oid"`
CreatedAt time.Time `json:"created_at"`
FilledNotional sjson.Number `json:"filled_notional"`
FilledSize sjson.Number `json:"filled_size"`
Funds string `json:"funds"`
InstrumentID string `json:"instrument_id"`
Notional string `json:"notional"`
OrderID string `json:"order_id"`
OrderType sjson.Number `json:"order_type"` /*int*/
Price sjson.Number `json:"price"`
PriceAvg sjson.Number `json:"price_avg"`
ProductID string `json:"product_id"`
Side string `json:"side"`
Size sjson.Number `json:"size"`
Status string `json:"status"` // status为state旧版参数,会短期兼容,建议尽早切换state
State sjson.Number `json:"state"` /*int*/ // -2:失败 -1:撤单成功 0:等待成交 1:部分成交 2:完全成交 3:下单中 4:撤单中
Timestamp time.Time `json:"timestamp"`
Type string `json:"type"`
}
type FillItem struct {
CreatedAt string `json:"created_at"`
ExecType string `json:"exec_type"`
Fee float64 `json:"fee,string"`
InstrumentID string `json:"instrument_id"`
LedgerID string `json:"ledger_id"`
Liquidity string `json:"liquidity"`
OrderID string `json:"order_id"`
Price string `json:"price"`
ProductID string `json:"product_id"`
Side string `json:"side"`
Size float64 `json:"size,string"`
Timestamp string `json:"timestamp"`
}
func (r *MarginGetOrderResult) GetState() int64 {
i, _ := r.State.Int64()
return i
}