ccxt 4.2.90__py2.py3-none-any.whl → 4.2.92__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 +1 -1
- ccxt/abstract/bybit.py +1 -0
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/bybit.py +1 -0
- ccxt/async_support/coinbase.py +3 -1
- ccxt/async_support/deribit.py +111 -101
- ccxt/async_support/gemini.py +1 -0
- ccxt/async_support/kraken.py +66 -14
- ccxt/async_support/okx.py +30 -30
- ccxt/base/exchange.py +6 -10
- ccxt/bybit.py +1 -0
- ccxt/coinbase.py +3 -1
- ccxt/deribit.py +111 -101
- ccxt/gemini.py +1 -0
- ccxt/kraken.py +66 -14
- ccxt/okx.py +30 -30
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/bitmex.py +35 -17
- ccxt/pro/kucoin.py +85 -0
- ccxt/pro/kucoinfutures.py +141 -76
- ccxt/test/test_async.py +15 -1
- ccxt/test/test_sync.py +15 -1
- {ccxt-4.2.90.dist-info → ccxt-4.2.92.dist-info}/METADATA +4 -4
- {ccxt-4.2.90.dist-info → ccxt-4.2.92.dist-info}/RECORD +27 -27
- {ccxt-4.2.90.dist-info → ccxt-4.2.92.dist-info}/WHEEL +0 -0
- {ccxt-4.2.90.dist-info → ccxt-4.2.92.dist-info}/top_level.txt +0 -0
ccxt/__init__.py
CHANGED
ccxt/abstract/bybit.py
CHANGED
@@ -173,6 +173,7 @@ class ImplicitAPI:
|
|
173
173
|
private_get_v5_broker_earning_record = privateGetV5BrokerEarningRecord = Entry('v5/broker/earning-record', 'private', 'GET', {'cost': 5})
|
174
174
|
private_get_v5_broker_earnings_info = privateGetV5BrokerEarningsInfo = Entry('v5/broker/earnings-info', 'private', 'GET', {'cost': 5})
|
175
175
|
private_get_v5_broker_account_info = privateGetV5BrokerAccountInfo = Entry('v5/broker/account-info', 'private', 'GET', {'cost': 5})
|
176
|
+
private_get_v5_broker_asset_query_sub_member_deposit_record = privateGetV5BrokerAssetQuerySubMemberDepositRecord = Entry('v5/broker/asset/query-sub-member-deposit-record', 'private', 'GET', {'cost': 10})
|
176
177
|
private_post_option_usdc_openapi_private_v1_place_order = privatePostOptionUsdcOpenapiPrivateV1PlaceOrder = Entry('option/usdc/openapi/private/v1/place-order', 'private', 'POST', {'cost': 2.5})
|
177
178
|
private_post_option_usdc_openapi_private_v1_replace_order = privatePostOptionUsdcOpenapiPrivateV1ReplaceOrder = Entry('option/usdc/openapi/private/v1/replace-order', 'private', 'POST', {'cost': 2.5})
|
178
179
|
private_post_option_usdc_openapi_private_v1_cancel_order = privatePostOptionUsdcOpenapiPrivateV1CancelOrder = Entry('option/usdc/openapi/private/v1/cancel-order', 'private', 'POST', {'cost': 2.5})
|
ccxt/async_support/__init__.py
CHANGED
ccxt/async_support/bybit.py
CHANGED
ccxt/async_support/coinbase.py
CHANGED
@@ -338,6 +338,7 @@ class coinbase(Exchange, ImplicitAPI):
|
|
338
338
|
'CGLD': 'CELO',
|
339
339
|
},
|
340
340
|
'options': {
|
341
|
+
'brokerId': 'ccxt',
|
341
342
|
'stablePairs': ['BUSD-USD', 'CBETH-ETH', 'DAI-USD', 'GUSD-USD', 'GYEN-USD', 'PAX-USD', 'PAX-USDT', 'USDC-EUR', 'USDC-GBP', 'USDT-EUR', 'USDT-GBP', 'USDT-USD', 'USDT-USDC', 'WBTC-BTC'],
|
342
343
|
'fetchCurrencies': {
|
343
344
|
'expires': 5000,
|
@@ -2252,8 +2253,9 @@ class coinbase(Exchange, ImplicitAPI):
|
|
2252
2253
|
"""
|
2253
2254
|
await self.load_markets()
|
2254
2255
|
market = self.market(symbol)
|
2256
|
+
id = self.safe_string(self.options, 'brokerId', 'ccxt')
|
2255
2257
|
request = {
|
2256
|
-
'client_order_id': self.uuid(),
|
2258
|
+
'client_order_id': id + '-' + self.uuid(),
|
2257
2259
|
'product_id': market['id'],
|
2258
2260
|
'side': side.upper(),
|
2259
2261
|
}
|
ccxt/async_support/deribit.py
CHANGED
@@ -692,117 +692,127 @@ class deribit(Exchange, ImplicitAPI):
|
|
692
692
|
"""
|
693
693
|
retrieves data on all markets for deribit
|
694
694
|
:see: https://docs.deribit.com/#public-get_currencies
|
695
|
+
:see: https://docs.deribit.com/#public-get_instruments
|
695
696
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
696
697
|
:returns dict[]: an array of objects representing market data
|
697
698
|
"""
|
698
|
-
|
699
|
-
#
|
700
|
-
# {
|
701
|
-
# "jsonrpc": "2.0",
|
702
|
-
# "result": [
|
703
|
-
# {
|
704
|
-
# "withdrawal_priorities": [
|
705
|
-
# {value: 0.15, name: "very_low"},
|
706
|
-
# {value: 1.5, name: "very_high"},
|
707
|
-
# ],
|
708
|
-
# "withdrawal_fee": 0.0005,
|
709
|
-
# "min_withdrawal_fee": 0.0005,
|
710
|
-
# "min_confirmations": 1,
|
711
|
-
# "fee_precision": 4,
|
712
|
-
# "currency_long": "Bitcoin",
|
713
|
-
# "currency": "BTC",
|
714
|
-
# "coin_type": "BITCOIN"
|
715
|
-
# }
|
716
|
-
# ],
|
717
|
-
# "usIn": 1583761588590479,
|
718
|
-
# "usOut": 1583761588590544,
|
719
|
-
# "usDiff": 65,
|
720
|
-
# "testnet": False
|
721
|
-
# }
|
722
|
-
#
|
723
|
-
parsedMarkets = {}
|
724
|
-
currenciesResult = self.safe_value(currenciesResponse, 'result', [])
|
699
|
+
instrumentsResponses = []
|
725
700
|
result = []
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
701
|
+
parsedMarkets = {}
|
702
|
+
fetchAllMarkets = None
|
703
|
+
fetchAllMarkets, params = self.handle_option_and_params(params, 'fetchMarkets', 'fetchAllMarkets', True)
|
704
|
+
if fetchAllMarkets:
|
705
|
+
instrumentsResponse = await self.publicGetGetInstruments(params)
|
706
|
+
instrumentsResponses.append(instrumentsResponse)
|
707
|
+
else:
|
708
|
+
currenciesResponse = await self.publicGetGetCurrencies(params)
|
732
709
|
#
|
733
710
|
# {
|
734
|
-
# "jsonrpc":"2.0",
|
735
|
-
# "result":[
|
736
|
-
# {
|
737
|
-
# "tick_size":0.0005,
|
738
|
-
# "taker_commission":0.0003,
|
739
|
-
# "strike":52000.0,
|
740
|
-
# "settlement_period":"month",
|
741
|
-
# "settlement_currency":"BTC",
|
742
|
-
# "quote_currency":"BTC",
|
743
|
-
# "option_type":"put", # put, call
|
744
|
-
# "min_trade_amount":0.1,
|
745
|
-
# "maker_commission":0.0003,
|
746
|
-
# "kind":"option",
|
747
|
-
# "is_active":true,
|
748
|
-
# "instrument_name":"BTC-24JUN22-52000-P",
|
749
|
-
# "expiration_timestamp":1656057600000,
|
750
|
-
# "creation_timestamp":1648199543000,
|
751
|
-
# "counter_currency":"USD",
|
752
|
-
# "contract_size":1.0,
|
753
|
-
# "block_trade_commission":0.0003,
|
754
|
-
# "base_currency":"BTC"
|
755
|
-
# },
|
711
|
+
# "jsonrpc": "2.0",
|
712
|
+
# "result": [
|
756
713
|
# {
|
757
|
-
# "
|
758
|
-
#
|
759
|
-
#
|
760
|
-
#
|
761
|
-
# "
|
762
|
-
# "
|
763
|
-
# "
|
764
|
-
# "
|
765
|
-
# "
|
766
|
-
# "
|
767
|
-
# "
|
768
|
-
#
|
769
|
-
# "future_type":"reversed",
|
770
|
-
# "expiration_timestamp":1653638400000,
|
771
|
-
# "creation_timestamp":1648195209000,
|
772
|
-
# "counter_currency":"USD",
|
773
|
-
# "contract_size":10.0,
|
774
|
-
# "block_trade_commission":0.0001,
|
775
|
-
# "base_currency":"BTC"
|
776
|
-
# },
|
777
|
-
# {
|
778
|
-
# "tick_size":0.5,
|
779
|
-
# "taker_commission":0.0005,
|
780
|
-
# "settlement_period":"perpetual",
|
781
|
-
# "settlement_currency":"BTC",
|
782
|
-
# "quote_currency":"USD",
|
783
|
-
# "min_trade_amount":10.0,
|
784
|
-
# "max_liquidation_commission":0.0075,
|
785
|
-
# "max_leverage":50,
|
786
|
-
# "maker_commission":0.0,
|
787
|
-
# "kind":"future",
|
788
|
-
# "is_active":true,
|
789
|
-
# "instrument_name":"BTC-PERPETUAL",
|
790
|
-
# "future_type":"reversed",
|
791
|
-
# "expiration_timestamp":32503708800000,
|
792
|
-
# "creation_timestamp":1534242287000,
|
793
|
-
# "counter_currency":"USD",
|
794
|
-
# "contract_size":10.0,
|
795
|
-
# "block_trade_commission":0.0001,
|
796
|
-
# "base_currency":"BTC"
|
797
|
-
# },
|
714
|
+
# "withdrawal_priorities": [
|
715
|
+
# {value: 0.15, name: "very_low"},
|
716
|
+
# {value: 1.5, name: "very_high"},
|
717
|
+
# ],
|
718
|
+
# "withdrawal_fee": 0.0005,
|
719
|
+
# "min_withdrawal_fee": 0.0005,
|
720
|
+
# "min_confirmations": 1,
|
721
|
+
# "fee_precision": 4,
|
722
|
+
# "currency_long": "Bitcoin",
|
723
|
+
# "currency": "BTC",
|
724
|
+
# "coin_type": "BITCOIN"
|
725
|
+
# }
|
798
726
|
# ],
|
799
|
-
# "usIn":
|
800
|
-
# "usOut":
|
801
|
-
# "usDiff":
|
802
|
-
# "testnet":
|
727
|
+
# "usIn": 1583761588590479,
|
728
|
+
# "usOut": 1583761588590544,
|
729
|
+
# "usDiff": 65,
|
730
|
+
# "testnet": False
|
803
731
|
# }
|
804
732
|
#
|
805
|
-
|
733
|
+
currenciesResult = self.safe_value(currenciesResponse, 'result', [])
|
734
|
+
for i in range(0, len(currenciesResult)):
|
735
|
+
currencyId = self.safe_string(currenciesResult[i], 'currency')
|
736
|
+
request = {
|
737
|
+
'currency': currencyId,
|
738
|
+
}
|
739
|
+
instrumentsResponse = await self.publicGetGetInstruments(self.extend(request, params))
|
740
|
+
#
|
741
|
+
# {
|
742
|
+
# "jsonrpc":"2.0",
|
743
|
+
# "result":[
|
744
|
+
# {
|
745
|
+
# "tick_size":0.0005,
|
746
|
+
# "taker_commission":0.0003,
|
747
|
+
# "strike":52000.0,
|
748
|
+
# "settlement_period":"month",
|
749
|
+
# "settlement_currency":"BTC",
|
750
|
+
# "quote_currency":"BTC",
|
751
|
+
# "option_type":"put", # put, call
|
752
|
+
# "min_trade_amount":0.1,
|
753
|
+
# "maker_commission":0.0003,
|
754
|
+
# "kind":"option",
|
755
|
+
# "is_active":true,
|
756
|
+
# "instrument_name":"BTC-24JUN22-52000-P",
|
757
|
+
# "expiration_timestamp":1656057600000,
|
758
|
+
# "creation_timestamp":1648199543000,
|
759
|
+
# "counter_currency":"USD",
|
760
|
+
# "contract_size":1.0,
|
761
|
+
# "block_trade_commission":0.0003,
|
762
|
+
# "base_currency":"BTC"
|
763
|
+
# },
|
764
|
+
# {
|
765
|
+
# "tick_size":0.5,
|
766
|
+
# "taker_commission":0.0005,
|
767
|
+
# "settlement_period":"month", # month, week
|
768
|
+
# "settlement_currency":"BTC",
|
769
|
+
# "quote_currency":"USD",
|
770
|
+
# "min_trade_amount":10.0,
|
771
|
+
# "max_liquidation_commission":0.0075,
|
772
|
+
# "max_leverage":50,
|
773
|
+
# "maker_commission":0.0,
|
774
|
+
# "kind":"future",
|
775
|
+
# "is_active":true,
|
776
|
+
# "instrument_name":"BTC-27MAY22",
|
777
|
+
# "future_type":"reversed",
|
778
|
+
# "expiration_timestamp":1653638400000,
|
779
|
+
# "creation_timestamp":1648195209000,
|
780
|
+
# "counter_currency":"USD",
|
781
|
+
# "contract_size":10.0,
|
782
|
+
# "block_trade_commission":0.0001,
|
783
|
+
# "base_currency":"BTC"
|
784
|
+
# },
|
785
|
+
# {
|
786
|
+
# "tick_size":0.5,
|
787
|
+
# "taker_commission":0.0005,
|
788
|
+
# "settlement_period":"perpetual",
|
789
|
+
# "settlement_currency":"BTC",
|
790
|
+
# "quote_currency":"USD",
|
791
|
+
# "min_trade_amount":10.0,
|
792
|
+
# "max_liquidation_commission":0.0075,
|
793
|
+
# "max_leverage":50,
|
794
|
+
# "maker_commission":0.0,
|
795
|
+
# "kind":"future",
|
796
|
+
# "is_active":true,
|
797
|
+
# "instrument_name":"BTC-PERPETUAL",
|
798
|
+
# "future_type":"reversed",
|
799
|
+
# "expiration_timestamp":32503708800000,
|
800
|
+
# "creation_timestamp":1534242287000,
|
801
|
+
# "counter_currency":"USD",
|
802
|
+
# "contract_size":10.0,
|
803
|
+
# "block_trade_commission":0.0001,
|
804
|
+
# "base_currency":"BTC"
|
805
|
+
# },
|
806
|
+
# ],
|
807
|
+
# "usIn":1648691472831791,
|
808
|
+
# "usOut":1648691472831896,
|
809
|
+
# "usDiff":105,
|
810
|
+
# "testnet":false
|
811
|
+
# }
|
812
|
+
#
|
813
|
+
instrumentsResponses.append(instrumentsResponse)
|
814
|
+
for i in range(0, len(instrumentsResponses)):
|
815
|
+
instrumentsResult = self.safe_value(instrumentsResponses[i], 'result', [])
|
806
816
|
for k in range(0, len(instrumentsResult)):
|
807
817
|
market = instrumentsResult[k]
|
808
818
|
kind = self.safe_string(market, 'kind')
|
ccxt/async_support/gemini.py
CHANGED
@@ -445,6 +445,7 @@ class gemini(Exchange, ImplicitAPI):
|
|
445
445
|
# '</tr>'
|
446
446
|
# ]
|
447
447
|
marketId = cells[0].replace('<td>', '')
|
448
|
+
marketId = marketId.replace('*', '')
|
448
449
|
# base = self.safe_currency_code(baseId)
|
449
450
|
minAmountString = cells[1].replace('<td>', '')
|
450
451
|
minAmountParts = minAmountString.split(' ')
|
ccxt/async_support/kraken.py
CHANGED
@@ -609,9 +609,7 @@ class kraken(Exchange, ImplicitAPI):
|
|
609
609
|
if currencyId is not None:
|
610
610
|
if len(currencyId) > 3:
|
611
611
|
if (currencyId.find('X') == 0) or (currencyId.find('Z') == 0):
|
612
|
-
if currencyId.find('.') > 0:
|
613
|
-
return super(kraken, self).safe_currency(currencyId, currency)
|
614
|
-
else:
|
612
|
+
if not (currencyId.find('.') > 0):
|
615
613
|
currencyId = currencyId[1:]
|
616
614
|
return super(kraken, self).safe_currency(currencyId, currency)
|
617
615
|
|
@@ -653,8 +651,13 @@ class kraken(Exchange, ImplicitAPI):
|
|
653
651
|
# {
|
654
652
|
# "error": [],
|
655
653
|
# "result": {
|
656
|
-
# "
|
657
|
-
#
|
654
|
+
# "BCH": {
|
655
|
+
# "aclass": "currency",
|
656
|
+
# "altname": "BCH",
|
657
|
+
# "decimals": 10,
|
658
|
+
# "display_decimals": 5
|
659
|
+
# "status": "enabled",
|
660
|
+
# },
|
658
661
|
# ...
|
659
662
|
# },
|
660
663
|
# }
|
@@ -669,15 +672,15 @@ class kraken(Exchange, ImplicitAPI):
|
|
669
672
|
# see: https://support.kraken.com/hc/en-us/articles/201893608-What-are-the-withdrawal-fees-
|
670
673
|
# to add support for multiple withdrawal/deposit methods and
|
671
674
|
# differentiated fees for each particular method
|
672
|
-
code = self.safe_currency_code(
|
675
|
+
code = self.safe_currency_code(id)
|
673
676
|
precision = self.parse_number(self.parse_precision(self.safe_string(currency, 'decimals')))
|
674
677
|
# assumes all currencies are active except those listed above
|
675
|
-
active =
|
678
|
+
active = self.safe_string(currency, 'status') == 'enabled'
|
676
679
|
result[code] = {
|
677
680
|
'id': id,
|
678
681
|
'code': code,
|
679
682
|
'info': currency,
|
680
|
-
'name':
|
683
|
+
'name': self.safe_string(currency, 'altname'),
|
681
684
|
'active': active,
|
682
685
|
'deposit': None,
|
683
686
|
'withdraw': None,
|
@@ -2526,15 +2529,15 @@ class kraken(Exchange, ImplicitAPI):
|
|
2526
2529
|
"""
|
2527
2530
|
fetch all open positions
|
2528
2531
|
:see: https://docs.kraken.com/rest/#tag/Account-Data/operation/getOpenPositions
|
2529
|
-
:param str[]
|
2532
|
+
:param str[] [symbols]: not used by kraken fetchPositions()
|
2530
2533
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2531
2534
|
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
2532
2535
|
"""
|
2533
2536
|
await self.load_markets()
|
2534
2537
|
request = {
|
2535
2538
|
# 'txid': 'comma delimited list of transaction ids to restrict output to',
|
2536
|
-
|
2537
|
-
|
2539
|
+
'docalcs': 'true', # whether or not to include profit/loss calculations
|
2540
|
+
'consolidation': 'market', # what to consolidate the positions data around, market will consolidate positions based on market pair
|
2538
2541
|
}
|
2539
2542
|
response = await self.privatePostOpenPositions(self.extend(request, params))
|
2540
2543
|
#
|
@@ -2582,9 +2585,58 @@ class kraken(Exchange, ImplicitAPI):
|
|
2582
2585
|
# ]
|
2583
2586
|
# }
|
2584
2587
|
#
|
2585
|
-
|
2586
|
-
|
2587
|
-
|
2588
|
+
symbols = self.market_symbols(symbols)
|
2589
|
+
result = self.safe_list(response, 'result')
|
2590
|
+
results = self.parse_positions(result, symbols)
|
2591
|
+
return self.filter_by_array_positions(results, 'symbol', symbols, False)
|
2592
|
+
|
2593
|
+
def parse_position(self, position, market: Market = None):
|
2594
|
+
#
|
2595
|
+
# {
|
2596
|
+
# "pair": "ETHUSDT",
|
2597
|
+
# "positions": "1",
|
2598
|
+
# "type": "buy",
|
2599
|
+
# "leverage": "2.00000",
|
2600
|
+
# "cost": "28.49800",
|
2601
|
+
# "fee": "0.07979",
|
2602
|
+
# "vol": "0.02000000",
|
2603
|
+
# "vol_closed": "0.00000000",
|
2604
|
+
# "margin": "14.24900"
|
2605
|
+
# }
|
2606
|
+
#
|
2607
|
+
marketId = self.safe_string(position, 'pair')
|
2608
|
+
rawSide = self.safe_string(position, 'type')
|
2609
|
+
side = 'long' if (rawSide == 'buy') else 'short'
|
2610
|
+
return self.safe_position({
|
2611
|
+
'info': position,
|
2612
|
+
'id': None,
|
2613
|
+
'symbol': self.safe_symbol(marketId, market),
|
2614
|
+
'notional': None,
|
2615
|
+
'marginMode': None,
|
2616
|
+
'liquidationPrice': None,
|
2617
|
+
'entryPrice': None,
|
2618
|
+
'unrealizedPnl': self.safe_number(position, 'net'),
|
2619
|
+
'realizedPnl': None,
|
2620
|
+
'percentage': None,
|
2621
|
+
'contracts': self.safe_number(position, 'vol'),
|
2622
|
+
'contractSize': None,
|
2623
|
+
'markPrice': None,
|
2624
|
+
'lastPrice': None,
|
2625
|
+
'side': side,
|
2626
|
+
'hedged': None,
|
2627
|
+
'timestamp': None,
|
2628
|
+
'datetime': None,
|
2629
|
+
'lastUpdateTimestamp': None,
|
2630
|
+
'maintenanceMargin': None,
|
2631
|
+
'maintenanceMarginPercentage': None,
|
2632
|
+
'collateral': None,
|
2633
|
+
'initialMargin': self.safe_number(position, 'margin'),
|
2634
|
+
'initialMarginPercentage': None,
|
2635
|
+
'leverage': self.safe_number(position, 'leverage'),
|
2636
|
+
'marginRatio': None,
|
2637
|
+
'stopLossPrice': None,
|
2638
|
+
'takeProfitPrice': None,
|
2639
|
+
})
|
2588
2640
|
|
2589
2641
|
def parse_account_type(self, account):
|
2590
2642
|
accountByType = {
|
ccxt/async_support/okx.py
CHANGED
@@ -1236,7 +1236,7 @@ class okx(Exchange, ImplicitAPI):
|
|
1236
1236
|
# ]
|
1237
1237
|
# }
|
1238
1238
|
#
|
1239
|
-
data = self.
|
1239
|
+
data = self.safe_list(response, 'data', [])
|
1240
1240
|
dataLength = len(data)
|
1241
1241
|
update = {
|
1242
1242
|
'updated': None,
|
@@ -1277,8 +1277,8 @@ class okx(Exchange, ImplicitAPI):
|
|
1277
1277
|
# "msg": ""
|
1278
1278
|
# }
|
1279
1279
|
#
|
1280
|
-
data = self.
|
1281
|
-
first = self.
|
1280
|
+
data = self.safe_list(response, 'data', [])
|
1281
|
+
first = self.safe_dict(data, 0, {})
|
1282
1282
|
return self.safe_integer(first, 'ts')
|
1283
1283
|
|
1284
1284
|
async def fetch_accounts(self, params={}) -> List[Account]:
|
@@ -1308,7 +1308,7 @@ class okx(Exchange, ImplicitAPI):
|
|
1308
1308
|
# "msg": ""
|
1309
1309
|
# }
|
1310
1310
|
#
|
1311
|
-
data = self.
|
1311
|
+
data = self.safe_list(response, 'data', [])
|
1312
1312
|
result = []
|
1313
1313
|
for i in range(0, len(data)):
|
1314
1314
|
account = data[i]
|
@@ -1330,7 +1330,7 @@ class okx(Exchange, ImplicitAPI):
|
|
1330
1330
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1331
1331
|
:returns dict[]: an array of objects representing market data
|
1332
1332
|
"""
|
1333
|
-
types = self.
|
1333
|
+
types = self.safe_list(self.options, 'fetchMarkets', [])
|
1334
1334
|
promises = []
|
1335
1335
|
result = []
|
1336
1336
|
for i in range(0, len(types)):
|
@@ -1427,7 +1427,7 @@ class okx(Exchange, ImplicitAPI):
|
|
1427
1427
|
symbol = symbol + '-' + ymd + '-' + strikePrice + '-' + optionType
|
1428
1428
|
optionType = 'put' if (optionType == 'P') else 'call'
|
1429
1429
|
tickSize = self.safe_string(market, 'tickSz')
|
1430
|
-
fees = self.
|
1430
|
+
fees = self.safe_dict_2(self.fees, type, 'trading', {})
|
1431
1431
|
maxLeverage = self.safe_string(market, 'lever', '1')
|
1432
1432
|
maxLeverage = Precise.string_max(maxLeverage, '1')
|
1433
1433
|
maxSpotCost = self.safe_number(market, 'maxMktSz')
|
@@ -1486,7 +1486,7 @@ class okx(Exchange, ImplicitAPI):
|
|
1486
1486
|
'instType': self.convert_to_instrument_type(type),
|
1487
1487
|
}
|
1488
1488
|
if type == 'option':
|
1489
|
-
optionsUnderlying = self.
|
1489
|
+
optionsUnderlying = self.safe_list(self.options, 'defaultUnderlying', ['BTC-USD', 'ETH-USD'])
|
1490
1490
|
promises = []
|
1491
1491
|
for i in range(0, len(optionsUnderlying)):
|
1492
1492
|
underlying = optionsUnderlying[i]
|
@@ -1495,8 +1495,8 @@ class okx(Exchange, ImplicitAPI):
|
|
1495
1495
|
promisesResult = await asyncio.gather(*promises)
|
1496
1496
|
markets = []
|
1497
1497
|
for i in range(0, len(promisesResult)):
|
1498
|
-
res = self.
|
1499
|
-
options = self.
|
1498
|
+
res = self.safe_dict(promisesResult, i, {})
|
1499
|
+
options = self.safe_list(res, 'data', [])
|
1500
1500
|
markets = self.array_concat(markets, options)
|
1501
1501
|
return self.parse_markets(markets)
|
1502
1502
|
response = await self.publicGetPublicInstruments(self.extend(request, params))
|
@@ -1533,7 +1533,7 @@ class okx(Exchange, ImplicitAPI):
|
|
1533
1533
|
# "msg": ""
|
1534
1534
|
# }
|
1535
1535
|
#
|
1536
|
-
dataResponse = self.
|
1536
|
+
dataResponse = self.safe_list(response, 'data', [])
|
1537
1537
|
return self.parse_markets(dataResponse)
|
1538
1538
|
|
1539
1539
|
def safe_network(self, networkId):
|
@@ -1607,7 +1607,7 @@ class okx(Exchange, ImplicitAPI):
|
|
1607
1607
|
# "msg": ""
|
1608
1608
|
# }
|
1609
1609
|
#
|
1610
|
-
data = self.
|
1610
|
+
data = self.safe_list(response, 'data', [])
|
1611
1611
|
result = {}
|
1612
1612
|
dataByCurrencyId = self.group_by(data, 'ccy')
|
1613
1613
|
currencyIds = list(dataByCurrencyId.keys())
|
@@ -1623,11 +1623,11 @@ class okx(Exchange, ImplicitAPI):
|
|
1623
1623
|
maxPrecision = None
|
1624
1624
|
for j in range(0, len(chains)):
|
1625
1625
|
chain = chains[j]
|
1626
|
-
canDeposit = self.
|
1626
|
+
canDeposit = self.safe_bool(chain, 'canDep')
|
1627
1627
|
depositEnabled = canDeposit if (canDeposit) else depositEnabled
|
1628
|
-
canWithdraw = self.
|
1628
|
+
canWithdraw = self.safe_bool(chain, 'canWd')
|
1629
1629
|
withdrawEnabled = canWithdraw if (canWithdraw) else withdrawEnabled
|
1630
|
-
canInternal = self.
|
1630
|
+
canInternal = self.safe_bool(chain, 'canInternal')
|
1631
1631
|
active = True if (canDeposit and canWithdraw and canInternal) else False
|
1632
1632
|
currencyActive = active if (active) else currencyActive
|
1633
1633
|
networkId = self.safe_string(chain, 'chain')
|
@@ -1656,7 +1656,7 @@ class okx(Exchange, ImplicitAPI):
|
|
1656
1656
|
},
|
1657
1657
|
'info': chain,
|
1658
1658
|
}
|
1659
|
-
firstChain = self.
|
1659
|
+
firstChain = self.safe_dict(chains, 0, {})
|
1660
1660
|
result[code] = {
|
1661
1661
|
'info': None,
|
1662
1662
|
'code': code,
|
@@ -1725,8 +1725,8 @@ class okx(Exchange, ImplicitAPI):
|
|
1725
1725
|
# ]
|
1726
1726
|
# }
|
1727
1727
|
#
|
1728
|
-
data = self.
|
1729
|
-
first = self.
|
1728
|
+
data = self.safe_list(response, 'data', [])
|
1729
|
+
first = self.safe_dict(data, 0, {})
|
1730
1730
|
timestamp = self.safe_integer(first, 'ts')
|
1731
1731
|
return self.parse_order_book(first, symbol, timestamp)
|
1732
1732
|
|
@@ -1825,7 +1825,7 @@ class okx(Exchange, ImplicitAPI):
|
|
1825
1825
|
# ]
|
1826
1826
|
# }
|
1827
1827
|
#
|
1828
|
-
data = self.
|
1828
|
+
data = self.safe_list(response, 'data', [])
|
1829
1829
|
first = self.safe_dict(data, 0, {})
|
1830
1830
|
return self.parse_ticker(first, market)
|
1831
1831
|
|
@@ -1846,7 +1846,7 @@ class okx(Exchange, ImplicitAPI):
|
|
1846
1846
|
'instType': self.convert_to_instrument_type(marketType),
|
1847
1847
|
}
|
1848
1848
|
if marketType == 'option':
|
1849
|
-
defaultUnderlying = self.
|
1849
|
+
defaultUnderlying = self.safe_string(self.options, 'defaultUnderlying', 'BTC-USD')
|
1850
1850
|
currencyId = self.safe_string_2(params, 'uly', 'marketId', defaultUnderlying)
|
1851
1851
|
if currencyId is None:
|
1852
1852
|
raise ArgumentsRequired(self.id + ' fetchTickers() requires an underlying uly or marketId parameter for options markets')
|
@@ -2095,7 +2095,7 @@ class okx(Exchange, ImplicitAPI):
|
|
2095
2095
|
return await self.fetch_paginated_call_deterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 200)
|
2096
2096
|
price = self.safe_string(params, 'price')
|
2097
2097
|
params = self.omit(params, 'price')
|
2098
|
-
options = self.
|
2098
|
+
options = self.safe_dict(self.options, 'fetchOHLCV', {})
|
2099
2099
|
timezone = self.safe_string(options, 'timezone', 'UTC')
|
2100
2100
|
if limit is None:
|
2101
2101
|
limit = 100 # default 100, max 100
|
@@ -2208,7 +2208,7 @@ class okx(Exchange, ImplicitAPI):
|
|
2208
2208
|
# }
|
2209
2209
|
#
|
2210
2210
|
rates = []
|
2211
|
-
data = self.
|
2211
|
+
data = self.safe_list(response, 'data', [])
|
2212
2212
|
for i in range(0, len(data)):
|
2213
2213
|
rate = data[i]
|
2214
2214
|
timestamp = self.safe_integer(rate, 'fundingTime')
|
@@ -2230,10 +2230,10 @@ class okx(Exchange, ImplicitAPI):
|
|
2230
2230
|
|
2231
2231
|
def parse_trading_balance(self, response):
|
2232
2232
|
result = {'info': response}
|
2233
|
-
data = self.
|
2234
|
-
first = self.
|
2233
|
+
data = self.safe_list(response, 'data', [])
|
2234
|
+
first = self.safe_dict(data, 0, {})
|
2235
2235
|
timestamp = self.safe_integer(first, 'uTime')
|
2236
|
-
details = self.
|
2236
|
+
details = self.safe_list(first, 'details', [])
|
2237
2237
|
for i in range(0, len(details)):
|
2238
2238
|
balance = details[i]
|
2239
2239
|
currencyId = self.safe_string(balance, 'ccy')
|
@@ -2255,7 +2255,7 @@ class okx(Exchange, ImplicitAPI):
|
|
2255
2255
|
|
2256
2256
|
def parse_funding_balance(self, response):
|
2257
2257
|
result = {'info': response}
|
2258
|
-
data = self.
|
2258
|
+
data = self.safe_list(response, 'data', [])
|
2259
2259
|
for i in range(0, len(data)):
|
2260
2260
|
balance = data[i]
|
2261
2261
|
currencyId = self.safe_string(balance, 'ccy')
|
@@ -2333,8 +2333,8 @@ class okx(Exchange, ImplicitAPI):
|
|
2333
2333
|
# "msg": ""
|
2334
2334
|
# }
|
2335
2335
|
#
|
2336
|
-
data = self.
|
2337
|
-
first = self.
|
2336
|
+
data = self.safe_list(response, 'data', [])
|
2337
|
+
first = self.safe_dict(data, 0, {})
|
2338
2338
|
return self.parse_trading_fee(first, market)
|
2339
2339
|
|
2340
2340
|
async def fetch_balance(self, params={}) -> Balances:
|
@@ -2748,8 +2748,8 @@ class okx(Exchange, ImplicitAPI):
|
|
2748
2748
|
response = await self.privatePostTradeOrderAlgo(request)
|
2749
2749
|
else:
|
2750
2750
|
response = await self.privatePostTradeBatchOrders(request)
|
2751
|
-
data = self.
|
2752
|
-
first = self.
|
2751
|
+
data = self.safe_list(response, 'data', [])
|
2752
|
+
first = self.safe_dict(data, 0, {})
|
2753
2753
|
order = self.parse_order(first, market)
|
2754
2754
|
order['type'] = type
|
2755
2755
|
order['side'] = side
|
@@ -4128,7 +4128,7 @@ class okx(Exchange, ImplicitAPI):
|
|
4128
4128
|
# ]
|
4129
4129
|
# }
|
4130
4130
|
#
|
4131
|
-
data = self.
|
4131
|
+
data = self.safe_list(response, 'data', [])
|
4132
4132
|
return self.parse_ledger(data, currency, since, limit)
|
4133
4133
|
|
4134
4134
|
def parse_ledger_entry_type(self, type):
|