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