ccxt 4.2.45 → 4.2.47
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 +5405 -8414
- package/README.md +4 -4
- package/change.sh +5 -3
- package/dist/ccxt.browser.js +824 -64
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/ws/Cache.js +13 -5
- package/dist/cjs/src/base/ws/OrderBook.js +2 -2
- package/dist/cjs/src/binance.js +34 -12
- package/dist/cjs/src/bitfinex2.js +1 -0
- package/dist/cjs/src/bithumb.js +5 -0
- package/dist/cjs/src/btcturk.js +11 -0
- package/dist/cjs/src/bybit.js +185 -2
- package/dist/cjs/src/coinbase.js +9 -5
- package/dist/cjs/src/coincheck.js +11 -0
- package/dist/cjs/src/coinmate.js +114 -1
- package/dist/cjs/src/coinsph.js +32 -1
- package/dist/cjs/src/coinspot.js +7 -0
- package/dist/cjs/src/cryptocom.js +2 -2
- package/dist/cjs/src/currencycom.js +22 -0
- package/dist/cjs/src/deribit.js +34 -1
- package/dist/cjs/src/exmo.js +22 -0
- package/dist/cjs/src/gemini.js +15 -0
- package/dist/cjs/src/hitbtc.js +2 -0
- package/dist/cjs/src/hollaex.js +27 -1
- package/dist/cjs/src/idex.js +60 -1
- package/dist/cjs/src/indodax.js +106 -1
- package/dist/cjs/src/latoken.js +3 -0
- package/dist/cjs/src/mercado.js +3 -0
- package/dist/cjs/src/oceanex.js +3 -0
- package/dist/cjs/src/okx.js +1 -0
- package/dist/cjs/src/pro/bitget.js +12 -8
- package/dist/cjs/src/pro/bitmart.js +11 -11
- package/dist/cjs/src/pro/bitmex.js +4 -4
- package/dist/cjs/src/pro/cex.js +2 -2
- package/dist/cjs/src/pro/gemini.js +4 -3
- package/dist/cjs/src/timex.js +65 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bequant.d.ts +2 -0
- package/js/src/abstract/bitcoincom.d.ts +2 -0
- package/js/src/abstract/bithumb.d.ts +5 -0
- package/js/src/abstract/coinmate.d.ts +12 -0
- package/js/src/abstract/fmfwio.d.ts +2 -0
- package/js/src/abstract/hitbtc.d.ts +2 -0
- package/js/src/abstract/hitbtc3.d.ts +2 -0
- package/js/src/abstract/hollaex.d.ts +3 -0
- package/js/src/abstract/okx.d.ts +1 -0
- package/js/src/base/Exchange.d.ts +9 -7
- package/js/src/base/ws/Cache.d.ts +5 -1
- package/js/src/base/ws/Cache.js +13 -5
- package/js/src/base/ws/OrderBook.d.ts +5 -1
- package/js/src/base/ws/OrderBook.js +3 -3
- package/js/src/binance.d.ts +1 -1
- package/js/src/binance.js +34 -12
- package/js/src/bitfinex2.js +1 -0
- package/js/src/bithumb.js +5 -0
- package/js/src/btcturk.js +11 -0
- package/js/src/bybit.d.ts +2 -0
- package/js/src/bybit.js +185 -2
- package/js/src/coinbase.js +9 -5
- package/js/src/coincheck.js +11 -0
- package/js/src/coinmate.d.ts +3 -1
- package/js/src/coinmate.js +114 -1
- package/js/src/coinsph.js +32 -1
- package/js/src/coinspot.js +7 -0
- package/js/src/cryptocom.js +2 -2
- package/js/src/currencycom.js +22 -0
- package/js/src/deribit.js +34 -1
- package/js/src/exmo.js +22 -0
- package/js/src/gemini.js +15 -0
- package/js/src/hitbtc.js +2 -0
- package/js/src/hollaex.js +27 -1
- package/js/src/idex.d.ts +14 -0
- package/js/src/idex.js +60 -1
- package/js/src/indodax.d.ts +3 -0
- package/js/src/indodax.js +106 -1
- package/js/src/latoken.js +3 -0
- package/js/src/mercado.js +3 -0
- package/js/src/oceanex.js +3 -0
- package/js/src/okx.js +1 -0
- package/js/src/pro/bitget.js +12 -8
- package/js/src/pro/bitmart.js +11 -11
- package/js/src/pro/bitmex.js +4 -4
- package/js/src/pro/cex.js +2 -2
- package/js/src/pro/gemini.js +4 -3
- package/js/src/timex.d.ts +14 -0
- package/js/src/timex.js +65 -0
- package/package.json +1 -1
- package/skip-tests.json +4 -0
package/dist/cjs/ccxt.js
CHANGED
|
@@ -177,7 +177,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
177
177
|
|
|
178
178
|
//-----------------------------------------------------------------------------
|
|
179
179
|
// this is updated by vss.js when building
|
|
180
|
-
const version = '4.2.
|
|
180
|
+
const version = '4.2.47';
|
|
181
181
|
Exchange["default"].ccxtVersion = version;
|
|
182
182
|
const exchanges = {
|
|
183
183
|
'ace': ace,
|
|
@@ -20,6 +20,7 @@ class BaseCache extends Array {
|
|
|
20
20
|
class ArrayCache extends BaseCache {
|
|
21
21
|
constructor(maxSize = undefined) {
|
|
22
22
|
super(maxSize);
|
|
23
|
+
this.hashmap = {};
|
|
23
24
|
Object.defineProperty(this, 'nestedNewUpdatesBySymbol', {
|
|
24
25
|
__proto__: null,
|
|
25
26
|
value: false,
|
|
@@ -45,6 +46,12 @@ class ArrayCache extends BaseCache {
|
|
|
45
46
|
value: false,
|
|
46
47
|
writable: true,
|
|
47
48
|
});
|
|
49
|
+
Object.defineProperty(this, 'hashmap', {
|
|
50
|
+
__proto__: null,
|
|
51
|
+
value: {},
|
|
52
|
+
writable: true,
|
|
53
|
+
enumerable: false,
|
|
54
|
+
});
|
|
48
55
|
}
|
|
49
56
|
getLimit(symbol, limit) {
|
|
50
57
|
let newUpdatesValue = undefined;
|
|
@@ -124,6 +131,7 @@ class ArrayCacheByTimestamp extends BaseCache {
|
|
|
124
131
|
if (item[0] in this.hashmap) {
|
|
125
132
|
const reference = this.hashmap[item[0]];
|
|
126
133
|
if (reference !== item) {
|
|
134
|
+
// eslint-disable-next-line
|
|
127
135
|
for (const prop in item) {
|
|
128
136
|
reference[prop] = item[prop];
|
|
129
137
|
}
|
|
@@ -149,11 +157,11 @@ class ArrayCacheBySymbolById extends ArrayCache {
|
|
|
149
157
|
constructor(maxSize = undefined) {
|
|
150
158
|
super(maxSize);
|
|
151
159
|
this.nestedNewUpdatesBySymbol = true;
|
|
152
|
-
Object.defineProperty(this, 'hashmap', {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
})
|
|
160
|
+
// Object.defineProperty (this, 'hashmap', {
|
|
161
|
+
// __proto__: null, // make it invisible
|
|
162
|
+
// value: {},
|
|
163
|
+
// writable: true,
|
|
164
|
+
// })
|
|
157
165
|
}
|
|
158
166
|
append(item) {
|
|
159
167
|
const byId = this.hashmap[item.symbol] = this.hashmap[item.symbol] || {};
|
|
@@ -7,14 +7,14 @@ var generic = require('../functions/generic.js');
|
|
|
7
7
|
var OrderBookSide = require('./OrderBookSide.js');
|
|
8
8
|
|
|
9
9
|
/* eslint-disable max-classes-per-file */
|
|
10
|
-
// ----------------------------------------------------------------------------
|
|
11
|
-
// overwrites absolute volumes at price levels
|
|
12
10
|
class OrderBook {
|
|
13
11
|
constructor(snapshot = {}, depth = undefined) {
|
|
12
|
+
this.cache = []; // make prop visible so we use typed OrderBooks
|
|
14
13
|
Object.defineProperty(this, 'cache', {
|
|
15
14
|
__proto__: null,
|
|
16
15
|
value: [],
|
|
17
16
|
writable: true,
|
|
17
|
+
enumerable: false,
|
|
18
18
|
});
|
|
19
19
|
depth = depth || Number.MAX_SAFE_INTEGER;
|
|
20
20
|
const defaults = {
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -3158,25 +3158,38 @@ class binance extends binance$1 {
|
|
|
3158
3158
|
account['debt'] = Precise["default"].stringAdd(debt, interest);
|
|
3159
3159
|
return account;
|
|
3160
3160
|
}
|
|
3161
|
-
parseBalanceCustom(response, type = undefined, marginMode = undefined) {
|
|
3161
|
+
parseBalanceCustom(response, type = undefined, marginMode = undefined, isPortfolioMargin = false) {
|
|
3162
3162
|
const result = {
|
|
3163
3163
|
'info': response,
|
|
3164
3164
|
};
|
|
3165
3165
|
let timestamp = undefined;
|
|
3166
3166
|
const isolated = marginMode === 'isolated';
|
|
3167
3167
|
const cross = (type === 'margin') || (marginMode === 'cross');
|
|
3168
|
-
if (
|
|
3168
|
+
if (isPortfolioMargin) {
|
|
3169
3169
|
for (let i = 0; i < response.length; i++) {
|
|
3170
3170
|
const entry = response[i];
|
|
3171
3171
|
const account = this.account();
|
|
3172
3172
|
const currencyId = this.safeString(entry, 'asset');
|
|
3173
3173
|
const code = this.safeCurrencyCode(currencyId);
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3174
|
+
if (type === 'linear') {
|
|
3175
|
+
account['free'] = this.safeString(entry, 'umWalletBalance');
|
|
3176
|
+
account['used'] = this.safeString(entry, 'umUnrealizedPNL');
|
|
3177
|
+
}
|
|
3178
|
+
else if (type === 'inverse') {
|
|
3179
|
+
account['free'] = this.safeString(entry, 'cmWalletBalance');
|
|
3180
|
+
account['used'] = this.safeString(entry, 'cmUnrealizedPNL');
|
|
3181
|
+
}
|
|
3182
|
+
else if (cross) {
|
|
3183
|
+
const borrowed = this.safeString(entry, 'crossMarginBorrowed');
|
|
3184
|
+
const interest = this.safeString(entry, 'crossMarginInterest');
|
|
3185
|
+
account['debt'] = Precise["default"].stringAdd(borrowed, interest);
|
|
3186
|
+
account['free'] = this.safeString(entry, 'crossMarginFree');
|
|
3187
|
+
account['used'] = this.safeString(entry, 'crossMarginLocked');
|
|
3188
|
+
account['total'] = this.safeString(entry, 'crossMarginAsset');
|
|
3189
|
+
}
|
|
3190
|
+
else {
|
|
3191
|
+
account['total'] = this.safeString(entry, 'totalWalletBalance');
|
|
3192
|
+
}
|
|
3180
3193
|
result[code] = account;
|
|
3181
3194
|
}
|
|
3182
3195
|
}
|
|
@@ -3296,7 +3309,13 @@ class binance extends binance$1 {
|
|
|
3296
3309
|
let response = undefined;
|
|
3297
3310
|
const request = {};
|
|
3298
3311
|
if (isPortfolioMargin || (type === 'papi')) {
|
|
3299
|
-
type
|
|
3312
|
+
if (this.isLinear(type, subType)) {
|
|
3313
|
+
type = 'linear';
|
|
3314
|
+
}
|
|
3315
|
+
else if (this.isInverse(type, subType)) {
|
|
3316
|
+
type = 'inverse';
|
|
3317
|
+
}
|
|
3318
|
+
isPortfolioMargin = true;
|
|
3300
3319
|
response = await this.papiGetBalance(this.extend(request, query));
|
|
3301
3320
|
}
|
|
3302
3321
|
else if (this.isLinear(type, subType)) {
|
|
@@ -3544,7 +3563,7 @@ class binance extends binance$1 {
|
|
|
3544
3563
|
// },
|
|
3545
3564
|
// ]
|
|
3546
3565
|
//
|
|
3547
|
-
return this.parseBalanceCustom(response, type, marginMode);
|
|
3566
|
+
return this.parseBalanceCustom(response, type, marginMode, isPortfolioMargin);
|
|
3548
3567
|
}
|
|
3549
3568
|
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
3550
3569
|
/**
|
|
@@ -9827,12 +9846,12 @@ class binance extends binance$1 {
|
|
|
9827
9846
|
/**
|
|
9828
9847
|
* @method
|
|
9829
9848
|
* @name binance#fetchPositions
|
|
9849
|
+
* @description fetch all open positions
|
|
9830
9850
|
* @see https://binance-docs.github.io/apidocs/futures/en/#position-information-v2-user_data
|
|
9831
9851
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#position-information-user_data
|
|
9832
9852
|
* @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
|
|
9833
9853
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
|
|
9834
9854
|
* @see https://binance-docs.github.io/apidocs/voptions/en/#option-position-information-user_data
|
|
9835
|
-
* @description fetch all open positions
|
|
9836
9855
|
* @param {string[]} [symbols] list of unified market symbols
|
|
9837
9856
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
9838
9857
|
* @param {string} [method] method name to call, "positionRisk", "account" or "option", default is "positionRisk"
|
|
@@ -10056,7 +10075,10 @@ class binance extends binance$1 {
|
|
|
10056
10075
|
const result = [];
|
|
10057
10076
|
for (let i = 0; i < response.length; i++) {
|
|
10058
10077
|
const parsed = this.parsePositionRisk(response[i]);
|
|
10059
|
-
|
|
10078
|
+
const entryPrice = this.safeString(parsed, 'entryPrice');
|
|
10079
|
+
if ((entryPrice !== '0') && (entryPrice !== '0.0') && (entryPrice !== '0.00000000')) {
|
|
10080
|
+
result.push(parsed);
|
|
10081
|
+
}
|
|
10060
10082
|
}
|
|
10061
10083
|
symbols = this.marketSymbols(symbols);
|
|
10062
10084
|
return this.filterByArrayPositions(result, 'symbol', symbols, false);
|
package/dist/cjs/src/bithumb.js
CHANGED
|
@@ -88,6 +88,11 @@ class bithumb extends bithumb$1 {
|
|
|
88
88
|
'orderbook/ALL_{quoteId}',
|
|
89
89
|
'orderbook/{baseId}_{quoteId}',
|
|
90
90
|
'transaction_history/{baseId}_{quoteId}',
|
|
91
|
+
'network-info',
|
|
92
|
+
'assetsstatus/multichain/ALL',
|
|
93
|
+
'assetsstatus/multichain/{currency}',
|
|
94
|
+
'withdraw/minimum/ALL',
|
|
95
|
+
'withdraw/minimum/{currency}',
|
|
91
96
|
'assetsstatus/ALL',
|
|
92
97
|
'assetsstatus/{baseId}',
|
|
93
98
|
'candlestick/{baseId}_{quoteId}/{interval}',
|
package/dist/cjs/src/btcturk.js
CHANGED
|
@@ -144,6 +144,7 @@ class btcturk extends btcturk$1 {
|
|
|
144
144
|
* @method
|
|
145
145
|
* @name btcturk#fetchMarkets
|
|
146
146
|
* @description retrieves data on all markets for btcturk
|
|
147
|
+
* @see https://docs.btcturk.com/public-endpoints/exchange-info
|
|
147
148
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
148
149
|
* @returns {object[]} an array of objects representing market data
|
|
149
150
|
*/
|
|
@@ -293,6 +294,7 @@ class btcturk extends btcturk$1 {
|
|
|
293
294
|
* @method
|
|
294
295
|
* @name btcturk#fetchBalance
|
|
295
296
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
297
|
+
* @see https://docs.btcturk.com/private-endpoints/account-balance
|
|
296
298
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
297
299
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
298
300
|
*/
|
|
@@ -321,6 +323,7 @@ class btcturk extends btcturk$1 {
|
|
|
321
323
|
* @method
|
|
322
324
|
* @name btcturk#fetchOrderBook
|
|
323
325
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
326
|
+
* @see https://docs.btcturk.com/public-endpoints/orderbook
|
|
324
327
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
325
328
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
326
329
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -401,6 +404,7 @@ class btcturk extends btcturk$1 {
|
|
|
401
404
|
* @method
|
|
402
405
|
* @name btcturk#fetchTickers
|
|
403
406
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
407
|
+
* @see https://docs.btcturk.com/public-endpoints/ticker
|
|
404
408
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
405
409
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
406
410
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -415,6 +419,7 @@ class btcturk extends btcturk$1 {
|
|
|
415
419
|
* @method
|
|
416
420
|
* @name btcturk#fetchTicker
|
|
417
421
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
422
|
+
* @see https://docs.btcturk.com/public-endpoints/ticker
|
|
418
423
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
419
424
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
420
425
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -490,6 +495,7 @@ class btcturk extends btcturk$1 {
|
|
|
490
495
|
* @method
|
|
491
496
|
* @name btcturk#fetchTrades
|
|
492
497
|
* @description get the list of most recent trades for a particular symbol
|
|
498
|
+
* @see https://docs.btcturk.com/public-endpoints/trades
|
|
493
499
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
494
500
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
495
501
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
@@ -653,6 +659,7 @@ class btcturk extends btcturk$1 {
|
|
|
653
659
|
* @method
|
|
654
660
|
* @name btcturk#createOrder
|
|
655
661
|
* @description create a trade order
|
|
662
|
+
* @see https://docs.btcturk.com/private-endpoints/submit-order
|
|
656
663
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
657
664
|
* @param {string} type 'market' or 'limit'
|
|
658
665
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -687,6 +694,7 @@ class btcturk extends btcturk$1 {
|
|
|
687
694
|
* @method
|
|
688
695
|
* @name btcturk#cancelOrder
|
|
689
696
|
* @description cancels an open order
|
|
697
|
+
* @see https://docs.btcturk.com/private-endpoints/cancel-order
|
|
690
698
|
* @param {string} id order id
|
|
691
699
|
* @param {string} symbol not used by btcturk cancelOrder ()
|
|
692
700
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -702,6 +710,7 @@ class btcturk extends btcturk$1 {
|
|
|
702
710
|
* @method
|
|
703
711
|
* @name btcturk#fetchOpenOrders
|
|
704
712
|
* @description fetch all unfilled currently open orders
|
|
713
|
+
* @see https://docs.btcturk.com/private-endpoints/open-orders
|
|
705
714
|
* @param {string} symbol unified market symbol
|
|
706
715
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
707
716
|
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
@@ -726,6 +735,7 @@ class btcturk extends btcturk$1 {
|
|
|
726
735
|
* @method
|
|
727
736
|
* @name btcturk#fetchOrders
|
|
728
737
|
* @description fetches information on multiple orders made by the user
|
|
738
|
+
* @see https://docs.btcturk.com/private-endpoints/all-orders
|
|
729
739
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
730
740
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
731
741
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
@@ -848,6 +858,7 @@ class btcturk extends btcturk$1 {
|
|
|
848
858
|
* @method
|
|
849
859
|
* @name btcturk#fetchMyTrades
|
|
850
860
|
* @description fetch all trades made by the user
|
|
861
|
+
* @see https://docs.btcturk.com/private-endpoints/user-transactions
|
|
851
862
|
* @param {string} symbol unified market symbol
|
|
852
863
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
853
864
|
* @param {int} [limit] the maximum number of trades structures to retrieve
|
package/dist/cjs/src/bybit.js
CHANGED
|
@@ -4479,11 +4479,194 @@ class bybit extends bybit$1 {
|
|
|
4479
4479
|
const data = this.safeValue(result, 'dataList', []);
|
|
4480
4480
|
return this.parseOrders(data, market, since, limit);
|
|
4481
4481
|
}
|
|
4482
|
+
async fetchOrderClassic(id, symbol = undefined, params = {}) {
|
|
4483
|
+
/**
|
|
4484
|
+
* @method
|
|
4485
|
+
* @name bybit#fetchOrderClassic
|
|
4486
|
+
* @description fetches information on an order made by the user *classic accounts only*
|
|
4487
|
+
* @see https://bybit-exchange.github.io/docs/v5/order/order-list
|
|
4488
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
4489
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4490
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4491
|
+
*/
|
|
4492
|
+
if (symbol === undefined) {
|
|
4493
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
|
|
4494
|
+
}
|
|
4495
|
+
await this.loadMarkets();
|
|
4496
|
+
const market = this.market(symbol);
|
|
4497
|
+
if (market['spot']) {
|
|
4498
|
+
throw new errors.NotSupported(this.id + ' fetchOrder() is not supported for spot markets');
|
|
4499
|
+
}
|
|
4500
|
+
const request = {
|
|
4501
|
+
'orderId': id,
|
|
4502
|
+
};
|
|
4503
|
+
const result = await this.fetchOrders(symbol, undefined, undefined, this.extend(request, params));
|
|
4504
|
+
const length = result.length;
|
|
4505
|
+
if (length === 0) {
|
|
4506
|
+
const isTrigger = this.safeBoolN(params, ['trigger', 'stop'], false);
|
|
4507
|
+
const extra = isTrigger ? '' : 'If you are trying to fetch SL/TP conditional order, you might try setting params["trigger"] = true';
|
|
4508
|
+
throw new errors.OrderNotFound('Order ' + id.toString() + ' was not found.' + extra);
|
|
4509
|
+
}
|
|
4510
|
+
if (length > 1) {
|
|
4511
|
+
throw new errors.InvalidOrder(this.id + ' returned more than one order');
|
|
4512
|
+
}
|
|
4513
|
+
return this.safeValue(result, 0);
|
|
4514
|
+
}
|
|
4482
4515
|
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
4483
|
-
|
|
4516
|
+
/**
|
|
4517
|
+
* @method
|
|
4518
|
+
* @name bybit#fetchOrderClassic
|
|
4519
|
+
* @description *classic accounts only/ spot not supported* fetches information on an order made by the user *classic accounts only*
|
|
4520
|
+
* @see https://bybit-exchange.github.io/docs/v5/order/order-list
|
|
4521
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
4522
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4523
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4524
|
+
*/
|
|
4525
|
+
const res = await this.isUnifiedEnabled();
|
|
4526
|
+
const enableUnifiedAccount = this.safeBool(res, 1);
|
|
4527
|
+
if (enableUnifiedAccount) {
|
|
4528
|
+
throw new errors.NotSupported(this.id + ' fetchOrder() is not supported after the 5/02 update for UTA accounts, please use fetchOpenOrder or fetchClosedOrder');
|
|
4529
|
+
}
|
|
4530
|
+
return await this.fetchOrderClassic(id, symbol, params);
|
|
4484
4531
|
}
|
|
4485
4532
|
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
4486
|
-
|
|
4533
|
+
const res = await this.isUnifiedEnabled();
|
|
4534
|
+
/**
|
|
4535
|
+
* @method
|
|
4536
|
+
* @name bybit#fetchOrders
|
|
4537
|
+
* @description *classic accounts only/ spot not supported* fetches information on multiple orders made by the user *classic accounts only/ spot not supported*
|
|
4538
|
+
* @see https://bybit-exchange.github.io/docs/v5/order/order-list
|
|
4539
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
4540
|
+
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
4541
|
+
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
4542
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4543
|
+
* @param {boolean} [params.stop] true if stop order
|
|
4544
|
+
* @param {string} [params.type] market type, ['swap', 'option']
|
|
4545
|
+
* @param {string} [params.subType] market subType, ['linear', 'inverse']
|
|
4546
|
+
* @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
|
|
4547
|
+
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
4548
|
+
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
4549
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4550
|
+
*/
|
|
4551
|
+
const enableUnifiedAccount = this.safeBool(res, 1);
|
|
4552
|
+
if (enableUnifiedAccount) {
|
|
4553
|
+
throw new errors.NotSupported(this.id + ' fetchOrders() is not supported after the 5/02 update for UTA accounts, please use fetchOpenOrders, fetchClosedOrders or fetchCanceledOrders');
|
|
4554
|
+
}
|
|
4555
|
+
return await this.fetchOrdersClassic(symbol, since, limit, params);
|
|
4556
|
+
}
|
|
4557
|
+
async fetchOrdersClassic(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
4558
|
+
/**
|
|
4559
|
+
* @method
|
|
4560
|
+
* @name bybit#fetchOrders
|
|
4561
|
+
* @description fetches information on multiple orders made by the user *classic accounts only*
|
|
4562
|
+
* @see https://bybit-exchange.github.io/docs/v5/order/order-list
|
|
4563
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
4564
|
+
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
4565
|
+
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
4566
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4567
|
+
* @param {boolean} [params.stop] true if stop order
|
|
4568
|
+
* @param {string} [params.type] market type, ['swap', 'option', 'spot']
|
|
4569
|
+
* @param {string} [params.subType] market subType, ['linear', 'inverse']
|
|
4570
|
+
* @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
|
|
4571
|
+
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
4572
|
+
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
4573
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4574
|
+
*/
|
|
4575
|
+
await this.loadMarkets();
|
|
4576
|
+
let paginate = false;
|
|
4577
|
+
[paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate');
|
|
4578
|
+
if (paginate) {
|
|
4579
|
+
return await this.fetchPaginatedCallCursor('fetchOrders', symbol, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 50);
|
|
4580
|
+
}
|
|
4581
|
+
const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
|
|
4582
|
+
const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
|
|
4583
|
+
const request = {};
|
|
4584
|
+
let market = undefined;
|
|
4585
|
+
let isUsdcSettled = false;
|
|
4586
|
+
if (symbol !== undefined) {
|
|
4587
|
+
market = this.market(symbol);
|
|
4588
|
+
isUsdcSettled = market['settle'] === 'USDC';
|
|
4589
|
+
request['symbol'] = market['id'];
|
|
4590
|
+
}
|
|
4591
|
+
let type = undefined;
|
|
4592
|
+
[type, params] = this.getBybitType('fetchOrders', market, params);
|
|
4593
|
+
if (((type === 'option') || isUsdcSettled) && !isUnifiedAccount) {
|
|
4594
|
+
return await this.fetchUsdcOrders(symbol, since, limit, params);
|
|
4595
|
+
}
|
|
4596
|
+
if (type === 'spot') {
|
|
4597
|
+
throw new errors.NotSupported(this.id + ' fetchOrders() is not supported for spot markets');
|
|
4598
|
+
}
|
|
4599
|
+
request['category'] = type;
|
|
4600
|
+
const isStop = this.safeBoolN(params, ['trigger', 'stop'], false);
|
|
4601
|
+
params = this.omit(params, ['trigger', 'stop']);
|
|
4602
|
+
if (isStop) {
|
|
4603
|
+
request['orderFilter'] = 'StopOrder';
|
|
4604
|
+
}
|
|
4605
|
+
if (limit !== undefined) {
|
|
4606
|
+
request['limit'] = limit;
|
|
4607
|
+
}
|
|
4608
|
+
if (since !== undefined) {
|
|
4609
|
+
request['startTime'] = since;
|
|
4610
|
+
}
|
|
4611
|
+
const until = this.safeInteger2(params, 'until', 'till'); // unified in milliseconds
|
|
4612
|
+
const endTime = this.safeInteger(params, 'endTime', until); // exchange-specific in milliseconds
|
|
4613
|
+
params = this.omit(params, ['endTime', 'till', 'until']);
|
|
4614
|
+
if (endTime !== undefined) {
|
|
4615
|
+
request['endTime'] = endTime;
|
|
4616
|
+
}
|
|
4617
|
+
const response = await this.privateGetV5OrderHistory(this.extend(request, params));
|
|
4618
|
+
//
|
|
4619
|
+
// {
|
|
4620
|
+
// "retCode": 0,
|
|
4621
|
+
// "retMsg": "OK",
|
|
4622
|
+
// "result": {
|
|
4623
|
+
// "nextPageCursor": "03234de9-1332-41eb-b805-4a9f42c136a3%3A1672220109387%2C03234de9-1332-41eb-b805-4a9f42c136a3%3A1672220109387",
|
|
4624
|
+
// "category": "linear",
|
|
4625
|
+
// "list": [
|
|
4626
|
+
// {
|
|
4627
|
+
// "symbol": "BTCUSDT",
|
|
4628
|
+
// "orderType": "Limit",
|
|
4629
|
+
// "orderLinkId": "test-001",
|
|
4630
|
+
// "orderId": "03234de9-1332-41eb-b805-4a9f42c136a3",
|
|
4631
|
+
// "cancelType": "CancelByUser",
|
|
4632
|
+
// "avgPrice": "0",
|
|
4633
|
+
// "stopOrderType": "UNKNOWN",
|
|
4634
|
+
// "lastPriceOnCreated": "16656.5",
|
|
4635
|
+
// "orderStatus": "Cancelled",
|
|
4636
|
+
// "takeProfit": "",
|
|
4637
|
+
// "cumExecValue": "0",
|
|
4638
|
+
// "triggerDirection": 0,
|
|
4639
|
+
// "blockTradeId": "",
|
|
4640
|
+
// "rejectReason": "EC_PerCancelRequest",
|
|
4641
|
+
// "isLeverage": "",
|
|
4642
|
+
// "price": "18000",
|
|
4643
|
+
// "orderIv": "",
|
|
4644
|
+
// "createdTime": "1672220109387",
|
|
4645
|
+
// "tpTriggerBy": "UNKNOWN",
|
|
4646
|
+
// "positionIdx": 0,
|
|
4647
|
+
// "timeInForce": "GoodTillCancel",
|
|
4648
|
+
// "leavesValue": "0",
|
|
4649
|
+
// "updatedTime": "1672220114123",
|
|
4650
|
+
// "side": "Sell",
|
|
4651
|
+
// "triggerPrice": "",
|
|
4652
|
+
// "cumExecFee": "0",
|
|
4653
|
+
// "slTriggerBy": "UNKNOWN",
|
|
4654
|
+
// "leavesQty": "0",
|
|
4655
|
+
// "closeOnTrigger": false,
|
|
4656
|
+
// "cumExecQty": "0",
|
|
4657
|
+
// "reduceOnly": false,
|
|
4658
|
+
// "qty": "0.1",
|
|
4659
|
+
// "stopLoss": "",
|
|
4660
|
+
// "triggerBy": "UNKNOWN"
|
|
4661
|
+
// }
|
|
4662
|
+
// ]
|
|
4663
|
+
// },
|
|
4664
|
+
// "retExtInfo": {},
|
|
4665
|
+
// "time": 1672221263862
|
|
4666
|
+
// }
|
|
4667
|
+
//
|
|
4668
|
+
const data = this.addPaginationCursorToResult(response);
|
|
4669
|
+
return this.parseOrders(data, market, since, limit);
|
|
4487
4670
|
}
|
|
4488
4671
|
async fetchClosedOrder(id, symbol = undefined, params = {}) {
|
|
4489
4672
|
/**
|
package/dist/cjs/src/coinbase.js
CHANGED
|
@@ -62,6 +62,8 @@ class coinbase extends coinbase$1 {
|
|
|
62
62
|
'fetchCrossBorrowRate': false,
|
|
63
63
|
'fetchCrossBorrowRates': false,
|
|
64
64
|
'fetchCurrencies': true,
|
|
65
|
+
'fetchDepositAddress': 'emulated',
|
|
66
|
+
'fetchDepositAddresses': false,
|
|
65
67
|
'fetchDepositAddressesByNetwork': true,
|
|
66
68
|
'fetchDeposits': true,
|
|
67
69
|
'fetchFundingHistory': false,
|
|
@@ -1740,17 +1742,18 @@ class coinbase extends coinbase$1 {
|
|
|
1740
1742
|
* @see https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-accounts#list-accounts
|
|
1741
1743
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1742
1744
|
* @param {boolean} [params.v3] default false, set true to use v3 api endpoint
|
|
1745
|
+
* @param {object} [params.type] "spot" (default) or "swap"
|
|
1743
1746
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
1744
1747
|
*/
|
|
1745
1748
|
await this.loadMarkets();
|
|
1746
|
-
const request = {
|
|
1747
|
-
'limit': 250,
|
|
1748
|
-
};
|
|
1749
|
+
const request = {};
|
|
1749
1750
|
let response = undefined;
|
|
1750
1751
|
const isV3 = this.safeBool(params, 'v3', false);
|
|
1751
|
-
|
|
1752
|
+
const type = this.safeString(params, 'type');
|
|
1753
|
+
params = this.omit(params, ['v3', 'type']);
|
|
1752
1754
|
const method = this.safeString(this.options, 'fetchBalance', 'v3PrivateGetBrokerageAccounts');
|
|
1753
1755
|
if ((isV3) || (method === 'v3PrivateGetBrokerageAccounts')) {
|
|
1756
|
+
request['limit'] = 250;
|
|
1754
1757
|
response = await this.v3PrivateGetBrokerageAccounts(this.extend(request, params));
|
|
1755
1758
|
}
|
|
1756
1759
|
else {
|
|
@@ -1827,6 +1830,7 @@ class coinbase extends coinbase$1 {
|
|
|
1827
1830
|
// "size": 9
|
|
1828
1831
|
// }
|
|
1829
1832
|
//
|
|
1833
|
+
params['type'] = type;
|
|
1830
1834
|
return this.parseCustomBalance(response, params);
|
|
1831
1835
|
}
|
|
1832
1836
|
async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -3401,7 +3405,7 @@ class coinbase extends coinbase$1 {
|
|
|
3401
3405
|
async fetchDepositAddressesByNetwork(code, params = {}) {
|
|
3402
3406
|
/**
|
|
3403
3407
|
* @method
|
|
3404
|
-
* @name
|
|
3408
|
+
* @name coinbase#fetchDepositAddress
|
|
3405
3409
|
* @description fetch the deposit address for a currency associated with this account
|
|
3406
3410
|
* @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postcoinbaseaccountaddresses
|
|
3407
3411
|
* @param {string} code unified currency code
|
|
@@ -189,6 +189,7 @@ class coincheck extends coincheck$1 {
|
|
|
189
189
|
* @method
|
|
190
190
|
* @name coincheck#fetchBalance
|
|
191
191
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
192
|
+
* @see https://coincheck.com/documents/exchange/api#order-transactions-pagination
|
|
192
193
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
193
194
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
194
195
|
*/
|
|
@@ -201,6 +202,7 @@ class coincheck extends coincheck$1 {
|
|
|
201
202
|
* @method
|
|
202
203
|
* @name coincheck#fetchOpenOrders
|
|
203
204
|
* @description fetch all unfilled currently open orders
|
|
205
|
+
* @see https://coincheck.com/documents/exchange/api#order-opens
|
|
204
206
|
* @param {string} symbol unified market symbol
|
|
205
207
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
206
208
|
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
@@ -276,6 +278,7 @@ class coincheck extends coincheck$1 {
|
|
|
276
278
|
* @method
|
|
277
279
|
* @name coincheck#fetchOrderBook
|
|
278
280
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
281
|
+
* @see https://coincheck.com/documents/exchange/api#order-book
|
|
279
282
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
280
283
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
281
284
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -332,6 +335,7 @@ class coincheck extends coincheck$1 {
|
|
|
332
335
|
* @method
|
|
333
336
|
* @name coincheck#fetchTicker
|
|
334
337
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
338
|
+
* @see https://coincheck.com/documents/exchange/api#ticker
|
|
335
339
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
336
340
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
337
341
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -445,6 +449,7 @@ class coincheck extends coincheck$1 {
|
|
|
445
449
|
* @method
|
|
446
450
|
* @name coincheck#fetchMyTrades
|
|
447
451
|
* @description fetch all trades made by the user
|
|
452
|
+
* @see https://coincheck.com/documents/exchange/api#order-transactions-pagination
|
|
448
453
|
* @param {string} symbol unified market symbol
|
|
449
454
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
450
455
|
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
@@ -488,6 +493,7 @@ class coincheck extends coincheck$1 {
|
|
|
488
493
|
* @method
|
|
489
494
|
* @name coincheck#fetchTrades
|
|
490
495
|
* @description get the list of most recent trades for a particular symbol
|
|
496
|
+
* @see https://coincheck.com/documents/exchange/api#public-trades
|
|
491
497
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
492
498
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
493
499
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
@@ -521,6 +527,7 @@ class coincheck extends coincheck$1 {
|
|
|
521
527
|
* @method
|
|
522
528
|
* @name coincheck#fetchTradingFees
|
|
523
529
|
* @description fetch the trading fees for multiple markets
|
|
530
|
+
* @see https://coincheck.com/documents/exchange/api#account-info
|
|
524
531
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
525
532
|
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
|
|
526
533
|
*/
|
|
@@ -567,6 +574,7 @@ class coincheck extends coincheck$1 {
|
|
|
567
574
|
* @method
|
|
568
575
|
* @name coincheck#createOrder
|
|
569
576
|
* @description create a trade order
|
|
577
|
+
* @see https://coincheck.com/documents/exchange/api#order-new
|
|
570
578
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
571
579
|
* @param {string} type 'market' or 'limit'
|
|
572
580
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -603,6 +611,7 @@ class coincheck extends coincheck$1 {
|
|
|
603
611
|
* @method
|
|
604
612
|
* @name coincheck#cancelOrder
|
|
605
613
|
* @description cancels an open order
|
|
614
|
+
* @see https://coincheck.com/documents/exchange/api#order-cancel
|
|
606
615
|
* @param {string} id order id
|
|
607
616
|
* @param {string} symbol not used by coincheck cancelOrder ()
|
|
608
617
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -618,6 +627,7 @@ class coincheck extends coincheck$1 {
|
|
|
618
627
|
* @method
|
|
619
628
|
* @name coincheck#fetchDeposits
|
|
620
629
|
* @description fetch all deposits made to an account
|
|
630
|
+
* @see https://coincheck.com/documents/exchange/api#account-deposits
|
|
621
631
|
* @param {string} code unified currency code
|
|
622
632
|
* @param {int} [since] the earliest time in ms to fetch deposits for
|
|
623
633
|
* @param {int} [limit] the maximum number of deposits structures to retrieve
|
|
@@ -666,6 +676,7 @@ class coincheck extends coincheck$1 {
|
|
|
666
676
|
* @method
|
|
667
677
|
* @name coincheck#fetchWithdrawals
|
|
668
678
|
* @description fetch all withdrawals made from an account
|
|
679
|
+
* @see https://coincheck.com/documents/exchange/api#withdraws
|
|
669
680
|
* @param {string} code unified currency code
|
|
670
681
|
* @param {int} [since] the earliest time in ms to fetch withdrawals for
|
|
671
682
|
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
|