ccxt 4.1.91 → 4.1.95
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/CHANGELOG.md +37 -0
- package/README.md +3 -3
- package/dist/ccxt.browser.js +727 -286
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/binance.js +11 -9
- package/dist/cjs/src/bingx.js +11 -6
- package/dist/cjs/src/bitget.js +152 -103
- package/dist/cjs/src/bitrue.js +2 -11
- package/dist/cjs/src/bybit.js +1 -0
- package/dist/cjs/src/coinbase.js +44 -2
- package/dist/cjs/src/coinone.js +394 -143
- package/dist/cjs/src/hitbtc.js +41 -0
- package/dist/cjs/src/kucoinfutures.js +22 -6
- package/dist/cjs/src/okx.js +2 -0
- package/dist/cjs/src/pro/bingx.js +44 -5
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bybit.d.ts +1 -0
- package/js/src/abstract/coinbase.d.ts +6 -0
- package/js/src/abstract/coinone.d.ts +44 -2
- package/js/src/abstract/kucoinfutures.d.ts +2 -0
- package/js/src/abstract/okx.d.ts +2 -0
- package/js/src/binance.js +11 -9
- package/js/src/bingx.js +11 -6
- package/js/src/bitget.d.ts +1 -0
- package/js/src/bitget.js +152 -103
- package/js/src/bitrue.js +2 -11
- package/js/src/bybit.js +1 -0
- package/js/src/coinbase.js +44 -2
- package/js/src/coinone.d.ts +1 -0
- package/js/src/coinone.js +394 -143
- package/js/src/hitbtc.d.ts +1 -0
- package/js/src/hitbtc.js +41 -0
- package/js/src/kucoinfutures.js +22 -6
- package/js/src/okx.js +2 -0
- package/js/src/pro/bingx.d.ts +2 -0
- package/js/src/pro/bingx.js +44 -5
- package/package.json +1 -1
- package/skip-tests.json +7 -0
- package/changelog.js +0 -101
package/js/src/coinone.js
CHANGED
|
@@ -48,6 +48,7 @@ export default class coinone extends Exchange {
|
|
|
48
48
|
'fetchClosedOrders': false,
|
|
49
49
|
'fetchCrossBorrowRate': false,
|
|
50
50
|
'fetchCrossBorrowRates': false,
|
|
51
|
+
'fetchCurrencies': true,
|
|
51
52
|
'fetchDepositAddresses': true,
|
|
52
53
|
'fetchFundingHistory': false,
|
|
53
54
|
'fetchFundingRate': false,
|
|
@@ -84,6 +85,9 @@ export default class coinone extends Exchange {
|
|
|
84
85
|
'logo': 'https://user-images.githubusercontent.com/1294454/38003300-adc12fba-323f-11e8-8525-725f53c4a659.jpg',
|
|
85
86
|
'api': {
|
|
86
87
|
'rest': 'https://api.coinone.co.kr',
|
|
88
|
+
'v2Public': 'https://api.coinone.co.kr/public/v2',
|
|
89
|
+
'v2Private': 'https://api.coinone.co.kr/v2',
|
|
90
|
+
'v2_1Private': 'https://api.coinone.co.kr/v2.1',
|
|
87
91
|
},
|
|
88
92
|
'www': 'https://coinone.co.kr',
|
|
89
93
|
'doc': 'https://doc.coinone.co.kr',
|
|
@@ -95,31 +99,85 @@ export default class coinone extends Exchange {
|
|
|
95
99
|
'api': {
|
|
96
100
|
'public': {
|
|
97
101
|
'get': [
|
|
98
|
-
'orderbook
|
|
99
|
-
'
|
|
100
|
-
'
|
|
102
|
+
'orderbook',
|
|
103
|
+
'ticker',
|
|
104
|
+
'ticker_utc',
|
|
105
|
+
'trades',
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
'v2Public': {
|
|
109
|
+
'get': [
|
|
110
|
+
'range_units',
|
|
111
|
+
'markets/{quote_currency}',
|
|
112
|
+
'markets/{quote_currency}/{target_currency}',
|
|
113
|
+
'orderbook/{quote_currency}/{target_currency}',
|
|
114
|
+
'trades/{quote_currency}/{target_currency}',
|
|
115
|
+
'ticker_new/{quote_currency}',
|
|
116
|
+
'ticker_new/{quote_currency}/{target_currency}',
|
|
117
|
+
'ticker_utc_new/{quote_currency}',
|
|
118
|
+
'ticker_utc_new/{quote_currency}/{target_currency}',
|
|
119
|
+
'currencies',
|
|
120
|
+
'currencies/{currency}',
|
|
121
|
+
'chart/{quote_currency}/{target_currency}',
|
|
101
122
|
],
|
|
102
123
|
},
|
|
103
124
|
'private': {
|
|
104
125
|
'post': [
|
|
105
|
-
'account/deposit_address
|
|
106
|
-
'account/btc_deposit_address
|
|
107
|
-
'account/balance
|
|
108
|
-
'account/daily_balance
|
|
109
|
-
'account/user_info
|
|
110
|
-
'account/virtual_account
|
|
111
|
-
'order/cancel_all
|
|
112
|
-
'order/cancel
|
|
113
|
-
'order/limit_buy
|
|
114
|
-
'order/limit_sell
|
|
115
|
-
'order/complete_orders
|
|
116
|
-
'order/limit_orders
|
|
117
|
-
'order/
|
|
118
|
-
'transaction/auth_number
|
|
119
|
-
'transaction/history
|
|
120
|
-
'transaction/krw/history
|
|
121
|
-
'transaction/btc
|
|
122
|
-
'transaction/coin
|
|
126
|
+
'account/deposit_address',
|
|
127
|
+
'account/btc_deposit_address',
|
|
128
|
+
'account/balance',
|
|
129
|
+
'account/daily_balance',
|
|
130
|
+
'account/user_info',
|
|
131
|
+
'account/virtual_account',
|
|
132
|
+
'order/cancel_all',
|
|
133
|
+
'order/cancel',
|
|
134
|
+
'order/limit_buy',
|
|
135
|
+
'order/limit_sell',
|
|
136
|
+
'order/complete_orders',
|
|
137
|
+
'order/limit_orders',
|
|
138
|
+
'order/order_info',
|
|
139
|
+
'transaction/auth_number',
|
|
140
|
+
'transaction/history',
|
|
141
|
+
'transaction/krw/history',
|
|
142
|
+
'transaction/btc',
|
|
143
|
+
'transaction/coin',
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
'v2Private': {
|
|
147
|
+
'post': [
|
|
148
|
+
'account/balance',
|
|
149
|
+
'account/deposit_address',
|
|
150
|
+
'account/user_info',
|
|
151
|
+
'account/virtual_account',
|
|
152
|
+
'order/cancel',
|
|
153
|
+
'order/limit_buy',
|
|
154
|
+
'order/limit_sell',
|
|
155
|
+
'order/limit_orders',
|
|
156
|
+
'order/complete_orders',
|
|
157
|
+
'order/query_order',
|
|
158
|
+
'transaction/auth_number',
|
|
159
|
+
'transaction/btc',
|
|
160
|
+
'transaction/history',
|
|
161
|
+
'transaction/krw/history',
|
|
162
|
+
],
|
|
163
|
+
},
|
|
164
|
+
'v2_1Private': {
|
|
165
|
+
'post': [
|
|
166
|
+
'account/balance/all',
|
|
167
|
+
'account/balance',
|
|
168
|
+
'account/trade_fee',
|
|
169
|
+
'account/trade_fee/{quote_currency}/{target_currency}',
|
|
170
|
+
'order/limit',
|
|
171
|
+
'order/cancel',
|
|
172
|
+
'order/cancel/all',
|
|
173
|
+
'order/open_orders',
|
|
174
|
+
'order/open_orders/all',
|
|
175
|
+
'order/complete_orders',
|
|
176
|
+
'order/complete_orders/all',
|
|
177
|
+
'order/info',
|
|
178
|
+
'transaction/krw/history',
|
|
179
|
+
'transaction/coin/history',
|
|
180
|
+
'transaction/coin/withdrawal/limit',
|
|
123
181
|
],
|
|
124
182
|
},
|
|
125
183
|
},
|
|
@@ -143,53 +201,129 @@ export default class coinone extends Exchange {
|
|
|
143
201
|
},
|
|
144
202
|
});
|
|
145
203
|
}
|
|
204
|
+
async fetchCurrencies(params = {}) {
|
|
205
|
+
/**
|
|
206
|
+
* @method
|
|
207
|
+
* @name coinone#fetchCurrencies
|
|
208
|
+
* @description fetches all available currencies on an exchange
|
|
209
|
+
* @see https://docs.coinone.co.kr/reference/currencies
|
|
210
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
211
|
+
* @returns {object} an associative dictionary of currencies
|
|
212
|
+
*/
|
|
213
|
+
const response = await this.v2PublicGetCurrencies(params);
|
|
214
|
+
//
|
|
215
|
+
// {
|
|
216
|
+
// "result": "success",
|
|
217
|
+
// "error_code": "0",
|
|
218
|
+
// "server_time": 1701054555578,
|
|
219
|
+
// "currencies": [
|
|
220
|
+
// {
|
|
221
|
+
// "name": "Polygon",
|
|
222
|
+
// "symbol": "MATIC",
|
|
223
|
+
// "deposit_status": "normal",
|
|
224
|
+
// "withdraw_status": "normal",
|
|
225
|
+
// "deposit_confirm_count": 150,
|
|
226
|
+
// "max_precision": 8,
|
|
227
|
+
// "deposit_fee": "0.0",
|
|
228
|
+
// "withdrawal_min_amount": "1.0",
|
|
229
|
+
// "withdrawal_fee": "3.0"
|
|
230
|
+
// }
|
|
231
|
+
// ]
|
|
232
|
+
// }
|
|
233
|
+
//
|
|
234
|
+
const result = {};
|
|
235
|
+
const currencies = this.safeValue(response, 'currencies', []);
|
|
236
|
+
for (let i = 0; i < currencies.length; i++) {
|
|
237
|
+
const entry = currencies[i];
|
|
238
|
+
const id = this.safeString(entry, 'symbol');
|
|
239
|
+
const name = this.safeString(entry, 'name');
|
|
240
|
+
const code = this.safeCurrencyCode(id);
|
|
241
|
+
const withdrawStatus = this.safeString(entry, 'withdraw_status', '');
|
|
242
|
+
const depositStatus = this.safeString(entry, 'deposit_status', '');
|
|
243
|
+
const isWithdrawEnabled = withdrawStatus === 'normal';
|
|
244
|
+
const isDepositEnabled = depositStatus === 'normal';
|
|
245
|
+
result[code] = {
|
|
246
|
+
'id': id,
|
|
247
|
+
'code': code,
|
|
248
|
+
'info': entry,
|
|
249
|
+
'name': name,
|
|
250
|
+
'active': isWithdrawEnabled && isDepositEnabled,
|
|
251
|
+
'deposit': isDepositEnabled,
|
|
252
|
+
'withdraw': isWithdrawEnabled,
|
|
253
|
+
'fee': this.safeNumber(entry, 'withdrawal_fee'),
|
|
254
|
+
'precision': this.parseNumber(this.parsePrecision(this.safeString(entry, 'max_precision'))),
|
|
255
|
+
'limits': {
|
|
256
|
+
'amount': {
|
|
257
|
+
'min': undefined,
|
|
258
|
+
'max': undefined,
|
|
259
|
+
},
|
|
260
|
+
'withdraw': {
|
|
261
|
+
'min': this.safeNumber(entry, 'withdrawal_min_amount'),
|
|
262
|
+
'max': undefined,
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
'networks': {},
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
return result;
|
|
269
|
+
}
|
|
146
270
|
async fetchMarkets(params = {}) {
|
|
147
271
|
/**
|
|
148
272
|
* @method
|
|
149
273
|
* @name coinone#fetchMarkets
|
|
150
274
|
* @description retrieves data on all markets for coinone
|
|
275
|
+
* @see https://docs.coinone.co.kr/v1.0/reference/tickers
|
|
151
276
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
152
277
|
* @returns {object[]} an array of objects representing market data
|
|
153
278
|
*/
|
|
154
279
|
const request = {
|
|
155
|
-
'
|
|
280
|
+
'quote_currency': 'KRW',
|
|
156
281
|
};
|
|
157
|
-
const response = await this.
|
|
158
|
-
//
|
|
159
|
-
//
|
|
160
|
-
//
|
|
161
|
-
//
|
|
162
|
-
//
|
|
163
|
-
//
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
//
|
|
167
|
-
//
|
|
168
|
-
//
|
|
169
|
-
//
|
|
170
|
-
//
|
|
171
|
-
//
|
|
172
|
-
//
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
//
|
|
176
|
-
//
|
|
177
|
-
//
|
|
282
|
+
const response = await this.v2PublicGetTickerNewQuoteCurrency(request);
|
|
283
|
+
//
|
|
284
|
+
// {
|
|
285
|
+
// "result": "success",
|
|
286
|
+
// "error_code": "0",
|
|
287
|
+
// "server_time": 1701067923060,
|
|
288
|
+
// "tickers": [
|
|
289
|
+
// {
|
|
290
|
+
// "quote_currency": "krw",
|
|
291
|
+
// "target_currency": "stg",
|
|
292
|
+
// "timestamp": 1701067920001,
|
|
293
|
+
// "high": "667.5",
|
|
294
|
+
// "low": "667.5",
|
|
295
|
+
// "first": "667.5",
|
|
296
|
+
// "last": "667.5",
|
|
297
|
+
// "quote_volume": "0.0",
|
|
298
|
+
// "target_volume": "0.0",
|
|
299
|
+
// "best_asks": [
|
|
300
|
+
// {
|
|
301
|
+
// "price": "777.0",
|
|
302
|
+
// "qty": "73.9098"
|
|
303
|
+
// }
|
|
304
|
+
// ],
|
|
305
|
+
// "best_bids": [
|
|
306
|
+
// {
|
|
307
|
+
// "price": "690.8",
|
|
308
|
+
// "qty": "40.7768"
|
|
309
|
+
// }
|
|
310
|
+
// ],
|
|
311
|
+
// "id": "1701067920001001"
|
|
312
|
+
// }
|
|
313
|
+
// ]
|
|
314
|
+
// }
|
|
178
315
|
//
|
|
316
|
+
const tickers = this.safeValue(response, 'tickers', []);
|
|
179
317
|
const result = [];
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const
|
|
185
|
-
const ticker = this.safeValue(response, baseId, {});
|
|
186
|
-
const currency = this.safeValue(ticker, 'currency');
|
|
187
|
-
if (currency === undefined) {
|
|
188
|
-
continue;
|
|
189
|
-
}
|
|
318
|
+
for (let i = 0; i < tickers.length; i++) {
|
|
319
|
+
const entry = this.safeValue(tickers, i);
|
|
320
|
+
const id = this.safeString(entry, 'id');
|
|
321
|
+
const baseId = this.safeStringUpper(entry, 'target_currency');
|
|
322
|
+
const quoteId = this.safeStringUpper(entry, 'quote_currency');
|
|
190
323
|
const base = this.safeCurrencyCode(baseId);
|
|
324
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
191
325
|
result.push({
|
|
192
|
-
'id':
|
|
326
|
+
'id': id,
|
|
193
327
|
'symbol': base + '/' + quote,
|
|
194
328
|
'base': base,
|
|
195
329
|
'quote': quote,
|
|
@@ -236,7 +370,7 @@ export default class coinone extends Exchange {
|
|
|
236
370
|
},
|
|
237
371
|
},
|
|
238
372
|
'created': undefined,
|
|
239
|
-
'info':
|
|
373
|
+
'info': entry,
|
|
240
374
|
});
|
|
241
375
|
}
|
|
242
376
|
return result;
|
|
@@ -265,11 +399,12 @@ export default class coinone extends Exchange {
|
|
|
265
399
|
* @method
|
|
266
400
|
* @name coinone#fetchBalance
|
|
267
401
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
402
|
+
* @see https://docs.coinone.co.kr/v1.0/reference/v21
|
|
268
403
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
269
404
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
270
405
|
*/
|
|
271
406
|
await this.loadMarkets();
|
|
272
|
-
const response = await this.
|
|
407
|
+
const response = await this.v2PrivatePostAccountBalance(params);
|
|
273
408
|
return this.parseBalance(response);
|
|
274
409
|
}
|
|
275
410
|
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
@@ -277,6 +412,7 @@ export default class coinone extends Exchange {
|
|
|
277
412
|
* @method
|
|
278
413
|
* @name coinone#fetchOrderBook
|
|
279
414
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
415
|
+
* @see https://docs.coinone.co.kr/v1.0/reference/orderbook
|
|
280
416
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
281
417
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
282
418
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -285,18 +421,46 @@ export default class coinone extends Exchange {
|
|
|
285
421
|
await this.loadMarkets();
|
|
286
422
|
const market = this.market(symbol);
|
|
287
423
|
const request = {
|
|
288
|
-
'
|
|
289
|
-
'
|
|
424
|
+
'quote_currency': market['quote'],
|
|
425
|
+
'target_currency': market['base'],
|
|
290
426
|
};
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
427
|
+
if (limit !== undefined) {
|
|
428
|
+
request['size'] = limit; // only support 5, 10, 15, 16
|
|
429
|
+
}
|
|
430
|
+
const response = await this.v2PublicGetOrderbookQuoteCurrencyTargetCurrency(this.extend(request, params));
|
|
431
|
+
//
|
|
432
|
+
// {
|
|
433
|
+
// "result": "success",
|
|
434
|
+
// "error_code": "0",
|
|
435
|
+
// "timestamp": 1701071108673,
|
|
436
|
+
// "id": "1701071108673001",
|
|
437
|
+
// "quote_currency": "KRW",
|
|
438
|
+
// "target_currency": "BTC",
|
|
439
|
+
// "order_book_unit": "0.0",
|
|
440
|
+
// "bids": [
|
|
441
|
+
// {
|
|
442
|
+
// "price": "50048000",
|
|
443
|
+
// "qty": "0.01080229"
|
|
444
|
+
// }
|
|
445
|
+
// ],
|
|
446
|
+
// "asks": [
|
|
447
|
+
// {
|
|
448
|
+
// "price": "50058000",
|
|
449
|
+
// "qty": "0.00272592"
|
|
450
|
+
// }
|
|
451
|
+
// ]
|
|
452
|
+
// }
|
|
453
|
+
//
|
|
454
|
+
const timestamp = this.safeInteger(response, 'timestamp');
|
|
455
|
+
return this.parseOrderBook(response, market['symbol'], timestamp, 'bids', 'asks', 'price', 'qty');
|
|
294
456
|
}
|
|
295
457
|
async fetchTickers(symbols = undefined, params = {}) {
|
|
296
458
|
/**
|
|
297
459
|
* @method
|
|
298
460
|
* @name coinone#fetchTickers
|
|
299
461
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
462
|
+
* @see https://docs.coinone.co.kr/v1.0/reference/tickers
|
|
463
|
+
* @see https://docs.coinone.co.kr/v1.0/reference/ticker
|
|
300
464
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
301
465
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
302
466
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -304,28 +468,62 @@ export default class coinone extends Exchange {
|
|
|
304
468
|
await this.loadMarkets();
|
|
305
469
|
symbols = this.marketSymbols(symbols);
|
|
306
470
|
const request = {
|
|
307
|
-
'
|
|
308
|
-
'format': 'json',
|
|
471
|
+
'quote_currency': 'KRW',
|
|
309
472
|
};
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
473
|
+
let market = undefined;
|
|
474
|
+
let response = undefined;
|
|
475
|
+
if (symbols !== undefined) {
|
|
476
|
+
const first = this.safeString(symbols, 0);
|
|
477
|
+
market = this.market(first);
|
|
478
|
+
request['quote_currency'] = market['quote'];
|
|
479
|
+
request['target_currency'] = market['base'];
|
|
480
|
+
response = await this.v2PublicGetTickerNewQuoteCurrencyTargetCurrency(this.extend(request, params));
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
response = await this.v2PublicGetTickerNewQuoteCurrency(this.extend(request, params));
|
|
321
484
|
}
|
|
322
|
-
|
|
485
|
+
//
|
|
486
|
+
// {
|
|
487
|
+
// "result": "success",
|
|
488
|
+
// "error_code": "0",
|
|
489
|
+
// "server_time": 1701073358487,
|
|
490
|
+
// "tickers": [
|
|
491
|
+
// {
|
|
492
|
+
// "quote_currency": "krw",
|
|
493
|
+
// "target_currency": "btc",
|
|
494
|
+
// "timestamp": 1701073357818,
|
|
495
|
+
// "high": "50543000.0",
|
|
496
|
+
// "low": "49945000.0",
|
|
497
|
+
// "first": "50487000.0",
|
|
498
|
+
// "last": "50062000.0",
|
|
499
|
+
// "quote_volume": "11349804285.3859",
|
|
500
|
+
// "target_volume": "226.07268994",
|
|
501
|
+
// "best_asks": [
|
|
502
|
+
// {
|
|
503
|
+
// "price": "50081000.0",
|
|
504
|
+
// "qty": "0.18471358"
|
|
505
|
+
// }
|
|
506
|
+
// ],
|
|
507
|
+
// "best_bids": [
|
|
508
|
+
// {
|
|
509
|
+
// "price": "50062000.0",
|
|
510
|
+
// "qty": "0.04213455"
|
|
511
|
+
// }
|
|
512
|
+
// ],
|
|
513
|
+
// "id": "1701073357818001"
|
|
514
|
+
// }
|
|
515
|
+
// ]
|
|
516
|
+
// }
|
|
517
|
+
//
|
|
518
|
+
const data = this.safeValue(response, 'tickers', []);
|
|
519
|
+
return this.parseTickers(data, symbols);
|
|
323
520
|
}
|
|
324
521
|
async fetchTicker(symbol, params = {}) {
|
|
325
522
|
/**
|
|
326
523
|
* @method
|
|
327
524
|
* @name coinone#fetchTicker
|
|
328
525
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
526
|
+
* @see https://docs.coinone.co.kr/v1.0/reference/ticker
|
|
329
527
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
330
528
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
331
529
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -333,53 +531,102 @@ export default class coinone extends Exchange {
|
|
|
333
531
|
await this.loadMarkets();
|
|
334
532
|
const market = this.market(symbol);
|
|
335
533
|
const request = {
|
|
336
|
-
'
|
|
337
|
-
'
|
|
534
|
+
'quote_currency': market['quote'],
|
|
535
|
+
'target_currency': market['base'],
|
|
338
536
|
};
|
|
339
|
-
const response = await this.
|
|
340
|
-
|
|
537
|
+
const response = await this.v2PublicGetTickerNewQuoteCurrencyTargetCurrency(this.extend(request, params));
|
|
538
|
+
//
|
|
539
|
+
// {
|
|
540
|
+
// "result": "success",
|
|
541
|
+
// "error_code": "0",
|
|
542
|
+
// "server_time": 1701073358487,
|
|
543
|
+
// "tickers": [
|
|
544
|
+
// {
|
|
545
|
+
// "quote_currency": "krw",
|
|
546
|
+
// "target_currency": "btc",
|
|
547
|
+
// "timestamp": 1701073357818,
|
|
548
|
+
// "high": "50543000.0",
|
|
549
|
+
// "low": "49945000.0",
|
|
550
|
+
// "first": "50487000.0",
|
|
551
|
+
// "last": "50062000.0",
|
|
552
|
+
// "quote_volume": "11349804285.3859",
|
|
553
|
+
// "target_volume": "226.07268994",
|
|
554
|
+
// "best_asks": [
|
|
555
|
+
// {
|
|
556
|
+
// "price": "50081000.0",
|
|
557
|
+
// "qty": "0.18471358"
|
|
558
|
+
// }
|
|
559
|
+
// ],
|
|
560
|
+
// "best_bids": [
|
|
561
|
+
// {
|
|
562
|
+
// "price": "50062000.0",
|
|
563
|
+
// "qty": "0.04213455"
|
|
564
|
+
// }
|
|
565
|
+
// ],
|
|
566
|
+
// "id": "1701073357818001"
|
|
567
|
+
// }
|
|
568
|
+
// ]
|
|
569
|
+
// }
|
|
570
|
+
//
|
|
571
|
+
const data = this.safeValue(response, 'tickers', []);
|
|
572
|
+
const ticker = this.safeValue(data, 0, {});
|
|
573
|
+
return this.parseTicker(ticker, market);
|
|
341
574
|
}
|
|
342
575
|
parseTicker(ticker, market = undefined) {
|
|
343
576
|
//
|
|
344
577
|
// {
|
|
345
|
-
// "
|
|
346
|
-
// "
|
|
347
|
-
// "
|
|
348
|
-
// "high":"0
|
|
349
|
-
// "
|
|
350
|
-
// "
|
|
351
|
-
// "
|
|
352
|
-
// "
|
|
353
|
-
// "
|
|
354
|
-
// "
|
|
355
|
-
//
|
|
578
|
+
// "quote_currency": "krw",
|
|
579
|
+
// "target_currency": "btc",
|
|
580
|
+
// "timestamp": 1701073357818,
|
|
581
|
+
// "high": "50543000.0",
|
|
582
|
+
// "low": "49945000.0",
|
|
583
|
+
// "first": "50487000.0",
|
|
584
|
+
// "last": "50062000.0",
|
|
585
|
+
// "quote_volume": "11349804285.3859",
|
|
586
|
+
// "target_volume": "226.07268994",
|
|
587
|
+
// "best_asks": [
|
|
588
|
+
// {
|
|
589
|
+
// "price": "50081000.0",
|
|
590
|
+
// "qty": "0.18471358"
|
|
591
|
+
// }
|
|
592
|
+
// ],
|
|
593
|
+
// "best_bids": [
|
|
594
|
+
// {
|
|
595
|
+
// "price": "50062000.0",
|
|
596
|
+
// "qty": "0.04213455"
|
|
597
|
+
// }
|
|
598
|
+
// ],
|
|
599
|
+
// "id": "1701073357818001"
|
|
356
600
|
// }
|
|
357
601
|
//
|
|
358
|
-
const timestamp = this.
|
|
359
|
-
const open = this.safeString(ticker, 'first');
|
|
602
|
+
const timestamp = this.safeInteger(ticker, 'timestamp');
|
|
360
603
|
const last = this.safeString(ticker, 'last');
|
|
361
|
-
const
|
|
362
|
-
const
|
|
604
|
+
const asks = this.safeValue(ticker, 'best_asks');
|
|
605
|
+
const bids = this.safeValue(ticker, 'best_bids');
|
|
606
|
+
const baseId = this.safeString(ticker, 'target_currency');
|
|
607
|
+
const quoteId = this.safeString(ticker, 'quote_currency');
|
|
608
|
+
const base = this.safeCurrencyCode(baseId);
|
|
609
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
363
610
|
return this.safeTicker({
|
|
364
|
-
'symbol':
|
|
611
|
+
'symbol': base + '/' + quote,
|
|
365
612
|
'timestamp': timestamp,
|
|
366
613
|
'datetime': this.iso8601(timestamp),
|
|
367
614
|
'high': this.safeString(ticker, 'high'),
|
|
368
615
|
'low': this.safeString(ticker, 'low'),
|
|
369
|
-
'bid':
|
|
370
|
-
'bidVolume':
|
|
371
|
-
'ask':
|
|
372
|
-
'askVolume':
|
|
616
|
+
'bid': this.safeString(bids, 'price'),
|
|
617
|
+
'bidVolume': this.safeString(bids, 'qty'),
|
|
618
|
+
'ask': this.safeString(asks, 'price'),
|
|
619
|
+
'askVolume': this.safeString(asks, 'qty'),
|
|
373
620
|
'vwap': undefined,
|
|
374
|
-
'open':
|
|
621
|
+
'open': this.safeString(ticker, 'first'),
|
|
375
622
|
'close': last,
|
|
376
623
|
'last': last,
|
|
377
|
-
'previousClose':
|
|
624
|
+
'previousClose': undefined,
|
|
378
625
|
'change': undefined,
|
|
379
626
|
'percentage': undefined,
|
|
380
627
|
'average': undefined,
|
|
381
|
-
'baseVolume': this.safeString(ticker, '
|
|
382
|
-
'quoteVolume':
|
|
628
|
+
'baseVolume': this.safeString(ticker, 'target_volume'),
|
|
629
|
+
'quoteVolume': this.safeString(ticker, 'quote_volume'),
|
|
383
630
|
'info': ticker,
|
|
384
631
|
}, market);
|
|
385
632
|
}
|
|
@@ -388,10 +635,11 @@ export default class coinone extends Exchange {
|
|
|
388
635
|
// fetchTrades (public)
|
|
389
636
|
//
|
|
390
637
|
// {
|
|
391
|
-
// "
|
|
392
|
-
// "
|
|
393
|
-
// "
|
|
394
|
-
// "
|
|
638
|
+
// "id": "1701075265708001",
|
|
639
|
+
// "timestamp": 1701075265708,
|
|
640
|
+
// "price": "50020000",
|
|
641
|
+
// "qty": "0.00155177",
|
|
642
|
+
// "is_seller_maker": false
|
|
395
643
|
// }
|
|
396
644
|
//
|
|
397
645
|
// fetchMyTrades (private)
|
|
@@ -406,25 +654,12 @@ export default class coinone extends Exchange {
|
|
|
406
654
|
// "orderId": "E84A1AC2-8088-4FA0-B093-A3BCDB9B3C85"
|
|
407
655
|
// }
|
|
408
656
|
//
|
|
409
|
-
const timestamp = this.
|
|
657
|
+
const timestamp = this.safeInteger(trade, 'timestamp');
|
|
410
658
|
market = this.safeMarket(undefined, market);
|
|
411
|
-
const
|
|
412
|
-
let side =
|
|
413
|
-
if (
|
|
414
|
-
|
|
415
|
-
side = 'sell';
|
|
416
|
-
}
|
|
417
|
-
else if (is_ask === '0') {
|
|
418
|
-
side = 'buy';
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
else {
|
|
422
|
-
if (side === 'ask') {
|
|
423
|
-
side = 'sell';
|
|
424
|
-
}
|
|
425
|
-
else if (side === 'bid') {
|
|
426
|
-
side = 'buy';
|
|
427
|
-
}
|
|
659
|
+
const isSellerMaker = this.safeValue(trade, 'is_seller_maker');
|
|
660
|
+
let side = undefined;
|
|
661
|
+
if (isSellerMaker !== undefined) {
|
|
662
|
+
side = isSellerMaker ? 'sell' : 'buy';
|
|
428
663
|
}
|
|
429
664
|
const priceString = this.safeString(trade, 'price');
|
|
430
665
|
const amountString = this.safeString(trade, 'qty');
|
|
@@ -463,6 +698,7 @@ export default class coinone extends Exchange {
|
|
|
463
698
|
* @method
|
|
464
699
|
* @name coinone#fetchTrades
|
|
465
700
|
* @description get the list of most recent trades for a particular symbol
|
|
701
|
+
* @see https://docs.coinone.co.kr/v1.0/reference/recent-completed-orders
|
|
466
702
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
467
703
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
468
704
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
@@ -472,28 +708,33 @@ export default class coinone extends Exchange {
|
|
|
472
708
|
await this.loadMarkets();
|
|
473
709
|
const market = this.market(symbol);
|
|
474
710
|
const request = {
|
|
475
|
-
'
|
|
476
|
-
'
|
|
711
|
+
'quote_currency': market['quote'],
|
|
712
|
+
'target_currency': market['base'],
|
|
477
713
|
};
|
|
478
|
-
|
|
714
|
+
if (limit !== undefined) {
|
|
715
|
+
request['size'] = limit; // only support 10, 50, 100, 150, 200
|
|
716
|
+
}
|
|
717
|
+
const response = await this.v2PublicGetTradesQuoteCurrencyTargetCurrency(this.extend(request, params));
|
|
479
718
|
//
|
|
480
719
|
// {
|
|
481
720
|
// "result": "success",
|
|
482
|
-
// "
|
|
483
|
-
// "
|
|
484
|
-
// "
|
|
485
|
-
// "
|
|
721
|
+
// "error_code": "0",
|
|
722
|
+
// "server_time": 1701075315771,
|
|
723
|
+
// "quote_currency": "KRW",
|
|
724
|
+
// "target_currency": "BTC",
|
|
725
|
+
// "transactions": [
|
|
486
726
|
// {
|
|
487
|
-
// "
|
|
488
|
-
// "
|
|
489
|
-
// "
|
|
490
|
-
// "
|
|
727
|
+
// "id": "1701075265708001",
|
|
728
|
+
// "timestamp": 1701075265708,
|
|
729
|
+
// "price": "50020000",
|
|
730
|
+
// "qty": "0.00155177",
|
|
731
|
+
// "is_seller_maker": false
|
|
491
732
|
// }
|
|
492
733
|
// ]
|
|
493
734
|
// }
|
|
494
735
|
//
|
|
495
|
-
const
|
|
496
|
-
return this.parseTrades(
|
|
736
|
+
const data = this.safeValue(response, 'transactions', []);
|
|
737
|
+
return this.parseTrades(data, market, since, limit);
|
|
497
738
|
}
|
|
498
739
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
499
740
|
/**
|
|
@@ -549,7 +790,7 @@ export default class coinone extends Exchange {
|
|
|
549
790
|
'order_id': id,
|
|
550
791
|
'currency': market['id'],
|
|
551
792
|
};
|
|
552
|
-
const response = await this.
|
|
793
|
+
const response = await this.v2PrivatePostOrderQueryOrder(this.extend(request, params));
|
|
553
794
|
//
|
|
554
795
|
// {
|
|
555
796
|
// "result": "success",
|
|
@@ -760,7 +1001,7 @@ export default class coinone extends Exchange {
|
|
|
760
1001
|
const request = {
|
|
761
1002
|
'currency': market['id'],
|
|
762
1003
|
};
|
|
763
|
-
const response = await this.
|
|
1004
|
+
const response = await this.v2PrivatePostOrderCompleteOrders(this.extend(request, params));
|
|
764
1005
|
//
|
|
765
1006
|
// despite the name of the endpoint it returns trades which may have a duplicate orderId
|
|
766
1007
|
// https://github.com/ccxt/ccxt/pull/7067
|
|
@@ -813,7 +1054,7 @@ export default class coinone extends Exchange {
|
|
|
813
1054
|
'is_ask': isAsk,
|
|
814
1055
|
'currency': this.marketId(symbol),
|
|
815
1056
|
};
|
|
816
|
-
const response = await this.
|
|
1057
|
+
const response = await this.v2PrivatePostOrderCancel(this.extend(request, params));
|
|
817
1058
|
//
|
|
818
1059
|
// {
|
|
819
1060
|
// "result": "success",
|
|
@@ -832,7 +1073,7 @@ export default class coinone extends Exchange {
|
|
|
832
1073
|
* @returns {object} a list of [address structures]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
833
1074
|
*/
|
|
834
1075
|
await this.loadMarkets();
|
|
835
|
-
const response = await this.
|
|
1076
|
+
const response = await this.v2PrivatePostAccountDepositAddress(params);
|
|
836
1077
|
//
|
|
837
1078
|
// {
|
|
838
1079
|
// "result": "success",
|
|
@@ -885,6 +1126,16 @@ export default class coinone extends Exchange {
|
|
|
885
1126
|
const request = this.implodeParams(path, params);
|
|
886
1127
|
const query = this.omit(params, this.extractParams(path));
|
|
887
1128
|
let url = this.urls['api']['rest'] + '/';
|
|
1129
|
+
if (api === 'v2Public') {
|
|
1130
|
+
url = this.urls['api']['v2Public'] + '/';
|
|
1131
|
+
api = 'public';
|
|
1132
|
+
}
|
|
1133
|
+
else if (api === 'v2Private') {
|
|
1134
|
+
url = this.urls['api']['v2Private'] + '/';
|
|
1135
|
+
}
|
|
1136
|
+
else if (api === 'v2_1Private') {
|
|
1137
|
+
url = this.urls['api']['v2_1Private'] + '/';
|
|
1138
|
+
}
|
|
888
1139
|
if (api === 'public') {
|
|
889
1140
|
url += request;
|
|
890
1141
|
if (Object.keys(query).length) {
|
|
@@ -893,7 +1144,7 @@ export default class coinone extends Exchange {
|
|
|
893
1144
|
}
|
|
894
1145
|
else {
|
|
895
1146
|
this.checkRequiredCredentials();
|
|
896
|
-
url +=
|
|
1147
|
+
url += request;
|
|
897
1148
|
const nonce = this.nonce().toString();
|
|
898
1149
|
const json = this.json(this.extend({
|
|
899
1150
|
'access_token': this.apiKey,
|