ccxt 4.0.112__py2.py3-none-any.whl → 4.1.2__py2.py3-none-any.whl

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.
ccxt/bybit.py CHANGED
@@ -3805,6 +3805,16 @@ class bybit(Exchange, ImplicitAPI):
3805
3805
  :param float amount: how much of currency you want to trade in units of base currency
3806
3806
  :param float price: the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
3807
3807
  :param dict [params]: extra parameters specific to the bybit api endpoint
3808
+ :param float [params.triggerPrice]: The price that a trigger order is triggered at
3809
+ :param float [params.stopLossPrice]: The price that a stop loss order is triggered at
3810
+ :param float [params.takeProfitPrice]: The price that a take profit order is triggered at
3811
+ :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice that the attached take profit order will be triggered
3812
+ :param float [params.takeProfit.triggerPrice]: take profit trigger price
3813
+ :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice that the attached stop loss order will be triggered
3814
+ :param float [params.stopLoss.triggerPrice]: stop loss trigger price
3815
+ :param str [params.triggerBy]: 'IndexPrice', 'MarkPrice' or 'LastPrice', default is 'LastPrice', required if no initial value for triggerPrice
3816
+ :param str [params.slTriggerBy]: 'IndexPrice', 'MarkPrice' or 'LastPrice', default is 'LastPrice', required if no initial value for stopLoss
3817
+ :param str [params.tpTriggerby]: 'IndexPrice', 'MarkPrice' or 'LastPrice', default is 'LastPrice', required if no initial value for takeProfit
3808
3818
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
3809
3819
  """
3810
3820
  self.check_required_symbol('editOrder', symbol)
@@ -3840,9 +3850,9 @@ class bybit(Exchange, ImplicitAPI):
3840
3850
  request['price'] = self.price_to_precision(symbol, price)
3841
3851
  if amount is not None:
3842
3852
  request['qty'] = self.amount_to_precision(symbol, amount)
3843
- triggerPrice = self.safe_value_2(params, 'triggerPrice', 'stopPrice')
3844
- stopLossTriggerPrice = self.safe_value(params, 'stopLossPrice')
3845
- takeProfitTriggerPrice = self.safe_value(params, 'takeProfitPrice')
3853
+ triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
3854
+ stopLossTriggerPrice = self.safe_string(params, 'stopLossPrice')
3855
+ takeProfitTriggerPrice = self.safe_string(params, 'takeProfitPrice')
3846
3856
  stopLoss = self.safe_value(params, 'stopLoss')
3847
3857
  takeProfit = self.safe_value(params, 'takeProfit')
3848
3858
  isStopLossTriggerOrder = stopLossTriggerPrice is not None
@@ -3852,14 +3862,23 @@ class bybit(Exchange, ImplicitAPI):
3852
3862
  if isStopLossTriggerOrder or isTakeProfitTriggerOrder:
3853
3863
  triggerPrice = stopLossTriggerPrice if isStopLossTriggerOrder else takeProfitTriggerPrice
3854
3864
  if triggerPrice is not None:
3855
- request['triggerPrice'] = triggerPrice
3865
+ triggerPriceRequest = triggerPrice if (triggerPrice == '0') else self.price_to_precision(symbol, triggerPrice)
3866
+ request['triggerPrice'] = triggerPriceRequest
3867
+ triggerBy = self.safe_string(params, 'triggerBy', 'LastPrice')
3868
+ request['triggerBy'] = triggerBy
3856
3869
  if isStopLoss or isTakeProfit:
3857
3870
  if isStopLoss:
3858
- slTriggerPrice = self.safe_value_2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss)
3859
- request['stopLoss'] = slTriggerPrice
3871
+ slTriggerPrice = self.safe_string_2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss)
3872
+ stopLossRequest = slTriggerPrice if (slTriggerPrice == '0') else self.price_to_precision(symbol, slTriggerPrice)
3873
+ request['stopLoss'] = stopLossRequest
3874
+ slTriggerBy = self.safe_string(params, 'slTriggerBy', 'LastPrice')
3875
+ request['slTriggerBy'] = slTriggerBy
3860
3876
  if isTakeProfit:
3861
- tpTriggerPrice = self.safe_value_2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit)
3862
- request['takeProfit'] = tpTriggerPrice
3877
+ tpTriggerPrice = self.safe_string_2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit)
3878
+ takeProfitRequest = tpTriggerPrice if (tpTriggerPrice == '0') else self.price_to_precision(symbol, tpTriggerPrice)
3879
+ request['takeProfit'] = takeProfitRequest
3880
+ tpTriggerBy = self.safe_string(params, 'tpTriggerBy', 'LastPrice')
3881
+ request['tpTriggerBy'] = tpTriggerBy
3863
3882
  clientOrderId = self.safe_string(params, 'clientOrderId')
3864
3883
  if clientOrderId is not None:
3865
3884
  request['orderLinkId'] = clientOrderId
ccxt/coinbasepro.py CHANGED
@@ -125,6 +125,7 @@ class coinbasepro(Exchange, ImplicitAPI):
125
125
  },
126
126
  'private': {
127
127
  'get': [
128
+ 'address-book',
128
129
  'accounts',
129
130
  'accounts/{id}',
130
131
  'accounts/{id}/holds',
ccxt/kucoin.py CHANGED
@@ -826,6 +826,7 @@ class kucoin(Exchange, ImplicitAPI):
826
826
  def fetch_time(self, params={}):
827
827
  """
828
828
  fetches the current integer timestamp in milliseconds from the exchange server
829
+ see https://docs.kucoin.com/#server-time
829
830
  :param dict [params]: extra parameters specific to the kucoin api endpoint
830
831
  :returns int: the current integer timestamp in milliseconds from the exchange server
831
832
  """
@@ -842,6 +843,7 @@ class kucoin(Exchange, ImplicitAPI):
842
843
  def fetch_status(self, params={}):
843
844
  """
844
845
  the latest known information on the availability of the exchange API
846
+ see https://docs.kucoin.com/#service-status
845
847
  :param dict [params]: extra parameters specific to the kucoin api endpoint
846
848
  :returns dict: a `status structure <https://github.com/ccxt/ccxt/wiki/Manual#exchange-status-structure>`
847
849
  """
@@ -868,6 +870,8 @@ class kucoin(Exchange, ImplicitAPI):
868
870
  def fetch_markets(self, params={}):
869
871
  """
870
872
  retrieves data on all markets for kucoin
873
+ see https://docs.kucoin.com/#get-symbols-list-deprecated
874
+ see https://docs.kucoin.com/#get-all-tickers
871
875
  :param dict [params]: extra parameters specific to the exchange api endpoint
872
876
  :returns dict[]: an array of objects representing market data
873
877
  """
@@ -1002,6 +1006,7 @@ class kucoin(Exchange, ImplicitAPI):
1002
1006
  def fetch_currencies(self, params={}):
1003
1007
  """
1004
1008
  fetches all available currencies on an exchange
1009
+ see https://docs.kucoin.com/#get-currencies
1005
1010
  :param dict params: extra parameters specific to the kucoin api endpoint
1006
1011
  :returns dict: an associative dictionary of currencies
1007
1012
  """
@@ -1098,7 +1103,7 @@ class kucoin(Exchange, ImplicitAPI):
1098
1103
  isDepositEnabled = False
1099
1104
  for j in range(0, chainsLength):
1100
1105
  chain = chains[j]
1101
- chainId = self.safe_string(chain, 'chain')
1106
+ chainId = self.safe_string(chain, 'chainId')
1102
1107
  networkCode = self.network_id_to_code(chainId)
1103
1108
  chainWithdrawEnabled = self.safe_value(chain, 'isWithdrawEnabled', False)
1104
1109
  if isWithdrawEnabled is None:
@@ -1153,6 +1158,7 @@ class kucoin(Exchange, ImplicitAPI):
1153
1158
  def fetch_accounts(self, params={}):
1154
1159
  """
1155
1160
  fetch all the accounts associated with a profile
1161
+ see https://docs.kucoin.com/#list-accounts
1156
1162
  :param dict [params]: extra parameters specific to the kucoin api endpoint
1157
1163
  :returns dict: a dictionary of `account structures <https://github.com/ccxt/ccxt/wiki/Manual#account-structure>` indexed by the account type
1158
1164
  """
@@ -1417,6 +1423,7 @@ class kucoin(Exchange, ImplicitAPI):
1417
1423
  def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
1418
1424
  """
1419
1425
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
1426
+ see https://docs.kucoin.com/#get-all-tickers
1420
1427
  :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1421
1428
  :param dict [params]: extra parameters specific to the kucoin api endpoint
1422
1429
  :returns dict: a dictionary of `ticker structures <https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure>`
@@ -1467,6 +1474,7 @@ class kucoin(Exchange, ImplicitAPI):
1467
1474
  def fetch_ticker(self, symbol: str, params={}):
1468
1475
  """
1469
1476
  fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1477
+ see https://docs.kucoin.com/#get-24hr-stats
1470
1478
  :param str symbol: unified symbol of the market to fetch the ticker for
1471
1479
  :param dict [params]: extra parameters specific to the kucoin api endpoint
1472
1480
  :returns dict: a `ticker structure <https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure>`
@@ -1526,6 +1534,7 @@ class kucoin(Exchange, ImplicitAPI):
1526
1534
  def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Optional[int] = None, limit: Optional[int] = None, params={}):
1527
1535
  """
1528
1536
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1537
+ see https://docs.kucoin.com/#get-klines
1529
1538
  :param str symbol: unified symbol of the market to fetch OHLCV data for
1530
1539
  :param str timeframe: the length of time each candle represents
1531
1540
  :param int [since]: timestamp in ms of the earliest candle to fetch
@@ -1597,6 +1606,7 @@ class kucoin(Exchange, ImplicitAPI):
1597
1606
  def fetch_deposit_address(self, code: str, params={}):
1598
1607
  """
1599
1608
  fetch the deposit address for a currency associated with self account
1609
+ see https://docs.kucoin.com/#get-deposit-addresses-v2
1600
1610
  :param str code: unified currency code
1601
1611
  :param dict [params]: extra parameters specific to the kucoin api endpoint
1602
1612
  :param str [params.network]: the blockchain network name
@@ -1685,6 +1695,8 @@ class kucoin(Exchange, ImplicitAPI):
1685
1695
  def fetch_order_book(self, symbol: str, limit: Optional[int] = None, params={}):
1686
1696
  """
1687
1697
  fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
1698
+ see https://docs.kucoin.com/#get-part-order-book-aggregated
1699
+ see https://docs.kucoin.com/#get-full-order-book-aggregated
1688
1700
  :param str symbol: unified symbol of the market to fetch the order book for
1689
1701
  :param int [limit]: the maximum amount of order book entries to return
1690
1702
  :param dict [params]: extra parameters specific to the kucoin api endpoint
@@ -2092,6 +2104,10 @@ class kucoin(Exchange, ImplicitAPI):
2092
2104
  def fetch_closed_orders(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
2093
2105
  """
2094
2106
  fetches information on multiple closed orders made by the user
2107
+ see https://docs.kucoin.com/spot#list-orders
2108
+ see https://docs.kucoin.com/spot#list-stop-orders
2109
+ see https://docs.kucoin.com/spot-hf/#obtain-list-of-active-hf-orders
2110
+ see https://docs.kucoin.com/spot-hf/#obtain-list-of-filled-hf-orders
2095
2111
  :param str symbol: unified market symbol of the market orders were made in
2096
2112
  :param int [since]: the earliest time in ms to fetch orders for
2097
2113
  :param int [limit]: the maximum number of orde structures to retrieve
@@ -2109,6 +2125,10 @@ class kucoin(Exchange, ImplicitAPI):
2109
2125
  def fetch_open_orders(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
2110
2126
  """
2111
2127
  fetch all unfilled currently open orders
2128
+ see https://docs.kucoin.com/spot#list-orders
2129
+ see https://docs.kucoin.com/spot#list-stop-orders
2130
+ see https://docs.kucoin.com/spot-hf/#obtain-list-of-active-hf-orders
2131
+ see https://docs.kucoin.com/spot-hf/#obtain-list-of-filled-hf-orders
2112
2132
  :param str symbol: unified market symbol
2113
2133
  :param int [since]: the earliest time in ms to fetch open orders for
2114
2134
  :param int [limit]: the maximum number of open orders structures to retrieve
@@ -2361,6 +2381,8 @@ class kucoin(Exchange, ImplicitAPI):
2361
2381
  def fetch_order_trades(self, id: str, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
2362
2382
  """
2363
2383
  fetch all the trades made from a single order
2384
+ see https://docs.kucoin.com/#list-fills
2385
+ see https://docs.kucoin.com/spot-hf/#transaction-details
2364
2386
  :param str id: order id
2365
2387
  :param str symbol: unified market symbol
2366
2388
  :param int [since]: the earliest time in ms to fetch trades for
@@ -2470,6 +2492,7 @@ class kucoin(Exchange, ImplicitAPI):
2470
2492
  def fetch_trades(self, symbol: str, since: Optional[int] = None, limit: Optional[int] = None, params={}):
2471
2493
  """
2472
2494
  get the list of most recent trades for a particular symbol
2495
+ see https://docs.kucoin.com/#get-trade-histories
2473
2496
  :param str symbol: unified symbol of the market to fetch trades for
2474
2497
  :param int [since]: timestamp in ms of the earliest trade to fetch
2475
2498
  :param int [limit]: the maximum amount of trades to fetch
@@ -2634,6 +2657,7 @@ class kucoin(Exchange, ImplicitAPI):
2634
2657
  def fetch_trading_fee(self, symbol: str, params={}):
2635
2658
  """
2636
2659
  fetch the trading fees for a market
2660
+ see https://docs.kucoin.com/#actual-fee-rate-of-the-trading-pair
2637
2661
  :param str symbol: unified market symbol
2638
2662
  :param dict [params]: extra parameters specific to the kucoin api endpoint
2639
2663
  :returns dict: a `fee structure <https://github.com/ccxt/ccxt/wiki/Manual#fee-structure>`
@@ -2671,6 +2695,7 @@ class kucoin(Exchange, ImplicitAPI):
2671
2695
  def withdraw(self, code: str, amount, address, tag=None, params={}):
2672
2696
  """
2673
2697
  make a withdrawal
2698
+ see https://docs.kucoin.com/#apply-withdraw-2
2674
2699
  :param str code: unified currency code
2675
2700
  :param float amount: the amount to withdraw
2676
2701
  :param str address: the address to withdraw to
@@ -2829,6 +2854,8 @@ class kucoin(Exchange, ImplicitAPI):
2829
2854
  def fetch_deposits(self, code: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
2830
2855
  """
2831
2856
  fetch all deposits made to an account
2857
+ see https://docs.kucoin.com/#get-deposit-list
2858
+ see https://docs.kucoin.com/#get-v1-historical-deposits-list
2832
2859
  :param str code: unified currency code
2833
2860
  :param int [since]: the earliest time in ms to fetch deposits for
2834
2861
  :param int [limit]: the maximum number of deposits structures to retrieve
@@ -2896,6 +2923,8 @@ class kucoin(Exchange, ImplicitAPI):
2896
2923
  def fetch_withdrawals(self, code: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
2897
2924
  """
2898
2925
  fetch all withdrawals made from an account
2926
+ see https://docs.kucoin.com/#get-withdrawals-list
2927
+ see https://docs.kucoin.com/#get-v1-historical-withdrawals-list
2899
2928
  :param str code: unified currency code
2900
2929
  :param int [since]: the earliest time in ms to fetch withdrawals for
2901
2930
  :param int [limit]: the maximum number of withdrawals structures to retrieve
@@ -3372,6 +3401,7 @@ class kucoin(Exchange, ImplicitAPI):
3372
3401
  def fetch_ledger(self, code: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
3373
3402
  """
3374
3403
  fetch the history of changes, actions done by the user or operations that altered balance of the user
3404
+ see https://docs.kucoin.com/#get-account-ledgers
3375
3405
  :param str code: unified currency code, default is None
3376
3406
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
3377
3407
  :param int [limit]: max number of ledger entrys to return, default is None
ccxt/okx.py CHANGED
@@ -2040,13 +2040,23 @@ class okx(Exchange, ImplicitAPI):
2040
2040
  defaultType = self.safe_string(options, 'type', defaultType) # Candles or HistoryCandles
2041
2041
  type = self.safe_string(params, 'type', defaultType)
2042
2042
  params = self.omit(params, 'type')
2043
- method = 'publicGetMarket' + type
2044
2043
  isHistoryCandles = (type == 'HistoryCandles')
2044
+ response = None
2045
2045
  if price == 'mark':
2046
- method = 'publicGetMarketHistoryMarkPriceCandles' if (isHistoryCandles) else 'publicGetMarketMarkPriceCandles'
2046
+ if isHistoryCandles:
2047
+ response = self.publicGetMarketHistoryMarkPriceCandles(self.extend(request, params))
2048
+ else:
2049
+ response = self.publicGetMarketMarkPriceCandles(self.extend(request, params))
2047
2050
  elif price == 'index':
2048
- method = 'publicGetMarketHistoryIndexCandles' if (isHistoryCandles) else 'publicGetMarketIndexCandles'
2049
- response = getattr(self, method)(self.extend(request, params))
2051
+ if isHistoryCandles:
2052
+ response = self.publicGetMarketHistoryIndexCandles(self.extend(request, params))
2053
+ else:
2054
+ response = self.publicGetMarketIndexCandles(self.extend(request, params))
2055
+ else:
2056
+ if isHistoryCandles:
2057
+ response = self.publicGetMarketHistoryCandles(self.extend(request, params))
2058
+ else:
2059
+ response = self.publicGetMarketCandles(self.extend(request, params))
2050
2060
  #
2051
2061
  # {
2052
2062
  # "code": "0",
@@ -2239,15 +2249,14 @@ class okx(Exchange, ImplicitAPI):
2239
2249
  """
2240
2250
  self.load_markets()
2241
2251
  marketType, query = self.handle_market_type_and_params('fetchBalance', None, params)
2242
- method = None
2243
- if marketType == 'funding':
2244
- method = 'privateGetAssetBalances'
2245
- else:
2246
- method = 'privateGetAccountBalance'
2247
2252
  request = {
2248
2253
  # 'ccy': 'BTC,ETH', # comma-separated list of currency ids
2249
2254
  }
2250
- response = getattr(self, method)(self.extend(request, query))
2255
+ response = None
2256
+ if marketType == 'funding':
2257
+ response = self.privateGetAssetBalances(self.extend(request, query))
2258
+ else:
2259
+ response = self.privateGetAccountBalance(self.extend(request, query))
2251
2260
  #
2252
2261
  # {
2253
2262
  # "code": "0",
ccxt/pro/__init__.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # ----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.0.112'
7
+ __version__ = '4.1.2'
8
8
 
9
9
  # ----------------------------------------------------------------------------
10
10
 
ccxt/pro/coinbasepro.py CHANGED
@@ -28,9 +28,11 @@ class coinbasepro(ccxt.async_support.coinbasepro):
28
28
  'watchTickers': True,
29
29
  'watchTrades': True,
30
30
  'watchTradesForSymbols': True,
31
+ 'watchMyTradesForSymbols': True,
31
32
  'watchBalance': False,
32
33
  'watchStatus': False, # for now
33
34
  'watchOrders': True,
35
+ 'watchOrdersForSymbols': True,
34
36
  'watchMyTrades': True,
35
37
  },
36
38
  'urls': {
@@ -198,6 +200,48 @@ class coinbasepro(ccxt.async_support.coinbasepro):
198
200
  limit = trades.getLimit(symbol, limit)
199
201
  return self.filter_by_since_limit(trades, since, limit, 'timestamp', True)
200
202
 
203
+ async def watch_my_trades_for_symbols(self, symbols: Optional[List[str]] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
204
+ """
205
+ watches information on multiple trades made by the user
206
+ :param str[] symbols: unified symbol of the market to fetch trades for
207
+ :param int [since]: the earliest time in ms to fetch trades for
208
+ :param int [limit]: the maximum number of trade structures to retrieve
209
+ :param dict [params]: extra parameters specific to the coinbasepro api endpoint
210
+ :returns dict[]: a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure
211
+ """
212
+ symbols = self.market_symbols(symbols, None, False)
213
+ await self.load_markets()
214
+ name = 'user'
215
+ messageHash = 'multipleMyTrades::'
216
+ authentication = self.authenticate()
217
+ trades = await self.subscribe_multiple(name, symbols, messageHash, self.extend(params, authentication))
218
+ if self.newUpdates:
219
+ first = self.safe_value(trades, 0)
220
+ tradeSymbol = self.safe_string(first, 'symbol')
221
+ limit = trades.getLimit(tradeSymbol, limit)
222
+ return self.filter_by_since_limit(trades, since, limit, 'timestamp', True)
223
+
224
+ async def watch_orders_for_symbols(self, symbols: Optional[List[str]] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
225
+ """
226
+ watches information on multiple orders made by the user
227
+ :param str[] symbols: unified symbol of the market to fetch orders for
228
+ :param int [since]: the earliest time in ms to fetch orders for
229
+ :param int [limit]: the maximum number of trade structures to retrieve
230
+ :param dict [params]: extra parameters specific to the coinbasepro api endpoint
231
+ :returns dict[]: a list of `order structures <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
232
+ """
233
+ symbols = self.market_symbols(symbols, None, False)
234
+ await self.load_markets()
235
+ name = 'user'
236
+ messageHash = 'multipleOrders::'
237
+ authentication = self.authenticate()
238
+ orders = await self.subscribe_multiple(name, symbols, messageHash, self.extend(params, authentication))
239
+ if self.newUpdates:
240
+ first = self.safe_value(orders, 0)
241
+ tradeSymbol = self.safe_string(first, 'symbol')
242
+ limit = orders.getLimit(tradeSymbol, limit)
243
+ return self.filter_by_since_limit(orders, since, limit, 'timestamp', True)
244
+
201
245
  async def watch_orders(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
202
246
  """
203
247
  watches information on multiple orders made by the user
@@ -326,6 +370,7 @@ class coinbasepro(ccxt.async_support.coinbasepro):
326
370
  marketId = self.safe_string(message, 'product_id')
327
371
  if marketId is not None:
328
372
  trade = self.parse_ws_trade(message)
373
+ symbol = trade['symbol']
329
374
  type = 'myTrades'
330
375
  messageHash = type + ':' + marketId
331
376
  tradesArray = self.myTrades
@@ -335,6 +380,7 @@ class coinbasepro(ccxt.async_support.coinbasepro):
335
380
  self.myTrades = tradesArray
336
381
  tradesArray.append(trade)
337
382
  client.resolve(tradesArray, messageHash)
383
+ self.resolve_promise_if_messagehash_matches(client, 'multipleMyTrades::', symbol, tradesArray)
338
384
  return message
339
385
 
340
386
  def parse_ws_trade(self, trade, market=None):
@@ -390,12 +436,23 @@ class coinbasepro(ccxt.async_support.coinbasepro):
390
436
  # }
391
437
  parsed = super(coinbasepro, self).parse_trade(trade)
392
438
  feeRate = None
439
+ isMaker = False
393
440
  if 'maker_fee_rate' in trade:
441
+ isMaker = True
394
442
  parsed['takerOrMaker'] = 'maker'
395
443
  feeRate = self.safe_number(trade, 'maker_fee_rate')
396
444
  else:
397
445
  parsed['takerOrMaker'] = 'taker'
398
446
  feeRate = self.safe_number(trade, 'taker_fee_rate')
447
+ # side always represents the maker side of the trade
448
+ # so if we're taker, we invert it
449
+ currentSide = parsed['side']
450
+ parsed['side'] = self.safe_string({
451
+ 'buy': 'sell',
452
+ 'sell': 'buy',
453
+ }, currentSide, currentSide)
454
+ idKey = 'maker_order_id' if isMaker else 'taker_order_id'
455
+ parsed['order'] = self.safe_string(trade, idKey)
399
456
  market = self.market(parsed['symbol'])
400
457
  feeCurrency = market['quote']
401
458
  feeCost = None
@@ -518,6 +575,7 @@ class coinbasepro(ccxt.async_support.coinbasepro):
518
575
  parsed = self.parse_ws_order(message)
519
576
  orders.append(parsed)
520
577
  client.resolve(orders, messageHash)
578
+ self.resolve_promise_if_messagehash_matches(client, 'multipleOrders::', symbol, orders)
521
579
  else:
522
580
  sequence = self.safe_integer(message, 'sequence')
523
581
  previousInfo = self.safe_value(previousOrder, 'info', {})
@@ -553,6 +611,7 @@ class coinbasepro(ccxt.async_support.coinbasepro):
553
611
  # update the newUpdates count
554
612
  orders.append(previousOrder)
555
613
  client.resolve(orders, messageHash)
614
+ self.resolve_promise_if_messagehash_matches(client, 'multipleOrders::', symbol, orders)
556
615
  elif (type == 'received') or (type == 'done'):
557
616
  info = self.extend(previousOrder['info'], message)
558
617
  order = self.parse_ws_order(info)
@@ -565,6 +624,7 @@ class coinbasepro(ccxt.async_support.coinbasepro):
565
624
  # update the newUpdates count
566
625
  orders.append(previousOrder)
567
626
  client.resolve(orders, messageHash)
627
+ self.resolve_promise_if_messagehash_matches(client, 'multipleOrders::', symbol, orders)
568
628
 
569
629
  def parse_ws_order(self, order, market=None):
570
630
  id = self.safe_string(order, 'order_id')
@@ -588,10 +648,7 @@ class coinbasepro(ccxt.async_support.coinbasepro):
588
648
  filled = 0
589
649
  if amount is not None:
590
650
  remaining = amount - filled
591
- cost = None
592
- if (price is not None) and (amount is not None):
593
- cost = price * amount
594
- return {
651
+ return self.safe_order({
595
652
  'info': order,
596
653
  'symbol': symbol,
597
654
  'id': id,
@@ -607,14 +664,14 @@ class coinbasepro(ccxt.async_support.coinbasepro):
607
664
  'stopPrice': None,
608
665
  'triggerPrice': None,
609
666
  'amount': amount,
610
- 'cost': cost,
667
+ 'cost': None,
611
668
  'average': None,
612
669
  'filled': filled,
613
670
  'remaining': remaining,
614
671
  'status': status,
615
672
  'fee': None,
616
673
  'trades': None,
617
- }
674
+ })
618
675
 
619
676
  def handle_ticker(self, client: Client, message):
620
677
  #
ccxt/pro/okx.py CHANGED
@@ -978,8 +978,8 @@ class okx(ccxt.async_support.okx):
978
978
  # filter orders with no last trade id
979
979
  for i in range(0, len(rawOrders)):
980
980
  rawOrder = rawOrders[i]
981
- tradeId = self.safe_string(rawOrder, 'tradeId')
982
- if not self.is_empty(tradeId):
981
+ tradeId = self.safe_string(rawOrder, 'tradeId', '')
982
+ if len(tradeId) > 0:
983
983
  order = self.parse_order(rawOrder)
984
984
  filteredOrders.append(order)
985
985
  tradesLength = len(filteredOrders)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ccxt
3
- Version: 4.0.112
3
+ Version: 4.1.2
4
4
  Summary: A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 130+ exchanges
5
5
  Home-page: https://ccxt.com
6
6
  Author: Igor Kroitor
@@ -258,13 +258,13 @@ console.log(version, Object.keys(exchanges));
258
258
 
259
259
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
260
260
 
261
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.0.112/dist/ccxt.browser.js
262
- * unpkg: https://unpkg.com/ccxt@4.0.112/dist/ccxt.browser.js
261
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.1.2/dist/ccxt.browser.js
262
+ * unpkg: https://unpkg.com/ccxt@4.1.2/dist/ccxt.browser.js
263
263
 
264
264
  CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
265
265
 
266
266
  ```HTML
267
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.0.112/dist/ccxt.browser.js"></script>
267
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.1.2/dist/ccxt.browser.js"></script>
268
268
  ```
269
269
 
270
270
  Creates a global `ccxt` object: