ccxt 4.2.47 → 4.2.48
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 +3 -3
- package/dist/ccxt.browser.js +304 -54
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/binance.js +3 -1
- package/dist/cjs/src/idex.js +52 -1
- package/dist/cjs/src/indodax.js +120 -19
- package/dist/cjs/src/okx.js +32 -5
- package/dist/cjs/src/pro/hitbtc.js +6 -11
- package/dist/cjs/src/upbit.js +90 -16
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/indodax.d.ts +9 -8
- package/js/src/binance.js +3 -1
- package/js/src/idex.d.ts +7 -0
- package/js/src/idex.js +52 -1
- package/js/src/indodax.d.ts +3 -1
- package/js/src/indodax.js +120 -19
- package/js/src/okx.js +32 -5
- package/js/src/pro/hitbtc.js +6 -11
- package/js/src/upbit.d.ts +2 -0
- package/js/src/upbit.js +90 -16
- package/package.json +1 -1
package/js/src/indodax.js
CHANGED
|
@@ -100,7 +100,7 @@ export default class indodax extends Exchange {
|
|
|
100
100
|
'urls': {
|
|
101
101
|
'logo': 'https://user-images.githubusercontent.com/51840849/87070508-9358c880-c221-11ea-8dc5-5391afbbb422.jpg',
|
|
102
102
|
'api': {
|
|
103
|
-
'public': 'https://indodax.com
|
|
103
|
+
'public': 'https://indodax.com',
|
|
104
104
|
'private': 'https://indodax.com/tapi',
|
|
105
105
|
},
|
|
106
106
|
'www': 'https://www.indodax.com',
|
|
@@ -110,14 +110,15 @@ export default class indodax extends Exchange {
|
|
|
110
110
|
'api': {
|
|
111
111
|
'public': {
|
|
112
112
|
'get': {
|
|
113
|
-
'server_time': 5,
|
|
114
|
-
'pairs': 5,
|
|
115
|
-
'price_increments': 5,
|
|
116
|
-
'summaries': 5,
|
|
117
|
-
'
|
|
118
|
-
'
|
|
119
|
-
'{pair}
|
|
120
|
-
'{pair}
|
|
113
|
+
'api/server_time': 5,
|
|
114
|
+
'api/pairs': 5,
|
|
115
|
+
'api/price_increments': 5,
|
|
116
|
+
'api/summaries': 5,
|
|
117
|
+
'api/ticker/{pair}': 5,
|
|
118
|
+
'api/ticker_all': 5,
|
|
119
|
+
'api/trades/{pair}': 5,
|
|
120
|
+
'api/depth/{pair}': 5,
|
|
121
|
+
'tradingview/history_v2': 5,
|
|
121
122
|
},
|
|
122
123
|
},
|
|
123
124
|
'private': {
|
|
@@ -182,6 +183,16 @@ export default class indodax extends Exchange {
|
|
|
182
183
|
// 'ETH': 'eth'
|
|
183
184
|
// 'BASE': 'base'
|
|
184
185
|
},
|
|
186
|
+
'timeframes': {
|
|
187
|
+
'1m': '1',
|
|
188
|
+
'15m': '15',
|
|
189
|
+
'30m': '30',
|
|
190
|
+
'1h': '60',
|
|
191
|
+
'4h': '240',
|
|
192
|
+
'1d': '1D',
|
|
193
|
+
'3d': '3D',
|
|
194
|
+
'1w': '1W',
|
|
195
|
+
},
|
|
185
196
|
},
|
|
186
197
|
'commonCurrencies': {
|
|
187
198
|
'STR': 'XLM',
|
|
@@ -201,10 +212,11 @@ export default class indodax extends Exchange {
|
|
|
201
212
|
* @method
|
|
202
213
|
* @name indodax#fetchTime
|
|
203
214
|
* @description fetches the current integer timestamp in milliseconds from the exchange server
|
|
215
|
+
* @see https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#server-time
|
|
204
216
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
205
217
|
* @returns {int} the current integer timestamp in milliseconds from the exchange server
|
|
206
218
|
*/
|
|
207
|
-
const response = await this.
|
|
219
|
+
const response = await this.publicGetApiServerTime(params);
|
|
208
220
|
//
|
|
209
221
|
// {
|
|
210
222
|
// "timezone": "UTC",
|
|
@@ -218,10 +230,11 @@ export default class indodax extends Exchange {
|
|
|
218
230
|
* @method
|
|
219
231
|
* @name indodax#fetchMarkets
|
|
220
232
|
* @description retrieves data on all markets for indodax
|
|
233
|
+
* @see https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#pairs
|
|
221
234
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
222
235
|
* @returns {object[]} an array of objects representing market data
|
|
223
236
|
*/
|
|
224
|
-
const response = await this.
|
|
237
|
+
const response = await this.publicGetApiPairs(params);
|
|
225
238
|
//
|
|
226
239
|
// [
|
|
227
240
|
// {
|
|
@@ -338,6 +351,7 @@ export default class indodax extends Exchange {
|
|
|
338
351
|
* @method
|
|
339
352
|
* @name indodax#fetchBalance
|
|
340
353
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
354
|
+
* @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#get-info-endpoint
|
|
341
355
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
342
356
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
343
357
|
*/
|
|
@@ -380,6 +394,7 @@ export default class indodax extends Exchange {
|
|
|
380
394
|
* @method
|
|
381
395
|
* @name indodax#fetchOrderBook
|
|
382
396
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
397
|
+
* @see https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#depth
|
|
383
398
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
384
399
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
385
400
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -388,9 +403,9 @@ export default class indodax extends Exchange {
|
|
|
388
403
|
await this.loadMarkets();
|
|
389
404
|
const market = this.market(symbol);
|
|
390
405
|
const request = {
|
|
391
|
-
'pair': market['
|
|
406
|
+
'pair': market['base'] + market['quote'],
|
|
392
407
|
};
|
|
393
|
-
const orderbook = await this.
|
|
408
|
+
const orderbook = await this.publicGetApiDepthPair(this.extend(request, params));
|
|
394
409
|
return this.parseOrderBook(orderbook, market['symbol'], undefined, 'buy', 'sell');
|
|
395
410
|
}
|
|
396
411
|
parseTicker(ticker, market = undefined) {
|
|
@@ -439,6 +454,7 @@ export default class indodax extends Exchange {
|
|
|
439
454
|
* @method
|
|
440
455
|
* @name indodax#fetchTicker
|
|
441
456
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
457
|
+
* @see https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#ticker
|
|
442
458
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
443
459
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
444
460
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -446,9 +462,9 @@ export default class indodax extends Exchange {
|
|
|
446
462
|
await this.loadMarkets();
|
|
447
463
|
const market = this.market(symbol);
|
|
448
464
|
const request = {
|
|
449
|
-
'pair': market['
|
|
465
|
+
'pair': market['base'] + market['quote'],
|
|
450
466
|
};
|
|
451
|
-
const response = await this.
|
|
467
|
+
const response = await this.publicGetApiTickerPair(this.extend(request, params));
|
|
452
468
|
//
|
|
453
469
|
// {
|
|
454
470
|
// "ticker": {
|
|
@@ -493,7 +509,7 @@ export default class indodax extends Exchange {
|
|
|
493
509
|
// }
|
|
494
510
|
// }
|
|
495
511
|
//
|
|
496
|
-
const response = await this.
|
|
512
|
+
const response = await this.publicGetApiTickerAll(params);
|
|
497
513
|
const tickers = this.safeValue(response, 'tickers');
|
|
498
514
|
return this.parseTickers(tickers, symbols);
|
|
499
515
|
}
|
|
@@ -520,6 +536,7 @@ export default class indodax extends Exchange {
|
|
|
520
536
|
* @method
|
|
521
537
|
* @name indodax#fetchTrades
|
|
522
538
|
* @description get the list of most recent trades for a particular symbol
|
|
539
|
+
* @see https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#trades
|
|
523
540
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
524
541
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
525
542
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
@@ -529,11 +546,81 @@ export default class indodax extends Exchange {
|
|
|
529
546
|
await this.loadMarkets();
|
|
530
547
|
const market = this.market(symbol);
|
|
531
548
|
const request = {
|
|
532
|
-
'pair': market['
|
|
549
|
+
'pair': market['base'] + market['quote'],
|
|
533
550
|
};
|
|
534
|
-
const response = await this.
|
|
551
|
+
const response = await this.publicGetApiTradesPair(this.extend(request, params));
|
|
535
552
|
return this.parseTrades(response, market, since, limit);
|
|
536
553
|
}
|
|
554
|
+
parseOHLCV(ohlcv, market = undefined) {
|
|
555
|
+
//
|
|
556
|
+
// {
|
|
557
|
+
// "Time": 1708416900,
|
|
558
|
+
// "Open": 51707.52,
|
|
559
|
+
// "High": 51707.52,
|
|
560
|
+
// "Low": 51707.52,
|
|
561
|
+
// "Close": 51707.52,
|
|
562
|
+
// "Volume": "0"
|
|
563
|
+
// }
|
|
564
|
+
//
|
|
565
|
+
return [
|
|
566
|
+
this.safeTimestamp(ohlcv, 'Time'),
|
|
567
|
+
this.safeNumber(ohlcv, 'Open'),
|
|
568
|
+
this.safeNumber(ohlcv, 'High'),
|
|
569
|
+
this.safeNumber(ohlcv, 'Low'),
|
|
570
|
+
this.safeNumber(ohlcv, 'Close'),
|
|
571
|
+
this.safeNumber(ohlcv, 'Volume'),
|
|
572
|
+
];
|
|
573
|
+
}
|
|
574
|
+
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
575
|
+
/**
|
|
576
|
+
* @method
|
|
577
|
+
* @name indodax#fetchOHLCV
|
|
578
|
+
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
579
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
580
|
+
* @param {string} timeframe the length of time each candle represents
|
|
581
|
+
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
582
|
+
* @param {int} [limit] the maximum amount of candles to fetch
|
|
583
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
584
|
+
* @param {int} [params.until] timestamp in ms of the latest candle to fetch
|
|
585
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
586
|
+
*/
|
|
587
|
+
await this.loadMarkets();
|
|
588
|
+
const market = this.market(symbol);
|
|
589
|
+
const timeframes = this.options['timeframes'];
|
|
590
|
+
const selectedTimeframe = this.safeString(timeframes, timeframe, timeframe);
|
|
591
|
+
const now = this.seconds();
|
|
592
|
+
const until = this.safeInteger2(params, 'until', 'till', now);
|
|
593
|
+
params = this.omit(params, ['until', 'till']);
|
|
594
|
+
const request = {
|
|
595
|
+
'to': until,
|
|
596
|
+
'tf': selectedTimeframe,
|
|
597
|
+
'symbol': market['base'] + market['quote'],
|
|
598
|
+
};
|
|
599
|
+
if (limit === undefined) {
|
|
600
|
+
limit = 1000;
|
|
601
|
+
}
|
|
602
|
+
if (since !== undefined) {
|
|
603
|
+
request['from'] = Math.floor(since / 1000);
|
|
604
|
+
}
|
|
605
|
+
else {
|
|
606
|
+
const duration = this.parseTimeframe(timeframe);
|
|
607
|
+
request['from'] = now - limit * duration - 1;
|
|
608
|
+
}
|
|
609
|
+
const response = await this.publicGetTradingviewHistoryV2(this.extend(request, params));
|
|
610
|
+
//
|
|
611
|
+
// [
|
|
612
|
+
// {
|
|
613
|
+
// "Time": 1708416900,
|
|
614
|
+
// "Open": 51707.52,
|
|
615
|
+
// "High": 51707.52,
|
|
616
|
+
// "Low": 51707.52,
|
|
617
|
+
// "Close": 51707.52,
|
|
618
|
+
// "Volume": "0"
|
|
619
|
+
// }
|
|
620
|
+
// ]
|
|
621
|
+
//
|
|
622
|
+
return this.parseOHLCVs(response, market, timeframe, since, limit);
|
|
623
|
+
}
|
|
537
624
|
parseOrderStatus(status) {
|
|
538
625
|
const statuses = {
|
|
539
626
|
'open': 'open',
|
|
@@ -625,6 +712,7 @@ export default class indodax extends Exchange {
|
|
|
625
712
|
* @method
|
|
626
713
|
* @name indodax#fetchOrder
|
|
627
714
|
* @description fetches information on an order made by the user
|
|
715
|
+
* @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#get-order-endpoints
|
|
628
716
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
629
717
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
630
718
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
@@ -649,6 +737,7 @@ export default class indodax extends Exchange {
|
|
|
649
737
|
* @method
|
|
650
738
|
* @name indodax#fetchOpenOrders
|
|
651
739
|
* @description fetch all unfilled currently open orders
|
|
740
|
+
* @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#open-orders-endpoints
|
|
652
741
|
* @param {string} symbol unified market symbol
|
|
653
742
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
654
743
|
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
@@ -689,6 +778,7 @@ export default class indodax extends Exchange {
|
|
|
689
778
|
* @method
|
|
690
779
|
* @name indodax#fetchClosedOrders
|
|
691
780
|
* @description fetches information on multiple closed orders made by the user
|
|
781
|
+
* @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#order-history
|
|
692
782
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
693
783
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
694
784
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
@@ -713,6 +803,7 @@ export default class indodax extends Exchange {
|
|
|
713
803
|
* @method
|
|
714
804
|
* @name indodax#createOrder
|
|
715
805
|
* @description create a trade order
|
|
806
|
+
* @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#trade-endpoints
|
|
716
807
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
717
808
|
* @param {string} type 'market' or 'limit'
|
|
718
809
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -752,6 +843,7 @@ export default class indodax extends Exchange {
|
|
|
752
843
|
* @method
|
|
753
844
|
* @name indodax#cancelOrder
|
|
754
845
|
* @description cancels an open order
|
|
846
|
+
* @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#cancel-order-endpoints
|
|
755
847
|
* @param {string} id order id
|
|
756
848
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
757
849
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -778,6 +870,7 @@ export default class indodax extends Exchange {
|
|
|
778
870
|
* @method
|
|
779
871
|
* @name indodax#fetchTransactionFee
|
|
780
872
|
* @description fetch the fee for a transaction
|
|
873
|
+
* @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#withdraw-fee-endpoints
|
|
781
874
|
* @param {string} code unified currency code
|
|
782
875
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
783
876
|
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
@@ -811,6 +904,7 @@ export default class indodax extends Exchange {
|
|
|
811
904
|
* @method
|
|
812
905
|
* @name indodax#fetchDepositsWithdrawals
|
|
813
906
|
* @description fetch history of deposits and withdrawals
|
|
907
|
+
* @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#transaction-history-endpoints
|
|
814
908
|
* @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
|
|
815
909
|
* @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
|
|
816
910
|
* @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
|
|
@@ -912,6 +1006,7 @@ export default class indodax extends Exchange {
|
|
|
912
1006
|
* @method
|
|
913
1007
|
* @name indodax#withdraw
|
|
914
1008
|
* @description make a withdrawal
|
|
1009
|
+
* @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#withdraw-coin-endpoints
|
|
915
1010
|
* @param {string} code unified currency code
|
|
916
1011
|
* @param {float} amount the amount to withdraw
|
|
917
1012
|
* @param {string} address the address to withdraw to
|
|
@@ -1045,6 +1140,7 @@ export default class indodax extends Exchange {
|
|
|
1045
1140
|
* @method
|
|
1046
1141
|
* @name indodax#fetchDepositAddresses
|
|
1047
1142
|
* @description fetch deposit addresses for multiple currencies and chain types
|
|
1143
|
+
* @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#general-information-on-endpoints
|
|
1048
1144
|
* @param {string[]} [codes] list of unified currency codes, default is undefined
|
|
1049
1145
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1050
1146
|
* @returns {object} a list of [address structures]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
@@ -1127,7 +1223,12 @@ export default class indodax extends Exchange {
|
|
|
1127
1223
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
1128
1224
|
let url = this.urls['api'][api];
|
|
1129
1225
|
if (api === 'public') {
|
|
1130
|
-
|
|
1226
|
+
const query = this.omit(params, this.extractParams(path));
|
|
1227
|
+
const requestPath = '/' + this.implodeParams(path, params);
|
|
1228
|
+
url = url + requestPath;
|
|
1229
|
+
if (Object.keys(query).length) {
|
|
1230
|
+
url += '?' + this.urlencodeWithArrayRepeat(query);
|
|
1231
|
+
}
|
|
1131
1232
|
}
|
|
1132
1233
|
else {
|
|
1133
1234
|
this.checkRequiredCredentials();
|
package/js/src/okx.js
CHANGED
|
@@ -5231,6 +5231,7 @@ export default class okx extends Exchange {
|
|
|
5231
5231
|
* @method
|
|
5232
5232
|
* @name okx#fetchPositions
|
|
5233
5233
|
* @see https://www.okx.com/docs-v5/en/#rest-api-account-get-positions
|
|
5234
|
+
* @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-positions-history history
|
|
5234
5235
|
* @description fetch all open positions
|
|
5235
5236
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
5236
5237
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -5371,13 +5372,38 @@ export default class okx extends Exchange {
|
|
|
5371
5372
|
// "vegaBS": "",
|
|
5372
5373
|
// "vegaPA": ""
|
|
5373
5374
|
// }
|
|
5375
|
+
// history
|
|
5376
|
+
// {
|
|
5377
|
+
// "cTime":"1708351230102",
|
|
5378
|
+
// "ccy":"USDT",
|
|
5379
|
+
// "closeAvgPx":"1.2567",
|
|
5380
|
+
// "closeTotalPos":"40",
|
|
5381
|
+
// "direction":"short",
|
|
5382
|
+
// "fee":"-0.0351036",
|
|
5383
|
+
// "fundingFee":"0",
|
|
5384
|
+
// "instId":"SUSHI-USDT-SWAP",
|
|
5385
|
+
// "instType":"SWAP",
|
|
5386
|
+
// "lever":"10.0",
|
|
5387
|
+
// "liqPenalty":"0",
|
|
5388
|
+
// "mgnMode":"isolated",
|
|
5389
|
+
// "openAvgPx":"1.2462",
|
|
5390
|
+
// "openMaxPos":"40",
|
|
5391
|
+
// "pnl":"-0.42",
|
|
5392
|
+
// "pnlRatio":"-0.0912982667308618",
|
|
5393
|
+
// "posId":"666159086676836352",
|
|
5394
|
+
// "realizedPnl":"-0.4551036",
|
|
5395
|
+
// "triggerPx":"",
|
|
5396
|
+
// "type":"2",
|
|
5397
|
+
// "uTime":"1708354805699",
|
|
5398
|
+
// "uly":"SUSHI-USDT"
|
|
5399
|
+
// }
|
|
5374
5400
|
//
|
|
5375
5401
|
const marketId = this.safeString(position, 'instId');
|
|
5376
5402
|
market = this.safeMarket(marketId, market);
|
|
5377
5403
|
const symbol = market['symbol'];
|
|
5378
5404
|
const pos = this.safeString(position, 'pos'); // 'pos' field: One way mode: 0 if position is not open, 1 if open | Two way (hedge) mode: -1 if short, 1 if long, 0 if position is not open
|
|
5379
5405
|
const contractsAbs = Precise.stringAbs(pos);
|
|
5380
|
-
let side = this.
|
|
5406
|
+
let side = this.safeString2(position, 'posSide', 'direction');
|
|
5381
5407
|
const hedged = side !== 'net';
|
|
5382
5408
|
const contracts = this.parseNumber(contractsAbs);
|
|
5383
5409
|
if (market['margin']) {
|
|
@@ -5418,7 +5444,7 @@ export default class okx extends Exchange {
|
|
|
5418
5444
|
const notional = this.parseNumber(notionalString);
|
|
5419
5445
|
const marginMode = this.safeString(position, 'mgnMode');
|
|
5420
5446
|
let initialMarginString = undefined;
|
|
5421
|
-
const entryPriceString = this.
|
|
5447
|
+
const entryPriceString = this.safeString2(position, 'avgPx', 'openAvgPx');
|
|
5422
5448
|
const unrealizedPnlString = this.safeString(position, 'upl');
|
|
5423
5449
|
const leverageString = this.safeString(position, 'lever');
|
|
5424
5450
|
let initialMarginPercentage = undefined;
|
|
@@ -5449,23 +5475,24 @@ export default class okx extends Exchange {
|
|
|
5449
5475
|
const marginRatio = this.parseNumber(Precise.stringDiv(maintenanceMarginString, collateralString, 4));
|
|
5450
5476
|
return this.safePosition({
|
|
5451
5477
|
'info': position,
|
|
5452
|
-
'id':
|
|
5478
|
+
'id': this.safeString(position, 'posId'),
|
|
5453
5479
|
'symbol': symbol,
|
|
5454
5480
|
'notional': notional,
|
|
5455
5481
|
'marginMode': marginMode,
|
|
5456
5482
|
'liquidationPrice': liquidationPrice,
|
|
5457
5483
|
'entryPrice': this.parseNumber(entryPriceString),
|
|
5458
5484
|
'unrealizedPnl': this.parseNumber(unrealizedPnlString),
|
|
5485
|
+
'realizedPnl': this.safeNumber(position, 'realizedPnl'),
|
|
5459
5486
|
'percentage': percentage,
|
|
5460
5487
|
'contracts': contracts,
|
|
5461
5488
|
'contractSize': contractSize,
|
|
5462
5489
|
'markPrice': this.parseNumber(markPriceString),
|
|
5463
|
-
'lastPrice':
|
|
5490
|
+
'lastPrice': this.safeNumber(position, 'closeAvgPx'),
|
|
5464
5491
|
'side': side,
|
|
5465
5492
|
'hedged': hedged,
|
|
5466
5493
|
'timestamp': timestamp,
|
|
5467
5494
|
'datetime': this.iso8601(timestamp),
|
|
5468
|
-
'lastUpdateTimestamp':
|
|
5495
|
+
'lastUpdateTimestamp': this.safeInteger(position, 'uTime'),
|
|
5469
5496
|
'maintenanceMargin': maintenanceMargin,
|
|
5470
5497
|
'maintenanceMarginPercentage': maintenanceMarginPercentage,
|
|
5471
5498
|
'collateral': this.parseNumber(collateralString),
|
package/js/src/pro/hitbtc.js
CHANGED
|
@@ -223,7 +223,7 @@ export default class hitbtc extends hitbtcRest {
|
|
|
223
223
|
'symbols': [market['id']],
|
|
224
224
|
},
|
|
225
225
|
};
|
|
226
|
-
const orderbook = await this.subscribePublic(name,
|
|
226
|
+
const orderbook = await this.subscribePublic(name, 'orderbooks', [symbol], this.deepExtend(request, params));
|
|
227
227
|
return orderbook.limit();
|
|
228
228
|
}
|
|
229
229
|
handleOrderBook(client, message) {
|
|
@@ -252,13 +252,12 @@ export default class hitbtc extends hitbtcRest {
|
|
|
252
252
|
//
|
|
253
253
|
const data = this.safeValue2(message, 'snapshot', 'update', {});
|
|
254
254
|
const marketIds = Object.keys(data);
|
|
255
|
-
const channel = this.safeString(message, 'ch');
|
|
256
255
|
for (let i = 0; i < marketIds.length; i++) {
|
|
257
256
|
const marketId = marketIds[i];
|
|
258
257
|
const market = this.safeMarket(marketId);
|
|
259
258
|
const symbol = market['symbol'];
|
|
260
259
|
const item = data[marketId];
|
|
261
|
-
const messageHash =
|
|
260
|
+
const messageHash = 'orderbooks::' + symbol;
|
|
262
261
|
if (!(symbol in this.orderbooks)) {
|
|
263
262
|
const subscription = this.safeValue(client.subscriptions, messageHash, {});
|
|
264
263
|
const limit = this.safeInteger(subscription, 'limit');
|
|
@@ -316,7 +315,7 @@ export default class hitbtc extends hitbtcRest {
|
|
|
316
315
|
'symbols': [market['id']],
|
|
317
316
|
},
|
|
318
317
|
};
|
|
319
|
-
const result = await this.subscribePublic(name, '
|
|
318
|
+
const result = await this.subscribePublic(name, 'tickers', [symbol], this.deepExtend(request, params));
|
|
320
319
|
return this.safeValue(result, symbol);
|
|
321
320
|
}
|
|
322
321
|
async watchTickers(symbols = undefined, params = {}) {
|
|
@@ -399,7 +398,6 @@ export default class hitbtc extends hitbtcRest {
|
|
|
399
398
|
//
|
|
400
399
|
const data = this.safeValue(message, 'data', {});
|
|
401
400
|
const marketIds = Object.keys(data);
|
|
402
|
-
const channel = this.safeString(message, 'ch');
|
|
403
401
|
const newTickers = {};
|
|
404
402
|
for (let i = 0; i < marketIds.length; i++) {
|
|
405
403
|
const marketId = marketIds[i];
|
|
@@ -408,8 +406,6 @@ export default class hitbtc extends hitbtcRest {
|
|
|
408
406
|
const ticker = this.parseWsTicker(data[marketId], market);
|
|
409
407
|
this.tickers[symbol] = ticker;
|
|
410
408
|
newTickers[symbol] = ticker;
|
|
411
|
-
const messageHash = channel + '::' + symbol;
|
|
412
|
-
client.resolve(newTickers, messageHash);
|
|
413
409
|
}
|
|
414
410
|
client.resolve(newTickers, 'tickers');
|
|
415
411
|
const messageHashes = this.findMessageHashes(client, 'tickers::');
|
|
@@ -425,7 +421,6 @@ export default class hitbtc extends hitbtcRest {
|
|
|
425
421
|
client.resolve(tickers, messageHash);
|
|
426
422
|
}
|
|
427
423
|
}
|
|
428
|
-
client.resolve(this.tickers, channel);
|
|
429
424
|
return message;
|
|
430
425
|
}
|
|
431
426
|
parseWsTicker(ticker, market = undefined) {
|
|
@@ -506,7 +501,7 @@ export default class hitbtc extends hitbtcRest {
|
|
|
506
501
|
request['limit'] = limit;
|
|
507
502
|
}
|
|
508
503
|
const name = 'trades';
|
|
509
|
-
const trades = await this.subscribePublic(name,
|
|
504
|
+
const trades = await this.subscribePublic(name, 'trades', [symbol], this.deepExtend(request, params));
|
|
510
505
|
if (this.newUpdates) {
|
|
511
506
|
limit = trades.getLimit(symbol, limit);
|
|
512
507
|
}
|
|
@@ -635,7 +630,7 @@ export default class hitbtc extends hitbtcRest {
|
|
|
635
630
|
if (limit !== undefined) {
|
|
636
631
|
request['params']['limit'] = limit;
|
|
637
632
|
}
|
|
638
|
-
const ohlcv = await this.subscribePublic(name,
|
|
633
|
+
const ohlcv = await this.subscribePublic(name, 'candles', [symbol], this.deepExtend(request, params));
|
|
639
634
|
if (this.newUpdates) {
|
|
640
635
|
limit = ohlcv.getLimit(symbol, limit);
|
|
641
636
|
}
|
|
@@ -696,7 +691,7 @@ export default class hitbtc extends hitbtcRest {
|
|
|
696
691
|
for (let j = 0; j < ohlcvs.length; j++) {
|
|
697
692
|
stored.append(ohlcvs[j]);
|
|
698
693
|
}
|
|
699
|
-
const messageHash =
|
|
694
|
+
const messageHash = 'candles::' + symbol;
|
|
700
695
|
client.resolve(stored, messageHash);
|
|
701
696
|
}
|
|
702
697
|
return message;
|
package/js/src/upbit.d.ts
CHANGED
|
@@ -62,7 +62,9 @@ export default class upbit extends Exchange {
|
|
|
62
62
|
createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: number, params?: {}): Promise<Order>;
|
|
63
63
|
cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
|
|
64
64
|
fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
65
|
+
fetchDeposit(id: string, code?: Str, params?: {}): Promise<Transaction>;
|
|
65
66
|
fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
67
|
+
fetchWithdrawal(id: string, code?: Str, params?: {}): Promise<Transaction>;
|
|
66
68
|
parseTransactionStatus(status: any): string;
|
|
67
69
|
parseTransaction(transaction: any, currency?: Currency): Transaction;
|
|
68
70
|
parseOrderStatus(status: any): string;
|