ccxt 4.2.78__py2.py3-none-any.whl → 4.2.80__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/bingx.py +1 -0
- ccxt/abstract/gate.py +1 -0
- ccxt/abstract/gateio.py +1 -0
- ccxt/abstract/upbit.py +1 -0
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +10 -1
- ccxt/async_support/base/ws/functions.py +1 -1
- ccxt/async_support/binance.py +3 -3
- ccxt/async_support/bingx.py +37 -5
- ccxt/async_support/bitstamp.py +20 -26
- ccxt/async_support/bybit.py +92 -0
- ccxt/async_support/coinbaseinternational.py +2 -2
- ccxt/async_support/deribit.py +152 -1
- ccxt/async_support/gate.py +11 -4
- ccxt/async_support/hyperliquid.py +42 -9
- ccxt/async_support/mexc.py +2 -2
- ccxt/async_support/upbit.py +2 -0
- ccxt/base/exchange.py +38 -9
- ccxt/base/types.py +23 -0
- ccxt/binance.py +3 -3
- ccxt/bingx.py +37 -5
- ccxt/bitstamp.py +20 -26
- ccxt/bybit.py +92 -0
- ccxt/coinbaseinternational.py +2 -2
- ccxt/deribit.py +152 -1
- ccxt/gate.py +11 -4
- ccxt/hyperliquid.py +42 -9
- ccxt/mexc.py +2 -2
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/alpaca.py +1 -1
- ccxt/pro/binance.py +5 -5
- ccxt/pro/bitfinex2.py +1 -1
- ccxt/pro/bitget.py +1 -1
- ccxt/pro/bitmart.py +1 -1
- ccxt/pro/bitmex.py +1 -1
- ccxt/pro/bitopro.py +2 -1
- ccxt/pro/blockchaincom.py +1 -1
- ccxt/pro/bybit.py +14 -1
- ccxt/pro/cex.py +9 -5
- ccxt/pro/cryptocom.py +1 -1
- ccxt/pro/gemini.py +4 -3
- ccxt/pro/hitbtc.py +1 -1
- ccxt/pro/htx.py +1 -1
- ccxt/pro/okcoin.py +1 -1
- ccxt/pro/onetrading.py +1 -1
- ccxt/pro/phemex.py +6 -1
- ccxt/pro/woo.py +30 -0
- ccxt/test/base/test_ohlcv.py +3 -2
- ccxt/test/base/test_shared_methods.py +8 -0
- ccxt/test/base/test_ticker.py +7 -1
- ccxt/test/test_async.py +26 -25
- ccxt/test/test_sync.py +26 -25
- ccxt/upbit.py +2 -0
- {ccxt-4.2.78.dist-info → ccxt-4.2.80.dist-info}/METADATA +6 -6
- {ccxt-4.2.78.dist-info → ccxt-4.2.80.dist-info}/RECORD +58 -58
- {ccxt-4.2.78.dist-info → ccxt-4.2.80.dist-info}/WHEEL +0 -0
- {ccxt-4.2.78.dist-info → ccxt-4.2.80.dist-info}/top_level.txt +0 -0
@@ -754,6 +754,8 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
754
754
|
"""
|
755
755
|
await self.load_markets()
|
756
756
|
market = self.market(symbol)
|
757
|
+
vaultAddress = self.safe_string(params, 'vaultAddress')
|
758
|
+
params = self.omit(params, 'vaultAddress')
|
757
759
|
symbol = market['symbol']
|
758
760
|
order = {
|
759
761
|
'symbol': symbol,
|
@@ -763,7 +765,10 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
763
765
|
'price': price,
|
764
766
|
'params': params,
|
765
767
|
}
|
766
|
-
|
768
|
+
globalParams = {}
|
769
|
+
if vaultAddress is not None:
|
770
|
+
globalParams['vaultAddress'] = vaultAddress
|
771
|
+
response = await self.create_orders([order], globalParams)
|
767
772
|
first = self.safe_dict(response, 0)
|
768
773
|
return first
|
769
774
|
|
@@ -807,7 +812,6 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
807
812
|
amount = self.safe_string(rawOrder, 'amount')
|
808
813
|
price = self.safe_string(rawOrder, 'price')
|
809
814
|
orderParams = self.safe_dict(rawOrder, 'params', {})
|
810
|
-
orderParams = self.extend(params, orderParams)
|
811
815
|
clientOrderId = self.safe_string_2(orderParams, 'clientOrderId', 'client_id')
|
812
816
|
slippage = self.safe_string(orderParams, 'slippage', defaultSlippage)
|
813
817
|
defaultTimeInForce = 'ioc' if (isMarket) else 'gtc'
|
@@ -847,6 +851,7 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
847
851
|
orderType['limit'] = {
|
848
852
|
'tif': timeInForce,
|
849
853
|
}
|
854
|
+
orderParams = self.omit(orderParams, ['clientOrderId', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce', 'client_id'])
|
850
855
|
orderObj = {
|
851
856
|
'a': self.parse_to_int(market['baseId']),
|
852
857
|
'b': isBuy,
|
@@ -858,8 +863,8 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
858
863
|
}
|
859
864
|
if clientOrderId is not None:
|
860
865
|
orderObj['c'] = clientOrderId
|
861
|
-
orderReq.append(orderObj)
|
862
|
-
vaultAddress = self.safe_string(params, 'vaultAddress')
|
866
|
+
orderReq.append(self.extend(orderObj, orderParams))
|
867
|
+
vaultAddress = self.format_vault_address(self.safe_string(params, 'vaultAddress'))
|
863
868
|
orderAction = {
|
864
869
|
'type': 'order',
|
865
870
|
'orders': orderReq,
|
@@ -875,6 +880,9 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
875
880
|
'signature': signature,
|
876
881
|
# 'vaultAddress': vaultAddress,
|
877
882
|
}
|
883
|
+
if vaultAddress is not None:
|
884
|
+
params = self.omit(params, 'vaultAddress')
|
885
|
+
request['vaultAddress'] = vaultAddress
|
878
886
|
response = await self.privatePostExchange(self.extend(request, params))
|
879
887
|
#
|
880
888
|
# {
|
@@ -957,10 +965,13 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
957
965
|
'o': self.parse_to_numeric(ids[i]),
|
958
966
|
})
|
959
967
|
cancelAction['cancels'] = cancelReq
|
960
|
-
vaultAddress = self.safe_string(params, 'vaultAddress')
|
968
|
+
vaultAddress = self.format_vault_address(self.safe_string(params, 'vaultAddress'))
|
961
969
|
signature = self.sign_l1_action(cancelAction, nonce, vaultAddress)
|
962
970
|
request['action'] = cancelAction
|
963
971
|
request['signature'] = signature
|
972
|
+
if vaultAddress is not None:
|
973
|
+
params = self.omit(params, 'vaultAddress')
|
974
|
+
request['vaultAddress'] = vaultAddress
|
964
975
|
response = await self.privatePostExchange(self.extend(request, params))
|
965
976
|
#
|
966
977
|
# {
|
@@ -1066,7 +1077,7 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1066
1077
|
'type': 'batchModify',
|
1067
1078
|
'modifies': [modifyReq],
|
1068
1079
|
}
|
1069
|
-
vaultAddress = self.safe_string(params, 'vaultAddress')
|
1080
|
+
vaultAddress = self.format_vault_address(self.safe_string(params, 'vaultAddress'))
|
1070
1081
|
signature = self.sign_l1_action(modifyAction, nonce, vaultAddress)
|
1071
1082
|
request = {
|
1072
1083
|
'action': modifyAction,
|
@@ -1074,6 +1085,9 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1074
1085
|
'signature': signature,
|
1075
1086
|
# 'vaultAddress': vaultAddress,
|
1076
1087
|
}
|
1088
|
+
if vaultAddress is not None:
|
1089
|
+
params = self.omit(params, 'vaultAddress')
|
1090
|
+
request['vaultAddress'] = vaultAddress
|
1077
1091
|
response = await self.privatePostExchange(self.extend(request, params))
|
1078
1092
|
#
|
1079
1093
|
# {
|
@@ -1643,7 +1657,7 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1643
1657
|
'isolated': isIsolated,
|
1644
1658
|
'hedged': None,
|
1645
1659
|
'side': side,
|
1646
|
-
'contracts': self.
|
1660
|
+
'contracts': self.safe_number(entry, 'szi'),
|
1647
1661
|
'contractSize': None,
|
1648
1662
|
'entryPrice': self.safe_number(entry, 'entryPx'),
|
1649
1663
|
'markPrice': None,
|
@@ -1687,6 +1701,10 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1687
1701
|
'leverage': leverage,
|
1688
1702
|
}
|
1689
1703
|
vaultAddress = self.safe_string(params, 'vaultAddress')
|
1704
|
+
if vaultAddress is not None:
|
1705
|
+
params = self.omit(params, 'vaultAddress')
|
1706
|
+
if vaultAddress.startswith('0x'):
|
1707
|
+
vaultAddress = vaultAddress.replace('0x', '')
|
1690
1708
|
signature = self.sign_l1_action(updateAction, nonce, vaultAddress)
|
1691
1709
|
request = {
|
1692
1710
|
'action': updateAction,
|
@@ -1694,6 +1712,8 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1694
1712
|
'signature': signature,
|
1695
1713
|
# 'vaultAddress': vaultAddress,
|
1696
1714
|
}
|
1715
|
+
if vaultAddress is not None:
|
1716
|
+
request['vaultAddress'] = vaultAddress
|
1697
1717
|
response = await self.privatePostExchange(self.extend(request, params))
|
1698
1718
|
#
|
1699
1719
|
# {
|
@@ -1729,7 +1749,7 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1729
1749
|
'isCross': isCross,
|
1730
1750
|
'leverage': leverage,
|
1731
1751
|
}
|
1732
|
-
vaultAddress = self.safe_string(params, 'vaultAddress')
|
1752
|
+
vaultAddress = self.format_vault_address(self.safe_string(params, 'vaultAddress'))
|
1733
1753
|
signature = self.sign_l1_action(updateAction, nonce, vaultAddress)
|
1734
1754
|
request = {
|
1735
1755
|
'action': updateAction,
|
@@ -1737,6 +1757,9 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1737
1757
|
'signature': signature,
|
1738
1758
|
# 'vaultAddress': vaultAddress,
|
1739
1759
|
}
|
1760
|
+
if vaultAddress is not None:
|
1761
|
+
params = self.omit(params, 'vaultAddress')
|
1762
|
+
request['vaultAddress'] = vaultAddress
|
1740
1763
|
response = await self.privatePostExchange(self.extend(request, params))
|
1741
1764
|
#
|
1742
1765
|
# {
|
@@ -1784,7 +1807,7 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1784
1807
|
'isBuy': True,
|
1785
1808
|
'ntli': sz,
|
1786
1809
|
}
|
1787
|
-
vaultAddress = self.safe_string(params, 'vaultAddress')
|
1810
|
+
vaultAddress = self.format_vault_address(self.safe_string(params, 'vaultAddress'))
|
1788
1811
|
signature = self.sign_l1_action(updateAction, nonce, vaultAddress)
|
1789
1812
|
request = {
|
1790
1813
|
'action': updateAction,
|
@@ -1792,6 +1815,9 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1792
1815
|
'signature': signature,
|
1793
1816
|
# 'vaultAddress': vaultAddress,
|
1794
1817
|
}
|
1818
|
+
if vaultAddress is not None:
|
1819
|
+
params = self.omit(params, 'vaultAddress')
|
1820
|
+
request['vaultAddress'] = vaultAddress
|
1795
1821
|
response = await self.privatePostExchange(self.extend(request, params))
|
1796
1822
|
#
|
1797
1823
|
# {
|
@@ -1882,6 +1908,13 @@ class hyperliquid(Exchange, ImplicitAPI):
|
|
1882
1908
|
response = await self.privatePostExchange(self.extend(request, params))
|
1883
1909
|
return response
|
1884
1910
|
|
1911
|
+
def format_vault_address(self, address: Str = None):
|
1912
|
+
if address is None:
|
1913
|
+
return None
|
1914
|
+
if address.startswith('0x'):
|
1915
|
+
return address.replace('0x', '')
|
1916
|
+
return address
|
1917
|
+
|
1885
1918
|
def handle_public_address(self, methodName: str, params: dict):
|
1886
1919
|
userAux = None
|
1887
1920
|
userAux, params = self.handle_option_and_params(params, methodName, 'user')
|
ccxt/async_support/mexc.py
CHANGED
@@ -899,8 +899,8 @@ class mexc(Exchange, ImplicitAPI):
|
|
899
899
|
'30032': InvalidOrder, # Cannot exceed the maximum position
|
900
900
|
'30041': InvalidOrder, # current order type can not place order
|
901
901
|
'60005': ExchangeError, # your account is abnormal
|
902
|
-
'700001': AuthenticationError, # API
|
903
|
-
'700002': AuthenticationError, # Signature for self request is not valid
|
902
|
+
'700001': AuthenticationError, # {"code":700002,"msg":"Signature for self request is not valid."} # same message for expired API keys
|
903
|
+
'700002': AuthenticationError, # Signature for self request is not valid # or the API secret is incorrect
|
904
904
|
'700004': BadRequest, # Param 'origClientOrderId' or 'orderId' must be sent, but both were empty/null
|
905
905
|
'700005': InvalidNonce, # recvWindow must less than 60000
|
906
906
|
'700006': BadRequest, # IP non white list
|
ccxt/async_support/upbit.py
CHANGED
@@ -85,6 +85,7 @@ class upbit(Exchange, ImplicitAPI):
|
|
85
85
|
'1m': 'minutes',
|
86
86
|
'3m': 'minutes',
|
87
87
|
'5m': 'minutes',
|
88
|
+
'10m': 'minutes',
|
88
89
|
'15m': 'minutes',
|
89
90
|
'30m': 'minutes',
|
90
91
|
'1h': 'minutes',
|
@@ -114,6 +115,7 @@ class upbit(Exchange, ImplicitAPI):
|
|
114
115
|
'candles/minutes/1',
|
115
116
|
'candles/minutes/3',
|
116
117
|
'candles/minutes/5',
|
118
|
+
'candles/minutes/10',
|
117
119
|
'candles/minutes/15',
|
118
120
|
'candles/minutes/30',
|
119
121
|
'candles/minutes/60',
|
ccxt/base/exchange.py
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
__version__ = '4.2.
|
7
|
+
__version__ = '4.2.80'
|
8
8
|
|
9
9
|
# -----------------------------------------------------------------------------
|
10
10
|
|
@@ -31,7 +31,7 @@ from ccxt.base.decimal_to_precision import decimal_to_precision
|
|
31
31
|
from ccxt.base.decimal_to_precision import DECIMAL_PLACES, TICK_SIZE, NO_PADDING, TRUNCATE, ROUND, ROUND_UP, ROUND_DOWN, SIGNIFICANT_DIGITS
|
32
32
|
from ccxt.base.decimal_to_precision import number_to_string
|
33
33
|
from ccxt.base.precise import Precise
|
34
|
-
from ccxt.base.types import BalanceAccount, Currency, IndexType, OrderSide, OrderType, Trade, OrderRequest, Market, MarketType, Str, Num
|
34
|
+
from ccxt.base.types import BalanceAccount, Currency, IndexType, OrderSide, OrderType, Trade, OrderRequest, Market, MarketType, Str, Num, Strings
|
35
35
|
|
36
36
|
# -----------------------------------------------------------------------------
|
37
37
|
|
@@ -1171,7 +1171,7 @@ class Exchange(object):
|
|
1171
1171
|
return None
|
1172
1172
|
|
1173
1173
|
try:
|
1174
|
-
utc = datetime.datetime.
|
1174
|
+
utc = datetime.datetime.fromtimestamp(timestamp // 1000, datetime.timezone.utc)
|
1175
1175
|
return utc.strftime('%Y-%m-%dT%H:%M:%S.%f')[:-6] + "{:03d}".format(int(timestamp) % 1000) + 'Z'
|
1176
1176
|
except (TypeError, OverflowError, OSError):
|
1177
1177
|
return None
|
@@ -1187,13 +1187,13 @@ class Exchange(object):
|
|
1187
1187
|
|
1188
1188
|
@staticmethod
|
1189
1189
|
def dmy(timestamp, infix='-'):
|
1190
|
-
utc_datetime = datetime.datetime.
|
1190
|
+
utc_datetime = datetime.datetime.fromtimestamp(int(round(timestamp / 1000)), datetime.timezone.utc)
|
1191
1191
|
return utc_datetime.strftime('%m' + infix + '%d' + infix + '%Y')
|
1192
1192
|
|
1193
1193
|
@staticmethod
|
1194
1194
|
def ymd(timestamp, infix='-', fullYear=True):
|
1195
1195
|
year_format = '%Y' if fullYear else '%y'
|
1196
|
-
utc_datetime = datetime.datetime.
|
1196
|
+
utc_datetime = datetime.datetime.fromtimestamp(int(round(timestamp / 1000)), datetime.timezone.utc)
|
1197
1197
|
return utc_datetime.strftime(year_format + infix + '%m' + infix + '%d')
|
1198
1198
|
|
1199
1199
|
@staticmethod
|
@@ -1206,7 +1206,7 @@ class Exchange(object):
|
|
1206
1206
|
|
1207
1207
|
@staticmethod
|
1208
1208
|
def ymdhms(timestamp, infix=' '):
|
1209
|
-
utc_datetime = datetime.datetime.
|
1209
|
+
utc_datetime = datetime.datetime.fromtimestamp(int(round(timestamp / 1000)), datetime.timezone.utc)
|
1210
1210
|
return utc_datetime.strftime('%Y-%m-%d' + infix + '%H:%M:%S')
|
1211
1211
|
|
1212
1212
|
@staticmethod
|
@@ -1728,6 +1728,12 @@ class Exchange(object):
|
|
1728
1728
|
modifiedContent = modifiedContent.replace('}"', '}')
|
1729
1729
|
return modifiedContent
|
1730
1730
|
|
1731
|
+
def extend_exchange_options(self, newOptions):
|
1732
|
+
self.options = self.extend(self.options, newOptions)
|
1733
|
+
|
1734
|
+
def create_safe_dictionary(self):
|
1735
|
+
return {}
|
1736
|
+
|
1731
1737
|
# ########################################################################
|
1732
1738
|
# ########################################################################
|
1733
1739
|
# ########################################################################
|
@@ -3187,7 +3193,7 @@ class Exchange(object):
|
|
3187
3193
|
else:
|
3188
3194
|
raise BadResponse(errorMessage)
|
3189
3195
|
|
3190
|
-
def market_ids(self, symbols):
|
3196
|
+
def market_ids(self, symbols: Strings = None):
|
3191
3197
|
if symbols is None:
|
3192
3198
|
return symbols
|
3193
3199
|
result = []
|
@@ -3195,7 +3201,7 @@ class Exchange(object):
|
|
3195
3201
|
result.append(self.market_id(symbols[i]))
|
3196
3202
|
return result
|
3197
3203
|
|
3198
|
-
def market_symbols(self, symbols, type: Str = None, allowEmpty=True, sameTypeOnly=False, sameSubTypeOnly=False):
|
3204
|
+
def market_symbols(self, symbols: Strings = None, type: Str = None, allowEmpty=True, sameTypeOnly=False, sameSubTypeOnly=False):
|
3199
3205
|
if symbols is None:
|
3200
3206
|
if not allowEmpty:
|
3201
3207
|
raise ArgumentsRequired(self.id + ' empty list of symbols is not supported')
|
@@ -3225,7 +3231,7 @@ class Exchange(object):
|
|
3225
3231
|
result.append(symbol)
|
3226
3232
|
return result
|
3227
3233
|
|
3228
|
-
def market_codes(self, codes):
|
3234
|
+
def market_codes(self, codes: Strings = None):
|
3229
3235
|
if codes is None:
|
3230
3236
|
return codes
|
3231
3237
|
result = []
|
@@ -4025,6 +4031,9 @@ class Exchange(object):
|
|
4025
4031
|
def fetch_order_books(self, symbols: List[str] = None, limit: Int = None, params={}):
|
4026
4032
|
raise NotSupported(self.id + ' fetchOrderBooks() is not supported yet')
|
4027
4033
|
|
4034
|
+
def watch_bids_asks(self, symbols: List[str] = None, params={}):
|
4035
|
+
raise NotSupported(self.id + ' watchBidsAsks() is not supported yet')
|
4036
|
+
|
4028
4037
|
def watch_tickers(self, symbols: List[str] = None, params={}):
|
4029
4038
|
raise NotSupported(self.id + ' watchTickers() is not supported yet')
|
4030
4039
|
|
@@ -4327,6 +4336,12 @@ class Exchange(object):
|
|
4327
4336
|
def fetch_greeks(self, symbol: str, params={}):
|
4328
4337
|
raise NotSupported(self.id + ' fetchGreeks() is not supported yet')
|
4329
4338
|
|
4339
|
+
def fetch_option_chain(self, code: str, params={}):
|
4340
|
+
raise NotSupported(self.id + ' fetchOptionChain() is not supported yet')
|
4341
|
+
|
4342
|
+
def fetch_option(self, symbol: str, params={}):
|
4343
|
+
raise NotSupported(self.id + ' fetchOption() is not supported yet')
|
4344
|
+
|
4330
4345
|
def fetch_deposits_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
4331
4346
|
"""
|
4332
4347
|
fetch history of deposits and withdrawals
|
@@ -5324,6 +5339,20 @@ class Exchange(object):
|
|
5324
5339
|
def parse_greeks(self, greeks, market: Market = None):
|
5325
5340
|
raise NotSupported(self.id + ' parseGreeks() is not supported yet')
|
5326
5341
|
|
5342
|
+
def parse_option(self, chain, currency: Currency = None, market: Market = None):
|
5343
|
+
raise NotSupported(self.id + ' parseOption() is not supported yet')
|
5344
|
+
|
5345
|
+
def parse_option_chain(self, response: List[object], currencyKey: Str = None, symbolKey: Str = None):
|
5346
|
+
optionStructures = {}
|
5347
|
+
for i in range(0, len(response)):
|
5348
|
+
info = response[i]
|
5349
|
+
currencyId = self.safe_string(info, currencyKey)
|
5350
|
+
currency = self.safe_currency(currencyId)
|
5351
|
+
marketId = self.safe_string(info, symbolKey)
|
5352
|
+
market = self.safe_market(marketId, None, None, 'option')
|
5353
|
+
optionStructures[market['symbol']] = self.parseOption(info, currency, market)
|
5354
|
+
return optionStructures
|
5355
|
+
|
5327
5356
|
def parse_margin_modes(self, response: List[object], symbols: List[str] = None, symbolKey: Str = None, marketType: MarketType = None):
|
5328
5357
|
marginModeStructures = {}
|
5329
5358
|
for i in range(0, len(response)):
|
ccxt/base/types.py
CHANGED
@@ -53,6 +53,7 @@ Strings = Optional[List[str]]
|
|
53
53
|
Int = Optional[int]
|
54
54
|
Bool = Optional[bool]
|
55
55
|
MarketType = Literal['spot', 'margin', 'swap', 'future', 'option']
|
56
|
+
SubType = Literal['linear', 'inverse']
|
56
57
|
|
57
58
|
|
58
59
|
class FeeInterface(TypedDict):
|
@@ -301,6 +302,28 @@ class Greeks(TypedDict):
|
|
301
302
|
info: Dict[str, Any]
|
302
303
|
|
303
304
|
|
305
|
+
class Option(TypedDict):
|
306
|
+
info: Dict[str, Any]
|
307
|
+
currency: Str
|
308
|
+
symbol: Str
|
309
|
+
timestamp: Int
|
310
|
+
datetime: Str
|
311
|
+
impliedVolatility: Num
|
312
|
+
openInterest: Num
|
313
|
+
bidPrice: Num
|
314
|
+
askPrice: Num
|
315
|
+
midPrice: Num
|
316
|
+
markPrice: Num
|
317
|
+
lastPrice: Num
|
318
|
+
underlyingPrice: Num
|
319
|
+
change: Num
|
320
|
+
percentage: Num
|
321
|
+
baseVolume: Num
|
322
|
+
quoteVolume: Num
|
323
|
+
|
324
|
+
|
325
|
+
OptionChain = Dict[str, Option]
|
326
|
+
|
304
327
|
class MarketInterface(TypedDict):
|
305
328
|
info: Dict[str, Any]
|
306
329
|
id: Str
|
ccxt/binance.py
CHANGED
@@ -2422,13 +2422,13 @@ class binance(Exchange, ImplicitAPI):
|
|
2422
2422
|
},
|
2423
2423
|
})
|
2424
2424
|
|
2425
|
-
def is_inverse(self, type, subType=None) -> bool:
|
2425
|
+
def is_inverse(self, type: str, subType: Str = None) -> bool:
|
2426
2426
|
if subType is None:
|
2427
|
-
return
|
2427
|
+
return(type == 'delivery')
|
2428
2428
|
else:
|
2429
2429
|
return subType == 'inverse'
|
2430
2430
|
|
2431
|
-
def is_linear(self, type, subType=None) -> bool:
|
2431
|
+
def is_linear(self, type: str, subType: Str = None) -> bool:
|
2432
2432
|
if subType is None:
|
2433
2433
|
return(type == 'future') or (type == 'swap')
|
2434
2434
|
else:
|
ccxt/bingx.py
CHANGED
@@ -195,6 +195,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
195
195
|
'post': {
|
196
196
|
'trade/cancelReplace': 1,
|
197
197
|
'positionSide/dual': 1,
|
198
|
+
'trade/closePosition': 1,
|
198
199
|
},
|
199
200
|
},
|
200
201
|
},
|
@@ -2031,6 +2032,8 @@ class bingx(Exchange, ImplicitAPI):
|
|
2031
2032
|
'SELL': 'sell',
|
2032
2033
|
'SHORT': 'sell',
|
2033
2034
|
'LONG': 'buy',
|
2035
|
+
'ask': 'sell',
|
2036
|
+
'bid': 'buy',
|
2034
2037
|
}
|
2035
2038
|
return self.safe_string(sides, side, side)
|
2036
2039
|
|
@@ -3655,14 +3658,43 @@ class bingx(Exchange, ImplicitAPI):
|
|
3655
3658
|
:param str symbol: Unified CCXT market symbol
|
3656
3659
|
:param str [side]: not used by bingx
|
3657
3660
|
:param dict [params]: extra parameters specific to the bingx api endpoint
|
3661
|
+
:param str|None [params.positionId]: it is recommended to hasattr(self, fill) parameter when closing a position
|
3658
3662
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
3659
3663
|
"""
|
3660
3664
|
self.load_markets()
|
3661
|
-
|
3662
|
-
|
3663
|
-
|
3664
|
-
|
3665
|
-
|
3665
|
+
positionId = self.safe_string(params, 'positionId')
|
3666
|
+
params = self.omit(params, 'positionId')
|
3667
|
+
response = None
|
3668
|
+
if positionId is not None:
|
3669
|
+
request: dict = {
|
3670
|
+
'positionId': positionId,
|
3671
|
+
}
|
3672
|
+
response = self.swapV1PrivatePostTradeClosePosition(self.extend(request, params))
|
3673
|
+
else:
|
3674
|
+
market = self.market(symbol)
|
3675
|
+
request: dict = {
|
3676
|
+
'symbol': market['id'],
|
3677
|
+
}
|
3678
|
+
response = self.swapV2PrivatePostTradeCloseAllPositions(self.extend(request, params))
|
3679
|
+
#
|
3680
|
+
# swapV1PrivatePostTradeClosePosition
|
3681
|
+
#
|
3682
|
+
# {
|
3683
|
+
# "code": 0,
|
3684
|
+
# "msg": "",
|
3685
|
+
# "timestamp": 1710992264190,
|
3686
|
+
# "data": {
|
3687
|
+
# "orderId": 1770656007907930112,
|
3688
|
+
# "positionId": "1751667128353910784",
|
3689
|
+
# "symbol": "LTC-USDT",
|
3690
|
+
# "side": "Ask",
|
3691
|
+
# "type": "MARKET",
|
3692
|
+
# "positionSide": "Long",
|
3693
|
+
# "origQty": "0.2"
|
3694
|
+
# }
|
3695
|
+
# }
|
3696
|
+
#
|
3697
|
+
# swapV2PrivatePostTradeCloseAllPositions
|
3666
3698
|
#
|
3667
3699
|
# {
|
3668
3700
|
# "code": 0,
|
ccxt/bitstamp.py
CHANGED
@@ -1082,16 +1082,17 @@ class bitstamp(Exchange, ImplicitAPI):
|
|
1082
1082
|
'timestamp': None,
|
1083
1083
|
'datetime': None,
|
1084
1084
|
}
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
currencyId = currency
|
1085
|
+
if response is None:
|
1086
|
+
response = []
|
1087
|
+
for i in range(0, len(response)):
|
1088
|
+
currencyBalance = response[i]
|
1089
|
+
currencyId = self.safe_string(currencyBalance, 'currency')
|
1090
|
+
currencyCode = self.safe_currency_code(currencyId)
|
1090
1091
|
account = self.account()
|
1091
|
-
account['free'] = self.safe_string(
|
1092
|
-
account['used'] = self.safe_string(
|
1093
|
-
account['total'] = self.safe_string(
|
1094
|
-
result[
|
1092
|
+
account['free'] = self.safe_string(currencyBalance, 'available')
|
1093
|
+
account['used'] = self.safe_string(currencyBalance, 'reserved')
|
1094
|
+
account['total'] = self.safe_string(currencyBalance, 'total')
|
1095
|
+
result[currencyCode] = account
|
1095
1096
|
return self.safe_balance(result)
|
1096
1097
|
|
1097
1098
|
def fetch_balance(self, params={}) -> Balances:
|
@@ -1102,24 +1103,17 @@ class bitstamp(Exchange, ImplicitAPI):
|
|
1102
1103
|
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
|
1103
1104
|
"""
|
1104
1105
|
self.load_markets()
|
1105
|
-
response = self.
|
1106
|
+
response = self.privatePostAccountBalances(params)
|
1106
1107
|
#
|
1107
|
-
#
|
1108
|
-
#
|
1109
|
-
#
|
1110
|
-
#
|
1111
|
-
#
|
1112
|
-
#
|
1113
|
-
#
|
1114
|
-
#
|
1115
|
-
#
|
1116
|
-
# "bat_balance": "0.00000000",
|
1117
|
-
# "bat_reserved": "0.00000000",
|
1118
|
-
# "bat_withdrawal_fee": "5.00000000",
|
1119
|
-
# "batbtc_fee": "0.000",
|
1120
|
-
# "bateur_fee": "0.000",
|
1121
|
-
# "batusd_fee": "0.000",
|
1122
|
-
# }
|
1108
|
+
# [
|
1109
|
+
# {
|
1110
|
+
# "currency": "usdt",
|
1111
|
+
# "total": "7.00000",
|
1112
|
+
# "available": "7.00000",
|
1113
|
+
# "reserved": "0.00000"
|
1114
|
+
# },
|
1115
|
+
# ...
|
1116
|
+
# ]
|
1123
1117
|
#
|
1124
1118
|
return self.parse_balance(response)
|
1125
1119
|
|
ccxt/bybit.py
CHANGED
@@ -84,6 +84,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
84
84
|
'fetchDeposits': True,
|
85
85
|
'fetchDepositWithdrawFee': 'emulated',
|
86
86
|
'fetchDepositWithdrawFees': True,
|
87
|
+
'fetchFundingHistory': True,
|
87
88
|
'fetchFundingRate': True, # emulated in exchange
|
88
89
|
'fetchFundingRateHistory': True,
|
89
90
|
'fetchFundingRates': True,
|
@@ -7539,6 +7540,97 @@ class bybit(Exchange, ImplicitAPI):
|
|
7539
7540
|
})
|
7540
7541
|
return tiers
|
7541
7542
|
|
7543
|
+
def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
7544
|
+
"""
|
7545
|
+
fetch the history of funding payments paid and received on self account
|
7546
|
+
:see: https://bybit-exchange.github.io/docs/api-explorer/v5/position/execution
|
7547
|
+
:param str [symbol]: unified market symbol
|
7548
|
+
:param int [since]: the earliest time in ms to fetch funding history for
|
7549
|
+
:param int [limit]: the maximum number of funding history structures to retrieve
|
7550
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
7551
|
+
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
7552
|
+
:returns dict: a `funding history structure <https://docs.ccxt.com/#/?id=funding-history-structure>`
|
7553
|
+
"""
|
7554
|
+
self.load_markets()
|
7555
|
+
paginate = False
|
7556
|
+
paginate, params = self.handle_option_and_params(params, 'fetchFundingHistory', 'paginate')
|
7557
|
+
if paginate:
|
7558
|
+
return self.fetch_paginated_call_cursor('fetchFundingHistory', symbol, since, limit, params, 'nextPageCursor', 'cursor', None, 100)
|
7559
|
+
request = {
|
7560
|
+
'execType': 'Funding',
|
7561
|
+
}
|
7562
|
+
market: Market = None
|
7563
|
+
if symbol is not None:
|
7564
|
+
market = self.market(symbol)
|
7565
|
+
request['symbol'] = market['id']
|
7566
|
+
type = None
|
7567
|
+
type, params = self.get_bybit_type('fetchFundingHistory', market, params)
|
7568
|
+
request['category'] = type
|
7569
|
+
if symbol is not None:
|
7570
|
+
request['symbol'] = market['id']
|
7571
|
+
if since is not None:
|
7572
|
+
request['startTime'] = since
|
7573
|
+
if limit is not None:
|
7574
|
+
request['size'] = limit
|
7575
|
+
else:
|
7576
|
+
request['size'] = 100
|
7577
|
+
request, params = self.handle_until_option('endTime', request, params)
|
7578
|
+
response = self.privateGetV5ExecutionList(self.extend(request, params))
|
7579
|
+
fundings = self.add_pagination_cursor_to_result(response)
|
7580
|
+
return self.parse_incomes(fundings, market, since, limit)
|
7581
|
+
|
7582
|
+
def parse_income(self, income, market: Market = None):
|
7583
|
+
#
|
7584
|
+
# {
|
7585
|
+
# "symbol": "XMRUSDT",
|
7586
|
+
# "orderType": "UNKNOWN",
|
7587
|
+
# "underlyingPrice": "",
|
7588
|
+
# "orderLinkId": "",
|
7589
|
+
# "orderId": "a11e5fe2-1dbf-4bab-a9b2-af80a14efc5d",
|
7590
|
+
# "stopOrderType": "UNKNOWN",
|
7591
|
+
# "execTime": "1710950400000",
|
7592
|
+
# "feeCurrency": "",
|
7593
|
+
# "createType": "",
|
7594
|
+
# "feeRate": "-0.000761",
|
7595
|
+
# "tradeIv": "",
|
7596
|
+
# "blockTradeId": "",
|
7597
|
+
# "markPrice": "136.79",
|
7598
|
+
# "execPrice": "137.11",
|
7599
|
+
# "markIv": "",
|
7600
|
+
# "orderQty": "0",
|
7601
|
+
# "orderPrice": "0",
|
7602
|
+
# "execValue": "134.3678",
|
7603
|
+
# "closedSize": "0",
|
7604
|
+
# "execType": "Funding",
|
7605
|
+
# "seq": "28097658790",
|
7606
|
+
# "side": "Sell",
|
7607
|
+
# "indexPrice": "",
|
7608
|
+
# "leavesQty": "0",
|
7609
|
+
# "isMaker": False,
|
7610
|
+
# "execFee": "-0.10232512",
|
7611
|
+
# "execId": "8d1ef156-4ec6-4445-9a6c-1c0c24dbd046",
|
7612
|
+
# "marketUnit": "",
|
7613
|
+
# "execQty": "0.98",
|
7614
|
+
# "nextPageCursor": "5774437%3A0%2C5771289%3A0"
|
7615
|
+
# }
|
7616
|
+
#
|
7617
|
+
marketId = self.safe_string(income, 'symbol')
|
7618
|
+
market = self.safe_market(marketId, market, None, 'contract')
|
7619
|
+
code = 'USDT'
|
7620
|
+
if market['inverse']:
|
7621
|
+
code = market['quote']
|
7622
|
+
timestamp = self.safe_integer(income, 'execTime')
|
7623
|
+
return {
|
7624
|
+
'info': income,
|
7625
|
+
'symbol': self.safe_symbol(marketId, market, '-', 'swap'),
|
7626
|
+
'code': code,
|
7627
|
+
'timestamp': timestamp,
|
7628
|
+
'datetime': self.iso8601(timestamp),
|
7629
|
+
'id': self.safe_string(income, 'execId'),
|
7630
|
+
'amount': self.safe_number(income, 'execQty'),
|
7631
|
+
'rate': self.safe_number(income, 'feeRate'),
|
7632
|
+
}
|
7633
|
+
|
7542
7634
|
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
|
7543
7635
|
url = self.implode_hostname(self.urls['api'][api]) + '/' + path
|
7544
7636
|
if api == 'public':
|
ccxt/coinbaseinternational.py
CHANGED
@@ -126,10 +126,10 @@ class coinbaseinternational(Exchange, ImplicitAPI):
|
|
126
126
|
},
|
127
127
|
'www': 'https://international.coinbase.com',
|
128
128
|
'doc': [
|
129
|
-
'https://docs.cloud.
|
129
|
+
'https://docs.cloud.coinbase.com/intx/docs',
|
130
130
|
],
|
131
131
|
'fees': [
|
132
|
-
'https://help.
|
132
|
+
'https://help.coinbase.com/en/international-exchange/trading-deposits-withdrawals/international-exchange-fees',
|
133
133
|
],
|
134
134
|
'referral': '',
|
135
135
|
},
|