ccxt 4.3.73__py2.py3-none-any.whl → 4.3.75__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 +1 -1
- ccxt/abstract/binance.py +5 -0
- ccxt/abstract/binancecoinm.py +5 -0
- ccxt/abstract/binanceus.py +5 -0
- ccxt/abstract/binanceusdm.py +5 -0
- ccxt/abstract/bybit.py +1 -0
- ccxt/ace.py +1 -1
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/ace.py +1 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/binance.py +222 -84
- ccxt/async_support/bybit.py +32 -7
- ccxt/async_support/mexc.py +1 -1
- ccxt/async_support/whitebit.py +17 -2
- ccxt/async_support/woo.py +1 -1
- ccxt/async_support/yobit.py +49 -26
- ccxt/base/exchange.py +1 -1
- ccxt/binance.py +222 -84
- ccxt/bybit.py +32 -7
- ccxt/mexc.py +1 -1
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/alpaca.py +5 -0
- ccxt/pro/binance.py +15 -2
- ccxt/pro/bitfinex.py +5 -0
- ccxt/test/tests_async.py +3 -2
- ccxt/test/tests_helpers.py +3 -0
- ccxt/test/tests_sync.py +3 -2
- ccxt/whitebit.py +17 -2
- ccxt/woo.py +1 -1
- ccxt/yobit.py +48 -26
- {ccxt-4.3.73.dist-info → ccxt-4.3.75.dist-info}/METADATA +6 -6
- {ccxt-4.3.73.dist-info → ccxt-4.3.75.dist-info}/RECORD +35 -35
- {ccxt-4.3.73.dist-info → ccxt-4.3.75.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.3.73.dist-info → ccxt-4.3.75.dist-info}/WHEEL +0 -0
- {ccxt-4.3.73.dist-info → ccxt-4.3.75.dist-info}/top_level.txt +0 -0
ccxt/binance.py
CHANGED
@@ -212,8 +212,10 @@ class binance(Exchange, ImplicitAPI):
|
|
212
212
|
'dapiPrivateV2': 'https://testnet.binancefuture.com/dapi/v2',
|
213
213
|
'fapiPublic': 'https://testnet.binancefuture.com/fapi/v1',
|
214
214
|
'fapiPublicV2': 'https://testnet.binancefuture.com/fapi/v2',
|
215
|
+
'fapiPublicV3': 'https://testnet.binancefuture.com/fapi/v3',
|
215
216
|
'fapiPrivate': 'https://testnet.binancefuture.com/fapi/v1',
|
216
217
|
'fapiPrivateV2': 'https://testnet.binancefuture.com/fapi/v2',
|
218
|
+
'fapiPrivateV3': 'https://testnet.binancefuture.com/fapi/v3',
|
217
219
|
'public': 'https://testnet.binance.vision/api/v3',
|
218
220
|
'private': 'https://testnet.binance.vision/api/v3',
|
219
221
|
'v1': 'https://testnet.binance.vision/api/v1',
|
@@ -231,9 +233,11 @@ class binance(Exchange, ImplicitAPI):
|
|
231
233
|
'dapiData': 'https://dapi.binance.com/futures/data',
|
232
234
|
'fapiPublic': 'https://fapi.binance.com/fapi/v1',
|
233
235
|
'fapiPublicV2': 'https://fapi.binance.com/fapi/v2',
|
236
|
+
'fapiPublicV3': 'https://fapi.binance.com/fapi/v3',
|
234
237
|
'fapiPrivate': 'https://fapi.binance.com/fapi/v1',
|
235
|
-
'fapiData': 'https://fapi.binance.com/futures/data',
|
236
238
|
'fapiPrivateV2': 'https://fapi.binance.com/fapi/v2',
|
239
|
+
'fapiPrivateV3': 'https://fapi.binance.com/fapi/v3',
|
240
|
+
'fapiData': 'https://fapi.binance.com/futures/data',
|
237
241
|
'public': 'https://api.binance.com/api/v3',
|
238
242
|
'private': 'https://api.binance.com/api/v3',
|
239
243
|
'v1': 'https://api.binance.com/api/v1',
|
@@ -869,6 +873,8 @@ class binance(Exchange, ImplicitAPI):
|
|
869
873
|
'trade/asyn': 1000,
|
870
874
|
'trade/asyn/id': 10,
|
871
875
|
'feeBurn': 1,
|
876
|
+
'symbolConfig': 5,
|
877
|
+
'accountConfig': 5,
|
872
878
|
},
|
873
879
|
'post': {
|
874
880
|
'batchOrders': 5,
|
@@ -909,6 +915,16 @@ class binance(Exchange, ImplicitAPI):
|
|
909
915
|
'positionRisk': 1,
|
910
916
|
},
|
911
917
|
},
|
918
|
+
'fapiPublicV3': {
|
919
|
+
'get': {},
|
920
|
+
},
|
921
|
+
'fapiPrivateV3': {
|
922
|
+
'get': {
|
923
|
+
'account': 1,
|
924
|
+
'balance': 1,
|
925
|
+
'positionRisk': 1,
|
926
|
+
},
|
927
|
+
},
|
912
928
|
'eapiPublic': {
|
913
929
|
'get': {
|
914
930
|
'ping': 1,
|
@@ -3347,7 +3363,7 @@ class binance(Exchange, ImplicitAPI):
|
|
3347
3363
|
response = self.papiGetBalance(self.extend(request, query))
|
3348
3364
|
elif self.is_linear(type, subType):
|
3349
3365
|
type = 'linear'
|
3350
|
-
response = self.
|
3366
|
+
response = self.fapiPrivateV3GetAccount(self.extend(request, query))
|
3351
3367
|
elif self.is_inverse(type, subType):
|
3352
3368
|
type = 'inverse'
|
3353
3369
|
response = self.dapiPrivateGetAccount(self.extend(request, query))
|
@@ -8765,24 +8781,29 @@ class binance(Exchange, ImplicitAPI):
|
|
8765
8781
|
#
|
8766
8782
|
# usdm
|
8767
8783
|
#
|
8784
|
+
# v3(similar for cross & isolated)
|
8785
|
+
#
|
8768
8786
|
# {
|
8769
|
-
#
|
8770
|
-
#
|
8771
|
-
#
|
8772
|
-
#
|
8773
|
-
#
|
8774
|
-
#
|
8775
|
-
#
|
8776
|
-
#
|
8777
|
-
#
|
8778
|
-
#
|
8779
|
-
#
|
8780
|
-
#
|
8781
|
-
#
|
8782
|
-
#
|
8783
|
-
#
|
8784
|
-
#
|
8785
|
-
#
|
8787
|
+
# "symbol": "WLDUSDT",
|
8788
|
+
# "positionSide": "BOTH",
|
8789
|
+
# "positionAmt": "-849",
|
8790
|
+
# "unrealizedProfit": "11.17920750",
|
8791
|
+
# "notional": "-1992.46079250",
|
8792
|
+
# "isolatedMargin": "0",
|
8793
|
+
# "isolatedWallet": "0",
|
8794
|
+
# "initialMargin": "99.62303962",
|
8795
|
+
# "maintMargin": "11.95476475",
|
8796
|
+
# "updateTime": "1721995760449"
|
8797
|
+
# "leverage": "50", # in v2
|
8798
|
+
# "entryPrice": "2.34", # in v2
|
8799
|
+
# "positionInitialMargin": "118.82116614", # in v2
|
8800
|
+
# "openOrderInitialMargin": "0", # in v2
|
8801
|
+
# "isolated": False, # in v2
|
8802
|
+
# "breakEvenPrice": "2.3395788", # in v2
|
8803
|
+
# "maxNotional": "25000", # in v2
|
8804
|
+
# "bidNotional": "0", # in v2
|
8805
|
+
# "askNotional": "0" # in v2
|
8806
|
+
# }
|
8786
8807
|
#
|
8787
8808
|
# coinm
|
8788
8809
|
#
|
@@ -8848,13 +8869,15 @@ class binance(Exchange, ImplicitAPI):
|
|
8848
8869
|
market = self.safe_market(marketId, market, None, 'contract')
|
8849
8870
|
symbol = self.safe_string(market, 'symbol')
|
8850
8871
|
leverageString = self.safe_string(position, 'leverage')
|
8851
|
-
leverage = int(leverageString)
|
8872
|
+
leverage = int(leverageString) if (leverageString is not None) else None
|
8852
8873
|
initialMarginString = self.safe_string(position, 'initialMargin')
|
8853
8874
|
initialMargin = self.parse_number(initialMarginString)
|
8854
|
-
initialMarginPercentageString =
|
8855
|
-
|
8856
|
-
|
8857
|
-
|
8875
|
+
initialMarginPercentageString = None
|
8876
|
+
if leverageString is not None:
|
8877
|
+
initialMarginPercentageString = Precise.string_div('1', leverageString, 8)
|
8878
|
+
rational = self.is_round_number(1000 % leverage)
|
8879
|
+
if not rational:
|
8880
|
+
initialMarginPercentageString = Precise.string_div(Precise.string_add(initialMarginPercentageString, '1e-8'), '1', 8)
|
8858
8881
|
# to notionalValue
|
8859
8882
|
usdm = ('notional' in position)
|
8860
8883
|
maintenanceMarginString = self.safe_string(position, 'maintMargin')
|
@@ -8887,6 +8910,9 @@ class binance(Exchange, ImplicitAPI):
|
|
8887
8910
|
if timestamp == 0:
|
8888
8911
|
timestamp = None
|
8889
8912
|
isolated = self.safe_bool(position, 'isolated')
|
8913
|
+
if isolated is None:
|
8914
|
+
isolatedMarginRaw = self.safe_string(position, 'isolatedMargin')
|
8915
|
+
isolated = not Precise.string_eq(isolatedMarginRaw, '0')
|
8890
8916
|
marginMode = None
|
8891
8917
|
collateralString = None
|
8892
8918
|
walletBalance = None
|
@@ -8991,23 +9017,34 @@ class binance(Exchange, ImplicitAPI):
|
|
8991
9017
|
#
|
8992
9018
|
# usdm
|
8993
9019
|
#
|
8994
|
-
#
|
8995
|
-
#
|
8996
|
-
#
|
8997
|
-
#
|
8998
|
-
#
|
8999
|
-
#
|
9000
|
-
#
|
9001
|
-
#
|
9002
|
-
#
|
9003
|
-
#
|
9004
|
-
#
|
9005
|
-
#
|
9006
|
-
#
|
9007
|
-
#
|
9008
|
-
#
|
9009
|
-
#
|
9010
|
-
#
|
9020
|
+
# {
|
9021
|
+
# symbol: "WLDUSDT",
|
9022
|
+
# positionSide: "BOTH",
|
9023
|
+
# positionAmt: "5",
|
9024
|
+
# entryPrice: "2.3483",
|
9025
|
+
# breakEvenPrice: "2.349356735",
|
9026
|
+
# markPrice: "2.39560000",
|
9027
|
+
# unRealizedProfit: "0.23650000",
|
9028
|
+
# liquidationPrice: "0",
|
9029
|
+
# isolatedMargin: "0",
|
9030
|
+
# notional: "11.97800000",
|
9031
|
+
# isolatedWallet: "0",
|
9032
|
+
# updateTime: "1722062678998",
|
9033
|
+
# initialMargin: "2.39560000", # not in v2
|
9034
|
+
# maintMargin: "0.07186800", # not in v2
|
9035
|
+
# positionInitialMargin: "2.39560000", # not in v2
|
9036
|
+
# openOrderInitialMargin: "0", # not in v2
|
9037
|
+
# adl: "2", # not in v2
|
9038
|
+
# bidNotional: "0", # not in v2
|
9039
|
+
# askNotional: "0", # not in v2
|
9040
|
+
# marginAsset: "USDT", # not in v2
|
9041
|
+
# # the below fields are only in v2
|
9042
|
+
# leverage: "5",
|
9043
|
+
# maxNotionalValue: "6000000",
|
9044
|
+
# marginType: "cross",
|
9045
|
+
# isAutoAddMargin: "false",
|
9046
|
+
# isolated: False,
|
9047
|
+
# adlQuantile: "2",
|
9011
9048
|
#
|
9012
9049
|
# coinm
|
9013
9050
|
#
|
@@ -9065,6 +9102,7 @@ class binance(Exchange, ImplicitAPI):
|
|
9065
9102
|
marketId = self.safe_string(position, 'symbol')
|
9066
9103
|
market = self.safe_market(marketId, market, None, 'contract')
|
9067
9104
|
symbol = self.safe_string(market, 'symbol')
|
9105
|
+
isolatedMarginString = self.safe_string(position, 'isolatedMargin')
|
9068
9106
|
leverageBrackets = self.safe_dict(self.options, 'leverageBrackets', {})
|
9069
9107
|
leverageBracket = self.safe_list(leverageBrackets, symbol, [])
|
9070
9108
|
notionalString = self.safe_string_2(position, 'notional', 'notionalValue')
|
@@ -9080,12 +9118,12 @@ class binance(Exchange, ImplicitAPI):
|
|
9080
9118
|
contracts = self.parse_number(contractsAbs)
|
9081
9119
|
unrealizedPnlString = self.safe_string(position, 'unRealizedProfit')
|
9082
9120
|
unrealizedPnl = self.parse_number(unrealizedPnlString)
|
9083
|
-
leverageString = self.safe_string(position, 'leverage')
|
9084
|
-
leverage = int(leverageString)
|
9085
9121
|
liquidationPriceString = self.omit_zero(self.safe_string(position, 'liquidationPrice'))
|
9086
9122
|
liquidationPrice = self.parse_number(liquidationPriceString)
|
9087
9123
|
collateralString = None
|
9088
9124
|
marginMode = self.safe_string(position, 'marginType')
|
9125
|
+
if marginMode is None and isolatedMarginString is not None:
|
9126
|
+
marginMode = 'cross' if Precise.string_eq(isolatedMarginString, '0') else 'isolated'
|
9089
9127
|
side = None
|
9090
9128
|
if Precise.string_gt(notionalString, '0'):
|
9091
9129
|
side = 'long'
|
@@ -9142,13 +9180,25 @@ class binance(Exchange, ImplicitAPI):
|
|
9142
9180
|
timestamp = None
|
9143
9181
|
maintenanceMarginPercentage = self.parse_number(maintenanceMarginPercentageString)
|
9144
9182
|
maintenanceMarginString = Precise.string_mul(maintenanceMarginPercentageString, notionalStringAbs)
|
9183
|
+
if maintenanceMarginString is None:
|
9184
|
+
# for a while, self new value was a backup to the existing calculations, but in future we might prioritize self
|
9185
|
+
maintenanceMarginString = self.safe_string(position, 'maintMargin')
|
9145
9186
|
maintenanceMargin = self.parse_number(maintenanceMarginString)
|
9146
|
-
|
9147
|
-
|
9148
|
-
|
9149
|
-
|
9150
|
-
|
9151
|
-
|
9187
|
+
initialMarginString = None
|
9188
|
+
initialMarginPercentageString = None
|
9189
|
+
leverageString = self.safe_string(position, 'leverage')
|
9190
|
+
if leverageString is not None:
|
9191
|
+
leverage = int(leverageString)
|
9192
|
+
rational = self.is_round_number(1000 % leverage)
|
9193
|
+
initialMarginPercentageString = Precise.string_div('1', leverageString, 8)
|
9194
|
+
if not rational:
|
9195
|
+
initialMarginPercentageString = Precise.string_add(initialMarginPercentageString, '1e-8')
|
9196
|
+
unrounded = Precise.string_mul(notionalStringAbs, initialMarginPercentageString)
|
9197
|
+
initialMarginString = Precise.string_div(unrounded, '1', 8)
|
9198
|
+
else:
|
9199
|
+
initialMarginString = self.safe_string(position, 'initialMargin')
|
9200
|
+
unrounded = Precise.string_mul(initialMarginString, '1')
|
9201
|
+
initialMarginPercentageString = Precise.string_div(unrounded, notionalStringAbs, 8)
|
9152
9202
|
marginRatio = None
|
9153
9203
|
percentage = None
|
9154
9204
|
if not Precise.string_equals(collateralString, '0'):
|
@@ -9170,7 +9220,7 @@ class binance(Exchange, ImplicitAPI):
|
|
9170
9220
|
'markPrice': markPrice,
|
9171
9221
|
'entryPrice': entryPrice,
|
9172
9222
|
'timestamp': timestamp,
|
9173
|
-
'initialMargin':
|
9223
|
+
'initialMargin': self.parse_number(initialMarginString),
|
9174
9224
|
'initialMarginPercentage': self.parse_number(initialMarginPercentageString),
|
9175
9225
|
'maintenanceMargin': maintenanceMargin,
|
9176
9226
|
'maintenanceMarginPercentage': maintenanceMarginPercentage,
|
@@ -9500,9 +9550,14 @@ class binance(Exchange, ImplicitAPI):
|
|
9500
9550
|
:param str [method]: method name to call, "positionRisk", "account" or "option", default is "positionRisk"
|
9501
9551
|
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
9502
9552
|
"""
|
9503
|
-
defaultValue = self.safe_string(self.options, 'fetchPositions', 'positionRisk')
|
9504
9553
|
defaultMethod = None
|
9505
|
-
defaultMethod, params = self.handle_option_and_params(params, 'fetchPositions', 'method'
|
9554
|
+
defaultMethod, params = self.handle_option_and_params(params, 'fetchPositions', 'method')
|
9555
|
+
if defaultMethod is None:
|
9556
|
+
options = self.safe_dict(self.options, 'fetchPositions')
|
9557
|
+
if options is None:
|
9558
|
+
defaultMethod = self.safe_string(self.options, 'fetchPositions', 'positionRisk')
|
9559
|
+
else:
|
9560
|
+
defaultMethod = 'positionRisk'
|
9506
9561
|
if defaultMethod == 'positionRisk':
|
9507
9562
|
return self.fetch_positions_risk(symbols, params)
|
9508
9563
|
elif defaultMethod == 'account':
|
@@ -9510,7 +9565,7 @@ class binance(Exchange, ImplicitAPI):
|
|
9510
9565
|
elif defaultMethod == 'option':
|
9511
9566
|
return self.fetch_option_positions(symbols, params)
|
9512
9567
|
else:
|
9513
|
-
raise NotSupported(self.id + '.options["fetchPositions"]
|
9568
|
+
raise NotSupported(self.id + '.options["fetchPositions"]["method"] or params["method"] = "' + defaultMethod + '" is invalid, please choose between "account", "positionRisk" and "option"')
|
9514
9569
|
|
9515
9570
|
def fetch_account_positions(self, symbols: Strings = None, params={}):
|
9516
9571
|
"""
|
@@ -9525,6 +9580,7 @@ class binance(Exchange, ImplicitAPI):
|
|
9525
9580
|
:param boolean [params.portfolioMargin]: set to True if you would like to fetch positions in a portfolio margin account
|
9526
9581
|
:param str [params.subType]: "linear" or "inverse"
|
9527
9582
|
:param boolean [params.filterClosed]: set to True if you would like to filter out closed positions, default is False
|
9583
|
+
:param boolean [params.useV2]: set to True if you want to use obsolete endpoint, where some more additional fields were provided
|
9528
9584
|
:returns dict: data on account positions
|
9529
9585
|
"""
|
9530
9586
|
if symbols is not None:
|
@@ -9544,7 +9600,78 @@ class binance(Exchange, ImplicitAPI):
|
|
9544
9600
|
if isPortfolioMargin:
|
9545
9601
|
response = self.papiGetUmAccount(params)
|
9546
9602
|
else:
|
9547
|
-
|
9603
|
+
useV2 = None
|
9604
|
+
useV2, params = self.handle_option_and_params(params, 'fetchAccountPositions', 'useV2', False)
|
9605
|
+
if not useV2:
|
9606
|
+
response = self.fapiPrivateV3GetAccount(params)
|
9607
|
+
else:
|
9608
|
+
response = self.fapiPrivateV2GetAccount(params)
|
9609
|
+
#
|
9610
|
+
# {
|
9611
|
+
# "totalInitialMargin": "99.62112386",
|
9612
|
+
# "totalMaintMargin": "11.95453485",
|
9613
|
+
# "totalWalletBalance": "99.84331553",
|
9614
|
+
# "totalUnrealizedProfit": "11.17675690",
|
9615
|
+
# "totalMarginBalance": "111.02007243",
|
9616
|
+
# "totalPositionInitialMargin": "99.62112386",
|
9617
|
+
# "totalOpenOrderInitialMargin": "0.00000000",
|
9618
|
+
# "totalCrossWalletBalance": "99.84331553",
|
9619
|
+
# "totalCrossUnPnl": "11.17675690",
|
9620
|
+
# "availableBalance": "11.39894857",
|
9621
|
+
# "maxWithdrawAmount": "11.39894857",
|
9622
|
+
# "feeTier": "0", # in v2
|
9623
|
+
# "canTrade": True, # in v2
|
9624
|
+
# "canDeposit": True, # in v2
|
9625
|
+
# "canWithdraw": True, # in v2
|
9626
|
+
# "feeBurn": True, # in v2
|
9627
|
+
# "tradeGroupId": "-1",// in v2
|
9628
|
+
# "updateTime": "0", # in v2
|
9629
|
+
# "multiAssetsMargin": True # in v2
|
9630
|
+
# "assets": [
|
9631
|
+
# {
|
9632
|
+
# "asset": "USDT",
|
9633
|
+
# "walletBalance": "72.72317863",
|
9634
|
+
# "unrealizedProfit": "11.17920750",
|
9635
|
+
# "marginBalance": "83.90238613",
|
9636
|
+
# "maintMargin": "11.95476475",
|
9637
|
+
# "initialMargin": "99.62303962",
|
9638
|
+
# "positionInitialMargin": "99.62303962",
|
9639
|
+
# "openOrderInitialMargin": "0.00000000",
|
9640
|
+
# "crossWalletBalance": "72.72317863",
|
9641
|
+
# "crossUnPnl": "11.17920750",
|
9642
|
+
# "availableBalance": "11.39916777",
|
9643
|
+
# "maxWithdrawAmount": "11.39916777",
|
9644
|
+
# "updateTime": "1721995605338",
|
9645
|
+
# "marginAvailable": True # in v2
|
9646
|
+
# },
|
9647
|
+
# ... and some few supported settle currencies: USDC, BTC, ETH, BNB ..
|
9648
|
+
# ],
|
9649
|
+
# "positions": [
|
9650
|
+
# {
|
9651
|
+
# "symbol": "WLDUSDT",
|
9652
|
+
# "positionSide": "BOTH",
|
9653
|
+
# "positionAmt": "-849",
|
9654
|
+
# "unrealizedProfit": "11.17920750",
|
9655
|
+
# "isolatedMargin": "0",
|
9656
|
+
# "isolatedWallet": "0",
|
9657
|
+
# "notional": "-1992.46079250",
|
9658
|
+
# "initialMargin": "99.62303962",
|
9659
|
+
# "maintMargin": "11.95476475",
|
9660
|
+
# "updateTime": "1721995760449"
|
9661
|
+
# "leverage": "50", # in v2
|
9662
|
+
# "entryPrice": "2.34", # in v2
|
9663
|
+
# "positionInitialMargin": "118.82116614", # in v2
|
9664
|
+
# "openOrderInitialMargin": "0", # in v2
|
9665
|
+
# "isolated": False, # in v2
|
9666
|
+
# "breakEvenPrice": "2.3395788", # in v2
|
9667
|
+
# "maxNotional": "25000", # in v2
|
9668
|
+
# "bidNotional": "0", # in v2
|
9669
|
+
# "askNotional": "0" # in v2
|
9670
|
+
# },
|
9671
|
+
# ...
|
9672
|
+
# ]
|
9673
|
+
# }
|
9674
|
+
#
|
9548
9675
|
elif self.is_inverse(type, subType):
|
9549
9676
|
if isPortfolioMargin:
|
9550
9677
|
response = self.papiGetCmAccount(params)
|
@@ -9591,7 +9718,33 @@ class binance(Exchange, ImplicitAPI):
|
|
9591
9718
|
if isPortfolioMargin:
|
9592
9719
|
response = self.papiGetUmPositionRisk(self.extend(request, params))
|
9593
9720
|
else:
|
9594
|
-
response = self.
|
9721
|
+
response = self.fapiPrivateV3GetPositionRisk(self.extend(request, params))
|
9722
|
+
#
|
9723
|
+
# [
|
9724
|
+
# {
|
9725
|
+
# symbol: "WLDUSDT",
|
9726
|
+
# positionSide: "BOTH",
|
9727
|
+
# positionAmt: "5",
|
9728
|
+
# entryPrice: "2.3483",
|
9729
|
+
# breakEvenPrice: "2.349356735",
|
9730
|
+
# markPrice: "2.39560000",
|
9731
|
+
# unRealizedProfit: "0.23650000",
|
9732
|
+
# liquidationPrice: "0",
|
9733
|
+
# isolatedMargin: "0",
|
9734
|
+
# notional: "11.97800000",
|
9735
|
+
# isolatedWallet: "0",
|
9736
|
+
# updateTime: "1722062678998",
|
9737
|
+
# initialMargin: "2.39560000", # added in v3
|
9738
|
+
# maintMargin: "0.07186800", # added in v3
|
9739
|
+
# positionInitialMargin: "2.39560000", # added in v3
|
9740
|
+
# openOrderInitialMargin: "0", # added in v3
|
9741
|
+
# adl: "2", # added in v3
|
9742
|
+
# bidNotional: "0", # added in v3
|
9743
|
+
# askNotional: "0", # added in v3
|
9744
|
+
# marginAsset: "USDT", # added in v3
|
9745
|
+
# },
|
9746
|
+
# ]
|
9747
|
+
#
|
9595
9748
|
elif self.is_inverse(type, subType):
|
9596
9749
|
if isPortfolioMargin:
|
9597
9750
|
response = self.papiGetCmPositionRisk(self.extend(request, params))
|
@@ -9605,18 +9758,18 @@ class binance(Exchange, ImplicitAPI):
|
|
9605
9758
|
#
|
9606
9759
|
# [
|
9607
9760
|
# {
|
9761
|
+
# "symbol": "BTCUSDT",
|
9762
|
+
# "positionSide": "BOTH",
|
9763
|
+
# "positionAmt": "0.000",
|
9608
9764
|
# "entryPrice": "0.00000",
|
9765
|
+
# "markPrice": "6679.50671178",
|
9766
|
+
# "unRealizedProfit": "0.00000000",
|
9767
|
+
# "liquidationPrice": "0",
|
9768
|
+
# "isolatedMargin": "0.00000000",
|
9609
9769
|
# "marginType": "isolated",
|
9610
9770
|
# "isAutoAddMargin": "false",
|
9611
|
-
# "isolatedMargin": "0.00000000",
|
9612
9771
|
# "leverage": "10",
|
9613
|
-
# "liquidationPrice": "0",
|
9614
|
-
# "markPrice": "6679.50671178",
|
9615
9772
|
# "maxNotionalValue": "20000000",
|
9616
|
-
# "positionAmt": "0.000",
|
9617
|
-
# "symbol": "BTCUSDT",
|
9618
|
-
# "unRealizedProfit": "0.00000000",
|
9619
|
-
# "positionSide": "BOTH",
|
9620
9773
|
# "updateTime": 0
|
9621
9774
|
# }
|
9622
9775
|
# ]
|
@@ -9633,27 +9786,13 @@ class binance(Exchange, ImplicitAPI):
|
|
9633
9786
|
# "liquidationPrice": "5930.78",
|
9634
9787
|
# "markPrice": "6679.50671178",
|
9635
9788
|
# "maxNotionalValue": "20000000",
|
9636
|
-
# "
|
9789
|
+
# "positionSide": "LONG",
|
9790
|
+
# "positionAmt": "20.000", # negative value for 'SHORT'
|
9637
9791
|
# "symbol": "BTCUSDT",
|
9638
9792
|
# "unRealizedProfit": "2316.83423560"
|
9639
|
-
# "positionSide": "LONG",
|
9640
9793
|
# "updateTime": 1625474304765
|
9641
9794
|
# },
|
9642
|
-
#
|
9643
|
-
# "entryPrice": "0.00000",
|
9644
|
-
# "marginType": "isolated",
|
9645
|
-
# "isAutoAddMargin": "false",
|
9646
|
-
# "isolatedMargin": "5413.95799991",
|
9647
|
-
# "leverage": "10",
|
9648
|
-
# "liquidationPrice": "7189.95",
|
9649
|
-
# "markPrice": "6679.50671178",
|
9650
|
-
# "maxNotionalValue": "20000000",
|
9651
|
-
# "positionAmt": "-10.000",
|
9652
|
-
# "symbol": "BTCUSDT",
|
9653
|
-
# "unRealizedProfit": "-1156.46711780",
|
9654
|
-
# "positionSide": "SHORT",
|
9655
|
-
# "updateTime": 0
|
9656
|
-
# }
|
9795
|
+
# .. second dict is similar, but with `positionSide: SHORT`
|
9657
9796
|
# ]
|
9658
9797
|
#
|
9659
9798
|
# inverse portfolio margin:
|
@@ -9697,10 +9836,9 @@ class binance(Exchange, ImplicitAPI):
|
|
9697
9836
|
result = []
|
9698
9837
|
for i in range(0, len(response)):
|
9699
9838
|
rawPosition = response[i]
|
9700
|
-
|
9701
|
-
if
|
9702
|
-
|
9703
|
-
result.append(parsed)
|
9839
|
+
entryPriceString = self.safe_string(rawPosition, 'entryPrice')
|
9840
|
+
if Precise.string_gt(entryPriceString, '0'):
|
9841
|
+
result.append(self.parse_position_risk(response[i]))
|
9704
9842
|
symbols = self.market_symbols(symbols)
|
9705
9843
|
return self.filter_by_array_positions(result, 'symbol', symbols, False)
|
9706
9844
|
|
@@ -10335,7 +10473,7 @@ class binance(Exchange, ImplicitAPI):
|
|
10335
10473
|
body = self.urlencode(params)
|
10336
10474
|
else:
|
10337
10475
|
raise AuthenticationError(self.id + ' userDataStream endpoint requires `apiKey` credential')
|
10338
|
-
elif (api == 'private') or (api == 'eapiPrivate') or (api == 'sapi' and path != 'system/status') or (api == 'sapiV2') or (api == 'sapiV3') or (api == 'sapiV4') or (api == 'dapiPrivate') or (api == 'dapiPrivateV2') or (api == 'fapiPrivate') or (api == 'fapiPrivateV2') or (api == 'papi' and path != 'ping'):
|
10476
|
+
elif (api == 'private') or (api == 'eapiPrivate') or (api == 'sapi' and path != 'system/status') or (api == 'sapiV2') or (api == 'sapiV3') or (api == 'sapiV4') or (api == 'dapiPrivate') or (api == 'dapiPrivateV2') or (api == 'fapiPrivate') or (api == 'fapiPrivateV2') or (api == 'fapiPrivateV3') or (api == 'papi' and path != 'ping'):
|
10339
10477
|
self.check_required_credentials()
|
10340
10478
|
if method == 'POST' and ((path == 'order') or (path == 'sor/order')):
|
10341
10479
|
# inject in implicit API calls
|
ccxt/bybit.py
CHANGED
@@ -254,6 +254,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
254
254
|
},
|
255
255
|
'private': {
|
256
256
|
'get': {
|
257
|
+
'v5/market/instruments-info': 5,
|
257
258
|
# Legacy inverse swap
|
258
259
|
'v2/private/wallet/fund/records': 25, # 120 per minute = 2 per second => cost = 50 / 2 = 25
|
259
260
|
# spot
|
@@ -999,6 +1000,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
999
1000
|
},
|
1000
1001
|
'precisionMode': TICK_SIZE,
|
1001
1002
|
'options': {
|
1003
|
+
'usePrivateInstrumentsInfo': False,
|
1002
1004
|
'sandboxMode': False,
|
1003
1005
|
'enableDemoTrading': False,
|
1004
1006
|
'fetchMarkets': ['spot', 'linear', 'inverse', 'option'],
|
@@ -1457,7 +1459,12 @@ class bybit(Exchange, ImplicitAPI):
|
|
1457
1459
|
request: dict = {
|
1458
1460
|
'category': 'spot',
|
1459
1461
|
}
|
1460
|
-
|
1462
|
+
usePrivateInstrumentsInfo = self.safe_bool(self.options, 'usePrivateInstrumentsInfo', False)
|
1463
|
+
response: dict = None
|
1464
|
+
if usePrivateInstrumentsInfo:
|
1465
|
+
response = self.privateGetV5MarketInstrumentsInfo(self.extend(request, params))
|
1466
|
+
else:
|
1467
|
+
response = self.publicGetV5MarketInstrumentsInfo(self.extend(request, params))
|
1461
1468
|
#
|
1462
1469
|
# {
|
1463
1470
|
# "retCode": 0,
|
@@ -1566,14 +1573,23 @@ class bybit(Exchange, ImplicitAPI):
|
|
1566
1573
|
def fetch_future_markets(self, params):
|
1567
1574
|
params = self.extend(params)
|
1568
1575
|
params['limit'] = 1000 # minimize number of requests
|
1569
|
-
|
1576
|
+
usePrivateInstrumentsInfo = self.safe_bool(self.options, 'usePrivateInstrumentsInfo', False)
|
1577
|
+
response: dict = None
|
1578
|
+
if usePrivateInstrumentsInfo:
|
1579
|
+
response = self.privateGetV5MarketInstrumentsInfo(params)
|
1580
|
+
else:
|
1581
|
+
response = self.publicGetV5MarketInstrumentsInfo(params)
|
1570
1582
|
data = self.safe_dict(response, 'result', {})
|
1571
1583
|
markets = self.safe_list(data, 'list', [])
|
1572
1584
|
paginationCursor = self.safe_string(data, 'nextPageCursor')
|
1573
1585
|
if paginationCursor is not None:
|
1574
1586
|
while(paginationCursor is not None):
|
1575
1587
|
params['cursor'] = paginationCursor
|
1576
|
-
responseInner =
|
1588
|
+
responseInner: dict = None
|
1589
|
+
if usePrivateInstrumentsInfo:
|
1590
|
+
responseInner = self.privateGetV5MarketInstrumentsInfo(params)
|
1591
|
+
else:
|
1592
|
+
responseInner = self.publicGetV5MarketInstrumentsInfo(params)
|
1577
1593
|
dataNew = self.safe_dict(responseInner, 'result', {})
|
1578
1594
|
rawMarkets = self.safe_list(dataNew, 'list', [])
|
1579
1595
|
rawMarketsLength = len(rawMarkets)
|
@@ -1730,7 +1746,12 @@ class bybit(Exchange, ImplicitAPI):
|
|
1730
1746
|
request: dict = {
|
1731
1747
|
'category': 'option',
|
1732
1748
|
}
|
1733
|
-
|
1749
|
+
usePrivateInstrumentsInfo = self.safe_bool(self.options, 'usePrivateInstrumentsInfo', False)
|
1750
|
+
response: dict = None
|
1751
|
+
if usePrivateInstrumentsInfo:
|
1752
|
+
response = self.privateGetV5MarketInstrumentsInfo(self.extend(request, params))
|
1753
|
+
else:
|
1754
|
+
response = self.publicGetV5MarketInstrumentsInfo(self.extend(request, params))
|
1734
1755
|
data = self.safe_dict(response, 'result', {})
|
1735
1756
|
markets = self.safe_list(data, 'list', [])
|
1736
1757
|
if self.options['loadAllOptions']:
|
@@ -1739,7 +1760,11 @@ class bybit(Exchange, ImplicitAPI):
|
|
1739
1760
|
if paginationCursor is not None:
|
1740
1761
|
while(paginationCursor is not None):
|
1741
1762
|
request['cursor'] = paginationCursor
|
1742
|
-
responseInner =
|
1763
|
+
responseInner: dict = None
|
1764
|
+
if usePrivateInstrumentsInfo:
|
1765
|
+
responseInner = self.privateGetV5MarketInstrumentsInfo(self.extend(request, params))
|
1766
|
+
else:
|
1767
|
+
responseInner = self.publicGetV5MarketInstrumentsInfo(self.extend(request, params))
|
1743
1768
|
dataNew = self.safe_dict(responseInner, 'result', {})
|
1744
1769
|
rawMarkets = self.safe_list(dataNew, 'list', [])
|
1745
1770
|
rawMarketsLength = len(rawMarkets)
|
@@ -6738,8 +6763,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
6738
6763
|
currency = None
|
6739
6764
|
request: dict = {}
|
6740
6765
|
if code is not None:
|
6741
|
-
currency = self.
|
6742
|
-
request['coin'] = currency
|
6766
|
+
currency = self.safe_currency(code)
|
6767
|
+
request['coin'] = currency['id']
|
6743
6768
|
if since is not None:
|
6744
6769
|
request['startTime'] = since
|
6745
6770
|
if limit is not None:
|
ccxt/mexc.py
CHANGED
@@ -4908,7 +4908,7 @@ class mexc(Exchange, ImplicitAPI):
|
|
4908
4908
|
networks = self.safe_dict(self.options, 'networks', {})
|
4909
4909
|
network = self.safe_string_2(params, 'network', 'netWork') # self line allows the user to specify either ERC20 or ETH
|
4910
4910
|
network = self.safe_string(networks, network, network) # handle ETH > ERC-20 alias
|
4911
|
-
network = self.
|
4911
|
+
network = self.network_id_to_code(network)
|
4912
4912
|
self.check_address(address)
|
4913
4913
|
self.load_markets()
|
4914
4914
|
currency = self.currency(code)
|
ccxt/pro/__init__.py
CHANGED
ccxt/pro/alpaca.py
CHANGED
@@ -56,6 +56,7 @@ class alpaca(ccxt.async_support.alpaca):
|
|
56
56
|
async def watch_ticker(self, symbol: str, params={}) -> Ticker:
|
57
57
|
"""
|
58
58
|
watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
59
|
+
:see: https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#quotes
|
59
60
|
:param str symbol: unified symbol of the market to fetch the ticker for
|
60
61
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
61
62
|
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
@@ -129,6 +130,7 @@ class alpaca(ccxt.async_support.alpaca):
|
|
129
130
|
async def watch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
|
130
131
|
"""
|
131
132
|
watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
133
|
+
:see: https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#bars
|
132
134
|
:param str symbol: unified symbol of the market to fetch OHLCV data for
|
133
135
|
:param str timeframe: the length of time each candle represents
|
134
136
|
:param int [since]: timestamp in ms of the earliest candle to fetch
|
@@ -181,6 +183,7 @@ class alpaca(ccxt.async_support.alpaca):
|
|
181
183
|
async def watch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
|
182
184
|
"""
|
183
185
|
watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
|
186
|
+
:see: https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#orderbooks
|
184
187
|
:param str symbol: unified symbol of the market to fetch the order book for
|
185
188
|
:param int [limit]: the maximum amount of order book entries to return.
|
186
189
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -254,6 +257,7 @@ class alpaca(ccxt.async_support.alpaca):
|
|
254
257
|
async def watch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
255
258
|
"""
|
256
259
|
watches information on multiple trades made in a market
|
260
|
+
:see: https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#trades
|
257
261
|
:param str symbol: unified market symbol of the market trades were made in
|
258
262
|
:param int [since]: the earliest time in ms to fetch orders for
|
259
263
|
:param int [limit]: the maximum number of trade structures to retrieve
|
@@ -302,6 +306,7 @@ class alpaca(ccxt.async_support.alpaca):
|
|
302
306
|
async def watch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
303
307
|
"""
|
304
308
|
watches information on multiple trades made by the user
|
309
|
+
:see: https://docs.alpaca.markets/docs/websocket-streaming#trade-updates
|
305
310
|
:param str symbol: unified market symbol of the market trades were made in
|
306
311
|
:param int [since]: the earliest time in ms to fetch trades for
|
307
312
|
:param int [limit]: the maximum number of trade structures to retrieve
|