ccxt 4.4.4__py2.py3-none-any.whl → 4.4.6__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/__init__.py CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  # ----------------------------------------------------------------------------
24
24
 
25
- __version__ = '4.4.4'
25
+ __version__ = '4.4.6'
26
26
 
27
27
  # ----------------------------------------------------------------------------
28
28
 
@@ -4,7 +4,7 @@ from ccxt.base.types import Entry
4
4
  class ImplicitAPI:
5
5
  sapi_get_copytrading_futures_userstatus = sapiGetCopyTradingFuturesUserStatus = Entry('copyTrading/futures/userStatus', 'sapi', 'GET', {'cost': 2})
6
6
  sapi_get_copytrading_futures_leadsymbol = sapiGetCopyTradingFuturesLeadSymbol = Entry('copyTrading/futures/leadSymbol', 'sapi', 'GET', {'cost': 2})
7
- sapi_get_system_status = sapiGetSystemStatus = Entry('system/status', 'sapi', 'GET', {'cost': 0.1})
7
+ sapi_get_system_status = sapiGetSystemStatus = Entry('system/status', 'sapi', 'GET', {'cost': 1})
8
8
  sapi_get_accountsnapshot = sapiGetAccountSnapshot = Entry('accountSnapshot', 'sapi', 'GET', {'cost': 240})
9
9
  sapi_get_account_info = sapiGetAccountInfo = Entry('account/info', 'sapi', 'GET', {'cost': 0.1})
10
10
  sapi_get_margin_asset = sapiGetMarginAsset = Entry('margin/asset', 'sapi', 'GET', {'cost': 1})
@@ -86,10 +86,10 @@ class ImplicitAPI:
86
86
  sapi_get_capital_config_getall = sapiGetCapitalConfigGetall = Entry('capital/config/getall', 'sapi', 'GET', {'cost': 1})
87
87
  sapi_get_capital_deposit_address = sapiGetCapitalDepositAddress = Entry('capital/deposit/address', 'sapi', 'GET', {'cost': 1})
88
88
  sapi_get_capital_deposit_address_list = sapiGetCapitalDepositAddressList = Entry('capital/deposit/address/list', 'sapi', 'GET', {'cost': 1})
89
- sapi_get_capital_deposit_hisrec = sapiGetCapitalDepositHisrec = Entry('capital/deposit/hisrec', 'sapi', 'GET', {'cost': 0.1})
89
+ sapi_get_capital_deposit_hisrec = sapiGetCapitalDepositHisrec = Entry('capital/deposit/hisrec', 'sapi', 'GET', {'cost': 1})
90
90
  sapi_get_capital_deposit_subaddress = sapiGetCapitalDepositSubAddress = Entry('capital/deposit/subAddress', 'sapi', 'GET', {'cost': 0.1})
91
91
  sapi_get_capital_deposit_subhisrec = sapiGetCapitalDepositSubHisrec = Entry('capital/deposit/subHisrec', 'sapi', 'GET', {'cost': 0.1})
92
- sapi_get_capital_withdraw_history = sapiGetCapitalWithdrawHistory = Entry('capital/withdraw/history', 'sapi', 'GET', {'cost': 2})
92
+ sapi_get_capital_withdraw_history = sapiGetCapitalWithdrawHistory = Entry('capital/withdraw/history', 'sapi', 'GET', {'cost': 1})
93
93
  sapi_get_capital_withdraw_address_list = sapiGetCapitalWithdrawAddressList = Entry('capital/withdraw/address/list', 'sapi', 'GET', {'cost': 10})
94
94
  sapi_get_capital_contract_convertible_coins = sapiGetCapitalContractConvertibleCoins = Entry('capital/contract/convertible-coins', 'sapi', 'GET', {'cost': 4.0002})
95
95
  sapi_get_convert_tradeflow = sapiGetConvertTradeFlow = Entry('convert/tradeFlow', 'sapi', 'GET', {'cost': 20.001})
@@ -108,7 +108,7 @@ class ImplicitAPI:
108
108
  sapi_get_sub_account_list = sapiGetSubAccountList = Entry('sub-account/list', 'sapi', 'GET', {'cost': 0.1})
109
109
  sapi_get_sub_account_margin_account = sapiGetSubAccountMarginAccount = Entry('sub-account/margin/account', 'sapi', 'GET', {'cost': 1})
110
110
  sapi_get_sub_account_margin_accountsummary = sapiGetSubAccountMarginAccountSummary = Entry('sub-account/margin/accountSummary', 'sapi', 'GET', {'cost': 1})
111
- sapi_get_sub_account_spotsummary = sapiGetSubAccountSpotSummary = Entry('sub-account/spotSummary', 'sapi', 'GET', {'cost': 0.1})
111
+ sapi_get_sub_account_spotsummary = sapiGetSubAccountSpotSummary = Entry('sub-account/spotSummary', 'sapi', 'GET', {'cost': 1})
112
112
  sapi_get_sub_account_status = sapiGetSubAccountStatus = Entry('sub-account/status', 'sapi', 'GET', {'cost': 1})
113
113
  sapi_get_sub_account_sub_transfer_history = sapiGetSubAccountSubTransferHistory = Entry('sub-account/sub/transfer/history', 'sapi', 'GET', {'cost': 0.1})
114
114
  sapi_get_sub_account_transfer_subuserhistory = sapiGetSubAccountTransferSubUserHistory = Entry('sub-account/transfer/subUserHistory', 'sapi', 'GET', {'cost': 0.1})
@@ -280,14 +280,14 @@ class ImplicitAPI:
280
280
  sapi_get_cl_transferhistory = sapiGetClTransferHistory = Entry('cl/transferHistory', 'sapi', 'GET', {'cost': 1})
281
281
  sapi_get_apipartner_checkeligibility = sapiGetApipartnerCheckEligibility = Entry('apipartner/checkEligibility', 'sapi', 'GET', {'cost': 1})
282
282
  sapi_get_apipartner_rebatehistory = sapiGetApipartnerRebateHistory = Entry('apipartner/rebateHistory', 'sapi', 'GET', {'cost': 1})
283
- sapi_post_asset_dust = sapiPostAssetDust = Entry('asset/dust', 'sapi', 'POST', {'cost': 0.06667})
283
+ sapi_post_asset_dust = sapiPostAssetDust = Entry('asset/dust', 'sapi', 'POST', {'cost': 10})
284
284
  sapi_post_asset_dust_btc = sapiPostAssetDustBtc = Entry('asset/dust-btc', 'sapi', 'POST', {'cost': 0.1})
285
285
  sapi_post_asset_transfer = sapiPostAssetTransfer = Entry('asset/transfer', 'sapi', 'POST', {'cost': 6.0003})
286
286
  sapi_post_asset_get_funding_asset = sapiPostAssetGetFundingAsset = Entry('asset/get-funding-asset', 'sapi', 'POST', {'cost': 0.1})
287
287
  sapi_post_asset_convert_transfer = sapiPostAssetConvertTransfer = Entry('asset/convert-transfer', 'sapi', 'POST', {'cost': 0.033335})
288
288
  sapi_post_account_disablefastwithdrawswitch = sapiPostAccountDisableFastWithdrawSwitch = Entry('account/disableFastWithdrawSwitch', 'sapi', 'POST', {'cost': 0.1})
289
289
  sapi_post_account_enablefastwithdrawswitch = sapiPostAccountEnableFastWithdrawSwitch = Entry('account/enableFastWithdrawSwitch', 'sapi', 'POST', {'cost': 0.1})
290
- sapi_post_capital_withdraw_apply = sapiPostCapitalWithdrawApply = Entry('capital/withdraw/apply', 'sapi', 'POST', {'cost': 4.0002})
290
+ sapi_post_capital_withdraw_apply = sapiPostCapitalWithdrawApply = Entry('capital/withdraw/apply', 'sapi', 'POST', {'cost': 1})
291
291
  sapi_post_capital_contract_convertible_coins = sapiPostCapitalContractConvertibleCoins = Entry('capital/contract/convertible-coins', 'sapi', 'POST', {'cost': 4.0002})
292
292
  sapi_post_capital_deposit_credit_apply = sapiPostCapitalDepositCreditApply = Entry('capital/deposit/credit-apply', 'sapi', 'POST', {'cost': 0.1})
293
293
  sapi_post_margin_borrow_repay = sapiPostMarginBorrowRepay = Entry('margin/borrow-repay', 'sapi', 'POST', {'cost': 20.001})
@@ -439,7 +439,7 @@ class ImplicitAPI:
439
439
  sapiv2_post_loan_flexible_borrow = sapiV2PostLoanFlexibleBorrow = Entry('loan/flexible/borrow', 'sapiV2', 'POST', {'cost': 40.002})
440
440
  sapiv2_post_loan_flexible_repay = sapiV2PostLoanFlexibleRepay = Entry('loan/flexible/repay', 'sapiV2', 'POST', {'cost': 40.002})
441
441
  sapiv2_post_loan_flexible_adjust_ltv = sapiV2PostLoanFlexibleAdjustLtv = Entry('loan/flexible/adjust/ltv', 'sapiV2', 'POST', {'cost': 40.002})
442
- sapiv3_get_sub_account_assets = sapiV3GetSubAccountAssets = Entry('sub-account/assets', 'sapiV3', 'GET', {'cost': 0.40002})
442
+ sapiv3_get_sub_account_assets = sapiV3GetSubAccountAssets = Entry('sub-account/assets', 'sapiV3', 'GET', {'cost': 1})
443
443
  sapiv3_get_accountstatus = sapiV3GetAccountStatus = Entry('accountStatus', 'sapiV3', 'GET', {'cost': 1})
444
444
  sapiv3_get_apitradingstatus = sapiV3GetApiTradingStatus = Entry('apiTradingStatus', 'sapiV3', 'GET', {'cost': 1})
445
445
  sapiv3_get_sub_account_list = sapiV3GetSubAccountList = Entry('sub-account/list', 'sapiV3', 'GET', {'cost': 1})
@@ -641,48 +641,48 @@ class ImplicitAPI:
641
641
  eapiprivate_delete_allopenorders = eapiPrivateDeleteAllOpenOrders = Entry('allOpenOrders', 'eapiPrivate', 'DELETE', {'cost': 1})
642
642
  eapiprivate_delete_allopenordersbyunderlying = eapiPrivateDeleteAllOpenOrdersByUnderlying = Entry('allOpenOrdersByUnderlying', 'eapiPrivate', 'DELETE', {'cost': 1})
643
643
  eapiprivate_delete_listenkey = eapiPrivateDeleteListenKey = Entry('listenKey', 'eapiPrivate', 'DELETE', {'cost': 1})
644
- public_get_ping = publicGetPing = Entry('ping', 'public', 'GET', {'cost': 0.2})
645
- public_get_time = publicGetTime = Entry('time', 'public', 'GET', {'cost': 0.2})
644
+ public_get_ping = publicGetPing = Entry('ping', 'public', 'GET', {'cost': 1})
645
+ public_get_time = publicGetTime = Entry('time', 'public', 'GET', {'cost': 1})
646
646
  public_get_depth = publicGetDepth = Entry('depth', 'public', 'GET', {'cost': 1, 'byLimit': [[100, 1], [500, 5], [1000, 10], [5000, 50]]})
647
- public_get_trades = publicGetTrades = Entry('trades', 'public', 'GET', {'cost': 2})
648
- public_get_aggtrades = publicGetAggTrades = Entry('aggTrades', 'public', 'GET', {'cost': 0.4})
649
- public_get_historicaltrades = publicGetHistoricalTrades = Entry('historicalTrades', 'public', 'GET', {'cost': 2})
650
- public_get_klines = publicGetKlines = Entry('klines', 'public', 'GET', {'cost': 0.4})
647
+ public_get_trades = publicGetTrades = Entry('trades', 'public', 'GET', {'cost': 1})
648
+ public_get_aggtrades = publicGetAggTrades = Entry('aggTrades', 'public', 'GET', {'cost': 1})
649
+ public_get_historicaltrades = publicGetHistoricalTrades = Entry('historicalTrades', 'public', 'GET', {'cost': 5})
650
+ public_get_klines = publicGetKlines = Entry('klines', 'public', 'GET', {'cost': 1})
651
651
  public_get_uiklines = publicGetUiKlines = Entry('uiKlines', 'public', 'GET', {'cost': 0.4})
652
- public_get_ticker_24hr = publicGetTicker24hr = Entry('ticker/24hr', 'public', 'GET', {'cost': 0.4, 'noSymbol': 16})
653
- public_get_ticker = publicGetTicker = Entry('ticker', 'public', 'GET', {'cost': 0.4, 'noSymbol': 16})
652
+ public_get_ticker_24hr = publicGetTicker24hr = Entry('ticker/24hr', 'public', 'GET', {'cost': 1, 'noSymbol': 40})
653
+ public_get_ticker = publicGetTicker = Entry('ticker', 'public', 'GET', {'cost': 2, 'noSymbol': 100})
654
654
  public_get_ticker_tradingday = publicGetTickerTradingDay = Entry('ticker/tradingDay', 'public', 'GET', {'cost': 0.8})
655
- public_get_ticker_price = publicGetTickerPrice = Entry('ticker/price', 'public', 'GET', {'cost': 0.4, 'noSymbol': 0.8})
656
- public_get_ticker_bookticker = publicGetTickerBookTicker = Entry('ticker/bookTicker', 'public', 'GET', {'cost': 0.4, 'noSymbol': 0.8})
657
- public_get_exchangeinfo = publicGetExchangeInfo = Entry('exchangeInfo', 'public', 'GET', {'cost': 4})
658
- public_get_avgprice = publicGetAvgPrice = Entry('avgPrice', 'public', 'GET', {'cost': 0.4})
655
+ public_get_ticker_price = publicGetTickerPrice = Entry('ticker/price', 'public', 'GET', {'cost': 1, 'noSymbol': 2})
656
+ public_get_ticker_bookticker = publicGetTickerBookTicker = Entry('ticker/bookTicker', 'public', 'GET', {'cost': 1, 'noSymbol': 2})
657
+ public_get_exchangeinfo = publicGetExchangeInfo = Entry('exchangeInfo', 'public', 'GET', {'cost': 10})
658
+ public_get_avgprice = publicGetAvgPrice = Entry('avgPrice', 'public', 'GET', {'cost': 1})
659
659
  public_put_userdatastream = publicPutUserDataStream = Entry('userDataStream', 'public', 'PUT', {'cost': 0.4})
660
660
  public_post_userdatastream = publicPostUserDataStream = Entry('userDataStream', 'public', 'POST', {'cost': 0.4})
661
661
  public_delete_userdatastream = publicDeleteUserDataStream = Entry('userDataStream', 'public', 'DELETE', {'cost': 0.4})
662
- private_get_allorderlist = privateGetAllOrderList = Entry('allOrderList', 'private', 'GET', {'cost': 4})
663
- private_get_openorderlist = privateGetOpenOrderList = Entry('openOrderList', 'private', 'GET', {'cost': 1.2})
664
- private_get_orderlist = privateGetOrderList = Entry('orderList', 'private', 'GET', {'cost': 0.8})
665
- private_get_order = privateGetOrder = Entry('order', 'private', 'GET', {'cost': 0.8})
666
- private_get_openorders = privateGetOpenOrders = Entry('openOrders', 'private', 'GET', {'cost': 1.2, 'noSymbol': 16})
667
- private_get_allorders = privateGetAllOrders = Entry('allOrders', 'private', 'GET', {'cost': 4})
668
- private_get_account = privateGetAccount = Entry('account', 'private', 'GET', {'cost': 4})
669
- private_get_mytrades = privateGetMyTrades = Entry('myTrades', 'private', 'GET', {'cost': 4})
670
- private_get_ratelimit_order = privateGetRateLimitOrder = Entry('rateLimit/order', 'private', 'GET', {'cost': 8})
671
- private_get_mypreventedmatches = privateGetMyPreventedMatches = Entry('myPreventedMatches', 'private', 'GET', {'cost': 4})
662
+ private_get_allorderlist = privateGetAllOrderList = Entry('allOrderList', 'private', 'GET', {'cost': 10})
663
+ private_get_openorderlist = privateGetOpenOrderList = Entry('openOrderList', 'private', 'GET', {'cost': 3})
664
+ private_get_orderlist = privateGetOrderList = Entry('orderList', 'private', 'GET', {'cost': 2})
665
+ private_get_order = privateGetOrder = Entry('order', 'private', 'GET', {'cost': 2})
666
+ private_get_openorders = privateGetOpenOrders = Entry('openOrders', 'private', 'GET', {'cost': 3, 'noSymbol': 40})
667
+ private_get_allorders = privateGetAllOrders = Entry('allOrders', 'private', 'GET', {'cost': 10})
668
+ private_get_account = privateGetAccount = Entry('account', 'private', 'GET', {'cost': 10})
669
+ private_get_mytrades = privateGetMyTrades = Entry('myTrades', 'private', 'GET', {'cost': 10})
670
+ private_get_ratelimit_order = privateGetRateLimitOrder = Entry('rateLimit/order', 'private', 'GET', {'cost': 20})
671
+ private_get_mypreventedmatches = privateGetMyPreventedMatches = Entry('myPreventedMatches', 'private', 'GET', {'cost': 10})
672
672
  private_get_myallocations = privateGetMyAllocations = Entry('myAllocations', 'private', 'GET', {'cost': 4})
673
673
  private_get_account_commission = privateGetAccountCommission = Entry('account/commission', 'private', 'GET', {'cost': 4})
674
- private_post_order_oco = privatePostOrderOco = Entry('order/oco', 'private', 'POST', {'cost': 0.2})
674
+ private_post_order_oco = privatePostOrderOco = Entry('order/oco', 'private', 'POST', {'cost': 1})
675
675
  private_post_orderlist_oco = privatePostOrderListOco = Entry('orderList/oco', 'private', 'POST', {'cost': 0.2})
676
676
  private_post_orderlist_oto = privatePostOrderListOto = Entry('orderList/oto', 'private', 'POST', {'cost': 0.2})
677
677
  private_post_orderlist_otoco = privatePostOrderListOtoco = Entry('orderList/otoco', 'private', 'POST', {'cost': 0.2})
678
678
  private_post_sor_order = privatePostSorOrder = Entry('sor/order', 'private', 'POST', {'cost': 0.2})
679
679
  private_post_sor_order_test = privatePostSorOrderTest = Entry('sor/order/test', 'private', 'POST', {'cost': 0.2})
680
- private_post_order = privatePostOrder = Entry('order', 'private', 'POST', {'cost': 0.2})
681
- private_post_order_cancelreplace = privatePostOrderCancelReplace = Entry('order/cancelReplace', 'private', 'POST', {'cost': 0.2})
682
- private_post_order_test = privatePostOrderTest = Entry('order/test', 'private', 'POST', {'cost': 0.2})
683
- private_delete_openorders = privateDeleteOpenOrders = Entry('openOrders', 'private', 'DELETE', {'cost': 0.2})
684
- private_delete_orderlist = privateDeleteOrderList = Entry('orderList', 'private', 'DELETE', {'cost': 0.2})
685
- private_delete_order = privateDeleteOrder = Entry('order', 'private', 'DELETE', {'cost': 0.2})
680
+ private_post_order = privatePostOrder = Entry('order', 'private', 'POST', {'cost': 1})
681
+ private_post_order_cancelreplace = privatePostOrderCancelReplace = Entry('order/cancelReplace', 'private', 'POST', {'cost': 1})
682
+ private_post_order_test = privatePostOrderTest = Entry('order/test', 'private', 'POST', {'cost': 1})
683
+ private_delete_openorders = privateDeleteOpenOrders = Entry('openOrders', 'private', 'DELETE', {'cost': 1})
684
+ private_delete_orderlist = privateDeleteOrderList = Entry('orderList', 'private', 'DELETE', {'cost': 1})
685
+ private_delete_order = privateDeleteOrder = Entry('order', 'private', 'DELETE', {'cost': 1})
686
686
  papi_get_ping = papiGetPing = Entry('ping', 'papi', 'GET', {'cost': 1})
687
687
  papi_get_um_order = papiGetUmOrder = Entry('um/order', 'papi', 'GET', {'cost': 1})
688
688
  papi_get_um_openorder = papiGetUmOpenOrder = Entry('um/openOrder', 'papi', 'GET', {'cost': 1})
ccxt/abstract/bitmart.py CHANGED
@@ -101,3 +101,7 @@ class ImplicitAPI:
101
101
  private_post_contract_private_submit_plan_order = privatePostContractPrivateSubmitPlanOrder = Entry('contract/private/submit-plan-order', 'private', 'POST', {'cost': 2.5})
102
102
  private_post_contract_private_cancel_plan_order = privatePostContractPrivateCancelPlanOrder = Entry('contract/private/cancel-plan-order', 'private', 'POST', {'cost': 1.5})
103
103
  private_post_contract_private_submit_leverage = privatePostContractPrivateSubmitLeverage = Entry('contract/private/submit-leverage', 'private', 'POST', {'cost': 2.5})
104
+ private_post_contract_private_submit_tp_sl_order = privatePostContractPrivateSubmitTpSlOrder = Entry('contract/private/submit-tp-sl-order', 'private', 'POST', {'cost': 2.5})
105
+ private_post_contract_private_modify_plan_order = privatePostContractPrivateModifyPlanOrder = Entry('contract/private/modify-plan-order', 'private', 'POST', {'cost': 2.5})
106
+ private_post_contract_private_modify_preset_plan_order = privatePostContractPrivateModifyPresetPlanOrder = Entry('contract/private/modify-preset-plan-order', 'private', 'POST', {'cost': 2.5})
107
+ private_post_contract_private_modify_tp_sl_order = privatePostContractPrivateModifyTpSlOrder = Entry('contract/private/modify-tp-sl-order', 'private', 'POST', {'cost': 2.5})
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.4'
7
+ __version__ = '4.4.6'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # -----------------------------------------------------------------------------
4
4
 
5
- __version__ = '4.4.4'
5
+ __version__ = '4.4.6'
6
6
 
7
7
  # -----------------------------------------------------------------------------
8
8
 
@@ -1223,6 +1223,7 @@ class binance(Exchange, ImplicitAPI):
1223
1223
  # exchange-specific options
1224
1224
  'options': {
1225
1225
  'sandboxMode': False,
1226
+ 'fetchMargins': True,
1226
1227
  'fetchMarkets': [
1227
1228
  'spot', # allows CORS in browsers
1228
1229
  'linear', # allows CORS in browsers
@@ -2854,13 +2855,12 @@ class binance(Exchange, ImplicitAPI):
2854
2855
  if type == 'option' and sandboxMode:
2855
2856
  continue
2856
2857
  fetchMarkets.append(type)
2857
- fetchMargins = False
2858
+ fetchMargins = self.safe_bool(self.options, 'fetchMargins', False)
2858
2859
  for i in range(0, len(fetchMarkets)):
2859
2860
  marketType = fetchMarkets[i]
2860
2861
  if marketType == 'spot':
2861
2862
  promisesRaw.append(self.publicGetExchangeInfo(params))
2862
- if self.check_required_credentials(False) and not sandboxMode:
2863
- fetchMargins = True
2863
+ if fetchMargins and self.check_required_credentials(False) and not sandboxMode:
2864
2864
  promisesRaw.append(self.sapiGetMarginAllPairs(params))
2865
2865
  promisesRaw.append(self.sapiGetMarginIsolatedAllPairs(params))
2866
2866
  elif marketType == 'linear':
@@ -44,6 +44,7 @@ class binanceus(binance, ImplicitAPI):
44
44
  'options': {
45
45
  'fetchMarkets': ['spot'],
46
46
  'defaultType': 'spot',
47
+ 'fetchMargins': False,
47
48
  'quoteOrderQty': False,
48
49
  },
49
50
  'has': {
@@ -995,8 +995,8 @@ class bitflyer(Exchange, ImplicitAPI):
995
995
  feedback = self.id + ' ' + body
996
996
  # i.e. {"status":-2,"error_message":"Under maintenance","data":null}
997
997
  errorMessage = self.safe_string(response, 'error_message')
998
- statusCode = self.safe_number(response, 'status')
998
+ statusCode = self.safe_integer(response, 'status')
999
999
  if errorMessage is not None:
1000
1000
  self.throw_exactly_matched_exception(self.exceptions['exact'], statusCode, feedback)
1001
- self.throw_broadly_matched_exception(self.exceptions['broad'], errorMessage, feedback)
1001
+ raise ExchangeError(feedback)
1002
1002
  return None
@@ -1337,6 +1337,8 @@ class bitget(Exchange, ImplicitAPI):
1337
1337
  'TONCOIN': 'TON',
1338
1338
  },
1339
1339
  'options': {
1340
+ 'timeDifference': 0, # the difference between system clock and Binance clock
1341
+ 'adjustForTimeDifference': False, # controls the adjustment logic upon instantiation
1340
1342
  'timeframes': {
1341
1343
  'spot': {
1342
1344
  '1m': '1min',
@@ -1535,17 +1537,21 @@ class bitget(Exchange, ImplicitAPI):
1535
1537
  retrieves data on all markets for bitget
1536
1538
  :see: https://www.bitget.com/api-doc/spot/market/Get-Symbols
1537
1539
  :see: https://www.bitget.com/api-doc/contract/market/Get-All-Symbols-Contracts
1540
+ :see: https://www.bitget.com/api-doc/margin/common/support-currencies
1538
1541
  :param dict [params]: extra parameters specific to the exchange API endpoint
1539
1542
  :returns dict[]: an array of objects representing market data
1540
1543
  """
1544
+ if self.options['adjustForTimeDifference']:
1545
+ await self.load_time_difference()
1541
1546
  sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
1542
1547
  types = self.safe_value(self.options, 'fetchMarkets', ['spot', 'swap'])
1543
1548
  if sandboxMode:
1544
1549
  types = ['swap']
1545
1550
  promises = []
1551
+ fetchMargins = False
1546
1552
  for i in range(0, len(types)):
1547
1553
  type = types[i]
1548
- if type == 'swap':
1554
+ if (type == 'swap') or (type == 'future'):
1549
1555
  subTypes = None
1550
1556
  if sandboxMode:
1551
1557
  # the following are simulated trading markets ['SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES']
@@ -1553,15 +1559,33 @@ class bitget(Exchange, ImplicitAPI):
1553
1559
  else:
1554
1560
  subTypes = ['USDT-FUTURES', 'COIN-FUTURES', 'USDC-FUTURES']
1555
1561
  for j in range(0, len(subTypes)):
1556
- promises.append(self.fetch_markets_by_type(type, self.extend(params, {
1562
+ promises.append(self.publicMixGetV2MixMarketContracts(self.extend(params, {
1557
1563
  'productType': subTypes[j],
1558
1564
  })))
1565
+ elif type == 'spot':
1566
+ promises.append(self.publicSpotGetV2SpotPublicSymbols(params))
1567
+ fetchMargins = True
1568
+ promises.append(self.publicMarginGetV2MarginCurrencies(params))
1569
+ else:
1570
+ raise NotSupported(self.id + ' does not support ' + type + ' market')
1571
+ results = await asyncio.gather(*promises)
1572
+ markets = []
1573
+ self.options['crossMarginPairsData'] = []
1574
+ self.options['isolatedMarginPairsData'] = []
1575
+ for i in range(0, len(results)):
1576
+ res = self.safe_dict(results, i)
1577
+ data = self.safe_list(res, 'data', [])
1578
+ firstData = self.safe_dict(data, 0, {})
1579
+ isBorrowable = self.safe_string(firstData, 'isBorrowable')
1580
+ if fetchMargins and isBorrowable is not None:
1581
+ keysList = list(self.index_by(data, 'symbol').keys())
1582
+ self.options['crossMarginPairsData'] = keysList
1583
+ self.options['isolatedMarginPairsData'] = keysList
1559
1584
  else:
1560
- promises.append(self.fetch_markets_by_type(types[i], params))
1561
- promises = await asyncio.gather(*promises)
1562
- result = promises[0]
1563
- for i in range(1, len(promises)):
1564
- result = self.array_concat(result, promises[i])
1585
+ markets = self.array_concat(markets, data)
1586
+ result = []
1587
+ for i in range(0, len(markets)):
1588
+ result.append(self.parse_market(markets[i]))
1565
1589
  return result
1566
1590
 
1567
1591
  def parse_market(self, market: dict) -> Market:
@@ -1649,11 +1673,20 @@ class bitget(Exchange, ImplicitAPI):
1649
1673
  expiry = None
1650
1674
  expiryDatetime = None
1651
1675
  symbolType = self.safe_string(market, 'symbolType')
1676
+ marginModes = None
1677
+ isMarginTradingAllowed = False
1652
1678
  if symbolType is None:
1653
1679
  type = 'spot'
1654
1680
  spot = True
1655
1681
  pricePrecision = self.parse_number(self.parse_precision(self.safe_string(market, 'pricePrecision')))
1656
1682
  amountPrecision = self.parse_number(self.parse_precision(self.safe_string(market, 'quantityPrecision')))
1683
+ hasCrossMargin = self.in_array(marketId, self.options['crossMarginPairsData'])
1684
+ hasIsolatedMargin = self.in_array(marketId, self.options['isolatedMarginPairsData'])
1685
+ marginModes = {
1686
+ 'cross': hasCrossMargin,
1687
+ 'isolated': hasIsolatedMargin,
1688
+ }
1689
+ isMarginTradingAllowed = hasCrossMargin or hasCrossMargin
1657
1690
  else:
1658
1691
  if symbolType == 'perpetual':
1659
1692
  type = 'swap'
@@ -1689,6 +1722,10 @@ class bitget(Exchange, ImplicitAPI):
1689
1722
  preciseAmount.reduce()
1690
1723
  amountString = str(preciseAmount)
1691
1724
  amountPrecision = self.parse_number(amountString)
1725
+ marginModes = {
1726
+ 'cross': True,
1727
+ 'isolated': True,
1728
+ }
1692
1729
  status = self.safe_string_2(market, 'status', 'symbolStatus')
1693
1730
  active = None
1694
1731
  if status is not None:
@@ -1708,7 +1745,8 @@ class bitget(Exchange, ImplicitAPI):
1708
1745
  'settleId': settleId,
1709
1746
  'type': type,
1710
1747
  'spot': spot,
1711
- 'margin': None,
1748
+ 'margin': spot and isMarginTradingAllowed,
1749
+ 'marginModes': marginModes,
1712
1750
  'swap': swap,
1713
1751
  'future': future,
1714
1752
  'option': False,
@@ -1749,88 +1787,6 @@ class bitget(Exchange, ImplicitAPI):
1749
1787
  'info': market,
1750
1788
  }
1751
1789
 
1752
- async def fetch_markets_by_type(self, type, params={}):
1753
- response = None
1754
- if type == 'spot':
1755
- response = await self.publicSpotGetV2SpotPublicSymbols(params)
1756
- elif (type == 'swap') or (type == 'future'):
1757
- response = await self.publicMixGetV2MixMarketContracts(params)
1758
- else:
1759
- raise NotSupported(self.id + ' does not support ' + type + ' market')
1760
- #
1761
- # spot
1762
- #
1763
- # {
1764
- # "code": "00000",
1765
- # "msg": "success",
1766
- # "requestTime": 1700102364653,
1767
- # "data": [
1768
- # {
1769
- # "symbol": "TRXUSDT",
1770
- # "baseCoin": "TRX",
1771
- # "quoteCoin": "USDT",
1772
- # "minTradeAmount": "0",
1773
- # "maxTradeAmount": "10000000000",
1774
- # "takerFeeRate": "0.002",
1775
- # "makerFeeRate": "0.002",
1776
- # "pricePrecision": "6",
1777
- # "quantityPrecision": "4",
1778
- # "quotePrecision": "6",
1779
- # "status": "online",
1780
- # "minTradeUSDT": "5",
1781
- # "buyLimitPriceRatio": "0.05",
1782
- # "sellLimitPriceRatio": "0.05"
1783
- # },
1784
- # ]
1785
- # }
1786
- #
1787
- # swap and future
1788
- #
1789
- # {
1790
- # "code": "00000",
1791
- # "msg": "success",
1792
- # "requestTime": 1700102364709,
1793
- # "data": [
1794
- # {
1795
- # "symbol": "BTCUSDT",
1796
- # "baseCoin": "BTC",
1797
- # "quoteCoin": "USDT",
1798
- # "buyLimitPriceRatio": "0.01",
1799
- # "sellLimitPriceRatio": "0.01",
1800
- # "feeRateUpRatio": "0.005",
1801
- # "makerFeeRate": "0.0002",
1802
- # "takerFeeRate": "0.0006",
1803
- # "openCostUpRatio": "0.01",
1804
- # "supportMarginCoins": ["USDT"],
1805
- # "minTradeNum": "0.001",
1806
- # "priceEndStep": "1",
1807
- # "volumePlace": "3",
1808
- # "pricePlace": "1",
1809
- # "sizeMultiplier": "0.001",
1810
- # "symbolType": "perpetual",
1811
- # "minTradeUSDT": "5",
1812
- # "maxSymbolOrderNum": "200",
1813
- # "maxProductOrderNum": "400",
1814
- # "maxPositionNum": "150",
1815
- # "symbolStatus": "normal",
1816
- # "offTime": "-1",
1817
- # "limitOpenTime": "-1",
1818
- # "deliveryTime": "",
1819
- # "deliveryStartTime": "",
1820
- # "deliveryPeriod": "",
1821
- # "launchTime": "",
1822
- # "fundInterval": "8",
1823
- # "minLever": "1",
1824
- # "maxLever": "125",
1825
- # "posLimit": "0.05",
1826
- # "maintainTime": ""
1827
- # },
1828
- # ]
1829
- # }
1830
- #
1831
- data = self.safe_value(response, 'data', [])
1832
- return self.parse_markets(data)
1833
-
1834
1790
  async def fetch_currencies(self, params={}) -> Currencies:
1835
1791
  """
1836
1792
  fetches all available currencies on an exchange
@@ -8251,6 +8207,9 @@ class bitget(Exchange, ImplicitAPI):
8251
8207
  raise ExchangeError(feedback) # unknown message
8252
8208
  return None
8253
8209
 
8210
+ def nonce(self):
8211
+ return self.milliseconds() - self.options['timeDifference']
8212
+
8254
8213
  def sign(self, path, api=[], method='GET', params={}, headers=None, body=None):
8255
8214
  signed = api[0] == 'private'
8256
8215
  endpoint = api[1]
@@ -8266,7 +8225,7 @@ class bitget(Exchange, ImplicitAPI):
8266
8225
  url = url + '?' + self.urlencode(query)
8267
8226
  if signed:
8268
8227
  self.check_required_credentials()
8269
- timestamp = str(self.milliseconds())
8228
+ timestamp = str(self.nonce())
8270
8229
  auth = timestamp + method + payload
8271
8230
  if method == 'POST':
8272
8231
  body = self.json(params)