ccxt 4.3.6__py2.py3-none-any.whl → 4.3.8__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ccxt might be problematic. Click here for more details.
- ccxt/__init__.py +1 -1
- ccxt/abstract/coinbase.py +5 -0
- ccxt/ace.py +5 -0
- ccxt/alpaca.py +6 -0
- ccxt/ascendex.py +2 -2
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/ace.py +5 -0
- ccxt/async_support/alpaca.py +6 -0
- ccxt/async_support/ascendex.py +2 -2
- ccxt/async_support/base/exchange.py +27 -1
- ccxt/async_support/bigone.py +1 -1
- ccxt/async_support/binance.py +6 -4
- ccxt/async_support/bingx.py +4 -2
- ccxt/async_support/bitbank.py +4 -1
- ccxt/async_support/bitfinex.py +1 -1
- ccxt/async_support/bitfinex2.py +1 -1
- ccxt/async_support/bitflyer.py +1 -1
- ccxt/async_support/bitget.py +71 -5
- ccxt/async_support/bithumb.py +5 -1
- ccxt/async_support/bitmart.py +1 -1
- ccxt/async_support/bitmex.py +3 -1
- ccxt/async_support/bitopro.py +6 -1
- ccxt/async_support/bitrue.py +1 -1
- ccxt/async_support/bitso.py +4 -1
- ccxt/async_support/bitstamp.py +4 -1
- ccxt/async_support/bitteam.py +4 -0
- ccxt/async_support/bitvavo.py +4 -1
- ccxt/async_support/bl3p.py +3 -0
- ccxt/async_support/blockchaincom.py +1 -1
- ccxt/async_support/btcalpha.py +3 -0
- ccxt/async_support/btcbox.py +3 -0
- ccxt/async_support/btcmarkets.py +4 -1
- ccxt/async_support/btcturk.py +3 -0
- ccxt/async_support/bybit.py +116 -14
- ccxt/async_support/cex.py +6 -0
- ccxt/async_support/coinbase.py +94 -18
- ccxt/async_support/coinbaseinternational.py +3 -1
- ccxt/async_support/coinbasepro.py +7 -1
- ccxt/async_support/coincheck.py +3 -0
- ccxt/async_support/coinex.py +255 -192
- ccxt/async_support/coinlist.py +5 -1
- ccxt/async_support/coinmate.py +4 -1
- ccxt/async_support/coinone.py +3 -0
- ccxt/async_support/coinsph.py +5 -1
- ccxt/async_support/coinspot.py +3 -0
- ccxt/async_support/cryptocom.py +3 -1
- ccxt/async_support/delta.py +2 -2
- ccxt/async_support/deribit.py +1 -1
- ccxt/async_support/digifinex.py +3 -3
- ccxt/async_support/exmo.py +8 -3
- ccxt/async_support/gate.py +112 -24
- ccxt/async_support/gemini.py +1 -1
- ccxt/async_support/hitbtc.py +7 -6
- ccxt/async_support/hollaex.py +1 -1
- ccxt/async_support/htx.py +3 -1
- ccxt/async_support/huobijp.py +1 -1
- ccxt/async_support/hyperliquid.py +2 -2
- ccxt/async_support/idex.py +4 -1
- ccxt/async_support/independentreserve.py +3 -0
- ccxt/async_support/indodax.py +4 -1
- ccxt/async_support/kraken.py +1 -1
- ccxt/async_support/kucoin.py +3 -1
- ccxt/async_support/kucoinfutures.py +3 -1
- ccxt/async_support/kuna.py +1 -1
- ccxt/async_support/latoken.py +6 -0
- ccxt/async_support/lbank.py +1 -1
- ccxt/async_support/luno.py +3 -0
- ccxt/async_support/lykke.py +6 -1
- ccxt/async_support/mercado.py +4 -1
- ccxt/async_support/mexc.py +110 -4
- ccxt/async_support/ndax.py +5 -1
- ccxt/async_support/novadax.py +5 -1
- ccxt/async_support/okcoin.py +1 -1
- ccxt/async_support/okx.py +81 -5
- ccxt/async_support/onetrading.py +4 -1
- ccxt/async_support/p2b.py +3 -0
- ccxt/async_support/phemex.py +1 -1
- ccxt/async_support/poloniex.py +1 -1
- ccxt/async_support/probit.py +4 -1
- ccxt/async_support/timex.py +3 -0
- ccxt/async_support/tokocrypto.py +1 -1
- ccxt/async_support/tradeogre.py +3 -0
- ccxt/async_support/upbit.py +1 -1
- ccxt/async_support/wavesexchange.py +4 -1
- ccxt/async_support/wazirx.py +3 -0
- ccxt/async_support/whitebit.py +1 -1
- ccxt/async_support/woo.py +4 -2
- ccxt/async_support/yobit.py +4 -1
- ccxt/async_support/zaif.py +1 -1
- ccxt/async_support/zonda.py +1 -1
- ccxt/base/exchange.py +38 -4
- ccxt/bigone.py +1 -1
- ccxt/binance.py +6 -4
- ccxt/bingx.py +4 -2
- ccxt/bitbank.py +4 -1
- ccxt/bitfinex.py +1 -1
- ccxt/bitfinex2.py +1 -1
- ccxt/bitflyer.py +1 -1
- ccxt/bitget.py +71 -5
- ccxt/bithumb.py +5 -1
- ccxt/bitmart.py +1 -1
- ccxt/bitmex.py +3 -1
- ccxt/bitopro.py +6 -1
- ccxt/bitrue.py +1 -1
- ccxt/bitso.py +4 -1
- ccxt/bitstamp.py +4 -1
- ccxt/bitteam.py +4 -0
- ccxt/bitvavo.py +4 -1
- ccxt/bl3p.py +3 -0
- ccxt/blockchaincom.py +1 -1
- ccxt/btcalpha.py +3 -0
- ccxt/btcbox.py +3 -0
- ccxt/btcmarkets.py +4 -1
- ccxt/btcturk.py +3 -0
- ccxt/bybit.py +116 -14
- ccxt/cex.py +6 -0
- ccxt/coinbase.py +94 -18
- ccxt/coinbaseinternational.py +3 -1
- ccxt/coinbasepro.py +7 -1
- ccxt/coincheck.py +3 -0
- ccxt/coinex.py +255 -192
- ccxt/coinlist.py +5 -1
- ccxt/coinmate.py +4 -1
- ccxt/coinone.py +3 -0
- ccxt/coinsph.py +5 -1
- ccxt/coinspot.py +3 -0
- ccxt/cryptocom.py +3 -1
- ccxt/delta.py +2 -2
- ccxt/deribit.py +1 -1
- ccxt/digifinex.py +3 -3
- ccxt/exmo.py +8 -3
- ccxt/gate.py +112 -24
- ccxt/gemini.py +1 -1
- ccxt/hitbtc.py +7 -6
- ccxt/hollaex.py +1 -1
- ccxt/htx.py +3 -1
- ccxt/huobijp.py +1 -1
- ccxt/hyperliquid.py +2 -2
- ccxt/idex.py +4 -1
- ccxt/independentreserve.py +3 -0
- ccxt/indodax.py +4 -1
- ccxt/kraken.py +1 -1
- ccxt/kucoin.py +3 -1
- ccxt/kucoinfutures.py +3 -1
- ccxt/kuna.py +1 -1
- ccxt/latoken.py +6 -0
- ccxt/lbank.py +1 -1
- ccxt/luno.py +3 -0
- ccxt/lykke.py +6 -1
- ccxt/mercado.py +4 -1
- ccxt/mexc.py +110 -4
- ccxt/ndax.py +5 -1
- ccxt/novadax.py +5 -1
- ccxt/okcoin.py +1 -1
- ccxt/okx.py +81 -5
- ccxt/onetrading.py +4 -1
- ccxt/p2b.py +3 -0
- ccxt/phemex.py +1 -1
- ccxt/poloniex.py +1 -1
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/bybit.py +1 -1
- ccxt/pro/coinbase.py +28 -28
- ccxt/probit.py +4 -1
- ccxt/timex.py +3 -0
- ccxt/tokocrypto.py +1 -1
- ccxt/tradeogre.py +3 -0
- ccxt/upbit.py +1 -1
- ccxt/wavesexchange.py +4 -1
- ccxt/wazirx.py +3 -0
- ccxt/whitebit.py +1 -1
- ccxt/woo.py +4 -2
- ccxt/yobit.py +4 -1
- ccxt/zaif.py +1 -1
- ccxt/zonda.py +1 -1
- {ccxt-4.3.6.dist-info → ccxt-4.3.8.dist-info}/METADATA +4 -4
- {ccxt-4.3.6.dist-info → ccxt-4.3.8.dist-info}/RECORD +178 -178
- {ccxt-4.3.6.dist-info → ccxt-4.3.8.dist-info}/WHEEL +0 -0
- {ccxt-4.3.6.dist-info → ccxt-4.3.8.dist-info}/top_level.txt +0 -0
ccxt/async_support/coinex.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.coinex import ImplicitAPI
|
8
8
|
import asyncio
|
9
|
-
from ccxt.base.types import Balances, Currencies, Currency, Int, Leverage, Leverages, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Balances, Currencies, Currency, Int, Leverage, Leverages, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -103,7 +103,9 @@ class coinex(Exchange, ImplicitAPI):
|
|
103
103
|
'fetchOrder': True,
|
104
104
|
'fetchOrderBook': True,
|
105
105
|
'fetchPosition': True,
|
106
|
+
'fetchPositionHistory': True,
|
106
107
|
'fetchPositions': True,
|
108
|
+
'fetchPositionsHistory': False,
|
107
109
|
'fetchPositionsRisk': False,
|
108
110
|
'fetchPremiumIndexOHLCV': False,
|
109
111
|
'fetchTicker': True,
|
@@ -1416,31 +1418,31 @@ class coinex(Exchange, ImplicitAPI):
|
|
1416
1418
|
|
1417
1419
|
def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
|
1418
1420
|
#
|
1419
|
-
#
|
1420
|
-
#
|
1421
|
-
# "
|
1422
|
-
# "
|
1423
|
-
# "
|
1424
|
-
# "
|
1425
|
-
# "
|
1426
|
-
# "
|
1427
|
-
# "
|
1428
|
-
#
|
1421
|
+
# {
|
1422
|
+
# "close": "66999.95",
|
1423
|
+
# "created_at": 1713934620000,
|
1424
|
+
# "high": "66999.95",
|
1425
|
+
# "low": "66988.53",
|
1426
|
+
# "market": "BTCUSDT",
|
1427
|
+
# "open": "66988.53",
|
1428
|
+
# "value": "0.1572393", # base volume
|
1429
|
+
# "volume": "10533.2501364336" # quote volume
|
1430
|
+
# }
|
1429
1431
|
#
|
1430
1432
|
return [
|
1431
|
-
self.
|
1432
|
-
self.safe_number(ohlcv,
|
1433
|
-
self.safe_number(ohlcv,
|
1434
|
-
self.safe_number(ohlcv,
|
1435
|
-
self.safe_number(ohlcv,
|
1436
|
-
self.safe_number(ohlcv,
|
1433
|
+
self.safe_integer(ohlcv, 'created_at'),
|
1434
|
+
self.safe_number(ohlcv, 'open'),
|
1435
|
+
self.safe_number(ohlcv, 'high'),
|
1436
|
+
self.safe_number(ohlcv, 'low'),
|
1437
|
+
self.safe_number(ohlcv, 'close'),
|
1438
|
+
self.safe_number(ohlcv, 'value'),
|
1437
1439
|
]
|
1438
1440
|
|
1439
1441
|
async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
|
1440
1442
|
"""
|
1441
1443
|
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
1442
|
-
:see: https://
|
1443
|
-
:see: https://
|
1444
|
+
:see: https://docs.coinex.com/api/v2/spot/market/http/list-market-kline
|
1445
|
+
:see: https://docs.coinex.com/api/v2/futures/market/http/list-market-kline
|
1444
1446
|
:param str symbol: unified symbol of the market to fetch OHLCV data for
|
1445
1447
|
:param str timeframe: the length of time each candle represents
|
1446
1448
|
:param int [since]: timestamp in ms of the earliest candle to fetch
|
@@ -1452,36 +1454,31 @@ class coinex(Exchange, ImplicitAPI):
|
|
1452
1454
|
market = self.market(symbol)
|
1453
1455
|
request = {
|
1454
1456
|
'market': market['id'],
|
1455
|
-
'
|
1457
|
+
'period': self.safe_string(self.timeframes, timeframe, timeframe),
|
1456
1458
|
}
|
1457
1459
|
if limit is not None:
|
1458
1460
|
request['limit'] = limit
|
1459
1461
|
response = None
|
1460
1462
|
if market['swap']:
|
1461
|
-
response = await self.
|
1463
|
+
response = await self.v2PublicGetFuturesKline(self.extend(request, params))
|
1462
1464
|
else:
|
1463
|
-
response = await self.
|
1464
|
-
#
|
1465
|
-
# Spot
|
1465
|
+
response = await self.v2PublicGetSpotKline(self.extend(request, params))
|
1466
1466
|
#
|
1467
|
-
#
|
1468
|
-
# "code": 0,
|
1469
|
-
# "data": [
|
1470
|
-
# [1591484400, "0.02505349", "0.02506988", "0.02507000", "0.02505304", "343.19716223", "8.6021323866383196", "ETHBTC"],
|
1471
|
-
# [1591484700, "0.02506990", "0.02508109", "0.02508109", "0.02506979", "91.59841581", "2.2972047780447000", "ETHBTC"],
|
1472
|
-
# [1591485000, "0.02508106", "0.02507996", "0.02508106", "0.02507500", "65.15307697", "1.6340597822306000", "ETHBTC"],
|
1473
|
-
# ],
|
1474
|
-
# "message": "OK"
|
1475
|
-
# }
|
1476
|
-
#
|
1477
|
-
# Swap
|
1467
|
+
# Spot and Swap
|
1478
1468
|
#
|
1479
1469
|
# {
|
1480
1470
|
# "code": 0,
|
1481
1471
|
# "data": [
|
1482
|
-
#
|
1483
|
-
#
|
1484
|
-
#
|
1472
|
+
# {
|
1473
|
+
# "close": "66999.95",
|
1474
|
+
# "created_at": 1713934620000,
|
1475
|
+
# "high": "66999.95",
|
1476
|
+
# "low": "66988.53",
|
1477
|
+
# "market": "BTCUSDT",
|
1478
|
+
# "open": "66988.53",
|
1479
|
+
# "value": "0.1572393",
|
1480
|
+
# "volume": "10533.2501364336"
|
1481
|
+
# },
|
1485
1482
|
# ],
|
1486
1483
|
# "message": "OK"
|
1487
1484
|
# }
|
@@ -1491,196 +1488,151 @@ class coinex(Exchange, ImplicitAPI):
|
|
1491
1488
|
|
1492
1489
|
async def fetch_margin_balance(self, params={}):
|
1493
1490
|
await self.load_markets()
|
1494
|
-
|
1495
|
-
marketId = self.safe_string(params, 'market')
|
1496
|
-
market: Market = None
|
1497
|
-
if symbol is not None:
|
1498
|
-
market = self.market(symbol)
|
1499
|
-
marketId = market['id']
|
1500
|
-
elif marketId is None:
|
1501
|
-
raise ArgumentsRequired(self.id + ' fetchMarginBalance() fetching a margin account requires a market parameter or a symbol parameter')
|
1502
|
-
params = self.omit(params, ['symbol', 'market'])
|
1503
|
-
request = {
|
1504
|
-
'market': marketId,
|
1505
|
-
}
|
1506
|
-
response = await self.v1PrivateGetMarginAccount(self.extend(request, params))
|
1491
|
+
response = await self.v2PrivateGetAssetsMarginBalance(params)
|
1507
1492
|
#
|
1508
|
-
#
|
1509
|
-
#
|
1510
|
-
#
|
1511
|
-
#
|
1512
|
-
#
|
1513
|
-
#
|
1514
|
-
#
|
1515
|
-
#
|
1516
|
-
#
|
1517
|
-
#
|
1518
|
-
#
|
1519
|
-
#
|
1520
|
-
#
|
1521
|
-
#
|
1522
|
-
#
|
1523
|
-
#
|
1524
|
-
#
|
1525
|
-
#
|
1526
|
-
#
|
1527
|
-
#
|
1528
|
-
#
|
1529
|
-
#
|
1530
|
-
#
|
1531
|
-
#
|
1532
|
-
#
|
1533
|
-
#
|
1534
|
-
#
|
1535
|
-
#
|
1536
|
-
#
|
1537
|
-
# "liquidation_price": ""
|
1538
|
-
# },
|
1539
|
-
# "message": "Success"
|
1540
|
-
# }
|
1493
|
+
# {
|
1494
|
+
# "data": [
|
1495
|
+
# {
|
1496
|
+
# "margin_account": "BTCUSDT",
|
1497
|
+
# "base_ccy": "BTC",
|
1498
|
+
# "quote_ccy": "USDT",
|
1499
|
+
# "available": {
|
1500
|
+
# "base_ccy": "0.00000026",
|
1501
|
+
# "quote_ccy": "0"
|
1502
|
+
# },
|
1503
|
+
# "frozen": {
|
1504
|
+
# "base_ccy": "0",
|
1505
|
+
# "quote_ccy": "0"
|
1506
|
+
# },
|
1507
|
+
# "repaid": {
|
1508
|
+
# "base_ccy": "0",
|
1509
|
+
# "quote_ccy": "0"
|
1510
|
+
# },
|
1511
|
+
# "interest": {
|
1512
|
+
# "base_ccy": "0",
|
1513
|
+
# "quote_ccy": "0"
|
1514
|
+
# },
|
1515
|
+
# "rik_rate": "",
|
1516
|
+
# "liq_price": ""
|
1517
|
+
# },
|
1518
|
+
# ],
|
1519
|
+
# "code": 0,
|
1520
|
+
# "message": "OK"
|
1521
|
+
# }
|
1541
1522
|
#
|
1542
1523
|
result = {'info': response}
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
buyAccount = self.account()
|
1560
|
-
buyCurrencyId = self.safe_string(data, 'buy_asset_type')
|
1561
|
-
buyCurrencyCode = self.safe_currency_code(buyCurrencyId)
|
1562
|
-
buyAccount['free'] = self.safe_string(free, 'buy_type')
|
1563
|
-
buyAccount['total'] = self.safe_string(total, 'buy_type')
|
1564
|
-
buyDebt = self.safe_string(loan, 'buy_type')
|
1565
|
-
buyInterest = self.safe_string(interest, 'buy_type')
|
1566
|
-
buyAccount['debt'] = Precise.string_add(buyDebt, buyInterest)
|
1567
|
-
result[buyCurrencyCode] = buyAccount
|
1568
|
-
#
|
1524
|
+
balances = self.safe_list(response, 'data', [])
|
1525
|
+
for i in range(0, len(balances)):
|
1526
|
+
entry = balances[i]
|
1527
|
+
free = self.safe_dict(entry, 'available', {})
|
1528
|
+
used = self.safe_dict(entry, 'frozen', {})
|
1529
|
+
loan = self.safe_dict(entry, 'repaid', {})
|
1530
|
+
interest = self.safe_dict(entry, 'interest', {})
|
1531
|
+
baseAccount = self.account()
|
1532
|
+
baseCurrencyId = self.safe_string(entry, 'base_ccy')
|
1533
|
+
baseCurrencyCode = self.safe_currency_code(baseCurrencyId)
|
1534
|
+
baseAccount['free'] = self.safe_string(free, 'base_ccy')
|
1535
|
+
baseAccount['used'] = self.safe_string(used, 'base_ccy')
|
1536
|
+
baseDebt = self.safe_string(loan, 'base_ccy')
|
1537
|
+
baseInterest = self.safe_string(interest, 'base_ccy')
|
1538
|
+
baseAccount['debt'] = Precise.string_add(baseDebt, baseInterest)
|
1539
|
+
result[baseCurrencyCode] = baseAccount
|
1569
1540
|
return self.safe_balance(result)
|
1570
1541
|
|
1571
1542
|
async def fetch_spot_balance(self, params={}):
|
1572
1543
|
await self.load_markets()
|
1573
|
-
response = await self.
|
1544
|
+
response = await self.v2PrivateGetAssetsSpotBalance(params)
|
1574
1545
|
#
|
1575
1546
|
# {
|
1576
|
-
#
|
1577
|
-
#
|
1578
|
-
#
|
1579
|
-
#
|
1580
|
-
#
|
1581
|
-
#
|
1582
|
-
#
|
1583
|
-
#
|
1584
|
-
#
|
1585
|
-
# },
|
1586
|
-
# "ETH": { # ETH account
|
1587
|
-
# "available": "5.06000", # Available ETH
|
1588
|
-
# "frozen": "0.00000" # Frozen ETH
|
1589
|
-
# }
|
1590
|
-
# },
|
1591
|
-
# "message": "Ok"
|
1547
|
+
# "code": 0,
|
1548
|
+
# "data": [
|
1549
|
+
# {
|
1550
|
+
# "available": "0.00000046",
|
1551
|
+
# "ccy": "USDT",
|
1552
|
+
# "frozen": "0"
|
1553
|
+
# }
|
1554
|
+
# ],
|
1555
|
+
# "message": "OK"
|
1592
1556
|
# }
|
1593
1557
|
#
|
1594
1558
|
result = {'info': response}
|
1595
|
-
balances = self.
|
1596
|
-
|
1597
|
-
|
1598
|
-
currencyId =
|
1559
|
+
balances = self.safe_list(response, 'data', [])
|
1560
|
+
for i in range(0, len(balances)):
|
1561
|
+
entry = balances[i]
|
1562
|
+
currencyId = self.safe_string(entry, 'ccy')
|
1599
1563
|
code = self.safe_currency_code(currencyId)
|
1600
|
-
balance = self.safe_value(balances, currencyId, {})
|
1601
1564
|
account = self.account()
|
1602
|
-
account['free'] = self.safe_string(
|
1603
|
-
account['used'] = self.safe_string(
|
1565
|
+
account['free'] = self.safe_string(entry, 'available')
|
1566
|
+
account['used'] = self.safe_string(entry, 'frozen')
|
1604
1567
|
result[code] = account
|
1605
1568
|
return self.safe_balance(result)
|
1606
1569
|
|
1607
1570
|
async def fetch_swap_balance(self, params={}):
|
1608
1571
|
await self.load_markets()
|
1609
|
-
response = await self.
|
1572
|
+
response = await self.v2PrivateGetAssetsFuturesBalance(params)
|
1610
1573
|
#
|
1611
1574
|
# {
|
1612
1575
|
# "code": 0,
|
1613
|
-
# "data":
|
1614
|
-
#
|
1615
|
-
# "available": "
|
1616
|
-
# "
|
1617
|
-
# "frozen": "0
|
1618
|
-
# "margin": "0
|
1619
|
-
# "
|
1620
|
-
# "
|
1576
|
+
# "data": [
|
1577
|
+
# {
|
1578
|
+
# "available": "0.00000046",
|
1579
|
+
# "ccy": "USDT",
|
1580
|
+
# "frozen": "0",
|
1581
|
+
# "margin": "0",
|
1582
|
+
# "transferrable": "0.00000046",
|
1583
|
+
# "unrealized_pnl": "0"
|
1621
1584
|
# }
|
1622
|
-
#
|
1585
|
+
# ],
|
1623
1586
|
# "message": "OK"
|
1624
1587
|
# }
|
1625
1588
|
#
|
1626
1589
|
result = {'info': response}
|
1627
|
-
balances = self.
|
1628
|
-
|
1629
|
-
|
1630
|
-
currencyId =
|
1590
|
+
balances = self.safe_list(response, 'data', [])
|
1591
|
+
for i in range(0, len(balances)):
|
1592
|
+
entry = balances[i]
|
1593
|
+
currencyId = self.safe_string(entry, 'ccy')
|
1631
1594
|
code = self.safe_currency_code(currencyId)
|
1632
|
-
balance = self.safe_value(balances, currencyId, {})
|
1633
1595
|
account = self.account()
|
1634
|
-
account['free'] = self.safe_string(
|
1635
|
-
account['used'] = self.safe_string(
|
1636
|
-
account['total'] = self.safe_string(balance, 'balance_total')
|
1596
|
+
account['free'] = self.safe_string(entry, 'available')
|
1597
|
+
account['used'] = self.safe_string(entry, 'frozen')
|
1637
1598
|
result[code] = account
|
1638
1599
|
return self.safe_balance(result)
|
1639
1600
|
|
1640
1601
|
async def fetch_financial_balance(self, params={}):
|
1641
1602
|
await self.load_markets()
|
1642
|
-
response = await self.
|
1603
|
+
response = await self.v2PrivateGetAssetsFinancialBalance(params)
|
1643
1604
|
#
|
1644
1605
|
# {
|
1645
|
-
#
|
1646
|
-
#
|
1647
|
-
#
|
1648
|
-
#
|
1649
|
-
#
|
1650
|
-
#
|
1651
|
-
#
|
1652
|
-
#
|
1653
|
-
#
|
1654
|
-
#
|
1655
|
-
# "available": "999900",
|
1656
|
-
# "frozen": "0",
|
1657
|
-
# "lock": "0"
|
1658
|
-
# }
|
1659
|
-
# ],
|
1660
|
-
# "message": "Success"
|
1661
|
-
# }
|
1606
|
+
# "code": 0,
|
1607
|
+
# "data": [
|
1608
|
+
# {
|
1609
|
+
# "available": "0.00000046",
|
1610
|
+
# "ccy": "USDT",
|
1611
|
+
# "frozen": "0"
|
1612
|
+
# }
|
1613
|
+
# ],
|
1614
|
+
# "message": "OK"
|
1615
|
+
# }
|
1662
1616
|
#
|
1663
1617
|
result = {'info': response}
|
1664
|
-
balances = self.
|
1618
|
+
balances = self.safe_list(response, 'data', [])
|
1665
1619
|
for i in range(0, len(balances)):
|
1666
|
-
|
1667
|
-
currencyId = self.safe_string(
|
1620
|
+
entry = balances[i]
|
1621
|
+
currencyId = self.safe_string(entry, 'ccy')
|
1668
1622
|
code = self.safe_currency_code(currencyId)
|
1669
1623
|
account = self.account()
|
1670
|
-
account['free'] = self.safe_string(
|
1671
|
-
|
1672
|
-
locked = self.safe_string(balance, 'lock')
|
1673
|
-
account['used'] = Precise.string_add(frozen, locked)
|
1624
|
+
account['free'] = self.safe_string(entry, 'available')
|
1625
|
+
account['used'] = self.safe_string(entry, 'frozen')
|
1674
1626
|
result[code] = account
|
1675
1627
|
return self.safe_balance(result)
|
1676
1628
|
|
1677
1629
|
async def fetch_balance(self, params={}) -> Balances:
|
1678
1630
|
"""
|
1679
1631
|
query for balance and get the amount of funds available for trading or funds locked in orders
|
1680
|
-
:see: https://
|
1681
|
-
:see: https://
|
1682
|
-
:see: https://
|
1683
|
-
:see: https://
|
1632
|
+
:see: https://docs.coinex.com/api/v2/assets/balance/http/get-spot-balance # spot
|
1633
|
+
:see: https://docs.coinex.com/api/v2/assets/balance/http/get-futures-balance # swap
|
1634
|
+
:see: https://docs.coinex.com/api/v2/assets/balance/http/get-marigin-balance # margin
|
1635
|
+
:see: https://docs.coinex.com/api/v2/assets/balance/http/get-financial-balance # financial
|
1684
1636
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1685
1637
|
:param str [params.type]: 'margin', 'swap', 'financial', or 'spot'
|
1686
1638
|
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
|
@@ -3519,7 +3471,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3519
3471
|
# "side": 2,
|
3520
3472
|
# "stop_loss_price": "0.00000000000000000000",
|
3521
3473
|
# "stop_loss_type": 0,
|
3522
|
-
# "
|
3474
|
+
# "sy s": 0,
|
3523
3475
|
# "take_profit_price": "0.00000000000000000000",
|
3524
3476
|
# "take_profit_type": 0,
|
3525
3477
|
# "taker_fee": "0.00000000000000000000",
|
@@ -3598,7 +3550,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3598
3550
|
# "side": 2,
|
3599
3551
|
# "stop_loss_price": "0.00000000000000000000",
|
3600
3552
|
# "stop_loss_type": 0,
|
3601
|
-
# "
|
3553
|
+
# "s ys": 0,
|
3602
3554
|
# "take_profit_price": "0.00000000000000000000",
|
3603
3555
|
# "take_profit_type": 0,
|
3604
3556
|
# "taker_fee": "0.00000000000000000000",
|
@@ -3615,6 +3567,8 @@ class coinex(Exchange, ImplicitAPI):
|
|
3615
3567
|
return self.parse_position(data[0], market)
|
3616
3568
|
|
3617
3569
|
def parse_position(self, position, market: Market = None):
|
3570
|
+
#
|
3571
|
+
# fetchPosition
|
3618
3572
|
#
|
3619
3573
|
# {
|
3620
3574
|
# "adl_sort": 3396,
|
@@ -3658,7 +3612,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3658
3612
|
# "side": 2,
|
3659
3613
|
# "stop_loss_price": "0.00000000000000000000",
|
3660
3614
|
# "stop_loss_type": 0,
|
3661
|
-
# "
|
3615
|
+
# "s ys": 0,
|
3662
3616
|
# "take_profit_price": "0.00000000000000000000",
|
3663
3617
|
# "take_profit_type": 0,
|
3664
3618
|
# "taker_fee": "0.00000000000000000000",
|
@@ -3668,6 +3622,40 @@ class coinex(Exchange, ImplicitAPI):
|
|
3668
3622
|
# "user_id": 3620173
|
3669
3623
|
# }
|
3670
3624
|
#
|
3625
|
+
#
|
3626
|
+
# fetchPositionHistory
|
3627
|
+
#
|
3628
|
+
# {
|
3629
|
+
# amount_max: '10',
|
3630
|
+
# amount_max_margin: '2.03466666666666666666',
|
3631
|
+
# bkr_price: '0',
|
3632
|
+
# create_time: '1711150526.2581',
|
3633
|
+
# deal_all: '12.591',
|
3634
|
+
# deal_asset_fee: '0',
|
3635
|
+
# fee_asset: '',
|
3636
|
+
# finish_type: '5',
|
3637
|
+
# first_price: '0.6104',
|
3638
|
+
# latest_price: '0.6487',
|
3639
|
+
# leverage: '3',
|
3640
|
+
# liq_amount: '0',
|
3641
|
+
# liq_price: '0',
|
3642
|
+
# liq_profit: '0',
|
3643
|
+
# mainten_margin: '0.01',
|
3644
|
+
# market: 'XRPUSDT',
|
3645
|
+
# market_type: '1',
|
3646
|
+
# open_price: '0.6104',
|
3647
|
+
# open_val_max: '6.104',
|
3648
|
+
# position_id: '297371462',
|
3649
|
+
# profit_real: '0.35702107169',
|
3650
|
+
# settle_price: '0.6104',
|
3651
|
+
# settle_val: '0',
|
3652
|
+
# side: '2',
|
3653
|
+
# s ys: "0",
|
3654
|
+
# type: '2',
|
3655
|
+
# update_time: '1711391446.133233',
|
3656
|
+
# user_id: '3685860'
|
3657
|
+
# }
|
3658
|
+
#
|
3671
3659
|
marketId = self.safe_string(position, 'market')
|
3672
3660
|
market = self.safe_market(marketId, market, None, 'swap')
|
3673
3661
|
symbol = market['symbol']
|
@@ -3683,7 +3671,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3683
3671
|
timestamp = self.safe_timestamp(position, 'update_time')
|
3684
3672
|
maintenanceMargin = self.safe_string(position, 'mainten_margin_amount')
|
3685
3673
|
maintenanceMarginPercentage = self.safe_string(position, 'mainten_margin')
|
3686
|
-
collateral = self.
|
3674
|
+
collateral = self.safe_string_2(position, 'margin_amount', 'amount_max_margin')
|
3687
3675
|
leverage = self.safe_string(position, 'leverage')
|
3688
3676
|
notional = self.safe_string(position, 'open_val')
|
3689
3677
|
initialMargin = Precise.string_div(notional, leverage)
|
@@ -3893,7 +3881,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3893
3881
|
# "side": 2,
|
3894
3882
|
# "stop_loss_price": "0.00000000000000000000",
|
3895
3883
|
# "stop_loss_type": 0,
|
3896
|
-
# "
|
3884
|
+
# "s ys": 0,
|
3897
3885
|
# "take_profit_price": "0.00000000000000000000",
|
3898
3886
|
# "take_profit_type": 0,
|
3899
3887
|
# "taker_fee": "0.00000000000000000000",
|
@@ -3958,7 +3946,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3958
3946
|
# "side": 2,
|
3959
3947
|
# "stop_loss_price": "0.00000000000000000000",
|
3960
3948
|
# "stop_loss_type": 0,
|
3961
|
-
# "
|
3949
|
+
# "sy s": 0,
|
3962
3950
|
# "take_profit_price": "0.00000000000000000000",
|
3963
3951
|
# "take_profit_type": 0,
|
3964
3952
|
# "taker_fee": "0.00000000000000000000",
|
@@ -4002,7 +3990,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
4002
3990
|
'datetime': self.iso8601(timestamp),
|
4003
3991
|
}
|
4004
3992
|
|
4005
|
-
async def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
|
3993
|
+
async def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
4006
3994
|
"""
|
4007
3995
|
add margin
|
4008
3996
|
:see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http032_adjust_position_margin
|
@@ -4013,7 +4001,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
4013
4001
|
"""
|
4014
4002
|
return await self.modify_margin_helper(symbol, amount, 1, params)
|
4015
4003
|
|
4016
|
-
async def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
|
4004
|
+
async def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
4017
4005
|
"""
|
4018
4006
|
remove margin from a position
|
4019
4007
|
:see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http032_adjust_position_margin
|
@@ -4265,7 +4253,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
4265
4253
|
result.append(self.parse_funding_rate(ticker, marketInner))
|
4266
4254
|
return self.filter_by_array(result, 'symbol', symbols)
|
4267
4255
|
|
4268
|
-
async def withdraw(self, code: str, amount: float, address, tag=None, params={}):
|
4256
|
+
async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
|
4269
4257
|
"""
|
4270
4258
|
make a withdrawal
|
4271
4259
|
:see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account015_submit_withdraw
|
@@ -5252,6 +5240,77 @@ class coinex(Exchange, ImplicitAPI):
|
|
5252
5240
|
'shortLeverage': leverageValue,
|
5253
5241
|
}
|
5254
5242
|
|
5243
|
+
async def fetch_position_history(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> Position:
|
5244
|
+
"""
|
5245
|
+
fetches historical positions
|
5246
|
+
:see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http033-0_finished_position
|
5247
|
+
:param str symbol: unified contract symbol
|
5248
|
+
:param int [since]: not used by coinex fetchPositionHistory
|
5249
|
+
:param int [limit]: the maximum amount of records to fetch, default=1000
|
5250
|
+
:param dict params: extra parameters specific to the exchange api endpoint
|
5251
|
+
*
|
5252
|
+
* EXCHANGE SPECIFIC PARAMETERS
|
5253
|
+
:param int [params.side]: 0: all 1: sell, 2: buy
|
5254
|
+
:returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
|
5255
|
+
"""
|
5256
|
+
await self.load_markets()
|
5257
|
+
market = self.market(symbol)
|
5258
|
+
if limit is None:
|
5259
|
+
limit = 1000
|
5260
|
+
request = {
|
5261
|
+
'market': market['id'],
|
5262
|
+
'side': 0,
|
5263
|
+
'limit': limit,
|
5264
|
+
}
|
5265
|
+
response = await self.v1PerpetualPrivateGetPositionFinished(self.extend(request, params))
|
5266
|
+
#
|
5267
|
+
# {
|
5268
|
+
# code: '0',
|
5269
|
+
# data: {
|
5270
|
+
# limit: '1000',
|
5271
|
+
# offset: '0',
|
5272
|
+
# records: [
|
5273
|
+
# {
|
5274
|
+
# amount_max: '10',
|
5275
|
+
# amount_max_margin: '2.03466666666666666666',
|
5276
|
+
# bkr_price: '0',
|
5277
|
+
# create_time: '1711150526.2581',
|
5278
|
+
# deal_all: '12.591',
|
5279
|
+
# deal_asset_fee: '0',
|
5280
|
+
# fee_asset: '',
|
5281
|
+
# finish_type: '5',
|
5282
|
+
# first_price: '0.6104',
|
5283
|
+
# latest_price: '0.6487',
|
5284
|
+
# leverage: '3',
|
5285
|
+
# liq_amount: '0',
|
5286
|
+
# liq_price: '0',
|
5287
|
+
# liq_profit: '0',
|
5288
|
+
# mainten_margin: '0.01',
|
5289
|
+
# market: 'XRPUSDT',
|
5290
|
+
# market_type: '1',
|
5291
|
+
# open_price: '0.6104',
|
5292
|
+
# open_val_max: '6.104',
|
5293
|
+
# position_id: '297371462',
|
5294
|
+
# profit_real: '0.35702107169',
|
5295
|
+
# settle_price: '0.6104',
|
5296
|
+
# settle_val: '0',
|
5297
|
+
# side: '2',
|
5298
|
+
# sy s: '0',
|
5299
|
+
# type: '2',
|
5300
|
+
# update_time: '1711391446.133233',
|
5301
|
+
# user_id: '3685860'
|
5302
|
+
# },
|
5303
|
+
# ...
|
5304
|
+
# ]
|
5305
|
+
# },
|
5306
|
+
# message: 'OK'
|
5307
|
+
# }
|
5308
|
+
#
|
5309
|
+
data = self.safe_dict(response, 'data')
|
5310
|
+
records = self.safe_list(data, 'records')
|
5311
|
+
positions = self.parse_positions(records)
|
5312
|
+
return self.filter_by_symbol_since_limit(positions, symbol, since, limit)
|
5313
|
+
|
5255
5314
|
def handle_margin_mode_and_params(self, methodName, params={}, defaultValue=None):
|
5256
5315
|
"""
|
5257
5316
|
* @ignore
|
@@ -5344,7 +5403,10 @@ class coinex(Exchange, ImplicitAPI):
|
|
5344
5403
|
self.check_required_credentials()
|
5345
5404
|
query = self.keysort(query)
|
5346
5405
|
urlencoded = self.rawencode(query)
|
5347
|
-
preparedString = method + '/' + version + '/' + path
|
5406
|
+
preparedString = method + '/' + version + '/' + path
|
5407
|
+
if urlencoded:
|
5408
|
+
preparedString += '?' + urlencoded
|
5409
|
+
preparedString += nonce + self.secret
|
5348
5410
|
signature = self.hash(self.encode(preparedString), 'sha256')
|
5349
5411
|
headers = {
|
5350
5412
|
'X-COINEX-KEY': self.apiKey,
|
@@ -5352,7 +5414,8 @@ class coinex(Exchange, ImplicitAPI):
|
|
5352
5414
|
'X-COINEX-TIMESTAMP': nonce,
|
5353
5415
|
}
|
5354
5416
|
if (method == 'GET') or (method == 'DELETE') or (method == 'PUT'):
|
5355
|
-
|
5417
|
+
if urlencoded:
|
5418
|
+
url += '?' + urlencoded
|
5356
5419
|
else:
|
5357
5420
|
body = self.json(query)
|
5358
5421
|
return {'url': url, 'method': method, 'body': body, 'headers': headers}
|