ccxt 4.4.49__py2.py3-none-any.whl → 4.4.51__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/binance.py +1 -0
- ccxt/abstract/binancecoinm.py +1 -0
- ccxt/abstract/binanceus.py +1 -0
- ccxt/abstract/binanceusdm.py +1 -0
- ccxt/alpaca.py +63 -2
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/alpaca.py +63 -2
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/binance.py +39 -20
- ccxt/async_support/blofin.py +5 -1
- ccxt/async_support/coinex.py +4 -4
- ccxt/async_support/coinmetro.py +16 -3
- ccxt/async_support/deribit.py +11 -3
- ccxt/async_support/gate.py +1 -1
- ccxt/async_support/hollaex.py +14 -17
- ccxt/async_support/htx.py +5 -3
- ccxt/async_support/kucoin.py +49 -69
- ccxt/async_support/mexc.py +24 -8
- ccxt/async_support/okcoin.py +13 -5
- ccxt/async_support/onetrading.py +1 -1
- ccxt/async_support/paradex.py +1 -1
- ccxt/async_support/paymium.py +42 -0
- ccxt/async_support/probit.py +77 -8
- ccxt/async_support/timex.py +67 -0
- ccxt/async_support/tokocrypto.py +81 -4
- ccxt/async_support/tradeogre.py +58 -1
- ccxt/async_support/vertex.py +65 -2
- ccxt/async_support/wavesexchange.py +73 -0
- ccxt/async_support/wazirx.py +59 -3
- ccxt/async_support/whitebit.py +79 -4
- ccxt/async_support/xt.py +112 -0
- ccxt/async_support/yobit.py +56 -0
- ccxt/async_support/zaif.py +55 -0
- ccxt/async_support/zonda.py +58 -0
- ccxt/base/exchange.py +72 -4
- ccxt/binance.py +39 -20
- ccxt/blofin.py +5 -1
- ccxt/coinex.py +4 -4
- ccxt/coinmetro.py +16 -3
- ccxt/deribit.py +11 -3
- ccxt/gate.py +1 -1
- ccxt/hollaex.py +14 -17
- ccxt/htx.py +5 -3
- ccxt/kucoin.py +49 -69
- ccxt/mexc.py +24 -8
- ccxt/okcoin.py +13 -5
- ccxt/onetrading.py +1 -1
- ccxt/paradex.py +1 -1
- ccxt/paymium.py +42 -0
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/binance.py +2 -0
- ccxt/pro/blofin.py +8 -0
- ccxt/pro/coinex.py +4 -1
- ccxt/probit.py +77 -8
- ccxt/timex.py +67 -0
- ccxt/tokocrypto.py +81 -4
- ccxt/tradeogre.py +58 -1
- ccxt/vertex.py +65 -2
- ccxt/wavesexchange.py +73 -0
- ccxt/wazirx.py +59 -3
- ccxt/whitebit.py +79 -4
- ccxt/xt.py +112 -0
- ccxt/yobit.py +56 -0
- ccxt/zaif.py +55 -0
- ccxt/zonda.py +58 -0
- {ccxt-4.4.49.dist-info → ccxt-4.4.51.dist-info}/METADATA +18 -18
- {ccxt-4.4.49.dist-info → ccxt-4.4.51.dist-info}/RECORD +71 -71
- {ccxt-4.4.49.dist-info → ccxt-4.4.51.dist-info}/WHEEL +1 -1
- {ccxt-4.4.49.dist-info → ccxt-4.4.51.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.49.dist-info → ccxt-4.4.51.dist-info}/top_level.txt +0 -0
ccxt/__init__.py
CHANGED
ccxt/abstract/binance.py
CHANGED
@@ -220,6 +220,7 @@ class ImplicitAPI:
|
|
220
220
|
sapi_get_portfolio_repay_futures_switch = sapiGetPortfolioRepayFuturesSwitch = Entry('portfolio/repay-futures-switch', 'sapi', 'GET', {'cost': 3})
|
221
221
|
sapi_get_portfolio_margin_asset_leverage = sapiGetPortfolioMarginAssetLeverage = Entry('portfolio/margin-asset-leverage', 'sapi', 'GET', {'cost': 5})
|
222
222
|
sapi_get_portfolio_balance = sapiGetPortfolioBalance = Entry('portfolio/balance', 'sapi', 'GET', {'cost': 2})
|
223
|
+
sapi_get_portfolio_negative_balance_exchange_record = sapiGetPortfolioNegativeBalanceExchangeRecord = Entry('portfolio/negative-balance-exchange-record', 'sapi', 'GET', {'cost': 2})
|
223
224
|
sapi_get_staking_productlist = sapiGetStakingProductList = Entry('staking/productList', 'sapi', 'GET', {'cost': 0.1})
|
224
225
|
sapi_get_staking_position = sapiGetStakingPosition = Entry('staking/position', 'sapi', 'GET', {'cost': 0.1})
|
225
226
|
sapi_get_staking_stakingrecord = sapiGetStakingStakingRecord = Entry('staking/stakingRecord', 'sapi', 'GET', {'cost': 0.1})
|
ccxt/abstract/binancecoinm.py
CHANGED
@@ -220,6 +220,7 @@ class ImplicitAPI:
|
|
220
220
|
sapi_get_portfolio_repay_futures_switch = sapiGetPortfolioRepayFuturesSwitch = Entry('portfolio/repay-futures-switch', 'sapi', 'GET', {'cost': 3})
|
221
221
|
sapi_get_portfolio_margin_asset_leverage = sapiGetPortfolioMarginAssetLeverage = Entry('portfolio/margin-asset-leverage', 'sapi', 'GET', {'cost': 5})
|
222
222
|
sapi_get_portfolio_balance = sapiGetPortfolioBalance = Entry('portfolio/balance', 'sapi', 'GET', {'cost': 2})
|
223
|
+
sapi_get_portfolio_negative_balance_exchange_record = sapiGetPortfolioNegativeBalanceExchangeRecord = Entry('portfolio/negative-balance-exchange-record', 'sapi', 'GET', {'cost': 2})
|
223
224
|
sapi_get_staking_productlist = sapiGetStakingProductList = Entry('staking/productList', 'sapi', 'GET', {'cost': 0.1})
|
224
225
|
sapi_get_staking_position = sapiGetStakingPosition = Entry('staking/position', 'sapi', 'GET', {'cost': 0.1})
|
225
226
|
sapi_get_staking_stakingrecord = sapiGetStakingStakingRecord = Entry('staking/stakingRecord', 'sapi', 'GET', {'cost': 0.1})
|
ccxt/abstract/binanceus.py
CHANGED
@@ -220,6 +220,7 @@ class ImplicitAPI:
|
|
220
220
|
sapi_get_portfolio_repay_futures_switch = sapiGetPortfolioRepayFuturesSwitch = Entry('portfolio/repay-futures-switch', 'sapi', 'GET', {'cost': 3})
|
221
221
|
sapi_get_portfolio_margin_asset_leverage = sapiGetPortfolioMarginAssetLeverage = Entry('portfolio/margin-asset-leverage', 'sapi', 'GET', {'cost': 5})
|
222
222
|
sapi_get_portfolio_balance = sapiGetPortfolioBalance = Entry('portfolio/balance', 'sapi', 'GET', {'cost': 2})
|
223
|
+
sapi_get_portfolio_negative_balance_exchange_record = sapiGetPortfolioNegativeBalanceExchangeRecord = Entry('portfolio/negative-balance-exchange-record', 'sapi', 'GET', {'cost': 2})
|
223
224
|
sapi_get_staking_productlist = sapiGetStakingProductList = Entry('staking/productList', 'sapi', 'GET', {'cost': 0.1})
|
224
225
|
sapi_get_staking_position = sapiGetStakingPosition = Entry('staking/position', 'sapi', 'GET', {'cost': 0.1})
|
225
226
|
sapi_get_staking_stakingrecord = sapiGetStakingStakingRecord = Entry('staking/stakingRecord', 'sapi', 'GET', {'cost': 0.1})
|
ccxt/abstract/binanceusdm.py
CHANGED
@@ -220,6 +220,7 @@ class ImplicitAPI:
|
|
220
220
|
sapi_get_portfolio_repay_futures_switch = sapiGetPortfolioRepayFuturesSwitch = Entry('portfolio/repay-futures-switch', 'sapi', 'GET', {'cost': 3})
|
221
221
|
sapi_get_portfolio_margin_asset_leverage = sapiGetPortfolioMarginAssetLeverage = Entry('portfolio/margin-asset-leverage', 'sapi', 'GET', {'cost': 5})
|
222
222
|
sapi_get_portfolio_balance = sapiGetPortfolioBalance = Entry('portfolio/balance', 'sapi', 'GET', {'cost': 2})
|
223
|
+
sapi_get_portfolio_negative_balance_exchange_record = sapiGetPortfolioNegativeBalanceExchangeRecord = Entry('portfolio/negative-balance-exchange-record', 'sapi', 'GET', {'cost': 2})
|
223
224
|
sapi_get_staking_productlist = sapiGetStakingProductList = Entry('staking/productList', 'sapi', 'GET', {'cost': 0.1})
|
224
225
|
sapi_get_staking_position = sapiGetStakingPosition = Entry('staking/position', 'sapi', 'GET', {'cost': 0.1})
|
225
226
|
sapi_get_staking_stakingrecord = sapiGetStakingStakingRecord = Entry('staking/stakingRecord', 'sapi', 'GET', {'cost': 0.1})
|
ccxt/alpaca.py
CHANGED
@@ -60,6 +60,9 @@ class alpaca(Exchange, ImplicitAPI):
|
|
60
60
|
'cancelOrder': True,
|
61
61
|
'closeAllPositions': False,
|
62
62
|
'closePosition': False,
|
63
|
+
'createMarketBuyOrder': True,
|
64
|
+
'createMarketBuyOrderWithCost': True,
|
65
|
+
'createMarketOrderWithCost': True,
|
63
66
|
'createOrder': True,
|
64
67
|
'createStopOrder': True,
|
65
68
|
'createTriggerOrder': True,
|
@@ -442,7 +445,7 @@ class alpaca(Exchange, ImplicitAPI):
|
|
442
445
|
# "status": "active",
|
443
446
|
# "tradable": True,
|
444
447
|
# "marginable": False,
|
445
|
-
# "maintenance_margin_requirement":
|
448
|
+
# "maintenance_margin_requirement": 101,
|
446
449
|
# "shortable": False,
|
447
450
|
# "easy_to_borrow": False,
|
448
451
|
# "fractionable": True,
|
@@ -905,6 +908,58 @@ class alpaca(Exchange, ImplicitAPI):
|
|
905
908
|
clientOrderId = self.safe_string(params, 'clientOrderId', defaultClientId)
|
906
909
|
return clientOrderId
|
907
910
|
|
911
|
+
def create_market_order_with_cost(self, symbol: str, side: OrderSide, cost: float, params={}):
|
912
|
+
"""
|
913
|
+
create a market order by providing the symbol, side and cost
|
914
|
+
|
915
|
+
https://docs.alpaca.markets/reference/postorder
|
916
|
+
|
917
|
+
:param str symbol: unified symbol of the market to create an order in
|
918
|
+
:param str side: 'buy' or 'sell'
|
919
|
+
:param float cost: how much you want to trade in units of the quote currency
|
920
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
921
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
922
|
+
"""
|
923
|
+
self.load_markets()
|
924
|
+
req = {
|
925
|
+
'cost': cost,
|
926
|
+
}
|
927
|
+
return self.create_order(symbol, 'market', side, 0, None, self.extend(req, params))
|
928
|
+
|
929
|
+
def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
|
930
|
+
"""
|
931
|
+
create a market buy order by providing the symbol and cost
|
932
|
+
|
933
|
+
https://docs.alpaca.markets/reference/postorder
|
934
|
+
|
935
|
+
:param str symbol: unified symbol of the market to create an order in
|
936
|
+
:param float cost: how much you want to trade in units of the quote currency
|
937
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
938
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
939
|
+
"""
|
940
|
+
self.load_markets()
|
941
|
+
req = {
|
942
|
+
'cost': cost,
|
943
|
+
}
|
944
|
+
return self.create_order(symbol, 'market', 'buy', 0, None, self.extend(req, params))
|
945
|
+
|
946
|
+
def create_market_sell_order_with_cost(self, symbol: str, cost: float, params={}):
|
947
|
+
"""
|
948
|
+
create a market sell order by providing the symbol and cost
|
949
|
+
|
950
|
+
https://docs.alpaca.markets/reference/postorder
|
951
|
+
|
952
|
+
:param str symbol: unified symbol of the market to create an order in
|
953
|
+
:param float cost: how much you want to trade in units of the quote currency
|
954
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
955
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
956
|
+
"""
|
957
|
+
self.load_markets()
|
958
|
+
req = {
|
959
|
+
'cost': cost,
|
960
|
+
}
|
961
|
+
return self.create_order(symbol, 'market', 'sell', cost, None, self.extend(req, params))
|
962
|
+
|
908
963
|
def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
909
964
|
"""
|
910
965
|
create a trade order
|
@@ -918,6 +973,7 @@ class alpaca(Exchange, ImplicitAPI):
|
|
918
973
|
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
919
974
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
920
975
|
:param float [params.triggerPrice]: The price at which a trigger order is triggered at
|
976
|
+
:param float [params.cost]: *market orders only* the cost of the order in units of the quote currency
|
921
977
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
922
978
|
"""
|
923
979
|
self.load_markets()
|
@@ -925,7 +981,6 @@ class alpaca(Exchange, ImplicitAPI):
|
|
925
981
|
id = market['id']
|
926
982
|
request: dict = {
|
927
983
|
'symbol': id,
|
928
|
-
'qty': self.amount_to_precision(symbol, amount),
|
929
984
|
'side': side,
|
930
985
|
'type': type, # market, limit, stop_limit
|
931
986
|
}
|
@@ -940,6 +995,12 @@ class alpaca(Exchange, ImplicitAPI):
|
|
940
995
|
request['type'] = newType
|
941
996
|
if type.find('limit') >= 0:
|
942
997
|
request['limit_price'] = self.price_to_precision(symbol, price)
|
998
|
+
cost = self.safe_string(params, 'cost')
|
999
|
+
if cost is not None:
|
1000
|
+
params = self.omit(params, 'cost')
|
1001
|
+
request['notional'] = self.cost_to_precision(symbol, cost)
|
1002
|
+
else:
|
1003
|
+
request['qty'] = self.amount_to_precision(symbol, amount)
|
943
1004
|
defaultTIF = self.safe_string(self.options, 'defaultTimeInForce')
|
944
1005
|
request['time_in_force'] = self.safe_string(params, 'timeInForce', defaultTIF)
|
945
1006
|
params = self.omit(params, ['timeInForce', 'triggerPrice'])
|
ccxt/async_support/__init__.py
CHANGED
ccxt/async_support/alpaca.py
CHANGED
@@ -60,6 +60,9 @@ class alpaca(Exchange, ImplicitAPI):
|
|
60
60
|
'cancelOrder': True,
|
61
61
|
'closeAllPositions': False,
|
62
62
|
'closePosition': False,
|
63
|
+
'createMarketBuyOrder': True,
|
64
|
+
'createMarketBuyOrderWithCost': True,
|
65
|
+
'createMarketOrderWithCost': True,
|
63
66
|
'createOrder': True,
|
64
67
|
'createStopOrder': True,
|
65
68
|
'createTriggerOrder': True,
|
@@ -442,7 +445,7 @@ class alpaca(Exchange, ImplicitAPI):
|
|
442
445
|
# "status": "active",
|
443
446
|
# "tradable": True,
|
444
447
|
# "marginable": False,
|
445
|
-
# "maintenance_margin_requirement":
|
448
|
+
# "maintenance_margin_requirement": 101,
|
446
449
|
# "shortable": False,
|
447
450
|
# "easy_to_borrow": False,
|
448
451
|
# "fractionable": True,
|
@@ -905,6 +908,58 @@ class alpaca(Exchange, ImplicitAPI):
|
|
905
908
|
clientOrderId = self.safe_string(params, 'clientOrderId', defaultClientId)
|
906
909
|
return clientOrderId
|
907
910
|
|
911
|
+
async def create_market_order_with_cost(self, symbol: str, side: OrderSide, cost: float, params={}):
|
912
|
+
"""
|
913
|
+
create a market order by providing the symbol, side and cost
|
914
|
+
|
915
|
+
https://docs.alpaca.markets/reference/postorder
|
916
|
+
|
917
|
+
:param str symbol: unified symbol of the market to create an order in
|
918
|
+
:param str side: 'buy' or 'sell'
|
919
|
+
:param float cost: how much you want to trade in units of the quote currency
|
920
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
921
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
922
|
+
"""
|
923
|
+
await self.load_markets()
|
924
|
+
req = {
|
925
|
+
'cost': cost,
|
926
|
+
}
|
927
|
+
return await self.create_order(symbol, 'market', side, 0, None, self.extend(req, params))
|
928
|
+
|
929
|
+
async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
|
930
|
+
"""
|
931
|
+
create a market buy order by providing the symbol and cost
|
932
|
+
|
933
|
+
https://docs.alpaca.markets/reference/postorder
|
934
|
+
|
935
|
+
:param str symbol: unified symbol of the market to create an order in
|
936
|
+
:param float cost: how much you want to trade in units of the quote currency
|
937
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
938
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
939
|
+
"""
|
940
|
+
await self.load_markets()
|
941
|
+
req = {
|
942
|
+
'cost': cost,
|
943
|
+
}
|
944
|
+
return await self.create_order(symbol, 'market', 'buy', 0, None, self.extend(req, params))
|
945
|
+
|
946
|
+
async def create_market_sell_order_with_cost(self, symbol: str, cost: float, params={}):
|
947
|
+
"""
|
948
|
+
create a market sell order by providing the symbol and cost
|
949
|
+
|
950
|
+
https://docs.alpaca.markets/reference/postorder
|
951
|
+
|
952
|
+
:param str symbol: unified symbol of the market to create an order in
|
953
|
+
:param float cost: how much you want to trade in units of the quote currency
|
954
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
955
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
956
|
+
"""
|
957
|
+
await self.load_markets()
|
958
|
+
req = {
|
959
|
+
'cost': cost,
|
960
|
+
}
|
961
|
+
return await self.create_order(symbol, 'market', 'sell', cost, None, self.extend(req, params))
|
962
|
+
|
908
963
|
async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
909
964
|
"""
|
910
965
|
create a trade order
|
@@ -918,6 +973,7 @@ class alpaca(Exchange, ImplicitAPI):
|
|
918
973
|
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
919
974
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
920
975
|
:param float [params.triggerPrice]: The price at which a trigger order is triggered at
|
976
|
+
:param float [params.cost]: *market orders only* the cost of the order in units of the quote currency
|
921
977
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
922
978
|
"""
|
923
979
|
await self.load_markets()
|
@@ -925,7 +981,6 @@ class alpaca(Exchange, ImplicitAPI):
|
|
925
981
|
id = market['id']
|
926
982
|
request: dict = {
|
927
983
|
'symbol': id,
|
928
|
-
'qty': self.amount_to_precision(symbol, amount),
|
929
984
|
'side': side,
|
930
985
|
'type': type, # market, limit, stop_limit
|
931
986
|
}
|
@@ -940,6 +995,12 @@ class alpaca(Exchange, ImplicitAPI):
|
|
940
995
|
request['type'] = newType
|
941
996
|
if type.find('limit') >= 0:
|
942
997
|
request['limit_price'] = self.price_to_precision(symbol, price)
|
998
|
+
cost = self.safe_string(params, 'cost')
|
999
|
+
if cost is not None:
|
1000
|
+
params = self.omit(params, 'cost')
|
1001
|
+
request['notional'] = self.cost_to_precision(symbol, cost)
|
1002
|
+
else:
|
1003
|
+
request['qty'] = self.amount_to_precision(symbol, amount)
|
943
1004
|
defaultTIF = self.safe_string(self.options, 'defaultTimeInForce')
|
944
1005
|
request['time_in_force'] = self.safe_string(params, 'timeInForce', defaultTIF)
|
945
1006
|
params = self.omit(params, ['timeInForce', 'triggerPrice'])
|
ccxt/async_support/binance.py
CHANGED
@@ -503,6 +503,7 @@ class binance(Exchange, ImplicitAPI):
|
|
503
503
|
'portfolio/repay-futures-switch': 3, # Weight(IP): 30 => cost = 0.1 * 30 = 3
|
504
504
|
'portfolio/margin-asset-leverage': 5, # Weight(IP): 50 => cost = 0.1 * 50 = 5
|
505
505
|
'portfolio/balance': 2,
|
506
|
+
'portfolio/negative-balance-exchange-record': 2,
|
506
507
|
# staking
|
507
508
|
'staking/productList': 0.1,
|
508
509
|
'staking/position': 0.1,
|
@@ -1599,7 +1600,7 @@ class binance(Exchange, ImplicitAPI):
|
|
1599
1600
|
'triggerDirection': False,
|
1600
1601
|
'stopLossPrice': True,
|
1601
1602
|
'takeProfitPrice': True,
|
1602
|
-
'attachedStopLossTakeProfit': None,
|
1603
|
+
'attachedStopLossTakeProfit': None,
|
1603
1604
|
'timeInForce': {
|
1604
1605
|
'IOC': True,
|
1605
1606
|
'FOK': True,
|
@@ -1608,12 +1609,16 @@ class binance(Exchange, ImplicitAPI):
|
|
1608
1609
|
},
|
1609
1610
|
'hedged': True,
|
1610
1611
|
'leverage': False,
|
1611
|
-
'marketBuyRequiresPrice': False,
|
1612
1612
|
'marketBuyByCost': True,
|
1613
|
-
|
1614
|
-
'selfTradePrevention':
|
1615
|
-
|
1616
|
-
|
1613
|
+
'marketBuyRequiresPrice': False,
|
1614
|
+
'selfTradePrevention': {
|
1615
|
+
'expire_maker': True,
|
1616
|
+
'expire_taker': True,
|
1617
|
+
'expire_both': True,
|
1618
|
+
'none': True,
|
1619
|
+
},
|
1620
|
+
'trailing': False, # todo: self is different from standard trailing https://github.com/binance/binance-spot-api-docs/blob/master/faqs/trailing-stop-faq.md
|
1621
|
+
'icebergAmount': True,
|
1617
1622
|
},
|
1618
1623
|
'createOrders': None,
|
1619
1624
|
'fetchMyTrades': {
|
@@ -1654,7 +1659,7 @@ class binance(Exchange, ImplicitAPI):
|
|
1654
1659
|
'limit': 1000,
|
1655
1660
|
},
|
1656
1661
|
},
|
1657
|
-
'
|
1662
|
+
'forDerivatives': {
|
1658
1663
|
'sandbox': True,
|
1659
1664
|
'createOrder': {
|
1660
1665
|
'marginMode': False,
|
@@ -1726,18 +1731,18 @@ class binance(Exchange, ImplicitAPI):
|
|
1726
1731
|
},
|
1727
1732
|
'swap': {
|
1728
1733
|
'linear': {
|
1729
|
-
'extends': '
|
1734
|
+
'extends': 'forDerivatives',
|
1730
1735
|
},
|
1731
1736
|
'inverse': {
|
1732
|
-
'extends': '
|
1737
|
+
'extends': 'forDerivatives',
|
1733
1738
|
},
|
1734
1739
|
},
|
1735
1740
|
'future': {
|
1736
1741
|
'linear': {
|
1737
|
-
'extends': '
|
1742
|
+
'extends': 'forDerivatives',
|
1738
1743
|
},
|
1739
1744
|
'inverse': {
|
1740
|
-
'extends': '
|
1745
|
+
'extends': 'forDerivatives',
|
1741
1746
|
},
|
1742
1747
|
},
|
1743
1748
|
},
|
@@ -4401,12 +4406,11 @@ class binance(Exchange, ImplicitAPI):
|
|
4401
4406
|
type = 'spot' if (timestamp is None) else 'swap'
|
4402
4407
|
marketId = self.safe_string(entry, 'symbol')
|
4403
4408
|
market = self.safe_market(marketId, market, None, type)
|
4404
|
-
price = self.safe_number(entry, 'price')
|
4405
4409
|
return {
|
4406
4410
|
'symbol': market['symbol'],
|
4407
4411
|
'timestamp': timestamp,
|
4408
4412
|
'datetime': self.iso8601(timestamp),
|
4409
|
-
'price': price,
|
4413
|
+
'price': self.safe_number_omit_zero(entry, 'price'),
|
4410
4414
|
'side': None,
|
4411
4415
|
'info': entry,
|
4412
4416
|
}
|
@@ -5001,11 +5005,13 @@ class binance(Exchange, ImplicitAPI):
|
|
5001
5005
|
until = self.safe_integer(params, 'until')
|
5002
5006
|
if until is not None:
|
5003
5007
|
request['endTime'] = until
|
5004
|
-
if limit is not None:
|
5005
|
-
isFutureOrSwap = (market['swap'] or market['future'])
|
5006
|
-
request['limit'] = min(limit, 1000) if isFutureOrSwap else limit # default = 500, maximum = 1000
|
5007
5008
|
method = self.safe_string(self.options, 'fetchTradesMethod')
|
5008
5009
|
method = self.safe_string_2(params, 'fetchTradesMethod', 'method', method)
|
5010
|
+
if limit is not None:
|
5011
|
+
isFutureOrSwap = (market['swap'] or market['future'])
|
5012
|
+
isHistoricalEndpoint = (method is not None) and (method.find('GetHistoricalTrades') >= 0)
|
5013
|
+
maxLimitForContractHistorical = 500 if isHistoricalEndpoint else 1000
|
5014
|
+
request['limit'] = min(limit, maxLimitForContractHistorical) if isFutureOrSwap else limit # default = 500, maximum = 1000
|
5009
5015
|
params = self.omit(params, ['until', 'fetchTradesMethod'])
|
5010
5016
|
response = None
|
5011
5017
|
if market['option'] or method == 'eapiPublicGetTrades':
|
@@ -6019,7 +6025,7 @@ class binance(Exchange, ImplicitAPI):
|
|
6019
6025
|
"""
|
6020
6026
|
create a trade order
|
6021
6027
|
|
6022
|
-
https://developers.binance.com/docs/binance-spot-api-docs/rest-api/
|
6028
|
+
https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade
|
6023
6029
|
https://developers.binance.com/docs/binance-spot-api-docs/rest-api/public-api-endpoints#test-new-order-trade
|
6024
6030
|
https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/New-Order
|
6025
6031
|
https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/New-Order
|
@@ -6048,6 +6054,8 @@ class binance(Exchange, ImplicitAPI):
|
|
6048
6054
|
:param float [params.stopLossPrice]: the price that a stop loss order is triggered at
|
6049
6055
|
:param float [params.takeProfitPrice]: the price that a take profit order is triggered at
|
6050
6056
|
:param boolean [params.portfolioMargin]: set to True if you would like to create an order in a portfolio margin account
|
6057
|
+
:param str [params.selfTradePrevention]: set unified value for stp(see .features for available values)
|
6058
|
+
:param float [params.icebergAmount]: set iceberg amount for limit orders
|
6051
6059
|
:param str [params.stopLossOrTakeProfit]: 'stopLoss' or 'takeProfit', required for spot trailing orders
|
6052
6060
|
:param str [params.positionSide]: *swap and portfolio margin only* "BOTH" for one-way mode, "LONG" for buy side of hedged mode, "SHORT" for sell side of hedged mode
|
6053
6061
|
:param bool [params.hedged]: *swap and portfolio margin only* True for hedged mode, False for one way mode, default is False
|
@@ -6341,7 +6349,7 @@ class binance(Exchange, ImplicitAPI):
|
|
6341
6349
|
if stopPrice is not None:
|
6342
6350
|
request['stopPrice'] = self.price_to_precision(symbol, stopPrice)
|
6343
6351
|
if timeInForceIsRequired and (self.safe_string(params, 'timeInForce') is None) and (self.safe_string(request, 'timeInForce') is None):
|
6344
|
-
request['timeInForce'] = self.options
|
6352
|
+
request['timeInForce'] = self.safe_string(self.options, 'defaultTimeInForce') # 'GTC' = Good To Cancel(default), 'IOC' = Immediate Or Cancel
|
6345
6353
|
if not isPortfolioMargin and market['contract'] and postOnly:
|
6346
6354
|
request['timeInForce'] = 'GTX'
|
6347
6355
|
# remove timeInForce from params because PO is only used by self.is_post_only and it's not a valid value for Binance
|
@@ -6353,7 +6361,17 @@ class binance(Exchange, ImplicitAPI):
|
|
6353
6361
|
params = self.omit(params, 'reduceOnly')
|
6354
6362
|
side = 'sell' if (side == 'buy') else 'buy'
|
6355
6363
|
request['positionSide'] = 'LONG' if (side == 'buy') else 'SHORT'
|
6356
|
-
|
6364
|
+
# unified stp
|
6365
|
+
selfTradePrevention = self.safe_string(params, 'selfTradePrevention')
|
6366
|
+
if selfTradePrevention is not None:
|
6367
|
+
if market['spot']:
|
6368
|
+
request['selfTradePreventionMode'] = selfTradePrevention.upper() # binance enums exactly match the unified ccxt enums(but needs uppercase)
|
6369
|
+
# unified iceberg
|
6370
|
+
icebergAmount = self.safe_number(params, 'icebergAmount')
|
6371
|
+
if icebergAmount is not None:
|
6372
|
+
if market['spot']:
|
6373
|
+
request['icebergQty'] = self.amount_to_precision(symbol, icebergAmount)
|
6374
|
+
requestParams = self.omit(params, ['type', 'newClientOrderId', 'clientOrderId', 'postOnly', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'triggerPrice', 'trailingTriggerPrice', 'trailingPercent', 'quoteOrderQty', 'cost', 'test', 'hedged', 'selfTradePrevention', 'icebergAmount'])
|
6357
6375
|
return self.extend(request, requestParams)
|
6358
6376
|
|
6359
6377
|
async def create_market_order_with_cost(self, symbol: str, side: OrderSide, cost: float, params={}):
|
@@ -6837,6 +6855,7 @@ class binance(Exchange, ImplicitAPI):
|
|
6837
6855
|
:param str symbol: unified market symbol
|
6838
6856
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
6839
6857
|
:param str [params.trigger]: set to True if you would like to fetch portfolio margin account stop or conditional orders
|
6858
|
+
:param boolean [params.portfolioMargin]: set to True if you would like to fetch for a portfolio margin account
|
6840
6859
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
6841
6860
|
"""
|
6842
6861
|
if symbol is None:
|
@@ -10159,7 +10178,7 @@ class binance(Exchange, ImplicitAPI):
|
|
10159
10178
|
# }
|
10160
10179
|
#
|
10161
10180
|
marketId = self.safe_string(position, 'symbol')
|
10162
|
-
market = self.safe_market(marketId, market)
|
10181
|
+
market = self.safe_market(marketId, market, None, 'swap')
|
10163
10182
|
symbol = market['symbol']
|
10164
10183
|
side = self.safe_string_lower(position, 'side')
|
10165
10184
|
quantity = self.safe_string(position, 'quantity')
|
ccxt/async_support/blofin.py
CHANGED
@@ -166,6 +166,9 @@ class blofin(Exchange, ImplicitAPI):
|
|
166
166
|
'api': {
|
167
167
|
'rest': 'https://openapi.blofin.com',
|
168
168
|
},
|
169
|
+
'test': {
|
170
|
+
'rest': 'https://demo-trading-openapi.blofin.com',
|
171
|
+
},
|
169
172
|
'referral': {
|
170
173
|
'url': 'https://blofin.com/register?referral_code=f79EsS',
|
171
174
|
'discount': 0.05,
|
@@ -295,7 +298,7 @@ class blofin(Exchange, ImplicitAPI):
|
|
295
298
|
'trailing': False,
|
296
299
|
},
|
297
300
|
'fetchOHLCV': {
|
298
|
-
'
|
301
|
+
'limit': 1440,
|
299
302
|
},
|
300
303
|
},
|
301
304
|
'spot': {
|
@@ -323,6 +326,7 @@ class blofin(Exchange, ImplicitAPI):
|
|
323
326
|
'attachedStopLossTakeProfit': {
|
324
327
|
'triggerPriceType': None,
|
325
328
|
'limit': True,
|
329
|
+
'price': None,
|
326
330
|
},
|
327
331
|
'hedged': True,
|
328
332
|
},
|
ccxt/async_support/coinex.py
CHANGED
@@ -481,7 +481,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
481
481
|
'ERC20': 'ERC20',
|
482
482
|
'BRC20': 'BRC20',
|
483
483
|
'SOL': 'SOL',
|
484
|
-
'TON': '
|
484
|
+
'TON': 'TON',
|
485
485
|
'BSV': 'BSV',
|
486
486
|
'AVAXC': 'AVA_C',
|
487
487
|
'AVAXX': 'AVA',
|
@@ -3767,7 +3767,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3767
3767
|
'currency': self.safe_currency_code(None, currency),
|
3768
3768
|
'network': None,
|
3769
3769
|
'address': address,
|
3770
|
-
'tag': tag,
|
3770
|
+
'tag': self.safe_string(depositAddress, 'memo', tag),
|
3771
3771
|
}
|
3772
3772
|
|
3773
3773
|
async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
@@ -4609,13 +4609,13 @@ class coinex(Exchange, ImplicitAPI):
|
|
4609
4609
|
self.check_address(address)
|
4610
4610
|
await self.load_markets()
|
4611
4611
|
currency = self.currency(code)
|
4612
|
-
if tag:
|
4613
|
-
address = address + ':' + tag
|
4614
4612
|
request: dict = {
|
4615
4613
|
'ccy': currency['id'],
|
4616
4614
|
'to_address': address, # must be authorized, inter-user transfer by a registered mobile phone number or an email address is supported
|
4617
4615
|
'amount': self.number_to_string(amount), # the actual amount without fees, https://www.coinex.com/fees
|
4618
4616
|
}
|
4617
|
+
if tag is not None:
|
4618
|
+
request['memo'] = tag
|
4619
4619
|
networkCode = None
|
4620
4620
|
networkCode, params = self.handle_network_code_and_params(params)
|
4621
4621
|
if networkCode is not None:
|
ccxt/async_support/coinmetro.py
CHANGED
@@ -219,7 +219,7 @@ class coinmetro(Exchange, ImplicitAPI):
|
|
219
219
|
# exchange-specific options
|
220
220
|
'options': {
|
221
221
|
'currenciesByIdForParseMarket': None,
|
222
|
-
'currencyIdsListForParseMarket':
|
222
|
+
'currencyIdsListForParseMarket': ['QRDO'],
|
223
223
|
},
|
224
224
|
'features': {
|
225
225
|
'spot': {
|
@@ -407,7 +407,11 @@ class coinmetro(Exchange, ImplicitAPI):
|
|
407
407
|
if self.safe_value(self.options, 'currenciesByIdForParseMarket') is None:
|
408
408
|
currenciesById = self.index_by(result, 'id')
|
409
409
|
self.options['currenciesByIdForParseMarket'] = currenciesById
|
410
|
-
self.options
|
410
|
+
currentCurrencyIdsList = self.safe_list(self.options, 'currencyIdsListForParseMarket', [])
|
411
|
+
currencyIdsList = list(currenciesById.keys())
|
412
|
+
for i in range(0, len(currencyIdsList)):
|
413
|
+
currentCurrencyIdsList.append(currencyIdsList[i])
|
414
|
+
self.options['currencyIdsListForParseMarket'] = currentCurrencyIdsList
|
411
415
|
return result
|
412
416
|
|
413
417
|
async def fetch_markets(self, params={}) -> List[Market]:
|
@@ -506,10 +510,19 @@ class coinmetro(Exchange, ImplicitAPI):
|
|
506
510
|
baseId = None
|
507
511
|
quoteId = None
|
508
512
|
currencyIds = self.safe_value(self.options, 'currencyIdsListForParseMarket', [])
|
513
|
+
# Bubble sort by length(longest first)
|
514
|
+
currencyIdsLength = len(currencyIds)
|
515
|
+
for i in range(0, currencyIdsLength):
|
516
|
+
for j in range(0, currencyIdsLength - i - 1):
|
517
|
+
a = currencyIds[j]
|
518
|
+
b = currencyIds[j + 1]
|
519
|
+
if len(a) < len(b):
|
520
|
+
currencyIds[j] = b
|
521
|
+
currencyIds[j + 1] = a
|
509
522
|
for i in range(0, len(currencyIds)):
|
510
523
|
currencyId = currencyIds[i]
|
511
524
|
entryIndex = marketId.find(currencyId)
|
512
|
-
if entryIndex
|
525
|
+
if entryIndex == 0:
|
513
526
|
restId = marketId.replace(currencyId, '')
|
514
527
|
if self.in_array(restId, currencyIds):
|
515
528
|
if entryIndex == 0:
|
ccxt/async_support/deribit.py
CHANGED
@@ -3063,7 +3063,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
3063
3063
|
:param int [since]: the earliest time in ms to fetch funding rate history for
|
3064
3064
|
:param int [limit]: the maximum number of entries to retrieve
|
3065
3065
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3066
|
-
:param int [params.
|
3066
|
+
:param int [params.until]: fetch funding rate ending at self timestamp
|
3067
3067
|
: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)
|
3068
3068
|
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
3069
3069
|
"""
|
@@ -3072,16 +3072,24 @@ class deribit(Exchange, ImplicitAPI):
|
|
3072
3072
|
paginate = False
|
3073
3073
|
paginate, params = self.handle_option_and_params(params, 'fetchFundingRateHistory', 'paginate')
|
3074
3074
|
if paginate:
|
3075
|
-
|
3075
|
+
# 1h needed to fix : https://github.com/ccxt/ccxt/issues/25040
|
3076
|
+
return await self.fetch_paginated_call_deterministic('fetchFundingRateHistory', symbol, since, limit, '1h', params, 720)
|
3076
3077
|
time = self.milliseconds()
|
3077
3078
|
month = 30 * 24 * 60 * 60 * 1000
|
3078
3079
|
if since is None:
|
3079
3080
|
since = time - month
|
3081
|
+
else:
|
3082
|
+
time = since + month
|
3080
3083
|
request: dict = {
|
3081
3084
|
'instrument_name': market['id'],
|
3082
3085
|
'start_timestamp': since - 1,
|
3083
|
-
'end_timestamp': time,
|
3084
3086
|
}
|
3087
|
+
until = self.safe_integer_2(params, 'until', 'end_timestamp')
|
3088
|
+
if until is not None:
|
3089
|
+
params = self.omit(params, ['until'])
|
3090
|
+
request['end_timestamp'] = until
|
3091
|
+
else:
|
3092
|
+
request['end_timestamp'] = time
|
3085
3093
|
response = await self.publicGetGetFundingRateHistory(self.extend(request, params))
|
3086
3094
|
#
|
3087
3095
|
# {
|
ccxt/async_support/gate.py
CHANGED
@@ -1792,7 +1792,7 @@ class gate(Exchange, ImplicitAPI):
|
|
1792
1792
|
active = listed and tradeEnabled and withdrawEnabled and depositEnabled
|
1793
1793
|
if self.safe_value(result, code) is None:
|
1794
1794
|
result[code] = {
|
1795
|
-
'id':
|
1795
|
+
'id': currency,
|
1796
1796
|
'code': code,
|
1797
1797
|
'info': None,
|
1798
1798
|
'name': None,
|