ccxt 4.4.24__py2.py3-none-any.whl → 4.4.26__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/alpaca.py +1 -0
- ccxt/abstract/bingx.py +1 -0
- ccxt/abstract/okx.py +1 -0
- ccxt/abstract/phemex.py +1 -0
- ccxt/alpaca.py +245 -12
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/alpaca.py +245 -12
- ccxt/async_support/base/exchange.py +6 -6
- ccxt/async_support/binance.py +5 -6
- ccxt/async_support/bingx.py +6 -1
- ccxt/async_support/bitget.py +5 -5
- ccxt/async_support/bitmart.py +6 -6
- ccxt/async_support/bitmex.py +8 -7
- ccxt/async_support/bybit.py +6 -15
- ccxt/async_support/cex.py +36 -0
- ccxt/async_support/coinex.py +50 -28
- ccxt/async_support/digifinex.py +5 -5
- ccxt/async_support/exmo.py +1 -0
- ccxt/async_support/gate.py +6 -6
- ccxt/async_support/hitbtc.py +5 -9
- ccxt/async_support/htx.py +21 -22
- ccxt/async_support/hyperliquid.py +12 -4
- ccxt/async_support/kucoin.py +5 -5
- ccxt/async_support/okx.py +6 -5
- ccxt/async_support/phemex.py +4 -2
- ccxt/async_support/whitebit.py +5 -5
- ccxt/async_support/woo.py +1 -1
- ccxt/async_support/woofipro.py +1 -1
- ccxt/async_support/xt.py +36 -25
- ccxt/base/exchange.py +11 -6
- ccxt/base/types.py +12 -0
- ccxt/binance.py +5 -6
- ccxt/bingx.py +6 -1
- ccxt/bitget.py +5 -5
- ccxt/bitmart.py +6 -6
- ccxt/bitmex.py +8 -7
- ccxt/bybit.py +6 -15
- ccxt/cex.py +36 -0
- ccxt/coinex.py +50 -28
- ccxt/digifinex.py +5 -5
- ccxt/exmo.py +1 -0
- ccxt/gate.py +6 -6
- ccxt/hitbtc.py +5 -9
- ccxt/htx.py +21 -22
- ccxt/hyperliquid.py +12 -4
- ccxt/kucoin.py +5 -5
- ccxt/okx.py +6 -5
- ccxt/phemex.py +4 -2
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/exmo.py +204 -4
- ccxt/test/tests_helpers.py +3 -1
- ccxt/whitebit.py +5 -5
- ccxt/woo.py +1 -1
- ccxt/woofipro.py +1 -1
- ccxt/xt.py +36 -25
- {ccxt-4.4.24.dist-info → ccxt-4.4.26.dist-info}/METADATA +7 -7
- {ccxt-4.4.24.dist-info → ccxt-4.4.26.dist-info}/RECORD +61 -61
- {ccxt-4.4.24.dist-info → ccxt-4.4.26.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.24.dist-info → ccxt-4.4.26.dist-info}/WHEEL +0 -0
- {ccxt-4.4.24.dist-info → ccxt-4.4.26.dist-info}/top_level.txt +0 -0
ccxt/async_support/kucoin.py
CHANGED
@@ -9,7 +9,7 @@ import asyncio
|
|
9
9
|
import hashlib
|
10
10
|
import math
|
11
11
|
import json
|
12
|
-
from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, DepositAddress, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
|
12
|
+
from ccxt.base.types import Account, Balances, BorrowInterest, Bool, Currencies, Currency, DepositAddress, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
|
13
13
|
from typing import List
|
14
14
|
from ccxt.base.errors import ExchangeError
|
15
15
|
from ccxt.base.errors import AuthenticationError
|
@@ -4154,7 +4154,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4154
4154
|
'info': info,
|
4155
4155
|
}
|
4156
4156
|
|
4157
|
-
async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
4157
|
+
async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
|
4158
4158
|
"""
|
4159
4159
|
fetch the interest owed by the user for borrowing currency for margin trading
|
4160
4160
|
:see: https://docs.kucoin.com/#get-repay-record
|
@@ -4249,7 +4249,7 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4249
4249
|
assets = self.safe_list(data, 'assets', []) if (marginMode == 'isolated') else self.safe_list(data, 'accounts', [])
|
4250
4250
|
return self.parse_borrow_interests(assets, None)
|
4251
4251
|
|
4252
|
-
def parse_borrow_interest(self, info: dict, market: Market = None):
|
4252
|
+
def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
|
4253
4253
|
#
|
4254
4254
|
# Cross
|
4255
4255
|
#
|
@@ -4312,15 +4312,15 @@ class kucoin(Exchange, ImplicitAPI):
|
|
4312
4312
|
interest = self.safe_number(info, 'accruedInterest')
|
4313
4313
|
currencyId = self.safe_string(info, 'currency')
|
4314
4314
|
return {
|
4315
|
+
'info': info,
|
4315
4316
|
'symbol': symbol,
|
4316
|
-
'marginMode': marginMode,
|
4317
4317
|
'currency': self.safe_currency_code(currencyId),
|
4318
4318
|
'interest': interest,
|
4319
4319
|
'interestRate': self.safe_number(info, 'dailyIntRate'),
|
4320
4320
|
'amountBorrowed': amountBorrowed,
|
4321
|
+
'marginMode': marginMode,
|
4321
4322
|
'timestamp': timestamp, # create time
|
4322
4323
|
'datetime': self.iso8601(timestamp),
|
4323
|
-
'info': info,
|
4324
4324
|
}
|
4325
4325
|
|
4326
4326
|
async def fetch_borrow_rate_histories(self, codes=None, since: Int = None, limit: Int = None, params={}):
|
ccxt/async_support/okx.py
CHANGED
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.okx import ImplicitAPI
|
8
8
|
import asyncio
|
9
9
|
import hashlib
|
10
|
-
from ccxt.base.types import Account,
|
10
|
+
from ccxt.base.types import Account, Balances, BorrowInterest, Conversion, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, DepositAddress, Greeks, Int, LedgerEntry, Leverage, LeverageTier, LongShortRatio, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
|
11
11
|
from typing import List
|
12
12
|
from typing import Any
|
13
13
|
from ccxt.base.errors import ExchangeError
|
@@ -422,6 +422,7 @@ class okx(Exchange, ImplicitAPI):
|
|
422
422
|
# eth staking
|
423
423
|
'finance/staking-defi/eth/balance': 5 / 3,
|
424
424
|
'finance/staking-defi/eth/purchase-redeem-history': 5 / 3,
|
425
|
+
'finance/staking-defi/eth/product-info': 3,
|
425
426
|
# copytrading
|
426
427
|
'copytrading/current-subpositions': 1,
|
427
428
|
'copytrading/subpositions-history': 1,
|
@@ -6540,7 +6541,7 @@ class okx(Exchange, ImplicitAPI):
|
|
6540
6541
|
})
|
6541
6542
|
return tiers
|
6542
6543
|
|
6543
|
-
async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
6544
|
+
async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
|
6544
6545
|
"""
|
6545
6546
|
fetch the interest owed by the user for borrowing currency for margin trading
|
6546
6547
|
:see: https://www.okx.com/docs-v5/en/#rest-api-account-get-interest-accrued-data
|
@@ -6596,21 +6597,21 @@ class okx(Exchange, ImplicitAPI):
|
|
6596
6597
|
interest = self.parse_borrow_interests(data)
|
6597
6598
|
return self.filter_by_currency_since_limit(interest, code, since, limit)
|
6598
6599
|
|
6599
|
-
def parse_borrow_interest(self, info: dict, market: Market = None):
|
6600
|
+
def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
|
6600
6601
|
instId = self.safe_string(info, 'instId')
|
6601
6602
|
if instId is not None:
|
6602
6603
|
market = self.safe_market(instId, market)
|
6603
6604
|
timestamp = self.safe_integer(info, 'ts')
|
6604
6605
|
return {
|
6606
|
+
'info': info,
|
6605
6607
|
'symbol': self.safe_string(market, 'symbol'),
|
6606
|
-
'marginMode': self.safe_string(info, 'mgnMode'),
|
6607
6608
|
'currency': self.safe_currency_code(self.safe_string(info, 'ccy')),
|
6608
6609
|
'interest': self.safe_number(info, 'interest'),
|
6609
6610
|
'interestRate': self.safe_number(info, 'interestRate'),
|
6610
6611
|
'amountBorrowed': self.safe_number(info, 'liab'),
|
6612
|
+
'marginMode': self.safe_string(info, 'mgnMode'),
|
6611
6613
|
'timestamp': timestamp, # Interest accrued time
|
6612
6614
|
'datetime': self.iso8601(timestamp),
|
6613
|
-
'info': info,
|
6614
6615
|
}
|
6615
6616
|
|
6616
6617
|
async def borrow_cross_margin(self, code: str, amount: float, params={}):
|
ccxt/async_support/phemex.py
CHANGED
@@ -121,7 +121,7 @@ class phemex(Exchange, ImplicitAPI):
|
|
121
121
|
'private': 'https://{hostname}',
|
122
122
|
},
|
123
123
|
'www': 'https://phemex.com',
|
124
|
-
'doc': 'https://
|
124
|
+
'doc': 'https://phemex-docs.github.io/#overview',
|
125
125
|
'fees': 'https://phemex.com/fees-conditions',
|
126
126
|
'referral': {
|
127
127
|
'url': 'https://phemex.com/register?referralCode=EDNVJ',
|
@@ -179,6 +179,7 @@ class phemex(Exchange, ImplicitAPI):
|
|
179
179
|
'v2': {
|
180
180
|
'get': {
|
181
181
|
'public/products': 5,
|
182
|
+
'public/products-plus': 5,
|
182
183
|
'md/v2/orderbook': 5, # ?symbol=<symbol>&id=<id>
|
183
184
|
'md/v2/trade': 5, # ?symbol=<symbol>&id=<id>
|
184
185
|
'md/v2/ticker/24hr': 5, # ?symbol=<symbol>&id=<id>
|
@@ -746,13 +747,14 @@ class phemex(Exchange, ImplicitAPI):
|
|
746
747
|
'max': self.parse_safe_number(self.safe_string(market, 'maxOrderValue')),
|
747
748
|
},
|
748
749
|
},
|
749
|
-
'created':
|
750
|
+
'created': self.safe_integer(market, 'listTime'),
|
750
751
|
'info': market,
|
751
752
|
})
|
752
753
|
|
753
754
|
async def fetch_markets(self, params={}) -> List[Market]:
|
754
755
|
"""
|
755
756
|
retrieves data on all markets for phemex
|
757
|
+
:see: https://phemex-docs.github.io/#query-product-information-3
|
756
758
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
757
759
|
:returns dict[]: an array of objects representing market data
|
758
760
|
"""
|
ccxt/async_support/whitebit.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.whitebit import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Bool, Currencies, Currency, DepositAddress, Int, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFees, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Balances, BorrowInterest, Bool, Currencies, Currency, DepositAddress, Int, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, 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
|
@@ -2144,7 +2144,7 @@ class whitebit(Exchange, ImplicitAPI):
|
|
2144
2144
|
records = self.safe_list(response, 'records', [])
|
2145
2145
|
return self.parse_transactions(records, currency, since, limit)
|
2146
2146
|
|
2147
|
-
async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
2147
|
+
async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
|
2148
2148
|
"""
|
2149
2149
|
fetch the interest owed by the user for borrowing currency for margin trading
|
2150
2150
|
:see: https://docs.whitebit.com/private/http-trade-v4/#open-positions
|
@@ -2186,7 +2186,7 @@ class whitebit(Exchange, ImplicitAPI):
|
|
2186
2186
|
interest = self.parse_borrow_interests(response, market)
|
2187
2187
|
return self.filter_by_currency_since_limit(interest, code, since, limit)
|
2188
2188
|
|
2189
|
-
def parse_borrow_interest(self, info: dict, market: Market = None):
|
2189
|
+
def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
|
2190
2190
|
#
|
2191
2191
|
# {
|
2192
2192
|
# "positionId": 191823,
|
@@ -2210,15 +2210,15 @@ class whitebit(Exchange, ImplicitAPI):
|
|
2210
2210
|
symbol = self.safe_symbol(marketId, market, '_')
|
2211
2211
|
timestamp = self.safe_timestamp(info, 'modifyDate')
|
2212
2212
|
return {
|
2213
|
+
'info': info,
|
2213
2214
|
'symbol': symbol,
|
2214
|
-
'marginMode': 'cross',
|
2215
2215
|
'currency': 'USDT',
|
2216
2216
|
'interest': self.safe_number(info, 'unrealizedFunding'),
|
2217
2217
|
'interestRate': 0.00098, # https://whitebit.com/fees
|
2218
2218
|
'amountBorrowed': self.safe_number(info, 'amount'),
|
2219
|
+
'marginMode': 'cross',
|
2219
2220
|
'timestamp': timestamp,
|
2220
2221
|
'datetime': self.iso8601(timestamp),
|
2221
|
-
'info': info,
|
2222
2222
|
}
|
2223
2223
|
|
2224
2224
|
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
ccxt/async_support/woo.py
CHANGED
@@ -2332,7 +2332,7 @@ class woo(Exchange, ImplicitAPI):
|
|
2332
2332
|
#
|
2333
2333
|
return self.parse_transaction(response, currency)
|
2334
2334
|
|
2335
|
-
async def repay_margin(self, code: str, amount, symbol: Str = None, params={}):
|
2335
|
+
async def repay_margin(self, code: str, amount: float, symbol: Str = None, params={}):
|
2336
2336
|
"""
|
2337
2337
|
repay borrowed margin and interest
|
2338
2338
|
:see: https://docs.woo.org/#repay-interest
|
ccxt/async_support/woofipro.py
CHANGED
@@ -133,7 +133,7 @@ class woofipro(Exchange, ImplicitAPI):
|
|
133
133
|
'1y': '1y',
|
134
134
|
},
|
135
135
|
'urls': {
|
136
|
-
'logo': 'https://github.com/
|
136
|
+
'logo': 'https://github.com/user-attachments/assets/9ba21b8a-a9c7-4770-b7f1-ce3bcbde68c1',
|
137
137
|
'api': {
|
138
138
|
'public': 'https://api-evm.orderly.org',
|
139
139
|
'private': 'https://api-evm.orderly.org',
|
ccxt/async_support/xt.py
CHANGED
@@ -1699,6 +1699,9 @@ class xt(Exchange, ImplicitAPI):
|
|
1699
1699
|
market = self.safe_market(marketId, market, '_', marketType)
|
1700
1700
|
symbol = market['symbol']
|
1701
1701
|
timestamp = self.safe_integer(ticker, 't')
|
1702
|
+
percentage = self.safe_string_2(ticker, 'cr', 'r')
|
1703
|
+
if percentage is not None:
|
1704
|
+
percentage = Precise.string_mul(percentage, '100')
|
1702
1705
|
return self.safe_ticker({
|
1703
1706
|
'symbol': symbol,
|
1704
1707
|
'timestamp': timestamp,
|
@@ -1715,7 +1718,7 @@ class xt(Exchange, ImplicitAPI):
|
|
1715
1718
|
'last': self.safe_string(ticker, 'c'),
|
1716
1719
|
'previousClose': None,
|
1717
1720
|
'change': self.safe_number(ticker, 'cv'),
|
1718
|
-
'percentage': self.
|
1721
|
+
'percentage': self.parse_number(percentage),
|
1719
1722
|
'average': None,
|
1720
1723
|
'baseVolume': None,
|
1721
1724
|
'quoteVolume': self.safe_number_2(ticker, 'a', 'v'),
|
@@ -1903,6 +1906,17 @@ class xt(Exchange, ImplicitAPI):
|
|
1903
1906
|
# "b": True
|
1904
1907
|
# }
|
1905
1908
|
#
|
1909
|
+
# spot: watchTrades
|
1910
|
+
#
|
1911
|
+
# {
|
1912
|
+
# s: 'btc_usdt',
|
1913
|
+
# i: '228825383103928709',
|
1914
|
+
# t: 1684258222702,
|
1915
|
+
# p: '27003.65',
|
1916
|
+
# q: '0.000796',
|
1917
|
+
# b: True
|
1918
|
+
# }
|
1919
|
+
#
|
1906
1920
|
# spot: watchMyTrades
|
1907
1921
|
#
|
1908
1922
|
# {
|
@@ -1915,17 +1929,6 @@ class xt(Exchange, ImplicitAPI):
|
|
1915
1929
|
# "v": "90000" # volume trade amount
|
1916
1930
|
# }
|
1917
1931
|
#
|
1918
|
-
# spot: watchTrades
|
1919
|
-
#
|
1920
|
-
# {
|
1921
|
-
# s: 'btc_usdt',
|
1922
|
-
# i: '228825383103928709',
|
1923
|
-
# t: 1684258222702,
|
1924
|
-
# p: '27003.65',
|
1925
|
-
# q: '0.000796',
|
1926
|
-
# b: True
|
1927
|
-
# }
|
1928
|
-
#
|
1929
1932
|
# swap and future: fetchTrades
|
1930
1933
|
#
|
1931
1934
|
# {
|
@@ -2004,19 +2007,27 @@ class xt(Exchange, ImplicitAPI):
|
|
2004
2007
|
if marketType is None:
|
2005
2008
|
marketType = 'spot' if hasSpotKeys else 'contract'
|
2006
2009
|
market = self.safe_market(marketId, market, '_', marketType)
|
2007
|
-
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2018
|
-
|
2019
|
-
|
2010
|
+
side = None
|
2011
|
+
takerOrMaker = None
|
2012
|
+
isBuyerMaker = self.safe_bool(trade, 'b')
|
2013
|
+
if isBuyerMaker is not None:
|
2014
|
+
side = 'sell' if isBuyerMaker else 'buy'
|
2015
|
+
takerOrMaker = 'taker' # public trades always taker
|
2016
|
+
else:
|
2017
|
+
takerMaker = self.safe_string_lower(trade, 'takerMaker')
|
2018
|
+
if takerMaker is not None:
|
2019
|
+
takerOrMaker = takerMaker
|
2020
|
+
else:
|
2021
|
+
isMaker = self.safe_bool(trade, 'isMaker')
|
2022
|
+
if isMaker is not None:
|
2023
|
+
takerOrMaker = 'maker' if isMaker else 'taker'
|
2024
|
+
orderSide = self.safe_string_lower(trade, 'orderSide')
|
2025
|
+
if orderSide is not None:
|
2026
|
+
side = orderSide
|
2027
|
+
else:
|
2028
|
+
bidOrAsk = self.safe_string(trade, 'm')
|
2029
|
+
if bidOrAsk is not None:
|
2030
|
+
side = 'buy' if (bidOrAsk == 'BID') else 'sell'
|
2020
2031
|
timestamp = self.safe_integer_n(trade, ['t', 'time', 'timestamp'])
|
2021
2032
|
quantity = self.safe_string_2(trade, 'q', 'quantity')
|
2022
2033
|
amount = None
|
ccxt/base/exchange.py
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
__version__ = '4.4.
|
7
|
+
__version__ = '4.4.26'
|
8
8
|
|
9
9
|
# -----------------------------------------------------------------------------
|
10
10
|
|
@@ -296,6 +296,7 @@ class Exchange(object):
|
|
296
296
|
quote_currencies = None
|
297
297
|
currencies = None
|
298
298
|
options = None # Python does not allow to define properties in run-time with setattr
|
299
|
+
isSandboxModeEnabled = False
|
299
300
|
accounts = None
|
300
301
|
positions = None
|
301
302
|
|
@@ -2403,6 +2404,8 @@ class Exchange(object):
|
|
2403
2404
|
self.urls['api'] = self.clone(self.urls['test'])
|
2404
2405
|
else:
|
2405
2406
|
raise NotSupported(self.id + ' does not have a sandbox URL')
|
2407
|
+
# set flag
|
2408
|
+
self.isSandboxModeEnabled = True
|
2406
2409
|
elif 'apiBackup' in self.urls:
|
2407
2410
|
if isinstance(self.urls['api'], str):
|
2408
2411
|
self.urls['api'] = self.urls['apiBackup']
|
@@ -2410,6 +2413,8 @@ class Exchange(object):
|
|
2410
2413
|
self.urls['api'] = self.clone(self.urls['apiBackup'])
|
2411
2414
|
newUrls = self.omit(self.urls, 'apiBackup')
|
2412
2415
|
self.urls = newUrls
|
2416
|
+
# set flag
|
2417
|
+
self.isSandboxModeEnabled = False
|
2413
2418
|
|
2414
2419
|
def sign(self, path, api: Any = 'public', method='GET', params={}, headers: Any = None, body: Any = None):
|
2415
2420
|
return {}
|
@@ -3509,13 +3514,13 @@ class Exchange(object):
|
|
3509
3514
|
'markPrice': self.safe_number(ticker, 'markPrice'),
|
3510
3515
|
})
|
3511
3516
|
|
3512
|
-
def fetch_borrow_rate(self, code: str, amount, params={}):
|
3517
|
+
def fetch_borrow_rate(self, code: str, amount: float, params={}):
|
3513
3518
|
raise NotSupported(self.id + ' fetchBorrowRate is deprecated, please use fetchCrossBorrowRate or fetchIsolatedBorrowRate instead')
|
3514
3519
|
|
3515
|
-
def repay_cross_margin(self, code: str, amount, params={}):
|
3520
|
+
def repay_cross_margin(self, code: str, amount: float, params={}):
|
3516
3521
|
raise NotSupported(self.id + ' repayCrossMargin is not support yet')
|
3517
3522
|
|
3518
|
-
def repay_isolated_margin(self, symbol: str, code: str, amount, params={}):
|
3523
|
+
def repay_isolated_margin(self, symbol: str, code: str, amount: float, params={}):
|
3519
3524
|
raise NotSupported(self.id + ' repayIsolatedMargin is not support yet')
|
3520
3525
|
|
3521
3526
|
def borrow_cross_margin(self, code: str, amount: float, params={}):
|
@@ -3524,10 +3529,10 @@ class Exchange(object):
|
|
3524
3529
|
def borrow_isolated_margin(self, symbol: str, code: str, amount: float, params={}):
|
3525
3530
|
raise NotSupported(self.id + ' borrowIsolatedMargin is not support yet')
|
3526
3531
|
|
3527
|
-
def borrow_margin(self, code: str, amount, symbol: Str = None, params={}):
|
3532
|
+
def borrow_margin(self, code: str, amount: float, symbol: Str = None, params={}):
|
3528
3533
|
raise NotSupported(self.id + ' borrowMargin is deprecated, please use borrowCrossMargin or borrowIsolatedMargin instead')
|
3529
3534
|
|
3530
|
-
def repay_margin(self, code: str, amount, symbol: Str = None, params={}):
|
3535
|
+
def repay_margin(self, code: str, amount: float, symbol: Str = None, params={}):
|
3531
3536
|
raise NotSupported(self.id + ' repayMargin is deprecated, please use repayCrossMargin or repayIsolatedMargin instead')
|
3532
3537
|
|
3533
3538
|
def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}):
|
ccxt/base/types.py
CHANGED
@@ -542,6 +542,18 @@ class LongShortRatio:
|
|
542
542
|
longShortRatio: float
|
543
543
|
|
544
544
|
|
545
|
+
class BorrowInterest:
|
546
|
+
info: Any
|
547
|
+
symbol: Optional[Str]
|
548
|
+
currency: Optional[Str]
|
549
|
+
interest: Optional[Num]
|
550
|
+
interestRate: Optional[Num]
|
551
|
+
amountBorrowed: Optional[Num]
|
552
|
+
marginMode: Optional[Str]
|
553
|
+
timestamp: Optional[Int]
|
554
|
+
datetime: Optional[Str]
|
555
|
+
|
556
|
+
|
545
557
|
FundingRates = Dict[Str, FundingRate]
|
546
558
|
LastPrices = Dict[Str, LastPrice]
|
547
559
|
Currencies = Dict[Str, CurrencyInterface]
|
ccxt/binance.py
CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.binance import ImplicitAPI
|
8
8
|
import hashlib
|
9
9
|
import json
|
10
|
-
from ccxt.base.types import
|
10
|
+
from ccxt.base.types import Balances, BorrowInterest, Conversion, CrossBorrowRate, Currencies, Currency, DepositAddress, Greeks, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, Leverage, Leverages, LeverageTier, LeverageTiers, LongShortRatio, MarginMode, MarginModes, MarginModification, Market, MarketInterface, Num, Option, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
13
13
|
from ccxt.base.errors import AuthenticationError
|
@@ -11304,7 +11304,7 @@ class binance(Exchange, ImplicitAPI):
|
|
11304
11304
|
#
|
11305
11305
|
return response
|
11306
11306
|
|
11307
|
-
def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
11307
|
+
def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
|
11308
11308
|
"""
|
11309
11309
|
fetch the interest owed by the user for borrowing currency for margin trading
|
11310
11310
|
:see: https://developers.binance.com/docs/margin_trading/borrow-and-repay/Get-Interest-History
|
@@ -11378,21 +11378,20 @@ class binance(Exchange, ImplicitAPI):
|
|
11378
11378
|
interest = self.parse_borrow_interests(rows, market)
|
11379
11379
|
return self.filter_by_currency_since_limit(interest, code, since, limit)
|
11380
11380
|
|
11381
|
-
def parse_borrow_interest(self, info: dict, market: Market = None):
|
11381
|
+
def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
|
11382
11382
|
symbol = self.safe_string(info, 'isolatedSymbol')
|
11383
11383
|
timestamp = self.safe_integer(info, 'interestAccuredTime')
|
11384
11384
|
marginMode = 'cross' if (symbol is None) else 'isolated'
|
11385
11385
|
return {
|
11386
|
-
'
|
11386
|
+
'info': info,
|
11387
11387
|
'symbol': symbol,
|
11388
|
-
'marginMode': marginMode,
|
11389
11388
|
'currency': self.safe_currency_code(self.safe_string(info, 'asset')),
|
11390
11389
|
'interest': self.safe_number(info, 'interest'),
|
11391
11390
|
'interestRate': self.safe_number(info, 'interestRate'),
|
11392
11391
|
'amountBorrowed': self.safe_number(info, 'principal'),
|
11392
|
+
'marginMode': marginMode,
|
11393
11393
|
'timestamp': timestamp,
|
11394
11394
|
'datetime': self.iso8601(timestamp),
|
11395
|
-
'info': info,
|
11396
11395
|
}
|
11397
11396
|
|
11398
11397
|
def repay_cross_margin(self, code: str, amount, params={}):
|
ccxt/bingx.py
CHANGED
@@ -219,6 +219,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
219
219
|
'market/markPriceKlines': 1,
|
220
220
|
'trade/batchCancelReplace': 5,
|
221
221
|
'trade/fullOrder': 2,
|
222
|
+
'positionMargin/history': 2,
|
222
223
|
},
|
223
224
|
'post': {
|
224
225
|
'trade/cancelReplace': 2,
|
@@ -2676,6 +2677,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
2676
2677
|
:see: https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Bulk%20order
|
2677
2678
|
:param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
2678
2679
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2680
|
+
:param boolean [params.sync]: *spot only* if True, multiple orders are ordered serially and all orders do not require the same symbol/side/type
|
2679
2681
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
2680
2682
|
"""
|
2681
2683
|
self.load_markets()
|
@@ -2703,6 +2705,9 @@ class bingx(Exchange, ImplicitAPI):
|
|
2703
2705
|
request['batchOrders'] = self.json(ordersRequests)
|
2704
2706
|
response = self.swapV2PrivatePostTradeBatchOrders(request)
|
2705
2707
|
else:
|
2708
|
+
sync = self.safe_bool(params, 'sync', False)
|
2709
|
+
if sync:
|
2710
|
+
request['sync'] = True
|
2706
2711
|
request['data'] = self.json(ordersRequests)
|
2707
2712
|
response = self.spotV1PrivatePostTradeBatchOrders(request)
|
2708
2713
|
#
|
@@ -3139,7 +3144,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
3139
3144
|
'cost': Precise.string_abs(feeCost),
|
3140
3145
|
},
|
3141
3146
|
'trades': None,
|
3142
|
-
'reduceOnly': self.
|
3147
|
+
'reduceOnly': self.safe_bool_2(order, 'reduceOnly', 'ro'),
|
3143
3148
|
}, market)
|
3144
3149
|
|
3145
3150
|
def parse_order_status(self, status: Str):
|
ccxt/bitget.py
CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.bitget import ImplicitAPI
|
8
8
|
import hashlib
|
9
9
|
import json
|
10
|
-
from ccxt.base.types import
|
10
|
+
from ccxt.base.types import Balances, BorrowInterest, Conversion, CrossBorrowRate, Currencies, Currency, DepositAddress, FundingHistory, Int, IsolatedBorrowRate, LedgerEntry, Leverage, LeverageTier, Liquidation, LongShortRatio, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
13
13
|
from ccxt.base.errors import AuthenticationError
|
@@ -7628,7 +7628,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7628
7628
|
'info': info,
|
7629
7629
|
}
|
7630
7630
|
|
7631
|
-
def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
7631
|
+
def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
|
7632
7632
|
"""
|
7633
7633
|
fetch the interest owed by the user for borrowing currency for margin trading
|
7634
7634
|
:see: https://www.bitget.com/api-doc/margin/cross/record/Get-Cross-Interest-Records
|
@@ -7725,7 +7725,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7725
7725
|
interest = self.parse_borrow_interests(rows, market)
|
7726
7726
|
return self.filter_by_currency_since_limit(interest, code, since, limit)
|
7727
7727
|
|
7728
|
-
def parse_borrow_interest(self, info: dict, market: Market = None):
|
7728
|
+
def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
|
7729
7729
|
#
|
7730
7730
|
# isolated
|
7731
7731
|
#
|
@@ -7759,15 +7759,15 @@ class bitget(Exchange, ImplicitAPI):
|
|
7759
7759
|
marginMode = 'isolated' if (marketId is not None) else 'cross'
|
7760
7760
|
timestamp = self.safe_integer(info, 'cTime')
|
7761
7761
|
return {
|
7762
|
+
'info': info,
|
7762
7763
|
'symbol': self.safe_string(market, 'symbol'),
|
7763
|
-
'marginMode': marginMode,
|
7764
7764
|
'currency': self.safe_currency_code(self.safe_string(info, 'interestCoin')),
|
7765
7765
|
'interest': self.safe_number(info, 'interestAmount'),
|
7766
7766
|
'interestRate': self.safe_number(info, 'dailyInterestRate'),
|
7767
7767
|
'amountBorrowed': None,
|
7768
|
+
'marginMode': marginMode,
|
7768
7769
|
'timestamp': timestamp,
|
7769
7770
|
'datetime': self.iso8601(timestamp),
|
7770
|
-
'info': info,
|
7771
7771
|
}
|
7772
7772
|
|
7773
7773
|
def close_position(self, symbol: str, side: OrderSide = None, params={}) -> Order:
|
ccxt/bitmart.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.bitmart import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currencies, Currency, DepositAddress, Int, IsolatedBorrowRate, IsolatedBorrowRates, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Balances, BorrowInterest, Currencies, Currency, DepositAddress, Int, IsolatedBorrowRate, IsolatedBorrowRates, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -1806,7 +1806,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
1806
1806
|
if since is not None:
|
1807
1807
|
request['after'] = self.parse_to_int((since / 1000)) - 1
|
1808
1808
|
else:
|
1809
|
-
maxLimit =
|
1809
|
+
maxLimit = 500
|
1810
1810
|
if limit is None:
|
1811
1811
|
limit = maxLimit
|
1812
1812
|
limit = min(maxLimit, limit)
|
@@ -3983,7 +3983,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
3983
3983
|
records = self.safe_list(data, 'records', [])
|
3984
3984
|
return self.parse_transfers(records, currency, since, limit)
|
3985
3985
|
|
3986
|
-
def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
3986
|
+
def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
|
3987
3987
|
"""
|
3988
3988
|
fetch the interest owed by the user for borrowing currency for margin trading
|
3989
3989
|
:see: https://developer-pro.bitmart.com/en/spot/#get-borrow-record-isolated
|
@@ -4032,7 +4032,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
4032
4032
|
interest = self.parse_borrow_interests(rows, market)
|
4033
4033
|
return self.filter_by_currency_since_limit(interest, code, since, limit)
|
4034
4034
|
|
4035
|
-
def parse_borrow_interest(self, info: dict, market: Market = None):
|
4035
|
+
def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
|
4036
4036
|
#
|
4037
4037
|
# {
|
4038
4038
|
# "borrow_id": "1657664327844Lk5eJJugXmdHHZoe",
|
@@ -4049,15 +4049,15 @@ class bitmart(Exchange, ImplicitAPI):
|
|
4049
4049
|
market = self.safe_market(marketId, market)
|
4050
4050
|
timestamp = self.safe_integer(info, 'create_time')
|
4051
4051
|
return {
|
4052
|
+
'info': info,
|
4052
4053
|
'symbol': self.safe_string(market, 'symbol'),
|
4053
|
-
'marginMode': 'isolated',
|
4054
4054
|
'currency': self.safe_currency_code(self.safe_string(info, 'currency')),
|
4055
4055
|
'interest': self.safe_number(info, 'interest_amount'),
|
4056
4056
|
'interestRate': self.safe_number(info, 'hourly_interest'),
|
4057
4057
|
'amountBorrowed': self.safe_number(info, 'borrow_amount'),
|
4058
|
+
'marginMode': 'isolated',
|
4058
4059
|
'timestamp': timestamp, # borrow creation time
|
4059
4060
|
'datetime': self.iso8601(timestamp),
|
4060
|
-
'info': info,
|
4061
4061
|
}
|
4062
4062
|
|
4063
4063
|
def fetch_open_interest(self, symbol: str, params={}):
|
ccxt/bitmex.py
CHANGED
@@ -1108,17 +1108,18 @@ class bitmex(Exchange, ImplicitAPI):
|
|
1108
1108
|
# set the timestamp to zero, 1970 Jan 1 00:00:00
|
1109
1109
|
# for unrealized pnl and other transactions without a timestamp
|
1110
1110
|
timestamp = 0 # see comments above
|
1111
|
+
fee = None
|
1111
1112
|
feeCost = self.safe_string(item, 'fee')
|
1112
1113
|
if feeCost is not None:
|
1113
1114
|
feeCost = self.convert_to_real_amount(code, feeCost)
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1115
|
+
fee = {
|
1116
|
+
'cost': self.parse_number(feeCost),
|
1117
|
+
'currency': code,
|
1118
|
+
}
|
1118
1119
|
after = self.safe_string(item, 'walletBalance')
|
1119
1120
|
if after is not None:
|
1120
1121
|
after = self.convert_to_real_amount(code, after)
|
1121
|
-
before = self.
|
1122
|
+
before = self.parse_number(Precise.string_sub(self.number_to_string(after), self.number_to_string(amount)))
|
1122
1123
|
direction = None
|
1123
1124
|
if Precise.string_lt(amountString, '0'):
|
1124
1125
|
direction = 'out'
|
@@ -1137,9 +1138,9 @@ class bitmex(Exchange, ImplicitAPI):
|
|
1137
1138
|
'referenceAccount': referenceAccount,
|
1138
1139
|
'type': type,
|
1139
1140
|
'currency': code,
|
1140
|
-
'amount': self.
|
1141
|
+
'amount': self.parse_number(amount),
|
1141
1142
|
'before': before,
|
1142
|
-
'after': self.
|
1143
|
+
'after': self.parse_number(after),
|
1143
1144
|
'status': status,
|
1144
1145
|
'fee': fee,
|
1145
1146
|
}, currency)
|