gate-io-api 0.0.23__py3-none-any.whl → 0.0.25__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 gate-io-api might be problematic. Click here for more details.
- gate/ccxt/__init__.py +2 -3
- gate/ccxt/async_support/__init__.py +2 -3
- gate/ccxt/async_support/base/exchange.py +2 -2
- gate/ccxt/async_support/gate.py +12 -8
- gate/ccxt/base/exchange.py +109 -23
- gate/ccxt/gate.py +12 -8
- gate/ccxt/pro/__init__.py +2 -3
- gate/ccxt/pro/gate.py +22 -2
- {gate_io_api-0.0.23.dist-info → gate_io_api-0.0.25.dist-info}/METADATA +9 -3
- {gate_io_api-0.0.23.dist-info → gate_io_api-0.0.25.dist-info}/RECORD +11 -11
- {gate_io_api-0.0.23.dist-info → gate_io_api-0.0.25.dist-info}/WHEEL +0 -0
gate/ccxt/__init__.py
CHANGED
|
@@ -26,7 +26,7 @@ sys.modules['ccxt'] = ccxt_module
|
|
|
26
26
|
|
|
27
27
|
# ----------------------------------------------------------------------------
|
|
28
28
|
|
|
29
|
-
__version__ = '4.4.
|
|
29
|
+
__version__ = '4.4.78'
|
|
30
30
|
|
|
31
31
|
# ----------------------------------------------------------------------------
|
|
32
32
|
|
|
@@ -87,10 +87,9 @@ from ccxt.base.errors import CancelPending # noqa: F4
|
|
|
87
87
|
from ccxt.base.errors import UnsubscribeError # noqa: F401
|
|
88
88
|
from ccxt.base.errors import error_hierarchy # noqa: F401
|
|
89
89
|
|
|
90
|
-
from ccxt.bitfinex1 import bitfinex1 # noqa: F401
|
|
91
90
|
from ccxt.gate import gate # noqa: F401
|
|
92
91
|
|
|
93
|
-
exchanges = [ '
|
|
92
|
+
exchanges = [ 'gate',]
|
|
94
93
|
|
|
95
94
|
base = [
|
|
96
95
|
'Exchange',
|
|
@@ -8,7 +8,7 @@ sys.modules['ccxt'] = ccxt_module
|
|
|
8
8
|
|
|
9
9
|
# -----------------------------------------------------------------------------
|
|
10
10
|
|
|
11
|
-
__version__ = '4.4.
|
|
11
|
+
__version__ = '4.4.78'
|
|
12
12
|
|
|
13
13
|
# -----------------------------------------------------------------------------
|
|
14
14
|
|
|
@@ -67,10 +67,9 @@ from ccxt.base.errors import UnsubscribeError # noqa: F4
|
|
|
67
67
|
from ccxt.base.errors import error_hierarchy # noqa: F401
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
from ccxt.async_support.bitfinex1 import bitfinex1 # noqa: F401
|
|
71
70
|
from ccxt.async_support.gate import gate # noqa: F401
|
|
72
71
|
|
|
73
|
-
exchanges = [ '
|
|
72
|
+
exchanges = [ 'gate',]
|
|
74
73
|
|
|
75
74
|
base = [
|
|
76
75
|
'Exchange',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# -----------------------------------------------------------------------------
|
|
4
4
|
|
|
5
|
-
__version__ = '4.4.
|
|
5
|
+
__version__ = '4.4.78'
|
|
6
6
|
|
|
7
7
|
# -----------------------------------------------------------------------------
|
|
8
8
|
|
|
@@ -154,7 +154,7 @@ class Exchange(BaseExchange):
|
|
|
154
154
|
proxyUrl = self.check_proxy_url_settings(url, method, headers, body)
|
|
155
155
|
if proxyUrl is not None:
|
|
156
156
|
request_headers.update({'Origin': self.origin})
|
|
157
|
-
url = proxyUrl + url
|
|
157
|
+
url = proxyUrl + self.url_encoder_for_proxy_url(url)
|
|
158
158
|
# proxy agents
|
|
159
159
|
final_proxy = None # set default
|
|
160
160
|
proxy_session = None
|
gate/ccxt/async_support/gate.py
CHANGED
|
@@ -1485,6 +1485,10 @@ class gate(Exchange, ImplicitAPI):
|
|
|
1485
1485
|
takerPercent = self.safe_string(market, 'taker_fee_rate')
|
|
1486
1486
|
makerPercent = self.safe_string(market, 'maker_fee_rate', takerPercent)
|
|
1487
1487
|
isLinear = quote == settle
|
|
1488
|
+
contractSize = self.safe_string(market, 'quanto_multiplier')
|
|
1489
|
+
# exception only for one market: https://api.gateio.ws/api/v4/futures/btc/contracts
|
|
1490
|
+
if contractSize == '0':
|
|
1491
|
+
contractSize = '1' # 1 USD in WEB: https://i.imgur.com/MBBUI04.png
|
|
1488
1492
|
return {
|
|
1489
1493
|
'id': id,
|
|
1490
1494
|
'symbol': symbol,
|
|
@@ -1506,7 +1510,7 @@ class gate(Exchange, ImplicitAPI):
|
|
|
1506
1510
|
'inverse': not isLinear,
|
|
1507
1511
|
'taker': self.parse_number(Precise.string_div(takerPercent, '100')), # Fee is in %, so divide by 100
|
|
1508
1512
|
'maker': self.parse_number(Precise.string_div(makerPercent, '100')),
|
|
1509
|
-
'contractSize': self.
|
|
1513
|
+
'contractSize': self.parse_number(contractSize),
|
|
1510
1514
|
'expiry': expiry,
|
|
1511
1515
|
'expiryDatetime': self.iso8601(expiry),
|
|
1512
1516
|
'strike': None,
|
|
@@ -1819,9 +1823,9 @@ class gate(Exchange, ImplicitAPI):
|
|
|
1819
1823
|
partFirst = self.safe_string(parts, 0)
|
|
1820
1824
|
# if there's an underscore then the second part is always the chain name(except the _OLD suffix)
|
|
1821
1825
|
currencyName = currencyId if currencyId.endswith('_OLD') else partFirst
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
tradeDisabled =
|
|
1826
|
+
withdrawDisabled = self.safe_bool(entry, 'withdraw_disabled', False)
|
|
1827
|
+
depositDisabled = self.safe_bool(entry, 'deposit_disabled', False)
|
|
1828
|
+
tradeDisabled = self.safe_bool(entry, 'trade_disabled', False)
|
|
1825
1829
|
precision = self.parse_number('0.0001') # temporary safe default, because no value provided from API
|
|
1826
1830
|
code = self.safe_currency_code(currencyName)
|
|
1827
1831
|
# check leveraged tokens(e.g. BTC3S, ETH5L)
|
|
@@ -1849,8 +1853,8 @@ class gate(Exchange, ImplicitAPI):
|
|
|
1849
1853
|
},
|
|
1850
1854
|
},
|
|
1851
1855
|
'active': not tradeDisabled,
|
|
1852
|
-
'deposit':
|
|
1853
|
-
'withdraw':
|
|
1856
|
+
'deposit': not depositDisabled,
|
|
1857
|
+
'withdraw': not withdrawDisabled,
|
|
1854
1858
|
'fee': None,
|
|
1855
1859
|
'precision': precision,
|
|
1856
1860
|
}
|
|
@@ -5720,7 +5724,7 @@ class gate(Exchange, ImplicitAPI):
|
|
|
5720
5724
|
#
|
|
5721
5725
|
return self.parse_position(response, market)
|
|
5722
5726
|
|
|
5723
|
-
async def fetch_positions(self, symbols: Strings = None, params={}):
|
|
5727
|
+
async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
|
5724
5728
|
"""
|
|
5725
5729
|
fetch all open positions
|
|
5726
5730
|
|
|
@@ -6366,7 +6370,7 @@ class gate(Exchange, ImplicitAPI):
|
|
|
6366
6370
|
queryString = self.urlencode(query)
|
|
6367
6371
|
# https://github.com/ccxt/ccxt/issues/25570
|
|
6368
6372
|
if queryString.find('currencies=') >= 0 and queryString.find('%2C') >= 0:
|
|
6369
|
-
queryString = queryString.replace('%
|
|
6373
|
+
queryString = queryString.replace('%2C', ',')
|
|
6370
6374
|
url += '?' + queryString
|
|
6371
6375
|
if method == 'PATCH':
|
|
6372
6376
|
body = self.json(query)
|
gate/ccxt/base/exchange.py
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# -----------------------------------------------------------------------------
|
|
6
6
|
|
|
7
|
-
__version__ = '4.4.
|
|
7
|
+
__version__ = '4.4.78'
|
|
8
8
|
|
|
9
9
|
# -----------------------------------------------------------------------------
|
|
10
10
|
|
|
@@ -67,6 +67,10 @@ from ccxt.static_dependencies.starknet.hash.address import compute_address
|
|
|
67
67
|
from ccxt.static_dependencies.starknet.hash.selector import get_selector_from_name
|
|
68
68
|
from ccxt.static_dependencies.starknet.hash.utils import message_signature, private_to_stark_key
|
|
69
69
|
from ccxt.static_dependencies.starknet.utils.typed_data import TypedData as TypedDataDataclass
|
|
70
|
+
try:
|
|
71
|
+
import apexpro.zklink_sdk as zklink_sdk
|
|
72
|
+
except ImportError:
|
|
73
|
+
zklink_sdk = None
|
|
70
74
|
|
|
71
75
|
# -----------------------------------------------------------------------------
|
|
72
76
|
|
|
@@ -509,7 +513,7 @@ class Exchange(object):
|
|
|
509
513
|
proxyUrl = self.check_proxy_url_settings(url, method, headers, body)
|
|
510
514
|
if proxyUrl is not None:
|
|
511
515
|
request_headers.update({'Origin': self.origin})
|
|
512
|
-
url = proxyUrl + url
|
|
516
|
+
url = proxyUrl + self.url_encoder_for_proxy_url(url)
|
|
513
517
|
# proxy agents
|
|
514
518
|
proxies = None # set default
|
|
515
519
|
httpProxy, httpsProxy, socksProxy = self.check_proxy_settings(url, method, headers, body)
|
|
@@ -1755,6 +1759,69 @@ class Exchange(object):
|
|
|
1755
1759
|
def binary_length(self, binary):
|
|
1756
1760
|
return len(binary)
|
|
1757
1761
|
|
|
1762
|
+
def get_zk_contract_signature_obj(self, seeds: str, params={}):
|
|
1763
|
+
if zklink_sdk is None:
|
|
1764
|
+
raise Exception('zklink_sdk is not installed, please do pip3 install apexomni-arm or apexomni-x86-mac or apexomni-x86-windows-linux')
|
|
1765
|
+
|
|
1766
|
+
slotId = self.safe_string(params, 'slotId')
|
|
1767
|
+
nonceInt = int(self.remove0x_prefix(self.hash(self.encode(slotId), 'sha256', 'hex')), 16)
|
|
1768
|
+
|
|
1769
|
+
maxUint64 = 18446744073709551615
|
|
1770
|
+
maxUint32 = 4294967295
|
|
1771
|
+
|
|
1772
|
+
slotId = (nonceInt % maxUint64) / maxUint32
|
|
1773
|
+
nonce = nonceInt % maxUint32
|
|
1774
|
+
accountId = int(self.safe_string(params, 'accountId'), 10) % maxUint32
|
|
1775
|
+
|
|
1776
|
+
priceStr = (Decimal(self.safe_string(params, 'price')) * Decimal(10) ** Decimal('18')).quantize(Decimal(0), rounding='ROUND_DOWN')
|
|
1777
|
+
sizeStr = (Decimal(self.safe_string(params, 'size')) * Decimal(10) ** Decimal('18')).quantize(Decimal(0), rounding='ROUND_DOWN')
|
|
1778
|
+
|
|
1779
|
+
takerFeeRateStr = (Decimal(self.safe_string(params, 'takerFeeRate')) * Decimal(10000)).quantize(Decimal(0), rounding='ROUND_UP')
|
|
1780
|
+
makerFeeRateStr = (Decimal(self.safe_string(params, 'makerFeeRate')) * Decimal(10000)).quantize(Decimal(0), rounding='ROUND_UP')
|
|
1781
|
+
|
|
1782
|
+
builder = zklink_sdk.ContractBuilder(
|
|
1783
|
+
int(accountId), int(0), int(slotId), int(nonce), int(self.safe_number(params, 'pairId')),
|
|
1784
|
+
sizeStr.__str__(), priceStr.__str__(), self.safe_string(params, 'direction') == "BUY",
|
|
1785
|
+
int(takerFeeRateStr), int(makerFeeRateStr), False)
|
|
1786
|
+
|
|
1787
|
+
|
|
1788
|
+
tx = zklink_sdk.Contract(builder)
|
|
1789
|
+
seedsByte = bytes.fromhex(seeds.removeprefix('0x'))
|
|
1790
|
+
signerSeed = zklink_sdk.ZkLinkSigner().new_from_seed(seedsByte)
|
|
1791
|
+
auth_data = signerSeed.sign_musig(tx.get_bytes())
|
|
1792
|
+
signature = auth_data.signature
|
|
1793
|
+
return signature
|
|
1794
|
+
|
|
1795
|
+
def get_zk_transfer_signature_obj(self, seeds: str, params={}):
|
|
1796
|
+
if zklink_sdk is None:
|
|
1797
|
+
raise Exception('zklink_sdk is not installed, please do pip3 install apexomni-arm or apexomni-x86-mac or apexomni-x86-windows-linux')
|
|
1798
|
+
|
|
1799
|
+
nonce = self.safe_string(params, 'nonce', '0')
|
|
1800
|
+
if self.safe_bool(params, 'isContract'):
|
|
1801
|
+
formattedUint32 = '4294967295'
|
|
1802
|
+
formattedNonce = int(self.remove0x_prefix(self.hash(self.encode(nonce), 'sha256', 'hex')), 16)
|
|
1803
|
+
nonce = Precise.string_mod(str(formattedNonce), formattedUint32)
|
|
1804
|
+
|
|
1805
|
+
tx_builder = zklink_sdk.TransferBuilder(
|
|
1806
|
+
int(self.safe_number(params, 'zkAccountId', 0)),
|
|
1807
|
+
self.safe_string(params, 'receiverAddress'),
|
|
1808
|
+
int(self.safe_number(params, 'subAccountId', 0)),
|
|
1809
|
+
int(self.safe_number(params, 'receiverSubAccountId', 0)),
|
|
1810
|
+
int(self.safe_number(params, 'tokenId', 0)),
|
|
1811
|
+
self.safe_string(params, 'amount', '0'),
|
|
1812
|
+
self.safe_string(params, 'fee', '0'),
|
|
1813
|
+
self.parse_to_int(nonce),
|
|
1814
|
+
int(self.safe_number(params, 'timestampSeconds', 0))
|
|
1815
|
+
)
|
|
1816
|
+
|
|
1817
|
+
tx = zklink_sdk.Transfer(tx_builder)
|
|
1818
|
+
seedsByte = bytes.fromhex(seeds.removeprefix('0x'))
|
|
1819
|
+
signerSeed = zklink_sdk.ZkLinkSigner().new_from_seed(seedsByte)
|
|
1820
|
+
auth_data = signerSeed.sign_musig(tx.get_bytes())
|
|
1821
|
+
signature = auth_data.signature
|
|
1822
|
+
return signature
|
|
1823
|
+
|
|
1824
|
+
|
|
1758
1825
|
# ########################################################################
|
|
1759
1826
|
# ########################################################################
|
|
1760
1827
|
# ########################################################################
|
|
@@ -2254,6 +2321,12 @@ class Exchange(object):
|
|
|
2254
2321
|
raise InvalidProxySettings(self.id + ' you have multiple conflicting proxy settings(' + joinedProxyNames + '), please use only one from : proxyUrl, proxy_url, proxyUrlCallback, proxy_url_callback')
|
|
2255
2322
|
return proxyUrl
|
|
2256
2323
|
|
|
2324
|
+
def url_encoder_for_proxy_url(self, targetUrl: str):
|
|
2325
|
+
# to be overriden
|
|
2326
|
+
includesQuery = targetUrl.find('?') >= 0
|
|
2327
|
+
finalUrl = self.encode_uri_component(targetUrl) if includesQuery else targetUrl
|
|
2328
|
+
return finalUrl
|
|
2329
|
+
|
|
2257
2330
|
def check_proxy_settings(self, url: Str = None, method: Str = None, headers=None, body=None):
|
|
2258
2331
|
usedProxies = []
|
|
2259
2332
|
httpProxy = None
|
|
@@ -2913,9 +2986,6 @@ class Exchange(object):
|
|
|
2913
2986
|
|
|
2914
2987
|
def safe_currency_structure(self, currency: object):
|
|
2915
2988
|
# derive data from networks: deposit, withdraw, active, fee, limits, precision
|
|
2916
|
-
currencyDeposit = self.safe_bool(currency, 'deposit')
|
|
2917
|
-
currencyWithdraw = self.safe_bool(currency, 'withdraw')
|
|
2918
|
-
currencyActive = self.safe_bool(currency, 'active')
|
|
2919
2989
|
networks = self.safe_dict(currency, 'networks', {})
|
|
2920
2990
|
keys = list(networks.keys())
|
|
2921
2991
|
length = len(keys)
|
|
@@ -2924,20 +2994,24 @@ class Exchange(object):
|
|
|
2924
2994
|
key = keys[i]
|
|
2925
2995
|
network = networks[key]
|
|
2926
2996
|
deposit = self.safe_bool(network, 'deposit')
|
|
2997
|
+
currencyDeposit = self.safe_bool(currency, 'deposit')
|
|
2927
2998
|
if currencyDeposit is None or deposit:
|
|
2928
2999
|
currency['deposit'] = deposit
|
|
2929
3000
|
withdraw = self.safe_bool(network, 'withdraw')
|
|
3001
|
+
currencyWithdraw = self.safe_bool(currency, 'withdraw')
|
|
2930
3002
|
if currencyWithdraw is None or withdraw:
|
|
2931
3003
|
currency['withdraw'] = withdraw
|
|
2932
|
-
active = self.safe_bool(network, 'active')
|
|
2933
|
-
if currencyActive is None or active:
|
|
2934
|
-
currency['active'] = active
|
|
2935
3004
|
# set network 'active' to False if D or W is disabled
|
|
2936
|
-
|
|
3005
|
+
active = self.safe_bool(network, 'active')
|
|
3006
|
+
if active is None:
|
|
2937
3007
|
if deposit and withdraw:
|
|
2938
3008
|
currency['networks'][key]['active'] = True
|
|
2939
3009
|
elif deposit is not None and withdraw is not None:
|
|
2940
3010
|
currency['networks'][key]['active'] = False
|
|
3011
|
+
active = self.safe_bool(network, 'active')
|
|
3012
|
+
currencyActive = self.safe_bool(currency, 'active')
|
|
3013
|
+
if currencyActive is None or active:
|
|
3014
|
+
currency['active'] = active
|
|
2941
3015
|
# find lowest fee(which is more desired)
|
|
2942
3016
|
fee = self.safe_string(network, 'fee')
|
|
2943
3017
|
feeMain = self.safe_string(currency, 'fee')
|
|
@@ -2946,7 +3020,7 @@ class Exchange(object):
|
|
|
2946
3020
|
# find lowest precision(which is more desired)
|
|
2947
3021
|
precision = self.safe_string(network, 'precision')
|
|
2948
3022
|
precisionMain = self.safe_string(currency, 'precision')
|
|
2949
|
-
if precisionMain is None or Precise.
|
|
3023
|
+
if precisionMain is None or Precise.string_gt(precision, precisionMain):
|
|
2950
3024
|
currency['precision'] = self.parse_number(precision)
|
|
2951
3025
|
# limits
|
|
2952
3026
|
limits = self.safe_dict(network, 'limits')
|
|
@@ -6471,24 +6545,36 @@ class Exchange(object):
|
|
|
6471
6545
|
return self.sort_by(result, 'id', True)
|
|
6472
6546
|
return result
|
|
6473
6547
|
|
|
6474
|
-
def remove_repeated_elements_from_array(self, input):
|
|
6548
|
+
def remove_repeated_elements_from_array(self, input, fallbackToTimestamp: bool = True):
|
|
6549
|
+
uniqueDic = {}
|
|
6550
|
+
uniqueResult = []
|
|
6551
|
+
for i in range(0, len(input)):
|
|
6552
|
+
entry = input[i]
|
|
6553
|
+
uniqValue = self.safe_string_n(entry, ['id', 'timestamp', 0]) if fallbackToTimestamp else self.safe_string(entry, 'id')
|
|
6554
|
+
if uniqValue is not None and not (uniqValue in uniqueDic):
|
|
6555
|
+
uniqueDic[uniqValue] = 1
|
|
6556
|
+
uniqueResult.append(entry)
|
|
6557
|
+
valuesLength = len(uniqueResult)
|
|
6558
|
+
if valuesLength > 0:
|
|
6559
|
+
return uniqueResult
|
|
6560
|
+
return input
|
|
6561
|
+
|
|
6562
|
+
def remove_repeated_trades_from_array(self, input):
|
|
6475
6563
|
uniqueResult = {}
|
|
6476
6564
|
for i in range(0, len(input)):
|
|
6477
6565
|
entry = input[i]
|
|
6478
6566
|
id = self.safe_string(entry, 'id')
|
|
6479
|
-
if id is
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6567
|
+
if id is None:
|
|
6568
|
+
price = self.safe_string(entry, 'price')
|
|
6569
|
+
amount = self.safe_string(entry, 'amount')
|
|
6570
|
+
timestamp = self.safe_string(entry, 'timestamp')
|
|
6571
|
+
side = self.safe_string(entry, 'side')
|
|
6572
|
+
# unique trade identifier
|
|
6573
|
+
id = 't_' + str(timestamp) + '_' + side + '_' + price + '_' + amount
|
|
6574
|
+
if id is not None and not (id in uniqueResult):
|
|
6575
|
+
uniqueResult[id] = entry
|
|
6487
6576
|
values = list(uniqueResult.values())
|
|
6488
|
-
|
|
6489
|
-
if valuesLength > 0:
|
|
6490
|
-
return values
|
|
6491
|
-
return input
|
|
6577
|
+
return values
|
|
6492
6578
|
|
|
6493
6579
|
def handle_until_option(self, key: str, request, params, multiplier=1):
|
|
6494
6580
|
until = self.safe_integer_2(params, 'until', 'till')
|
gate/ccxt/gate.py
CHANGED
|
@@ -1484,6 +1484,10 @@ class gate(Exchange, ImplicitAPI):
|
|
|
1484
1484
|
takerPercent = self.safe_string(market, 'taker_fee_rate')
|
|
1485
1485
|
makerPercent = self.safe_string(market, 'maker_fee_rate', takerPercent)
|
|
1486
1486
|
isLinear = quote == settle
|
|
1487
|
+
contractSize = self.safe_string(market, 'quanto_multiplier')
|
|
1488
|
+
# exception only for one market: https://api.gateio.ws/api/v4/futures/btc/contracts
|
|
1489
|
+
if contractSize == '0':
|
|
1490
|
+
contractSize = '1' # 1 USD in WEB: https://i.imgur.com/MBBUI04.png
|
|
1487
1491
|
return {
|
|
1488
1492
|
'id': id,
|
|
1489
1493
|
'symbol': symbol,
|
|
@@ -1505,7 +1509,7 @@ class gate(Exchange, ImplicitAPI):
|
|
|
1505
1509
|
'inverse': not isLinear,
|
|
1506
1510
|
'taker': self.parse_number(Precise.string_div(takerPercent, '100')), # Fee is in %, so divide by 100
|
|
1507
1511
|
'maker': self.parse_number(Precise.string_div(makerPercent, '100')),
|
|
1508
|
-
'contractSize': self.
|
|
1512
|
+
'contractSize': self.parse_number(contractSize),
|
|
1509
1513
|
'expiry': expiry,
|
|
1510
1514
|
'expiryDatetime': self.iso8601(expiry),
|
|
1511
1515
|
'strike': None,
|
|
@@ -1818,9 +1822,9 @@ class gate(Exchange, ImplicitAPI):
|
|
|
1818
1822
|
partFirst = self.safe_string(parts, 0)
|
|
1819
1823
|
# if there's an underscore then the second part is always the chain name(except the _OLD suffix)
|
|
1820
1824
|
currencyName = currencyId if currencyId.endswith('_OLD') else partFirst
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
tradeDisabled =
|
|
1825
|
+
withdrawDisabled = self.safe_bool(entry, 'withdraw_disabled', False)
|
|
1826
|
+
depositDisabled = self.safe_bool(entry, 'deposit_disabled', False)
|
|
1827
|
+
tradeDisabled = self.safe_bool(entry, 'trade_disabled', False)
|
|
1824
1828
|
precision = self.parse_number('0.0001') # temporary safe default, because no value provided from API
|
|
1825
1829
|
code = self.safe_currency_code(currencyName)
|
|
1826
1830
|
# check leveraged tokens(e.g. BTC3S, ETH5L)
|
|
@@ -1848,8 +1852,8 @@ class gate(Exchange, ImplicitAPI):
|
|
|
1848
1852
|
},
|
|
1849
1853
|
},
|
|
1850
1854
|
'active': not tradeDisabled,
|
|
1851
|
-
'deposit':
|
|
1852
|
-
'withdraw':
|
|
1855
|
+
'deposit': not depositDisabled,
|
|
1856
|
+
'withdraw': not withdrawDisabled,
|
|
1853
1857
|
'fee': None,
|
|
1854
1858
|
'precision': precision,
|
|
1855
1859
|
}
|
|
@@ -5719,7 +5723,7 @@ class gate(Exchange, ImplicitAPI):
|
|
|
5719
5723
|
#
|
|
5720
5724
|
return self.parse_position(response, market)
|
|
5721
5725
|
|
|
5722
|
-
def fetch_positions(self, symbols: Strings = None, params={}):
|
|
5726
|
+
def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
|
5723
5727
|
"""
|
|
5724
5728
|
fetch all open positions
|
|
5725
5729
|
|
|
@@ -6365,7 +6369,7 @@ class gate(Exchange, ImplicitAPI):
|
|
|
6365
6369
|
queryString = self.urlencode(query)
|
|
6366
6370
|
# https://github.com/ccxt/ccxt/issues/25570
|
|
6367
6371
|
if queryString.find('currencies=') >= 0 and queryString.find('%2C') >= 0:
|
|
6368
|
-
queryString = queryString.replace('%
|
|
6372
|
+
queryString = queryString.replace('%2C', ',')
|
|
6369
6373
|
url += '?' + queryString
|
|
6370
6374
|
if method == 'PATCH':
|
|
6371
6375
|
body = self.json(query)
|
gate/ccxt/pro/__init__.py
CHANGED
|
@@ -8,7 +8,7 @@ sys.modules['ccxt'] = ccxt_module
|
|
|
8
8
|
|
|
9
9
|
# ----------------------------------------------------------------------------
|
|
10
10
|
|
|
11
|
-
__version__ = '4.4.
|
|
11
|
+
__version__ = '4.4.78'
|
|
12
12
|
|
|
13
13
|
# ----------------------------------------------------------------------------
|
|
14
14
|
|
|
@@ -16,7 +16,6 @@ from ccxt.async_support.base.exchange import Exchange # noqa: F401
|
|
|
16
16
|
|
|
17
17
|
# CCXT Pro exchanges (now this is mainly used for importing exchanges in WS tests)
|
|
18
18
|
|
|
19
|
-
from ccxt.pro.bitfinex1 import bitfinex1 # noqa: F401
|
|
20
19
|
from ccxt.pro.gate import gate # noqa: F401
|
|
21
20
|
|
|
22
|
-
exchanges = [ '
|
|
21
|
+
exchanges = [ 'gate',]
|
gate/ccxt/pro/gate.py
CHANGED
|
@@ -1178,8 +1178,28 @@ class gate(gateAsync):
|
|
|
1178
1178
|
for i in range(0, len(data)):
|
|
1179
1179
|
rawPosition = data[i]
|
|
1180
1180
|
position = self.parse_position(rawPosition)
|
|
1181
|
-
|
|
1182
|
-
|
|
1181
|
+
symbol = self.safe_string(position, 'symbol')
|
|
1182
|
+
side = self.safe_string(position, 'side')
|
|
1183
|
+
# Control when position is closed no side is returned
|
|
1184
|
+
if side is None:
|
|
1185
|
+
prevLongPosition = self.safe_dict(cache, symbol + 'long')
|
|
1186
|
+
if prevLongPosition is not None:
|
|
1187
|
+
position['side'] = prevLongPosition['side']
|
|
1188
|
+
newPositions.append(position)
|
|
1189
|
+
cache.append(position)
|
|
1190
|
+
prevShortPosition = self.safe_dict(cache, symbol + 'short')
|
|
1191
|
+
if prevShortPosition is not None:
|
|
1192
|
+
position['side'] = prevShortPosition['side']
|
|
1193
|
+
newPositions.append(position)
|
|
1194
|
+
cache.append(position)
|
|
1195
|
+
# if no prev position is found, default to long
|
|
1196
|
+
if prevLongPosition is None and prevShortPosition is None:
|
|
1197
|
+
position['side'] = 'long'
|
|
1198
|
+
newPositions.append(position)
|
|
1199
|
+
cache.append(position)
|
|
1200
|
+
else:
|
|
1201
|
+
newPositions.append(position)
|
|
1202
|
+
cache.append(position)
|
|
1183
1203
|
messageHashes = self.find_message_hashes(client, type + ':positions::')
|
|
1184
1204
|
for i in range(0, len(messageHashes)):
|
|
1185
1205
|
messageHash = messageHashes[i]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gate-io-api
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.25
|
|
4
4
|
Summary: gate crypto exchange api client
|
|
5
5
|
Project-URL: Homepage, https://github.com/ccxt/ccxt
|
|
6
6
|
Project-URL: Issues, https://github.com/ccxt/ccxt
|
|
@@ -20,8 +20,10 @@ Description-Content-Type: text/markdown
|
|
|
20
20
|
# gate-python
|
|
21
21
|
Python SDK (sync and async) for Gate cryptocurrency exchange with Rest and WS capabilities.
|
|
22
22
|
|
|
23
|
-
You can check the SDK docs here: [SDK](https://docs.ccxt.com/#/exchanges/gate)
|
|
24
|
-
You can check Gate's docs here: [Docs](https://www.google.com/search?q=google+gate+cryptocurrency+exchange+api+docs)
|
|
23
|
+
- You can check the SDK docs here: [SDK](https://docs.ccxt.com/#/exchanges/gate)
|
|
24
|
+
- You can check Gate's docs here: [Docs](https://www.google.com/search?q=google+gate+cryptocurrency+exchange+api+docs)
|
|
25
|
+
- Github repo: https://github.com/ccxt/gate-python
|
|
26
|
+
- Pypi package: https://pypi.org/project/gate-io-api
|
|
25
27
|
|
|
26
28
|
|
|
27
29
|
## Installation
|
|
@@ -44,6 +46,8 @@ def main():
|
|
|
44
46
|
#
|
|
45
47
|
# balance = instance.fetch_balance()
|
|
46
48
|
# order = instance.create_order("BTC/USDC", "limit", "buy", 1, 100000)
|
|
49
|
+
|
|
50
|
+
main()
|
|
47
51
|
```
|
|
48
52
|
|
|
49
53
|
### Async
|
|
@@ -92,6 +96,8 @@ async def main():
|
|
|
92
96
|
|
|
93
97
|
# once you are done with the exchange
|
|
94
98
|
await instance.close()
|
|
99
|
+
|
|
100
|
+
asyncio.run(main())
|
|
95
101
|
```
|
|
96
102
|
|
|
97
103
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
gate/__init__.py,sha256=rmRavmagjlyk7Z5zGWWJiY8tfYIPsk04hRzC4SYJOzA,222
|
|
2
|
-
gate/ccxt/__init__.py,sha256=
|
|
3
|
-
gate/ccxt/gate.py,sha256=
|
|
2
|
+
gate/ccxt/__init__.py,sha256=5kn89eZZbtA5iLQ6o8NihvT9aPiq-D2_6kYPV1eI8co,6044
|
|
3
|
+
gate/ccxt/gate.py,sha256=NsqL92pBgTUB0cc1y0sWZVScgLSWje98WPO7MKkKtUI,351150
|
|
4
4
|
gate/ccxt/abstract/gate.py,sha256=MrRMycFEpZKJ6yC7qi0p_qcwZtU9WJi5bBbVllskGoA,45044
|
|
5
|
-
gate/ccxt/async_support/__init__.py,sha256=
|
|
6
|
-
gate/ccxt/async_support/gate.py,sha256=
|
|
5
|
+
gate/ccxt/async_support/__init__.py,sha256=30d1bO0N5-cClHSHoGslbnPu42duDvUx8P2Hw_Y-ioE,4777
|
|
6
|
+
gate/ccxt/async_support/gate.py,sha256=pYpJtFpqydeVZu-BZrNhS24SWh4NhOCFhh-koFgDU2o,353109
|
|
7
7
|
gate/ccxt/async_support/base/__init__.py,sha256=aVYSsFi--b4InRs9zDN_wtCpj8odosAB726JdUHavrk,67
|
|
8
|
-
gate/ccxt/async_support/base/exchange.py,sha256=
|
|
8
|
+
gate/ccxt/async_support/base/exchange.py,sha256=AOQnGV5CUYT2fOCko3E6JqYxa_s8_QxHDdBxbqUUOgU,117255
|
|
9
9
|
gate/ccxt/async_support/base/throttler.py,sha256=tvDVcdRUVYi8fZRlEcnqtgzcgB_KMUMRs5Pu8tuU-tU,1847
|
|
10
10
|
gate/ccxt/async_support/base/ws/__init__.py,sha256=uockzpLuwntKGZbs5EOWFe-Zg-k6Cj7GhNJLc_RX0so,1791
|
|
11
11
|
gate/ccxt/async_support/base/ws/aiohttp_client.py,sha256=Y5HxAVXyyYduj6b6SbbUZETlq3GrVMzrkW1r-TMgpb8,6329
|
|
@@ -19,11 +19,11 @@ gate/ccxt/async_support/base/ws/order_book_side.py,sha256=GhnGUt78pJ-AYL_Dq9prod
|
|
|
19
19
|
gate/ccxt/base/__init__.py,sha256=eTx1OE3HJjspFUQjGm6LBhaQiMKJnXjkdP-JUXknyQ0,1320
|
|
20
20
|
gate/ccxt/base/decimal_to_precision.py,sha256=fgWRBzRTtsf3r2INyS4f7WHlzgjB5YM1ekiwqD21aac,6634
|
|
21
21
|
gate/ccxt/base/errors.py,sha256=MvCrL_sAM3de616T6RE0PSxiF2xV6Qqz5b1y1ghidbk,4888
|
|
22
|
-
gate/ccxt/base/exchange.py,sha256=
|
|
22
|
+
gate/ccxt/base/exchange.py,sha256=R0StVeXIxmXvA73by-Gqx70tT7wbJMNuenrVXgoe0Dk,326255
|
|
23
23
|
gate/ccxt/base/precise.py,sha256=koce64Yrp6vFbGijJtUt-QQ6XhJgeGTCksZ871FPp_A,8886
|
|
24
24
|
gate/ccxt/base/types.py,sha256=SfxIKDSsxP7MPHWiOVI965Nr5NSEPpAno5fuveTRi3w,11423
|
|
25
|
-
gate/ccxt/pro/__init__.py,sha256=
|
|
26
|
-
gate/ccxt/pro/gate.py,sha256=
|
|
25
|
+
gate/ccxt/pro/__init__.py,sha256=VzyC4lcVsFr67N3ryM_Xtj3VuFmLMzVBvqeFCiBmLhk,615
|
|
26
|
+
gate/ccxt/pro/gate.py,sha256=TImMphR9V8h9xqDJ541s3zb4NOppfLDc-XoBkntT1nA,89399
|
|
27
27
|
gate/ccxt/static_dependencies/README.md,sha256=3TCvhhn09_Cqf9BDDpao1V7EfKHDpQ6k9oWRsLFixpU,18
|
|
28
28
|
gate/ccxt/static_dependencies/__init__.py,sha256=tzFje8cloqmiIE6kola3EaYC0SnD1izWnri69hzHsSw,168
|
|
29
29
|
gate/ccxt/static_dependencies/ecdsa/__init__.py,sha256=Xaj0G79BLtBt2YZcOOMV8qOlQZ7fIJznNiHhiEEZfQA,594
|
|
@@ -283,6 +283,6 @@ gate/ccxt/static_dependencies/toolz/curried/exceptions.py,sha256=gKFOHDIayAWnX2u
|
|
|
283
283
|
gate/ccxt/static_dependencies/toolz/curried/operator.py,sha256=ML92mknkAwzBl2NCm-4werSUmJEtSHNY9NSzhseNM9s,525
|
|
284
284
|
gate/ccxt/static_dependencies/typing_inspect/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
285
285
|
gate/ccxt/static_dependencies/typing_inspect/typing_inspect.py,sha256=5gIWomLPfuDpgd3gX1GlnX0MuXM3VorR4j2W2qXORiQ,28269
|
|
286
|
-
gate_io_api-0.0.
|
|
287
|
-
gate_io_api-0.0.
|
|
288
|
-
gate_io_api-0.0.
|
|
286
|
+
gate_io_api-0.0.25.dist-info/METADATA,sha256=Tvcd-UBWpsd6w7t6MklN9_JkrheLIqAVC2NiJafIvWM,26789
|
|
287
|
+
gate_io_api-0.0.25.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
288
|
+
gate_io_api-0.0.25.dist-info/RECORD,,
|
|
File without changes
|