lbank-connector 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +215 -0
- package/package.json +24 -0
- package/src/APIBase.js +134 -0
- package/src/Spot.js +25 -0
- package/src/WebSocketAPI.js +28 -0
- package/src/WebSocketAPIBase.js +129 -0
- package/src/constants.js +84 -0
- package/src/errors/LbankClientError.js +15 -0
- package/src/errors/LbankConnectorError.js +8 -0
- package/src/errors/MissingParameterError.js +12 -0
- package/src/index.js +6 -0
- package/src/modules/spot/Market.js +192 -0
- package/src/modules/spot/Subscribe.js +34 -0
- package/src/modules/spot/Trade.js +183 -0
- package/src/modules/spot/Wallet.js +152 -0
- package/src/modules/websocket/Account.js +23 -0
- package/src/modules/websocket/Market.js +80 -0
- package/src/modules/websocket/Trade.js +25 -0
- package/src/modules/websocket/WebSocketModuleBase.js +11 -0
- package/src/node.js +50 -0
- package/src/utils/defaultLogger.js +9 -0
- package/src/utils/isEmptyValue.js +11 -0
- package/src/utils/request.js +84 -0
- package/src/utils/validation.js +34 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
const APIBase = require('../../APIBase')
|
|
2
|
+
const { HttpMethod } = require('../../constants')
|
|
3
|
+
const { validateRequiredParameters } = require('../../utils/validation')
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Market Data Endpoints
|
|
7
|
+
*/
|
|
8
|
+
class Market extends APIBase {
|
|
9
|
+
/**
|
|
10
|
+
* Test whether the Rest API can be connected.
|
|
11
|
+
*/
|
|
12
|
+
ping () {
|
|
13
|
+
return this.sendPublicRequest(
|
|
14
|
+
HttpMethod.POST,
|
|
15
|
+
'/v2/supplement/system_ping.do'
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Available trading pairs
|
|
21
|
+
*/
|
|
22
|
+
currencyPairs () {
|
|
23
|
+
return this.sendPublicRequest(HttpMethod.GET, '/v2/currencyPairs.do')
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Acquiring the basic information of all trading pairs
|
|
28
|
+
*/
|
|
29
|
+
accuracy () {
|
|
30
|
+
return this.sendPublicRequest(HttpMethod.GET, '/v2/accuracy.do')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get withdrawal configurations
|
|
35
|
+
* @param {Object} [params] Parameters
|
|
36
|
+
* @param {string} [params.assetCode] Code of the asset
|
|
37
|
+
*/
|
|
38
|
+
withdrawConfigs (params) {
|
|
39
|
+
return this.sendPublicRequest(
|
|
40
|
+
HttpMethod.GET,
|
|
41
|
+
'/v2/withdrawConfigs.do',
|
|
42
|
+
params
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 获取美元对人民币的兑换比例
|
|
48
|
+
*/
|
|
49
|
+
// usdToCny () {
|
|
50
|
+
// return this.sendPublicRequest(HttpMethod.GET, '/v2/usdToCny.do')
|
|
51
|
+
// }
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Get timestamp
|
|
55
|
+
*/
|
|
56
|
+
timestamp () {
|
|
57
|
+
return this.sendPublicRequest(HttpMethod.GET, '/v2/timestamp.do')
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Get depth information
|
|
62
|
+
* @param {Object} params request parameters
|
|
63
|
+
* @param {string} params.symbol Trading Pair.
|
|
64
|
+
* @param {number} params.size The count of returned items.(1-200)
|
|
65
|
+
*/
|
|
66
|
+
depth (params) {
|
|
67
|
+
validateRequiredParameters({
|
|
68
|
+
symbol: params.symbol,
|
|
69
|
+
size: params.size
|
|
70
|
+
})
|
|
71
|
+
return this.sendPublicRequest(HttpMethod.GET, '/v2/depth.do', params)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get the latest price of the trading pair
|
|
76
|
+
* @param {Object} [params] request parameters
|
|
77
|
+
* @param {string} [params.symbol] Pair
|
|
78
|
+
*/
|
|
79
|
+
price (params) {
|
|
80
|
+
return this.sendPublicRequest(
|
|
81
|
+
HttpMethod.GET,
|
|
82
|
+
'/v2/supplement/ticker/price.do',
|
|
83
|
+
params
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Symbol Order Book Ticker
|
|
89
|
+
* The current optimal pending order
|
|
90
|
+
* @param {Object} params request parameters
|
|
91
|
+
* @param {string} params.symbol coin pair
|
|
92
|
+
*/
|
|
93
|
+
bookTicker (params) {
|
|
94
|
+
validateRequiredParameters({
|
|
95
|
+
symbol: params.symbol
|
|
96
|
+
})
|
|
97
|
+
return this.sendPublicRequest(
|
|
98
|
+
HttpMethod.GET,
|
|
99
|
+
'/v2/supplement/ticker/bookTicker.do',
|
|
100
|
+
params
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 24hr Ticker
|
|
106
|
+
* GET the LBank coin quote data, excluding Leveraged Tokens trading pairs (get Leveraged Tokens trading pairs GET /v2/etfTicker/24hr.do)
|
|
107
|
+
* @param {Object} params request parameters
|
|
108
|
+
* @param {string} params.symbol Pair. Such as: eth_btc、zec_btc、 all
|
|
109
|
+
*/
|
|
110
|
+
ticker24h (params) {
|
|
111
|
+
validateRequiredParameters({
|
|
112
|
+
symbol: params.symbol
|
|
113
|
+
})
|
|
114
|
+
return this.sendPublicRequest(HttpMethod.GET, '/v2/ticker/24hr.do', params)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Leveraged Tokens 24hr Ticker
|
|
119
|
+
* Get LBank Leveraged Tokens market data
|
|
120
|
+
* @param {Object} params request parameters
|
|
121
|
+
* @param {string} params.symbol Pair. Such as: btc3l_usdt、all
|
|
122
|
+
*/
|
|
123
|
+
etfTicker24hr (params) {
|
|
124
|
+
validateRequiredParameters({
|
|
125
|
+
symbol: params.symbol
|
|
126
|
+
})
|
|
127
|
+
return this.sendPublicRequest(
|
|
128
|
+
HttpMethod.GET,
|
|
129
|
+
'/v2/etfTicker/24hr.do',
|
|
130
|
+
params
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* 获取LBank市场深度,这是带版本号的根据增量合并起来的深度
|
|
136
|
+
* @param {Object} params request parameters
|
|
137
|
+
* @param {string} params.symbol 币对如 btc_usdt
|
|
138
|
+
*/
|
|
139
|
+
// incrDepth (params) {
|
|
140
|
+
// return this.sendPublicRequest(HttpMethod.GET, '/v2/incrDepth.do', params)
|
|
141
|
+
// }
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Recent transactions list
|
|
145
|
+
* List of recent transactions
|
|
146
|
+
* @param {Object} params request parameters
|
|
147
|
+
* @param {string} params.symbol coin pair
|
|
148
|
+
* @param {string} params.size Returns size
|
|
149
|
+
* @param {string} [params.time] Returns size pieces of data after the timestamp, if empty, returns the latest size pieces of data
|
|
150
|
+
*/
|
|
151
|
+
trades (params) {
|
|
152
|
+
validateRequiredParameters({
|
|
153
|
+
symbol: params.symbol,
|
|
154
|
+
size: params.size
|
|
155
|
+
})
|
|
156
|
+
return this.sendPublicRequest(
|
|
157
|
+
HttpMethod.GET,
|
|
158
|
+
'/v2/supplement/trades.do',
|
|
159
|
+
params
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Query K Bar Data
|
|
165
|
+
* @param {Object} params request parameters
|
|
166
|
+
* @param {string} params.symbol Trading Pair. Such as: eth_btc
|
|
167
|
+
* @param {string} params.type minute1: 1 minute
|
|
168
|
+
minute5: 5 minutes
|
|
169
|
+
minute15: 15minutes
|
|
170
|
+
minute30: 30 minutes
|
|
171
|
+
hour1: 1 hour
|
|
172
|
+
hour4: 4 hours
|
|
173
|
+
hour8: 8 hours
|
|
174
|
+
hour12: 12 hours
|
|
175
|
+
day1: 1 day
|
|
176
|
+
week1: 1 week
|
|
177
|
+
month1: 1 month
|
|
178
|
+
* @param {number} params.size Count of the bars (1-2000)
|
|
179
|
+
* @param {string|number} params.time Timestamp (of Seconds)
|
|
180
|
+
*/
|
|
181
|
+
kline (params) {
|
|
182
|
+
validateRequiredParameters({
|
|
183
|
+
symbol: params.symbol,
|
|
184
|
+
size: params.size,
|
|
185
|
+
type: params.type,
|
|
186
|
+
time: params.time
|
|
187
|
+
})
|
|
188
|
+
return this.sendPublicRequest(HttpMethod.GET, '/v2/kline.do', params)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
module.exports = Market
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const APIBase = require('../../APIBase')
|
|
2
|
+
const { HttpMethod } = require('../../constants')
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* WebSocket API(Asset & Order)
|
|
6
|
+
*/
|
|
7
|
+
class Subscribe extends APIBase {
|
|
8
|
+
/**
|
|
9
|
+
* Create subscribeKey. The key is valid in 60 minutes from creation.
|
|
10
|
+
*/
|
|
11
|
+
getKey () {
|
|
12
|
+
return this.sendSignRequest(HttpMethod.POST, '/v2/subscribe/get_key.do')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Extend the validity of subscribeKey. The key is valid in 60 minutes from this call.
|
|
17
|
+
* @param {Object} params Parameters
|
|
18
|
+
* @param {string} params.subscribeKey subscribeKey
|
|
19
|
+
*/
|
|
20
|
+
refreshKey (params) {
|
|
21
|
+
return this.sendSignRequest(HttpMethod.POST, '/v2/subscribe/refresh_key.do', params)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Close the data stream for an account.
|
|
26
|
+
* @param {Object} params Parameters
|
|
27
|
+
* @param {string} params.subscribeKey subscribeKey
|
|
28
|
+
*/
|
|
29
|
+
destroyKey (params) {
|
|
30
|
+
return this.sendSignRequest(HttpMethod.POST, '/v2/subscribe/destroy_key.do', params)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = Subscribe
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
const APIBase = require('../../APIBase')
|
|
2
|
+
const { HttpMethod } = require('../../constants')
|
|
3
|
+
const { validateRequiredParameters } = require('../../utils/validation')
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Spot Trading Endpoints
|
|
7
|
+
*/
|
|
8
|
+
class Trade extends APIBase {
|
|
9
|
+
/**
|
|
10
|
+
* Test order
|
|
11
|
+
* @param {Object} params request parameters
|
|
12
|
+
* @param {string} params.symbol Transaction pair eth_btc: Ethereum; zec_btc: Zerocoin
|
|
13
|
+
* @param {string} params.type The type of the order, including buy, sell, buy_market, sell_market, buy_maker, sell_maker, buy_ioc, sell_ioc, buy_fok, sell_fok
|
|
14
|
+
* @param {string} params.price Order price Buy and sell orders: greater than or equal to 0
|
|
15
|
+
* @param {string} params.amount Amount of transactions Sell order and sell order: BTC amount is greater than or equal to 0.001
|
|
16
|
+
* @param {string} [params.custom_id] User-defined ID, do not repeat by yourself
|
|
17
|
+
* @param {number} [params.window] Expiration time of order, milliseconds, automatic cancellation of order after timeout (considering the public network time, it is recommended not to exceed 5s)
|
|
18
|
+
*/
|
|
19
|
+
createOrderTest (params) {
|
|
20
|
+
validateRequiredParameters({
|
|
21
|
+
symbol: params.symbol,
|
|
22
|
+
type: params.type,
|
|
23
|
+
price: params.price,
|
|
24
|
+
amount: params.amount
|
|
25
|
+
})
|
|
26
|
+
return this.sendSignRequest(
|
|
27
|
+
HttpMethod.POST,
|
|
28
|
+
'/v2/supplement/create_order_test.do',
|
|
29
|
+
params
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Create order
|
|
35
|
+
* @param {Object} params request parameters
|
|
36
|
+
* @param {string} params.symbol Transaction pair eth_btc: Ethereum; zec_btc: Zerocoin
|
|
37
|
+
* @param {string} params.type The type of the order, including buy, sell, buy_market, sell_market, buy_maker, sell_maker, buy_ioc, sell_ioc, buy_fok, sell_fok
|
|
38
|
+
* @param {string} params.price Reference description Order price Buy and sell orders: greater than or equal to 0
|
|
39
|
+
* @param {string} params.amount Reference description Amount of transactions Sell order and sell order: BTC amount is greater than or equal to 0.001
|
|
40
|
+
* @param {string} params.sign signature of request parameter
|
|
41
|
+
* @param {string} [params.custom_id] User-defined ID, do not repeat by yourself
|
|
42
|
+
* @param {number} [params.window] Expiration time of order, milliseconds, automatic cancellation of order after timeout (considering the public network time, it is recommended not to exceed 5s)
|
|
43
|
+
*/
|
|
44
|
+
createOrder (params) {
|
|
45
|
+
validateRequiredParameters({
|
|
46
|
+
symbol: params.symbol,
|
|
47
|
+
type: params.type,
|
|
48
|
+
price: params.price,
|
|
49
|
+
amount: params.amount
|
|
50
|
+
})
|
|
51
|
+
return this.sendSignRequest(
|
|
52
|
+
HttpMethod.POST,
|
|
53
|
+
'/v2/supplement/create_order.do',
|
|
54
|
+
params
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Cancel order
|
|
60
|
+
* @param {Object} params request parameters
|
|
61
|
+
* @param {string} params.symbol coin pair
|
|
62
|
+
* @param {string} [params.orderId] orderid, User-defined id and order id must be passed
|
|
63
|
+
* @param {string} [params.origClientOrderId] User-defined id and order id must be passed
|
|
64
|
+
*/
|
|
65
|
+
cancelOrder (params) {
|
|
66
|
+
validateRequiredParameters({
|
|
67
|
+
symbol: params.symbol
|
|
68
|
+
})
|
|
69
|
+
return this.sendSignRequest(
|
|
70
|
+
HttpMethod.POST,
|
|
71
|
+
'/v2/supplement/cancel_order.do',
|
|
72
|
+
params
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Cancel order by symbol
|
|
78
|
+
* @param {Object} params request parameters
|
|
79
|
+
* @param {string} params.symbol coin pair
|
|
80
|
+
*/
|
|
81
|
+
cancelOrderBySymbol (params) {
|
|
82
|
+
validateRequiredParameters({
|
|
83
|
+
symbol: params.symbol
|
|
84
|
+
})
|
|
85
|
+
return this.sendSignRequest(
|
|
86
|
+
HttpMethod.POST,
|
|
87
|
+
'/v2/supplement/cancel_order_by_symbol.do',
|
|
88
|
+
params
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Orders info
|
|
94
|
+
* @param {Object} params
|
|
95
|
+
* @param {string} params.symbol coin pair
|
|
96
|
+
* @param {string} [params.orderId] orderid, User-defined id and order id must be passed
|
|
97
|
+
* @param {string} [params.origClientOrderId] User-defined id and order id must be passed
|
|
98
|
+
*/
|
|
99
|
+
ordersInfo (params) {
|
|
100
|
+
validateRequiredParameters({
|
|
101
|
+
symbol: params.symbol
|
|
102
|
+
})
|
|
103
|
+
return this.sendSignRequest(
|
|
104
|
+
HttpMethod.POST,
|
|
105
|
+
'/v2/supplement/orders_info.do',
|
|
106
|
+
params
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Current pending order
|
|
112
|
+
* @param {Object} params request parameters
|
|
113
|
+
* @param {string} params.symbol Transaction pair eth_btc: Ethereum; zec_btc: Zerocoin
|
|
114
|
+
* @param {string} params.current_page current page number
|
|
115
|
+
* @param {string} params.page_length Number of data items per page (not less than 1, not more than 200)
|
|
116
|
+
*/
|
|
117
|
+
ordersInfoNoDeal (params) {
|
|
118
|
+
validateRequiredParameters({
|
|
119
|
+
symbol: params.symbol,
|
|
120
|
+
current_page: params.current_page,
|
|
121
|
+
page_length: params.page_length
|
|
122
|
+
})
|
|
123
|
+
return this.sendSignRequest(
|
|
124
|
+
HttpMethod.POST,
|
|
125
|
+
'/v2/supplement/orders_info_no_deal.do',
|
|
126
|
+
params
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Query all orders
|
|
132
|
+
* @param {Object} params request parameters
|
|
133
|
+
* @param {string} params.symbol Transaction pair eth_btc: Ethereum; zec_btc: Zerocoin
|
|
134
|
+
* @param {string} params.current_page current page number
|
|
135
|
+
* @param {string} params.page_length Number of data items per page (not less than 1, not more than 200)
|
|
136
|
+
* @param {string} [params.status] Order Status
|
|
137
|
+
*/
|
|
138
|
+
ordersInfoHistory (params) {
|
|
139
|
+
validateRequiredParameters({
|
|
140
|
+
symbol: params.symbol,
|
|
141
|
+
current_page: params.current_page,
|
|
142
|
+
page_length: params.page_length
|
|
143
|
+
})
|
|
144
|
+
return this.sendSignRequest(
|
|
145
|
+
HttpMethod.POST,
|
|
146
|
+
'/v2/supplement/orders_info_history.do',
|
|
147
|
+
params
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Account information
|
|
153
|
+
*/
|
|
154
|
+
userInfoAccount () {
|
|
155
|
+
return this.sendSignRequest(
|
|
156
|
+
HttpMethod.POST,
|
|
157
|
+
'/v2/supplement/user_info_account.do',
|
|
158
|
+
{}
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Historical transaction details
|
|
164
|
+
* @param {Object} params request parameters
|
|
165
|
+
* @param {string} params.symbol Transaction pair eth_btc: Ethereum; zec_btc: Zerocoin
|
|
166
|
+
* @param {string} [params.startTime] Start time yyyy-mm-dd or yyyy-MM-dd HH:mm:ss, the maximum value is today, the default is yesterday
|
|
167
|
+
* @param {string} [params.endTime] End time yyyy-mm-dd or yyyy-MM-dd HH:mm:ss, the maximum value is today, the default is today
|
|
168
|
+
* @param {string} [params.fromId] The starting transaction ID of the query
|
|
169
|
+
* @param {string} [params.limit] Number of queries, default 100, [1-100]
|
|
170
|
+
*/
|
|
171
|
+
transactionHistory (params) {
|
|
172
|
+
validateRequiredParameters({
|
|
173
|
+
symbol: params.symbol
|
|
174
|
+
})
|
|
175
|
+
return this.sendSignRequest(
|
|
176
|
+
HttpMethod.POST,
|
|
177
|
+
'/v2/supplement/transaction_history.do',
|
|
178
|
+
params
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
module.exports = Trade
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
const APIBase = require('../../APIBase')
|
|
2
|
+
const { HttpMethod } = require('../../constants')
|
|
3
|
+
const { validateRequiredParameters } = require('../../utils/validation')
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Wallet Endpoints
|
|
7
|
+
*/
|
|
8
|
+
class Wallet extends APIBase {
|
|
9
|
+
/**
|
|
10
|
+
* System status - Get system status.
|
|
11
|
+
*/
|
|
12
|
+
systemStatus () {
|
|
13
|
+
return this.sendSignRequest(
|
|
14
|
+
HttpMethod.POST,
|
|
15
|
+
'/v2/supplement/system_status.do'
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get all coins information - Get all the currency information for the user (LBK supports deposit and withdrawal operations).
|
|
21
|
+
*/
|
|
22
|
+
userInfo () {
|
|
23
|
+
return this.sendSignRequest(
|
|
24
|
+
HttpMethod.POST,
|
|
25
|
+
'/v2/supplement/user_info.do'
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Withdrawal - User withdrawal
|
|
31
|
+
* @param {Object} params request parameters
|
|
32
|
+
* @param {string} params.address withdrawal address, when type=1, it is the transfer account
|
|
33
|
+
* @param {string} params.coin currency
|
|
34
|
+
* @param {string} params.amount withdrawal amount
|
|
35
|
+
* @param {string} params.fee fee
|
|
36
|
+
* @param {string} [params.networkName] Chain name, get it through the Get All Coin Information interface
|
|
37
|
+
* @param {string} [params.memo] memo: memo word of bts and dct
|
|
38
|
+
* @param {string} [params.mark] Withdrawal Notes
|
|
39
|
+
* @param {string} [params.name] Remarks of the address. After filling in this parameter, it will be added to the withdrawal address book of the currency.
|
|
40
|
+
* @param {string} [params.withdrawOrderId] Custom withdrawal id
|
|
41
|
+
* @param {string} [params.type] type=1 is for intra-site transfer
|
|
42
|
+
*/
|
|
43
|
+
withdraw (params) {
|
|
44
|
+
validateRequiredParameters({
|
|
45
|
+
address: params.address,
|
|
46
|
+
coin: params.coin,
|
|
47
|
+
amount: params.amount,
|
|
48
|
+
fee: params.fee
|
|
49
|
+
})
|
|
50
|
+
return this.sendSignRequest(
|
|
51
|
+
HttpMethod.POST,
|
|
52
|
+
'/v2/supplement/withdraw.do',
|
|
53
|
+
params
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get recharge history - User access to recharge history
|
|
59
|
+
*
|
|
60
|
+
* @param {Object} [params] request parameters
|
|
61
|
+
* @param {string} [params.status] Recharge status: ("1","Applying"),("2","Recharge successful"),("3","Recharge failed"),("4","Already Cancel"), ("5", "Transfer")
|
|
62
|
+
* @param {string} [params.coin] currency
|
|
63
|
+
* @param {string} [params.startTime] Start time, timestamp in milliseconds, default 90 days ago
|
|
64
|
+
* @param {string} [params.endTime] end time, timestamp in milliseconds, default day
|
|
65
|
+
*
|
|
66
|
+
*/
|
|
67
|
+
depositHistory (params) {
|
|
68
|
+
return this.sendSignRequest(
|
|
69
|
+
HttpMethod.POST,
|
|
70
|
+
'/v2/supplement/deposit_history.do',
|
|
71
|
+
params
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Get withdrawal history - User's coin withdrawal history
|
|
77
|
+
*
|
|
78
|
+
* @param {Object} [params] request parameters
|
|
79
|
+
* @param {string} [params.status] status: ("1","Applying"),("2","Cancelled"),("3","Withdrawal failed"),("4","Withdrawal complete")
|
|
80
|
+
* @param {string} [params.coin] currency
|
|
81
|
+
* @param {string} [params.withdrawOrderId] Custom withdrawal id
|
|
82
|
+
* @param {string} [params.startTime] Start time, timestamp in milliseconds, default 90 days ago
|
|
83
|
+
* @param {string} [params.endTime] end time, timestamp in milliseconds, default day
|
|
84
|
+
*
|
|
85
|
+
*/
|
|
86
|
+
withdraws (params) {
|
|
87
|
+
return this.sendSignRequest(
|
|
88
|
+
HttpMethod.POST,
|
|
89
|
+
'/v2/supplement/withdraws.do',
|
|
90
|
+
params
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The user obtains the deposit address - The user obtains the recharge address
|
|
96
|
+
*
|
|
97
|
+
* @param {Object} [params] request parameters
|
|
98
|
+
* @param {string} [params.networkName] chain name
|
|
99
|
+
* @param {string} [params.coin] currency
|
|
100
|
+
*
|
|
101
|
+
*/
|
|
102
|
+
getDepositAddress (params) {
|
|
103
|
+
return this.sendSignRequest(
|
|
104
|
+
HttpMethod.POST,
|
|
105
|
+
'/v2/supplement/get_deposit_address.do',
|
|
106
|
+
params
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The user obtains the deposit address - The user obtains the recharge address
|
|
112
|
+
*
|
|
113
|
+
* @param {Object} [params] request parameters
|
|
114
|
+
* @param {string} [params.coin] currency
|
|
115
|
+
*
|
|
116
|
+
*/
|
|
117
|
+
assetDetail (params) {
|
|
118
|
+
return this.sendSignRequest(
|
|
119
|
+
HttpMethod.POST,
|
|
120
|
+
'/v2/supplement/asset_detail.do',
|
|
121
|
+
params
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Transaction fee rate query - User transaction fee rate query
|
|
127
|
+
*
|
|
128
|
+
* @param {Object} [params] request parameters
|
|
129
|
+
* @param {string} [params.category] Trading pair, eg: lbk_usdt
|
|
130
|
+
*
|
|
131
|
+
*/
|
|
132
|
+
customerTradeFee (params) {
|
|
133
|
+
return this.sendSignRequest(
|
|
134
|
+
HttpMethod.POST,
|
|
135
|
+
'/v2/supplement/customer_trade_fee.do',
|
|
136
|
+
params
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Query user API Key permissions - Query user API Key permissions
|
|
142
|
+
*
|
|
143
|
+
*/
|
|
144
|
+
apiRestrictions () {
|
|
145
|
+
return this.sendSignRequest(
|
|
146
|
+
HttpMethod.POST,
|
|
147
|
+
'/v2/supplement/api_Restrictions.do'
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
module.exports = Wallet
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const WebSocketModuleBase = require('./WebSocketModuleBase')
|
|
2
|
+
const { validateRequiredParameters } = require('../../utils/validation')
|
|
3
|
+
|
|
4
|
+
class Account extends WebSocketModuleBase {
|
|
5
|
+
/**
|
|
6
|
+
* Update subscribed asset, Such events will be pushed when the balance of assets under the account changes (increase, deduction, available freeze, freeze release).
|
|
7
|
+
* @param {Object} params Parameters
|
|
8
|
+
* @param {string} params.action Action requested:subscribe,unsubscribe
|
|
9
|
+
* @param {string} params.subscribeKey Obtained through the REST interface of the /v2/subscribe/refresh_key.do
|
|
10
|
+
*/
|
|
11
|
+
assetUpdate (params) {
|
|
12
|
+
validateRequiredParameters({
|
|
13
|
+
action: params.action,
|
|
14
|
+
subscribeKey: params.subscribeKey
|
|
15
|
+
})
|
|
16
|
+
this.sendMessage({
|
|
17
|
+
subscribe: 'assetUpdate',
|
|
18
|
+
...params
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = Account
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const WebSocketModuleBase = require('./WebSocketModuleBase')
|
|
2
|
+
const { validateRequiredParameters } = require('../../utils/validation')
|
|
3
|
+
|
|
4
|
+
class Market extends WebSocketModuleBase {
|
|
5
|
+
/**
|
|
6
|
+
* Subscription of K-line Data
|
|
7
|
+
* @param {Object} params Parameters
|
|
8
|
+
* @param {string} params.action Action requested:subscribe,unsubscribe
|
|
9
|
+
* @param {string} params.kbar To subscribe to k-line types, 1min: 1 minute, 5min: 5 minutes, 15min: 15 minutes, 30min: 30 minutes, 1hr: 1 hour, 4hr: 4 hours, day: 1 day, week: 1 week, month: 1 month, year: 1 year
|
|
10
|
+
* @param {string} params.pair Trading pair:eth_btc
|
|
11
|
+
*/
|
|
12
|
+
kbar (params) {
|
|
13
|
+
validateRequiredParameters({
|
|
14
|
+
action: params.action,
|
|
15
|
+
kbar: params.kbar,
|
|
16
|
+
pair: params.pair
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
this.sendMessage({
|
|
20
|
+
subscribe: 'kbar',
|
|
21
|
+
...params
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Market Depth
|
|
27
|
+
* @param {Object} params Parameters
|
|
28
|
+
* @param {string} params.action Type of action requested:subscribe,unsubscribe
|
|
29
|
+
* @param {string} params.depth Pro-choise:10/50/100
|
|
30
|
+
* @param {string} params.pair Trading pair:eth_btc
|
|
31
|
+
*/
|
|
32
|
+
depth (params) {
|
|
33
|
+
validateRequiredParameters({
|
|
34
|
+
action: params.action,
|
|
35
|
+
depth: params.depth,
|
|
36
|
+
pair: params.pair
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
this.sendMessage({
|
|
40
|
+
subscribe: 'depth',
|
|
41
|
+
...params
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Market
|
|
47
|
+
* @param {Object} params Parameters
|
|
48
|
+
* @param {string} params.action Action requested:subscribe,unsubscribe
|
|
49
|
+
* @param {string} params.pair Trading pair:eth_btc
|
|
50
|
+
*/
|
|
51
|
+
tick (params) {
|
|
52
|
+
validateRequiredParameters({
|
|
53
|
+
action: params.action,
|
|
54
|
+
pair: params.pair
|
|
55
|
+
})
|
|
56
|
+
this.sendMessage({
|
|
57
|
+
subscribe: 'tick',
|
|
58
|
+
...params
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Trade record
|
|
64
|
+
* @param {Object} params Parameters
|
|
65
|
+
* @param {string} params.action Action requested: subscribe or unsubscribe
|
|
66
|
+
* @param {string} params.pair Trading pair:eth_btc
|
|
67
|
+
*/
|
|
68
|
+
trade (params) {
|
|
69
|
+
validateRequiredParameters({
|
|
70
|
+
action: params.action,
|
|
71
|
+
pair: params.pair
|
|
72
|
+
})
|
|
73
|
+
this.sendMessage({
|
|
74
|
+
subscribe: 'trade',
|
|
75
|
+
...params
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
module.exports = Market
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const WebSocketModuleBase = require('./WebSocketModuleBase')
|
|
2
|
+
const { validateRequiredParameters } = require('../../utils/validation')
|
|
3
|
+
|
|
4
|
+
class Trade extends WebSocketModuleBase {
|
|
5
|
+
/**
|
|
6
|
+
* Update subscribed orders, Such events will be pushed when there are new orders created, new orders dealed or new status changes of the account.
|
|
7
|
+
* @param {Object} params Parameters
|
|
8
|
+
* @param {string} params.action Action requested:subscribe,unsubscribe
|
|
9
|
+
* @param {string} params.subscribeKey Obtained through the REST interface of the /v2/subscribe/refresh_key.do
|
|
10
|
+
* @param {string} params.pair Trading pair :eth_btc. Support matching all: all
|
|
11
|
+
*/
|
|
12
|
+
orderUpdate (params) {
|
|
13
|
+
validateRequiredParameters({
|
|
14
|
+
action: params.action,
|
|
15
|
+
subscribeKey: params.subscribeKey,
|
|
16
|
+
pair: params.pair
|
|
17
|
+
})
|
|
18
|
+
this.sendMessage({
|
|
19
|
+
subscribe: 'orderUpdate',
|
|
20
|
+
...params
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = Trade
|