ccxt 4.1.1__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/binance.py CHANGED
@@ -3200,6 +3200,14 @@ class binance(Exchange, ImplicitAPI):
3200
3200
  def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Optional[int] = None, limit: Optional[int] = None, params={}):
3201
3201
  """
3202
3202
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
3203
+ see https://binance-docs.github.io/apidocs/spot/en/#kline-candlestick-data
3204
+ see https://binance-docs.github.io/apidocs/voptions/en/#kline-candlestick-data
3205
+ see https://binance-docs.github.io/apidocs/futures/en/#index-price-kline-candlestick-data
3206
+ see https://binance-docs.github.io/apidocs/futures/en/#mark-price-kline-candlestick-data
3207
+ see https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-data
3208
+ see https://binance-docs.github.io/apidocs/delivery/en/#index-price-kline-candlestick-data
3209
+ see https://binance-docs.github.io/apidocs/delivery/en/#mark-price-kline-candlestick-data
3210
+ see https://binance-docs.github.io/apidocs/delivery/en/#kline-candlestick-data
3203
3211
  :param str symbol: unified symbol of the market to fetch OHLCV data for
3204
3212
  :param str timeframe: the length of time each candle represents
3205
3213
  :param int [since]: timestamp in ms of the earliest candle to fetch
@@ -4359,6 +4367,11 @@ class binance(Exchange, ImplicitAPI):
4359
4367
  def fetch_order(self, id: str, symbol: Optional[str] = None, params={}):
4360
4368
  """
4361
4369
  fetches information on an order made by the user
4370
+ see https://binance-docs.github.io/apidocs/spot/en/#query-order-user_data
4371
+ see https://binance-docs.github.io/apidocs/futures/en/#query-order-user_data
4372
+ see https://binance-docs.github.io/apidocs/delivery/en/#query-order-user_data
4373
+ see https://binance-docs.github.io/apidocs/voptions/en/#query-single-order-trade
4374
+ see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-order-user_data
4362
4375
  :param str symbol: unified symbol of the market the order was made in
4363
4376
  :param dict [params]: extra parameters specific to the binance api endpoint
4364
4377
  :param str [params.marginMode]: 'cross' or 'isolated', for spot margin trading
@@ -4399,6 +4412,11 @@ class binance(Exchange, ImplicitAPI):
4399
4412
  def fetch_orders(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
4400
4413
  """
4401
4414
  fetches information on multiple orders made by the user
4415
+ see https://binance-docs.github.io/apidocs/spot/en/#all-orders-user_data
4416
+ see https://binance-docs.github.io/apidocs/futures/en/#all-orders-user_data
4417
+ see https://binance-docs.github.io/apidocs/delivery/en/#all-orders-user_data
4418
+ see https://binance-docs.github.io/apidocs/voptions/en/#query-option-order-history-trade
4419
+ see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-all-orders-user_data
4402
4420
  :param str symbol: unified market symbol of the market orders were made in
4403
4421
  :param int [since]: the earliest time in ms to fetch orders for
4404
4422
  :param int [limit]: the maximum number of order structures to retrieve
@@ -4510,6 +4528,11 @@ class binance(Exchange, ImplicitAPI):
4510
4528
  def fetch_open_orders(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
4511
4529
  """
4512
4530
  fetch all unfilled currently open orders
4531
+ see https://binance-docs.github.io/apidocs/spot/en/#current-open-orders-user_data
4532
+ see https://binance-docs.github.io/apidocs/futures/en/#current-all-open-orders-user_data
4533
+ see https://binance-docs.github.io/apidocs/delivery/en/#current-all-open-orders-user_data
4534
+ see https://binance-docs.github.io/apidocs/voptions/en/#query-current-open-option-orders-user_data
4535
+ see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-open-orders-user_data
4513
4536
  :param str symbol: unified market symbol
4514
4537
  :param int [since]: the earliest time in ms to fetch open orders for
4515
4538
  :param int [limit]: the maximum number of open orders structures to retrieve
@@ -4564,6 +4587,11 @@ class binance(Exchange, ImplicitAPI):
4564
4587
  def fetch_closed_orders(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
4565
4588
  """
4566
4589
  fetches information on multiple closed orders made by the user
4590
+ see https://binance-docs.github.io/apidocs/spot/en/#all-orders-user_data
4591
+ see https://binance-docs.github.io/apidocs/futures/en/#all-orders-user_data
4592
+ see https://binance-docs.github.io/apidocs/delivery/en/#all-orders-user_data
4593
+ see https://binance-docs.github.io/apidocs/voptions/en/#query-option-order-history-trade
4594
+ see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-all-orders-user_data
4567
4595
  :param str symbol: unified market symbol of the market orders were made in
4568
4596
  :param int [since]: the earliest time in ms to fetch orders for
4569
4597
  :param int [limit]: the maximum number of order structures to retrieve
@@ -4598,6 +4626,11 @@ class binance(Exchange, ImplicitAPI):
4598
4626
  def cancel_order(self, id: str, symbol: Optional[str] = None, params={}):
4599
4627
  """
4600
4628
  cancels an open order
4629
+ see https://binance-docs.github.io/apidocs/spot/en/#cancel-order-trade
4630
+ see https://binance-docs.github.io/apidocs/futures/en/#cancel-order-trade
4631
+ see https://binance-docs.github.io/apidocs/delivery/en/#cancel-order-trade
4632
+ see https://binance-docs.github.io/apidocs/voptions/en/#cancel-option-order-trade
4633
+ see https://binance-docs.github.io/apidocs/spot/en/#margin-account-cancel-order-trade
4601
4634
  :param str id: order id
4602
4635
  :param str symbol: unified symbol of the market the order was made in
4603
4636
  :param dict [params]: extra parameters specific to the binance api endpoint
@@ -4680,6 +4713,7 @@ class binance(Exchange, ImplicitAPI):
4680
4713
  """
4681
4714
  cancel multiple orders
4682
4715
  see https://binance-docs.github.io/apidocs/futures/en/#cancel-multiple-orders-trade
4716
+ see https://binance-docs.github.io/apidocs/delivery/en/#cancel-multiple-orders-trade
4683
4717
  :param [str] ids: order ids
4684
4718
  :param str [symbol]: unified market symbol
4685
4719
  :param dict [params]: extra parameters specific to the bingx api endpoint
@@ -4743,6 +4777,10 @@ class binance(Exchange, ImplicitAPI):
4743
4777
  def fetch_order_trades(self, id: str, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
4744
4778
  """
4745
4779
  fetch all the trades made from a single order
4780
+ see https://binance-docs.github.io/apidocs/spot/en/#account-trade-list-user_data
4781
+ see https://binance-docs.github.io/apidocs/futures/en/#account-trade-list-user_data
4782
+ see https://binance-docs.github.io/apidocs/delivery/en/#account-trade-list-user_data
4783
+ see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-trade-list-user_data
4746
4784
  :param str id: order id
4747
4785
  :param str symbol: unified market symbol
4748
4786
  :param int [since]: the earliest time in ms to fetch trades for
@@ -4766,6 +4804,10 @@ class binance(Exchange, ImplicitAPI):
4766
4804
  def fetch_my_trades(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
4767
4805
  """
4768
4806
  fetch all trades made by the user
4807
+ see https://binance-docs.github.io/apidocs/spot/en/#account-trade-list-user_data
4808
+ see https://binance-docs.github.io/apidocs/futures/en/#account-trade-list-user_data
4809
+ see https://binance-docs.github.io/apidocs/delivery/en/#account-trade-list-user_data
4810
+ see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-trade-list-user_data
4769
4811
  :param str symbol: unified market symbol
4770
4812
  :param int [since]: the earliest time in ms to fetch trades for
4771
4813
  :param int [limit]: the maximum number of trades structures to retrieve
@@ -4889,6 +4931,7 @@ class binance(Exchange, ImplicitAPI):
4889
4931
  def fetch_my_dust_trades(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
4890
4932
  """
4891
4933
  fetch all dust trades made by the user
4934
+ see https://binance-docs.github.io/apidocs/spot/en/#dustlog-user_data
4892
4935
  :param str symbol: not used by binance fetchMyDustTrades()
4893
4936
  :param int [since]: the earliest time in ms to fetch my dust trades for
4894
4937
  :param int [limit]: the maximum number of dust trades to retrieve
@@ -5017,6 +5060,8 @@ class binance(Exchange, ImplicitAPI):
5017
5060
  def fetch_deposits(self, code: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
5018
5061
  """
5019
5062
  fetch all deposits made to an account
5063
+ see https://binance-docs.github.io/apidocs/spot/en/#get-fiat-deposit-withdraw-history-user_data
5064
+ see https://binance-docs.github.io/apidocs/spot/en/#deposit-history-supporting-network-user_data
5020
5065
  :param str code: unified currency code
5021
5066
  :param int [since]: the earliest time in ms to fetch deposits for
5022
5067
  :param int [limit]: the maximum number of deposits structures to retrieve
@@ -5109,6 +5154,8 @@ class binance(Exchange, ImplicitAPI):
5109
5154
  def fetch_withdrawals(self, code: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
5110
5155
  """
5111
5156
  fetch all withdrawals made from an account
5157
+ see https://binance-docs.github.io/apidocs/spot/en/#get-fiat-deposit-withdraw-history-user_data
5158
+ see https://binance-docs.github.io/apidocs/spot/en/#withdraw-history-supporting-network-user_data
5112
5159
  :param str code: unified currency code
5113
5160
  :param int [since]: the earliest time in ms to fetch withdrawals for
5114
5161
  :param int [limit]: the maximum number of withdrawals structures to retrieve
@@ -5536,6 +5583,7 @@ class binance(Exchange, ImplicitAPI):
5536
5583
  def fetch_transfers(self, code: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
5537
5584
  """
5538
5585
  fetch a history of internal transfers made on an account
5586
+ see https://binance-docs.github.io/apidocs/spot/en/#query-user-universal-transfer-history-user_data
5539
5587
  :param str code: unified currency code of the currency transferred
5540
5588
  :param int [since]: the earliest time in ms to fetch transfers for
5541
5589
  :param int [limit]: the maximum number of transfers structures to retrieve
@@ -5591,6 +5639,7 @@ class binance(Exchange, ImplicitAPI):
5591
5639
  def fetch_deposit_address(self, code: str, params={}):
5592
5640
  """
5593
5641
  fetch the deposit address for a currency associated with self account
5642
+ see https://binance-docs.github.io/apidocs/spot/en/#deposit-address-supporting-network-user_data
5594
5643
  :param str code: unified currency code
5595
5644
  :param dict [params]: extra parameters specific to the binance api endpoint
5596
5645
  :returns dict: an `address structure <https://github.com/ccxt/ccxt/wiki/Manual#address-structure>`
@@ -5658,6 +5707,7 @@ class binance(Exchange, ImplicitAPI):
5658
5707
  """
5659
5708
  * @deprecated
5660
5709
  please use fetchDepositWithdrawFees instead
5710
+ see https://binance-docs.github.io/apidocs/spot/en/#all-coins-39-information-user_data
5661
5711
  :param str[]|None codes: not used by binance fetchTransactionFees()
5662
5712
  :param dict [params]: extra parameters specific to the binance api endpoint
5663
5713
  :returns dict[]: a list of `fee structures <https://github.com/ccxt/ccxt/wiki/Manual#fee-structure>`
@@ -5767,6 +5817,7 @@ class binance(Exchange, ImplicitAPI):
5767
5817
  def fetch_deposit_withdraw_fees(self, codes: Optional[List[str]] = None, params={}):
5768
5818
  """
5769
5819
  fetch deposit and withdraw fees
5820
+ see https://binance-docs.github.io/apidocs/spot/en/#all-coins-39-information-user_data
5770
5821
  :param str[]|None codes: not used by binance fetchDepositWithdrawFees()
5771
5822
  :param dict [params]: extra parameters specific to the binance api endpoint
5772
5823
  :returns dict[]: a list of `fee structures <https://github.com/ccxt/ccxt/wiki/Manual#fee-structure>`
@@ -5886,6 +5937,7 @@ class binance(Exchange, ImplicitAPI):
5886
5937
  def withdraw(self, code: str, amount, address, tag=None, params={}):
5887
5938
  """
5888
5939
  make a withdrawal
5940
+ see https://binance-docs.github.io/apidocs/spot/en/#withdraw-user_data
5889
5941
  :param str code: unified currency code
5890
5942
  :param float amount: the amount to withdraw
5891
5943
  :param str address: the address to withdraw to
@@ -5937,6 +5989,7 @@ class binance(Exchange, ImplicitAPI):
5937
5989
  def fetch_trading_fee(self, symbol: str, params={}):
5938
5990
  """
5939
5991
  fetch the trading fees for a market
5992
+ see https://binance-docs.github.io/apidocs/spot/en/#trade-fee-user_data
5940
5993
  :param str symbol: unified market symbol
5941
5994
  :param dict [params]: extra parameters specific to the binance api endpoint
5942
5995
  :returns dict: a `fee structure <https://github.com/ccxt/ccxt/wiki/Manual#fee-structure>`
@@ -5962,6 +6015,9 @@ class binance(Exchange, ImplicitAPI):
5962
6015
  def fetch_trading_fees(self, params={}):
5963
6016
  """
5964
6017
  fetch the trading fees for multiple markets
6018
+ see https://binance-docs.github.io/apidocs/spot/en/#trade-fee-user_data
6019
+ see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
6020
+ see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
5965
6021
  :param dict [params]: extra parameters specific to the binance api endpoint
5966
6022
  :returns dict: a dictionary of `fee structures <https://github.com/ccxt/ccxt/wiki/Manual#fee-structure>` indexed by market symbols
5967
6023
  """
@@ -6126,6 +6182,7 @@ class binance(Exchange, ImplicitAPI):
6126
6182
  def futures_transfer(self, code: str, amount, type, params={}):
6127
6183
  """
6128
6184
  transfer between futures account
6185
+ see https://binance-docs.github.io/apidocs/spot/en/#new-future-account-transfer-user_data
6129
6186
  :param str code: unified currency code
6130
6187
  :param float amount: the amount to transfer
6131
6188
  :param str type: 1 - transfer from spot account to USDT-Ⓜ futures account, 2 - transfer from USDT-Ⓜ futures account to spot account, 3 - transfer from spot account to COIN-Ⓜ futures account, 4 - transfer from COIN-Ⓜ futures account to spot account
@@ -6153,6 +6210,8 @@ class binance(Exchange, ImplicitAPI):
6153
6210
  def fetch_funding_rate(self, symbol: str, params={}):
6154
6211
  """
6155
6212
  fetch the current funding rate
6213
+ see https://binance-docs.github.io/apidocs/futures/en/#mark-price
6214
+ see https://binance-docs.github.io/apidocs/delivery/en/#index-price-and-mark-price
6156
6215
  :param str symbol: unified market symbol
6157
6216
  :param dict [params]: extra parameters specific to the binance api endpoint
6158
6217
  :returns dict: a `funding rate structure <https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-structure>`
@@ -6189,6 +6248,8 @@ class binance(Exchange, ImplicitAPI):
6189
6248
  def fetch_funding_rate_history(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
6190
6249
  """
6191
6250
  fetches historical funding rate prices
6251
+ see https://binance-docs.github.io/apidocs/futures/en/#get-funding-rate-history
6252
+ see https://binance-docs.github.io/apidocs/delivery/en/#get-funding-rate-history-of-perpetual-futures
6192
6253
  :param str symbol: unified symbol of the market to fetch the funding rate history for
6193
6254
  :param int [since]: timestamp in ms of the earliest funding rate to fetch
6194
6255
  :param int [limit]: the maximum amount of `funding rate structures <https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure>` to fetch
@@ -6249,6 +6310,8 @@ class binance(Exchange, ImplicitAPI):
6249
6310
  def fetch_funding_rates(self, symbols: Optional[List[str]] = None, params={}):
6250
6311
  """
6251
6312
  fetch the funding rate for multiple markets
6313
+ see https://binance-docs.github.io/apidocs/futures/en/#mark-price
6314
+ see https://binance-docs.github.io/apidocs/delivery/en/#index-price-and-mark-price
6252
6315
  :param str[]|None symbols: list of unified market symbols
6253
6316
  :param dict [params]: extra parameters specific to the binance api endpoint
6254
6317
  :returns dict: a dictionary of `funding rates structures <https://github.com/ccxt/ccxt/wiki/Manual#funding-rates-structure>`, indexe by market symbols
@@ -6729,6 +6792,8 @@ class binance(Exchange, ImplicitAPI):
6729
6792
  def fetch_leverage_tiers(self, symbols: Optional[List[str]] = None, params={}):
6730
6793
  """
6731
6794
  retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
6795
+ see https://binance-docs.github.io/apidocs/futures/en/#notional-and-leverage-brackets-user_data
6796
+ see https://binance-docs.github.io/apidocs/delivery/en/#notional-bracket-for-symbol-user_data
6732
6797
  :param str[]|None symbols: list of unified market symbols
6733
6798
  :param dict [params]: extra parameters specific to the binance api endpoint
6734
6799
  :returns dict: a dictionary of `leverage tiers structures <https://github.com/ccxt/ccxt/wiki/Manual#leverage-tiers-structure>`, indexed by market symbols
@@ -6993,6 +7058,8 @@ class binance(Exchange, ImplicitAPI):
6993
7058
  def fetch_account_positions(self, symbols: Optional[List[str]] = None, params={}):
6994
7059
  """
6995
7060
  fetch account positions
7061
+ see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
7062
+ see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
6996
7063
  :param str[]|None symbols: list of unified market symbols
6997
7064
  :param dict [params]: extra parameters specific to the binance api endpoint
6998
7065
  :returns dict: data on account positions
@@ -7023,6 +7090,7 @@ class binance(Exchange, ImplicitAPI):
7023
7090
  """
7024
7091
  fetch positions risk
7025
7092
  see https://binance-docs.github.io/apidocs/futures/en/#position-information-v2-user_data
7093
+ see https://binance-docs.github.io/apidocs/delivery/en/#position-information-user_data
7026
7094
  :param str[]|None symbols: list of unified market symbols
7027
7095
  :param dict [params]: extra parameters specific to the binance api endpoint
7028
7096
  :returns dict: data on the positions risk
@@ -7111,6 +7179,8 @@ class binance(Exchange, ImplicitAPI):
7111
7179
  def fetch_funding_history(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
7112
7180
  """
7113
7181
  fetch the history of funding payments paid and received on self account
7182
+ see https://binance-docs.github.io/apidocs/futures/en/#get-income-history-user_data
7183
+ see https://binance-docs.github.io/apidocs/delivery/en/#get-income-history-user_data
7114
7184
  :param str symbol: unified market symbol
7115
7185
  :param int [since]: the earliest time in ms to fetch funding history for
7116
7186
  :param int [limit]: the maximum number of funding history structures to retrieve
@@ -7149,6 +7219,8 @@ class binance(Exchange, ImplicitAPI):
7149
7219
  def set_leverage(self, leverage, symbol: Optional[str] = None, params={}):
7150
7220
  """
7151
7221
  set the level of leverage for a market
7222
+ see https://binance-docs.github.io/apidocs/futures/en/#change-initial-leverage-trade
7223
+ see https://binance-docs.github.io/apidocs/delivery/en/#change-initial-leverage-trade
7152
7224
  :param float leverage: the rate of leverage
7153
7225
  :param str symbol: unified market symbol
7154
7226
  :param dict [params]: extra parameters specific to the binance api endpoint
@@ -7178,6 +7250,8 @@ class binance(Exchange, ImplicitAPI):
7178
7250
  def set_margin_mode(self, marginMode: str, symbol: Optional[str] = None, params={}):
7179
7251
  """
7180
7252
  set margin mode to 'cross' or 'isolated'
7253
+ see https://binance-docs.github.io/apidocs/futures/en/#change-margin-type-trade
7254
+ see https://binance-docs.github.io/apidocs/delivery/en/#change-margin-type-trade
7181
7255
  :param str marginMode: 'cross' or 'isolated'
7182
7256
  :param str symbol: unified market symbol
7183
7257
  :param dict [params]: extra parameters specific to the binance api endpoint
@@ -7232,6 +7306,8 @@ class binance(Exchange, ImplicitAPI):
7232
7306
  def set_position_mode(self, hedged, symbol: Optional[str] = None, params={}):
7233
7307
  """
7234
7308
  set hedged to True or False for a market
7309
+ see https://binance-docs.github.io/apidocs/futures/en/#change-position-mode-trade
7310
+ see https://binance-docs.github.io/apidocs/delivery/en/#change-position-mode-trade
7235
7311
  :param bool hedged: set to True to use dualSidePosition
7236
7312
  :param str symbol: not used by binance setPositionMode()
7237
7313
  :param dict [params]: extra parameters specific to the binance api endpoint
@@ -7829,6 +7905,7 @@ class binance(Exchange, ImplicitAPI):
7829
7905
  def fetch_borrow_rate(self, code: str, params={}):
7830
7906
  """
7831
7907
  fetch the rate of interest to borrow a currency for margin trading
7908
+ see https://binance-docs.github.io/apidocs/spot/en/#query-margin-interest-rate-history-user_data
7832
7909
  :param str code: unified currency code
7833
7910
  :param dict [params]: extra parameters specific to the binance api endpoint
7834
7911
  :returns dict: a `borrow rate structure <https://github.com/ccxt/ccxt/wiki/Manual#borrow-rate-structure>`
@@ -7856,6 +7933,7 @@ class binance(Exchange, ImplicitAPI):
7856
7933
  def fetch_borrow_rate_history(self, code: str, since: Optional[int] = None, limit: Optional[int] = None, params={}):
7857
7934
  """
7858
7935
  retrieves a history of a currencies borrow interest rate at specific time slots
7936
+ see https://binance-docs.github.io/apidocs/spot/en/#query-margin-interest-rate-history-user_data
7859
7937
  :param str code: unified currency code
7860
7938
  :param int [since]: timestamp for the earliest borrow rate
7861
7939
  :param int [limit]: the maximum number of `borrow rate structures <https://github.com/ccxt/ccxt/wiki/Manual#borrow-rate-structure>` to retrieve
@@ -7923,6 +8001,7 @@ class binance(Exchange, ImplicitAPI):
7923
8001
  def create_gift_code(self, code: str, amount, params={}):
7924
8002
  """
7925
8003
  create gift code
8004
+ see https://binance-docs.github.io/apidocs/spot/en/#create-a-single-token-gift-card-user_data
7926
8005
  :param str code: gift code
7927
8006
  :param float amount: amount of currency for the gift
7928
8007
  :param dict [params]: extra parameters specific to the binance api endpoint
@@ -7958,6 +8037,7 @@ class binance(Exchange, ImplicitAPI):
7958
8037
  def redeem_gift_code(self, giftcardCode, params={}):
7959
8038
  """
7960
8039
  redeem gift code
8040
+ see https://binance-docs.github.io/apidocs/spot/en/#redeem-a-binance-gift-card-user_data
7961
8041
  :param str giftcardCode:
7962
8042
  :param dict [params]: extra parameters specific to the binance api endpoint
7963
8043
  :returns dict: response from the exchange
@@ -7982,6 +8062,7 @@ class binance(Exchange, ImplicitAPI):
7982
8062
  def verify_gift_code(self, id: str, params={}):
7983
8063
  """
7984
8064
  verify gift code
8065
+ see https://binance-docs.github.io/apidocs/spot/en/#verify-binance-gift-card-by-gift-card-number-user_data
7985
8066
  :param str id: reference number id
7986
8067
  :param dict [params]: extra parameters specific to the binance api endpoint
7987
8068
  :returns dict: response from the exchange
@@ -8003,6 +8084,7 @@ class binance(Exchange, ImplicitAPI):
8003
8084
  def fetch_borrow_interest(self, code: Optional[str] = None, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
8004
8085
  """
8005
8086
  fetch the interest owed by the user for borrowing currency for margin trading
8087
+ see https://binance-docs.github.io/apidocs/spot/en/#get-interest-history-user_data
8006
8088
  :param str code: unified currency code
8007
8089
  :param str symbol: unified market symbol when fetch interest in isolated markets
8008
8090
  :param int [since]: the earliest time in ms to fetch borrrow interest for
@@ -8143,6 +8225,8 @@ class binance(Exchange, ImplicitAPI):
8143
8225
  def fetch_open_interest_history(self, symbol: str, timeframe='5m', since: Optional[int] = None, limit: Optional[int] = None, params={}):
8144
8226
  """
8145
8227
  Retrieves the open interest history of a currency
8228
+ see https://binance-docs.github.io/apidocs/delivery/en/#open-interest-statistics
8229
+ see https://binance-docs.github.io/apidocs/futures/en/#open-interest-statistics
8146
8230
  :param str symbol: Unified CCXT market symbol
8147
8231
  :param str timeframe: "5m","15m","30m","1h","2h","4h","6h","12h", or "1d"
8148
8232
  :param int [since]: the time(ms) of the earliest record to retrieve unix timestamp
ccxt/bitrue.py CHANGED
@@ -827,7 +827,7 @@ class bitrue(Exchange, ImplicitAPI):
827
827
  'last': last,
828
828
  'previousClose': None,
829
829
  'change': None,
830
- 'percentage': self.safe_string(ticker, 'percentChange'),
830
+ 'percentage': Precise.string_mul(self.safe_string(ticker, 'percentChange'), '10000'),
831
831
  'average': None,
832
832
  'baseVolume': self.safe_string(ticker, 'baseVolume'),
833
833
  'quoteVolume': self.safe_string(ticker, 'quoteVolume'),
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/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.1.1'
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
  #