ccxt 4.4.86__py2.py3-none-any.whl → 4.4.88__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 +5 -1
- ccxt/abstract/modetrade.py +119 -0
- ccxt/abstract/okxus.py +349 -0
- ccxt/async_support/__init__.py +5 -1
- ccxt/async_support/base/exchange.py +8 -5
- ccxt/async_support/binance.py +1 -1
- ccxt/async_support/bitteam.py +31 -0
- ccxt/async_support/bybit.py +19 -57
- ccxt/async_support/coinmetro.py +3 -0
- ccxt/async_support/gate.py +91 -73
- ccxt/async_support/htx.py +10 -8
- ccxt/async_support/hyperliquid.py +32 -16
- ccxt/async_support/kraken.py +5 -8
- ccxt/async_support/modetrade.py +2727 -0
- ccxt/async_support/okx.py +90 -3
- ccxt/async_support/okxus.py +54 -0
- ccxt/async_support/paradex.py +4 -1
- ccxt/async_support/phemex.py +4 -6
- ccxt/async_support/poloniex.py +172 -159
- ccxt/async_support/probit.py +18 -47
- ccxt/async_support/timex.py +5 -10
- ccxt/async_support/vertex.py +3 -4
- ccxt/async_support/whitebit.py +41 -11
- ccxt/async_support/woo.py +101 -75
- ccxt/async_support/woofipro.py +25 -20
- ccxt/async_support/xt.py +31 -41
- ccxt/base/exchange.py +13 -9
- ccxt/binance.py +1 -1
- ccxt/bitteam.py +31 -0
- ccxt/bybit.py +19 -57
- ccxt/coinmetro.py +3 -0
- ccxt/gate.py +91 -73
- ccxt/htx.py +10 -8
- ccxt/hyperliquid.py +32 -16
- ccxt/kraken.py +5 -8
- ccxt/modetrade.py +2727 -0
- ccxt/okx.py +90 -3
- ccxt/okxus.py +54 -0
- ccxt/paradex.py +4 -1
- ccxt/phemex.py +4 -6
- ccxt/poloniex.py +172 -159
- ccxt/pro/__init__.py +69 -1
- ccxt/pro/modetrade.py +1271 -0
- ccxt/pro/okxus.py +38 -0
- ccxt/probit.py +18 -47
- ccxt/test/tests_async.py +17 -1
- ccxt/test/tests_sync.py +17 -1
- ccxt/timex.py +5 -10
- ccxt/vertex.py +3 -4
- ccxt/whitebit.py +41 -11
- ccxt/woo.py +100 -75
- ccxt/woofipro.py +24 -20
- ccxt/xt.py +31 -41
- {ccxt-4.4.86.dist-info → ccxt-4.4.88.dist-info}/METADATA +18 -6
- {ccxt-4.4.86.dist-info → ccxt-4.4.88.dist-info}/RECORD +58 -50
- {ccxt-4.4.86.dist-info → ccxt-4.4.88.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.86.dist-info → ccxt-4.4.88.dist-info}/WHEEL +0 -0
- {ccxt-4.4.86.dist-info → ccxt-4.4.88.dist-info}/top_level.txt +0 -0
ccxt/okx.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.okx import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Account, Any, Balances, BorrowInterest, Conversion, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, DepositAddress, Greeks, Int, LedgerEntry, Leverage, LeverageTier, LongShortRatio, MarginModification, Market, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, MarketInterface, TransferEntry
|
9
|
+
from ccxt.base.types import Account, Any, Balances, BorrowInterest, Conversion, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, DepositAddress, Greeks, Int, LedgerEntry, Leverage, LeverageTier, LongShortRatio, MarginModification, Market, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, OpenInterests, Trade, TradingFeeInterface, Transaction, MarketInterface, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -108,7 +108,7 @@ class okx(Exchange, ImplicitAPI):
|
|
108
108
|
'fetchFundingIntervals': False,
|
109
109
|
'fetchFundingRate': True,
|
110
110
|
'fetchFundingRateHistory': True,
|
111
|
-
'fetchFundingRates':
|
111
|
+
'fetchFundingRates': True,
|
112
112
|
'fetchGreeks': True,
|
113
113
|
'fetchIndexOHLCV': True,
|
114
114
|
'fetchIsolatedBorrowRate': False,
|
@@ -131,6 +131,7 @@ class okx(Exchange, ImplicitAPI):
|
|
131
131
|
'fetchOHLCV': True,
|
132
132
|
'fetchOpenInterest': True,
|
133
133
|
'fetchOpenInterestHistory': True,
|
134
|
+
'fetchOpenInterests': True,
|
134
135
|
'fetchOpenOrder': None,
|
135
136
|
'fetchOpenOrders': True,
|
136
137
|
'fetchOption': True,
|
@@ -5984,7 +5985,7 @@ class okx(Exchange, ImplicitAPI):
|
|
5984
5985
|
nextFundingRate = self.safe_number(contract, 'nextFundingRate')
|
5985
5986
|
fundingTime = self.safe_integer(contract, 'fundingTime')
|
5986
5987
|
fundingTimeString = self.safe_string(contract, 'fundingTime')
|
5987
|
-
nextFundingTimeString = self.safe_string(contract, '
|
5988
|
+
nextFundingTimeString = self.safe_string(contract, 'nextFundingTime')
|
5988
5989
|
millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
|
5989
5990
|
# https://www.okx.com/support/hc/en-us/articles/360053909272-Ⅸ-Introduction-to-perpetual-swap-funding-fee
|
5990
5991
|
# > The current interest is 0.
|
@@ -6069,6 +6070,39 @@ class okx(Exchange, ImplicitAPI):
|
|
6069
6070
|
entry = self.safe_dict(data, 0, {})
|
6070
6071
|
return self.parse_funding_rate(entry, market)
|
6071
6072
|
|
6073
|
+
def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
|
6074
|
+
"""
|
6075
|
+
fetches the current funding rates for multiple symbols
|
6076
|
+
|
6077
|
+
https://www.okx.com/docs-v5/en/#public-data-rest-api-get-funding-rate
|
6078
|
+
|
6079
|
+
:param str[] symbols: unified market symbols
|
6080
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
6081
|
+
:returns dict: a dictionary of `funding rates structure <https://docs.ccxt.com/#/?id=funding-rates-structure>`
|
6082
|
+
"""
|
6083
|
+
self.load_markets()
|
6084
|
+
symbols = self.market_symbols(symbols, 'swap', True)
|
6085
|
+
request: dict = {'instId': 'ANY'}
|
6086
|
+
response = self.publicGetPublicFundingRate(self.extend(request, params))
|
6087
|
+
#
|
6088
|
+
# {
|
6089
|
+
# "code": "0",
|
6090
|
+
# "data": [
|
6091
|
+
# {
|
6092
|
+
# "fundingRate": "0.00027815",
|
6093
|
+
# "fundingTime": "1634256000000",
|
6094
|
+
# "instId": "BTC-USD-SWAP",
|
6095
|
+
# "instType": "SWAP",
|
6096
|
+
# "nextFundingRate": "0.00017",
|
6097
|
+
# "nextFundingTime": "1634284800000"
|
6098
|
+
# }
|
6099
|
+
# ],
|
6100
|
+
# "msg": ""
|
6101
|
+
# }
|
6102
|
+
#
|
6103
|
+
data = self.safe_list(response, 'data', [])
|
6104
|
+
return self.parse_funding_rates(data, symbols)
|
6105
|
+
|
6072
6106
|
def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
6073
6107
|
"""
|
6074
6108
|
fetch the history of funding payments paid and received on self account
|
@@ -7026,6 +7060,59 @@ class okx(Exchange, ImplicitAPI):
|
|
7026
7060
|
data = self.safe_list(response, 'data', [])
|
7027
7061
|
return self.parse_open_interest(data[0], market)
|
7028
7062
|
|
7063
|
+
def fetch_open_interests(self, symbols: Strings = None, params={}) -> OpenInterests:
|
7064
|
+
"""
|
7065
|
+
Retrieves the open interests of some currencies
|
7066
|
+
|
7067
|
+
https://www.okx.com/docs-v5/en/#rest-api-public-data-get-open-interest
|
7068
|
+
|
7069
|
+
:param str[] symbols: Unified CCXT market symbols
|
7070
|
+
:param dict [params]: exchange specific parameters
|
7071
|
+
:param str params['instType']: Instrument type, options: 'SWAP', 'FUTURES', 'OPTION', default to 'SWAP'
|
7072
|
+
:param str params['uly']: Underlying, Applicable to FUTURES/SWAP/OPTION, if instType is 'OPTION', either uly or instFamily is required
|
7073
|
+
:param str params['instFamily']: Instrument family, Applicable to FUTURES/SWAP/OPTION, if instType is 'OPTION', either uly or instFamily is required
|
7074
|
+
:returns dict: an dictionary of `open interest structures <https://docs.ccxt.com/#/?id=open-interest-structure>`
|
7075
|
+
"""
|
7076
|
+
self.load_markets()
|
7077
|
+
symbols = self.market_symbols(symbols, None, True, True)
|
7078
|
+
market = None
|
7079
|
+
if symbols is not None:
|
7080
|
+
market = self.market(symbols[0])
|
7081
|
+
marketType = None
|
7082
|
+
marketType, params = self.handle_sub_type_and_params('fetchOpenInterests', market, params, 'swap')
|
7083
|
+
instType = 'SWAP'
|
7084
|
+
if marketType == 'future':
|
7085
|
+
instType = 'FUTURES'
|
7086
|
+
elif instType == 'option':
|
7087
|
+
instType = 'OPTION'
|
7088
|
+
request: dict = {'instType': instType}
|
7089
|
+
uly = self.safe_string(params, 'uly')
|
7090
|
+
if uly is not None:
|
7091
|
+
request['uly'] = uly
|
7092
|
+
instFamily = self.safe_string(params, 'instFamily')
|
7093
|
+
if instFamily is not None:
|
7094
|
+
request['instFamily'] = instFamily
|
7095
|
+
if instType == 'OPTION' and uly is None and instFamily is None:
|
7096
|
+
raise BadRequest(self.id + ' fetchOpenInterests() requires either uly or instFamily parameter for OPTION markets')
|
7097
|
+
response = self.publicGetPublicOpenInterest(self.extend(request, params))
|
7098
|
+
#
|
7099
|
+
# {
|
7100
|
+
# "code": "0",
|
7101
|
+
# "data": [
|
7102
|
+
# {
|
7103
|
+
# "instId": "BTC-USDT-SWAP",
|
7104
|
+
# "instType": "SWAP",
|
7105
|
+
# "oi": "2125419",
|
7106
|
+
# "oiCcy": "21254.19",
|
7107
|
+
# "ts": "1664005108969"
|
7108
|
+
# }
|
7109
|
+
# ],
|
7110
|
+
# "msg": ""
|
7111
|
+
# }
|
7112
|
+
#
|
7113
|
+
data = self.safe_list(response, 'data', [])
|
7114
|
+
return self.parse_open_interests(data, symbols)
|
7115
|
+
|
7029
7116
|
def fetch_open_interest_history(self, symbol: str, timeframe='1d', since: Int = None, limit: Int = None, params={}):
|
7030
7117
|
"""
|
7031
7118
|
Retrieves the open interest history of a currency
|
ccxt/okxus.py
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
4
|
+
# https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
5
|
+
|
6
|
+
from ccxt.okx import okx
|
7
|
+
from ccxt.abstract.okxus import ImplicitAPI
|
8
|
+
from ccxt.base.types import Any
|
9
|
+
|
10
|
+
|
11
|
+
class okxus(okx, ImplicitAPI):
|
12
|
+
|
13
|
+
def describe(self) -> Any:
|
14
|
+
return self.deep_extend(super(okxus, self).describe(), {
|
15
|
+
'id': 'okxus',
|
16
|
+
'name': 'OKX(US)',
|
17
|
+
'certified': False,
|
18
|
+
'pro': True,
|
19
|
+
'hostname': 'us.okx.com',
|
20
|
+
'urls': {
|
21
|
+
'logo': 'https://user-images.githubusercontent.com/1294454/152485636-38b19e4a-bece-4dec-979a-5982859ffc04.jpg',
|
22
|
+
'api': {
|
23
|
+
'rest': 'https://{hostname}',
|
24
|
+
},
|
25
|
+
'www': 'https://app.okx.com',
|
26
|
+
'doc': 'https://app.okx.com/docs-v5/en/#overview',
|
27
|
+
'fees': 'https://app.okx.com/pages/products/fees.html',
|
28
|
+
'referral': {
|
29
|
+
'url': 'https://www.app.okx.com/join/CCXT2023',
|
30
|
+
'discount': 0.2,
|
31
|
+
},
|
32
|
+
'test': {
|
33
|
+
'rest': 'https://{hostname}',
|
34
|
+
},
|
35
|
+
},
|
36
|
+
'has': {
|
37
|
+
'CORS': None,
|
38
|
+
'spot': True,
|
39
|
+
'margin': None,
|
40
|
+
'swap': False,
|
41
|
+
'future': False,
|
42
|
+
'option': False,
|
43
|
+
},
|
44
|
+
'features': {
|
45
|
+
'swap': {
|
46
|
+
'linear': None,
|
47
|
+
'inverse': None,
|
48
|
+
},
|
49
|
+
'future': {
|
50
|
+
'linear': None,
|
51
|
+
'inverse': None,
|
52
|
+
},
|
53
|
+
},
|
54
|
+
})
|
ccxt/paradex.py
CHANGED
@@ -1248,7 +1248,10 @@ class paradex(Exchange, ImplicitAPI):
|
|
1248
1248
|
cancelReason = self.safe_string(order, 'cancel_reason')
|
1249
1249
|
status = self.safe_string(order, 'status')
|
1250
1250
|
if cancelReason is not None:
|
1251
|
-
|
1251
|
+
if cancelReason == 'NOT_ENOUGH_MARGIN':
|
1252
|
+
status = 'rejected'
|
1253
|
+
else:
|
1254
|
+
status = 'canceled'
|
1252
1255
|
side = self.safe_string_lower(order, 'side')
|
1253
1256
|
average = self.omit_zero(self.safe_string(order, 'avg_fill_price'))
|
1254
1257
|
remaining = self.omit_zero(self.safe_string(order, 'remaining_size'))
|
ccxt/phemex.py
CHANGED
@@ -1130,9 +1130,7 @@ class phemex(Exchange, ImplicitAPI):
|
|
1130
1130
|
for i in range(0, len(currencies)):
|
1131
1131
|
currency = currencies[i]
|
1132
1132
|
id = self.safe_string(currency, 'currency')
|
1133
|
-
name = self.safe_string(currency, 'name')
|
1134
1133
|
code = self.safe_currency_code(id)
|
1135
|
-
status = self.safe_string(currency, 'status')
|
1136
1134
|
valueScaleString = self.safe_string(currency, 'valueScale')
|
1137
1135
|
valueScale = int(valueScaleString)
|
1138
1136
|
minValueEv = self.safe_string(currency, 'minValueEv')
|
@@ -1145,12 +1143,12 @@ class phemex(Exchange, ImplicitAPI):
|
|
1145
1143
|
precision = self.parse_number(precisionString)
|
1146
1144
|
minAmount = self.parse_number(Precise.string_mul(minValueEv, precisionString))
|
1147
1145
|
maxAmount = self.parse_number(Precise.string_mul(maxValueEv, precisionString))
|
1148
|
-
result[code] = {
|
1146
|
+
result[code] = self.safe_currency_structure({
|
1149
1147
|
'id': id,
|
1150
1148
|
'info': currency,
|
1151
1149
|
'code': code,
|
1152
|
-
'name': name,
|
1153
|
-
'active': status == 'Listed',
|
1150
|
+
'name': self.safe_string(currency, 'name'),
|
1151
|
+
'active': self.safe_string(currency, 'status') == 'Listed',
|
1154
1152
|
'deposit': None,
|
1155
1153
|
'withdraw': None,
|
1156
1154
|
'fee': None,
|
@@ -1168,7 +1166,7 @@ class phemex(Exchange, ImplicitAPI):
|
|
1168
1166
|
'valueScale': valueScale,
|
1169
1167
|
'networks': None,
|
1170
1168
|
'type': 'crypto',
|
1171
|
-
}
|
1169
|
+
})
|
1172
1170
|
return result
|
1173
1171
|
|
1174
1172
|
def custom_parse_bid_ask(self, bidask, priceKey=0, amountKey=1, market: Market = None):
|
ccxt/poloniex.py
CHANGED
@@ -321,6 +321,11 @@ class poloniex(Exchange, ImplicitAPI):
|
|
321
321
|
'BEP20': 'BSC',
|
322
322
|
'ERC20': 'ETH',
|
323
323
|
'TRC20': 'TRON',
|
324
|
+
'TRX': 'TRON',
|
325
|
+
},
|
326
|
+
'networksById': {
|
327
|
+
'TRX': 'TRC20',
|
328
|
+
'TRON': 'TRC20',
|
324
329
|
},
|
325
330
|
'limits': {
|
326
331
|
'cost': {
|
@@ -1148,102 +1153,103 @@ class poloniex(Exchange, ImplicitAPI):
|
|
1148
1153
|
response = self.publicGetCurrencies(self.extend(params, {'includeMultiChainCurrencies': True}))
|
1149
1154
|
#
|
1150
1155
|
# [
|
1151
|
-
#
|
1152
|
-
#
|
1153
|
-
#
|
1154
|
-
#
|
1155
|
-
#
|
1156
|
-
#
|
1157
|
-
#
|
1158
|
-
#
|
1159
|
-
#
|
1160
|
-
#
|
1161
|
-
#
|
1162
|
-
#
|
1163
|
-
#
|
1164
|
-
#
|
1165
|
-
#
|
1166
|
-
#
|
1167
|
-
#
|
1168
|
-
#
|
1169
|
-
#
|
1170
|
-
#
|
1171
|
-
#
|
1156
|
+
# {
|
1157
|
+
# "USDT": {
|
1158
|
+
# "id": 214,
|
1159
|
+
# "name": "Tether USD",
|
1160
|
+
# "description": "Sweep to Main Account",
|
1161
|
+
# "type": "address",
|
1162
|
+
# "withdrawalFee": "0.00000000",
|
1163
|
+
# "minConf": 2,
|
1164
|
+
# "depositAddress": null,
|
1165
|
+
# "blockchain": "OMNI",
|
1166
|
+
# "delisted": False,
|
1167
|
+
# "tradingState": "NORMAL",
|
1168
|
+
# "walletState": "DISABLED",
|
1169
|
+
# "walletDepositState": "DISABLED",
|
1170
|
+
# "walletWithdrawalState": "DISABLED",
|
1171
|
+
# "supportCollateral": True,
|
1172
|
+
# "supportBorrow": True,
|
1173
|
+
# "parentChain": null,
|
1174
|
+
# "isMultiChain": True,
|
1175
|
+
# "isChildChain": False,
|
1176
|
+
# "childChains": [
|
1177
|
+
# "USDTBSC",
|
1178
|
+
# "USDTETH",
|
1179
|
+
# "USDTSOL",
|
1180
|
+
# "USDTTRON"
|
1181
|
+
# ]
|
1182
|
+
# }
|
1183
|
+
# },
|
1184
|
+
# ...
|
1185
|
+
# {
|
1186
|
+
# "USDTBSC": {
|
1187
|
+
# "id": 582,
|
1188
|
+
# "name": "Binance-Peg BSC-USD",
|
1189
|
+
# "description": "Sweep to Main Account",
|
1190
|
+
# "type": "address",
|
1191
|
+
# "withdrawalFee": "0.00000000",
|
1192
|
+
# "minConf": 15,
|
1193
|
+
# "depositAddress": null,
|
1194
|
+
# "blockchain": "BSC",
|
1195
|
+
# "delisted": False,
|
1196
|
+
# "tradingState": "OFFLINE",
|
1197
|
+
# "walletState": "ENABLED",
|
1198
|
+
# "walletDepositState": "ENABLED",
|
1199
|
+
# "walletWithdrawalState": "DISABLED",
|
1200
|
+
# "supportCollateral": False,
|
1201
|
+
# "supportBorrow": False,
|
1202
|
+
# "parentChain": "USDT",
|
1203
|
+
# "isMultiChain": True,
|
1204
|
+
# "isChildChain": True,
|
1205
|
+
# "childChains": []
|
1206
|
+
# }
|
1207
|
+
# },
|
1208
|
+
# ...
|
1172
1209
|
# ]
|
1173
1210
|
#
|
1174
1211
|
result: dict = {}
|
1212
|
+
# poloniex has a complicated structure of currencies, so we handle them differently
|
1213
|
+
# at first, turn the response into a normal dictionary
|
1214
|
+
currenciesDict = {}
|
1175
1215
|
for i in range(0, len(response)):
|
1176
|
-
item = self.
|
1216
|
+
item = self.safe_dict(response, i)
|
1177
1217
|
ids = list(item.keys())
|
1178
|
-
id = self.
|
1179
|
-
|
1218
|
+
id = self.safe_string(ids, 0)
|
1219
|
+
currenciesDict[id] = item[id]
|
1220
|
+
keys = list(currenciesDict.keys())
|
1221
|
+
for i in range(0, len(keys)):
|
1222
|
+
id = keys[i]
|
1223
|
+
entry = currenciesDict[id]
|
1180
1224
|
code = self.safe_currency_code(id)
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
'code': code,
|
1199
|
-
'info': None,
|
1200
|
-
'name': name,
|
1201
|
-
'active': active,
|
1202
|
-
'deposit': depositEnabled,
|
1203
|
-
'withdraw': withdrawEnabled,
|
1204
|
-
'fee': self.parse_number(feeString),
|
1205
|
-
'precision': None,
|
1206
|
-
'type': 'crypto',
|
1207
|
-
'limits': {
|
1208
|
-
'amount': {
|
1209
|
-
'min': None,
|
1210
|
-
'max': None,
|
1211
|
-
},
|
1212
|
-
'deposit': {
|
1213
|
-
'min': None,
|
1214
|
-
'max': None,
|
1215
|
-
},
|
1216
|
-
'withdraw': {
|
1217
|
-
'min': None,
|
1218
|
-
'max': None,
|
1219
|
-
},
|
1220
|
-
},
|
1221
|
-
}
|
1222
|
-
minFeeString = self.safe_string(result[code], 'fee')
|
1223
|
-
if feeString is not None:
|
1224
|
-
minFeeString = feeString if (minFeeString is None) else Precise.string_min(feeString, minFeeString)
|
1225
|
-
depositAvailable = self.safe_value(result[code], 'deposit')
|
1226
|
-
depositAvailable = depositEnabled if (depositEnabled) else depositAvailable
|
1227
|
-
withdrawAvailable = self.safe_value(result[code], 'withdraw')
|
1228
|
-
withdrawAvailable = withdrawEnabled if (withdrawEnabled) else withdrawAvailable
|
1229
|
-
networks = self.safe_value(result[code], 'networks', {})
|
1230
|
-
if networkCode is not None:
|
1225
|
+
# skip childChains, are collected in parentChain loop
|
1226
|
+
if self.safe_bool(entry, 'isChildChain'):
|
1227
|
+
continue
|
1228
|
+
allChainEntries = []
|
1229
|
+
childChains = self.safe_list(entry, 'childChains', [])
|
1230
|
+
if childChains is not None:
|
1231
|
+
for j in range(0, len(childChains)):
|
1232
|
+
childChainId = childChains[j]
|
1233
|
+
childNetworkEntry = self.safe_dict(currenciesDict, childChainId)
|
1234
|
+
allChainEntries.append(childNetworkEntry)
|
1235
|
+
allChainEntries.append(entry)
|
1236
|
+
networks: dict = {}
|
1237
|
+
for j in range(0, len(allChainEntries)):
|
1238
|
+
chainEntry = allChainEntries[j]
|
1239
|
+
networkName = self.safe_string(chainEntry, 'blockchain')
|
1240
|
+
networkCode = self.network_id_to_code(networkName, code)
|
1241
|
+
specialNetworkId = self.safe_string(childChains, j, id) # in case it's primary chain, defeault to ID
|
1231
1242
|
networks[networkCode] = {
|
1232
|
-
'info':
|
1233
|
-
'id':
|
1243
|
+
'info': chainEntry,
|
1244
|
+
'id': specialNetworkId, # we need self for deposit/withdrawal, instead of friendly name
|
1245
|
+
'numericId': self.safe_integer(chainEntry, 'id'),
|
1234
1246
|
'network': networkCode,
|
1235
|
-
'
|
1236
|
-
'
|
1237
|
-
'
|
1238
|
-
'
|
1239
|
-
'active': active,
|
1240
|
-
'fee': self.parse_number(feeString),
|
1247
|
+
'active': self.safe_bool(chainEntry, 'walletState'),
|
1248
|
+
'deposit': self.safe_string(chainEntry, 'walletDepositState') == 'ENABLED',
|
1249
|
+
'withdraw': self.safe_string(chainEntry, 'walletWithdrawalState') == 'ENABLED',
|
1250
|
+
'fee': self.safe_number(chainEntry, 'withdrawalFee'),
|
1241
1251
|
'precision': None,
|
1242
1252
|
'limits': {
|
1243
|
-
'amount': {
|
1244
|
-
'min': None,
|
1245
|
-
'max': None,
|
1246
|
-
},
|
1247
1253
|
'withdraw': {
|
1248
1254
|
'min': None,
|
1249
1255
|
'max': None,
|
@@ -1254,19 +1260,34 @@ class poloniex(Exchange, ImplicitAPI):
|
|
1254
1260
|
},
|
1255
1261
|
},
|
1256
1262
|
}
|
1257
|
-
result[code]
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1263
|
+
result[code] = self.safe_currency_structure({
|
1264
|
+
'info': entry,
|
1265
|
+
'code': code,
|
1266
|
+
'id': id,
|
1267
|
+
'numericId': self.safe_integer(entry, 'id'),
|
1268
|
+
'type': 'crypto',
|
1269
|
+
'name': self.safe_string(entry, 'name'),
|
1270
|
+
'active': None,
|
1271
|
+
'deposit': None,
|
1272
|
+
'withdraw': None,
|
1273
|
+
'fee': None,
|
1274
|
+
'precision': None,
|
1275
|
+
'limits': {
|
1276
|
+
'amount': {
|
1277
|
+
'min': None,
|
1278
|
+
'max': None,
|
1279
|
+
},
|
1280
|
+
'withdraw': {
|
1281
|
+
'min': None,
|
1282
|
+
'max': None,
|
1283
|
+
},
|
1284
|
+
'deposit': {
|
1285
|
+
'min': None,
|
1286
|
+
'max': None,
|
1287
|
+
},
|
1288
|
+
},
|
1289
|
+
'networks': networks,
|
1290
|
+
})
|
1270
1291
|
return result
|
1271
1292
|
|
1272
1293
|
def fetch_ticker(self, symbol: str, params={}) -> Ticker:
|
@@ -2584,40 +2605,15 @@ class poloniex(Exchange, ImplicitAPI):
|
|
2584
2605
|
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
|
2585
2606
|
"""
|
2586
2607
|
self.load_markets()
|
2587
|
-
currency = self.
|
2588
|
-
|
2589
|
-
'currency': currency['id'],
|
2590
|
-
}
|
2591
|
-
networks = self.safe_value(self.options, 'networks', {})
|
2592
|
-
network = self.safe_string_upper(params, 'network') # self line allows the user to specify either ERC20 or ETH
|
2593
|
-
network = self.safe_string(networks, network, network) # handle ERC20>ETH alias
|
2594
|
-
if network is not None:
|
2595
|
-
request['currency'] = request['currency'] + network # when network the currency need to be changed to currency+network https://docs.poloniex.com/#withdraw on MultiChain Currencies section
|
2596
|
-
params = self.omit(params, 'network')
|
2597
|
-
else:
|
2598
|
-
if currency['id'] == 'USDT':
|
2599
|
-
raise ArgumentsRequired(self.id + ' createDepositAddress requires a network parameter for ' + code + '.')
|
2608
|
+
request, extraParams, currency, networkEntry = self.prepare_request_for_deposit_address(code, params)
|
2609
|
+
params = extraParams
|
2600
2610
|
response = self.privatePostWalletsAddress(self.extend(request, params))
|
2601
2611
|
#
|
2602
2612
|
# {
|
2603
2613
|
# "address" : "0xfxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxf"
|
2604
2614
|
# }
|
2605
2615
|
#
|
2606
|
-
|
2607
|
-
tag: Str = None
|
2608
|
-
self.check_address(address)
|
2609
|
-
if currency is not None:
|
2610
|
-
depositAddress = self.safe_string(currency['info'], 'depositAddress')
|
2611
|
-
if depositAddress is not None:
|
2612
|
-
tag = address
|
2613
|
-
address = depositAddress
|
2614
|
-
return {
|
2615
|
-
'currency': code,
|
2616
|
-
'address': address,
|
2617
|
-
'tag': tag,
|
2618
|
-
'network': network,
|
2619
|
-
'info': response,
|
2620
|
-
}
|
2616
|
+
return self.parse_deposit_address_special(response, currency, networkEntry)
|
2621
2617
|
|
2622
2618
|
def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
|
2623
2619
|
"""
|
@@ -2630,37 +2626,56 @@ class poloniex(Exchange, ImplicitAPI):
|
|
2630
2626
|
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
|
2631
2627
|
"""
|
2632
2628
|
self.load_markets()
|
2633
|
-
currency = self.
|
2634
|
-
|
2635
|
-
'currency': currency['id'],
|
2636
|
-
}
|
2637
|
-
networks = self.safe_value(self.options, 'networks', {})
|
2638
|
-
network = self.safe_string_upper(params, 'network') # self line allows the user to specify either ERC20 or ETH
|
2639
|
-
network = self.safe_string(networks, network, network) # handle ERC20>ETH alias
|
2640
|
-
if network is not None:
|
2641
|
-
request['currency'] = request['currency'] + network # when network the currency need to be changed to currency+network https://docs.poloniex.com/#withdraw on MultiChain Currencies section
|
2642
|
-
params = self.omit(params, 'network')
|
2643
|
-
else:
|
2644
|
-
if currency['id'] == 'USDT':
|
2645
|
-
raise ArgumentsRequired(self.id + ' fetchDepositAddress requires a network parameter for ' + code + '.')
|
2629
|
+
request, extraParams, currency, networkEntry = self.prepare_request_for_deposit_address(code, params)
|
2630
|
+
params = extraParams
|
2646
2631
|
response = self.privateGetWalletsAddresses(self.extend(request, params))
|
2647
2632
|
#
|
2648
2633
|
# {
|
2649
2634
|
# "USDTTRON" : "Txxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxp"
|
2650
2635
|
# }
|
2651
2636
|
#
|
2652
|
-
|
2637
|
+
keys = list(response.keys())
|
2638
|
+
length = len(keys)
|
2639
|
+
if length < 1:
|
2640
|
+
raise ExchangeError(self.id + ' fetchDepositAddress() returned an empty response, you might need to try "createDepositAddress" at first and then use "fetchDepositAddress"')
|
2641
|
+
return self.parse_deposit_address_special(response, currency, networkEntry)
|
2642
|
+
|
2643
|
+
def prepare_request_for_deposit_address(self, code: str, params: dict = {}) -> Any:
|
2644
|
+
if not (code in self.currencies):
|
2645
|
+
raise BadSymbol(self.id + ' fetchDepositAddress(): can not recognize ' + code + ' currency, you might try using unified currency-code and add provide specific "network" parameter, like: fetchDepositAddress("USDT", {"network": "TRC20"})')
|
2646
|
+
currency = self.currency(code)
|
2647
|
+
networkCode = None
|
2648
|
+
networkCode, params = self.handle_network_code_and_params(params)
|
2649
|
+
if networkCode is None:
|
2650
|
+
# we need to know the network to find out the currency-junction
|
2651
|
+
raise ArgumentsRequired(self.id + ' fetchDepositAddress requires a network parameter for ' + code + '.')
|
2652
|
+
exchangeNetworkId = None
|
2653
|
+
networkCode = self.network_id_to_code(networkCode, code)
|
2654
|
+
networkEntry = self.safe_dict(currency['networks'], networkCode)
|
2655
|
+
if networkEntry is not None:
|
2656
|
+
exchangeNetworkId = networkEntry['id']
|
2657
|
+
else:
|
2658
|
+
exchangeNetworkId = networkCode
|
2659
|
+
request = {
|
2660
|
+
'currency': exchangeNetworkId,
|
2661
|
+
}
|
2662
|
+
return [request, params, currency, networkEntry]
|
2663
|
+
|
2664
|
+
def parse_deposit_address_special(self, response, currency, networkEntry) -> DepositAddress:
|
2665
|
+
address = self.safe_string(response, 'address')
|
2666
|
+
if address is None:
|
2667
|
+
address = self.safe_string(response, networkEntry['id'])
|
2653
2668
|
tag: Str = None
|
2654
2669
|
self.check_address(address)
|
2655
|
-
if
|
2656
|
-
depositAddress = self.safe_string(
|
2670
|
+
if networkEntry is not None:
|
2671
|
+
depositAddress = self.safe_string(networkEntry['info'], 'depositAddress')
|
2657
2672
|
if depositAddress is not None:
|
2658
2673
|
tag = address
|
2659
2674
|
address = depositAddress
|
2660
2675
|
return {
|
2661
2676
|
'info': response,
|
2662
|
-
'currency': code,
|
2663
|
-
'network': network,
|
2677
|
+
'currency': currency['code'],
|
2678
|
+
'network': self.safe_string(networkEntry, 'network'),
|
2664
2679
|
'address': address,
|
2665
2680
|
'tag': tag,
|
2666
2681
|
}
|
@@ -2730,21 +2745,12 @@ class poloniex(Exchange, ImplicitAPI):
|
|
2730
2745
|
"""
|
2731
2746
|
tag, params = self.handle_withdraw_tag_and_params(tag, params)
|
2732
2747
|
self.check_address(address)
|
2733
|
-
self.
|
2734
|
-
|
2735
|
-
request
|
2736
|
-
|
2737
|
-
'amount': amount,
|
2738
|
-
'address': address,
|
2739
|
-
}
|
2748
|
+
request, extraParams, currency, networkEntry = self.prepare_request_for_deposit_address(code, params)
|
2749
|
+
params = extraParams
|
2750
|
+
request['amount'] = self.currency_to_precision(code, amount)
|
2751
|
+
request['address'] = address
|
2740
2752
|
if tag is not None:
|
2741
2753
|
request['paymentId'] = tag
|
2742
|
-
networks = self.safe_value(self.options, 'networks', {})
|
2743
|
-
network = self.safe_string_upper(params, 'network') # self line allows the user to specify either ERC20 or ETH
|
2744
|
-
network = self.safe_string(networks, network, network) # handle ERC20>ETH alias
|
2745
|
-
if network is not None:
|
2746
|
-
request['currency'] = request['currency'] + network # when network the currency need to be changed to currency+network https://docs.poloniex.com/#withdraw on MultiChain Currencies section
|
2747
|
-
params = self.omit(params, 'network')
|
2748
2754
|
response = self.privatePostWalletsWithdraw(self.extend(request, params))
|
2749
2755
|
#
|
2750
2756
|
# {
|
@@ -2753,7 +2759,11 @@ class poloniex(Exchange, ImplicitAPI):
|
|
2753
2759
|
# "withdrawalNumber": 13449869
|
2754
2760
|
# }
|
2755
2761
|
#
|
2756
|
-
|
2762
|
+
withdrawResponse = {
|
2763
|
+
'response': response,
|
2764
|
+
'withdrawNetworkEntry': networkEntry,
|
2765
|
+
}
|
2766
|
+
return self.parse_transaction(withdrawResponse, currency)
|
2757
2767
|
|
2758
2768
|
def fetch_transactions_helper(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
|
2759
2769
|
self.load_markets()
|
@@ -3071,6 +3081,9 @@ class poloniex(Exchange, ImplicitAPI):
|
|
3071
3081
|
# "withdrawalRequestsId": 33485231
|
3072
3082
|
# }
|
3073
3083
|
#
|
3084
|
+
# if it's being parsed from "withdraw()" method, get the original response
|
3085
|
+
if 'withdrawNetworkEntry' in transaction:
|
3086
|
+
transaction = transaction['response']
|
3074
3087
|
timestamp = self.safe_timestamp(transaction, 'timestamp')
|
3075
3088
|
currencyId = self.safe_string(transaction, 'currency')
|
3076
3089
|
code = self.safe_currency_code(currencyId)
|