ccxt 4.0.112 → 4.1.2

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/js/src/bybit.js CHANGED
@@ -4011,6 +4011,16 @@ export default class bybit extends Exchange {
4011
4011
  * @param {float} amount how much of currency you want to trade in units of base currency
4012
4012
  * @param {float} price the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
4013
4013
  * @param {object} [params] extra parameters specific to the bybit api endpoint
4014
+ * @param {float} [params.triggerPrice] The price that a trigger order is triggered at
4015
+ * @param {float} [params.stopLossPrice] The price that a stop loss order is triggered at
4016
+ * @param {float} [params.takeProfitPrice] The price that a take profit order is triggered at
4017
+ * @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice that the attached take profit order will be triggered
4018
+ * @param {float} [params.takeProfit.triggerPrice] take profit trigger price
4019
+ * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice that the attached stop loss order will be triggered
4020
+ * @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
4021
+ * @param {string} [params.triggerBy] 'IndexPrice', 'MarkPrice' or 'LastPrice', default is 'LastPrice', required if no initial value for triggerPrice
4022
+ * @param {string} [params.slTriggerBy] 'IndexPrice', 'MarkPrice' or 'LastPrice', default is 'LastPrice', required if no initial value for stopLoss
4023
+ * @param {string} [params.tpTriggerby] 'IndexPrice', 'MarkPrice' or 'LastPrice', default is 'LastPrice', required if no initial value for takeProfit
4014
4024
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4015
4025
  */
4016
4026
  this.checkRequiredSymbol('editOrder', symbol);
@@ -4053,9 +4063,9 @@ export default class bybit extends Exchange {
4053
4063
  if (amount !== undefined) {
4054
4064
  request['qty'] = this.amountToPrecision(symbol, amount);
4055
4065
  }
4056
- let triggerPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
4057
- const stopLossTriggerPrice = this.safeValue(params, 'stopLossPrice');
4058
- const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
4066
+ let triggerPrice = this.safeString2(params, 'triggerPrice', 'stopPrice');
4067
+ const stopLossTriggerPrice = this.safeString(params, 'stopLossPrice');
4068
+ const takeProfitTriggerPrice = this.safeString(params, 'takeProfitPrice');
4059
4069
  const stopLoss = this.safeValue(params, 'stopLoss');
4060
4070
  const takeProfit = this.safeValue(params, 'takeProfit');
4061
4071
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
@@ -4066,16 +4076,25 @@ export default class bybit extends Exchange {
4066
4076
  triggerPrice = isStopLossTriggerOrder ? stopLossTriggerPrice : takeProfitTriggerPrice;
4067
4077
  }
4068
4078
  if (triggerPrice !== undefined) {
4069
- request['triggerPrice'] = triggerPrice;
4079
+ const triggerPriceRequest = (triggerPrice === '0') ? triggerPrice : this.priceToPrecision(symbol, triggerPrice);
4080
+ request['triggerPrice'] = triggerPriceRequest;
4081
+ const triggerBy = this.safeString(params, 'triggerBy', 'LastPrice');
4082
+ request['triggerBy'] = triggerBy;
4070
4083
  }
4071
4084
  if (isStopLoss || isTakeProfit) {
4072
4085
  if (isStopLoss) {
4073
- const slTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
4074
- request['stopLoss'] = slTriggerPrice;
4086
+ const slTriggerPrice = this.safeString2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
4087
+ const stopLossRequest = (slTriggerPrice === '0') ? slTriggerPrice : this.priceToPrecision(symbol, slTriggerPrice);
4088
+ request['stopLoss'] = stopLossRequest;
4089
+ const slTriggerBy = this.safeString(params, 'slTriggerBy', 'LastPrice');
4090
+ request['slTriggerBy'] = slTriggerBy;
4075
4091
  }
4076
4092
  if (isTakeProfit) {
4077
- const tpTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
4078
- request['takeProfit'] = tpTriggerPrice;
4093
+ const tpTriggerPrice = this.safeString2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
4094
+ const takeProfitRequest = (tpTriggerPrice === '0') ? tpTriggerPrice : this.priceToPrecision(symbol, tpTriggerPrice);
4095
+ request['takeProfit'] = takeProfitRequest;
4096
+ const tpTriggerBy = this.safeString(params, 'tpTriggerBy', 'LastPrice');
4097
+ request['tpTriggerBy'] = tpTriggerBy;
4079
4098
  }
4080
4099
  }
4081
4100
  const clientOrderId = this.safeString(params, 'clientOrderId');
@@ -114,6 +114,7 @@ export default class coinbasepro extends Exchange {
114
114
  },
115
115
  'private': {
116
116
  'get': [
117
+ 'address-book',
117
118
  'accounts',
118
119
  'accounts/{id}',
119
120
  'accounts/{id}/holds',
package/js/src/kucoin.js CHANGED
@@ -811,6 +811,7 @@ export default class kucoin extends Exchange {
811
811
  * @method
812
812
  * @name kucoin#fetchTime
813
813
  * @description fetches the current integer timestamp in milliseconds from the exchange server
814
+ * @see https://docs.kucoin.com/#server-time
814
815
  * @param {object} [params] extra parameters specific to the kucoin api endpoint
815
816
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
816
817
  */
@@ -829,6 +830,7 @@ export default class kucoin extends Exchange {
829
830
  * @method
830
831
  * @name kucoin#fetchStatus
831
832
  * @description the latest known information on the availability of the exchange API
833
+ * @see https://docs.kucoin.com/#service-status
832
834
  * @param {object} [params] extra parameters specific to the kucoin api endpoint
833
835
  * @returns {object} a [status structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#exchange-status-structure}
834
836
  */
@@ -857,6 +859,8 @@ export default class kucoin extends Exchange {
857
859
  * @method
858
860
  * @name kucoin#fetchMarkets
859
861
  * @description retrieves data on all markets for kucoin
862
+ * @see https://docs.kucoin.com/#get-symbols-list-deprecated
863
+ * @see https://docs.kucoin.com/#get-all-tickers
860
864
  * @param {object} [params] extra parameters specific to the exchange api endpoint
861
865
  * @returns {object[]} an array of objects representing market data
862
866
  */
@@ -995,6 +999,7 @@ export default class kucoin extends Exchange {
995
999
  * @method
996
1000
  * @name kucoin#fetchCurrencies
997
1001
  * @description fetches all available currencies on an exchange
1002
+ * @see https://docs.kucoin.com/#get-currencies
998
1003
  * @param {object} params extra parameters specific to the kucoin api endpoint
999
1004
  * @returns {object} an associative dictionary of currencies
1000
1005
  */
@@ -1092,7 +1097,7 @@ export default class kucoin extends Exchange {
1092
1097
  }
1093
1098
  for (let j = 0; j < chainsLength; j++) {
1094
1099
  const chain = chains[j];
1095
- const chainId = this.safeString(chain, 'chain');
1100
+ const chainId = this.safeString(chain, 'chainId');
1096
1101
  const networkCode = this.networkIdToCode(chainId);
1097
1102
  const chainWithdrawEnabled = this.safeValue(chain, 'isWithdrawEnabled', false);
1098
1103
  if (isWithdrawEnabled === undefined) {
@@ -1155,6 +1160,7 @@ export default class kucoin extends Exchange {
1155
1160
  * @method
1156
1161
  * @name kucoin#fetchAccounts
1157
1162
  * @description fetch all the accounts associated with a profile
1163
+ * @see https://docs.kucoin.com/#list-accounts
1158
1164
  * @param {object} [params] extra parameters specific to the kucoin api endpoint
1159
1165
  * @returns {object} a dictionary of [account structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#account-structure} indexed by the account type
1160
1166
  */
@@ -1432,6 +1438,7 @@ export default class kucoin extends Exchange {
1432
1438
  * @method
1433
1439
  * @name kucoin#fetchTickers
1434
1440
  * @description fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
1441
+ * @see https://docs.kucoin.com/#get-all-tickers
1435
1442
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1436
1443
  * @param {object} [params] extra parameters specific to the kucoin api endpoint
1437
1444
  * @returns {object} a dictionary of [ticker structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
@@ -1486,6 +1493,7 @@ export default class kucoin extends Exchange {
1486
1493
  * @method
1487
1494
  * @name kucoin#fetchTicker
1488
1495
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1496
+ * @see https://docs.kucoin.com/#get-24hr-stats
1489
1497
  * @param {string} symbol unified symbol of the market to fetch the ticker for
1490
1498
  * @param {object} [params] extra parameters specific to the kucoin api endpoint
1491
1499
  * @returns {object} a [ticker structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
@@ -1547,6 +1555,7 @@ export default class kucoin extends Exchange {
1547
1555
  * @method
1548
1556
  * @name kucoin#fetchOHLCV
1549
1557
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1558
+ * @see https://docs.kucoin.com/#get-klines
1550
1559
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1551
1560
  * @param {string} timeframe the length of time each candle represents
1552
1561
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -1626,6 +1635,7 @@ export default class kucoin extends Exchange {
1626
1635
  * @method
1627
1636
  * @name kucoin#fetchDepositAddress
1628
1637
  * @description fetch the deposit address for a currency associated with this account
1638
+ * @see https://docs.kucoin.com/#get-deposit-addresses-v2
1629
1639
  * @param {string} code unified currency code
1630
1640
  * @param {object} [params] extra parameters specific to the kucoin api endpoint
1631
1641
  * @param {string} [params.network] the blockchain network name
@@ -1723,6 +1733,8 @@ export default class kucoin extends Exchange {
1723
1733
  * @method
1724
1734
  * @name kucoin#fetchOrderBook
1725
1735
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
1736
+ * @see https://docs.kucoin.com/#get-part-order-book-aggregated
1737
+ * @see https://docs.kucoin.com/#get-full-order-book-aggregated
1726
1738
  * @param {string} symbol unified symbol of the market to fetch the order book for
1727
1739
  * @param {int} [limit] the maximum amount of order book entries to return
1728
1740
  * @param {object} [params] extra parameters specific to the kucoin api endpoint
@@ -2193,6 +2205,10 @@ export default class kucoin extends Exchange {
2193
2205
  * @method
2194
2206
  * @name kucoin#fetchClosedOrders
2195
2207
  * @description fetches information on multiple closed orders made by the user
2208
+ * @see https://docs.kucoin.com/spot#list-orders
2209
+ * @see https://docs.kucoin.com/spot#list-stop-orders
2210
+ * @see https://docs.kucoin.com/spot-hf/#obtain-list-of-active-hf-orders
2211
+ * @see https://docs.kucoin.com/spot-hf/#obtain-list-of-filled-hf-orders
2196
2212
  * @param {string} symbol unified market symbol of the market orders were made in
2197
2213
  * @param {int} [since] the earliest time in ms to fetch orders for
2198
2214
  * @param {int} [limit] the maximum number of orde structures to retrieve
@@ -2212,6 +2228,10 @@ export default class kucoin extends Exchange {
2212
2228
  * @method
2213
2229
  * @name kucoin#fetchOpenOrders
2214
2230
  * @description fetch all unfilled currently open orders
2231
+ * @see https://docs.kucoin.com/spot#list-orders
2232
+ * @see https://docs.kucoin.com/spot#list-stop-orders
2233
+ * @see https://docs.kucoin.com/spot-hf/#obtain-list-of-active-hf-orders
2234
+ * @see https://docs.kucoin.com/spot-hf/#obtain-list-of-filled-hf-orders
2215
2235
  * @param {string} symbol unified market symbol
2216
2236
  * @param {int} [since] the earliest time in ms to fetch open orders for
2217
2237
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -2488,6 +2508,8 @@ export default class kucoin extends Exchange {
2488
2508
  * @method
2489
2509
  * @name kucoin#fetchOrderTrades
2490
2510
  * @description fetch all the trades made from a single order
2511
+ * @see https://docs.kucoin.com/#list-fills
2512
+ * @see https://docs.kucoin.com/spot-hf/#transaction-details
2491
2513
  * @param {string} id order id
2492
2514
  * @param {string} symbol unified market symbol
2493
2515
  * @param {int} [since] the earliest time in ms to fetch trades for
@@ -2613,6 +2635,7 @@ export default class kucoin extends Exchange {
2613
2635
  * @method
2614
2636
  * @name kucoin#fetchTrades
2615
2637
  * @description get the list of most recent trades for a particular symbol
2638
+ * @see https://docs.kucoin.com/#get-trade-histories
2616
2639
  * @param {string} symbol unified symbol of the market to fetch trades for
2617
2640
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
2618
2641
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -2785,6 +2808,7 @@ export default class kucoin extends Exchange {
2785
2808
  * @method
2786
2809
  * @name kucoin#fetchTradingFee
2787
2810
  * @description fetch the trading fees for a market
2811
+ * @see https://docs.kucoin.com/#actual-fee-rate-of-the-trading-pair
2788
2812
  * @param {string} symbol unified market symbol
2789
2813
  * @param {object} [params] extra parameters specific to the kucoin api endpoint
2790
2814
  * @returns {object} a [fee structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure}
@@ -2824,6 +2848,7 @@ export default class kucoin extends Exchange {
2824
2848
  * @method
2825
2849
  * @name kucoin#withdraw
2826
2850
  * @description make a withdrawal
2851
+ * @see https://docs.kucoin.com/#apply-withdraw-2
2827
2852
  * @param {string} code unified currency code
2828
2853
  * @param {float} amount the amount to withdraw
2829
2854
  * @param {string} address the address to withdraw to
@@ -2996,6 +3021,8 @@ export default class kucoin extends Exchange {
2996
3021
  * @method
2997
3022
  * @name kucoin#fetchDeposits
2998
3023
  * @description fetch all deposits made to an account
3024
+ * @see https://docs.kucoin.com/#get-deposit-list
3025
+ * @see https://docs.kucoin.com/#get-v1-historical-deposits-list
2999
3026
  * @param {string} code unified currency code
3000
3027
  * @param {int} [since] the earliest time in ms to fetch deposits for
3001
3028
  * @param {int} [limit] the maximum number of deposits structures to retrieve
@@ -3070,6 +3097,8 @@ export default class kucoin extends Exchange {
3070
3097
  * @method
3071
3098
  * @name kucoin#fetchWithdrawals
3072
3099
  * @description fetch all withdrawals made from an account
3100
+ * @see https://docs.kucoin.com/#get-withdrawals-list
3101
+ * @see https://docs.kucoin.com/#get-v1-historical-withdrawals-list
3073
3102
  * @param {string} code unified currency code
3074
3103
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
3075
3104
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
@@ -3584,6 +3613,7 @@ export default class kucoin extends Exchange {
3584
3613
  * @method
3585
3614
  * @name kucoin#fetchLedger
3586
3615
  * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
3616
+ * @see https://docs.kucoin.com/#get-account-ledgers
3587
3617
  * @param {string} code unified currency code, default is undefined
3588
3618
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
3589
3619
  * @param {int} [limit] max number of ledger entrys to return, default is undefined
package/js/src/latoken.js CHANGED
@@ -33,9 +33,9 @@ export default class latoken extends Exchange {
33
33
  'cancelOrder': true,
34
34
  'createOrder': true,
35
35
  'createPostOnlyOrder': false,
36
- 'createStopOrder': true,
37
36
  'createStopLimitOrder': true,
38
37
  'createStopMarketOrder': false,
38
+ 'createStopOrder': true,
39
39
  'fetchBalance': true,
40
40
  'fetchBorrowRate': false,
41
41
  'fetchBorrowRateHistories': false,
package/js/src/okx.js CHANGED
@@ -2086,15 +2086,32 @@ export default class okx extends Exchange {
2086
2086
  defaultType = this.safeString(options, 'type', defaultType); // Candles or HistoryCandles
2087
2087
  const type = this.safeString(params, 'type', defaultType);
2088
2088
  params = this.omit(params, 'type');
2089
- let method = 'publicGetMarket' + type;
2090
2089
  const isHistoryCandles = (type === 'HistoryCandles');
2090
+ let response = undefined;
2091
2091
  if (price === 'mark') {
2092
- method = (isHistoryCandles) ? 'publicGetMarketHistoryMarkPriceCandles' : 'publicGetMarketMarkPriceCandles';
2092
+ if (isHistoryCandles) {
2093
+ response = await this.publicGetMarketHistoryMarkPriceCandles(this.extend(request, params));
2094
+ }
2095
+ else {
2096
+ response = await this.publicGetMarketMarkPriceCandles(this.extend(request, params));
2097
+ }
2093
2098
  }
2094
2099
  else if (price === 'index') {
2095
- method = (isHistoryCandles) ? 'publicGetMarketHistoryIndexCandles' : 'publicGetMarketIndexCandles';
2100
+ if (isHistoryCandles) {
2101
+ response = await this.publicGetMarketHistoryIndexCandles(this.extend(request, params));
2102
+ }
2103
+ else {
2104
+ response = await this.publicGetMarketIndexCandles(this.extend(request, params));
2105
+ }
2106
+ }
2107
+ else {
2108
+ if (isHistoryCandles) {
2109
+ response = await this.publicGetMarketHistoryCandles(this.extend(request, params));
2110
+ }
2111
+ else {
2112
+ response = await this.publicGetMarketCandles(this.extend(request, params));
2113
+ }
2096
2114
  }
2097
- const response = await this[method](this.extend(request, params));
2098
2115
  //
2099
2116
  // {
2100
2117
  // "code": "0",
@@ -2306,17 +2323,16 @@ export default class okx extends Exchange {
2306
2323
  */
2307
2324
  await this.loadMarkets();
2308
2325
  const [marketType, query] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
2309
- let method = undefined;
2326
+ const request = {
2327
+ // 'ccy': 'BTC,ETH', // comma-separated list of currency ids
2328
+ };
2329
+ let response = undefined;
2310
2330
  if (marketType === 'funding') {
2311
- method = 'privateGetAssetBalances';
2331
+ response = await this.privateGetAssetBalances(this.extend(request, query));
2312
2332
  }
2313
2333
  else {
2314
- method = 'privateGetAccountBalance';
2334
+ response = await this.privateGetAccountBalance(this.extend(request, query));
2315
2335
  }
2316
- const request = {
2317
- // 'ccy': 'BTC,ETH', // comma-separated list of currency ids
2318
- };
2319
- const response = await this[method](this.extend(request, query));
2320
2336
  //
2321
2337
  // {
2322
2338
  // "code": "0",
@@ -16,6 +16,8 @@ export default class coinbasepro extends coinbaseproRest {
16
16
  watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
17
17
  watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<any>;
18
18
  watchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
19
+ watchMyTradesForSymbols(symbols?: string[], since?: Int, limit?: Int, params?: {}): Promise<any>;
20
+ watchOrdersForSymbols(symbols?: string[], since?: Int, limit?: Int, params?: {}): Promise<any>;
19
21
  watchOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
20
22
  watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<any>;
21
23
  watchOrderBookForSymbols(symbols: string[], limit?: Int, params?: {}): Promise<any>;
@@ -24,30 +26,7 @@ export default class coinbasepro extends coinbaseproRest {
24
26
  parseWsTrade(trade: any, market?: any): import("../base/types.js").Trade;
25
27
  parseWsOrderStatus(status: any): string;
26
28
  handleOrder(client: Client, message: any): void;
27
- parseWsOrder(order: any, market?: any): {
28
- info: any;
29
- symbol: any;
30
- id: string;
31
- clientOrderId: string;
32
- timestamp: number;
33
- datetime: string;
34
- lastTradeTimestamp: any;
35
- type: string;
36
- timeInForce: any;
37
- postOnly: any;
38
- side: string;
39
- price: number;
40
- stopPrice: any;
41
- triggerPrice: any;
42
- amount: number;
43
- cost: any;
44
- average: any;
45
- filled: any;
46
- remaining: number;
47
- status: string;
48
- fee: any;
49
- trades: any;
50
- };
29
+ parseWsOrder(order: any, market?: any): import("../base/types.js").Order;
51
30
  handleTicker(client: Client, message: any): any;
52
31
  parseTicker(ticker: any, market?: any): import("../base/types.js").Ticker;
53
32
  handleDelta(bookside: any, delta: any): void;
@@ -22,9 +22,11 @@ export default class coinbasepro extends coinbaseproRest {
22
22
  'watchTickers': true,
23
23
  'watchTrades': true,
24
24
  'watchTradesForSymbols': true,
25
+ 'watchMyTradesForSymbols': true,
25
26
  'watchBalance': false,
26
27
  'watchStatus': false,
27
28
  'watchOrders': true,
29
+ 'watchOrdersForSymbols': true,
28
30
  'watchMyTrades': true,
29
31
  },
30
32
  'urls': {
@@ -212,6 +214,54 @@ export default class coinbasepro extends coinbaseproRest {
212
214
  }
213
215
  return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
214
216
  }
217
+ async watchMyTradesForSymbols(symbols = undefined, since = undefined, limit = undefined, params = {}) {
218
+ /**
219
+ * @method
220
+ * @name coinbasepro#watchMyTradesForSymbols
221
+ * @description watches information on multiple trades made by the user
222
+ * @param {string[]} symbols unified symbol of the market to fetch trades for
223
+ * @param {int} [since] the earliest time in ms to fetch trades for
224
+ * @param {int} [limit] the maximum number of trade structures to retrieve
225
+ * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
226
+ * @returns {object[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure
227
+ */
228
+ symbols = this.marketSymbols(symbols, undefined, false);
229
+ await this.loadMarkets();
230
+ const name = 'user';
231
+ const messageHash = 'multipleMyTrades::';
232
+ const authentication = this.authenticate();
233
+ const trades = await this.subscribeMultiple(name, symbols, messageHash, this.extend(params, authentication));
234
+ if (this.newUpdates) {
235
+ const first = this.safeValue(trades, 0);
236
+ const tradeSymbol = this.safeString(first, 'symbol');
237
+ limit = trades.getLimit(tradeSymbol, limit);
238
+ }
239
+ return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
240
+ }
241
+ async watchOrdersForSymbols(symbols = undefined, since = undefined, limit = undefined, params = {}) {
242
+ /**
243
+ * @method
244
+ * @name coinbasepro#watchOrdersForSymbols
245
+ * @description watches information on multiple orders made by the user
246
+ * @param {string[]} symbols unified symbol of the market to fetch orders for
247
+ * @param {int} [since] the earliest time in ms to fetch orders for
248
+ * @param {int} [limit] the maximum number of trade structures to retrieve
249
+ * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
250
+ * @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
251
+ */
252
+ symbols = this.marketSymbols(symbols, undefined, false);
253
+ await this.loadMarkets();
254
+ const name = 'user';
255
+ const messageHash = 'multipleOrders::';
256
+ const authentication = this.authenticate();
257
+ const orders = await this.subscribeMultiple(name, symbols, messageHash, this.extend(params, authentication));
258
+ if (this.newUpdates) {
259
+ const first = this.safeValue(orders, 0);
260
+ const tradeSymbol = this.safeString(first, 'symbol');
261
+ limit = orders.getLimit(tradeSymbol, limit);
262
+ }
263
+ return this.filterBySinceLimit(orders, since, limit, 'timestamp', true);
264
+ }
215
265
  async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
216
266
  /**
217
267
  * @method
@@ -351,6 +401,7 @@ export default class coinbasepro extends coinbaseproRest {
351
401
  const marketId = this.safeString(message, 'product_id');
352
402
  if (marketId !== undefined) {
353
403
  const trade = this.parseWsTrade(message);
404
+ const symbol = trade['symbol'];
354
405
  const type = 'myTrades';
355
406
  const messageHash = type + ':' + marketId;
356
407
  let tradesArray = this.myTrades;
@@ -361,6 +412,7 @@ export default class coinbasepro extends coinbaseproRest {
361
412
  }
362
413
  tradesArray.append(trade);
363
414
  client.resolve(tradesArray, messageHash);
415
+ this.resolvePromiseIfMessagehashMatches(client, 'multipleMyTrades::', symbol, tradesArray);
364
416
  }
365
417
  return message;
366
418
  }
@@ -417,14 +469,25 @@ export default class coinbasepro extends coinbaseproRest {
417
469
  // }
418
470
  const parsed = super.parseTrade(trade);
419
471
  let feeRate = undefined;
472
+ let isMaker = false;
420
473
  if ('maker_fee_rate' in trade) {
474
+ isMaker = true;
421
475
  parsed['takerOrMaker'] = 'maker';
422
476
  feeRate = this.safeNumber(trade, 'maker_fee_rate');
423
477
  }
424
478
  else {
425
479
  parsed['takerOrMaker'] = 'taker';
426
480
  feeRate = this.safeNumber(trade, 'taker_fee_rate');
427
- }
481
+ // side always represents the maker side of the trade
482
+ // so if we're taker, we invert it
483
+ const currentSide = parsed['side'];
484
+ parsed['side'] = this.safeString({
485
+ 'buy': 'sell',
486
+ 'sell': 'buy',
487
+ }, currentSide, currentSide);
488
+ }
489
+ const idKey = isMaker ? 'maker_order_id' : 'taker_order_id';
490
+ parsed['order'] = this.safeString(trade, idKey);
428
491
  market = this.market(parsed['symbol']);
429
492
  const feeCurrency = market['quote'];
430
493
  let feeCost = undefined;
@@ -550,6 +613,7 @@ export default class coinbasepro extends coinbaseproRest {
550
613
  const parsed = this.parseWsOrder(message);
551
614
  orders.append(parsed);
552
615
  client.resolve(orders, messageHash);
616
+ this.resolvePromiseIfMessagehashMatches(client, 'multipleOrders::', symbol, orders);
553
617
  }
554
618
  else {
555
619
  const sequence = this.safeInteger(message, 'sequence');
@@ -593,6 +657,7 @@ export default class coinbasepro extends coinbaseproRest {
593
657
  // update the newUpdates count
594
658
  orders.append(previousOrder);
595
659
  client.resolve(orders, messageHash);
660
+ this.resolvePromiseIfMessagehashMatches(client, 'multipleOrders::', symbol, orders);
596
661
  }
597
662
  else if ((type === 'received') || (type === 'done')) {
598
663
  const info = this.extend(previousOrder['info'], message);
@@ -608,6 +673,7 @@ export default class coinbasepro extends coinbaseproRest {
608
673
  // update the newUpdates count
609
674
  orders.append(previousOrder);
610
675
  client.resolve(orders, messageHash);
676
+ this.resolvePromiseIfMessagehashMatches(client, 'multipleOrders::', symbol, orders);
611
677
  }
612
678
  }
613
679
  }
@@ -638,11 +704,7 @@ export default class coinbasepro extends coinbaseproRest {
638
704
  remaining = amount - filled;
639
705
  }
640
706
  }
641
- let cost = undefined;
642
- if ((price !== undefined) && (amount !== undefined)) {
643
- cost = price * amount;
644
- }
645
- return {
707
+ return this.safeOrder({
646
708
  'info': order,
647
709
  'symbol': symbol,
648
710
  'id': id,
@@ -658,14 +720,14 @@ export default class coinbasepro extends coinbaseproRest {
658
720
  'stopPrice': undefined,
659
721
  'triggerPrice': undefined,
660
722
  'amount': amount,
661
- 'cost': cost,
723
+ 'cost': undefined,
662
724
  'average': undefined,
663
725
  'filled': filled,
664
726
  'remaining': remaining,
665
727
  'status': status,
666
728
  'fee': undefined,
667
729
  'trades': undefined,
668
- };
730
+ });
669
731
  }
670
732
  handleTicker(client, message) {
671
733
  //
package/js/src/pro/okx.js CHANGED
@@ -1037,8 +1037,8 @@ export default class okx extends okxRest {
1037
1037
  // filter orders with no last trade id
1038
1038
  for (let i = 0; i < rawOrders.length; i++) {
1039
1039
  const rawOrder = rawOrders[i];
1040
- const tradeId = this.safeString(rawOrder, 'tradeId');
1041
- if (!this.isEmpty(tradeId)) {
1040
+ const tradeId = this.safeString(rawOrder, 'tradeId', '');
1041
+ if (tradeId.length > 0) {
1042
1042
  const order = this.parseOrder(rawOrder);
1043
1043
  filteredOrders.push(order);
1044
1044
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.0.112",
3
+ "version": "4.1.2",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 130+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",