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/alpaca.py
CHANGED
@@ -5,10 +5,11 @@
|
|
5
5
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.alpaca import ImplicitAPI
|
8
|
-
from ccxt.base.types import Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Trade
|
8
|
+
from ccxt.base.types import Currency, DepositAddress, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade
|
9
9
|
from typing import List
|
10
10
|
from ccxt.base.errors import ExchangeError
|
11
11
|
from ccxt.base.errors import PermissionDenied
|
12
|
+
from ccxt.base.errors import ArgumentsRequired
|
12
13
|
from ccxt.base.errors import BadRequest
|
13
14
|
from ccxt.base.errors import BadSymbol
|
14
15
|
from ccxt.base.errors import InsufficientFunds
|
@@ -63,7 +64,7 @@ class alpaca(Exchange, ImplicitAPI):
|
|
63
64
|
'fetchBidsAsks': False,
|
64
65
|
'fetchClosedOrders': True,
|
65
66
|
'fetchCurrencies': False,
|
66
|
-
'fetchDepositAddress':
|
67
|
+
'fetchDepositAddress': True,
|
67
68
|
'fetchDepositAddressesByNetwork': False,
|
68
69
|
'fetchDeposits': False,
|
69
70
|
'fetchDepositsWithdrawals': False,
|
@@ -74,7 +75,7 @@ class alpaca(Exchange, ImplicitAPI):
|
|
74
75
|
'fetchL1OrderBook': True,
|
75
76
|
'fetchL2OrderBook': False,
|
76
77
|
'fetchMarkets': True,
|
77
|
-
'fetchMyTrades':
|
78
|
+
'fetchMyTrades': True,
|
78
79
|
'fetchOHLCV': True,
|
79
80
|
'fetchOpenOrder': False,
|
80
81
|
'fetchOpenOrders': True,
|
@@ -89,8 +90,8 @@ class alpaca(Exchange, ImplicitAPI):
|
|
89
90
|
'fetchPositionsHistory': False,
|
90
91
|
'fetchPositionsRisk': False,
|
91
92
|
'fetchStatus': False,
|
92
|
-
'fetchTicker':
|
93
|
-
'fetchTickers':
|
93
|
+
'fetchTicker': True,
|
94
|
+
'fetchTickers': True,
|
94
95
|
'fetchTime': True,
|
95
96
|
'fetchTrades': True,
|
96
97
|
'fetchTradingFee': False,
|
@@ -129,6 +130,7 @@ class alpaca(Exchange, ImplicitAPI):
|
|
129
130
|
'v2/assets/{symbol_or_asset_id}',
|
130
131
|
'v2/corporate_actions/announcements/{id}',
|
131
132
|
'v2/corporate_actions/announcements',
|
133
|
+
'v2/wallets',
|
132
134
|
],
|
133
135
|
'post': [
|
134
136
|
'v2/orders',
|
@@ -671,6 +673,130 @@ class alpaca(Exchange, ImplicitAPI):
|
|
671
673
|
self.safe_number(ohlcv, 'v'), # volume
|
672
674
|
]
|
673
675
|
|
676
|
+
async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
|
677
|
+
"""
|
678
|
+
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
679
|
+
:see: https://docs.alpaca.markets/reference/cryptosnapshots-1
|
680
|
+
:param str symbol: unified symbol of the market to fetch the ticker for
|
681
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
682
|
+
:param str [params.loc]: crypto location, default: us
|
683
|
+
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
684
|
+
"""
|
685
|
+
await self.load_markets()
|
686
|
+
symbol = self.symbol(symbol)
|
687
|
+
tickers = await self.fetch_tickers([symbol], params)
|
688
|
+
return self.safe_dict(tickers, symbol)
|
689
|
+
|
690
|
+
async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
|
691
|
+
"""
|
692
|
+
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
693
|
+
:see: https://docs.alpaca.markets/reference/cryptosnapshots-1
|
694
|
+
:param str[] symbols: unified symbols of the markets to fetch tickers for
|
695
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
696
|
+
:param str [params.loc]: crypto location, default: us
|
697
|
+
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
698
|
+
"""
|
699
|
+
if symbols is None:
|
700
|
+
raise ArgumentsRequired(self.id + ' fetchTickers() requires a symbols argument')
|
701
|
+
await self.load_markets()
|
702
|
+
symbols = self.market_symbols(symbols)
|
703
|
+
loc = self.safe_string(params, 'loc', 'us')
|
704
|
+
ids = self.market_ids(symbols)
|
705
|
+
request = {
|
706
|
+
'symbols': ','.join(ids),
|
707
|
+
'loc': loc,
|
708
|
+
}
|
709
|
+
params = self.omit(params, 'loc')
|
710
|
+
response = await self.marketPublicGetV1beta3CryptoLocSnapshots(self.extend(request, params))
|
711
|
+
#
|
712
|
+
# {
|
713
|
+
# "snapshots": {
|
714
|
+
# "BTC/USD": {
|
715
|
+
# "dailyBar": {
|
716
|
+
# "c": 69403.554,
|
717
|
+
# "h": 69609.6515,
|
718
|
+
# "l": 69013.26,
|
719
|
+
# "n": 9,
|
720
|
+
# "o": 69536.7,
|
721
|
+
# "t": "2024-11-01T05:00:00Z",
|
722
|
+
# "v": 0.210809181,
|
723
|
+
# "vw": 69327.655393908
|
724
|
+
# },
|
725
|
+
# "latestQuote": {
|
726
|
+
# "ap": 69424.19,
|
727
|
+
# "as": 0.68149,
|
728
|
+
# "bp": 69366.086,
|
729
|
+
# "bs": 0.68312,
|
730
|
+
# "t": "2024-11-01T08:31:41.880246926Z"
|
731
|
+
# },
|
732
|
+
# "latestTrade": {
|
733
|
+
# "i": 5272941104897543146,
|
734
|
+
# "p": 69416.9,
|
735
|
+
# "s": 0.014017324,
|
736
|
+
# "t": "2024-11-01T08:14:28.245088803Z",
|
737
|
+
# "tks": "B"
|
738
|
+
# },
|
739
|
+
# "minuteBar": {
|
740
|
+
# "c": 69403.554,
|
741
|
+
# "h": 69403.554,
|
742
|
+
# "l": 69399.125,
|
743
|
+
# "n": 0,
|
744
|
+
# "o": 69399.125,
|
745
|
+
# "t": "2024-11-01T08:30:00Z",
|
746
|
+
# "v": 0,
|
747
|
+
# "vw": 0
|
748
|
+
# },
|
749
|
+
# "prevDailyBar": {
|
750
|
+
# "c": 69515.1415,
|
751
|
+
# "h": 72668.837,
|
752
|
+
# "l": 68796.85,
|
753
|
+
# "n": 129,
|
754
|
+
# "o": 72258.9,
|
755
|
+
# "t": "2024-10-31T05:00:00Z",
|
756
|
+
# "v": 2.217683307,
|
757
|
+
# "vw": 70782.6811608144
|
758
|
+
# }
|
759
|
+
# },
|
760
|
+
# }
|
761
|
+
# }
|
762
|
+
#
|
763
|
+
results = []
|
764
|
+
snapshots = self.safe_dict(response, 'snapshots', {})
|
765
|
+
marketIds = list(snapshots.keys())
|
766
|
+
for i in range(0, len(marketIds)):
|
767
|
+
marketId = marketIds[i]
|
768
|
+
market = self.safe_market(marketId)
|
769
|
+
entry = self.safe_dict(snapshots, marketId)
|
770
|
+
dailyBar = self.safe_dict(entry, 'dailyBar', {})
|
771
|
+
prevDailyBar = self.safe_dict(entry, 'prevDailyBar', {})
|
772
|
+
latestQuote = self.safe_dict(entry, 'latestQuote', {})
|
773
|
+
latestTrade = self.safe_dict(entry, 'latestTrade', {})
|
774
|
+
datetime = self.safe_string(latestQuote, 't')
|
775
|
+
ticker = self.safe_ticker({
|
776
|
+
'info': entry,
|
777
|
+
'symbol': market['symbol'],
|
778
|
+
'timestamp': self.parse8601(datetime),
|
779
|
+
'datetime': datetime,
|
780
|
+
'high': self.safe_string(dailyBar, 'h'),
|
781
|
+
'low': self.safe_string(dailyBar, 'l'),
|
782
|
+
'bid': self.safe_string(latestQuote, 'bp'),
|
783
|
+
'bidVolume': self.safe_string(latestQuote, 'bs'),
|
784
|
+
'ask': self.safe_string(latestQuote, 'ap'),
|
785
|
+
'askVolume': self.safe_string(latestQuote, 'as'),
|
786
|
+
'vwap': self.safe_string(dailyBar, 'vw'),
|
787
|
+
'open': self.safe_string(dailyBar, 'o'),
|
788
|
+
'close': self.safe_string(dailyBar, 'c'),
|
789
|
+
'last': self.safe_string(latestTrade, 'p'),
|
790
|
+
'previousClose': self.safe_string(prevDailyBar, 'c'),
|
791
|
+
'change': None,
|
792
|
+
'percentage': None,
|
793
|
+
'average': None,
|
794
|
+
'baseVolume': self.safe_string(dailyBar, 'v'),
|
795
|
+
'quoteVolume': self.safe_string(dailyBar, 'n'),
|
796
|
+
}, market)
|
797
|
+
results.append(ticker)
|
798
|
+
return self.filter_by_array(results, 'symbol', symbols)
|
799
|
+
|
674
800
|
async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
675
801
|
"""
|
676
802
|
create a trade order
|
@@ -1014,7 +1140,54 @@ class alpaca(Exchange, ImplicitAPI):
|
|
1014
1140
|
}
|
1015
1141
|
return self.safe_string(timeInForces, timeInForce, timeInForce)
|
1016
1142
|
|
1143
|
+
async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
1144
|
+
"""
|
1145
|
+
fetch all trades made by the user
|
1146
|
+
:see: https://docs.alpaca.markets/reference/getaccountactivitiesbyactivitytype-1
|
1147
|
+
:param str [symbol]: unified market symbol
|
1148
|
+
:param int [since]: the earliest time in ms to fetch trades for
|
1149
|
+
:param int [limit]: the maximum number of trade structures to retrieve
|
1150
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1151
|
+
:param int [params.until]: the latest time in ms to fetch trades for
|
1152
|
+
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
1153
|
+
"""
|
1154
|
+
await self.load_markets()
|
1155
|
+
market = None
|
1156
|
+
request: dict = {
|
1157
|
+
'activity_type': 'FILL',
|
1158
|
+
}
|
1159
|
+
if symbol is not None:
|
1160
|
+
market = self.market(symbol)
|
1161
|
+
if since is not None:
|
1162
|
+
request['after'] = since
|
1163
|
+
if limit is not None:
|
1164
|
+
request['page_size'] = limit
|
1165
|
+
request, params = self.handle_until_option('until', request, params)
|
1166
|
+
response = await self.traderPrivateGetV2AccountActivitiesActivityType(self.extend(request, params))
|
1167
|
+
#
|
1168
|
+
# [
|
1169
|
+
# {
|
1170
|
+
# "id": "20221228071929579::ca2aafd0-1270-4b56-b0a9-85423b4a07c8",
|
1171
|
+
# "activity_type": "FILL",
|
1172
|
+
# "transaction_time": "2022-12-28T12:19:29.579352Z",
|
1173
|
+
# "type": "fill",
|
1174
|
+
# "price": "67.31",
|
1175
|
+
# "qty": "0.07",
|
1176
|
+
# "side": "sell",
|
1177
|
+
# "symbol": "LTC/USD",
|
1178
|
+
# "leaves_qty": "0",
|
1179
|
+
# "order_id": "82eebcf7-6e66-4b7e-93f8-be0df0e4f12e",
|
1180
|
+
# "cum_qty": "0.07",
|
1181
|
+
# "order_status": "filled",
|
1182
|
+
# "swap_rate": "1"
|
1183
|
+
# },
|
1184
|
+
# ]
|
1185
|
+
#
|
1186
|
+
return self.parse_trades(response, market, since, limit)
|
1187
|
+
|
1017
1188
|
def parse_trade(self, trade: dict, market: Market = None) -> Trade:
|
1189
|
+
#
|
1190
|
+
# fetchTrades
|
1018
1191
|
#
|
1019
1192
|
# {
|
1020
1193
|
# "t":"2022-06-14T05:00:00.027869Z",
|
@@ -1025,25 +1198,43 @@ class alpaca(Exchange, ImplicitAPI):
|
|
1025
1198
|
# "i":"355681339"
|
1026
1199
|
# }
|
1027
1200
|
#
|
1028
|
-
|
1201
|
+
# fetchMyTrades
|
1202
|
+
#
|
1203
|
+
# {
|
1204
|
+
# "id": "20221228071929579::ca2aafd0-1270-4b56-b0a9-85423b4a07c8",
|
1205
|
+
# "activity_type": "FILL",
|
1206
|
+
# "transaction_time": "2022-12-28T12:19:29.579352Z",
|
1207
|
+
# "type": "fill",
|
1208
|
+
# "price": "67.31",
|
1209
|
+
# "qty": "0.07",
|
1210
|
+
# "side": "sell",
|
1211
|
+
# "symbol": "LTC/USD",
|
1212
|
+
# "leaves_qty": "0",
|
1213
|
+
# "order_id": "82eebcf7-6e66-4b7e-93f8-be0df0e4f12e",
|
1214
|
+
# "cum_qty": "0.07",
|
1215
|
+
# "order_status": "filled",
|
1216
|
+
# "swap_rate": "1"
|
1217
|
+
# },
|
1218
|
+
#
|
1219
|
+
marketId = self.safe_string_2(trade, 'S', 'symbol')
|
1029
1220
|
symbol = self.safe_symbol(marketId, market)
|
1030
|
-
datetime = self.
|
1221
|
+
datetime = self.safe_string_2(trade, 't', 'transaction_time')
|
1031
1222
|
timestamp = self.parse8601(datetime)
|
1032
1223
|
alpacaSide = self.safe_string(trade, 'tks')
|
1033
|
-
side
|
1224
|
+
side = self.safe_string(trade, 'side')
|
1034
1225
|
if alpacaSide == 'B':
|
1035
1226
|
side = 'buy'
|
1036
1227
|
elif alpacaSide == 'S':
|
1037
1228
|
side = 'sell'
|
1038
|
-
priceString = self.
|
1039
|
-
amountString = self.
|
1229
|
+
priceString = self.safe_string_2(trade, 'p', 'price')
|
1230
|
+
amountString = self.safe_string_2(trade, 's', 'qty')
|
1040
1231
|
return self.safe_trade({
|
1041
1232
|
'info': trade,
|
1042
|
-
'id': self.
|
1233
|
+
'id': self.safe_string_2(trade, 'i', 'id'),
|
1043
1234
|
'timestamp': timestamp,
|
1044
1235
|
'datetime': self.iso8601(timestamp),
|
1045
1236
|
'symbol': symbol,
|
1046
|
-
'order':
|
1237
|
+
'order': self.safe_string(trade, 'order_id'),
|
1047
1238
|
'type': None,
|
1048
1239
|
'side': side,
|
1049
1240
|
'takerOrMaker': 'taker',
|
@@ -1053,6 +1244,48 @@ class alpaca(Exchange, ImplicitAPI):
|
|
1053
1244
|
'fee': None,
|
1054
1245
|
}, market)
|
1055
1246
|
|
1247
|
+
async def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
|
1248
|
+
"""
|
1249
|
+
fetch the deposit address for a currency associated with self account
|
1250
|
+
:see: https://docs.alpaca.markets/reference/listcryptofundingwallets
|
1251
|
+
:param str code: unified currency code
|
1252
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1253
|
+
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
|
1254
|
+
"""
|
1255
|
+
await self.load_markets()
|
1256
|
+
currency = self.currency(code)
|
1257
|
+
request: dict = {
|
1258
|
+
'asset': currency['id'],
|
1259
|
+
}
|
1260
|
+
response = await self.traderPrivateGetV2Wallets(self.extend(request, params))
|
1261
|
+
#
|
1262
|
+
# {
|
1263
|
+
# "asset_id": "4fa30c85-77b7-4cbc-92dd-7b7513640aad",
|
1264
|
+
# "address": "bc1q2fpskfnwem3uq9z8660e4z6pfv7aqfamysk75r",
|
1265
|
+
# "created_at": "2024-11-03T07:30:05.609976344Z"
|
1266
|
+
# }
|
1267
|
+
#
|
1268
|
+
return self.parse_deposit_address(response, currency)
|
1269
|
+
|
1270
|
+
def parse_deposit_address(self, depositAddress, currency: Currency = None) -> DepositAddress:
|
1271
|
+
#
|
1272
|
+
# {
|
1273
|
+
# "asset_id": "4fa30c85-77b7-4cbc-92dd-7b7513640aad",
|
1274
|
+
# "address": "bc1q2fpskfnwem3uq9z8660e4z6pfv7aqfamysk75r",
|
1275
|
+
# "created_at": "2024-11-03T07:30:05.609976344Z"
|
1276
|
+
# }
|
1277
|
+
#
|
1278
|
+
parsedCurrency = None
|
1279
|
+
if currency is not None:
|
1280
|
+
parsedCurrency = currency['id']
|
1281
|
+
return {
|
1282
|
+
'info': depositAddress,
|
1283
|
+
'currency': parsedCurrency,
|
1284
|
+
'network': None,
|
1285
|
+
'address': self.safe_string(depositAddress, 'address'),
|
1286
|
+
'tag': None,
|
1287
|
+
}
|
1288
|
+
|
1056
1289
|
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
|
1057
1290
|
endpoint = '/' + self.implode_params(path, params)
|
1058
1291
|
url = self.implode_hostname(self.urls['api'][api[0]])
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# -----------------------------------------------------------------------------
|
4
4
|
|
5
|
-
__version__ = '4.4.
|
5
|
+
__version__ = '4.4.26'
|
6
6
|
|
7
7
|
# -----------------------------------------------------------------------------
|
8
8
|
|
@@ -743,13 +743,13 @@ class Exchange(BaseExchange):
|
|
743
743
|
async def fetch_payment_methods(self, params={}):
|
744
744
|
raise NotSupported(self.id + ' fetchPaymentMethods() is not supported yet')
|
745
745
|
|
746
|
-
async def fetch_borrow_rate(self, code: str, amount, params={}):
|
746
|
+
async def fetch_borrow_rate(self, code: str, amount: float, params={}):
|
747
747
|
raise NotSupported(self.id + ' fetchBorrowRate is deprecated, please use fetchCrossBorrowRate or fetchIsolatedBorrowRate instead')
|
748
748
|
|
749
|
-
async def repay_cross_margin(self, code: str, amount, params={}):
|
749
|
+
async def repay_cross_margin(self, code: str, amount: float, params={}):
|
750
750
|
raise NotSupported(self.id + ' repayCrossMargin is not support yet')
|
751
751
|
|
752
|
-
async def repay_isolated_margin(self, symbol: str, code: str, amount, params={}):
|
752
|
+
async def repay_isolated_margin(self, symbol: str, code: str, amount: float, params={}):
|
753
753
|
raise NotSupported(self.id + ' repayIsolatedMargin is not support yet')
|
754
754
|
|
755
755
|
async def borrow_cross_margin(self, code: str, amount: float, params={}):
|
@@ -758,10 +758,10 @@ class Exchange(BaseExchange):
|
|
758
758
|
async def borrow_isolated_margin(self, symbol: str, code: str, amount: float, params={}):
|
759
759
|
raise NotSupported(self.id + ' borrowIsolatedMargin is not support yet')
|
760
760
|
|
761
|
-
async def borrow_margin(self, code: str, amount, symbol: Str = None, params={}):
|
761
|
+
async def borrow_margin(self, code: str, amount: float, symbol: Str = None, params={}):
|
762
762
|
raise NotSupported(self.id + ' borrowMargin is deprecated, please use borrowCrossMargin or borrowIsolatedMargin instead')
|
763
763
|
|
764
|
-
async def repay_margin(self, code: str, amount, symbol: Str = None, params={}):
|
764
|
+
async def repay_margin(self, code: str, amount: float, symbol: Str = None, params={}):
|
765
765
|
raise NotSupported(self.id + ' repayMargin is deprecated, please use repayCrossMargin or repayIsolatedMargin instead')
|
766
766
|
|
767
767
|
async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}):
|
ccxt/async_support/binance.py
CHANGED
@@ -8,7 +8,7 @@ from ccxt.abstract.binance import ImplicitAPI
|
|
8
8
|
import asyncio
|
9
9
|
import hashlib
|
10
10
|
import json
|
11
|
-
from ccxt.base.types import
|
11
|
+
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
|
12
12
|
from typing import List
|
13
13
|
from ccxt.base.errors import ExchangeError
|
14
14
|
from ccxt.base.errors import AuthenticationError
|
@@ -11305,7 +11305,7 @@ class binance(Exchange, ImplicitAPI):
|
|
11305
11305
|
#
|
11306
11306
|
return response
|
11307
11307
|
|
11308
|
-
async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
11308
|
+
async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
|
11309
11309
|
"""
|
11310
11310
|
fetch the interest owed by the user for borrowing currency for margin trading
|
11311
11311
|
:see: https://developers.binance.com/docs/margin_trading/borrow-and-repay/Get-Interest-History
|
@@ -11379,21 +11379,20 @@ class binance(Exchange, ImplicitAPI):
|
|
11379
11379
|
interest = self.parse_borrow_interests(rows, market)
|
11380
11380
|
return self.filter_by_currency_since_limit(interest, code, since, limit)
|
11381
11381
|
|
11382
|
-
def parse_borrow_interest(self, info: dict, market: Market = None):
|
11382
|
+
def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
|
11383
11383
|
symbol = self.safe_string(info, 'isolatedSymbol')
|
11384
11384
|
timestamp = self.safe_integer(info, 'interestAccuredTime')
|
11385
11385
|
marginMode = 'cross' if (symbol is None) else 'isolated'
|
11386
11386
|
return {
|
11387
|
-
'
|
11387
|
+
'info': info,
|
11388
11388
|
'symbol': symbol,
|
11389
|
-
'marginMode': marginMode,
|
11390
11389
|
'currency': self.safe_currency_code(self.safe_string(info, 'asset')),
|
11391
11390
|
'interest': self.safe_number(info, 'interest'),
|
11392
11391
|
'interestRate': self.safe_number(info, 'interestRate'),
|
11393
11392
|
'amountBorrowed': self.safe_number(info, 'principal'),
|
11393
|
+
'marginMode': marginMode,
|
11394
11394
|
'timestamp': timestamp,
|
11395
11395
|
'datetime': self.iso8601(timestamp),
|
11396
|
-
'info': info,
|
11397
11396
|
}
|
11398
11397
|
|
11399
11398
|
async def repay_cross_margin(self, code: str, amount, params={}):
|
ccxt/async_support/bingx.py
CHANGED
@@ -220,6 +220,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
220
220
|
'market/markPriceKlines': 1,
|
221
221
|
'trade/batchCancelReplace': 5,
|
222
222
|
'trade/fullOrder': 2,
|
223
|
+
'positionMargin/history': 2,
|
223
224
|
},
|
224
225
|
'post': {
|
225
226
|
'trade/cancelReplace': 2,
|
@@ -2677,6 +2678,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
2677
2678
|
:see: https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Bulk%20order
|
2678
2679
|
: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
|
2679
2680
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2681
|
+
:param boolean [params.sync]: *spot only* if True, multiple orders are ordered serially and all orders do not require the same symbol/side/type
|
2680
2682
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
2681
2683
|
"""
|
2682
2684
|
await self.load_markets()
|
@@ -2704,6 +2706,9 @@ class bingx(Exchange, ImplicitAPI):
|
|
2704
2706
|
request['batchOrders'] = self.json(ordersRequests)
|
2705
2707
|
response = await self.swapV2PrivatePostTradeBatchOrders(request)
|
2706
2708
|
else:
|
2709
|
+
sync = self.safe_bool(params, 'sync', False)
|
2710
|
+
if sync:
|
2711
|
+
request['sync'] = True
|
2707
2712
|
request['data'] = self.json(ordersRequests)
|
2708
2713
|
response = await self.spotV1PrivatePostTradeBatchOrders(request)
|
2709
2714
|
#
|
@@ -3140,7 +3145,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
3140
3145
|
'cost': Precise.string_abs(feeCost),
|
3141
3146
|
},
|
3142
3147
|
'trades': None,
|
3143
|
-
'reduceOnly': self.
|
3148
|
+
'reduceOnly': self.safe_bool_2(order, 'reduceOnly', 'ro'),
|
3144
3149
|
}, market)
|
3145
3150
|
|
3146
3151
|
def parse_order_status(self, status: Str):
|
ccxt/async_support/bitget.py
CHANGED
@@ -8,7 +8,7 @@ from ccxt.abstract.bitget import ImplicitAPI
|
|
8
8
|
import asyncio
|
9
9
|
import hashlib
|
10
10
|
import json
|
11
|
-
from ccxt.base.types import
|
11
|
+
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
|
12
12
|
from typing import List
|
13
13
|
from ccxt.base.errors import ExchangeError
|
14
14
|
from ccxt.base.errors import AuthenticationError
|
@@ -7629,7 +7629,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7629
7629
|
'info': info,
|
7630
7630
|
}
|
7631
7631
|
|
7632
|
-
async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
7632
|
+
async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
|
7633
7633
|
"""
|
7634
7634
|
fetch the interest owed by the user for borrowing currency for margin trading
|
7635
7635
|
:see: https://www.bitget.com/api-doc/margin/cross/record/Get-Cross-Interest-Records
|
@@ -7726,7 +7726,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7726
7726
|
interest = self.parse_borrow_interests(rows, market)
|
7727
7727
|
return self.filter_by_currency_since_limit(interest, code, since, limit)
|
7728
7728
|
|
7729
|
-
def parse_borrow_interest(self, info: dict, market: Market = None):
|
7729
|
+
def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
|
7730
7730
|
#
|
7731
7731
|
# isolated
|
7732
7732
|
#
|
@@ -7760,15 +7760,15 @@ class bitget(Exchange, ImplicitAPI):
|
|
7760
7760
|
marginMode = 'isolated' if (marketId is not None) else 'cross'
|
7761
7761
|
timestamp = self.safe_integer(info, 'cTime')
|
7762
7762
|
return {
|
7763
|
+
'info': info,
|
7763
7764
|
'symbol': self.safe_string(market, 'symbol'),
|
7764
|
-
'marginMode': marginMode,
|
7765
7765
|
'currency': self.safe_currency_code(self.safe_string(info, 'interestCoin')),
|
7766
7766
|
'interest': self.safe_number(info, 'interestAmount'),
|
7767
7767
|
'interestRate': self.safe_number(info, 'dailyInterestRate'),
|
7768
7768
|
'amountBorrowed': None,
|
7769
|
+
'marginMode': marginMode,
|
7769
7770
|
'timestamp': timestamp,
|
7770
7771
|
'datetime': self.iso8601(timestamp),
|
7771
|
-
'info': info,
|
7772
7772
|
}
|
7773
7773
|
|
7774
7774
|
async def close_position(self, symbol: str, side: OrderSide = None, params={}) -> Order:
|
ccxt/async_support/bitmart.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.async_support.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
|
-
async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
3986
|
+
async 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
|
async def fetch_open_interest(self, symbol: str, params={}):
|
ccxt/async_support/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)
|