ccxt 4.3.67__py2.py3-none-any.whl → 4.3.69__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/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/binance.py +2 -2
- ccxt/async_support/bingx.py +446 -215
- ccxt/async_support/bitget.py +5 -4
- ccxt/async_support/bitmart.py +2 -2
- ccxt/async_support/bitrue.py +2 -2
- ccxt/async_support/btcbox.py +1 -1
- ccxt/async_support/bybit.py +2 -2
- ccxt/async_support/coinbaseinternational.py +72 -1
- ccxt/async_support/coinex.py +2 -2
- ccxt/async_support/coinlist.py +2 -2
- ccxt/async_support/deribit.py +2 -2
- ccxt/async_support/digifinex.py +2 -2
- ccxt/async_support/hyperliquid.py +0 -2
- ccxt/async_support/kucoin.py +11 -5
- ccxt/async_support/latoken.py +2 -2
- ccxt/async_support/mexc.py +2 -2
- ccxt/async_support/okx.py +2 -2
- ccxt/async_support/oxfun.py +1 -1
- ccxt/async_support/phemex.py +2 -2
- ccxt/async_support/poloniex.py +33 -33
- ccxt/async_support/poloniexfutures.py +26 -26
- ccxt/async_support/woo.py +2 -2
- ccxt/base/exchange.py +333 -120
- ccxt/base/types.py +21 -3
- ccxt/binance.py +2 -2
- ccxt/bingx.py +446 -215
- ccxt/bitget.py +5 -4
- ccxt/bitmart.py +2 -2
- ccxt/bitrue.py +2 -2
- ccxt/btcbox.py +1 -1
- ccxt/bybit.py +2 -2
- ccxt/coinbaseinternational.py +72 -1
- ccxt/coinex.py +2 -2
- ccxt/coinlist.py +2 -2
- ccxt/deribit.py +2 -2
- ccxt/digifinex.py +2 -2
- ccxt/hyperliquid.py +0 -2
- ccxt/kucoin.py +11 -5
- ccxt/latoken.py +2 -2
- ccxt/mexc.py +2 -2
- ccxt/okx.py +2 -2
- ccxt/oxfun.py +1 -1
- ccxt/phemex.py +2 -2
- ccxt/poloniex.py +33 -33
- ccxt/poloniexfutures.py +26 -26
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/krakenfutures.py +7 -6
- ccxt/pro/poloniex.py +13 -13
- ccxt/pro/poloniexfutures.py +5 -5
- ccxt/woo.py +2 -2
- {ccxt-4.3.67.dist-info → ccxt-4.3.69.dist-info}/METADATA +6 -6
- {ccxt-4.3.67.dist-info → ccxt-4.3.69.dist-info}/RECORD +58 -58
- {ccxt-4.3.67.dist-info → ccxt-4.3.69.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.3.67.dist-info → ccxt-4.3.69.dist-info}/WHEEL +0 -0
- {ccxt-4.3.67.dist-info → ccxt-4.3.69.dist-info}/top_level.txt +0 -0
ccxt/bingx.py
CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.bingx import ImplicitAPI
|
8
8
|
import hashlib
|
9
9
|
import numbers
|
10
|
-
from ccxt.base.types import Balances, Currencies, Currency, Int, Leverage, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
|
10
|
+
from ccxt.base.types import Balances, Currencies, Currency, Int, Leverage, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
13
13
|
from ccxt.base.errors import AuthenticationError
|
@@ -62,6 +62,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
62
62
|
'createTrailingPercentOrder': True,
|
63
63
|
'createTriggerOrder': True,
|
64
64
|
'fetchBalance': True,
|
65
|
+
'fetchCanceledOrders': True,
|
65
66
|
'fetchClosedOrders': True,
|
66
67
|
'fetchCurrencies': True,
|
67
68
|
'fetchDepositAddress': True,
|
@@ -1109,7 +1110,27 @@ class bingx(Exchange, ImplicitAPI):
|
|
1109
1110
|
# "s": "BTC-USDT"
|
1110
1111
|
# }
|
1111
1112
|
#
|
1112
|
-
|
1113
|
+
# inverse swap fetchMyTrades
|
1114
|
+
#
|
1115
|
+
# {
|
1116
|
+
# "orderId": "1817441228670648320",
|
1117
|
+
# "symbol": "SOL-USD",
|
1118
|
+
# "type": "MARKET",
|
1119
|
+
# "side": "BUY",
|
1120
|
+
# "positionSide": "LONG",
|
1121
|
+
# "tradeId": "97244554",
|
1122
|
+
# "volume": "2",
|
1123
|
+
# "tradePrice": "182.652",
|
1124
|
+
# "amount": "20.00000000",
|
1125
|
+
# "realizedPnl": "0.00000000",
|
1126
|
+
# "commission": "-0.00005475",
|
1127
|
+
# "currency": "SOL",
|
1128
|
+
# "buyer": True,
|
1129
|
+
# "maker": False,
|
1130
|
+
# "tradeTime": 1722146730000
|
1131
|
+
# }
|
1132
|
+
#
|
1133
|
+
time = self.safe_integer_n(trade, ['time', 'filledTm', 'T', 'tradeTime'])
|
1113
1134
|
datetimeId = self.safe_string(trade, 'filledTm')
|
1114
1135
|
if datetimeId is not None:
|
1115
1136
|
time = self.parse8601(datetimeId)
|
@@ -1120,8 +1141,8 @@ class bingx(Exchange, ImplicitAPI):
|
|
1120
1141
|
currencyId = self.safe_string_n(trade, ['currency', 'N', 'commissionAsset'])
|
1121
1142
|
currencyCode = self.safe_currency_code(currencyId)
|
1122
1143
|
m = self.safe_bool(trade, 'm')
|
1123
|
-
marketId = self.
|
1124
|
-
isBuyerMaker = self.
|
1144
|
+
marketId = self.safe_string_2(trade, 's', 'symbol')
|
1145
|
+
isBuyerMaker = self.safe_bool_n(trade, ['buyerMaker', 'isBuyerMaker', 'maker'])
|
1125
1146
|
takeOrMaker = None
|
1126
1147
|
if (isBuyerMaker is not None) or (m is not None):
|
1127
1148
|
takeOrMaker = 'maker' if (isBuyerMaker or m) else 'taker'
|
@@ -1152,7 +1173,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
1152
1173
|
'type': self.safe_string_lower(trade, 'o'),
|
1153
1174
|
'side': self.parse_order_side(side),
|
1154
1175
|
'takerOrMaker': takeOrMaker,
|
1155
|
-
'price': self.
|
1176
|
+
'price': self.safe_string_n(trade, ['price', 'p', 'tradePrice']),
|
1156
1177
|
'amount': amount,
|
1157
1178
|
'cost': cost,
|
1158
1179
|
'fee': {
|
@@ -2841,8 +2862,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
2841
2862
|
# "clientOrderID": ""
|
2842
2863
|
# }
|
2843
2864
|
#
|
2844
|
-
# inverse swap cancelAllOrders, cancelOrder
|
2845
|
-
# inverse swap cancelAllOrders, cancelOrder, fetchOpenOrders
|
2865
|
+
# inverse swap cancelAllOrders, cancelOrder, fetchOrder, fetchOpenOrders, fetchClosedOrders, fetchCanceledOrders
|
2846
2866
|
#
|
2847
2867
|
# {
|
2848
2868
|
# "symbol": "SOL-USD",
|
@@ -2900,7 +2920,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
2900
2920
|
side = self.safe_string_lower_2(order, 'side', 'S')
|
2901
2921
|
timestamp = self.safe_integer_n(order, ['time', 'transactTime', 'E'])
|
2902
2922
|
lastTradeTimestamp = self.safe_integer_2(order, 'updateTime', 'T')
|
2903
|
-
statusId = self.
|
2923
|
+
statusId = self.safe_string_upper_2(order, 'status', 'X')
|
2904
2924
|
feeCurrencyCode = self.safe_string_2(order, 'feeAsset', 'N')
|
2905
2925
|
feeCost = self.safe_string_n(order, ['fee', 'commission', 'n'])
|
2906
2926
|
if (feeCurrencyCode is None):
|
@@ -3399,11 +3419,12 @@ class bingx(Exchange, ImplicitAPI):
|
|
3399
3419
|
def fetch_order(self, id: str, symbol: Str = None, params={}):
|
3400
3420
|
"""
|
3401
3421
|
fetches information on an order made by the user
|
3402
|
-
:see: https://bingx-api.github.io/docs/#/spot/trade-api.html#Query%
|
3403
|
-
:see: https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Query%20Order
|
3422
|
+
:see: https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Order%20details
|
3423
|
+
:see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20details
|
3424
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Order
|
3404
3425
|
:param str symbol: unified symbol of the market the order was made in
|
3405
3426
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3406
|
-
:returns dict:
|
3427
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
3407
3428
|
"""
|
3408
3429
|
if symbol is None:
|
3409
3430
|
raise ArgumentsRequired(self.id + ' fetchOrder() requires a symbol argument')
|
@@ -3413,66 +3434,120 @@ class bingx(Exchange, ImplicitAPI):
|
|
3413
3434
|
'symbol': market['id'],
|
3414
3435
|
'orderId': id,
|
3415
3436
|
}
|
3437
|
+
type = None
|
3438
|
+
subType = None
|
3416
3439
|
response = None
|
3417
|
-
|
3418
|
-
|
3419
|
-
|
3440
|
+
type, params = self.handle_market_type_and_params('fetchOrder', market, params)
|
3441
|
+
subType, params = self.handle_sub_type_and_params('fetchOrder', market, params)
|
3442
|
+
if type == 'spot':
|
3443
|
+
response = self.spotV1PrivateGetTradeQuery(self.extend(request, params))
|
3444
|
+
#
|
3445
|
+
# {
|
3446
|
+
# "code": 0,
|
3447
|
+
# "msg": "",
|
3448
|
+
# "data": {
|
3449
|
+
# "symbol": "XRP-USDT",
|
3450
|
+
# "orderId": 1514087361158316032,
|
3451
|
+
# "price": "0.5",
|
3452
|
+
# "origQty": "10",
|
3453
|
+
# "executedQty": "0",
|
3454
|
+
# "cummulativeQuoteQty": "0",
|
3455
|
+
# "status": "CANCELED",
|
3456
|
+
# "type": "LIMIT",
|
3457
|
+
# "side": "BUY",
|
3458
|
+
# "time": 1649821532000,
|
3459
|
+
# "updateTime": 1649821543000,
|
3460
|
+
# "origQuoteOrderQty": "0",
|
3461
|
+
# "fee": "0",
|
3462
|
+
# "feeAsset": "XRP"
|
3463
|
+
# }
|
3464
|
+
# }
|
3465
|
+
#
|
3420
3466
|
else:
|
3421
|
-
|
3422
|
-
|
3423
|
-
|
3424
|
-
|
3425
|
-
|
3426
|
-
|
3427
|
-
|
3428
|
-
|
3429
|
-
|
3430
|
-
|
3431
|
-
|
3432
|
-
|
3433
|
-
|
3434
|
-
|
3435
|
-
|
3436
|
-
|
3437
|
-
|
3438
|
-
|
3439
|
-
|
3440
|
-
|
3441
|
-
|
3442
|
-
|
3443
|
-
|
3444
|
-
|
3445
|
-
|
3446
|
-
|
3447
|
-
|
3448
|
-
|
3449
|
-
|
3450
|
-
|
3451
|
-
|
3452
|
-
|
3453
|
-
|
3454
|
-
|
3455
|
-
|
3456
|
-
|
3457
|
-
|
3458
|
-
|
3459
|
-
|
3460
|
-
|
3461
|
-
|
3462
|
-
|
3463
|
-
|
3464
|
-
|
3465
|
-
|
3466
|
-
|
3467
|
-
|
3468
|
-
|
3469
|
-
|
3470
|
-
|
3471
|
-
|
3472
|
-
|
3473
|
-
|
3474
|
-
|
3475
|
-
|
3467
|
+
if subType == 'inverse':
|
3468
|
+
response = self.cswapV1PrivateGetTradeOrderDetail(self.extend(request, params))
|
3469
|
+
#
|
3470
|
+
# {
|
3471
|
+
# "code": 0,
|
3472
|
+
# "msg": "",
|
3473
|
+
# "data": {
|
3474
|
+
# "order": {
|
3475
|
+
# "symbol": "SOL-USD",
|
3476
|
+
# "orderId": "1816342420721254400",
|
3477
|
+
# "side": "BUY",
|
3478
|
+
# "positionSide": "Long",
|
3479
|
+
# "type": "LIMIT",
|
3480
|
+
# "quantity": 1,
|
3481
|
+
# "origQty": "",
|
3482
|
+
# "price": "150",
|
3483
|
+
# "executedQty": "0",
|
3484
|
+
# "avgPrice": "0.000",
|
3485
|
+
# "cumQuote": "",
|
3486
|
+
# "stopPrice": "",
|
3487
|
+
# "profit": "0.0000",
|
3488
|
+
# "commission": "0.0000",
|
3489
|
+
# "status": "Pending",
|
3490
|
+
# "time": 1721884753767,
|
3491
|
+
# "updateTime": 1721884753786,
|
3492
|
+
# "clientOrderId": "",
|
3493
|
+
# "leverage": "",
|
3494
|
+
# "takeProfit": {
|
3495
|
+
# "type": "TAKE_PROFIT",
|
3496
|
+
# "quantity": 0,
|
3497
|
+
# "stopPrice": 0,
|
3498
|
+
# "price": 0,
|
3499
|
+
# "workingType": "MARK_PRICE",
|
3500
|
+
# "stopGuaranteed": ""
|
3501
|
+
# },
|
3502
|
+
# "stopLoss": {
|
3503
|
+
# "type": "STOP",
|
3504
|
+
# "quantity": 0,
|
3505
|
+
# "stopPrice": 0,
|
3506
|
+
# "price": 0,
|
3507
|
+
# "workingType": "MARK_PRICE",
|
3508
|
+
# "stopGuaranteed": ""
|
3509
|
+
# },
|
3510
|
+
# "advanceAttr": 0,
|
3511
|
+
# "positionID": 0,
|
3512
|
+
# "takeProfitEntrustPrice": 0,
|
3513
|
+
# "stopLossEntrustPrice": 0,
|
3514
|
+
# "orderType": "",
|
3515
|
+
# "workingType": "MARK_PRICE"
|
3516
|
+
# }
|
3517
|
+
# }
|
3518
|
+
# }
|
3519
|
+
#
|
3520
|
+
else:
|
3521
|
+
response = self.swapV2PrivateGetTradeOrder(self.extend(request, params))
|
3522
|
+
#
|
3523
|
+
# {
|
3524
|
+
# "code": 0,
|
3525
|
+
# "msg": "",
|
3526
|
+
# "data": {
|
3527
|
+
# "order": {
|
3528
|
+
# "symbol": "BTC-USDT",
|
3529
|
+
# "orderId": 1597597642269917184,
|
3530
|
+
# "side": "SELL",
|
3531
|
+
# "positionSide": "LONG",
|
3532
|
+
# "type": "TAKE_PROFIT_MARKET",
|
3533
|
+
# "origQty": "1.0000",
|
3534
|
+
# "price": "0.0",
|
3535
|
+
# "executedQty": "0.0000",
|
3536
|
+
# "avgPrice": "0.0",
|
3537
|
+
# "cumQuote": "",
|
3538
|
+
# "stopPrice": "16494.0",
|
3539
|
+
# "profit": "",
|
3540
|
+
# "commission": "",
|
3541
|
+
# "status": "FILLED",
|
3542
|
+
# "time": 1669731935000,
|
3543
|
+
# "updateTime": 1669752524000
|
3544
|
+
# }
|
3545
|
+
# }
|
3546
|
+
# }
|
3547
|
+
#
|
3548
|
+
data = self.safe_dict(response, 'data', {})
|
3549
|
+
order = self.safe_dict(data, 'order', data)
|
3550
|
+
return self.parse_order(order, market)
|
3476
3551
|
|
3477
3552
|
def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
3478
3553
|
"""
|
@@ -3708,8 +3783,47 @@ class bingx(Exchange, ImplicitAPI):
|
|
3708
3783
|
def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
3709
3784
|
"""
|
3710
3785
|
fetches information on multiple closed orders made by the user
|
3711
|
-
:see: https://bingx-api.github.io/docs/#/spot/trade-api.html#Query%20Order%
|
3712
|
-
:see: https://bingx-api.github.io/docs/#/swapV2/trade-api.html#
|
3786
|
+
:see: https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Order%20history
|
3787
|
+
:see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20history
|
3788
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#User's%20History%20Orders
|
3789
|
+
:see: https://bingx-api.github.io/docs/#/standard/contract-interface.html#Historical%20order
|
3790
|
+
:param str symbol: unified market symbol of the closed orders
|
3791
|
+
:param int [since]: timestamp in ms of the earliest order
|
3792
|
+
:param int [limit]: the max number of closed orders to return
|
3793
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3794
|
+
:param int [params.until]: the latest time in ms to fetch orders for
|
3795
|
+
:param boolean [params.standard]: whether to fetch standard contract orders
|
3796
|
+
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
3797
|
+
"""
|
3798
|
+
self.load_markets()
|
3799
|
+
orders = self.fetch_canceled_and_closed_orders(symbol, since, limit, params)
|
3800
|
+
return self.filter_by(orders, 'status', 'closed')
|
3801
|
+
|
3802
|
+
def fetch_canceled_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
3803
|
+
"""
|
3804
|
+
fetches information on multiple canceled orders made by the user
|
3805
|
+
:see: https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Order%20history
|
3806
|
+
:see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20history
|
3807
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#User's%20History%20Orders
|
3808
|
+
:see: https://bingx-api.github.io/docs/#/standard/contract-interface.html#Historical%20order
|
3809
|
+
:param str symbol: unified market symbol of the canceled orders
|
3810
|
+
:param int [since]: timestamp in ms of the earliest order
|
3811
|
+
:param int [limit]: the max number of canceled orders to return
|
3812
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3813
|
+
:param int [params.until]: the latest time in ms to fetch orders for
|
3814
|
+
:param boolean [params.standard]: whether to fetch standard contract orders
|
3815
|
+
:returns dict: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
3816
|
+
"""
|
3817
|
+
self.load_markets()
|
3818
|
+
orders = self.fetch_canceled_and_closed_orders(symbol, since, limit, params)
|
3819
|
+
return self.filter_by(orders, 'status', 'canceled')
|
3820
|
+
|
3821
|
+
def fetch_canceled_and_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
3822
|
+
"""
|
3823
|
+
fetches information on multiple closed orders made by the user
|
3824
|
+
:see: https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Order%20history
|
3825
|
+
:see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20history
|
3826
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#User's%20History%20Orders
|
3713
3827
|
:see: https://bingx-api.github.io/docs/#/standard/contract-interface.html#Historical%20order
|
3714
3828
|
:param str [symbol]: unified market symbol of the market orders were made in
|
3715
3829
|
:param int [since]: the earliest time in ms to fetch orders for
|
@@ -3726,72 +3840,128 @@ class bingx(Exchange, ImplicitAPI):
|
|
3726
3840
|
request: dict = {
|
3727
3841
|
'symbol': market['id'],
|
3728
3842
|
}
|
3729
|
-
|
3843
|
+
type = None
|
3844
|
+
subType = None
|
3730
3845
|
standard = None
|
3846
|
+
response = None
|
3847
|
+
type, params = self.handle_market_type_and_params('fetchClosedOrders', market, params)
|
3848
|
+
subType, params = self.handle_sub_type_and_params('fetchClosedOrders', market, params)
|
3731
3849
|
standard, params = self.handle_option_and_params(params, 'fetchClosedOrders', 'standard', False)
|
3732
|
-
marketType, query = self.handle_market_type_and_params('fetchClosedOrders', market, params)
|
3733
3850
|
if standard:
|
3734
|
-
response = self.contractV1PrivateGetAllOrders(self.extend(request,
|
3735
|
-
elif
|
3736
|
-
response = self.spotV1PrivateGetTradeHistoryOrders(self.extend(request,
|
3851
|
+
response = self.contractV1PrivateGetAllOrders(self.extend(request, params))
|
3852
|
+
elif type == 'spot':
|
3853
|
+
response = self.spotV1PrivateGetTradeHistoryOrders(self.extend(request, params))
|
3854
|
+
#
|
3855
|
+
# {
|
3856
|
+
# "code": 0,
|
3857
|
+
# "msg": "",
|
3858
|
+
# "data": {
|
3859
|
+
# "orders": [
|
3860
|
+
# {
|
3861
|
+
# "symbol": "XRP-USDT",
|
3862
|
+
# "orderId": 1514073325788200960,
|
3863
|
+
# "price": "0.5",
|
3864
|
+
# "origQty": "20",
|
3865
|
+
# "executedQty": "0",
|
3866
|
+
# "cummulativeQuoteQty": "0",
|
3867
|
+
# "status": "PENDING",
|
3868
|
+
# "type": "LIMIT",
|
3869
|
+
# "side": "BUY",
|
3870
|
+
# "time": 1649818185647,
|
3871
|
+
# "updateTime": 1649818185647,
|
3872
|
+
# "origQuoteOrderQty": "0"
|
3873
|
+
# }
|
3874
|
+
# ]
|
3875
|
+
# }
|
3876
|
+
# }
|
3877
|
+
#
|
3737
3878
|
else:
|
3738
|
-
|
3739
|
-
|
3740
|
-
|
3741
|
-
|
3742
|
-
|
3743
|
-
|
3744
|
-
|
3745
|
-
|
3746
|
-
|
3747
|
-
|
3748
|
-
|
3749
|
-
|
3750
|
-
|
3751
|
-
|
3752
|
-
|
3753
|
-
|
3754
|
-
|
3755
|
-
|
3756
|
-
|
3757
|
-
|
3758
|
-
|
3759
|
-
|
3760
|
-
|
3761
|
-
|
3762
|
-
|
3763
|
-
|
3764
|
-
|
3765
|
-
|
3766
|
-
|
3767
|
-
|
3768
|
-
|
3769
|
-
|
3770
|
-
|
3771
|
-
|
3772
|
-
|
3773
|
-
|
3774
|
-
|
3775
|
-
|
3776
|
-
|
3777
|
-
|
3778
|
-
|
3779
|
-
|
3780
|
-
|
3781
|
-
|
3782
|
-
|
3783
|
-
|
3784
|
-
|
3785
|
-
|
3786
|
-
|
3787
|
-
|
3788
|
-
|
3789
|
-
|
3790
|
-
|
3791
|
-
|
3792
|
-
|
3793
|
-
|
3794
|
-
|
3879
|
+
if subType == 'inverse':
|
3880
|
+
response = self.cswapV1PrivateGetTradeOrderHistory(self.extend(request, params))
|
3881
|
+
#
|
3882
|
+
# {
|
3883
|
+
# "code": 0,
|
3884
|
+
# "msg": "",
|
3885
|
+
# "data": {
|
3886
|
+
# "orders": [
|
3887
|
+
# {
|
3888
|
+
# "symbol": "SOL-USD",
|
3889
|
+
# "orderId": "1816002957423951872",
|
3890
|
+
# "side": "BUY",
|
3891
|
+
# "positionSide": "LONG",
|
3892
|
+
# "type": "LIMIT",
|
3893
|
+
# "quantity": 1,
|
3894
|
+
# "origQty": "10.00000000",
|
3895
|
+
# "price": "150.000",
|
3896
|
+
# "executedQty": "0.00000000",
|
3897
|
+
# "avgPrice": "0.000",
|
3898
|
+
# "cumQuote": "",
|
3899
|
+
# "stopPrice": "0.000",
|
3900
|
+
# "profit": "0.0000",
|
3901
|
+
# "commission": "0.000000",
|
3902
|
+
# "status": "Filled",
|
3903
|
+
# "time": 1721803819000,
|
3904
|
+
# "updateTime": 1721803856000,
|
3905
|
+
# "clientOrderId": "",
|
3906
|
+
# "leverage": "",
|
3907
|
+
# "takeProfit": {
|
3908
|
+
# "type": "",
|
3909
|
+
# "quantity": 0,
|
3910
|
+
# "stopPrice": 0,
|
3911
|
+
# "price": 0,
|
3912
|
+
# "workingType": "",
|
3913
|
+
# "stopGuaranteed": ""
|
3914
|
+
# },
|
3915
|
+
# "stopLoss": {
|
3916
|
+
# "type": "",
|
3917
|
+
# "quantity": 0,
|
3918
|
+
# "stopPrice": 0,
|
3919
|
+
# "price": 0,
|
3920
|
+
# "workingType": "",
|
3921
|
+
# "stopGuaranteed": ""
|
3922
|
+
# },
|
3923
|
+
# "advanceAttr": 0,
|
3924
|
+
# "positionID": 0,
|
3925
|
+
# "takeProfitEntrustPrice": 0,
|
3926
|
+
# "stopLossEntrustPrice": 0,
|
3927
|
+
# "orderType": "",
|
3928
|
+
# "workingType": "MARK_PRICE"
|
3929
|
+
# },
|
3930
|
+
# ]
|
3931
|
+
# }
|
3932
|
+
# }
|
3933
|
+
#
|
3934
|
+
else:
|
3935
|
+
response = self.swapV2PrivateGetTradeAllOrders(self.extend(request, params))
|
3936
|
+
#
|
3937
|
+
# {
|
3938
|
+
# "code": 0,
|
3939
|
+
# "msg": "",
|
3940
|
+
# "data": {
|
3941
|
+
# "orders": [
|
3942
|
+
# {
|
3943
|
+
# "symbol": "LINK-USDT",
|
3944
|
+
# "orderId": 1585839271162413056,
|
3945
|
+
# "side": "BUY",
|
3946
|
+
# "positionSide": "LONG",
|
3947
|
+
# "type": "TRIGGER_MARKET",
|
3948
|
+
# "origQty": "5.0",
|
3949
|
+
# "price": "9",
|
3950
|
+
# "executedQty": "0.0",
|
3951
|
+
# "avgPrice": "0",
|
3952
|
+
# "cumQuote": "0",
|
3953
|
+
# "stopPrice": "5",
|
3954
|
+
# "profit": "0.0000",
|
3955
|
+
# "commission": "0.000000",
|
3956
|
+
# "status": "CANCELLED",
|
3957
|
+
# "time": 1667631605000,
|
3958
|
+
# "updateTime": 1667631605000
|
3959
|
+
# },
|
3960
|
+
# ]
|
3961
|
+
# }
|
3962
|
+
# }
|
3963
|
+
#
|
3964
|
+
data = self.safe_dict(response, 'data', {})
|
3795
3965
|
orders = self.safe_list(data, 'orders', [])
|
3796
3966
|
return self.parse_orders(orders, market, since, limit)
|
3797
3967
|
|
@@ -3834,7 +4004,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
3834
4004
|
'status': None,
|
3835
4005
|
}
|
3836
4006
|
|
3837
|
-
def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) ->
|
4007
|
+
def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[TransferEntry]:
|
3838
4008
|
"""
|
3839
4009
|
fetch a history of internal transfers made on an account
|
3840
4010
|
:see: https://bingx-api.github.io/docs/#/spot/account-api.html#Query%20User%20Universal%20Transfer%20History%20(USER_DATA)
|
@@ -4194,7 +4364,8 @@ class bingx(Exchange, ImplicitAPI):
|
|
4194
4364
|
def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
|
4195
4365
|
"""
|
4196
4366
|
set margin mode to 'cross' or 'isolated'
|
4197
|
-
:see: https://bingx-api.github.io/docs/#/swapV2/trade-api.html#
|
4367
|
+
:see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Change%20Margin%20Type
|
4368
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Set%20Margin%20Type
|
4198
4369
|
:param str marginMode: 'cross' or 'isolated'
|
4199
4370
|
:param str symbol: unified market symbol
|
4200
4371
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -4215,7 +4386,12 @@ class bingx(Exchange, ImplicitAPI):
|
|
4215
4386
|
'symbol': market['id'],
|
4216
4387
|
'marginType': marginMode,
|
4217
4388
|
}
|
4218
|
-
|
4389
|
+
subType = None
|
4390
|
+
subType, params = self.handle_sub_type_and_params('setMarginMode', market, params)
|
4391
|
+
if subType == 'inverse':
|
4392
|
+
return self.cswapV1PrivatePostTradeMarginType(self.extend(request, params))
|
4393
|
+
else:
|
4394
|
+
return self.swapV2PrivatePostTradeMarginType(self.extend(request, params))
|
4219
4395
|
|
4220
4396
|
def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
4221
4397
|
request: dict = {
|
@@ -4440,93 +4616,129 @@ class bingx(Exchange, ImplicitAPI):
|
|
4440
4616
|
def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
4441
4617
|
"""
|
4442
4618
|
fetch all trades made by the user
|
4443
|
-
:see: https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%
|
4444
|
-
:see: https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Query%20historical%20transaction%20orders
|
4619
|
+
:see: https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20transaction%20details
|
4620
|
+
:see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20historical%20transaction%20orders
|
4621
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Order%20Trade%20Detail
|
4445
4622
|
:param str [symbol]: unified market symbol
|
4446
4623
|
:param int [since]: the earliest time in ms to fetch trades for
|
4447
4624
|
:param int [limit]: the maximum number of trades structures to retrieve
|
4448
4625
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4449
4626
|
:param int [params.until]: timestamp in ms for the ending date filter, default is None
|
4450
4627
|
:param str params['trandingUnit']: COIN(directly represent assets such and ETH) or CONT(represents the number of contract sheets)
|
4628
|
+
:param str params['orderId']: the order id required for inverse swap
|
4451
4629
|
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
4452
4630
|
"""
|
4453
4631
|
if symbol is None:
|
4454
4632
|
raise ArgumentsRequired(self.id + ' fetchMyTrades() requires a symbol argument')
|
4455
4633
|
self.load_markets()
|
4456
4634
|
market = self.market(symbol)
|
4457
|
-
|
4458
|
-
response = None
|
4459
|
-
request: dict = {
|
4460
|
-
'symbol': market['id'],
|
4461
|
-
}
|
4462
|
-
if since is not None:
|
4463
|
-
startTimeReq = 'startTime' if market['spot'] else 'startTs'
|
4464
|
-
request[startTimeReq] = since
|
4465
|
-
elif market['swap']:
|
4466
|
-
request['startTs'] = now - 7776000000 # 90 days
|
4467
|
-
until = self.safe_integer(params, 'until')
|
4468
|
-
params = self.omit(params, 'until')
|
4469
|
-
if until is not None:
|
4470
|
-
endTimeReq = 'endTime' if market['spot'] else 'endTs'
|
4471
|
-
request[endTimeReq] = until
|
4472
|
-
elif market['swap']:
|
4473
|
-
request['endTs'] = now
|
4635
|
+
request: dict = {}
|
4474
4636
|
fills = None
|
4475
|
-
|
4476
|
-
|
4477
|
-
|
4478
|
-
|
4637
|
+
response = None
|
4638
|
+
subType = None
|
4639
|
+
subType, params = self.handle_sub_type_and_params('fetchMyTrades', market, params)
|
4640
|
+
if subType == 'inverse':
|
4641
|
+
orderId = self.safe_string(params, 'orderId')
|
4642
|
+
if orderId is None:
|
4643
|
+
raise ArgumentsRequired(self.id + ' fetchMyTrades() requires an orderId argument for inverse swap trades')
|
4644
|
+
response = self.cswapV1PrivateGetTradeAllFillOrders(self.extend(request, params))
|
4645
|
+
fills = self.safe_list(response, 'data', [])
|
4479
4646
|
#
|
4480
4647
|
# {
|
4481
4648
|
# "code": 0,
|
4482
4649
|
# "msg": "",
|
4483
|
-
# "
|
4484
|
-
# "data":
|
4485
|
-
#
|
4486
|
-
#
|
4487
|
-
#
|
4488
|
-
#
|
4489
|
-
#
|
4490
|
-
#
|
4491
|
-
#
|
4492
|
-
#
|
4493
|
-
#
|
4494
|
-
#
|
4495
|
-
#
|
4496
|
-
#
|
4497
|
-
#
|
4498
|
-
#
|
4499
|
-
#
|
4500
|
-
#
|
4650
|
+
# "timestamp": 1722147756019,
|
4651
|
+
# "data": [
|
4652
|
+
# {
|
4653
|
+
# "orderId": "1817441228670648320",
|
4654
|
+
# "symbol": "SOL-USD",
|
4655
|
+
# "type": "MARKET",
|
4656
|
+
# "side": "BUY",
|
4657
|
+
# "positionSide": "LONG",
|
4658
|
+
# "tradeId": "97244554",
|
4659
|
+
# "volume": "2",
|
4660
|
+
# "tradePrice": "182.652",
|
4661
|
+
# "amount": "20.00000000",
|
4662
|
+
# "realizedPnl": "0.00000000",
|
4663
|
+
# "commission": "-0.00005475",
|
4664
|
+
# "currency": "SOL",
|
4665
|
+
# "buyer": True,
|
4666
|
+
# "maker": False,
|
4667
|
+
# "tradeTime": 1722146730000
|
4668
|
+
# }
|
4669
|
+
# ]
|
4501
4670
|
# }
|
4502
4671
|
#
|
4503
4672
|
else:
|
4504
|
-
|
4505
|
-
|
4506
|
-
|
4507
|
-
|
4508
|
-
|
4509
|
-
|
4510
|
-
|
4511
|
-
|
4512
|
-
|
4513
|
-
|
4514
|
-
|
4515
|
-
|
4516
|
-
|
4517
|
-
|
4518
|
-
|
4519
|
-
|
4520
|
-
|
4521
|
-
|
4522
|
-
|
4523
|
-
|
4524
|
-
|
4525
|
-
|
4526
|
-
|
4527
|
-
|
4528
|
-
|
4529
|
-
|
4673
|
+
request['symbol'] = market['id']
|
4674
|
+
now = self.milliseconds()
|
4675
|
+
if since is not None:
|
4676
|
+
startTimeReq = 'startTime' if market['spot'] else 'startTs'
|
4677
|
+
request[startTimeReq] = since
|
4678
|
+
elif market['swap']:
|
4679
|
+
request['startTs'] = now - 7776000000 # 90 days
|
4680
|
+
until = self.safe_integer(params, 'until')
|
4681
|
+
params = self.omit(params, 'until')
|
4682
|
+
if until is not None:
|
4683
|
+
endTimeReq = 'endTime' if market['spot'] else 'endTs'
|
4684
|
+
request[endTimeReq] = until
|
4685
|
+
elif market['swap']:
|
4686
|
+
request['endTs'] = now
|
4687
|
+
if market['spot']:
|
4688
|
+
response = self.spotV1PrivateGetTradeMyTrades(self.extend(request, params))
|
4689
|
+
data = self.safe_dict(response, 'data', {})
|
4690
|
+
fills = self.safe_list(data, 'fills', [])
|
4691
|
+
#
|
4692
|
+
# {
|
4693
|
+
# "code": 0,
|
4694
|
+
# "msg": "",
|
4695
|
+
# "debugMsg": "",
|
4696
|
+
# "data": {
|
4697
|
+
# "fills": [
|
4698
|
+
# {
|
4699
|
+
# "symbol": "LTC-USDT",
|
4700
|
+
# "id": 36237072,
|
4701
|
+
# "orderId": 1674069326895775744,
|
4702
|
+
# "price": "85.891",
|
4703
|
+
# "qty": "0.0582",
|
4704
|
+
# "quoteQty": "4.9988562000000005",
|
4705
|
+
# "commission": -0.00005820000000000001,
|
4706
|
+
# "commissionAsset": "LTC",
|
4707
|
+
# "time": 1687964205000,
|
4708
|
+
# "isBuyer": True,
|
4709
|
+
# "isMaker": False
|
4710
|
+
# }
|
4711
|
+
# ]
|
4712
|
+
# }
|
4713
|
+
# }
|
4714
|
+
#
|
4715
|
+
else:
|
4716
|
+
tradingUnit = self.safe_string_upper(params, 'tradingUnit', 'CONT')
|
4717
|
+
params = self.omit(params, 'tradingUnit')
|
4718
|
+
request['tradingUnit'] = tradingUnit
|
4719
|
+
response = self.swapV2PrivateGetTradeAllFillOrders(self.extend(request, params))
|
4720
|
+
data = self.safe_dict(response, 'data', {})
|
4721
|
+
fills = self.safe_list(data, 'fill_orders', [])
|
4722
|
+
#
|
4723
|
+
# {
|
4724
|
+
# "code": "0",
|
4725
|
+
# "msg": '',
|
4726
|
+
# "data": {fill_orders: [
|
4727
|
+
# {
|
4728
|
+
# "volume": "0.1",
|
4729
|
+
# "price": "106.75",
|
4730
|
+
# "amount": "10.6750",
|
4731
|
+
# "commission": "-0.0053",
|
4732
|
+
# "currency": "USDT",
|
4733
|
+
# "orderId": "1676213270274379776",
|
4734
|
+
# "liquidatedPrice": "0.00",
|
4735
|
+
# "liquidatedMarginRatio": "0.00",
|
4736
|
+
# "filledTime": "2023-07-04T20:56:01.000+0800"
|
4737
|
+
# }
|
4738
|
+
# ]
|
4739
|
+
# }
|
4740
|
+
# }
|
4741
|
+
#
|
4530
4742
|
return self.parse_trades(fills, market, since, limit, params)
|
4531
4743
|
|
4532
4744
|
def parse_deposit_withdraw_fee(self, fee, currency: Currency = None):
|
@@ -5107,7 +5319,8 @@ class bingx(Exchange, ImplicitAPI):
|
|
5107
5319
|
def fetch_margin_mode(self, symbol: str, params={}) -> MarginMode:
|
5108
5320
|
"""
|
5109
5321
|
fetches the margin mode of the trading pair
|
5110
|
-
:see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Margin%
|
5322
|
+
:see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Margin%20Type
|
5323
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Margin%20Type
|
5111
5324
|
:param str symbol: unified symbol of the market to fetch the margin mode for
|
5112
5325
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5113
5326
|
:returns dict: a `margin mode structure <https://docs.ccxt.com/#/?id=margin-mode-structure>`
|
@@ -5117,25 +5330,43 @@ class bingx(Exchange, ImplicitAPI):
|
|
5117
5330
|
request: dict = {
|
5118
5331
|
'symbol': market['id'],
|
5119
5332
|
}
|
5120
|
-
|
5121
|
-
|
5122
|
-
|
5123
|
-
|
5124
|
-
|
5125
|
-
|
5126
|
-
|
5127
|
-
|
5128
|
-
|
5129
|
-
|
5333
|
+
subType = None
|
5334
|
+
response = None
|
5335
|
+
subType, params = self.handle_sub_type_and_params('fetchMarginMode', market, params)
|
5336
|
+
if subType == 'inverse':
|
5337
|
+
response = self.cswapV1PrivateGetTradeMarginType(self.extend(request, params))
|
5338
|
+
#
|
5339
|
+
# {
|
5340
|
+
# "code": 0,
|
5341
|
+
# "msg": "",
|
5342
|
+
# "timestamp": 1721966069132,
|
5343
|
+
# "data": {
|
5344
|
+
# "symbol": "SOL-USD",
|
5345
|
+
# "marginType": "CROSSED"
|
5346
|
+
# }
|
5347
|
+
# }
|
5348
|
+
#
|
5349
|
+
else:
|
5350
|
+
response = self.swapV2PrivateGetTradeMarginType(self.extend(request, params))
|
5351
|
+
#
|
5352
|
+
# {
|
5353
|
+
# "code": 0,
|
5354
|
+
# "msg": "",
|
5355
|
+
# "data": {
|
5356
|
+
# "marginType": "CROSSED"
|
5357
|
+
# }
|
5358
|
+
# }
|
5359
|
+
#
|
5130
5360
|
data = self.safe_dict(response, 'data', {})
|
5131
5361
|
return self.parse_margin_mode(data, market)
|
5132
5362
|
|
5133
5363
|
def parse_margin_mode(self, marginMode: dict, market=None) -> MarginMode:
|
5364
|
+
marketId = self.safe_string(marginMode, 'symbol')
|
5134
5365
|
marginType = self.safe_string_lower(marginMode, 'marginType')
|
5135
5366
|
marginType = 'cross' if (marginType == 'crossed') else marginType
|
5136
5367
|
return {
|
5137
5368
|
'info': marginMode,
|
5138
|
-
'symbol': market
|
5369
|
+
'symbol': self.safe_symbol(marketId, market, '-', 'swap'),
|
5139
5370
|
'marginMode': marginType,
|
5140
5371
|
}
|
5141
5372
|
|