ccxt 4.4.39__py2.py3-none-any.whl → 4.4.41__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/bitmart.py +2 -0
- ccxt/abstract/okx.py +5 -0
- ccxt/ascendex.py +9 -9
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/ascendex.py +9 -9
- ccxt/async_support/base/exchange.py +10 -3
- ccxt/async_support/base/ws/aiohttp_client.py +2 -2
- ccxt/async_support/binance.py +37 -41
- ccxt/async_support/bingx.py +4 -3
- ccxt/async_support/bit2c.py +0 -1
- ccxt/async_support/bitbank.py +0 -1
- ccxt/async_support/bitbns.py +0 -1
- ccxt/async_support/bitfinex.py +16 -17
- ccxt/async_support/bitfinex1.py +0 -1
- ccxt/async_support/bitflyer.py +0 -1
- ccxt/async_support/bitget.py +2 -2
- ccxt/async_support/bithumb.py +0 -1
- ccxt/async_support/bitmart.py +246 -6
- ccxt/async_support/bitmex.py +5 -6
- ccxt/async_support/bitopro.py +4 -5
- ccxt/async_support/bitrue.py +5 -7
- ccxt/async_support/bitso.py +1 -2
- ccxt/async_support/bitstamp.py +1 -2
- ccxt/async_support/bitteam.py +1 -3
- ccxt/async_support/bitvavo.py +2 -4
- ccxt/async_support/blockchaincom.py +5 -5
- ccxt/async_support/blofin.py +10 -10
- ccxt/async_support/btcalpha.py +0 -1
- ccxt/async_support/btcbox.py +0 -1
- ccxt/async_support/btcmarkets.py +1 -3
- ccxt/async_support/bybit.py +10 -11
- ccxt/async_support/cex.py +1 -1
- ccxt/async_support/coinbase.py +77 -1
- ccxt/async_support/coinbaseexchange.py +1 -1
- ccxt/async_support/coinbaseinternational.py +62 -0
- ccxt/async_support/coincatch.py +1 -1
- ccxt/async_support/coinex.py +9 -9
- ccxt/async_support/coinlist.py +1 -1
- ccxt/async_support/coinmetro.py +1 -1
- ccxt/async_support/cryptocom.py +91 -2
- ccxt/async_support/currencycom.py +1 -1
- ccxt/async_support/defx.py +1 -2
- ccxt/async_support/delta.py +1 -1
- ccxt/async_support/digifinex.py +1 -1
- ccxt/async_support/exmo.py +62 -6
- ccxt/async_support/gate.py +2 -2
- ccxt/async_support/hashkey.py +3 -5
- ccxt/async_support/htx.py +2 -2
- ccxt/async_support/hyperliquid.py +61 -2
- ccxt/async_support/kraken.py +124 -26
- ccxt/async_support/kucoin.py +29 -25
- ccxt/async_support/luno.py +1 -1
- ccxt/async_support/mexc.py +137 -1
- ccxt/async_support/ndax.py +1 -1
- ccxt/async_support/okcoin.py +18 -18
- ccxt/async_support/okx.py +27 -22
- ccxt/async_support/phemex.py +12 -8
- ccxt/async_support/poloniex.py +1 -1
- ccxt/async_support/poloniexfutures.py +6 -6
- ccxt/async_support/vertex.py +11 -11
- ccxt/async_support/woo.py +33 -33
- ccxt/async_support/woofipro.py +24 -24
- ccxt/async_support/xt.py +29 -27
- ccxt/async_support/zonda.py +1 -1
- ccxt/base/exchange.py +31 -19
- ccxt/base/types.py +10 -0
- ccxt/binance.py +37 -41
- ccxt/bingx.py +4 -3
- ccxt/bit2c.py +0 -1
- ccxt/bitbank.py +0 -1
- ccxt/bitbns.py +0 -1
- ccxt/bitfinex.py +16 -17
- ccxt/bitfinex1.py +0 -1
- ccxt/bitflyer.py +0 -1
- ccxt/bitget.py +2 -2
- ccxt/bithumb.py +0 -1
- ccxt/bitmart.py +246 -6
- ccxt/bitmex.py +5 -6
- ccxt/bitopro.py +4 -5
- ccxt/bitrue.py +5 -7
- ccxt/bitso.py +1 -2
- ccxt/bitstamp.py +1 -2
- ccxt/bitteam.py +1 -3
- ccxt/bitvavo.py +2 -4
- ccxt/blockchaincom.py +5 -5
- ccxt/blofin.py +10 -10
- ccxt/btcalpha.py +0 -1
- ccxt/btcbox.py +0 -1
- ccxt/btcmarkets.py +1 -3
- ccxt/bybit.py +10 -11
- ccxt/cex.py +1 -1
- ccxt/coinbase.py +77 -1
- ccxt/coinbaseexchange.py +1 -1
- ccxt/coinbaseinternational.py +62 -0
- ccxt/coincatch.py +1 -1
- ccxt/coinex.py +9 -9
- ccxt/coinlist.py +1 -1
- ccxt/coinmetro.py +1 -1
- ccxt/cryptocom.py +91 -2
- ccxt/currencycom.py +1 -1
- ccxt/defx.py +1 -2
- ccxt/delta.py +1 -1
- ccxt/digifinex.py +1 -1
- ccxt/exmo.py +62 -6
- ccxt/gate.py +2 -2
- ccxt/hashkey.py +3 -5
- ccxt/htx.py +2 -2
- ccxt/hyperliquid.py +61 -2
- ccxt/kraken.py +124 -26
- ccxt/kucoin.py +29 -25
- ccxt/luno.py +1 -1
- ccxt/mexc.py +137 -1
- ccxt/ndax.py +1 -1
- ccxt/okcoin.py +18 -18
- ccxt/okx.py +27 -22
- ccxt/phemex.py +12 -8
- ccxt/poloniex.py +1 -1
- ccxt/poloniexfutures.py +6 -6
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/bitget.py +1 -1
- ccxt/pro/bybit.py +12 -1
- ccxt/pro/coinex.py +2 -2
- ccxt/pro/gate.py +6 -6
- ccxt/pro/kucoin.py +3 -3
- ccxt/pro/okx.py +11 -11
- ccxt/pro/upbit.py +2 -2
- ccxt/vertex.py +11 -11
- ccxt/woo.py +33 -33
- ccxt/woofipro.py +24 -24
- ccxt/xt.py +29 -27
- ccxt/zonda.py +1 -1
- {ccxt-4.4.39.dist-info → ccxt-4.4.41.dist-info}/METADATA +4 -4
- {ccxt-4.4.39.dist-info → ccxt-4.4.41.dist-info}/RECORD +137 -137
- {ccxt-4.4.39.dist-info → ccxt-4.4.41.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.39.dist-info → ccxt-4.4.41.dist-info}/WHEEL +0 -0
- {ccxt-4.4.39.dist-info → ccxt-4.4.41.dist-info}/top_level.txt +0 -0
ccxt/bithumb.py
CHANGED
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, BorrowInterest, 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, FundingHistory, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, 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
|
@@ -81,12 +81,13 @@ class bitmart(Exchange, ImplicitAPI):
|
|
81
81
|
'fetchDeposits': True,
|
82
82
|
'fetchDepositWithdrawFee': True,
|
83
83
|
'fetchDepositWithdrawFees': False,
|
84
|
-
'fetchFundingHistory':
|
84
|
+
'fetchFundingHistory': True,
|
85
85
|
'fetchFundingRate': True,
|
86
86
|
'fetchFundingRateHistory': False,
|
87
87
|
'fetchFundingRates': False,
|
88
88
|
'fetchIsolatedBorrowRate': True,
|
89
89
|
'fetchIsolatedBorrowRates': True,
|
90
|
+
'fetchLedger': True,
|
90
91
|
'fetchLiquidations': False,
|
91
92
|
'fetchMarginMode': False,
|
92
93
|
'fetchMarkets': True,
|
@@ -173,6 +174,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
173
174
|
'contract/public/depth': 5,
|
174
175
|
'contract/public/open-interest': 30,
|
175
176
|
'contract/public/funding-rate': 30,
|
177
|
+
'contract/public/funding-rate-history': 30,
|
176
178
|
'contract/public/kline': 6, # should be 5 but errors
|
177
179
|
'account/v1/currencies': 30,
|
178
180
|
},
|
@@ -223,6 +225,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
223
225
|
'contract/private/position-risk': 10,
|
224
226
|
'contract/private/affilate/rebate-list': 10,
|
225
227
|
'contract/private/affilate/trade-list': 10,
|
228
|
+
'contract/private/transaction-history': 10,
|
226
229
|
},
|
227
230
|
'post': {
|
228
231
|
# sub-account endpoints
|
@@ -2482,7 +2485,6 @@ class bitmart(Exchange, ImplicitAPI):
|
|
2482
2485
|
'postOnly': postOnly,
|
2483
2486
|
'side': self.parse_order_side(self.safe_string(order, 'side')),
|
2484
2487
|
'price': self.omit_zero(priceString),
|
2485
|
-
'stopPrice': trailingActivationPrice,
|
2486
2488
|
'triggerPrice': trailingActivationPrice,
|
2487
2489
|
'amount': self.omit_zero(self.safe_string(order, 'size')),
|
2488
2490
|
'cost': self.safe_string_2(order, 'filled_notional', 'filledNotional'),
|
@@ -2890,7 +2892,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
2890
2892
|
:param str symbol: unified symbol of the market the order was made in
|
2891
2893
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2892
2894
|
:param str [params.clientOrderId]: *spot only* the client order id of the order to cancel
|
2893
|
-
:param boolean [params.
|
2895
|
+
:param boolean [params.trigger]: *swap only* whether the order is a trigger order
|
2894
2896
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
2895
2897
|
"""
|
2896
2898
|
if symbol is None:
|
@@ -2910,9 +2912,9 @@ class bitmart(Exchange, ImplicitAPI):
|
|
2910
2912
|
if market['spot']:
|
2911
2913
|
response = self.privatePostSpotV3CancelOrder(self.extend(request, params))
|
2912
2914
|
else:
|
2913
|
-
|
2915
|
+
trigger = self.safe_bool_2(params, 'stop', 'trigger')
|
2914
2916
|
params = self.omit(params, ['stop', 'trigger'])
|
2915
|
-
if not
|
2917
|
+
if not trigger:
|
2916
2918
|
response = self.privatePostContractPrivateCancelOrder(self.extend(request, params))
|
2917
2919
|
else:
|
2918
2920
|
response = self.privatePostContractPrivateCancelPlanOrder(self.extend(request, params))
|
@@ -4376,6 +4378,62 @@ class bitmart(Exchange, ImplicitAPI):
|
|
4376
4378
|
data = self.safe_dict(response, 'data', {})
|
4377
4379
|
return self.parse_funding_rate(data, market)
|
4378
4380
|
|
4381
|
+
def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
4382
|
+
"""
|
4383
|
+
fetches historical funding rate prices
|
4384
|
+
|
4385
|
+
https://developer-pro.bitmart.com/en/futuresv2/#get-funding-rate-history
|
4386
|
+
|
4387
|
+
:param str symbol: unified symbol of the market to fetch the funding rate history for
|
4388
|
+
:param int [since]: timestamp in ms of the earliest funding rate to fetch
|
4389
|
+
:param int [limit]: the maximum amount of funding rate structures to fetch
|
4390
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4391
|
+
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
|
4392
|
+
"""
|
4393
|
+
if symbol is None:
|
4394
|
+
raise ArgumentsRequired(self.id + ' fetchFundingRateHistory() requires a symbol argument')
|
4395
|
+
self.load_markets()
|
4396
|
+
market = self.market(symbol)
|
4397
|
+
request: dict = {
|
4398
|
+
'symbol': market['id'],
|
4399
|
+
}
|
4400
|
+
if limit is not None:
|
4401
|
+
request['limit'] = limit
|
4402
|
+
response = self.publicGetContractPublicFundingRateHistory(self.extend(request, params))
|
4403
|
+
#
|
4404
|
+
# {
|
4405
|
+
# "code": 1000,
|
4406
|
+
# "message": "Ok",
|
4407
|
+
# "data": {
|
4408
|
+
# "list": [
|
4409
|
+
# {
|
4410
|
+
# "symbol": "BTCUSDT",
|
4411
|
+
# "funding_rate": "0.000091412174",
|
4412
|
+
# "funding_time": "1734336000000"
|
4413
|
+
# },
|
4414
|
+
# ]
|
4415
|
+
# },
|
4416
|
+
# "trace": "fg73d949fgfdf6a40c8fc7f5ae6738.54.345345345345"
|
4417
|
+
# }
|
4418
|
+
#
|
4419
|
+
data = self.safe_dict(response, 'data', {})
|
4420
|
+
result = self.safe_list(data, 'list', [])
|
4421
|
+
rates = []
|
4422
|
+
for i in range(0, len(result)):
|
4423
|
+
entry = result[i]
|
4424
|
+
marketId = self.safe_string(entry, 'symbol')
|
4425
|
+
symbolInner = self.safe_symbol(marketId, market, '-', 'swap')
|
4426
|
+
timestamp = self.safe_integer(entry, 'funding_time')
|
4427
|
+
rates.append({
|
4428
|
+
'info': entry,
|
4429
|
+
'symbol': symbolInner,
|
4430
|
+
'fundingRate': self.safe_number(entry, 'funding_rate'),
|
4431
|
+
'timestamp': timestamp,
|
4432
|
+
'datetime': self.iso8601(timestamp),
|
4433
|
+
})
|
4434
|
+
sorted = self.sort_by(rates, 'timestamp')
|
4435
|
+
return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
|
4436
|
+
|
4379
4437
|
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
4380
4438
|
#
|
4381
4439
|
# {
|
@@ -4789,6 +4847,188 @@ class bitmart(Exchange, ImplicitAPI):
|
|
4789
4847
|
data = self.safe_dict(response, 'data', {})
|
4790
4848
|
return self.parse_order(data, market)
|
4791
4849
|
|
4850
|
+
def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
|
4851
|
+
"""
|
4852
|
+
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
4853
|
+
|
4854
|
+
https://developer-pro.bitmart.com/en/futuresv2/#get-transaction-history-keyed
|
4855
|
+
|
4856
|
+
:param str [code]: unified currency code
|
4857
|
+
:param int [since]: timestamp in ms of the earliest ledger entry
|
4858
|
+
:param int [limit]: max number of ledger entries to return
|
4859
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4860
|
+
:param int [params.until]: timestamp in ms of the latest ledger entry
|
4861
|
+
:returns dict[]: a list of `ledger structures <https://docs.ccxt.com/#/?id=ledger>`
|
4862
|
+
"""
|
4863
|
+
self.load_markets()
|
4864
|
+
currency = None
|
4865
|
+
if code is not None:
|
4866
|
+
currency = self.currency(code)
|
4867
|
+
request: dict = {}
|
4868
|
+
request, params = self.handle_until_option('end_time', request, params)
|
4869
|
+
transactionsRequest = self.fetch_transactions_request(0, None, since, limit, params)
|
4870
|
+
response = self.privateGetContractPrivateTransactionHistory(transactionsRequest)
|
4871
|
+
#
|
4872
|
+
# {
|
4873
|
+
# "code": 1000,
|
4874
|
+
# "message": "Ok",
|
4875
|
+
# "data": [
|
4876
|
+
# {
|
4877
|
+
# "time": "1734422402121",
|
4878
|
+
# "type": "Funding Fee",
|
4879
|
+
# "amount": "-0.00008253",
|
4880
|
+
# "asset": "USDT",
|
4881
|
+
# "symbol": "LTCUSDT",
|
4882
|
+
# "tran_id": "1734422402121",
|
4883
|
+
# "flow_type": 3
|
4884
|
+
# },
|
4885
|
+
# ],
|
4886
|
+
# "trace": "4cd11f83c71egfhfgh842790f07241e.23.173442343427772866"
|
4887
|
+
# }
|
4888
|
+
#
|
4889
|
+
data = self.safe_list(response, 'data', [])
|
4890
|
+
return self.parse_ledger(data, currency, since, limit)
|
4891
|
+
|
4892
|
+
def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
|
4893
|
+
#
|
4894
|
+
# {
|
4895
|
+
# "time": "1734422402121",
|
4896
|
+
# "type": "Funding Fee",
|
4897
|
+
# "amount": "-0.00008253",
|
4898
|
+
# "asset": "USDT",
|
4899
|
+
# "symbol": "LTCUSDT",
|
4900
|
+
# "tran_id": "1734422402121",
|
4901
|
+
# "flow_type": 3
|
4902
|
+
# }
|
4903
|
+
#
|
4904
|
+
amount = self.safe_string(item, 'amount')
|
4905
|
+
direction = None
|
4906
|
+
if Precise.string_le(amount, '0'):
|
4907
|
+
direction = 'out'
|
4908
|
+
amount = Precise.string_mul('-1', amount)
|
4909
|
+
else:
|
4910
|
+
direction = 'in'
|
4911
|
+
currencyId = self.safe_string(item, 'asset')
|
4912
|
+
timestamp = self.safe_integer(item, 'time')
|
4913
|
+
type = self.safe_string(item, 'type')
|
4914
|
+
return self.safe_ledger_entry({
|
4915
|
+
'info': item,
|
4916
|
+
'id': self.safe_string(item, 'tran_id'),
|
4917
|
+
'direction': direction,
|
4918
|
+
'account': None,
|
4919
|
+
'referenceAccount': None,
|
4920
|
+
'referenceId': self.safe_string(item, 'tradeId'),
|
4921
|
+
'type': self.parse_ledger_entry_type(type),
|
4922
|
+
'currency': self.safe_currency_code(currencyId, currency),
|
4923
|
+
'amount': self.parse_number(amount),
|
4924
|
+
'timestamp': timestamp,
|
4925
|
+
'datetime': self.iso8601(timestamp),
|
4926
|
+
'before': None,
|
4927
|
+
'after': None,
|
4928
|
+
'status': None,
|
4929
|
+
'fee': None,
|
4930
|
+
}, currency)
|
4931
|
+
|
4932
|
+
def parse_ledger_entry_type(self, type):
|
4933
|
+
ledgerType: dict = {
|
4934
|
+
'Commission Fee': 'fee',
|
4935
|
+
'Funding Fee': 'fee',
|
4936
|
+
'Realized PNL': 'trade',
|
4937
|
+
'Transfer': 'transfer',
|
4938
|
+
'Liquidation Clearance': 'settlement',
|
4939
|
+
}
|
4940
|
+
return self.safe_string(ledgerType, type, type)
|
4941
|
+
|
4942
|
+
def fetch_transactions_request(self, flowType: Int = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
4943
|
+
request: dict = {}
|
4944
|
+
if flowType is not None:
|
4945
|
+
request['flow_type'] = flowType
|
4946
|
+
market = None
|
4947
|
+
if symbol is not None:
|
4948
|
+
market = self.market(symbol)
|
4949
|
+
request['symbol'] = market['id']
|
4950
|
+
if since is not None:
|
4951
|
+
request['start_time'] = since
|
4952
|
+
if limit is not None:
|
4953
|
+
request['page_size'] = limit
|
4954
|
+
request, params = self.handle_until_option('end_time', request, params)
|
4955
|
+
return self.extend(request, params)
|
4956
|
+
|
4957
|
+
def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[FundingHistory]:
|
4958
|
+
"""
|
4959
|
+
fetch the history of funding payments paid and received on self account
|
4960
|
+
|
4961
|
+
https://developer-pro.bitmart.com/en/futuresv2/#get-transaction-history-keyed
|
4962
|
+
|
4963
|
+
:param str [symbol]: unified market symbol
|
4964
|
+
:param int [since]: the starting timestamp in milliseconds
|
4965
|
+
:param int [limit]: the number of entries to return
|
4966
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4967
|
+
:param int [params.until]: the latest time in ms to fetch funding history for
|
4968
|
+
:returns dict[]: a list of `funding history structures <https://docs.ccxt.com/#/?id=funding-history-structure>`
|
4969
|
+
"""
|
4970
|
+
self.load_markets()
|
4971
|
+
market = None
|
4972
|
+
if symbol is not None:
|
4973
|
+
market = self.market(symbol)
|
4974
|
+
request: dict = {}
|
4975
|
+
request, params = self.handle_until_option('end_time', request, params)
|
4976
|
+
transactionsRequest = self.fetch_transactions_request(3, symbol, since, limit, params)
|
4977
|
+
response = self.privateGetContractPrivateTransactionHistory(transactionsRequest)
|
4978
|
+
#
|
4979
|
+
# {
|
4980
|
+
# "code": 1000,
|
4981
|
+
# "message": "Ok",
|
4982
|
+
# "data": [
|
4983
|
+
# {
|
4984
|
+
# "time": "1734422402121",
|
4985
|
+
# "type": "Funding Fee",
|
4986
|
+
# "amount": "-0.00008253",
|
4987
|
+
# "asset": "USDT",
|
4988
|
+
# "symbol": "LTCUSDT",
|
4989
|
+
# "tran_id": "1734422402121",
|
4990
|
+
# "flow_type": 3
|
4991
|
+
# },
|
4992
|
+
# ],
|
4993
|
+
# "trace": "4cd11f83c71egfhfgh842790f07241e.23.173442343427772866"
|
4994
|
+
# }
|
4995
|
+
#
|
4996
|
+
data = self.safe_list(response, 'data', [])
|
4997
|
+
return self.parse_funding_histories(data, market, since, limit)
|
4998
|
+
|
4999
|
+
def parse_funding_history(self, contract, market: Market = None):
|
5000
|
+
#
|
5001
|
+
# {
|
5002
|
+
# "time": "1734422402121",
|
5003
|
+
# "type": "Funding Fee",
|
5004
|
+
# "amount": "-0.00008253",
|
5005
|
+
# "asset": "USDT",
|
5006
|
+
# "symbol": "LTCUSDT",
|
5007
|
+
# "tran_id": "1734422402121",
|
5008
|
+
# "flow_type": 3
|
5009
|
+
# }
|
5010
|
+
#
|
5011
|
+
marketId = self.safe_string(contract, 'symbol')
|
5012
|
+
currencyId = self.safe_string(contract, 'asset')
|
5013
|
+
timestamp = self.safe_integer(contract, 'time')
|
5014
|
+
return {
|
5015
|
+
'info': contract,
|
5016
|
+
'symbol': self.safe_symbol(marketId, market, None, 'swap'),
|
5017
|
+
'code': self.safe_currency_code(currencyId),
|
5018
|
+
'timestamp': timestamp,
|
5019
|
+
'datetime': self.iso8601(timestamp),
|
5020
|
+
'id': self.safe_string(contract, 'tran_id'),
|
5021
|
+
'amount': self.safe_number(contract, 'amount'),
|
5022
|
+
}
|
5023
|
+
|
5024
|
+
def parse_funding_histories(self, contracts, market=None, since: Int = None, limit: Int = None) -> List[FundingHistory]:
|
5025
|
+
result = []
|
5026
|
+
for i in range(0, len(contracts)):
|
5027
|
+
contract = contracts[i]
|
5028
|
+
result.append(self.parse_funding_history(contract, market))
|
5029
|
+
sorted = self.sort_by(result, 'timestamp')
|
5030
|
+
return self.filter_by_since_limit(sorted, since, limit)
|
5031
|
+
|
4792
5032
|
def nonce(self):
|
4793
5033
|
return self.milliseconds()
|
4794
5034
|
|
ccxt/bitmex.py
CHANGED
@@ -1277,7 +1277,7 @@ class bitmex(Exchange, ImplicitAPI):
|
|
1277
1277
|
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
1278
1278
|
:param int [limit]: max number of ledger entries to return, default is None
|
1279
1279
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1280
|
-
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger
|
1280
|
+
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
|
1281
1281
|
"""
|
1282
1282
|
self.load_markets()
|
1283
1283
|
request: dict = {
|
@@ -1807,7 +1807,7 @@ class bitmex(Exchange, ImplicitAPI):
|
|
1807
1807
|
if execInst is not None:
|
1808
1808
|
postOnly = (execInst == 'ParticipateDoNotInitiate')
|
1809
1809
|
timestamp = self.parse8601(self.safe_string(order, 'timestamp'))
|
1810
|
-
|
1810
|
+
triggerPrice = self.safe_number(order, 'stopPx')
|
1811
1811
|
remaining = self.safe_string(order, 'leavesQty')
|
1812
1812
|
return self.safe_order({
|
1813
1813
|
'info': order,
|
@@ -1822,8 +1822,7 @@ class bitmex(Exchange, ImplicitAPI):
|
|
1822
1822
|
'postOnly': postOnly,
|
1823
1823
|
'side': self.safe_string_lower(order, 'side'),
|
1824
1824
|
'price': self.safe_string(order, 'price'),
|
1825
|
-
'
|
1826
|
-
'triggerPrice': stopPrice,
|
1825
|
+
'triggerPrice': triggerPrice,
|
1827
1826
|
'amount': amount,
|
1828
1827
|
'cost': cost,
|
1829
1828
|
'average': average,
|
@@ -1961,7 +1960,7 @@ class bitmex(Exchange, ImplicitAPI):
|
|
1961
1960
|
else:
|
1962
1961
|
if triggerPrice is None:
|
1963
1962
|
# if exchange specific trigger types were provided
|
1964
|
-
raise ArgumentsRequired(self.id + ' createOrder() requires a triggerPrice
|
1963
|
+
raise ArgumentsRequired(self.id + ' createOrder() requires a triggerPrice parameter for the ' + orderType + ' order type')
|
1965
1964
|
request['stopPx'] = self.parse_to_numeric(self.price_to_precision(symbol, triggerPrice))
|
1966
1965
|
request['ordType'] = orderType
|
1967
1966
|
params = self.omit(params, ['triggerPrice', 'stopPrice', 'stopPx', 'triggerDirection', 'trailingAmount'])
|
@@ -2523,7 +2522,7 @@ class bitmex(Exchange, ImplicitAPI):
|
|
2523
2522
|
'timestamp': self.parse8601(datetime),
|
2524
2523
|
'datetime': datetime,
|
2525
2524
|
'fundingRate': self.safe_number(contract, 'fundingRate'),
|
2526
|
-
'fundingTimestamp': self.
|
2525
|
+
'fundingTimestamp': self.parse8601(fundingDatetime),
|
2527
2526
|
'fundingDatetime': fundingDatetime,
|
2528
2527
|
'nextFundingRate': self.safe_number(contract, 'indicativeFundingRate'),
|
2529
2528
|
'nextFundingTimestamp': None,
|
ccxt/bitopro.py
CHANGED
@@ -964,7 +964,6 @@ class bitopro(Exchange, ImplicitAPI):
|
|
964
964
|
'postOnly': postOnly,
|
965
965
|
'side': side,
|
966
966
|
'price': price,
|
967
|
-
'stopPrice': None,
|
968
967
|
'triggerPrice': None,
|
969
968
|
'amount': amount,
|
970
969
|
'cost': None,
|
@@ -1006,12 +1005,12 @@ class bitopro(Exchange, ImplicitAPI):
|
|
1006
1005
|
request['price'] = self.price_to_precision(symbol, price)
|
1007
1006
|
if orderType == 'STOP_LIMIT':
|
1008
1007
|
request['price'] = self.price_to_precision(symbol, price)
|
1009
|
-
|
1008
|
+
triggerPrice = self.safe_value_2(params, 'triggerPrice', 'stopPrice')
|
1010
1009
|
params = self.omit(params, ['triggerPrice', 'stopPrice'])
|
1011
|
-
if
|
1012
|
-
raise InvalidOrder(self.id + ' createOrder() requires a
|
1010
|
+
if triggerPrice is None:
|
1011
|
+
raise InvalidOrder(self.id + ' createOrder() requires a triggerPrice parameter for ' + orderType + ' orders')
|
1013
1012
|
else:
|
1014
|
-
request['stopPrice'] = self.price_to_precision(symbol,
|
1013
|
+
request['stopPrice'] = self.price_to_precision(symbol, triggerPrice)
|
1015
1014
|
condition = self.safe_string(params, 'condition')
|
1016
1015
|
if condition is None:
|
1017
1016
|
raise InvalidOrder(self.id + ' createOrder() requires a condition parameter for ' + orderType + ' orders')
|
ccxt/bitrue.py
CHANGED
@@ -1777,8 +1777,7 @@ class bitrue(Exchange, ImplicitAPI):
|
|
1777
1777
|
postOnly = (type == 'limit_maker') or (timeInForce == 'GTX') or (type == 'post_only')
|
1778
1778
|
if type == 'limit_maker':
|
1779
1779
|
type = 'limit'
|
1780
|
-
|
1781
|
-
stopPrice = self.parse_number(self.omit_zero(stopPriceString))
|
1780
|
+
triggerPrice = self.parse_number(self.omit_zero(self.safe_string(order, 'stopPrice')))
|
1782
1781
|
return self.safe_order({
|
1783
1782
|
'info': order,
|
1784
1783
|
'id': id,
|
@@ -1792,8 +1791,7 @@ class bitrue(Exchange, ImplicitAPI):
|
|
1792
1791
|
'postOnly': postOnly,
|
1793
1792
|
'side': side,
|
1794
1793
|
'price': price,
|
1795
|
-
'
|
1796
|
-
'triggerPrice': stopPrice,
|
1794
|
+
'triggerPrice': triggerPrice,
|
1797
1795
|
'amount': amount,
|
1798
1796
|
'cost': cost,
|
1799
1797
|
'average': average,
|
@@ -1916,10 +1914,10 @@ class bitrue(Exchange, ImplicitAPI):
|
|
1916
1914
|
if clientOrderId is not None:
|
1917
1915
|
params = self.omit(params, ['newClientOrderId', 'clientOrderId'])
|
1918
1916
|
request['newClientOrderId'] = clientOrderId
|
1919
|
-
|
1920
|
-
if
|
1917
|
+
triggerPrice = self.safe_value_2(params, 'triggerPrice', 'stopPrice')
|
1918
|
+
if triggerPrice is not None:
|
1921
1919
|
params = self.omit(params, ['triggerPrice', 'stopPrice'])
|
1922
|
-
request['stopPrice'] = self.price_to_precision(symbol,
|
1920
|
+
request['stopPrice'] = self.price_to_precision(symbol, triggerPrice)
|
1923
1921
|
response = self.spotV1PrivatePostOrder(self.extend(request, params))
|
1924
1922
|
data = response
|
1925
1923
|
else:
|
ccxt/bitso.py
CHANGED
@@ -209,7 +209,7 @@ class bitso(Exchange, ImplicitAPI):
|
|
209
209
|
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
210
210
|
:param int [limit]: max number of ledger entries to return, default is None
|
211
211
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
212
|
-
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger
|
212
|
+
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
|
213
213
|
"""
|
214
214
|
request: dict = {}
|
215
215
|
if limit is not None:
|
@@ -1108,7 +1108,6 @@ class bitso(Exchange, ImplicitAPI):
|
|
1108
1108
|
'postOnly': None,
|
1109
1109
|
'side': side,
|
1110
1110
|
'price': price,
|
1111
|
-
'stopPrice': None,
|
1112
1111
|
'triggerPrice': None,
|
1113
1112
|
'amount': amount,
|
1114
1113
|
'cost': None,
|
ccxt/bitstamp.py
CHANGED
@@ -1850,7 +1850,6 @@ class bitstamp(Exchange, ImplicitAPI):
|
|
1850
1850
|
'postOnly': None,
|
1851
1851
|
'side': side,
|
1852
1852
|
'price': price,
|
1853
|
-
'stopPrice': None,
|
1854
1853
|
'triggerPrice': None,
|
1855
1854
|
'cost': None,
|
1856
1855
|
'amount': amount,
|
@@ -1968,7 +1967,7 @@ class bitstamp(Exchange, ImplicitAPI):
|
|
1968
1967
|
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
1969
1968
|
:param int [limit]: max number of ledger entries to return, default is None
|
1970
1969
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1971
|
-
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger
|
1970
|
+
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
|
1972
1971
|
"""
|
1973
1972
|
self.load_markets()
|
1974
1973
|
request: dict = {}
|
ccxt/bitteam.py
CHANGED
@@ -1185,7 +1185,6 @@ class bitteam(Exchange, ImplicitAPI):
|
|
1185
1185
|
side = self.safe_string(order, 'side')
|
1186
1186
|
feeRaw = self.safe_value(order, 'fee')
|
1187
1187
|
price = self.safe_string(order, 'price')
|
1188
|
-
stopPrice = self.safe_string(order, 'stopPrice')
|
1189
1188
|
amount = self.safe_string(order, 'quantity')
|
1190
1189
|
filled = self.safe_string(order, 'executed')
|
1191
1190
|
fee = None
|
@@ -1210,8 +1209,7 @@ class bitteam(Exchange, ImplicitAPI):
|
|
1210
1209
|
'timeInForce': 'GTC',
|
1211
1210
|
'side': side,
|
1212
1211
|
'price': price,
|
1213
|
-
'
|
1214
|
-
'triggerPrice': stopPrice,
|
1212
|
+
'triggerPrice': self.safe_string(order, 'stopPrice'),
|
1215
1213
|
'average': None,
|
1216
1214
|
'amount': amount,
|
1217
1215
|
'cost': None,
|
ccxt/bitvavo.py
CHANGED
@@ -1112,7 +1112,7 @@ class bitvavo(Exchange, ImplicitAPI):
|
|
1112
1112
|
:param float price: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
1113
1113
|
:param dict [params]: extra parameters specific to the bitvavo api endpoint
|
1114
1114
|
:param str [params.timeInForce]: "GTC", "IOC", or "PO"
|
1115
|
-
:param float [params.stopPrice]:
|
1115
|
+
:param float [params.stopPrice]: Alias for triggerPrice
|
1116
1116
|
:param float [params.triggerPrice]: The price at which a trigger order is triggered at
|
1117
1117
|
:param bool [params.postOnly]: If True, the order will only be posted to the order book and not executed immediately
|
1118
1118
|
:param float [params.stopLossPrice]: The price at which a stop loss order is triggered at
|
@@ -1564,7 +1564,6 @@ class bitvavo(Exchange, ImplicitAPI):
|
|
1564
1564
|
timeInForce = self.safe_string(order, 'timeInForce')
|
1565
1565
|
postOnly = self.safe_value(order, 'postOnly')
|
1566
1566
|
# https://github.com/ccxt/ccxt/issues/8489
|
1567
|
-
stopPrice = self.safe_number(order, 'triggerPrice')
|
1568
1567
|
return self.safe_order({
|
1569
1568
|
'info': order,
|
1570
1569
|
'id': id,
|
@@ -1578,8 +1577,7 @@ class bitvavo(Exchange, ImplicitAPI):
|
|
1578
1577
|
'postOnly': postOnly,
|
1579
1578
|
'side': side,
|
1580
1579
|
'price': price,
|
1581
|
-
'
|
1582
|
-
'triggerPrice': stopPrice,
|
1580
|
+
'triggerPrice': self.safe_number(order, 'triggerPrice'),
|
1583
1581
|
'amount': amount,
|
1584
1582
|
'cost': cost,
|
1585
1583
|
'average': None,
|
ccxt/blockchaincom.py
CHANGED
@@ -567,12 +567,12 @@ class blockchaincom(Exchange, ImplicitAPI):
|
|
567
567
|
'orderQty': self.amount_to_precision(symbol, amount),
|
568
568
|
'clOrdId': clientOrderId,
|
569
569
|
}
|
570
|
-
|
570
|
+
triggerPrice = self.safe_value_2(params, 'stopPx', 'stopPrice')
|
571
571
|
params = self.omit(params, ['stopPx', 'stopPrice'])
|
572
572
|
if uppercaseOrderType == 'STOP' or uppercaseOrderType == 'STOPLIMIT':
|
573
|
-
if
|
574
|
-
raise ArgumentsRequired(self.id + ' createOrder() requires a stopPx or
|
575
|
-
if
|
573
|
+
if triggerPrice is None:
|
574
|
+
raise ArgumentsRequired(self.id + ' createOrder() requires a stopPx or triggerPrice param for a ' + uppercaseOrderType + ' order')
|
575
|
+
if triggerPrice is not None:
|
576
576
|
if uppercaseOrderType == 'MARKET':
|
577
577
|
request['ordType'] = 'STOP'
|
578
578
|
elif uppercaseOrderType == 'LIMIT':
|
@@ -586,7 +586,7 @@ class blockchaincom(Exchange, ImplicitAPI):
|
|
586
586
|
if priceRequired:
|
587
587
|
request['price'] = self.price_to_precision(symbol, price)
|
588
588
|
if stopPriceRequired:
|
589
|
-
request['stopPx'] = self.price_to_precision(symbol,
|
589
|
+
request['stopPx'] = self.price_to_precision(symbol, triggerPrice)
|
590
590
|
response = self.privatePostOrders(self.extend(request, params))
|
591
591
|
return self.parse_order(response, market)
|
592
592
|
|
ccxt/blofin.py
CHANGED
@@ -1331,7 +1331,7 @@ class blofin(Exchange, ImplicitAPI):
|
|
1331
1331
|
:param int [since]: the earliest time in ms to fetch open orders for
|
1332
1332
|
:param int [limit]: the maximum number of open orders structures to retrieve
|
1333
1333
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1334
|
-
:param bool [params.
|
1334
|
+
:param bool [params.trigger]: True if fetching trigger or conditional orders
|
1335
1335
|
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
1336
1336
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
1337
1337
|
"""
|
@@ -1348,12 +1348,12 @@ class blofin(Exchange, ImplicitAPI):
|
|
1348
1348
|
request['instId'] = market['id']
|
1349
1349
|
if limit is not None:
|
1350
1350
|
request['limit'] = limit # default 100, max 100
|
1351
|
-
|
1351
|
+
isTrigger = self.safe_bool_n(params, ['stop', 'trigger', 'tpsl', 'TPSL'], False)
|
1352
1352
|
method: Str = None
|
1353
1353
|
method, params = self.handle_option_and_params(params, 'fetchOpenOrders', 'method', 'privateGetTradeOrdersPending')
|
1354
1354
|
query = self.omit(params, ['method', 'stop', 'trigger', 'tpsl', 'TPSL'])
|
1355
1355
|
response = None
|
1356
|
-
if
|
1356
|
+
if isTrigger or (method == 'privateGetTradeOrdersTpslPending'):
|
1357
1357
|
response = self.privateGetTradeOrdersTpslPending(self.extend(request, query))
|
1358
1358
|
else:
|
1359
1359
|
response = self.privateGetTradeOrdersPending(self.extend(request, query))
|
@@ -1473,7 +1473,7 @@ class blofin(Exchange, ImplicitAPI):
|
|
1473
1473
|
:param str [params.marginMode]: 'cross' or 'isolated'
|
1474
1474
|
:param int [params.until]: the latest time in ms to fetch entries for
|
1475
1475
|
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
1476
|
-
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger
|
1476
|
+
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
|
1477
1477
|
"""
|
1478
1478
|
self.load_markets()
|
1479
1479
|
paginate = False
|
@@ -1660,8 +1660,8 @@ class blofin(Exchange, ImplicitAPI):
|
|
1660
1660
|
method = self.safe_string(params, 'method', defaultMethod)
|
1661
1661
|
clientOrderIds = self.parse_ids(self.safe_value(params, 'clientOrderId'))
|
1662
1662
|
tpslIds = self.parse_ids(self.safe_value(params, 'tpslId'))
|
1663
|
-
|
1664
|
-
if
|
1663
|
+
trigger = self.safe_bool_n(params, ['stop', 'trigger', 'tpsl'])
|
1664
|
+
if trigger:
|
1665
1665
|
method = 'privatePostTradeCancelTpsl'
|
1666
1666
|
if clientOrderIds is None:
|
1667
1667
|
ids = self.parse_ids(ids)
|
@@ -1672,7 +1672,7 @@ class blofin(Exchange, ImplicitAPI):
|
|
1672
1672
|
'instId': market['id'],
|
1673
1673
|
})
|
1674
1674
|
for i in range(0, len(ids)):
|
1675
|
-
if
|
1675
|
+
if trigger:
|
1676
1676
|
request.append({
|
1677
1677
|
'tpslId': ids[i],
|
1678
1678
|
'instId': market['id'],
|
@@ -2060,7 +2060,7 @@ class blofin(Exchange, ImplicitAPI):
|
|
2060
2060
|
:param int [since]: the earliest time in ms to fetch orders for
|
2061
2061
|
:param int [limit]: the maximum number of orde structures to retrieve
|
2062
2062
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2063
|
-
:param bool [params.
|
2063
|
+
:param bool [params.trigger]: True if fetching trigger or conditional orders
|
2064
2064
|
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
2065
2065
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
2066
2066
|
"""
|
@@ -2079,12 +2079,12 @@ class blofin(Exchange, ImplicitAPI):
|
|
2079
2079
|
request['limit'] = limit # default 100, max 100
|
2080
2080
|
if since is not None:
|
2081
2081
|
request['begin'] = since
|
2082
|
-
|
2082
|
+
isTrigger = self.safe_bool_n(params, ['stop', 'trigger', 'tpsl', 'TPSL'], False)
|
2083
2083
|
method: Str = None
|
2084
2084
|
method, params = self.handle_option_and_params(params, 'fetchOpenOrders', 'method', 'privateGetTradeOrdersHistory')
|
2085
2085
|
query = self.omit(params, ['method', 'stop', 'trigger', 'tpsl', 'TPSL'])
|
2086
2086
|
response = None
|
2087
|
-
if (
|
2087
|
+
if (isTrigger) or (method == 'privateGetTradeOrdersTpslHistory'):
|
2088
2088
|
response = self.privateGetTradeOrdersTpslHistory(self.extend(request, query))
|
2089
2089
|
else:
|
2090
2090
|
response = self.privateGetTradeOrdersHistory(self.extend(request, query))
|
ccxt/btcalpha.py
CHANGED