ccxt 4.0.72__py2.py3-none-any.whl → 4.0.73__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/lbank2.py +57 -53
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +8 -2
- ccxt/async_support/binance.py +95 -2
- ccxt/async_support/bybit.py +92 -0
- ccxt/async_support/cryptocom.py +1 -0
- ccxt/async_support/delta.py +1 -0
- ccxt/async_support/deribit.py +1 -0
- ccxt/async_support/gate.py +175 -0
- ccxt/async_support/lbank2.py +507 -185
- ccxt/async_support/okx.py +1 -0
- ccxt/base/exchange.py +8 -2
- ccxt/binance.py +95 -2
- ccxt/bybit.py +92 -0
- ccxt/cryptocom.py +1 -0
- ccxt/delta.py +1 -0
- ccxt/deribit.py +1 -0
- ccxt/gate.py +175 -0
- ccxt/lbank2.py +506 -185
- ccxt/okx.py +1 -0
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/bitmex.py +7 -6
- {ccxt-4.0.72.dist-info → ccxt-4.0.73.dist-info}/METADATA +4 -4
- {ccxt-4.0.72.dist-info → ccxt-4.0.73.dist-info}/RECORD +27 -27
- {ccxt-4.0.72.dist-info → ccxt-4.0.73.dist-info}/WHEEL +0 -0
- {ccxt-4.0.72.dist-info → ccxt-4.0.73.dist-info}/top_level.txt +0 -0
ccxt/lbank2.py
CHANGED
@@ -12,7 +12,6 @@ from typing import Optional
|
|
12
12
|
from typing import List
|
13
13
|
from ccxt.base.errors import ExchangeError
|
14
14
|
from ccxt.base.errors import PermissionDenied
|
15
|
-
from ccxt.base.errors import ArgumentsRequired
|
16
15
|
from ccxt.base.errors import BadRequest
|
17
16
|
from ccxt.base.errors import BadSymbol
|
18
17
|
from ccxt.base.errors import InsufficientFunds
|
@@ -41,7 +40,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
41
40
|
'CORS': False,
|
42
41
|
'spot': True,
|
43
42
|
'margin': False,
|
44
|
-
'swap':
|
43
|
+
'swap': None,
|
45
44
|
'future': False,
|
46
45
|
'option': False,
|
47
46
|
'addMargin': False,
|
@@ -85,6 +84,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
85
84
|
'fetchPremiumIndexOHLCV': False,
|
86
85
|
'fetchTicker': True,
|
87
86
|
'fetchTickers': True,
|
87
|
+
'fetchTime': True,
|
88
88
|
'fetchTrades': True,
|
89
89
|
'fetchTradingFees': True,
|
90
90
|
'fetchTransactionFees': True,
|
@@ -112,6 +112,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
112
112
|
'logo': 'https://user-images.githubusercontent.com/1294454/38063602-9605e28a-3302-11e8-81be-64b1e53c4cfb.jpg',
|
113
113
|
'api': {
|
114
114
|
'rest': 'https://api.lbank.info',
|
115
|
+
'contract': 'https://lbkperp.lbank.com',
|
115
116
|
},
|
116
117
|
'api2': 'https://api.lbkex.com',
|
117
118
|
'www': 'https://www.lbank.info',
|
@@ -120,73 +121,85 @@ class lbank2(Exchange, ImplicitAPI):
|
|
120
121
|
'referral': 'https://www.lbank.info/invitevip?icode=7QCY',
|
121
122
|
},
|
122
123
|
'api': {
|
123
|
-
'
|
124
|
-
'
|
125
|
-
'
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
124
|
+
'spot': {
|
125
|
+
'public': {
|
126
|
+
'get': {
|
127
|
+
'currencyPairs': 2.5,
|
128
|
+
'accuracy': 2.5,
|
129
|
+
'usdToCny': 2.5,
|
130
|
+
'withdrawConfigs': 2.5,
|
131
|
+
'timestamp': 2.5,
|
132
|
+
'ticker/24hr': 2.5,
|
133
|
+
'ticker': 2.5,
|
134
|
+
'depth': 2.5,
|
135
|
+
'incrDepth': 2.5,
|
136
|
+
'trades': 2.5,
|
137
|
+
'kline': 2.5,
|
138
|
+
# new quote endpoints
|
139
|
+
'supplement/system_ping': 2.5,
|
140
|
+
'supplement/incrDepth': 2.5,
|
141
|
+
'supplement/trades': 2.5,
|
142
|
+
'supplement/ticker/price': 2.5,
|
143
|
+
'supplement/ticker/bookTicker': 2.5,
|
144
|
+
},
|
145
|
+
'post': {
|
146
|
+
'supplement/system_status': 2.5,
|
147
|
+
},
|
142
148
|
},
|
143
|
-
'
|
144
|
-
'
|
149
|
+
'private': {
|
150
|
+
'post': {
|
151
|
+
# account
|
152
|
+
'user_info': 2.5,
|
153
|
+
'subscribe/get_key': 2.5,
|
154
|
+
'subscribe/refresh_key': 2.5,
|
155
|
+
'subscribe/destroy_key': 2.5,
|
156
|
+
'get_deposit_address': 2.5,
|
157
|
+
'deposit_history': 2.5,
|
158
|
+
# order
|
159
|
+
'create_order': 1,
|
160
|
+
'batch_create_order': 1,
|
161
|
+
'cancel_order': 1,
|
162
|
+
'cancel_clientOrders': 1,
|
163
|
+
'orders_info': 2.5,
|
164
|
+
'orders_info_history': 2.5,
|
165
|
+
'order_transaction_detail': 2.5,
|
166
|
+
'transaction_history': 2.5,
|
167
|
+
'orders_info_no_deal': 2.5,
|
168
|
+
# withdraw
|
169
|
+
'withdraw': 2.5,
|
170
|
+
'withdrawCancel': 2.5,
|
171
|
+
'withdraws': 2.5,
|
172
|
+
'supplement/user_info': 2.5,
|
173
|
+
'supplement/withdraw': 2.5,
|
174
|
+
'supplement/deposit_history': 2.5,
|
175
|
+
'supplement/withdraws': 2.5,
|
176
|
+
'supplement/get_deposit_address': 2.5,
|
177
|
+
'supplement/asset_detail': 2.5,
|
178
|
+
'supplement/customer_trade_fee': 2.5,
|
179
|
+
'supplement/api_Restrictions': 2.5,
|
180
|
+
# new quote endpoints
|
181
|
+
'supplement/system_ping': 2.5,
|
182
|
+
# new order endpoints
|
183
|
+
'supplement/create_order_test': 1,
|
184
|
+
'supplement/create_order': 1,
|
185
|
+
'supplement/cancel_order': 1,
|
186
|
+
'supplement/cancel_order_by_symbol': 1,
|
187
|
+
'supplement/orders_info': 2.5,
|
188
|
+
'supplement/orders_info_no_deal': 2.5,
|
189
|
+
'supplement/orders_info_history': 2.5,
|
190
|
+
'supplement/user_info_account': 2.5,
|
191
|
+
'supplement/transaction_history': 2.5,
|
192
|
+
},
|
145
193
|
},
|
146
194
|
},
|
147
|
-
'
|
148
|
-
'
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
'deposit_history': 2.5,
|
156
|
-
# order
|
157
|
-
'create_order': 1,
|
158
|
-
'batch_create_order': 1,
|
159
|
-
'cancel_order': 1,
|
160
|
-
'cancel_clientOrders': 1,
|
161
|
-
'orders_info': 2.5,
|
162
|
-
'orders_info_history': 2.5,
|
163
|
-
'order_transaction_detail': 2.5,
|
164
|
-
'transaction_history': 2.5,
|
165
|
-
'orders_info_no_deal': 2.5,
|
166
|
-
# withdraw
|
167
|
-
'withdraw': 2.5,
|
168
|
-
'withdrawCancel': 2.5,
|
169
|
-
'withdraws': 2.5,
|
170
|
-
'supplement/user_info': 2.5,
|
171
|
-
'supplement/withdraw': 2.5,
|
172
|
-
'supplement/deposit_history': 2.5,
|
173
|
-
'supplement/withdraws': 2.5,
|
174
|
-
'supplement/get_deposit_address': 2.5,
|
175
|
-
'supplement/asset_detail': 2.5,
|
176
|
-
'supplement/customer_trade_fee': 2.5,
|
177
|
-
'supplement/api_Restrictions': 2.5,
|
178
|
-
# new quote endpoints
|
179
|
-
'supplement/system_ping': 2.5,
|
180
|
-
# new order endpoints
|
181
|
-
'supplement/create_order_test': 1,
|
182
|
-
'supplement/create_order': 1,
|
183
|
-
'supplement/cancel_order': 1,
|
184
|
-
'supplement/cancel_order_by_symbol': 1,
|
185
|
-
'supplement/orders_info': 2.5,
|
186
|
-
'supplement/orders_info_no_deal': 2.5,
|
187
|
-
'supplement/orders_info_history': 2.5,
|
188
|
-
'supplement/user_info_account': 2.5,
|
189
|
-
'supplement/transaction_history': 2.5,
|
195
|
+
'contract': {
|
196
|
+
'public': {
|
197
|
+
'get': {
|
198
|
+
'cfd/openApi/v1/pub/getTime': 2.5,
|
199
|
+
'cfd/openApi/v1/pub/instrument': 2.5,
|
200
|
+
'cfd/openApi/v1/pub/marketData': 2.5,
|
201
|
+
'cfd/openApi/v1/pub/marketOrder': 2.5,
|
202
|
+
},
|
190
203
|
},
|
191
204
|
},
|
192
205
|
},
|
@@ -208,7 +221,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
208
221
|
'cacheSecretAsPem': True,
|
209
222
|
'createMarketBuyOrderRequiresPrice': True,
|
210
223
|
'fetchTrades': {
|
211
|
-
'method': '
|
224
|
+
'method': 'spotPublicGetTrades', # or 'spotPublicGetTradesSupplement'
|
212
225
|
},
|
213
226
|
'fetchTransactionFees': { # DEPRECATED, please use fetchDepositWithdrawFees
|
214
227
|
'method': 'fetchPrivateTransactionFees', # or 'fetchPublicTransactionFees'
|
@@ -220,13 +233,13 @@ class lbank2(Exchange, ImplicitAPI):
|
|
220
233
|
'method': 'fetchDepositAddressDefault', # or fetchDepositAddressSupplement
|
221
234
|
},
|
222
235
|
'createOrder': {
|
223
|
-
'method': '
|
236
|
+
'method': 'spotPrivatePostSupplementCreateOrder', # or spotPrivatePostCreateOrder
|
224
237
|
},
|
225
238
|
'fetchOrder': {
|
226
239
|
'method': 'fetchOrderSupplement', # or fetchOrderDefault
|
227
240
|
},
|
228
241
|
'fetchBalance': {
|
229
|
-
'method': '
|
242
|
+
'method': 'spotPrivatePostSupplementUserInfo', # or spotPrivatePostSupplementUserInfoAccount or spotPrivatePostUserInfo
|
230
243
|
},
|
231
244
|
'networks': {
|
232
245
|
'ERC20': 'erc20',
|
@@ -288,24 +301,76 @@ class lbank2(Exchange, ImplicitAPI):
|
|
288
301
|
},
|
289
302
|
})
|
290
303
|
|
304
|
+
def fetch_time(self, params={}):
|
305
|
+
"""
|
306
|
+
fetches the current integer timestamp in milliseconds from the exchange server
|
307
|
+
see https://www.lbank.info/en-US/docs/index.html#get-timestamp
|
308
|
+
see https://www.lbank.com/en-US/docs/contract.html#get-the-current-time
|
309
|
+
:param dict [params]: extra parameters specific to the lbank2 api endpoint
|
310
|
+
:returns int: the current integer timestamp in milliseconds from the exchange server
|
311
|
+
"""
|
312
|
+
type = None
|
313
|
+
type, params = self.handle_market_type_and_params('fetchTime', None, params)
|
314
|
+
response = None
|
315
|
+
if type == 'swap':
|
316
|
+
response = self.contractPublicGetCfdOpenApiV1PubGetTime(params)
|
317
|
+
else:
|
318
|
+
response = self.spotPublicGetTimestamp(params)
|
319
|
+
#
|
320
|
+
# spot
|
321
|
+
#
|
322
|
+
# {
|
323
|
+
# "result": "true",
|
324
|
+
# "data": 1691789627950,
|
325
|
+
# "error_code": 0,
|
326
|
+
# "ts": 1691789627950
|
327
|
+
# }
|
328
|
+
#
|
329
|
+
# swap
|
330
|
+
#
|
331
|
+
# {
|
332
|
+
# "data": 1691789627950,
|
333
|
+
# "error_code": 0,
|
334
|
+
# "msg": "Success",
|
335
|
+
# "result": "true",
|
336
|
+
# "success": True
|
337
|
+
# }
|
338
|
+
#
|
339
|
+
return self.safe_integer(response, 'data')
|
340
|
+
|
291
341
|
def fetch_markets(self, params={}):
|
292
342
|
"""
|
293
343
|
retrieves data on all markets for lbank2
|
294
344
|
see https://www.lbank.com/en-US/docs/index.html#trading-pairs
|
345
|
+
see https://www.lbank.com/en-US/docs/contract.html#query-contract-information-list
|
295
346
|
:param dict [params]: extra parameters specific to the exchange api endpoint
|
296
347
|
:returns dict[]: an array of objects representing market data
|
297
348
|
"""
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
#
|
308
|
-
#
|
349
|
+
marketsPromises = [
|
350
|
+
self.fetch_spot_markets(params),
|
351
|
+
self.fetch_swap_markets(params),
|
352
|
+
]
|
353
|
+
resolvedMarkets = marketsPromises
|
354
|
+
return self.array_concat(resolvedMarkets[0], resolvedMarkets[1])
|
355
|
+
|
356
|
+
def fetch_spot_markets(self, params={}):
|
357
|
+
response = self.spotPublicGetAccuracy(params)
|
358
|
+
#
|
359
|
+
# {
|
360
|
+
# "result": "true",
|
361
|
+
# "data": [
|
362
|
+
# {
|
363
|
+
# "symbol": "btc_usdt",
|
364
|
+
# "quantityAccuracy": "4",
|
365
|
+
# "minTranQua": "0.0001",
|
366
|
+
# "priceAccuracy": "2"
|
367
|
+
# },
|
368
|
+
# ],
|
369
|
+
# "error_code": 0,
|
370
|
+
# "ts": 1691560288484
|
371
|
+
# }
|
372
|
+
#
|
373
|
+
data = self.safe_value(response, 'data', [])
|
309
374
|
result = []
|
310
375
|
for i in range(0, len(data)):
|
311
376
|
market = data[i]
|
@@ -313,10 +378,9 @@ class lbank2(Exchange, ImplicitAPI):
|
|
313
378
|
parts = marketId.split('_')
|
314
379
|
baseId = parts[0]
|
315
380
|
quoteId = parts[1]
|
316
|
-
base =
|
317
|
-
quote =
|
381
|
+
base = self.safe_currency_code(baseId)
|
382
|
+
quote = self.safe_currency_code(quoteId)
|
318
383
|
symbol = base + '/' + quote
|
319
|
-
amountPrecision = self.parse_number(self.parse_precision(self.safe_string(market, 'quantityAccuracy')))
|
320
384
|
result.append({
|
321
385
|
'id': marketId,
|
322
386
|
'symbol': symbol,
|
@@ -342,7 +406,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
342
406
|
'strike': None,
|
343
407
|
'optionType': None,
|
344
408
|
'precision': {
|
345
|
-
'amount':
|
409
|
+
'amount': self.parse_number(self.parse_precision(self.safe_string(market, 'quantityAccuracy'))),
|
346
410
|
'price': self.parse_number(self.parse_precision(self.safe_string(market, 'priceAccuracy'))),
|
347
411
|
},
|
348
412
|
'limits': {
|
@@ -367,80 +431,198 @@ class lbank2(Exchange, ImplicitAPI):
|
|
367
431
|
})
|
368
432
|
return result
|
369
433
|
|
434
|
+
def fetch_swap_markets(self, params={}):
|
435
|
+
request = {
|
436
|
+
'productGroup': 'SwapU',
|
437
|
+
}
|
438
|
+
response = self.contractPublicGetCfdOpenApiV1PubInstrument(self.extend(request, params))
|
439
|
+
#
|
440
|
+
# {
|
441
|
+
# "data": [
|
442
|
+
# {
|
443
|
+
# "priceLimitUpperValue": 0.2,
|
444
|
+
# "symbol": "BTCUSDT",
|
445
|
+
# "volumeTick": 0.0001,
|
446
|
+
# "indexPrice": "29707.70200000",
|
447
|
+
# "minOrderVolume": "0.0001",
|
448
|
+
# "priceTick": 0.1,
|
449
|
+
# "maxOrderVolume": "30.0",
|
450
|
+
# "baseCurrency": "BTC",
|
451
|
+
# "volumeMultiple": 1.0,
|
452
|
+
# "exchangeID": "Exchange",
|
453
|
+
# "priceCurrency": "USDT",
|
454
|
+
# "priceLimitLowerValue": 0.2,
|
455
|
+
# "clearCurrency": "USDT",
|
456
|
+
# "symbolName": "BTCUSDT",
|
457
|
+
# "defaultLeverage": 20.0,
|
458
|
+
# "minOrderCost": "5.0"
|
459
|
+
# },
|
460
|
+
# ],
|
461
|
+
# "error_code": 0,
|
462
|
+
# "msg": "Success",
|
463
|
+
# "result": "true",
|
464
|
+
# "success": True
|
465
|
+
# }
|
466
|
+
#
|
467
|
+
data = self.safe_value(response, 'data', [])
|
468
|
+
result = []
|
469
|
+
for i in range(0, len(data)):
|
470
|
+
market = data[i]
|
471
|
+
marketId = self.safe_string(market, 'symbol')
|
472
|
+
baseId = self.safe_string(market, 'baseCurrency')
|
473
|
+
settleId = self.safe_string(market, 'clearCurrency')
|
474
|
+
quoteId = settleId
|
475
|
+
base = self.safe_currency_code(baseId)
|
476
|
+
quote = self.safe_currency_code(quoteId)
|
477
|
+
settle = self.safe_currency_code(settleId)
|
478
|
+
symbol = base + '/' + quote + ':' + settle
|
479
|
+
result.append({
|
480
|
+
'id': marketId,
|
481
|
+
'symbol': symbol,
|
482
|
+
'base': base,
|
483
|
+
'quote': quote,
|
484
|
+
'settle': settle,
|
485
|
+
'baseId': baseId,
|
486
|
+
'quoteId': quoteId,
|
487
|
+
'settleId': settleId,
|
488
|
+
'type': 'swap',
|
489
|
+
'spot': False,
|
490
|
+
'margin': False,
|
491
|
+
'swap': True,
|
492
|
+
'future': False,
|
493
|
+
'option': False,
|
494
|
+
'active': True,
|
495
|
+
'contract': True,
|
496
|
+
'linear': True,
|
497
|
+
'inverse': None,
|
498
|
+
'contractSize': self.safe_number(market, 'volumeMultiple'),
|
499
|
+
'expiry': None,
|
500
|
+
'expiryDatetime': None,
|
501
|
+
'strike': None,
|
502
|
+
'optionType': None,
|
503
|
+
'precision': {
|
504
|
+
'amount': self.safe_number(market, 'volumeTick'),
|
505
|
+
'price': self.safe_number(market, 'priceTick'),
|
506
|
+
},
|
507
|
+
'limits': {
|
508
|
+
'leverage': {
|
509
|
+
'min': None,
|
510
|
+
'max': None,
|
511
|
+
},
|
512
|
+
'amount': {
|
513
|
+
'min': self.safe_number(market, 'minOrderVolume'),
|
514
|
+
'max': self.safe_number(market, 'maxOrderVolume'),
|
515
|
+
},
|
516
|
+
'price': {
|
517
|
+
'min': self.safe_number(market, 'priceLimitLowerValue'),
|
518
|
+
'max': self.safe_number(market, 'priceLimitUpperValue'),
|
519
|
+
},
|
520
|
+
'cost': {
|
521
|
+
'min': self.safe_number(market, 'minOrderCost'),
|
522
|
+
'max': None,
|
523
|
+
},
|
524
|
+
},
|
525
|
+
'info': market,
|
526
|
+
})
|
527
|
+
return result
|
528
|
+
|
370
529
|
def parse_ticker(self, ticker, market=None):
|
371
530
|
#
|
372
|
-
#
|
373
|
-
#
|
374
|
-
#
|
375
|
-
#
|
376
|
-
#
|
377
|
-
#
|
378
|
-
#
|
379
|
-
#
|
380
|
-
#
|
381
|
-
#
|
382
|
-
#
|
383
|
-
#
|
531
|
+
# spot: fetchTicker, fetchTickers
|
532
|
+
#
|
533
|
+
# {
|
534
|
+
# "symbol": "btc_usdt",
|
535
|
+
# "ticker": {
|
536
|
+
# "high": "29695.57",
|
537
|
+
# "vol": "6890.2789",
|
538
|
+
# "low": "29110",
|
539
|
+
# "change": "0.58",
|
540
|
+
# "turnover": "202769821.06",
|
541
|
+
# "latest": "29405.98"
|
542
|
+
# },
|
543
|
+
# "timestamp": :1692064274908
|
544
|
+
# }
|
545
|
+
#
|
546
|
+
# swap: fetchTickers
|
547
|
+
#
|
548
|
+
# {
|
549
|
+
# "prePositionFeeRate": "0.000053",
|
550
|
+
# "volume": "2435.459",
|
551
|
+
# "symbol": "BTCUSDT",
|
552
|
+
# "highestPrice": "29446.5",
|
553
|
+
# "lowestPrice": "29362.9",
|
554
|
+
# "openPrice": "29419.5",
|
555
|
+
# "markedPrice": "29385.1",
|
556
|
+
# "turnover": "36345526.2438402",
|
557
|
+
# "lastPrice": "29387.0"
|
558
|
+
# }
|
384
559
|
#
|
560
|
+
timestamp = self.safe_integer(ticker, 'timestamp')
|
385
561
|
marketId = self.safe_string(ticker, 'symbol')
|
386
562
|
symbol = self.safe_symbol(marketId, market)
|
387
|
-
|
388
|
-
|
563
|
+
tickerData = self.safe_value(ticker, 'ticker', {})
|
564
|
+
market = self.safe_market(marketId, market)
|
565
|
+
data = ticker if (market['contract']) else tickerData
|
389
566
|
return self.safe_ticker({
|
390
567
|
'symbol': symbol,
|
391
568
|
'timestamp': timestamp,
|
392
569
|
'datetime': self.iso8601(timestamp),
|
393
|
-
'high': self.
|
394
|
-
'low': self.
|
570
|
+
'high': self.safe_string_2(data, 'high', 'highestPrice'),
|
571
|
+
'low': self.safe_string_2(data, 'low', 'lowestPrice'),
|
395
572
|
'bid': None,
|
396
573
|
'bidVolume': None,
|
397
574
|
'ask': None,
|
398
575
|
'askVolume': None,
|
399
576
|
'vwap': None,
|
400
|
-
'open':
|
577
|
+
'open': self.safe_string(data, 'openPrice'),
|
401
578
|
'close': None,
|
402
|
-
'last': self.
|
579
|
+
'last': self.safe_string_2(data, 'latest', 'lastPrice'),
|
403
580
|
'previousClose': None,
|
404
581
|
'change': None,
|
405
|
-
'percentage': self.safe_string(
|
582
|
+
'percentage': self.safe_string(data, 'change'),
|
406
583
|
'average': None,
|
407
|
-
'baseVolume': self.
|
408
|
-
'quoteVolume': self.safe_string(
|
584
|
+
'baseVolume': self.safe_string_2(data, 'vol', 'volume'),
|
585
|
+
'quoteVolume': self.safe_string(data, 'turnover'),
|
409
586
|
'info': ticker,
|
410
587
|
}, market)
|
411
588
|
|
412
589
|
def fetch_ticker(self, symbol: str, params={}):
|
413
590
|
"""
|
414
591
|
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
592
|
+
see https://www.lbank.info/en-US/docs/index.html#query-current-market-data-new
|
415
593
|
:param str symbol: unified symbol of the market to fetch the ticker for
|
416
594
|
:param dict [params]: extra parameters specific to the lbank2 api endpoint
|
417
595
|
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
418
596
|
"""
|
419
597
|
self.load_markets()
|
420
598
|
market = self.market(symbol)
|
599
|
+
if market['swap']:
|
600
|
+
response = self.fetch_tickers([market['symbol']], params)
|
601
|
+
return self.safe_value(response, market['symbol'])
|
421
602
|
request = {
|
422
603
|
'symbol': market['id'],
|
423
604
|
}
|
424
|
-
response = self.
|
425
|
-
#
|
426
|
-
#
|
427
|
-
#
|
428
|
-
#
|
429
|
-
#
|
430
|
-
#
|
431
|
-
#
|
432
|
-
#
|
433
|
-
#
|
434
|
-
#
|
435
|
-
#
|
436
|
-
#
|
437
|
-
#
|
438
|
-
#
|
439
|
-
#
|
440
|
-
#
|
441
|
-
#
|
442
|
-
#
|
443
|
-
#
|
605
|
+
response = self.spotPublicGetTicker24hr(self.extend(request, params))
|
606
|
+
#
|
607
|
+
# {
|
608
|
+
# "result": "true",
|
609
|
+
# "data": [
|
610
|
+
# {
|
611
|
+
# "symbol": "btc_usdt",
|
612
|
+
# "ticker": {
|
613
|
+
# "high": "29695.57",
|
614
|
+
# "vol": "6890.2789",
|
615
|
+
# "low": "29110",
|
616
|
+
# "change": "0.58",
|
617
|
+
# "turnover": "202769821.06",
|
618
|
+
# "latest": "29405.98"
|
619
|
+
# },
|
620
|
+
# "timestamp": :1692064274908
|
621
|
+
# }
|
622
|
+
# ],
|
623
|
+
# "error_code": 0,
|
624
|
+
# "ts": :1692064276872
|
625
|
+
# }
|
444
626
|
#
|
445
627
|
data = self.safe_value(response, 'data', [])
|
446
628
|
first = self.safe_value(data, 0, {})
|
@@ -449,21 +631,82 @@ class lbank2(Exchange, ImplicitAPI):
|
|
449
631
|
def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
|
450
632
|
"""
|
451
633
|
fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
634
|
+
see https://www.lbank.info/en-US/docs/index.html#query-current-market-data-new
|
635
|
+
see https://www.lbank.com/en-US/docs/contract.html#query-contract-market-list
|
452
636
|
:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
453
637
|
:param dict [params]: extra parameters specific to the lbank api endpoint
|
454
638
|
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
455
639
|
"""
|
456
640
|
self.load_markets()
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
641
|
+
market = None
|
642
|
+
if symbols is not None:
|
643
|
+
symbols = self.market_symbols(symbols)
|
644
|
+
symbolsLength = len(symbols)
|
645
|
+
if symbolsLength > 0:
|
646
|
+
market = self.market(symbols[0])
|
647
|
+
request = {}
|
648
|
+
type = None
|
649
|
+
type, params = self.handle_market_type_and_params('fetchTickers', market, params)
|
650
|
+
response = None
|
651
|
+
if type == 'swap':
|
652
|
+
request['productGroup'] = 'SwapU'
|
653
|
+
response = self.contractPublicGetCfdOpenApiV1PubMarketData(self.extend(request, params))
|
654
|
+
else:
|
655
|
+
request['symbol'] = 'all'
|
656
|
+
response = self.spotPublicGetTicker24hr(self.extend(request, params))
|
657
|
+
#
|
658
|
+
# spot
|
659
|
+
#
|
660
|
+
# {
|
661
|
+
# "result": "true",
|
662
|
+
# "data": [
|
663
|
+
# {
|
664
|
+
# "symbol": "btc_usdt",
|
665
|
+
# "ticker": {
|
666
|
+
# "high": "29695.57",
|
667
|
+
# "vol": "6890.2789",
|
668
|
+
# "low": "29110",
|
669
|
+
# "change": "0.58",
|
670
|
+
# "turnover": "202769821.06",
|
671
|
+
# "latest": "29405.98"
|
672
|
+
# },
|
673
|
+
# "timestamp": :1692064274908
|
674
|
+
# }
|
675
|
+
# ],
|
676
|
+
# "error_code": 0,
|
677
|
+
# "ts": :1692064276872
|
678
|
+
# }
|
679
|
+
#
|
680
|
+
# swap
|
681
|
+
#
|
682
|
+
# {
|
683
|
+
# "data": [
|
684
|
+
# {
|
685
|
+
# "prePositionFeeRate": "0.000053",
|
686
|
+
# "volume": "2435.459",
|
687
|
+
# "symbol": "BTCUSDT",
|
688
|
+
# "highestPrice": "29446.5",
|
689
|
+
# "lowestPrice": "29362.9",
|
690
|
+
# "openPrice": "29419.5",
|
691
|
+
# "markedPrice": "29385.1",
|
692
|
+
# "turnover": "36345526.2438402",
|
693
|
+
# "lastPrice": "29387.0"
|
694
|
+
# },
|
695
|
+
# ],
|
696
|
+
# "error_code": 0,
|
697
|
+
# "msg": "Success",
|
698
|
+
# "result": "true",
|
699
|
+
# "success": True
|
700
|
+
# }
|
701
|
+
#
|
461
702
|
data = self.safe_value(response, 'data', [])
|
462
703
|
return self.parse_tickers(data, symbols)
|
463
704
|
|
464
705
|
def fetch_order_book(self, symbol: str, limit: Optional[int] = None, params={}):
|
465
706
|
"""
|
466
707
|
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
|
708
|
+
see https://www.lbank.info/en-US/docs/index.html#query-market-depth
|
709
|
+
see https://www.lbank.com/en-US/docs/contract.html#get-handicap
|
467
710
|
:param str symbol: unified symbol of the market to fetch the order book for
|
468
711
|
:param int [limit]: the maximum amount of order book entries to return
|
469
712
|
:param dict [params]: extra parameters specific to the lbank2 api endpoint
|
@@ -475,16 +718,73 @@ class lbank2(Exchange, ImplicitAPI):
|
|
475
718
|
limit = 60
|
476
719
|
request = {
|
477
720
|
'symbol': market['id'],
|
478
|
-
'size': limit,
|
479
721
|
}
|
480
|
-
|
481
|
-
|
722
|
+
type = None
|
723
|
+
type, params = self.handle_market_type_and_params('fetchOrderBook', market, params)
|
724
|
+
response = None
|
725
|
+
if type == 'swap':
|
726
|
+
request['depth'] = limit
|
727
|
+
response = self.contractPublicGetCfdOpenApiV1PubMarketOrder(self.extend(request, params))
|
728
|
+
else:
|
729
|
+
request['size'] = limit
|
730
|
+
response = self.spotPublicGetDepth(self.extend(request, params))
|
731
|
+
#
|
732
|
+
# spot
|
733
|
+
#
|
734
|
+
# {
|
735
|
+
# "result": "true",
|
736
|
+
# "data": {
|
737
|
+
# "asks": [
|
738
|
+
# ["29243.37", "2.8783"],
|
739
|
+
# ["29243.39", "2.2842"],
|
740
|
+
# ["29243.4", "0.0337"]
|
741
|
+
# ],
|
742
|
+
# "bids": [
|
743
|
+
# ["29243.36", "1.5258"],
|
744
|
+
# ["29243.34", "0.8218"],
|
745
|
+
# ["29243.28", "1.285"]
|
746
|
+
# ],
|
747
|
+
# "timestamp": :1692157328820
|
748
|
+
# },
|
749
|
+
# "error_code": 0,
|
750
|
+
# "ts": :1692157328820
|
751
|
+
# }
|
752
|
+
#
|
753
|
+
# swap
|
754
|
+
#
|
755
|
+
# {
|
756
|
+
# "data": {
|
757
|
+
# "symbol": "BTCUSDT",
|
758
|
+
# "asks": [
|
759
|
+
# {
|
760
|
+
# "volume": "14.6535",
|
761
|
+
# "price": "29234.2",
|
762
|
+
# "orders": "1"
|
763
|
+
# },
|
764
|
+
# ],
|
765
|
+
# "bids": [
|
766
|
+
# {
|
767
|
+
# "volume": "13.4899",
|
768
|
+
# "price": "29234.1",
|
769
|
+
# "orders": "4"
|
770
|
+
# },
|
771
|
+
# ]
|
772
|
+
# },
|
773
|
+
# "error_code": 0,
|
774
|
+
# "msg": "Success",
|
775
|
+
# "result": "true",
|
776
|
+
# "success": True
|
777
|
+
# }
|
778
|
+
#
|
779
|
+
orderbook = self.safe_value(response, 'data', {})
|
482
780
|
timestamp = self.milliseconds()
|
781
|
+
if market['swap']:
|
782
|
+
return self.parse_order_book(orderbook, market['symbol'], timestamp, 'bids', 'asks', 'price', 'volume')
|
483
783
|
return self.parse_order_book(orderbook, market['symbol'], timestamp)
|
484
784
|
|
485
785
|
def parse_trade(self, trade, market=None):
|
486
786
|
#
|
487
|
-
# fetchTrades(old)
|
787
|
+
# fetchTrades(old) spotPublicGetTrades
|
488
788
|
#
|
489
789
|
# {
|
490
790
|
# "date_ms":1647021989789,
|
@@ -495,7 +795,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
495
795
|
# }
|
496
796
|
#
|
497
797
|
#
|
498
|
-
# fetchTrades(new)
|
798
|
+
# fetchTrades(new) spotPublicGetTradesSupplement
|
499
799
|
#
|
500
800
|
# {
|
501
801
|
# "quoteQty":1675.048485,
|
@@ -578,6 +878,8 @@ class lbank2(Exchange, ImplicitAPI):
|
|
578
878
|
def fetch_trades(self, symbol: str, since: Optional[int] = None, limit: Optional[int] = None, params={}):
|
579
879
|
"""
|
580
880
|
get the list of most recent trades for a particular symbol
|
881
|
+
see https://www.lbank.info/en-US/docs/index.html#query-historical-transactions
|
882
|
+
see https://www.lbank.info/en-US/docs/index.html#recent-transactions-list
|
581
883
|
:param str symbol: unified symbol of the market to fetch trades for
|
582
884
|
:param int [since]: timestamp in ms of the earliest trade to fetch
|
583
885
|
:param int [limit]: the maximum amount of trades to fetch
|
@@ -599,7 +901,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
599
901
|
params = self.omit(params, 'method')
|
600
902
|
if method is None:
|
601
903
|
options = self.safe_value(self.options, 'fetchTrades', {})
|
602
|
-
method = self.safe_string(options, 'method', '
|
904
|
+
method = self.safe_string(options, 'method', 'spotPublicGetTrades')
|
603
905
|
response = getattr(self, method)(self.extend(request, params))
|
604
906
|
#
|
605
907
|
# {
|
@@ -616,6 +918,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
616
918
|
# "error_code":0,
|
617
919
|
# "ts":1647021999308
|
618
920
|
# }
|
921
|
+
#
|
619
922
|
trades = self.safe_value(response, 'data', [])
|
620
923
|
return self.parse_trades(trades, market, since, limit)
|
621
924
|
|
@@ -642,6 +945,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
642
945
|
def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Optional[int] = None, limit: Optional[int] = None, params={}):
|
643
946
|
"""
|
644
947
|
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
948
|
+
see https://www.lbank.info/en-US/docs/index.html#query-k-bar-data
|
645
949
|
:param str symbol: unified symbol of the market to fetch OHLCV data for
|
646
950
|
:param str timeframe: the length of time each candle represents
|
647
951
|
:param int [since]: timestamp in ms of the earliest candle to fetch
|
@@ -663,7 +967,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
663
967
|
'time': self.parse_to_int(since / 1000),
|
664
968
|
'size': limit, # max 2000
|
665
969
|
}
|
666
|
-
response = self.
|
970
|
+
response = self.spotPublicGetKline(self.extend(request, params))
|
667
971
|
ohlcvs = self.safe_value(response, 'data', [])
|
668
972
|
#
|
669
973
|
#
|
@@ -690,7 +994,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
690
994
|
|
691
995
|
def parse_balance(self, response):
|
692
996
|
#
|
693
|
-
#
|
997
|
+
# spotPrivatePostUserInfo
|
694
998
|
#
|
695
999
|
# {
|
696
1000
|
# "toBtc": {
|
@@ -715,7 +1019,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
715
1019
|
# }
|
716
1020
|
# }
|
717
1021
|
#
|
718
|
-
#
|
1022
|
+
# spotPrivatePostSupplementUserInfoAccount
|
719
1023
|
#
|
720
1024
|
# {
|
721
1025
|
# "balances":[
|
@@ -727,7 +1031,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
727
1031
|
# ]
|
728
1032
|
# }
|
729
1033
|
#
|
730
|
-
#
|
1034
|
+
# spotPrivatePostSupplementUserInfo
|
731
1035
|
#
|
732
1036
|
# [
|
733
1037
|
# {
|
@@ -773,7 +1077,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
773
1077
|
'datetime': self.iso8601(timestamp),
|
774
1078
|
}
|
775
1079
|
data = self.safe_value(response, 'data')
|
776
|
-
# from
|
1080
|
+
# from spotPrivatePostUserInfo
|
777
1081
|
toBtc = self.safe_value(data, 'toBtc')
|
778
1082
|
if toBtc is not None:
|
779
1083
|
used = self.safe_value(data, 'freeze', {})
|
@@ -787,7 +1091,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
787
1091
|
account['free'] = self.safe_string(free, currencyId)
|
788
1092
|
result[code] = account
|
789
1093
|
return self.safe_balance(result)
|
790
|
-
# from
|
1094
|
+
# from spotPrivatePostSupplementUserInfoAccount
|
791
1095
|
balances = self.safe_value(data, 'balances')
|
792
1096
|
if balances is not None:
|
793
1097
|
for i in range(0, len(balances)):
|
@@ -799,7 +1103,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
799
1103
|
account['used'] = self.safe_string(item, 'locked')
|
800
1104
|
result[codeInner] = account
|
801
1105
|
return self.safe_balance(result)
|
802
|
-
# from
|
1106
|
+
# from spotPrivatePostSupplementUserInfo
|
803
1107
|
isArray = isinstance(data, list)
|
804
1108
|
if isArray is True:
|
805
1109
|
for i in range(0, len(data)):
|
@@ -816,6 +1120,9 @@ class lbank2(Exchange, ImplicitAPI):
|
|
816
1120
|
def fetch_balance(self, params={}):
|
817
1121
|
"""
|
818
1122
|
query for balance and get the amount of funds available for trading or funds locked in orders
|
1123
|
+
see https://www.lbank.info/en-US/docs/index.html#asset-information
|
1124
|
+
see https://www.lbank.info/en-US/docs/index.html#account-information
|
1125
|
+
see https://www.lbank.info/en-US/docs/index.html#get-all-coins-information
|
819
1126
|
:param dict [params]: extra parameters specific to the lbank2 api endpoint
|
820
1127
|
:returns dict: a `balance structure <https://docs.ccxt.com/en/latest/manual.html?#balance-structure>`
|
821
1128
|
"""
|
@@ -823,7 +1130,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
823
1130
|
method = self.safe_string(params, 'method')
|
824
1131
|
if method is None:
|
825
1132
|
options = self.safe_value(self.options, 'fetchBalance', {})
|
826
|
-
method = self.safe_string(options, 'method', '
|
1133
|
+
method = self.safe_string(options, 'method', 'spotPrivatePostSupplementUserInfo')
|
827
1134
|
response = getattr(self, method)()
|
828
1135
|
#
|
829
1136
|
# {
|
@@ -877,6 +1184,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
877
1184
|
def fetch_trading_fee(self, symbol: str, params={}):
|
878
1185
|
"""
|
879
1186
|
fetch the trading fees for a market
|
1187
|
+
see https://www.lbank.info/en-US/docs/index.html#transaction-fee-rate-query
|
880
1188
|
:param str symbol: unified market symbol
|
881
1189
|
:param dict [params]: extra parameters specific to the lbank2 api endpoint
|
882
1190
|
:returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
|
@@ -888,12 +1196,13 @@ class lbank2(Exchange, ImplicitAPI):
|
|
888
1196
|
def fetch_trading_fees(self, params={}):
|
889
1197
|
"""
|
890
1198
|
fetch the trading fees for multiple markets
|
1199
|
+
see https://www.lbank.info/en-US/docs/index.html#transaction-fee-rate-query
|
891
1200
|
:param dict [params]: extra parameters specific to the lbank2 api endpoint
|
892
1201
|
:returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
|
893
1202
|
"""
|
894
1203
|
self.load_markets()
|
895
1204
|
request = {}
|
896
|
-
response = self.
|
1205
|
+
response = self.spotPrivatePostSupplementCustomerTradeFee(self.extend(request, params))
|
897
1206
|
fees = self.safe_value(response, 'data', [])
|
898
1207
|
result = {}
|
899
1208
|
for i in range(0, len(fees)):
|
@@ -905,6 +1214,8 @@ class lbank2(Exchange, ImplicitAPI):
|
|
905
1214
|
def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount, price=None, params={}):
|
906
1215
|
"""
|
907
1216
|
create a trade order
|
1217
|
+
see https://www.lbank.info/en-US/docs/index.html#place-order
|
1218
|
+
see https://www.lbank.info/en-US/docs/index.html#place-an-order
|
908
1219
|
:param str symbol: unified symbol of the market to create an order in
|
909
1220
|
:param str type: 'market' or 'limit'
|
910
1221
|
:param str side: 'buy' or 'sell'
|
@@ -961,7 +1272,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
961
1272
|
params = self.omit(params, 'method')
|
962
1273
|
if method is None:
|
963
1274
|
options = self.safe_value(self.options, 'createOrder', {})
|
964
|
-
method = self.safe_string(options, 'method', '
|
1275
|
+
method = self.safe_string(options, 'method', 'spotPrivatePostSupplementCreateOrder')
|
965
1276
|
response = getattr(self, method)(self.extend(request, params))
|
966
1277
|
#
|
967
1278
|
# {
|
@@ -1114,6 +1425,8 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1114
1425
|
def fetch_order(self, id: str, symbol: Optional[str] = None, params={}):
|
1115
1426
|
"""
|
1116
1427
|
fetches information on an order made by the user
|
1428
|
+
see https://www.lbank.info/en-US/docs/index.html#query-order
|
1429
|
+
see https://www.lbank.info/en-US/docs/index.html#query-order-new
|
1117
1430
|
:param str symbol: unified symbol of the market the order was made in
|
1118
1431
|
:param dict [params]: extra parameters specific to the lbank2 api endpoint
|
1119
1432
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
@@ -1127,15 +1440,14 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1127
1440
|
return result
|
1128
1441
|
|
1129
1442
|
def fetch_order_supplement(self, id: str, symbol: Optional[str] = None, params={}):
|
1443
|
+
self.check_required_symbol('fetchOrder', symbol)
|
1130
1444
|
self.load_markets()
|
1131
|
-
if symbol is None:
|
1132
|
-
raise ArgumentsRequired(self.id + ' fetchOrder() requires a symbol argument')
|
1133
1445
|
market = self.market(symbol)
|
1134
1446
|
request = {
|
1135
1447
|
'symbol': market['id'],
|
1136
1448
|
'orderId': id,
|
1137
1449
|
}
|
1138
|
-
response = self.
|
1450
|
+
response = self.spotPrivatePostSupplementOrdersInfo(self.extend(request, params))
|
1139
1451
|
#
|
1140
1452
|
# {
|
1141
1453
|
# "result":true,
|
@@ -1162,15 +1474,14 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1162
1474
|
|
1163
1475
|
def fetch_order_default(self, id: str, symbol: Optional[str] = None, params={}):
|
1164
1476
|
# Id can be a list of ids delimited by a comma
|
1477
|
+
self.check_required_symbol('fetchOrder', symbol)
|
1165
1478
|
self.load_markets()
|
1166
|
-
if symbol is None:
|
1167
|
-
raise ArgumentsRequired(self.id + ' fetchOrder() requires a symbol argument')
|
1168
1479
|
market = self.market(symbol)
|
1169
1480
|
request = {
|
1170
1481
|
'symbol': market['id'],
|
1171
1482
|
'order_id': id,
|
1172
1483
|
}
|
1173
|
-
response = self.
|
1484
|
+
response = self.spotPrivatePostOrdersInfo(self.extend(request, params))
|
1174
1485
|
#
|
1175
1486
|
# {
|
1176
1487
|
# "result":true,
|
@@ -1205,14 +1516,14 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1205
1516
|
def fetch_my_trades(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
|
1206
1517
|
"""
|
1207
1518
|
fetch all trades made by the user
|
1519
|
+
see https://www.lbank.info/en-US/docs/index.html#past-transaction-details
|
1208
1520
|
:param str symbol: unified market symbol
|
1209
1521
|
:param int [since]: the earliest time in ms to fetch trades for
|
1210
|
-
:param int [limit]: the maximum number of
|
1522
|
+
:param int [limit]: the maximum number of trade structures to retrieve
|
1211
1523
|
:param dict [params]: extra parameters specific to the lbank2 api endpoint
|
1212
1524
|
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
1213
1525
|
"""
|
1214
|
-
|
1215
|
-
raise ArgumentsRequired(self.id + ' fetchMyTrades() requires a symbol argument')
|
1526
|
+
self.check_required_symbol('fetchMyTrades', symbol)
|
1216
1527
|
self.load_markets()
|
1217
1528
|
market = self.market(symbol)
|
1218
1529
|
since = self.safe_value(params, 'start_date', since)
|
@@ -1231,7 +1542,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1231
1542
|
if since is not None:
|
1232
1543
|
request['start_date'] = self.ymd(since, '-') # max query 2 days ago
|
1233
1544
|
request['end_date'] = self.ymd(since + 86400000, '-') # will cover 2 days
|
1234
|
-
response = self.
|
1545
|
+
response = self.spotPrivatePostTransactionHistory(self.extend(request, params))
|
1235
1546
|
#
|
1236
1547
|
# {
|
1237
1548
|
# "result":true,
|
@@ -1258,16 +1569,16 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1258
1569
|
def fetch_orders(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
|
1259
1570
|
"""
|
1260
1571
|
fetches information on multiple orders made by the user
|
1572
|
+
see https://www.lbank.info/en-US/docs/index.html#query-all-orders
|
1261
1573
|
:param str symbol: unified market symbol of the market orders were made in
|
1262
1574
|
:param int [since]: the earliest time in ms to fetch orders for
|
1263
|
-
:param int [limit]: the maximum number of
|
1575
|
+
:param int [limit]: the maximum number of order structures to retrieve
|
1264
1576
|
:param dict [params]: extra parameters specific to the lbank2 api endpoint
|
1265
1577
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
1266
1578
|
"""
|
1267
1579
|
# default query is for canceled and completely filled orders
|
1268
1580
|
# does not return open orders unless specified explicitly
|
1269
|
-
|
1270
|
-
raise ArgumentsRequired(self.id + ' fetchOrders() requires a symbol argument')
|
1581
|
+
self.check_required_symbol('fetchOrders', symbol)
|
1271
1582
|
self.load_markets()
|
1272
1583
|
market = self.market(symbol)
|
1273
1584
|
if limit is None:
|
@@ -1278,7 +1589,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1278
1589
|
'page_length': limit,
|
1279
1590
|
# 'status' -1: Cancelled, 0: Unfilled, 1: Partially filled, 2: Completely filled, 3: Partially filled and cancelled, 4: Cancellation is being processed
|
1280
1591
|
}
|
1281
|
-
response = self.
|
1592
|
+
response = self.spotPrivatePostSupplementOrdersInfoHistory(self.extend(request, params))
|
1282
1593
|
#
|
1283
1594
|
# {
|
1284
1595
|
# "result":true,
|
@@ -1313,14 +1624,14 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1313
1624
|
def fetch_open_orders(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
|
1314
1625
|
"""
|
1315
1626
|
fetch all unfilled currently open orders
|
1627
|
+
see https://www.lbank.info/en-US/docs/index.html#current-pending-order
|
1316
1628
|
:param str symbol: unified market symbol
|
1317
1629
|
:param int [since]: the earliest time in ms to fetch open orders for
|
1318
|
-
:param int [limit]: the maximum number of
|
1630
|
+
:param int [limit]: the maximum number of open order structures to retrieve
|
1319
1631
|
:param dict [params]: extra parameters specific to the lbank2 api endpoint
|
1320
1632
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
1321
1633
|
"""
|
1322
|
-
|
1323
|
-
raise ArgumentsRequired(self.id + ' fetchOpenOrders() requires a symbol argument')
|
1634
|
+
self.check_required_symbol('fetchOpenOrders', symbol)
|
1324
1635
|
self.load_markets()
|
1325
1636
|
market = self.market(symbol)
|
1326
1637
|
if limit is None:
|
@@ -1330,7 +1641,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1330
1641
|
'current_page': 1,
|
1331
1642
|
'page_length': limit,
|
1332
1643
|
}
|
1333
|
-
response = self.
|
1644
|
+
response = self.spotPrivatePostSupplementOrdersInfoNoDeal(self.extend(request, params))
|
1334
1645
|
#
|
1335
1646
|
# {
|
1336
1647
|
# "result":true,
|
@@ -1365,24 +1676,24 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1365
1676
|
def cancel_order(self, id: str, symbol: Optional[str] = None, params={}):
|
1366
1677
|
"""
|
1367
1678
|
cancels an open order
|
1679
|
+
see https://www.lbank.info/en-US/docs/index.html#cancel-order-new
|
1368
1680
|
:param str id: order id
|
1369
1681
|
:param str symbol: unified symbol of the market the order was made in
|
1370
1682
|
:param dict [params]: extra parameters specific to the lbank2 api endpoint
|
1371
1683
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1372
1684
|
"""
|
1373
|
-
|
1374
|
-
raise ArgumentsRequired(self.id + ' cancelOrder() requires a symbol argument')
|
1685
|
+
self.check_required_symbol('cancelOrder', symbol)
|
1375
1686
|
self.load_markets()
|
1376
1687
|
clientOrderId = self.safe_string_2(params, 'origClientOrderId', 'clientOrderId')
|
1377
1688
|
params = self.omit(params, ['origClientOrderId', 'clientOrderId'])
|
1378
1689
|
market = self.market(symbol)
|
1379
1690
|
request = {
|
1380
1691
|
'symbol': market['id'],
|
1692
|
+
'orderId': id,
|
1381
1693
|
}
|
1382
1694
|
if clientOrderId is not None:
|
1383
1695
|
request['origClientOrderId'] = clientOrderId
|
1384
|
-
|
1385
|
-
response = self.privatePostSupplementCancelOrder(self.extend(request, params))
|
1696
|
+
response = self.spotPrivatePostSupplementCancelOrder(self.extend(request, params))
|
1386
1697
|
#
|
1387
1698
|
# {
|
1388
1699
|
# "result":true,
|
@@ -1402,18 +1713,18 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1402
1713
|
def cancel_all_orders(self, symbol: Optional[str] = None, params={}):
|
1403
1714
|
"""
|
1404
1715
|
cancel all open orders in a market
|
1716
|
+
see https://www.lbank.info/en-US/docs/index.html#cancel-all-pending-orders-for-a-single-trading-pair
|
1405
1717
|
:param str symbol: unified market symbol of the market to cancel orders in
|
1406
1718
|
:param dict [params]: extra parameters specific to the lbank2 api endpoint
|
1407
1719
|
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
1408
1720
|
"""
|
1409
|
-
|
1410
|
-
raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
|
1721
|
+
self.check_required_symbol('cancelAllOrders', symbol)
|
1411
1722
|
self.load_markets()
|
1412
1723
|
market = self.market(symbol)
|
1413
1724
|
request = {
|
1414
1725
|
'symbol': market['id'],
|
1415
1726
|
}
|
1416
|
-
response = self.
|
1727
|
+
response = self.spotPrivatePostSupplementCancelOrderBySymbol(self.extend(request, params))
|
1417
1728
|
#
|
1418
1729
|
# {
|
1419
1730
|
# "result":"true",
|
@@ -1445,6 +1756,8 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1445
1756
|
def fetch_deposit_address(self, code: str, params={}):
|
1446
1757
|
"""
|
1447
1758
|
fetch the deposit address for a currency associated with self account
|
1759
|
+
see https://www.lbank.info/en-US/docs/index.html#get-deposit-address
|
1760
|
+
see https://www.lbank.info/en-US/docs/index.html#the-user-obtains-the-deposit-address
|
1448
1761
|
:param str code: unified currency code
|
1449
1762
|
:param dict [params]: extra parameters specific to the lbank2 api endpoint
|
1450
1763
|
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
|
@@ -1454,7 +1767,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1454
1767
|
params = self.omit(params, 'method')
|
1455
1768
|
if method is None:
|
1456
1769
|
options = self.safe_value(self.options, 'fetchDepositAddress', {})
|
1457
|
-
method = self.safe_string(options, 'method', '
|
1770
|
+
method = self.safe_string(options, 'method', 'fetchDepositAddressDefault')
|
1458
1771
|
return getattr(self, method)(code, params)
|
1459
1772
|
|
1460
1773
|
def fetch_deposit_address_default(self, code: str, params={}):
|
@@ -1467,7 +1780,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1467
1780
|
if network is not None:
|
1468
1781
|
request['netWork'] = network # ... yes, really lol
|
1469
1782
|
params = self.omit(params, 'network')
|
1470
|
-
response = self.
|
1783
|
+
response = self.spotPrivatePostGetDepositAddress(self.extend(request, params))
|
1471
1784
|
#
|
1472
1785
|
# {
|
1473
1786
|
# "result":true,
|
@@ -1508,7 +1821,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1508
1821
|
if network is not None:
|
1509
1822
|
request['networkName'] = network
|
1510
1823
|
params = self.omit(params, 'network')
|
1511
|
-
response = self.
|
1824
|
+
response = self.spotPrivatePostSupplementGetDepositAddress(self.extend(request, params))
|
1512
1825
|
#
|
1513
1826
|
# {
|
1514
1827
|
# "result":true,
|
@@ -1537,6 +1850,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1537
1850
|
def withdraw(self, code: str, amount, address, tag=None, params={}):
|
1538
1851
|
"""
|
1539
1852
|
make a withdrawal
|
1853
|
+
see https://www.lbank.info/en-US/docs/index.html#withdrawal
|
1540
1854
|
:param str code: unified currency code
|
1541
1855
|
:param float amount: the amount to withdraw
|
1542
1856
|
:param str address: the address to withdraw to
|
@@ -1549,8 +1863,8 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1549
1863
|
self.load_markets()
|
1550
1864
|
fee = self.safe_string(params, 'fee')
|
1551
1865
|
params = self.omit(params, 'fee')
|
1552
|
-
|
1553
|
-
|
1866
|
+
# The relevant coin network fee can be found by calling fetchDepositWithdrawFees(), note: if no network param is supplied then the default network will be used, self can also be found in fetchDepositWithdrawFees().
|
1867
|
+
self.check_required_argument('withdraw', fee, 'fee')
|
1554
1868
|
currency = self.currency(code)
|
1555
1869
|
request = {
|
1556
1870
|
'address': address,
|
@@ -1572,7 +1886,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1572
1886
|
networkId = self.safe_string(networks, network, network)
|
1573
1887
|
if networkId is not None:
|
1574
1888
|
request['networkName'] = networkId
|
1575
|
-
response = self.
|
1889
|
+
response = self.spotPrivatePostSupplementWithdraw(self.extend(request, params))
|
1576
1890
|
#
|
1577
1891
|
# {
|
1578
1892
|
# "result":true,
|
@@ -1693,6 +2007,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1693
2007
|
def fetch_deposits(self, code: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
|
1694
2008
|
"""
|
1695
2009
|
fetch all deposits made to an account
|
2010
|
+
see https://www.lbank.info/en-US/docs/index.html#get-recharge-history
|
1696
2011
|
:param str code: unified currency code
|
1697
2012
|
:param int [since]: the earliest time in ms to fetch deposits for
|
1698
2013
|
:param int [limit]: the maximum number of deposits structures to retrieve
|
@@ -1710,7 +2025,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1710
2025
|
request['coin'] = currency['id']
|
1711
2026
|
if since is not None:
|
1712
2027
|
request['startTime'] = since
|
1713
|
-
response = self.
|
2028
|
+
response = self.spotPrivatePostSupplementDepositHistory(self.extend(request, params))
|
1714
2029
|
#
|
1715
2030
|
# {
|
1716
2031
|
# "result":true,
|
@@ -1741,6 +2056,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1741
2056
|
def fetch_withdrawals(self, code: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
|
1742
2057
|
"""
|
1743
2058
|
fetch all withdrawals made from an account
|
2059
|
+
see https://www.lbank.info/en-US/docs/index.html#get-withdrawal-history
|
1744
2060
|
:param str code: unified currency code
|
1745
2061
|
:param int [since]: the earliest time in ms to fetch withdrawals for
|
1746
2062
|
:param int [limit]: the maximum number of withdrawals structures to retrieve
|
@@ -1759,7 +2075,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1759
2075
|
request['coin'] = currency['id']
|
1760
2076
|
if since is not None:
|
1761
2077
|
request['startTime'] = since
|
1762
|
-
response = self.
|
2078
|
+
response = self.spotPrivatePostSupplementWithdraws(self.extend(request, params))
|
1763
2079
|
#
|
1764
2080
|
# {
|
1765
2081
|
# "result":true,
|
@@ -1817,7 +2133,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1817
2133
|
# complete response
|
1818
2134
|
# incl. for coins which None in public method
|
1819
2135
|
self.load_markets()
|
1820
|
-
response = self.
|
2136
|
+
response = self.spotPrivatePostSupplementUserInfo()
|
1821
2137
|
#
|
1822
2138
|
# {
|
1823
2139
|
# "result": "true",
|
@@ -1879,7 +2195,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1879
2195
|
if code is not None:
|
1880
2196
|
currency = self.currency(code)
|
1881
2197
|
request['assetCode'] = currency['id']
|
1882
|
-
response = self.
|
2198
|
+
response = self.spotPublicGetWithdrawConfigs(self.extend(request, params))
|
1883
2199
|
#
|
1884
2200
|
# {
|
1885
2201
|
# result: 'true',
|
@@ -1926,6 +2242,8 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1926
2242
|
def fetch_deposit_withdraw_fees(self, codes: Optional[List[str]] = None, params={}):
|
1927
2243
|
"""
|
1928
2244
|
when using private endpoint, only returns information for currencies with non-zero balance, use public method by specifying self.options['fetchDepositWithdrawFees']['method'] = 'fetchPublicDepositWithdrawFees'
|
2245
|
+
see https://www.lbank.info/en-US/docs/index.html#get-all-coins-information
|
2246
|
+
see https://www.lbank.info/en-US/docs/index.html#withdrawal-configurations
|
1929
2247
|
:param str[]|None codes: array of unified currency codes
|
1930
2248
|
:param dict [params]: extra parameters specific to the lbank2 api endpoint
|
1931
2249
|
:returns dict: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
|
@@ -1947,7 +2265,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1947
2265
|
# complete response
|
1948
2266
|
# incl. for coins which None in public method
|
1949
2267
|
self.load_markets()
|
1950
|
-
response = self.
|
2268
|
+
response = self.spotPrivatePostSupplementUserInfo(params)
|
1951
2269
|
#
|
1952
2270
|
# {
|
1953
2271
|
# "result": "true",
|
@@ -1986,7 +2304,7 @@ class lbank2(Exchange, ImplicitAPI):
|
|
1986
2304
|
# vast majority fees None
|
1987
2305
|
self.load_markets()
|
1988
2306
|
request = {}
|
1989
|
-
response = self.
|
2307
|
+
response = self.spotPublicGetWithdrawConfigs(self.extend(request, params))
|
1990
2308
|
#
|
1991
2309
|
# {
|
1992
2310
|
# result: 'true',
|
@@ -2119,9 +2437,12 @@ class lbank2(Exchange, ImplicitAPI):
|
|
2119
2437
|
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
|
2120
2438
|
query = self.omit(params, self.extract_params(path))
|
2121
2439
|
url = self.urls['api']['rest'] + '/' + self.version + '/' + self.implode_params(path, params)
|
2122
|
-
# Every endpoint ends with ".do"
|
2123
|
-
|
2124
|
-
|
2440
|
+
# Every spot endpoint ends with ".do"
|
2441
|
+
if api[0] == 'spot':
|
2442
|
+
url += '.do'
|
2443
|
+
else:
|
2444
|
+
url = self.urls['api']['contract'] + '/' + self.implode_params(path, params)
|
2445
|
+
if api[1] == 'public':
|
2125
2446
|
if query:
|
2126
2447
|
url += '?' + self.urlencode(self.keysort(query))
|
2127
2448
|
else:
|