ccxt 4.1.47__py2.py3-none-any.whl → 4.1.49__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ccxt might be problematic. Click here for more details.
- ccxt/__init__.py +3 -1
- ccxt/abstract/binance.py +2 -0
- ccxt/abstract/binancecoinm.py +2 -0
- ccxt/abstract/binanceus.py +2 -0
- ccxt/abstract/binanceusdm.py +2 -0
- ccxt/abstract/htx.py +541 -0
- ccxt/ace.py +2 -2
- ccxt/ascendex.py +2 -2
- ccxt/async_support/__init__.py +3 -1
- ccxt/async_support/ace.py +2 -2
- ccxt/async_support/ascendex.py +2 -2
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/bigone.py +2 -2
- ccxt/async_support/binance.py +5 -3
- ccxt/async_support/bingx.py +3 -3
- ccxt/async_support/bitbns.py +2 -2
- ccxt/async_support/bitfinex.py +2 -2
- ccxt/async_support/bitfinex2.py +2 -2
- ccxt/async_support/bitget.py +3 -3
- ccxt/async_support/bithumb.py +2 -2
- ccxt/async_support/bitmart.py +157 -53
- ccxt/async_support/bitmex.py +2 -2
- ccxt/async_support/bitopro.py +2 -2
- ccxt/async_support/bitpanda.py +2 -2
- ccxt/async_support/bitrue.py +2 -2
- ccxt/async_support/bitstamp.py +2 -2
- ccxt/async_support/bittrex.py +2 -2
- ccxt/async_support/bitvavo.py +2 -2
- ccxt/async_support/blockchaincom.py +2 -2
- ccxt/async_support/btcalpha.py +2 -2
- ccxt/async_support/btcturk.py +2 -2
- ccxt/async_support/bybit.py +2 -2
- ccxt/async_support/cex.py +2 -2
- ccxt/async_support/coinbase.py +2 -2
- ccxt/async_support/coinbasepro.py +2 -2
- ccxt/async_support/coinex.py +63 -20
- ccxt/async_support/coinfalcon.py +2 -2
- ccxt/async_support/coinlist.py +2 -2
- ccxt/async_support/coinone.py +2 -2
- ccxt/async_support/coinsph.py +2 -2
- ccxt/async_support/coinspot.py +2 -2
- ccxt/async_support/cryptocom.py +2 -2
- ccxt/async_support/currencycom.py +2 -2
- ccxt/async_support/delta.py +2 -2
- ccxt/async_support/deribit.py +2 -2
- ccxt/async_support/digifinex.py +2 -2
- ccxt/async_support/exmo.py +2 -2
- ccxt/async_support/gate.py +2 -2
- ccxt/async_support/gemini.py +3 -3
- ccxt/async_support/hitbtc.py +2 -2
- ccxt/async_support/hollaex.py +2 -2
- ccxt/async_support/htx.py +7853 -0
- ccxt/async_support/huobi.py +3 -7846
- ccxt/async_support/huobijp.py +2 -2
- ccxt/async_support/idex.py +2 -2
- ccxt/async_support/indodax.py +2 -2
- ccxt/async_support/kraken.py +2 -6
- ccxt/async_support/krakenfutures.py +2 -2
- ccxt/async_support/kucoin.py +2 -2
- ccxt/async_support/kuna.py +2 -2
- ccxt/async_support/latoken.py +2 -2
- ccxt/async_support/lbank.py +2 -2
- ccxt/async_support/lbank2.py +2 -2
- ccxt/async_support/luno.py +2 -2
- ccxt/async_support/lykke.py +2 -2
- ccxt/async_support/mexc.py +23 -23
- ccxt/async_support/novadax.py +2 -2
- ccxt/async_support/oceanex.py +2 -2
- ccxt/async_support/okcoin.py +3 -3
- ccxt/async_support/okx.py +3 -3
- ccxt/async_support/phemex.py +2 -2
- ccxt/async_support/poloniex.py +2 -2
- ccxt/async_support/poloniexfutures.py +2 -2
- ccxt/async_support/probit.py +2 -2
- ccxt/async_support/tidex.py +2 -2
- ccxt/async_support/timex.py +4 -4
- ccxt/async_support/tokocrypto.py +2 -2
- ccxt/async_support/upbit.py +2 -2
- ccxt/async_support/wavesexchange.py +2 -2
- ccxt/async_support/wazirx.py +2 -2
- ccxt/async_support/whitebit.py +2 -2
- ccxt/async_support/yobit.py +2 -2
- ccxt/async_support/zonda.py +2 -2
- ccxt/base/exchange.py +1 -1
- ccxt/base/types.py +43 -4
- ccxt/bigone.py +2 -2
- ccxt/binance.py +5 -3
- ccxt/bingx.py +3 -3
- ccxt/bitbns.py +2 -2
- ccxt/bitfinex.py +2 -2
- ccxt/bitfinex2.py +2 -2
- ccxt/bitget.py +3 -3
- ccxt/bithumb.py +2 -2
- ccxt/bitmart.py +157 -53
- ccxt/bitmex.py +2 -2
- ccxt/bitopro.py +2 -2
- ccxt/bitpanda.py +2 -2
- ccxt/bitrue.py +2 -2
- ccxt/bitstamp.py +2 -2
- ccxt/bittrex.py +2 -2
- ccxt/bitvavo.py +2 -2
- ccxt/blockchaincom.py +2 -2
- ccxt/btcalpha.py +2 -2
- ccxt/btcturk.py +2 -2
- ccxt/bybit.py +2 -2
- ccxt/cex.py +2 -2
- ccxt/coinbase.py +2 -2
- ccxt/coinbasepro.py +2 -2
- ccxt/coinex.py +63 -20
- ccxt/coinfalcon.py +2 -2
- ccxt/coinlist.py +2 -2
- ccxt/coinone.py +2 -2
- ccxt/coinsph.py +2 -2
- ccxt/coinspot.py +2 -2
- ccxt/cryptocom.py +2 -2
- ccxt/currencycom.py +2 -2
- ccxt/delta.py +2 -2
- ccxt/deribit.py +2 -2
- ccxt/digifinex.py +2 -2
- ccxt/exmo.py +2 -2
- ccxt/gate.py +2 -2
- ccxt/gemini.py +3 -3
- ccxt/hitbtc.py +2 -2
- ccxt/hollaex.py +2 -2
- ccxt/htx.py +7852 -0
- ccxt/huobi.py +3 -7845
- ccxt/huobijp.py +2 -2
- ccxt/idex.py +2 -2
- ccxt/indodax.py +2 -2
- ccxt/kraken.py +2 -6
- ccxt/krakenfutures.py +2 -2
- ccxt/kucoin.py +2 -2
- ccxt/kuna.py +2 -2
- ccxt/latoken.py +2 -2
- ccxt/lbank.py +2 -2
- ccxt/lbank2.py +2 -2
- ccxt/luno.py +2 -2
- ccxt/lykke.py +2 -2
- ccxt/mexc.py +23 -23
- ccxt/novadax.py +2 -2
- ccxt/oceanex.py +2 -2
- ccxt/okcoin.py +3 -3
- ccxt/okx.py +3 -3
- ccxt/phemex.py +2 -2
- ccxt/poloniex.py +2 -2
- ccxt/poloniexfutures.py +2 -2
- ccxt/pro/__init__.py +3 -1
- ccxt/pro/htx.py +2177 -0
- ccxt/pro/huobi.py +4 -2166
- ccxt/probit.py +2 -2
- ccxt/test/test_async.py +15 -1
- ccxt/test/test_sync.py +15 -1
- ccxt/tidex.py +2 -2
- ccxt/timex.py +4 -4
- ccxt/tokocrypto.py +2 -2
- ccxt/upbit.py +2 -2
- ccxt/wavesexchange.py +2 -2
- ccxt/wazirx.py +2 -2
- ccxt/whitebit.py +2 -2
- ccxt/yobit.py +2 -2
- ccxt/zonda.py +2 -2
- ccxt-4.1.49.dist-info/METADATA +624 -0
- {ccxt-4.1.47.dist-info → ccxt-4.1.49.dist-info}/RECORD +165 -161
- ccxt-4.1.47.dist-info/METADATA +0 -624
- {ccxt-4.1.47.dist-info → ccxt-4.1.49.dist-info}/WHEEL +0 -0
- {ccxt-4.1.47.dist-info → ccxt-4.1.49.dist-info}/top_level.txt +0 -0
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, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
|
9
|
+
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
|
10
10
|
from typing import Optional
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
@@ -593,6 +593,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
593
593
|
'swap': 'swap',
|
594
594
|
},
|
595
595
|
'createMarketBuyOrderRequiresPrice': True,
|
596
|
+
'brokerId': 'CCXTxBitmart000',
|
596
597
|
},
|
597
598
|
})
|
598
599
|
|
@@ -1184,7 +1185,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
1184
1185
|
ticker = self.safe_value(tickersById, market['id'])
|
1185
1186
|
return self.parse_ticker(ticker, market)
|
1186
1187
|
|
1187
|
-
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
|
1188
|
+
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
|
1188
1189
|
"""
|
1189
1190
|
fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
1190
1191
|
:see: https://developer-pro.bitmart.com/en/spot/#get-ticker-of-all-pairs-v2
|
@@ -1910,6 +1911,12 @@ class bitmart(Exchange, ImplicitAPI):
|
|
1910
1911
|
# "order_id": 2707217580
|
1911
1912
|
# }
|
1912
1913
|
#
|
1914
|
+
# swap
|
1915
|
+
# "data": {
|
1916
|
+
# "order_id": 231116359426639,
|
1917
|
+
# "price": "market price"
|
1918
|
+
# },
|
1919
|
+
#
|
1913
1920
|
# cancelOrder
|
1914
1921
|
#
|
1915
1922
|
# "2707217580" # order id
|
@@ -1989,6 +1996,9 @@ class bitmart(Exchange, ImplicitAPI):
|
|
1989
1996
|
if type == 'ioc':
|
1990
1997
|
type = 'limit'
|
1991
1998
|
timeInForce = 'IOC'
|
1999
|
+
priceString = self.safe_string(order, 'price')
|
2000
|
+
if priceString == 'market price':
|
2001
|
+
priceString = None
|
1992
2002
|
return self.safe_order({
|
1993
2003
|
'id': id,
|
1994
2004
|
'clientOrderId': self.safe_string(order, 'client_order_id'),
|
@@ -2001,7 +2011,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
2001
2011
|
'timeInForce': timeInForce,
|
2002
2012
|
'postOnly': postOnly,
|
2003
2013
|
'side': self.parse_order_side(self.safe_string(order, 'side')),
|
2004
|
-
'price': self.omit_zero(
|
2014
|
+
'price': self.omit_zero(priceString),
|
2005
2015
|
'stopPrice': None,
|
2006
2016
|
'triggerPrice': None,
|
2007
2017
|
'amount': self.omit_zero(self.safe_string(order, 'size')),
|
@@ -2053,6 +2063,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
2053
2063
|
create a trade order
|
2054
2064
|
:see: https://developer-pro.bitmart.com/en/spot/#place-spot-order
|
2055
2065
|
:see: https://developer-pro.bitmart.com/en/spot/#place-margin-order
|
2066
|
+
:see: https://developer-pro.bitmart.com/en/futures/#submit-order-signed
|
2056
2067
|
:param str symbol: unified symbol of the market to create an order in
|
2057
2068
|
:param str type: 'market' or 'limit'
|
2058
2069
|
:param str side: 'buy' or 'sell'
|
@@ -2060,61 +2071,26 @@ class bitmart(Exchange, ImplicitAPI):
|
|
2060
2071
|
:param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
2061
2072
|
:param dict [params]: extra parameters specific to the bitmart api endpoint
|
2062
2073
|
:param str [params.marginMode]: 'cross' or 'isolated'
|
2074
|
+
:param str [params.leverage]: *swap only* leverage level
|
2075
|
+
:param str [params.clientOrderId]: client order id of the order
|
2076
|
+
:param boolean [params.reduceOnly]: *swap only* reduce only
|
2077
|
+
:param boolean [params.postOnly]: make sure the order is posted to the order book and not matched immediately
|
2063
2078
|
:returns dict: an `order structure <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
|
2064
2079
|
"""
|
2065
2080
|
self.load_markets()
|
2066
2081
|
market = self.market(symbol)
|
2067
|
-
|
2068
|
-
|
2069
|
-
|
2070
|
-
raise InvalidOrder(self.id + ' createOrder() only accepts timeInForce parameter values of IOC or PO')
|
2071
|
-
mode = self.safe_integer(params, 'mode') # only for swap
|
2072
|
-
isMarketOrder = type == 'market'
|
2073
|
-
postOnly = None
|
2074
|
-
isExchangeSpecificPo = (type == 'limit_maker') or (mode == 4)
|
2075
|
-
postOnly, params = self.handle_post_only(isMarketOrder, isExchangeSpecificPo, params)
|
2076
|
-
params = self.omit(params, ['timeInForce', 'postOnly'])
|
2077
|
-
ioc = ((timeInForce == 'IOC') or (type == 'ioc'))
|
2078
|
-
isLimitOrder = (type == 'limit') or postOnly or ioc
|
2079
|
-
method = None
|
2082
|
+
result = self.handle_margin_mode_and_params('createOrder', params)
|
2083
|
+
marginMode = self.safe_string(result, 0)
|
2084
|
+
response = None
|
2080
2085
|
if market['spot']:
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
2089
|
-
# for market buy it requires the amount of quote currency to spend
|
2090
|
-
if side == 'buy':
|
2091
|
-
notional = self.safe_number(params, 'notional')
|
2092
|
-
createMarketBuyOrderRequiresPrice = self.safe_value(self.options, 'createMarketBuyOrderRequiresPrice', True)
|
2093
|
-
if createMarketBuyOrderRequiresPrice:
|
2094
|
-
if price is not None:
|
2095
|
-
if notional is None:
|
2096
|
-
amountString = self.number_to_string(amount)
|
2097
|
-
priceString = self.number_to_string(price)
|
2098
|
-
notional = self.parse_number(Precise.string_mul(amountString, priceString))
|
2099
|
-
elif notional is None:
|
2100
|
-
raise InvalidOrder(self.id + " createOrder() requires the price argument with market buy orders to calculate total order cost(amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options['createMarketBuyOrderRequiresPrice'] = False and supply the total cost value in the 'amount' argument or in the 'notional' extra parameter(the exchange-specific behaviour)")
|
2101
|
-
else:
|
2102
|
-
notional = amount if (notional is None) else notional
|
2103
|
-
request['notional'] = self.decimal_to_precision(notional, TRUNCATE, market['precision']['price'], self.precisionMode)
|
2104
|
-
elif side == 'sell':
|
2105
|
-
request['size'] = self.amount_to_precision(symbol, amount)
|
2106
|
-
elif market['swap']:
|
2107
|
-
raise NotSupported(self.id + ' createOrder() does not accept swap orders, only spot orders are allowed')
|
2108
|
-
if postOnly:
|
2109
|
-
request['type'] = 'limit_maker'
|
2110
|
-
if ioc:
|
2111
|
-
request['type'] = 'ioc'
|
2112
|
-
marginMode, query = self.handle_margin_mode_and_params('createOrder', params)
|
2113
|
-
if marginMode is not None:
|
2114
|
-
if marginMode != 'isolated':
|
2115
|
-
raise NotSupported(self.id + ' only isolated margin is supported')
|
2116
|
-
method = 'privatePostSpotV1MarginSubmitOrder'
|
2117
|
-
response = getattr(self, method)(self.extend(request, query))
|
2086
|
+
spotRequest = self.create_spot_order_request(symbol, type, side, amount, price, params)
|
2087
|
+
if marginMode == 'isolated':
|
2088
|
+
response = self.privatePostSpotV1MarginSubmitOrder(spotRequest)
|
2089
|
+
else:
|
2090
|
+
response = self.privatePostSpotV2SubmitOrder(spotRequest)
|
2091
|
+
else:
|
2092
|
+
swapRequest = self.create_swap_order_request(symbol, type, side, amount, price, params)
|
2093
|
+
response = self.privatePostContractPrivateSubmitOrder(swapRequest)
|
2118
2094
|
#
|
2119
2095
|
# spot and margin
|
2120
2096
|
#
|
@@ -2127,6 +2103,9 @@ class bitmart(Exchange, ImplicitAPI):
|
|
2127
2103
|
# }
|
2128
2104
|
# }
|
2129
2105
|
#
|
2106
|
+
# swap
|
2107
|
+
# {"code":1000,"message":"Ok","data":{"order_id":231116359426639,"price":"market price"},"trace":"7f9c94e10f9d4513bc08a7bfc2a5559a.62.16996369620521911"}
|
2108
|
+
#
|
2130
2109
|
data = self.safe_value(response, 'data', {})
|
2131
2110
|
order = self.parse_order(data, market)
|
2132
2111
|
order['type'] = type
|
@@ -2135,6 +2114,129 @@ class bitmart(Exchange, ImplicitAPI):
|
|
2135
2114
|
order['price'] = price
|
2136
2115
|
return order
|
2137
2116
|
|
2117
|
+
def create_swap_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount, price=None, params={}):
|
2118
|
+
"""
|
2119
|
+
create a trade order
|
2120
|
+
:see: https://developer-pro.bitmart.com/en/futures/#submit-order-signed
|
2121
|
+
:param str symbol: unified symbol of the market to create an order in
|
2122
|
+
:param str type: 'market' or 'limit'
|
2123
|
+
:param str side: 'buy' or 'sell'
|
2124
|
+
:param float amount: how much of currency you want to trade in units of base currency
|
2125
|
+
:param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
2126
|
+
:param dict [params]: extra parameters specific to the bitmart api endpoint
|
2127
|
+
:param int [params.leverage]: leverage level
|
2128
|
+
:param boolean [params.reduceOnly]: *swap only* reduce only
|
2129
|
+
:param str [params.marginMode]: 'cross' or 'isolated', default is 'cross'
|
2130
|
+
* @param {string} [params.clientOrderId] client order id of the order
|
2131
|
+
:returns dict: an `order structure <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
|
2132
|
+
"""
|
2133
|
+
market = self.market(symbol)
|
2134
|
+
request = {
|
2135
|
+
'symbol': market['id'],
|
2136
|
+
'type': type,
|
2137
|
+
'size': int(self.amount_to_precision(symbol, amount)),
|
2138
|
+
}
|
2139
|
+
timeInForce = self.safe_string(params, 'timeInForce')
|
2140
|
+
mode = self.safe_integer(params, 'mode') # only for swap
|
2141
|
+
isMarketOrder = type == 'market'
|
2142
|
+
postOnly = None
|
2143
|
+
reduceOnly = self.safe_value(params, 'reduceOnly')
|
2144
|
+
isExchangeSpecificPo = (mode == 4)
|
2145
|
+
postOnly, params = self.handle_post_only(isMarketOrder, isExchangeSpecificPo, params)
|
2146
|
+
params = self.omit(params, ['timeInForce', 'postOnly', 'reduceOnly'])
|
2147
|
+
ioc = ((timeInForce == 'IOC') or (mode == 3))
|
2148
|
+
isLimitOrder = (type == 'limit') or postOnly or ioc
|
2149
|
+
if timeInForce == 'GTC':
|
2150
|
+
request['mode'] = 1
|
2151
|
+
elif timeInForce == 'FOK':
|
2152
|
+
request['mode'] = 2
|
2153
|
+
elif timeInForce == 'IOC':
|
2154
|
+
request['mode'] = 3
|
2155
|
+
if postOnly:
|
2156
|
+
request['mode'] = 4
|
2157
|
+
if isLimitOrder:
|
2158
|
+
request['price'] = self.price_to_precision(symbol, price)
|
2159
|
+
if side == 'buy':
|
2160
|
+
if reduceOnly:
|
2161
|
+
request['side'] = 2 # sell close long
|
2162
|
+
else:
|
2163
|
+
request['side'] = 1 # buy open long
|
2164
|
+
elif side == 'sell':
|
2165
|
+
if reduceOnly:
|
2166
|
+
request['side'] = 3 # sell close long
|
2167
|
+
else:
|
2168
|
+
request['side'] = 4 # sell open short
|
2169
|
+
marginMode = None
|
2170
|
+
marginMode, params = self.handle_margin_mode_and_params('createOrder', params, 'cross')
|
2171
|
+
request['open_type'] = marginMode
|
2172
|
+
clientOrderId = self.safe_string(params, 'clientOrderId')
|
2173
|
+
if clientOrderId is not None:
|
2174
|
+
params = self.omit(params, 'clientOrderId')
|
2175
|
+
request['client_order_id'] = clientOrderId
|
2176
|
+
leverage = self.safe_integer(params, 'leverage', 1)
|
2177
|
+
params = self.omit(params, 'leverage')
|
2178
|
+
request['leverage'] = self.number_to_string(leverage)
|
2179
|
+
return self.extend(request, params)
|
2180
|
+
|
2181
|
+
def create_spot_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount, price=None, params={}):
|
2182
|
+
"""
|
2183
|
+
create a spot order request
|
2184
|
+
:see: https://developer-pro.bitmart.com/en/spot/#place-spot-order
|
2185
|
+
:see: https://developer-pro.bitmart.com/en/spot/#place-margin-order
|
2186
|
+
:param str symbol: unified symbol of the market to create an order in
|
2187
|
+
:param str type: 'market' or 'limit'
|
2188
|
+
:param str side: 'buy' or 'sell'
|
2189
|
+
:param float amount: how much of currency you want to trade in units of base currency
|
2190
|
+
:param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
2191
|
+
:param dict [params]: extra parameters specific to the bitmart api endpoint
|
2192
|
+
:param str [params.marginMode]: 'cross' or 'isolated'
|
2193
|
+
:returns dict: an `order structure <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
|
2194
|
+
"""
|
2195
|
+
market = self.market(symbol)
|
2196
|
+
request = {
|
2197
|
+
'symbol': market['id'],
|
2198
|
+
'side': side,
|
2199
|
+
'type': type,
|
2200
|
+
}
|
2201
|
+
timeInForce = self.safe_string(params, 'timeInForce')
|
2202
|
+
if timeInForce == 'FOK':
|
2203
|
+
raise InvalidOrder(self.id + ' createOrder() only accepts timeInForce parameter values of IOC or PO')
|
2204
|
+
mode = self.safe_integer(params, 'mode') # only for swap
|
2205
|
+
isMarketOrder = type == 'market'
|
2206
|
+
postOnly = None
|
2207
|
+
isExchangeSpecificPo = (type == 'limit_maker') or (mode == 4)
|
2208
|
+
postOnly, params = self.handle_post_only(isMarketOrder, isExchangeSpecificPo, params)
|
2209
|
+
params = self.omit(params, ['timeInForce', 'postOnly'])
|
2210
|
+
ioc = ((timeInForce == 'IOC') or (type == 'ioc'))
|
2211
|
+
isLimitOrder = (type == 'limit') or postOnly or ioc
|
2212
|
+
# method = 'privatePostSpotV2SubmitOrder'
|
2213
|
+
if isLimitOrder:
|
2214
|
+
request['size'] = self.amount_to_precision(symbol, amount)
|
2215
|
+
request['price'] = self.price_to_precision(symbol, price)
|
2216
|
+
elif isMarketOrder:
|
2217
|
+
# for market buy it requires the amount of quote currency to spend
|
2218
|
+
if side == 'buy':
|
2219
|
+
notional = self.safe_number(params, 'notional')
|
2220
|
+
createMarketBuyOrderRequiresPrice = self.safe_value(self.options, 'createMarketBuyOrderRequiresPrice', True)
|
2221
|
+
if createMarketBuyOrderRequiresPrice:
|
2222
|
+
if price is not None:
|
2223
|
+
if notional is None:
|
2224
|
+
amountString = self.number_to_string(amount)
|
2225
|
+
priceString = self.number_to_string(price)
|
2226
|
+
notional = self.parse_number(Precise.string_mul(amountString, priceString))
|
2227
|
+
elif notional is None:
|
2228
|
+
raise InvalidOrder(self.id + " createOrder() requires the price argument with market buy orders to calculate total order cost(amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options['createMarketBuyOrderRequiresPrice'] = False and supply the total cost value in the 'amount' argument or in the 'notional' extra parameter(the exchange-specific behaviour)")
|
2229
|
+
else:
|
2230
|
+
notional = amount if (notional is None) else notional
|
2231
|
+
request['notional'] = self.decimal_to_precision(notional, TRUNCATE, market['precision']['price'], self.precisionMode)
|
2232
|
+
elif side == 'sell':
|
2233
|
+
request['size'] = self.amount_to_precision(symbol, amount)
|
2234
|
+
if postOnly:
|
2235
|
+
request['type'] = 'limit_maker'
|
2236
|
+
if ioc:
|
2237
|
+
request['type'] = 'ioc'
|
2238
|
+
return self.extend(request, params)
|
2239
|
+
|
2138
2240
|
def cancel_order(self, id: str, symbol: Optional[str] = None, params={}):
|
2139
2241
|
"""
|
2140
2242
|
:see: https://developer-pro.bitmart.com/en/futures/#cancel-order-signed
|
@@ -3835,9 +3937,11 @@ class bitmart(Exchange, ImplicitAPI):
|
|
3835
3937
|
if api == 'private':
|
3836
3938
|
self.check_required_credentials()
|
3837
3939
|
timestamp = str(self.milliseconds())
|
3940
|
+
brokerId = self.safe_string(self.options, 'brokerId', 'CCXTxBitmart000')
|
3838
3941
|
headers = {
|
3839
3942
|
'X-BM-KEY': self.apiKey,
|
3840
3943
|
'X-BM-TIMESTAMP': timestamp,
|
3944
|
+
'X-BM-BROKER-ID': brokerId,
|
3841
3945
|
'Content-Type': 'application/json',
|
3842
3946
|
}
|
3843
3947
|
if not getOrDelete:
|
ccxt/bitmex.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.bitmex import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
|
9
|
+
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
|
10
10
|
from typing import Optional
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
@@ -1276,7 +1276,7 @@ class bitmex(Exchange, ImplicitAPI):
|
|
1276
1276
|
raise BadSymbol(self.id + ' fetchTicker() symbol ' + symbol + ' not found')
|
1277
1277
|
return self.parse_ticker(ticker, market)
|
1278
1278
|
|
1279
|
-
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
|
1279
|
+
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
|
1280
1280
|
"""
|
1281
1281
|
fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
1282
1282
|
:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
ccxt/bitopro.py
CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.bitopro import ImplicitAPI
|
8
8
|
import hashlib
|
9
9
|
import math
|
10
|
-
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
|
10
|
+
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
|
11
11
|
from typing import Optional
|
12
12
|
from typing import List
|
13
13
|
from ccxt.base.errors import ExchangeError
|
@@ -439,7 +439,7 @@ class bitopro(Exchange, ImplicitAPI):
|
|
439
439
|
#
|
440
440
|
return self.parse_ticker(ticker, market)
|
441
441
|
|
442
|
-
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
|
442
|
+
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
|
443
443
|
"""
|
444
444
|
fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
445
445
|
:see: https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_ticker_data.md
|
ccxt/bitpanda.py
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.bitpanda import ImplicitAPI
|
8
|
-
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
|
8
|
+
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
|
9
9
|
from typing import Optional
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
@@ -642,7 +642,7 @@ class bitpanda(Exchange, ImplicitAPI):
|
|
642
642
|
#
|
643
643
|
return self.parse_ticker(response, market)
|
644
644
|
|
645
|
-
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
|
645
|
+
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
|
646
646
|
"""
|
647
647
|
fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
648
648
|
:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
ccxt/bitrue.py
CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.bitrue import ImplicitAPI
|
8
8
|
import hashlib
|
9
9
|
import json
|
10
|
-
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
|
10
|
+
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
|
11
11
|
from typing import Optional
|
12
12
|
from typing import List
|
13
13
|
from ccxt.base.errors import ExchangeError
|
@@ -975,7 +975,7 @@ class bitrue(Exchange, ImplicitAPI):
|
|
975
975
|
data[market['id']] = response
|
976
976
|
return self.parse_tickers(data, symbols)
|
977
977
|
|
978
|
-
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
|
978
|
+
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
|
979
979
|
"""
|
980
980
|
fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
981
981
|
:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
ccxt/bitstamp.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.bitstamp import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
|
9
|
+
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
|
10
10
|
from typing import Optional
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
@@ -743,7 +743,7 @@ class bitstamp(Exchange, ImplicitAPI):
|
|
743
743
|
#
|
744
744
|
return self.parse_ticker(ticker, market)
|
745
745
|
|
746
|
-
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
|
746
|
+
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
|
747
747
|
"""
|
748
748
|
fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
749
749
|
:see: https://www.bitstamp.net/api/#all-tickers
|
ccxt/bittrex.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.bittrex import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
|
9
|
+
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
|
10
10
|
from typing import Optional
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
@@ -566,7 +566,7 @@ class bittrex(Exchange, ImplicitAPI):
|
|
566
566
|
'info': ticker,
|
567
567
|
}, market)
|
568
568
|
|
569
|
-
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
|
569
|
+
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
|
570
570
|
"""
|
571
571
|
fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
572
572
|
:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
ccxt/bitvavo.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.bitvavo import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
|
9
|
+
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
|
10
10
|
from typing import Optional
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
@@ -589,7 +589,7 @@ class bitvavo(Exchange, ImplicitAPI):
|
|
589
589
|
'info': ticker,
|
590
590
|
}, market)
|
591
591
|
|
592
|
-
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
|
592
|
+
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
|
593
593
|
"""
|
594
594
|
fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
595
595
|
:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
ccxt/blockchaincom.py
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.blockchaincom import ImplicitAPI
|
8
|
-
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
|
8
|
+
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
|
9
9
|
from typing import Optional
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
@@ -442,7 +442,7 @@ class blockchaincom(Exchange, ImplicitAPI):
|
|
442
442
|
response = self.publicGetTickersSymbol(self.extend(request, params))
|
443
443
|
return self.parse_ticker(response, market)
|
444
444
|
|
445
|
-
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
|
445
|
+
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
|
446
446
|
"""
|
447
447
|
fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
448
448
|
:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
ccxt/btcalpha.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.btcalpha import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
|
9
|
+
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
|
10
10
|
from typing import Optional
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
@@ -236,7 +236,7 @@ class btcalpha(Exchange, ImplicitAPI):
|
|
236
236
|
})
|
237
237
|
return result
|
238
238
|
|
239
|
-
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
|
239
|
+
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
|
240
240
|
"""
|
241
241
|
:see: https://btc-alpha.github.io/api-docs/#tickers
|
242
242
|
fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
ccxt/btcturk.py
CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.btcturk import ImplicitAPI
|
8
8
|
import hashlib
|
9
9
|
import math
|
10
|
-
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade
|
10
|
+
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade
|
11
11
|
from typing import Optional
|
12
12
|
from typing import List
|
13
13
|
from ccxt.base.errors import ExchangeError
|
@@ -392,7 +392,7 @@ class btcturk(Exchange, ImplicitAPI):
|
|
392
392
|
'info': ticker,
|
393
393
|
}, market)
|
394
394
|
|
395
|
-
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
|
395
|
+
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
|
396
396
|
"""
|
397
397
|
fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
398
398
|
:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
ccxt/bybit.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.bybit import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import OrderRequest, Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
|
9
|
+
from ccxt.base.types import OrderRequest, Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
|
10
10
|
from typing import Optional
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
@@ -2017,7 +2017,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
2017
2017
|
rawTicker = self.safe_value(tickers, 0)
|
2018
2018
|
return self.parse_ticker(rawTicker, market)
|
2019
2019
|
|
2020
|
-
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
|
2020
|
+
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
|
2021
2021
|
"""
|
2022
2022
|
fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
2023
2023
|
:see: https://bybit-exchange.github.io/docs/v5/market/tickers
|
ccxt/cex.py
CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.cex import ImplicitAPI
|
8
8
|
import hashlib
|
9
9
|
import json
|
10
|
-
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade
|
10
|
+
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade
|
11
11
|
from typing import Optional
|
12
12
|
from typing import List
|
13
13
|
from ccxt.base.errors import ExchangeError
|
@@ -582,7 +582,7 @@ class cex(Exchange, ImplicitAPI):
|
|
582
582
|
'info': ticker,
|
583
583
|
}, market)
|
584
584
|
|
585
|
-
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
|
585
|
+
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
|
586
586
|
"""
|
587
587
|
fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
588
588
|
:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
ccxt/coinbase.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.coinbase import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
|
9
|
+
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
|
10
10
|
from typing import Optional
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
@@ -1167,7 +1167,7 @@ class coinbase(Exchange, ImplicitAPI):
|
|
1167
1167
|
}
|
1168
1168
|
return result
|
1169
1169
|
|
1170
|
-
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
|
1170
|
+
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
|
1171
1171
|
"""
|
1172
1172
|
fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
1173
1173
|
:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
ccxt/coinbasepro.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.coinbasepro import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
|
9
|
+
from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
|
10
10
|
from typing import Optional
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
@@ -611,7 +611,7 @@ class coinbasepro(Exchange, ImplicitAPI):
|
|
611
611
|
'info': ticker,
|
612
612
|
}, market)
|
613
613
|
|
614
|
-
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
|
614
|
+
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
|
615
615
|
"""
|
616
616
|
fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
617
617
|
:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|