ccxt 4.3.1__py2.py3-none-any.whl → 4.3.3__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.
Potentially problematic release.
This version of ccxt might be problematic. Click here for more details.
- ccxt/__init__.py +1 -1
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +5 -2
- ccxt/async_support/binance.py +295 -20
- ccxt/async_support/bingx.py +5 -4
- ccxt/async_support/bitget.py +74 -4
- ccxt/async_support/coinbase.py +10 -2
- ccxt/async_support/coinbasepro.py +1 -1
- ccxt/async_support/coinex.py +109 -145
- ccxt/async_support/cryptocom.py +5 -5
- ccxt/async_support/hyperliquid.py +154 -14
- ccxt/async_support/kraken.py +6 -3
- ccxt/async_support/kucoin.py +13 -11
- ccxt/async_support/okx.py +108 -0
- ccxt/async_support/poloniexfutures.py +9 -2
- ccxt/async_support/woo.py +102 -6
- ccxt/base/exchange.py +24 -2
- ccxt/base/types.py +4 -0
- ccxt/binance.py +295 -20
- ccxt/bingx.py +5 -4
- ccxt/bitget.py +74 -4
- ccxt/coinbase.py +10 -2
- ccxt/coinbasepro.py +1 -1
- ccxt/coinex.py +109 -145
- ccxt/cryptocom.py +5 -5
- ccxt/hyperliquid.py +154 -14
- ccxt/kraken.py +6 -3
- ccxt/kucoin.py +13 -11
- ccxt/okx.py +108 -0
- ccxt/poloniexfutures.py +9 -2
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/hyperliquid.py +8 -7
- ccxt/pro/kraken.py +1 -1
- ccxt/pro/wazirx.py +2 -1
- ccxt/woo.py +102 -6
- {ccxt-4.3.1.dist-info → ccxt-4.3.3.dist-info}/METADATA +7 -6
- {ccxt-4.3.1.dist-info → ccxt-4.3.3.dist-info}/RECORD +39 -39
- {ccxt-4.3.1.dist-info → ccxt-4.3.3.dist-info}/WHEEL +0 -0
- {ccxt-4.3.1.dist-info → ccxt-4.3.3.dist-info}/top_level.txt +0 -0
ccxt/binance.py
CHANGED
@@ -95,7 +95,9 @@ class binance(Exchange, ImplicitAPI):
|
|
95
95
|
'fetchClosedOrder': False,
|
96
96
|
'fetchClosedOrders': 'emulated',
|
97
97
|
'fetchConvertCurrencies': True,
|
98
|
-
'fetchConvertQuote':
|
98
|
+
'fetchConvertQuote': True,
|
99
|
+
'fetchConvertTrade': True,
|
100
|
+
'fetchConvertTradeHistory': True,
|
99
101
|
'fetchCrossBorrowRate': True,
|
100
102
|
'fetchCrossBorrowRates': False,
|
101
103
|
'fetchCurrencies': True,
|
@@ -11637,55 +11639,328 @@ class binance(Exchange, ImplicitAPI):
|
|
11637
11639
|
}
|
11638
11640
|
return result
|
11639
11641
|
|
11640
|
-
def
|
11642
|
+
def fetch_convert_quote(self, fromCode: str, toCode: str, amount: Num = None, params={}) -> Conversion:
|
11641
11643
|
"""
|
11642
|
-
|
11643
|
-
:see: https://binance-docs.github.io/apidocs/spot/en/#
|
11644
|
-
:param str id: the id of the trade that you want to make
|
11644
|
+
fetch a quote for converting from one currency to another
|
11645
|
+
:see: https://binance-docs.github.io/apidocs/spot/en/#send-quote-request-user_data
|
11645
11646
|
:param str fromCode: the currency that you want to sell and convert from
|
11646
11647
|
:param str toCode: the currency that you want to buy and convert into
|
11647
|
-
:param float
|
11648
|
+
:param float amount: how much you want to trade in units of the from currency
|
11648
11649
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
11650
|
+
:param str [params.walletType]: either 'SPOT' or 'FUNDING', the default is 'SPOT'
|
11649
11651
|
:returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
|
11650
11652
|
"""
|
11653
|
+
if amount is None:
|
11654
|
+
raise ArgumentsRequired(self.id + ' fetchConvertQuote() requires an amount argument')
|
11651
11655
|
self.load_markets()
|
11652
11656
|
request = {
|
11653
|
-
'
|
11654
|
-
'
|
11655
|
-
'
|
11656
|
-
'amount': amount,
|
11657
|
+
'fromAsset': fromCode,
|
11658
|
+
'toAsset': toCode,
|
11659
|
+
'fromAmount': amount,
|
11657
11660
|
}
|
11658
|
-
response = self.
|
11661
|
+
response = self.sapiPostConvertGetQuote(self.extend(request, params))
|
11659
11662
|
#
|
11660
11663
|
# {
|
11661
|
-
# "
|
11662
|
-
# "
|
11664
|
+
# "quoteId":"12415572564",
|
11665
|
+
# "ratio":"38163.7",
|
11666
|
+
# "inverseRatio":"0.0000262",
|
11667
|
+
# "validTimestamp":1623319461670,
|
11668
|
+
# "toAmount":"3816.37",
|
11669
|
+
# "fromAmount":"0.1"
|
11663
11670
|
# }
|
11664
11671
|
#
|
11665
11672
|
fromCurrency = self.currency(fromCode)
|
11666
11673
|
toCurrency = self.currency(toCode)
|
11667
11674
|
return self.parse_conversion(response, fromCurrency, toCurrency)
|
11668
11675
|
|
11676
|
+
def create_convert_trade(self, id: str, fromCode: str, toCode: str, amount: Num = None, params={}) -> Conversion:
|
11677
|
+
"""
|
11678
|
+
convert from one currency to another
|
11679
|
+
:see: https://binance-docs.github.io/apidocs/spot/en/#busd-convert-trade
|
11680
|
+
:see: https://binance-docs.github.io/apidocs/spot/en/#accept-quote-trade
|
11681
|
+
:param str id: the id of the trade that you want to make
|
11682
|
+
:param str fromCode: the currency that you want to sell and convert from
|
11683
|
+
:param str toCode: the currency that you want to buy and convert into
|
11684
|
+
:param float [amount]: how much you want to trade in units of the from currency
|
11685
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
11686
|
+
:returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
|
11687
|
+
"""
|
11688
|
+
self.load_markets()
|
11689
|
+
request = {}
|
11690
|
+
response = None
|
11691
|
+
if (fromCode == 'BUSD') or (toCode == 'BUSD'):
|
11692
|
+
if amount is None:
|
11693
|
+
raise ArgumentsRequired(self.id + ' createConvertTrade() requires an amount argument')
|
11694
|
+
request['clientTranId'] = id
|
11695
|
+
request['asset'] = fromCode
|
11696
|
+
request['targetAsset'] = toCode
|
11697
|
+
request['amount'] = amount
|
11698
|
+
response = self.sapiPostAssetConvertTransfer(self.extend(request, params))
|
11699
|
+
#
|
11700
|
+
# {
|
11701
|
+
# "tranId": 118263407119,
|
11702
|
+
# "status": "S"
|
11703
|
+
# }
|
11704
|
+
#
|
11705
|
+
else:
|
11706
|
+
request['quoteId'] = id
|
11707
|
+
response = self.sapiPostConvertAcceptQuote(self.extend(request, params))
|
11708
|
+
#
|
11709
|
+
# {
|
11710
|
+
# "orderId":"933256278426274426",
|
11711
|
+
# "createTime":1623381330472,
|
11712
|
+
# "orderStatus":"PROCESS"
|
11713
|
+
# }
|
11714
|
+
#
|
11715
|
+
fromCurrency = self.currency(fromCode)
|
11716
|
+
toCurrency = self.currency(toCode)
|
11717
|
+
return self.parse_conversion(response, fromCurrency, toCurrency)
|
11718
|
+
|
11719
|
+
def fetch_convert_trade(self, id: str, code: Str = None, params={}) -> Conversion:
|
11720
|
+
"""
|
11721
|
+
fetch the data for a conversion trade
|
11722
|
+
:see: https://binance-docs.github.io/apidocs/spot/en/#busd-convert-history-user_data
|
11723
|
+
:see: https://binance-docs.github.io/apidocs/spot/en/#order-status-user_data
|
11724
|
+
:param str id: the id of the trade that you want to fetch
|
11725
|
+
:param str [code]: the unified currency code of the conversion trade
|
11726
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
11727
|
+
:returns dict: a `conversion structure <https://docs.ccxt.com/#/?id=conversion-structure>`
|
11728
|
+
"""
|
11729
|
+
self.load_markets()
|
11730
|
+
request = {}
|
11731
|
+
response = None
|
11732
|
+
if code == 'BUSD':
|
11733
|
+
msInDay = 86400000
|
11734
|
+
now = self.milliseconds()
|
11735
|
+
if code is not None:
|
11736
|
+
currency = self.currency(code)
|
11737
|
+
request['asset'] = currency['id']
|
11738
|
+
request['tranId'] = id
|
11739
|
+
request['startTime'] = now - msInDay
|
11740
|
+
request['endTime'] = now
|
11741
|
+
response = self.sapiGetAssetConvertTransferQueryByPage(self.extend(request, params))
|
11742
|
+
#
|
11743
|
+
# {
|
11744
|
+
# "total": 3,
|
11745
|
+
# "rows": [
|
11746
|
+
# {
|
11747
|
+
# "tranId": 118263615991,
|
11748
|
+
# "type": 244,
|
11749
|
+
# "time": 1664442078000,
|
11750
|
+
# "deductedAsset": "BUSD",
|
11751
|
+
# "deductedAmount": "1",
|
11752
|
+
# "targetAsset": "USDC",
|
11753
|
+
# "targetAmount": "1",
|
11754
|
+
# "status": "S",
|
11755
|
+
# "accountType": "MAIN"
|
11756
|
+
# },
|
11757
|
+
# ]
|
11758
|
+
# }
|
11759
|
+
#
|
11760
|
+
else:
|
11761
|
+
request['orderId'] = id
|
11762
|
+
response = self.sapiGetConvertOrderStatus(self.extend(request, params))
|
11763
|
+
#
|
11764
|
+
# {
|
11765
|
+
# "orderId":933256278426274426,
|
11766
|
+
# "orderStatus":"SUCCESS",
|
11767
|
+
# "fromAsset":"BTC",
|
11768
|
+
# "fromAmount":"0.00054414",
|
11769
|
+
# "toAsset":"USDT",
|
11770
|
+
# "toAmount":"20",
|
11771
|
+
# "ratio":"36755",
|
11772
|
+
# "inverseRatio":"0.00002721",
|
11773
|
+
# "createTime":1623381330472
|
11774
|
+
# }
|
11775
|
+
#
|
11776
|
+
data = response
|
11777
|
+
if code == 'BUSD':
|
11778
|
+
rows = self.safe_list(response, 'rows', [])
|
11779
|
+
data = self.safe_dict(rows, 0, {})
|
11780
|
+
fromCurrencyId = self.safe_string_2(data, 'deductedAsset', 'fromAsset')
|
11781
|
+
toCurrencyId = self.safe_string_2(data, 'targetAsset', 'toAsset')
|
11782
|
+
fromCurrency = None
|
11783
|
+
toCurrency = None
|
11784
|
+
if fromCurrencyId is not None:
|
11785
|
+
fromCurrency = self.currency(fromCurrencyId)
|
11786
|
+
if toCurrencyId is not None:
|
11787
|
+
toCurrency = self.currency(toCurrencyId)
|
11788
|
+
return self.parse_conversion(data, fromCurrency, toCurrency)
|
11789
|
+
|
11790
|
+
def fetch_convert_trade_history(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Conversion]:
|
11791
|
+
"""
|
11792
|
+
fetch the users history of conversion trades
|
11793
|
+
:see: https://binance-docs.github.io/apidocs/spot/en/#busd-convert-history-user_data
|
11794
|
+
:see: https://binance-docs.github.io/apidocs/spot/en/#get-convert-trade-history-user_data
|
11795
|
+
:param str [code]: the unified currency code
|
11796
|
+
:param int [since]: the earliest time in ms to fetch conversions for
|
11797
|
+
:param int [limit]: the maximum number of conversion structures to retrieve
|
11798
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
11799
|
+
:param int [params.until]: timestamp in ms of the latest conversion to fetch
|
11800
|
+
:returns dict[]: a list of `conversion structures <https://docs.ccxt.com/#/?id=conversion-structure>`
|
11801
|
+
"""
|
11802
|
+
self.load_markets()
|
11803
|
+
request = {}
|
11804
|
+
msInThirtyDays = 2592000000
|
11805
|
+
now = self.milliseconds()
|
11806
|
+
if since is not None:
|
11807
|
+
request['startTime'] = since
|
11808
|
+
else:
|
11809
|
+
request['startTime'] = now - msInThirtyDays
|
11810
|
+
endTime = self.safe_string_2(params, 'endTime', 'until')
|
11811
|
+
if endTime is not None:
|
11812
|
+
request['endTime'] = endTime
|
11813
|
+
else:
|
11814
|
+
request['endTime'] = now
|
11815
|
+
params = self.omit(params, 'until')
|
11816
|
+
response = None
|
11817
|
+
responseQuery = None
|
11818
|
+
fromCurrencyKey = None
|
11819
|
+
toCurrencyKey = None
|
11820
|
+
if code == 'BUSD':
|
11821
|
+
currency = self.currency(code)
|
11822
|
+
request['asset'] = currency['id']
|
11823
|
+
if limit is not None:
|
11824
|
+
request['size'] = limit
|
11825
|
+
fromCurrencyKey = 'deductedAsset'
|
11826
|
+
toCurrencyKey = 'targetAsset'
|
11827
|
+
responseQuery = 'rows'
|
11828
|
+
response = self.sapiGetAssetConvertTransferQueryByPage(self.extend(request, params))
|
11829
|
+
#
|
11830
|
+
# {
|
11831
|
+
# "total": 3,
|
11832
|
+
# "rows": [
|
11833
|
+
# {
|
11834
|
+
# "tranId": 118263615991,
|
11835
|
+
# "type": 244,
|
11836
|
+
# "time": 1664442078000,
|
11837
|
+
# "deductedAsset": "BUSD",
|
11838
|
+
# "deductedAmount": "1",
|
11839
|
+
# "targetAsset": "USDC",
|
11840
|
+
# "targetAmount": "1",
|
11841
|
+
# "status": "S",
|
11842
|
+
# "accountType": "MAIN"
|
11843
|
+
# },
|
11844
|
+
# ]
|
11845
|
+
# }
|
11846
|
+
#
|
11847
|
+
else:
|
11848
|
+
if limit is not None:
|
11849
|
+
request['limit'] = limit
|
11850
|
+
fromCurrencyKey = 'fromAsset'
|
11851
|
+
toCurrencyKey = 'toAsset'
|
11852
|
+
responseQuery = 'list'
|
11853
|
+
response = self.sapiGetConvertTradeFlow(self.extend(request, params))
|
11854
|
+
#
|
11855
|
+
# {
|
11856
|
+
# "list": [
|
11857
|
+
# {
|
11858
|
+
# "quoteId": "f3b91c525b2644c7bc1e1cd31b6e1aa6",
|
11859
|
+
# "orderId": 940708407462087195,
|
11860
|
+
# "orderStatus": "SUCCESS",
|
11861
|
+
# "fromAsset": "USDT",
|
11862
|
+
# "fromAmount": "20",
|
11863
|
+
# "toAsset": "BNB",
|
11864
|
+
# "toAmount": "0.06154036",
|
11865
|
+
# "ratio": "0.00307702",
|
11866
|
+
# "inverseRatio": "324.99",
|
11867
|
+
# "createTime": 1624248872184
|
11868
|
+
# }
|
11869
|
+
# ],
|
11870
|
+
# "startTime": 1623824139000,
|
11871
|
+
# "endTime": 1626416139000,
|
11872
|
+
# "limit": 100,
|
11873
|
+
# "moreData": False
|
11874
|
+
# }
|
11875
|
+
#
|
11876
|
+
rows = self.safe_list(response, responseQuery, [])
|
11877
|
+
return self.parse_conversions(rows, fromCurrencyKey, toCurrencyKey, since, limit)
|
11878
|
+
|
11669
11879
|
def parse_conversion(self, conversion, fromCurrency: Currency = None, toCurrency: Currency = None) -> Conversion:
|
11880
|
+
#
|
11881
|
+
# fetchConvertQuote
|
11882
|
+
#
|
11883
|
+
# {
|
11884
|
+
# "quoteId":"12415572564",
|
11885
|
+
# "ratio":"38163.7",
|
11886
|
+
# "inverseRatio":"0.0000262",
|
11887
|
+
# "validTimestamp":1623319461670,
|
11888
|
+
# "toAmount":"3816.37",
|
11889
|
+
# "fromAmount":"0.1"
|
11890
|
+
# }
|
11670
11891
|
#
|
11671
11892
|
# createConvertTrade
|
11672
11893
|
#
|
11673
11894
|
# {
|
11895
|
+
# "orderId":"933256278426274426",
|
11896
|
+
# "createTime":1623381330472,
|
11897
|
+
# "orderStatus":"PROCESS"
|
11898
|
+
# }
|
11899
|
+
#
|
11900
|
+
# createConvertTrade BUSD
|
11901
|
+
#
|
11902
|
+
# {
|
11674
11903
|
# "tranId": 118263407119,
|
11675
11904
|
# "status": "S"
|
11676
11905
|
# }
|
11677
11906
|
#
|
11678
|
-
|
11679
|
-
|
11907
|
+
# fetchConvertTrade, fetchConvertTradeHistory BUSD
|
11908
|
+
#
|
11909
|
+
# {
|
11910
|
+
# "tranId": 118263615991,
|
11911
|
+
# "type": 244,
|
11912
|
+
# "time": 1664442078000,
|
11913
|
+
# "deductedAsset": "BUSD",
|
11914
|
+
# "deductedAmount": "1",
|
11915
|
+
# "targetAsset": "USDC",
|
11916
|
+
# "targetAmount": "1",
|
11917
|
+
# "status": "S",
|
11918
|
+
# "accountType": "MAIN"
|
11919
|
+
# }
|
11920
|
+
#
|
11921
|
+
# fetchConvertTrade
|
11922
|
+
#
|
11923
|
+
# {
|
11924
|
+
# "orderId":933256278426274426,
|
11925
|
+
# "orderStatus":"SUCCESS",
|
11926
|
+
# "fromAsset":"BTC",
|
11927
|
+
# "fromAmount":"0.00054414",
|
11928
|
+
# "toAsset":"USDT",
|
11929
|
+
# "toAmount":"20",
|
11930
|
+
# "ratio":"36755",
|
11931
|
+
# "inverseRatio":"0.00002721",
|
11932
|
+
# "createTime":1623381330472
|
11933
|
+
# }
|
11934
|
+
#
|
11935
|
+
# fetchConvertTradeHistory
|
11936
|
+
#
|
11937
|
+
# {
|
11938
|
+
# "quoteId": "f3b91c525b2644c7bc1e1cd31b6e1aa6",
|
11939
|
+
# "orderId": 940708407462087195,
|
11940
|
+
# "orderStatus": "SUCCESS",
|
11941
|
+
# "fromAsset": "USDT",
|
11942
|
+
# "fromAmount": "20",
|
11943
|
+
# "toAsset": "BNB",
|
11944
|
+
# "toAmount": "0.06154036",
|
11945
|
+
# "ratio": "0.00307702",
|
11946
|
+
# "inverseRatio": "324.99",
|
11947
|
+
# "createTime": 1624248872184
|
11948
|
+
# }
|
11949
|
+
#
|
11950
|
+
timestamp = self.safe_integer_n(conversion, ['time', 'validTimestamp', 'createTime'])
|
11951
|
+
fromCur = self.safe_string_2(conversion, 'deductedAsset', 'fromAsset')
|
11952
|
+
fromCode = self.safe_currency_code(fromCur, fromCurrency)
|
11953
|
+
to = self.safe_string_2(conversion, 'targetAsset', 'toAsset')
|
11954
|
+
toCode = self.safe_currency_code(to, toCurrency)
|
11680
11955
|
return {
|
11681
11956
|
'info': conversion,
|
11682
|
-
'timestamp':
|
11683
|
-
'datetime':
|
11684
|
-
'id': self.
|
11957
|
+
'timestamp': timestamp,
|
11958
|
+
'datetime': self.iso8601(timestamp),
|
11959
|
+
'id': self.safe_string_n(conversion, ['tranId', 'orderId', 'quoteId']),
|
11685
11960
|
'fromCurrency': fromCode,
|
11686
|
-
'fromAmount':
|
11961
|
+
'fromAmount': self.safe_number_2(conversion, 'deductedAmount', 'fromAmount'),
|
11687
11962
|
'toCurrency': toCode,
|
11688
|
-
'toAmount':
|
11963
|
+
'toAmount': self.safe_number_2(conversion, 'targetAmount', 'toAmount'),
|
11689
11964
|
'price': None,
|
11690
11965
|
'fee': None,
|
11691
11966
|
}
|
ccxt/bingx.py
CHANGED
@@ -19,6 +19,7 @@ from ccxt.base.errors import BadSymbol
|
|
19
19
|
from ccxt.base.errors import InsufficientFunds
|
20
20
|
from ccxt.base.errors import OrderNotFound
|
21
21
|
from ccxt.base.errors import NotSupported
|
22
|
+
from ccxt.base.errors import OperationFailed
|
22
23
|
from ccxt.base.errors import DDoSProtection
|
23
24
|
from ccxt.base.decimal_to_precision import DECIMAL_PLACES
|
24
25
|
from ccxt.base.precise import Precise
|
@@ -397,17 +398,17 @@ class bingx(Exchange, ImplicitAPI):
|
|
397
398
|
'100400': BadRequest,
|
398
399
|
'100421': BadSymbol, # {"code":100421,"msg":"This pair is currently restricted from API trading","debugMsg":""}
|
399
400
|
'100440': ExchangeError,
|
400
|
-
'100500':
|
401
|
+
'100500': OperationFailed, # {"code":100500,"msg":"The current system is busy, please try again later","debugMsg":""}
|
401
402
|
'100503': ExchangeError,
|
402
403
|
'80001': BadRequest,
|
403
|
-
'80012': InsufficientFunds, #
|
404
|
+
'80012': InsufficientFunds, # {"code":80012,"msg":"{\"Code\":101253,\"Msg\":\"margin is not enough\"}}
|
404
405
|
'80014': BadRequest,
|
405
406
|
'80016': OrderNotFound,
|
406
407
|
'80017': OrderNotFound,
|
407
408
|
'100414': AccountSuspended, # {"code":100414,"msg":"Code: 100414, Msg: risk control check fail,code(1)","debugMsg":""}
|
408
409
|
'100419': PermissionDenied, # {"code":100419,"msg":"IP does not match IP whitelist","success":false,"timestamp":1705274099347}
|
409
410
|
'100437': BadRequest, # {"code":100437,"msg":"The withdrawal amount is lower than the minimum limit, please re-enter.","timestamp":1689258588845}
|
410
|
-
'101204': InsufficientFunds, #
|
411
|
+
'101204': InsufficientFunds, # {"code":101204,"msg":"","data":{}}
|
411
412
|
},
|
412
413
|
'broad': {},
|
413
414
|
},
|
@@ -3717,7 +3718,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
3717
3718
|
market = None
|
3718
3719
|
if symbol is not None:
|
3719
3720
|
market = self.market(symbol)
|
3720
|
-
request['symbol'] =
|
3721
|
+
request['symbol'] = market['id']
|
3721
3722
|
if since is not None:
|
3722
3723
|
request['startTime'] = since
|
3723
3724
|
if limit is not None:
|
ccxt/bitget.py
CHANGED
@@ -87,6 +87,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
87
87
|
'fetchClosedOrders': True,
|
88
88
|
'fetchConvertCurrencies': True,
|
89
89
|
'fetchConvertQuote': True,
|
90
|
+
'fetchConvertTrade': False,
|
91
|
+
'fetchConvertTradeHistory': True,
|
90
92
|
'fetchCrossBorrowRate': True,
|
91
93
|
'fetchCrossBorrowRates': False,
|
92
94
|
'fetchCurrencies': True,
|
@@ -7943,6 +7945,59 @@ class bitget(Exchange, ImplicitAPI):
|
|
7943
7945
|
toCurrency = self.currency(toCurrencyId)
|
7944
7946
|
return self.parse_conversion(data, None, toCurrency)
|
7945
7947
|
|
7948
|
+
def fetch_convert_trade_history(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Conversion]:
|
7949
|
+
"""
|
7950
|
+
fetch the users history of conversion trades
|
7951
|
+
:see: https://www.bitget.com/api-doc/common/convert/Get-Convert-Record
|
7952
|
+
:param str [code]: the unified currency code
|
7953
|
+
:param int [since]: the earliest time in ms to fetch conversions for
|
7954
|
+
:param int [limit]: the maximum number of conversion structures to retrieve
|
7955
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
7956
|
+
:returns dict[]: a list of `conversion structures <https://docs.ccxt.com/#/?id=conversion-structure>`
|
7957
|
+
"""
|
7958
|
+
self.load_markets()
|
7959
|
+
request = {}
|
7960
|
+
msInDay = 86400000
|
7961
|
+
now = self.milliseconds()
|
7962
|
+
if since is not None:
|
7963
|
+
request['startTime'] = since
|
7964
|
+
else:
|
7965
|
+
request['startTime'] = now - msInDay
|
7966
|
+
endTime = self.safe_string_2(params, 'endTime', 'until')
|
7967
|
+
if endTime is not None:
|
7968
|
+
request['endTime'] = endTime
|
7969
|
+
else:
|
7970
|
+
request['endTime'] = now
|
7971
|
+
if limit is not None:
|
7972
|
+
request['limit'] = limit
|
7973
|
+
params = self.omit(params, 'until')
|
7974
|
+
response = self.privateConvertGetV2ConvertConvertRecord(self.extend(request, params))
|
7975
|
+
#
|
7976
|
+
# {
|
7977
|
+
# "code": "00000",
|
7978
|
+
# "msg": "success",
|
7979
|
+
# "requestTime": 1712124371799,
|
7980
|
+
# "data": {
|
7981
|
+
# "dataList": [
|
7982
|
+
# {
|
7983
|
+
# "id": "1159296505255219205",
|
7984
|
+
# "fromCoin": "USDT",
|
7985
|
+
# "fromCoinSize": "5",
|
7986
|
+
# "cnvtPrice": "0.99940076",
|
7987
|
+
# "toCoin": "USDC",
|
7988
|
+
# "toCoinSize": "4.99700379",
|
7989
|
+
# "ts": "1712123746217",
|
7990
|
+
# "fee": "0"
|
7991
|
+
# }
|
7992
|
+
# ],
|
7993
|
+
# "endId": "1159296505255219205"
|
7994
|
+
# }
|
7995
|
+
# }
|
7996
|
+
#
|
7997
|
+
data = self.safe_dict(response, 'data', {})
|
7998
|
+
dataList = self.safe_list(data, 'dataList', [])
|
7999
|
+
return self.parse_conversions(dataList, 'fromCoin', 'toCoin', since, limit)
|
8000
|
+
|
7946
8001
|
def parse_conversion(self, conversion, fromCurrency: Currency = None, toCurrency: Currency = None) -> Conversion:
|
7947
8002
|
#
|
7948
8003
|
# fetchConvertQuote
|
@@ -7966,6 +8021,19 @@ class bitget(Exchange, ImplicitAPI):
|
|
7966
8021
|
# "ts": "1712123746217"
|
7967
8022
|
# }
|
7968
8023
|
#
|
8024
|
+
# fetchConvertTradeHistory
|
8025
|
+
#
|
8026
|
+
# {
|
8027
|
+
# "id": "1159296505255219205",
|
8028
|
+
# "fromCoin": "USDT",
|
8029
|
+
# "fromCoinSize": "5",
|
8030
|
+
# "cnvtPrice": "0.99940076",
|
8031
|
+
# "toCoin": "USDC",
|
8032
|
+
# "toCoinSize": "4.99700379",
|
8033
|
+
# "ts": "1712123746217",
|
8034
|
+
# "fee": "0"
|
8035
|
+
# }
|
8036
|
+
#
|
7969
8037
|
timestamp = self.safe_integer(conversion, 'ts')
|
7970
8038
|
fromCoin = self.safe_string(conversion, 'fromCoin')
|
7971
8039
|
fromCode = self.safe_currency_code(fromCoin, fromCurrency)
|
@@ -7975,7 +8043,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7975
8043
|
'info': conversion,
|
7976
8044
|
'timestamp': timestamp,
|
7977
8045
|
'datetime': self.iso8601(timestamp),
|
7978
|
-
'id': self.
|
8046
|
+
'id': self.safe_string_2(conversion, 'id', 'traceId'),
|
7979
8047
|
'fromCurrency': fromCode,
|
7980
8048
|
'fromAmount': self.safe_number(conversion, 'fromCoinSize'),
|
7981
8049
|
'toCurrency': toCode,
|
@@ -8050,6 +8118,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
8050
8118
|
#
|
8051
8119
|
# spot
|
8052
8120
|
#
|
8121
|
+
# {"code":"00000","msg":"success","requestTime":1713294492511,"data":[...]}"
|
8122
|
+
#
|
8053
8123
|
# {"status":"fail","err_code":"01001","err_msg":"系统异常,请稍后重试"}
|
8054
8124
|
# {"status":"error","ts":1595594160149,"err_code":"invalid-parameter","err_msg":"invalid size, valid range: [1,2000]"}
|
8055
8125
|
# {"status":"error","ts":1595684716042,"err_code":"invalid-parameter","err_msg":"illegal sign invalid"}
|
@@ -8071,13 +8141,13 @@ class bitget(Exchange, ImplicitAPI):
|
|
8071
8141
|
# {"code":"40108","msg":"","requestTime":1595885064600,"data":null}
|
8072
8142
|
# {"order_id":"513468410013679613","client_oid":null,"symbol":"ethusd","result":false,"err_code":"order_no_exist_error","err_msg":"订单不存在!"}
|
8073
8143
|
#
|
8074
|
-
message = self.
|
8075
|
-
errorCode = self.safe_string_2(response, 'code', 'err_code')
|
8144
|
+
message = self.safe_string_2(response, 'err_msg', 'msg')
|
8076
8145
|
feedback = self.id + ' ' + body
|
8077
|
-
nonEmptyMessage = ((message is not None) and (message != ''))
|
8146
|
+
nonEmptyMessage = ((message is not None) and (message != '') and (message != 'success'))
|
8078
8147
|
if nonEmptyMessage:
|
8079
8148
|
self.throw_exactly_matched_exception(self.exceptions['exact'], message, feedback)
|
8080
8149
|
self.throw_broadly_matched_exception(self.exceptions['broad'], message, feedback)
|
8150
|
+
errorCode = self.safe_string_2(response, 'code', 'err_code')
|
8081
8151
|
nonZeroErrorCode = (errorCode is not None) and (errorCode != '00000')
|
8082
8152
|
if nonZeroErrorCode:
|
8083
8153
|
self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
|
ccxt/coinbase.py
CHANGED
@@ -27,9 +27,10 @@ class coinbase(Exchange, ImplicitAPI):
|
|
27
27
|
def describe(self):
|
28
28
|
return self.deep_extend(super(coinbase, self).describe(), {
|
29
29
|
'id': 'coinbase',
|
30
|
-
'name': 'Coinbase',
|
30
|
+
'name': 'Coinbase Advanced',
|
31
31
|
'countries': ['US'],
|
32
32
|
'pro': True,
|
33
|
+
'certified': True,
|
33
34
|
# rate-limits:
|
34
35
|
# ADVANCED API: https://docs.cloud.coinbase.com/advanced-trade-api/docs/rest-api-rate-limits
|
35
36
|
# - max 30 req/second for private data, 10 req/s for public data
|
@@ -2490,7 +2491,7 @@ class coinbase(Exchange, ImplicitAPI):
|
|
2490
2491
|
:param float [params.stopLossPrice]: price to trigger stop-loss orders
|
2491
2492
|
:param float [params.takeProfitPrice]: price to trigger take-profit orders
|
2492
2493
|
:param bool [params.postOnly]: True or False
|
2493
|
-
:param str [params.timeInForce]: 'GTC', 'IOC', 'GTD' or 'PO'
|
2494
|
+
:param str [params.timeInForce]: 'GTC', 'IOC', 'GTD' or 'PO', 'FOK'
|
2494
2495
|
:param str [params.stop_direction]: 'UNKNOWN_STOP_DIRECTION', 'STOP_DIRECTION_STOP_UP', 'STOP_DIRECTION_STOP_DOWN' the direction the stopPrice is triggered from
|
2495
2496
|
:param str [params.end_time]: '2023-05-25T17:01:05.092Z' for 'GTD' orders
|
2496
2497
|
:param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
|
@@ -2582,6 +2583,13 @@ class coinbase(Exchange, ImplicitAPI):
|
|
2582
2583
|
'limit_price': self.price_to_precision(symbol, price),
|
2583
2584
|
},
|
2584
2585
|
}
|
2586
|
+
elif timeInForce == 'FOK':
|
2587
|
+
request['order_configuration'] = {
|
2588
|
+
'limit_limit_fok': {
|
2589
|
+
'base_size': self.amount_to_precision(symbol, amount),
|
2590
|
+
'limit_price': self.price_to_precision(symbol, price),
|
2591
|
+
},
|
2592
|
+
}
|
2585
2593
|
else:
|
2586
2594
|
request['order_configuration'] = {
|
2587
2595
|
'limit_limit_gtc': {
|
ccxt/coinbasepro.py
CHANGED
@@ -27,7 +27,7 @@ class coinbasepro(Exchange, ImplicitAPI):
|
|
27
27
|
def describe(self):
|
28
28
|
return self.deep_extend(super(coinbasepro, self).describe(), {
|
29
29
|
'id': 'coinbasepro',
|
30
|
-
'name': 'Coinbase Pro',
|
30
|
+
'name': 'Coinbase Pro(Deprecated)',
|
31
31
|
'countries': ['US'],
|
32
32
|
'rateLimit': 100,
|
33
33
|
'userAgent': self.userAgents['chrome'],
|