ccxt 4.3.9__py2.py3-none-any.whl → 4.3.11__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/blofin.py +2 -0
- ccxt/abstract/kucoinfutures.py +2 -0
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/bitget.py +1 -1
- ccxt/async_support/blofin.py +2 -0
- ccxt/async_support/coinex.py +169 -148
- ccxt/async_support/kucoinfutures.py +148 -12
- ccxt/base/exchange.py +4 -4
- ccxt/base/types.py +2 -0
- ccxt/bitget.py +1 -1
- ccxt/blofin.py +2 -0
- ccxt/coinex.py +169 -148
- ccxt/kucoinfutures.py +148 -12
- ccxt/pro/__init__.py +1 -1
- {ccxt-4.3.9.dist-info → ccxt-4.3.11.dist-info}/METADATA +4 -4
- {ccxt-4.3.9.dist-info → ccxt-4.3.11.dist-info}/RECORD +20 -20
- {ccxt-4.3.9.dist-info → ccxt-4.3.11.dist-info}/WHEEL +0 -0
- {ccxt-4.3.9.dist-info → ccxt-4.3.11.dist-info}/top_level.txt +0 -0
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
from ccxt.async_support.kucoin import kucoin
|
7
7
|
from ccxt.abstract.kucoinfutures import ImplicitAPI
|
8
|
-
from ccxt.base.types import Balances, Currency, Int, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
8
|
+
from ccxt.base.types import Balances, Currency, Int, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
|
9
9
|
from typing import List
|
10
10
|
from ccxt.base.errors import AuthenticationError
|
11
11
|
from ccxt.base.errors import PermissionDenied
|
@@ -94,13 +94,14 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
94
94
|
'fetchPositionHistory': False,
|
95
95
|
'fetchPositionMode': False,
|
96
96
|
'fetchPositions': True,
|
97
|
-
'fetchPositionsHistory':
|
97
|
+
'fetchPositionsHistory': True,
|
98
98
|
'fetchPremiumIndexOHLCV': False,
|
99
99
|
'fetchStatus': True,
|
100
100
|
'fetchTicker': True,
|
101
101
|
'fetchTickers': True,
|
102
102
|
'fetchTime': True,
|
103
103
|
'fetchTrades': True,
|
104
|
+
'fetchTradingFee': True,
|
104
105
|
'fetchTransactionFee': False,
|
105
106
|
'fetchWithdrawals': True,
|
106
107
|
'setLeverage': False,
|
@@ -177,6 +178,8 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
177
178
|
'funding-history': 4.44,
|
178
179
|
'sub/api-key': 1,
|
179
180
|
'trade-statistics': 1,
|
181
|
+
'trade-fees': 1,
|
182
|
+
'history-positions': 1,
|
180
183
|
},
|
181
184
|
'post': {
|
182
185
|
'withdrawals': 1,
|
@@ -1107,6 +1110,71 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1107
1110
|
data = self.safe_list(response, 'data')
|
1108
1111
|
return self.parse_positions(data, symbols)
|
1109
1112
|
|
1113
|
+
async def fetch_positions_history(self, symbols: Strings = None, since: Int = None, limit: Int = None, params={}):
|
1114
|
+
"""
|
1115
|
+
fetches historical positions
|
1116
|
+
:see: https://www.kucoin.com/docs/rest/futures-trading/positions/get-positions-history
|
1117
|
+
:param str[] [symbols]: list of unified market symbols
|
1118
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1119
|
+
:param int [params.until]: closing end time
|
1120
|
+
:param int [params.pageId]: page id
|
1121
|
+
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
1122
|
+
"""
|
1123
|
+
await self.load_markets()
|
1124
|
+
if limit is None:
|
1125
|
+
limit = 200
|
1126
|
+
request = {
|
1127
|
+
'limit': limit,
|
1128
|
+
}
|
1129
|
+
if since is not None:
|
1130
|
+
request['from'] = since
|
1131
|
+
until = self.safe_integer(params, 'until')
|
1132
|
+
if until is not None:
|
1133
|
+
params = self.omit(params, 'until')
|
1134
|
+
request['to'] = until
|
1135
|
+
response = await self.futuresPrivateGetHistoryPositions(self.extend(request, params))
|
1136
|
+
#
|
1137
|
+
# {
|
1138
|
+
# "success": True,
|
1139
|
+
# "code": "200",
|
1140
|
+
# "msg": "success",
|
1141
|
+
# "retry": False,
|
1142
|
+
# "data": {
|
1143
|
+
# "currentPage": 1,
|
1144
|
+
# "pageSize": 10,
|
1145
|
+
# "totalNum": 25,
|
1146
|
+
# "totalPage": 3,
|
1147
|
+
# "items": [
|
1148
|
+
# {
|
1149
|
+
# "closeId": "300000000000000030",
|
1150
|
+
# "positionId": "300000000000000009",
|
1151
|
+
# "uid": 99996908309485,
|
1152
|
+
# "userId": "6527d4fc8c7f3d0001f40f5f",
|
1153
|
+
# "symbol": "XBTUSDM",
|
1154
|
+
# "settleCurrency": "XBT",
|
1155
|
+
# "leverage": "0.0",
|
1156
|
+
# "type": "LIQUID_LONG",
|
1157
|
+
# "side": null,
|
1158
|
+
# "closeSize": null,
|
1159
|
+
# "pnl": "-1.0000003793999999",
|
1160
|
+
# "realisedGrossCost": "0.9993849748999999",
|
1161
|
+
# "withdrawPnl": "0.0",
|
1162
|
+
# "roe": null,
|
1163
|
+
# "tradeFee": "0.0006154045",
|
1164
|
+
# "fundingFee": "0.0",
|
1165
|
+
# "openTime": 1713785751181,
|
1166
|
+
# "closeTime": 1713785752784,
|
1167
|
+
# "openPrice": null,
|
1168
|
+
# "closePrice": null
|
1169
|
+
# }
|
1170
|
+
# ]
|
1171
|
+
# }
|
1172
|
+
# }
|
1173
|
+
#
|
1174
|
+
data = self.safe_dict(response, 'data')
|
1175
|
+
items = self.safe_list(data, 'items', [])
|
1176
|
+
return self.parse_positions(items, symbols)
|
1177
|
+
|
1110
1178
|
def parse_position(self, position, market: Market = None):
|
1111
1179
|
#
|
1112
1180
|
# {
|
@@ -1153,16 +1221,46 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1153
1221
|
# }
|
1154
1222
|
# ]
|
1155
1223
|
# }
|
1224
|
+
# position history
|
1225
|
+
# {
|
1226
|
+
# "closeId": "300000000000000030",
|
1227
|
+
# "positionId": "300000000000000009",
|
1228
|
+
# "uid": 99996908309485,
|
1229
|
+
# "userId": "6527d4fc8c7f3d0001f40f5f",
|
1230
|
+
# "symbol": "XBTUSDM",
|
1231
|
+
# "settleCurrency": "XBT",
|
1232
|
+
# "leverage": "0.0",
|
1233
|
+
# "type": "LIQUID_LONG",
|
1234
|
+
# "side": null,
|
1235
|
+
# "closeSize": null,
|
1236
|
+
# "pnl": "-1.0000003793999999",
|
1237
|
+
# "realisedGrossCost": "0.9993849748999999",
|
1238
|
+
# "withdrawPnl": "0.0",
|
1239
|
+
# "roe": null,
|
1240
|
+
# "tradeFee": "0.0006154045",
|
1241
|
+
# "fundingFee": "0.0",
|
1242
|
+
# "openTime": 1713785751181,
|
1243
|
+
# "closeTime": 1713785752784,
|
1244
|
+
# "openPrice": null,
|
1245
|
+
# "closePrice": null
|
1246
|
+
# }
|
1156
1247
|
#
|
1157
1248
|
symbol = self.safe_string(position, 'symbol')
|
1158
1249
|
market = self.safe_market(symbol, market)
|
1159
1250
|
timestamp = self.safe_integer(position, 'currentTimestamp')
|
1160
1251
|
size = self.safe_string(position, 'currentQty')
|
1161
1252
|
side = None
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1253
|
+
type = self.safe_string_lower(position, 'type')
|
1254
|
+
if size is not None:
|
1255
|
+
if Precise.string_gt(size, '0'):
|
1256
|
+
side = 'long'
|
1257
|
+
elif Precise.string_lt(size, '0'):
|
1258
|
+
side = 'short'
|
1259
|
+
elif type is not None:
|
1260
|
+
if type.find('long') > -1:
|
1261
|
+
side = 'long'
|
1262
|
+
else:
|
1263
|
+
side = 'short'
|
1166
1264
|
notional = Precise.string_abs(self.safe_string(position, 'posCost'))
|
1167
1265
|
initialMargin = self.safe_string(position, 'posInit')
|
1168
1266
|
initialMarginPercentage = Precise.string_div(initialMargin, notional)
|
@@ -1170,25 +1268,27 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1170
1268
|
unrealisedPnl = self.safe_string(position, 'unrealisedPnl')
|
1171
1269
|
crossMode = self.safe_value(position, 'crossMode')
|
1172
1270
|
# currently crossMode is always set to False and only isolated positions are supported
|
1173
|
-
marginMode =
|
1271
|
+
marginMode = None
|
1272
|
+
if crossMode is not None:
|
1273
|
+
marginMode = 'cross' if crossMode else 'isolated'
|
1174
1274
|
return self.safe_position({
|
1175
1275
|
'info': position,
|
1176
|
-
'id': self.
|
1276
|
+
'id': self.safe_string_2(position, 'id', 'positionId'),
|
1177
1277
|
'symbol': self.safe_string(market, 'symbol'),
|
1178
1278
|
'timestamp': timestamp,
|
1179
1279
|
'datetime': self.iso8601(timestamp),
|
1180
|
-
'lastUpdateTimestamp':
|
1280
|
+
'lastUpdateTimestamp': self.safe_integer(position, 'closeTime'),
|
1181
1281
|
'initialMargin': self.parse_number(initialMargin),
|
1182
1282
|
'initialMarginPercentage': self.parse_number(initialMarginPercentage),
|
1183
1283
|
'maintenanceMargin': self.safe_number(position, 'posMaint'),
|
1184
1284
|
'maintenanceMarginPercentage': self.safe_number(position, 'maintMarginReq'),
|
1185
|
-
'entryPrice': self.
|
1285
|
+
'entryPrice': self.safe_number_2(position, 'avgEntryPrice', 'openPrice'),
|
1186
1286
|
'notional': self.parse_number(notional),
|
1187
|
-
'leverage': self.
|
1287
|
+
'leverage': self.safe_number_2(position, 'realLeverage', 'leverage'),
|
1188
1288
|
'unrealizedPnl': self.parse_number(unrealisedPnl),
|
1189
1289
|
'contracts': self.parse_number(Precise.string_abs(size)),
|
1190
1290
|
'contractSize': self.safe_value(market, 'contractSize'),
|
1191
|
-
'realizedPnl': self.
|
1291
|
+
'realizedPnl': self.safe_number_2(position, 'realisedPnl', 'pnl'),
|
1192
1292
|
'marginRatio': None,
|
1193
1293
|
'liquidationPrice': self.safe_number(position, 'liquidationPrice'),
|
1194
1294
|
'markPrice': self.safe_number(position, 'markPrice'),
|
@@ -2560,3 +2660,39 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2560
2660
|
else:
|
2561
2661
|
response = await self.futuresPrivatePostOrders(self.extend(request, params))
|
2562
2662
|
return self.parse_order(response, market)
|
2663
|
+
|
2664
|
+
async def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
|
2665
|
+
"""
|
2666
|
+
fetch the trading fees for a market
|
2667
|
+
:see: https://www.kucoin.com/docs/rest/funding/trade-fee/trading-pair-actual-fee-futures
|
2668
|
+
:param str symbol: unified market symbol
|
2669
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2670
|
+
:returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
|
2671
|
+
"""
|
2672
|
+
await self.load_markets()
|
2673
|
+
market = self.market(symbol)
|
2674
|
+
request = {
|
2675
|
+
'symbols': market['id'],
|
2676
|
+
}
|
2677
|
+
response = await self.privateGetTradeFees(self.extend(request, params))
|
2678
|
+
#
|
2679
|
+
# {
|
2680
|
+
# "code": "200000",
|
2681
|
+
# "data": {
|
2682
|
+
# "symbol": "XBTUSDTM",
|
2683
|
+
# "takerFeeRate": "0.0006",
|
2684
|
+
# "makerFeeRate": "0.0002"
|
2685
|
+
# }
|
2686
|
+
# }
|
2687
|
+
#
|
2688
|
+
data = self.safe_list(response, 'data', [])
|
2689
|
+
first = self.safe_dict(data, 0)
|
2690
|
+
marketId = self.safe_string(first, 'symbol')
|
2691
|
+
return {
|
2692
|
+
'info': response,
|
2693
|
+
'symbol': self.safe_symbol(marketId, market),
|
2694
|
+
'maker': self.safe_number(first, 'makerFeeRate'),
|
2695
|
+
'taker': self.safe_number(first, 'takerFeeRate'),
|
2696
|
+
'percentage': True,
|
2697
|
+
'tierBased': True,
|
2698
|
+
}
|
ccxt/base/exchange.py
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
__version__ = '4.3.
|
7
|
+
__version__ = '4.3.11'
|
8
8
|
|
9
9
|
# -----------------------------------------------------------------------------
|
10
10
|
|
@@ -5693,15 +5693,15 @@ class Exchange(object):
|
|
5693
5693
|
fromId = self.safe_string(entry, fromCurrencyKey)
|
5694
5694
|
toId = self.safe_string(entry, toCurrencyKey)
|
5695
5695
|
if fromId is not None:
|
5696
|
-
fromCurrency = self.
|
5696
|
+
fromCurrency = self.safe_currency(fromId)
|
5697
5697
|
if toId is not None:
|
5698
|
-
toCurrency = self.
|
5698
|
+
toCurrency = self.safe_currency(toId)
|
5699
5699
|
conversion = self.extend(self.parseConversion(entry, fromCurrency, toCurrency), params)
|
5700
5700
|
result.append(conversion)
|
5701
5701
|
sorted = self.sort_by(result, 'timestamp')
|
5702
5702
|
currency = None
|
5703
5703
|
if code is not None:
|
5704
|
-
currency = self.
|
5704
|
+
currency = self.safe_currency(code)
|
5705
5705
|
code = currency['code']
|
5706
5706
|
if code is None:
|
5707
5707
|
return self.filter_by_since_limit(sorted, since, limit)
|
ccxt/base/types.py
CHANGED
ccxt/bitget.py
CHANGED
@@ -7863,7 +7863,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7863
7863
|
"""
|
7864
7864
|
fetches historical positions
|
7865
7865
|
:see: https://www.bitget.com/api-doc/contract/position/Get-History-Position
|
7866
|
-
:param str [
|
7866
|
+
:param str[] [symbols]: unified contract symbols
|
7867
7867
|
:param int [since]: timestamp in ms of the earliest position to fetch, default=3 months ago, max range for params["until"] - since is 3 months
|
7868
7868
|
:param int [limit]: the maximum amount of records to fetch, default=20, max=100
|
7869
7869
|
:param dict params: extra parameters specific to the exchange api endpoint
|
ccxt/blofin.py
CHANGED