ccxt 4.2.11 → 4.2.13
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.
- package/README.md +5 -5
- package/build.sh +2 -2
- package/dist/ccxt.browser.js +1347 -490
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/_virtual/agent.js +7 -0
- package/dist/cjs/_virtual/parse-proxy-response.js +7 -0
- package/dist/cjs/_virtual/promisify.js +7 -0
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/js/ccxt.js +474 -0
- package/dist/cjs/js/src/abstract/ace.js +9 -0
- package/dist/cjs/js/src/abstract/alpaca.js +9 -0
- package/dist/cjs/js/src/abstract/ascendex.js +9 -0
- package/dist/cjs/js/src/abstract/bigone.js +9 -0
- package/dist/cjs/js/src/abstract/binance.js +9 -0
- package/dist/cjs/js/src/abstract/bingx.js +9 -0
- package/dist/cjs/js/src/abstract/bit2c.js +9 -0
- package/dist/cjs/js/src/abstract/bitbank.js +9 -0
- package/dist/cjs/js/src/abstract/bitbns.js +9 -0
- package/dist/cjs/js/src/abstract/bitfinex.js +9 -0
- package/dist/cjs/js/src/abstract/bitfinex2.js +9 -0
- package/dist/cjs/js/src/abstract/bitflyer.js +9 -0
- package/dist/cjs/js/src/abstract/bitforex.js +9 -0
- package/dist/cjs/js/src/abstract/bitget.js +9 -0
- package/dist/cjs/js/src/abstract/bithumb.js +9 -0
- package/dist/cjs/js/src/abstract/bitmart.js +9 -0
- package/dist/cjs/js/src/abstract/bitmex.js +9 -0
- package/dist/cjs/js/src/abstract/bitopro.js +9 -0
- package/dist/cjs/js/src/abstract/bitpanda.js +9 -0
- package/dist/cjs/js/src/abstract/bitrue.js +9 -0
- package/dist/cjs/js/src/abstract/bitso.js +9 -0
- package/dist/cjs/js/src/abstract/bitstamp.js +9 -0
- package/dist/cjs/js/src/abstract/bitteam.js +9 -0
- package/dist/cjs/js/src/abstract/bitvavo.js +9 -0
- package/dist/cjs/js/src/abstract/bl3p.js +9 -0
- package/dist/cjs/js/src/abstract/blockchaincom.js +9 -0
- package/dist/cjs/js/src/abstract/btcalpha.js +9 -0
- package/dist/cjs/js/src/abstract/btcbox.js +9 -0
- package/dist/cjs/js/src/abstract/btcmarkets.js +9 -0
- package/dist/cjs/js/src/abstract/btcturk.js +9 -0
- package/dist/cjs/js/src/abstract/bybit.js +9 -0
- package/dist/cjs/js/src/abstract/cex.js +9 -0
- package/dist/cjs/js/src/abstract/coinbase.js +9 -0
- package/dist/cjs/js/src/abstract/coinbasepro.js +9 -0
- package/dist/cjs/js/src/abstract/coincheck.js +9 -0
- package/dist/cjs/js/src/abstract/coinex.js +9 -0
- package/dist/cjs/js/src/abstract/coinlist.js +9 -0
- package/dist/cjs/js/src/abstract/coinmate.js +9 -0
- package/dist/cjs/js/src/abstract/coinone.js +9 -0
- package/dist/cjs/js/src/abstract/coinsph.js +9 -0
- package/dist/cjs/js/src/abstract/coinspot.js +9 -0
- package/dist/cjs/js/src/abstract/cryptocom.js +9 -0
- package/dist/cjs/js/src/abstract/currencycom.js +9 -0
- package/dist/cjs/js/src/abstract/delta.js +9 -0
- package/dist/cjs/js/src/abstract/deribit.js +9 -0
- package/dist/cjs/js/src/abstract/digifinex.js +9 -0
- package/dist/cjs/js/src/abstract/exmo.js +9 -0
- package/dist/cjs/js/src/abstract/gate.js +9 -0
- package/dist/cjs/js/src/abstract/gemini.js +9 -0
- package/dist/cjs/js/src/abstract/hitbtc.js +9 -0
- package/dist/cjs/js/src/abstract/hollaex.js +9 -0
- package/dist/cjs/js/src/abstract/htx.js +9 -0
- package/dist/cjs/js/src/abstract/huobijp.js +9 -0
- package/dist/cjs/js/src/abstract/idex.js +9 -0
- package/dist/cjs/js/src/abstract/independentreserve.js +9 -0
- package/dist/cjs/js/src/abstract/indodax.js +9 -0
- package/dist/cjs/js/src/abstract/kraken.js +9 -0
- package/dist/cjs/js/src/abstract/krakenfutures.js +9 -0
- package/dist/cjs/js/src/abstract/kucoin.js +9 -0
- package/dist/cjs/js/src/abstract/kucoinfutures.js +9 -0
- package/dist/cjs/js/src/abstract/kuna.js +9 -0
- package/dist/cjs/js/src/abstract/latoken.js +9 -0
- package/dist/cjs/js/src/abstract/lbank.js +9 -0
- package/dist/cjs/js/src/abstract/luno.js +9 -0
- package/dist/cjs/js/src/abstract/lykke.js +9 -0
- package/dist/cjs/js/src/abstract/mercado.js +9 -0
- package/dist/cjs/js/src/abstract/mexc.js +9 -0
- package/dist/cjs/js/src/abstract/ndax.js +9 -0
- package/dist/cjs/js/src/abstract/novadax.js +9 -0
- package/dist/cjs/js/src/abstract/oceanex.js +9 -0
- package/dist/cjs/js/src/abstract/okcoin.js +9 -0
- package/dist/cjs/js/src/abstract/okx.js +9 -0
- package/dist/cjs/js/src/abstract/p2b.js +9 -0
- package/dist/cjs/js/src/abstract/paymium.js +9 -0
- package/dist/cjs/js/src/abstract/phemex.js +9 -0
- package/dist/cjs/js/src/abstract/poloniex.js +9 -0
- package/dist/cjs/js/src/abstract/poloniexfutures.js +9 -0
- package/dist/cjs/js/src/abstract/probit.js +9 -0
- package/dist/cjs/js/src/abstract/timex.js +9 -0
- package/dist/cjs/js/src/abstract/tokocrypto.js +9 -0
- package/dist/cjs/js/src/abstract/upbit.js +9 -0
- package/dist/cjs/js/src/abstract/wavesexchange.js +9 -0
- package/dist/cjs/js/src/abstract/wazirx.js +9 -0
- package/dist/cjs/js/src/abstract/whitebit.js +9 -0
- package/dist/cjs/js/src/abstract/woo.js +9 -0
- package/dist/cjs/js/src/abstract/yobit.js +9 -0
- package/dist/cjs/js/src/abstract/zaif.js +9 -0
- package/dist/cjs/js/src/abstract/zonda.js +9 -0
- package/dist/cjs/js/src/ace.js +1058 -0
- package/dist/cjs/js/src/alpaca.js +1125 -0
- package/dist/cjs/js/src/ascendex.js +3360 -0
- package/dist/cjs/js/src/base/Exchange.js +5110 -0
- package/dist/cjs/js/src/base/Precise.js +263 -0
- package/dist/cjs/js/src/base/errors.js +299 -0
- package/dist/cjs/js/src/base/functions/crypto.js +78 -0
- package/dist/cjs/js/src/base/functions/encode.js +44 -0
- package/dist/cjs/js/src/base/functions/generic.js +193 -0
- package/dist/cjs/js/src/base/functions/misc.js +96 -0
- package/dist/cjs/js/src/base/functions/number.js +297 -0
- package/dist/cjs/js/src/base/functions/platform.js +28 -0
- package/dist/cjs/js/src/base/functions/rsa.js +34 -0
- package/dist/cjs/js/src/base/functions/string.js +48 -0
- package/dist/cjs/js/src/base/functions/throttle.js +66 -0
- package/dist/cjs/js/src/base/functions/time.js +187 -0
- package/dist/cjs/js/src/base/functions/totp.js +24 -0
- package/dist/cjs/js/src/base/functions/type.js +162 -0
- package/dist/cjs/js/src/base/functions.js +157 -0
- package/dist/cjs/js/src/base/ws/Cache.js +254 -0
- package/dist/cjs/js/src/base/ws/Client.js +299 -0
- package/dist/cjs/js/src/base/ws/Future.js +34 -0
- package/dist/cjs/js/src/base/ws/OrderBook.js +107 -0
- package/dist/cjs/js/src/base/ws/OrderBookSide.js +281 -0
- package/dist/cjs/js/src/base/ws/WsClient.js +69 -0
- package/dist/cjs/js/src/bequant.js +33 -0
- package/dist/cjs/js/src/bigone.js +2209 -0
- package/dist/cjs/js/src/binance.js +9736 -0
- package/dist/cjs/js/src/binancecoinm.js +45 -0
- package/dist/cjs/js/src/binanceus.js +84 -0
- package/dist/cjs/js/src/binanceusdm.js +58 -0
- package/dist/cjs/js/src/bingx.js +3807 -0
- package/dist/cjs/js/src/bit2c.js +916 -0
- package/dist/cjs/js/src/bitbank.js +1000 -0
- package/dist/cjs/js/src/bitbay.js +17 -0
- package/dist/cjs/js/src/bitbns.js +1220 -0
- package/dist/cjs/js/src/bitcoincom.js +17 -0
- package/dist/cjs/js/src/bitfinex.js +1670 -0
- package/dist/cjs/js/src/bitfinex2.js +2990 -0
- package/dist/cjs/js/src/bitflyer.js +1045 -0
- package/dist/cjs/js/src/bitforex.js +852 -0
- package/dist/cjs/js/src/bitget.js +8291 -0
- package/dist/cjs/js/src/bithumb.js +1090 -0
- package/dist/cjs/js/src/bitmart.js +4454 -0
- package/dist/cjs/js/src/bitmex.js +2884 -0
- package/dist/cjs/js/src/bitopro.js +1724 -0
- package/dist/cjs/js/src/bitpanda.js +2002 -0
- package/dist/cjs/js/src/bitrue.js +3253 -0
- package/dist/cjs/js/src/bitso.js +1753 -0
- package/dist/cjs/js/src/bitstamp.js +2188 -0
- package/dist/cjs/js/src/bitteam.js +2309 -0
- package/dist/cjs/js/src/bitvavo.js +1968 -0
- package/dist/cjs/js/src/bl3p.js +447 -0
- package/dist/cjs/js/src/blockchaincom.js +1160 -0
- package/dist/cjs/js/src/btcalpha.js +929 -0
- package/dist/cjs/js/src/btcbox.js +565 -0
- package/dist/cjs/js/src/btcmarkets.js +1237 -0
- package/dist/cjs/js/src/btcturk.js +929 -0
- package/dist/cjs/js/src/bybit.js +7646 -0
- package/dist/cjs/js/src/cex.js +1693 -0
- package/dist/cjs/js/src/coinbase.js +3424 -0
- package/dist/cjs/js/src/coinbasepro.js +1866 -0
- package/dist/cjs/js/src/coincheck.js +843 -0
- package/dist/cjs/js/src/coinex.js +5414 -0
- package/dist/cjs/js/src/coinlist.js +2329 -0
- package/dist/cjs/js/src/coinmate.js +989 -0
- package/dist/cjs/js/src/coinone.js +1185 -0
- package/dist/cjs/js/src/coinsph.js +1933 -0
- package/dist/cjs/js/src/coinspot.js +548 -0
- package/dist/cjs/js/src/cryptocom.js +3007 -0
- package/dist/cjs/js/src/currencycom.js +2015 -0
- package/dist/cjs/js/src/delta.js +3256 -0
- package/dist/cjs/js/src/deribit.js +3306 -0
- package/dist/cjs/js/src/digifinex.js +4307 -0
- package/dist/cjs/js/src/exmo.js +2645 -0
- package/dist/cjs/js/src/fmfwio.js +34 -0
- package/dist/cjs/js/src/gate.js +7072 -0
- package/dist/cjs/js/src/gateio.js +16 -0
- package/dist/cjs/js/src/gemini.js +1801 -0
- package/dist/cjs/js/src/hitbtc.js +3660 -0
- package/dist/cjs/js/src/hitbtc3.js +19 -0
- package/dist/cjs/js/src/hollaex.js +1882 -0
- package/dist/cjs/js/src/htx.js +9049 -0
- package/dist/cjs/js/src/huobi.js +16 -0
- package/dist/cjs/js/src/huobijp.js +1918 -0
- package/dist/cjs/js/src/idex.js +1770 -0
- package/dist/cjs/js/src/independentreserve.js +761 -0
- package/dist/cjs/js/src/indodax.js +1069 -0
- package/dist/cjs/js/src/kraken.js +2857 -0
- package/dist/cjs/js/src/krakenfutures.js +2407 -0
- package/dist/cjs/js/src/kucoin.js +4489 -0
- package/dist/cjs/js/src/kucoinfutures.js +2475 -0
- package/dist/cjs/js/src/kuna.js +1949 -0
- package/dist/cjs/js/src/latoken.js +1729 -0
- package/dist/cjs/js/src/lbank.js +2851 -0
- package/dist/cjs/js/src/luno.js +1044 -0
- package/dist/cjs/js/src/lykke.js +1303 -0
- package/dist/cjs/js/src/mercado.js +897 -0
- package/dist/cjs/js/src/mexc.js +5407 -0
- package/dist/cjs/js/src/ndax.js +2450 -0
- package/dist/cjs/js/src/novadax.js +1556 -0
- package/dist/cjs/js/src/oceanex.js +964 -0
- package/dist/cjs/js/src/okcoin.js +3115 -0
- package/dist/cjs/js/src/okx.js +7330 -0
- package/dist/cjs/js/src/p2b.js +1243 -0
- package/dist/cjs/js/src/paymium.js +597 -0
- package/dist/cjs/js/src/phemex.js +4722 -0
- package/dist/cjs/js/src/poloniex.js +2356 -0
- package/dist/cjs/js/src/poloniexfutures.js +1794 -0
- package/dist/cjs/js/src/pro/alpaca.js +714 -0
- package/dist/cjs/js/src/pro/ascendex.js +957 -0
- package/dist/cjs/js/src/pro/bequant.js +33 -0
- package/dist/cjs/js/src/pro/binance.js +2796 -0
- package/dist/cjs/js/src/pro/binancecoinm.js +23 -0
- package/dist/cjs/js/src/pro/binanceus.js +51 -0
- package/dist/cjs/js/src/pro/binanceusdm.js +32 -0
- package/dist/cjs/js/src/pro/bingx.js +944 -0
- package/dist/cjs/js/src/pro/bitcoincom.js +29 -0
- package/dist/cjs/js/src/pro/bitfinex.js +672 -0
- package/dist/cjs/js/src/pro/bitfinex2.js +1159 -0
- package/dist/cjs/js/src/pro/bitget.js +1733 -0
- package/dist/cjs/js/src/pro/bitmart.js +1486 -0
- package/dist/cjs/js/src/pro/bitmex.js +1576 -0
- package/dist/cjs/js/src/pro/bitopro.js +327 -0
- package/dist/cjs/js/src/pro/bitpanda.js +1341 -0
- package/dist/cjs/js/src/pro/bitrue.js +462 -0
- package/dist/cjs/js/src/pro/bitstamp.js +547 -0
- package/dist/cjs/js/src/pro/bitvavo.js +704 -0
- package/dist/cjs/js/src/pro/blockchaincom.js +794 -0
- package/dist/cjs/js/src/pro/bybit.js +1843 -0
- package/dist/cjs/js/src/pro/cex.js +1510 -0
- package/dist/cjs/js/src/pro/coinbase.js +561 -0
- package/dist/cjs/js/src/pro/coinbasepro.js +968 -0
- package/dist/cjs/js/src/pro/coinex.js +1095 -0
- package/dist/cjs/js/src/pro/cryptocom.js +1020 -0
- package/dist/cjs/js/src/pro/currencycom.js +563 -0
- package/dist/cjs/js/src/pro/deribit.js +825 -0
- package/dist/cjs/js/src/pro/exmo.js +658 -0
- package/dist/cjs/js/src/pro/gate.js +1316 -0
- package/dist/cjs/js/src/pro/gateio.js +16 -0
- package/dist/cjs/js/src/pro/gemini.js +649 -0
- package/dist/cjs/js/src/pro/hitbtc.js +1293 -0
- package/dist/cjs/js/src/pro/hollaex.js +597 -0
- package/dist/cjs/js/src/pro/htx.js +2383 -0
- package/dist/cjs/js/src/pro/huobi.js +16 -0
- package/dist/cjs/js/src/pro/huobijp.js +606 -0
- package/dist/cjs/js/src/pro/idex.js +714 -0
- package/dist/cjs/js/src/pro/independentreserve.js +280 -0
- package/dist/cjs/js/src/pro/kraken.js +1364 -0
- package/dist/cjs/js/src/pro/krakenfutures.js +1500 -0
- package/dist/cjs/js/src/pro/kucoin.js +1052 -0
- package/dist/cjs/js/src/pro/kucoinfutures.js +981 -0
- package/dist/cjs/js/src/pro/luno.js +322 -0
- package/dist/cjs/js/src/pro/mexc.js +1170 -0
- package/dist/cjs/js/src/pro/ndax.js +545 -0
- package/dist/cjs/js/src/pro/okcoin.js +760 -0
- package/dist/cjs/js/src/pro/okx.js +1608 -0
- package/dist/cjs/js/src/pro/phemex.js +1511 -0
- package/dist/cjs/js/src/pro/poloniex.js +1253 -0
- package/dist/cjs/js/src/pro/poloniexfutures.js +1014 -0
- package/dist/cjs/js/src/pro/probit.js +586 -0
- package/dist/cjs/js/src/pro/upbit.js +234 -0
- package/dist/cjs/js/src/pro/wazirx.js +776 -0
- package/dist/cjs/js/src/pro/whitebit.js +927 -0
- package/dist/cjs/js/src/pro/woo.js +769 -0
- package/dist/cjs/js/src/probit.js +1867 -0
- package/dist/cjs/js/src/static_dependencies/fflake/browser.js +401 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncrypt.js +195 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +308 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +554 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +94 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +70 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +91 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +16 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +1760 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +52 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +81 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +376 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +70 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +1580 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +74 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/_shortw_utils.js +24 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/curve.js +158 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/edwards.js +429 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +176 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/modular.js +324 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/montgomery.js +163 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/utils.js +245 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +1018 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/ed25519.js +383 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/secp256k1.js +258 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/_assert.js +53 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/_sha2.js +120 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/_u64.js +69 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/crypto.js +7 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/hmac.js +83 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/md5.js +240 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha1.js +91 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha256.js +130 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha3.js +214 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha512.js +239 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/utils.js +93 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/body.js +354 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/errors/abort-error.js +16 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/errors/base.js +20 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/errors/fetch-error.js +30 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/headers.js +239 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/index.js +372 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/request.js +273 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/response.js +139 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/get-search.js +14 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is-redirect.js +16 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is.js +81 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/referrer.js +292 -0
- package/dist/cjs/js/src/static_dependencies/proxies/agent-base/index.js +103 -0
- package/dist/cjs/js/src/static_dependencies/proxies/http-proxy-agent/index.js +140 -0
- package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/index.js +175 -0
- package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +95 -0
- package/dist/cjs/js/src/static_dependencies/qs/index.cjs.js +7 -0
- package/dist/cjs/js/src/static_dependencies/scure-base/index.js +383 -0
- package/dist/cjs/js/src/timex.js +1562 -0
- package/dist/cjs/js/src/tokocrypto.js +2542 -0
- package/dist/cjs/js/src/upbit.js +1844 -0
- package/dist/cjs/js/src/wavesexchange.js +2607 -0
- package/dist/cjs/js/src/wazirx.js +953 -0
- package/dist/cjs/js/src/whitebit.js +2309 -0
- package/dist/cjs/js/src/woo.js +2765 -0
- package/dist/cjs/js/src/yobit.js +1314 -0
- package/dist/cjs/js/src/zaif.js +736 -0
- package/dist/cjs/js/src/zonda.js +1883 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bigone.d.ts +18 -0
- package/js/src/abstract/binance.d.ts +2 -0
- package/js/src/abstract/binancecoinm.d.ts +2 -0
- package/js/src/abstract/binanceus.d.ts +2 -0
- package/js/src/abstract/binanceusdm.d.ts +2 -0
- package/js/src/abstract/bingx.d.ts +2 -0
- package/js/src/abstract/bybit.d.ts +1 -0
- package/js/src/abstract/gate.d.ts +11 -0
- package/js/src/abstract/gateio.d.ts +11 -0
- package/js/src/abstract/okx.d.ts +1 -0
- package/js/src/alpaca.js +18 -18
- package/js/src/base/Exchange.d.ts +5 -1
- package/js/src/base/Exchange.js +101 -12
- package/js/src/bigone.d.ts +3 -2
- package/js/src/bigone.js +429 -167
- package/js/src/binance.js +48 -34
- package/js/src/bingx.js +115 -38
- package/js/src/bitfinex.d.ts +2 -2
- package/js/src/bitfinex.js +2 -3
- package/js/src/bitget.js +33 -13
- package/js/src/bitmart.d.ts +2 -2
- package/js/src/bitmart.js +5 -5
- package/js/src/bitmex.js +1 -0
- package/js/src/bybit.js +2 -0
- package/js/src/coinbase.d.ts +26 -3
- package/js/src/coinbase.js +176 -26
- package/js/src/coinlist.js +3 -4
- package/js/src/coinone.js +1 -1
- package/js/src/coinsph.js +2 -3
- package/js/src/deribit.js +1 -0
- package/js/src/gate.d.ts +4 -4
- package/js/src/gate.js +96 -59
- package/js/src/gemini.js +1 -1
- package/js/src/hitbtc.d.ts +4 -4
- package/js/src/hitbtc.js +2 -3
- package/js/src/htx.d.ts +1 -0
- package/js/src/htx.js +29 -7
- package/js/src/huobijp.js +2 -3
- package/js/src/independentreserve.js +7 -5
- package/js/src/kraken.js +3 -6
- package/js/src/lbank.js +59 -33
- package/js/src/mexc.js +2 -1
- package/js/src/oceanex.js +1 -1
- package/js/src/okx.js +14 -3
- package/js/src/phemex.js +9 -2
- package/js/src/pro/binance.d.ts +2 -23
- package/js/src/pro/binance.js +58 -22
- package/js/src/pro/coinbase.d.ts +2 -2
- package/js/src/pro/coinbase.js +4 -1
- package/js/src/pro/coinbasepro.d.ts +2 -2
- package/js/src/pro/hitbtc.d.ts +2 -2
- package/js/src/pro/kraken.js +1 -1
- package/js/src/pro/okx.d.ts +1 -0
- package/js/src/pro/okx.js +52 -2
- package/js/src/pro/poloniex.d.ts +2 -2
- package/js/src/probit.js +4 -2
- package/js/src/upbit.d.ts +3 -101
- package/js/src/upbit.js +12 -12
- package/js/src/wavesexchange.js +1 -1
- package/js/src/woo.d.ts +2 -0
- package/js/src/woo.js +52 -0
- package/package.json +1 -1
- package/skip-tests.json +5 -0
|
@@ -0,0 +1,2851 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var lbank$1 = require('./abstract/lbank.js');
|
|
4
|
+
var errors = require('./base/errors.js');
|
|
5
|
+
var number = require('./base/functions/number.js');
|
|
6
|
+
var Precise = require('./base/Precise.js');
|
|
7
|
+
var md5 = require('./static_dependencies/noble-hashes/md5.js');
|
|
8
|
+
var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
|
|
9
|
+
var rsa = require('./base/functions/rsa.js');
|
|
10
|
+
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
/**
|
|
14
|
+
* @class lbank2
|
|
15
|
+
* @augments Exchange
|
|
16
|
+
*/
|
|
17
|
+
class lbank extends lbank$1 {
|
|
18
|
+
describe() {
|
|
19
|
+
return this.deepExtend(super.describe(), {
|
|
20
|
+
'id': 'lbank',
|
|
21
|
+
'name': 'LBank',
|
|
22
|
+
'countries': ['CN'],
|
|
23
|
+
'version': 'v2',
|
|
24
|
+
// 50 per second for making and cancelling orders 1000ms / 50 = 20
|
|
25
|
+
// 20 per second for all other requests, cost = 50 / 20 = 2.5
|
|
26
|
+
'rateLimit': 20,
|
|
27
|
+
'has': {
|
|
28
|
+
'CORS': false,
|
|
29
|
+
'spot': true,
|
|
30
|
+
'margin': false,
|
|
31
|
+
'swap': undefined,
|
|
32
|
+
'future': false,
|
|
33
|
+
'option': false,
|
|
34
|
+
'addMargin': false,
|
|
35
|
+
'cancelAllOrders': true,
|
|
36
|
+
'cancelOrder': true,
|
|
37
|
+
'createMarketBuyOrderWithCost': true,
|
|
38
|
+
'createMarketOrderWithCost': false,
|
|
39
|
+
'createMarketSellOrderWithCost': false,
|
|
40
|
+
'createOrder': true,
|
|
41
|
+
'createReduceOnlyOrder': false,
|
|
42
|
+
'createStopLimitOrder': false,
|
|
43
|
+
'createStopMarketOrder': false,
|
|
44
|
+
'createStopOrder': false,
|
|
45
|
+
'fetchBalance': true,
|
|
46
|
+
'fetchBorrowRateHistories': false,
|
|
47
|
+
'fetchBorrowRateHistory': false,
|
|
48
|
+
'fetchClosedOrders': false,
|
|
49
|
+
'fetchCrossBorrowRate': false,
|
|
50
|
+
'fetchCrossBorrowRates': false,
|
|
51
|
+
'fetchDepositWithdrawFee': 'emulated',
|
|
52
|
+
'fetchDepositWithdrawFees': true,
|
|
53
|
+
'fetchFundingHistory': false,
|
|
54
|
+
'fetchFundingRate': false,
|
|
55
|
+
'fetchFundingRateHistory': false,
|
|
56
|
+
'fetchFundingRates': false,
|
|
57
|
+
'fetchIndexOHLCV': false,
|
|
58
|
+
'fetchIsolatedBorrowRate': false,
|
|
59
|
+
'fetchIsolatedBorrowRates': false,
|
|
60
|
+
'fetchIsolatedPositions': false,
|
|
61
|
+
'fetchLeverage': false,
|
|
62
|
+
'fetchLeverageTiers': false,
|
|
63
|
+
'fetchMarginMode': false,
|
|
64
|
+
'fetchMarkets': true,
|
|
65
|
+
'fetchMarkOHLCV': false,
|
|
66
|
+
'fetchMyTrades': true,
|
|
67
|
+
'fetchOHLCV': true,
|
|
68
|
+
'fetchOpenOrders': true,
|
|
69
|
+
'fetchOrder': true,
|
|
70
|
+
'fetchOrderBook': true,
|
|
71
|
+
'fetchOrders': true,
|
|
72
|
+
'fetchPosition': false,
|
|
73
|
+
'fetchPositionMode': false,
|
|
74
|
+
'fetchPositions': false,
|
|
75
|
+
'fetchPositionsRisk': false,
|
|
76
|
+
'fetchPremiumIndexOHLCV': false,
|
|
77
|
+
'fetchTicker': true,
|
|
78
|
+
'fetchTickers': true,
|
|
79
|
+
'fetchTime': true,
|
|
80
|
+
'fetchTrades': true,
|
|
81
|
+
'fetchTradingFees': true,
|
|
82
|
+
'fetchTransactionFees': true,
|
|
83
|
+
'reduceMargin': false,
|
|
84
|
+
'setLeverage': false,
|
|
85
|
+
'setMarginMode': false,
|
|
86
|
+
'setPositionMode': false,
|
|
87
|
+
'withdraw': true,
|
|
88
|
+
},
|
|
89
|
+
'timeframes': {
|
|
90
|
+
'1m': 'minute1',
|
|
91
|
+
'5m': 'minute5',
|
|
92
|
+
'15m': 'minute15',
|
|
93
|
+
'30m': 'minute30',
|
|
94
|
+
'1h': 'hour1',
|
|
95
|
+
'2h': 'hour2',
|
|
96
|
+
'4h': 'hour4',
|
|
97
|
+
'6h': 'hour6',
|
|
98
|
+
'8h': 'hour8',
|
|
99
|
+
'12h': 'hour12',
|
|
100
|
+
'1d': 'day1',
|
|
101
|
+
'1w': 'week1',
|
|
102
|
+
},
|
|
103
|
+
'urls': {
|
|
104
|
+
'logo': 'https://user-images.githubusercontent.com/1294454/38063602-9605e28a-3302-11e8-81be-64b1e53c4cfb.jpg',
|
|
105
|
+
'api': {
|
|
106
|
+
'rest': 'https://api.lbank.info',
|
|
107
|
+
'contract': 'https://lbkperp.lbank.com',
|
|
108
|
+
},
|
|
109
|
+
'api2': 'https://api.lbkex.com',
|
|
110
|
+
'www': 'https://www.lbank.com',
|
|
111
|
+
'doc': 'https://www.lbank.com/en-US/docs/index.html',
|
|
112
|
+
'fees': 'https://support.lbank.site/hc/en-gb/articles/900000535703-Trading-Fees-From-14-00-on-April-7-2020-UTC-8-',
|
|
113
|
+
'referral': 'https://www.lbank.com/login/?icode=7QCY',
|
|
114
|
+
},
|
|
115
|
+
'api': {
|
|
116
|
+
'spot': {
|
|
117
|
+
'public': {
|
|
118
|
+
'get': {
|
|
119
|
+
'currencyPairs': 2.5,
|
|
120
|
+
'accuracy': 2.5,
|
|
121
|
+
'usdToCny': 2.5,
|
|
122
|
+
'withdrawConfigs': 2.5,
|
|
123
|
+
'timestamp': 2.5,
|
|
124
|
+
'ticker/24hr': 2.5,
|
|
125
|
+
'ticker': 2.5,
|
|
126
|
+
'depth': 2.5,
|
|
127
|
+
'incrDepth': 2.5,
|
|
128
|
+
'trades': 2.5,
|
|
129
|
+
'kline': 2.5,
|
|
130
|
+
// new quote endpoints
|
|
131
|
+
'supplement/system_ping': 2.5,
|
|
132
|
+
'supplement/incrDepth': 2.5,
|
|
133
|
+
'supplement/trades': 2.5,
|
|
134
|
+
'supplement/ticker/price': 2.5,
|
|
135
|
+
'supplement/ticker/bookTicker': 2.5,
|
|
136
|
+
},
|
|
137
|
+
'post': {
|
|
138
|
+
'supplement/system_status': 2.5,
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
'private': {
|
|
142
|
+
'post': {
|
|
143
|
+
// account
|
|
144
|
+
'user_info': 2.5,
|
|
145
|
+
'subscribe/get_key': 2.5,
|
|
146
|
+
'subscribe/refresh_key': 2.5,
|
|
147
|
+
'subscribe/destroy_key': 2.5,
|
|
148
|
+
'get_deposit_address': 2.5,
|
|
149
|
+
'deposit_history': 2.5,
|
|
150
|
+
// order
|
|
151
|
+
'create_order': 1,
|
|
152
|
+
'batch_create_order': 1,
|
|
153
|
+
'cancel_order': 1,
|
|
154
|
+
'cancel_clientOrders': 1,
|
|
155
|
+
'orders_info': 2.5,
|
|
156
|
+
'orders_info_history': 2.5,
|
|
157
|
+
'order_transaction_detail': 2.5,
|
|
158
|
+
'transaction_history': 2.5,
|
|
159
|
+
'orders_info_no_deal': 2.5,
|
|
160
|
+
// withdraw
|
|
161
|
+
'withdraw': 2.5,
|
|
162
|
+
'withdrawCancel': 2.5,
|
|
163
|
+
'withdraws': 2.5,
|
|
164
|
+
'supplement/user_info': 2.5,
|
|
165
|
+
'supplement/withdraw': 2.5,
|
|
166
|
+
'supplement/deposit_history': 2.5,
|
|
167
|
+
'supplement/withdraws': 2.5,
|
|
168
|
+
'supplement/get_deposit_address': 2.5,
|
|
169
|
+
'supplement/asset_detail': 2.5,
|
|
170
|
+
'supplement/customer_trade_fee': 2.5,
|
|
171
|
+
'supplement/api_Restrictions': 2.5,
|
|
172
|
+
// new quote endpoints
|
|
173
|
+
'supplement/system_ping': 2.5,
|
|
174
|
+
// new order endpoints
|
|
175
|
+
'supplement/create_order_test': 1,
|
|
176
|
+
'supplement/create_order': 1,
|
|
177
|
+
'supplement/cancel_order': 1,
|
|
178
|
+
'supplement/cancel_order_by_symbol': 1,
|
|
179
|
+
'supplement/orders_info': 2.5,
|
|
180
|
+
'supplement/orders_info_no_deal': 2.5,
|
|
181
|
+
'supplement/orders_info_history': 2.5,
|
|
182
|
+
'supplement/user_info_account': 2.5,
|
|
183
|
+
'supplement/transaction_history': 2.5,
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
'contract': {
|
|
188
|
+
'public': {
|
|
189
|
+
'get': {
|
|
190
|
+
'cfd/openApi/v1/pub/getTime': 2.5,
|
|
191
|
+
'cfd/openApi/v1/pub/instrument': 2.5,
|
|
192
|
+
'cfd/openApi/v1/pub/marketData': 2.5,
|
|
193
|
+
'cfd/openApi/v1/pub/marketOrder': 2.5,
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
'fees': {
|
|
199
|
+
'trading': {
|
|
200
|
+
'maker': this.parseNumber('0.001'),
|
|
201
|
+
'taker': this.parseNumber('0.001'),
|
|
202
|
+
},
|
|
203
|
+
'funding': {
|
|
204
|
+
'withdraw': {},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
'commonCurrencies': {
|
|
208
|
+
'VET_ERC20': 'VEN',
|
|
209
|
+
'PNT': 'Penta',
|
|
210
|
+
},
|
|
211
|
+
'precisionMode': number.TICK_SIZE,
|
|
212
|
+
'options': {
|
|
213
|
+
'cacheSecretAsPem': true,
|
|
214
|
+
'createMarketBuyOrderRequiresPrice': true,
|
|
215
|
+
'fetchTrades': {
|
|
216
|
+
'method': 'spotPublicGetTrades', // or 'spotPublicGetTradesSupplement'
|
|
217
|
+
},
|
|
218
|
+
'fetchTransactionFees': {
|
|
219
|
+
'method': 'fetchPrivateTransactionFees', // or 'fetchPublicTransactionFees'
|
|
220
|
+
},
|
|
221
|
+
'fetchDepositWithdrawFees': {
|
|
222
|
+
'method': 'fetchPrivateDepositWithdrawFees', // or 'fetchPublicDepositWithdrawFees'
|
|
223
|
+
},
|
|
224
|
+
'fetchDepositAddress': {
|
|
225
|
+
'method': 'fetchDepositAddressDefault', // or fetchDepositAddressSupplement
|
|
226
|
+
},
|
|
227
|
+
'createOrder': {
|
|
228
|
+
'method': 'spotPrivatePostSupplementCreateOrder', // or spotPrivatePostCreateOrder
|
|
229
|
+
},
|
|
230
|
+
'fetchOrder': {
|
|
231
|
+
'method': 'fetchOrderSupplement', // or fetchOrderDefault
|
|
232
|
+
},
|
|
233
|
+
'fetchBalance': {
|
|
234
|
+
'method': 'spotPrivatePostSupplementUserInfo', // or spotPrivatePostSupplementUserInfoAccount or spotPrivatePostUserInfo
|
|
235
|
+
},
|
|
236
|
+
'networks': {
|
|
237
|
+
'ERC20': 'erc20',
|
|
238
|
+
'ETH': 'erc20',
|
|
239
|
+
'TRC20': 'trc20',
|
|
240
|
+
'TRX': 'trc20',
|
|
241
|
+
'OMNI': 'omni',
|
|
242
|
+
'ASA': 'asa',
|
|
243
|
+
'BEP20': 'bep20(bsc)',
|
|
244
|
+
'BSC': 'bep20(bsc)',
|
|
245
|
+
'HT': 'heco',
|
|
246
|
+
'BNB': 'bep2',
|
|
247
|
+
'BTC': 'btc',
|
|
248
|
+
'DOGE': 'dogecoin',
|
|
249
|
+
'MATIC': 'matic',
|
|
250
|
+
'POLYGON': 'matic',
|
|
251
|
+
'OEC': 'oec',
|
|
252
|
+
'BTCTRON': 'btctron',
|
|
253
|
+
'XRP': 'xrp',
|
|
254
|
+
// other unusual chains with number of listed currencies supported
|
|
255
|
+
// 'avax c-chain': 1,
|
|
256
|
+
// klay: 12,
|
|
257
|
+
// bta: 1,
|
|
258
|
+
// fantom: 1,
|
|
259
|
+
// celo: 1,
|
|
260
|
+
// sol: 2,
|
|
261
|
+
// zenith: 1,
|
|
262
|
+
// ftm: 5,
|
|
263
|
+
// bep20: 1, (single token with mis-named chain) SSS
|
|
264
|
+
// bitci: 1,
|
|
265
|
+
// sgb: 1,
|
|
266
|
+
// moonbeam: 1,
|
|
267
|
+
// ekta: 1,
|
|
268
|
+
// etl: 1,
|
|
269
|
+
// arbitrum: 1,
|
|
270
|
+
// tpc: 1,
|
|
271
|
+
// ptx: 1
|
|
272
|
+
// }
|
|
273
|
+
},
|
|
274
|
+
'inverse-networks': {
|
|
275
|
+
'erc20': 'ERC20',
|
|
276
|
+
'trc20': 'TRC20',
|
|
277
|
+
'omni': 'OMNI',
|
|
278
|
+
'asa': 'ASA',
|
|
279
|
+
'bep20(bsc)': 'BSC',
|
|
280
|
+
'bep20': 'BSC',
|
|
281
|
+
'heco': 'HT',
|
|
282
|
+
'bep2': 'BNB',
|
|
283
|
+
'btc': 'BTC',
|
|
284
|
+
'dogecoin': 'DOGE',
|
|
285
|
+
'matic': 'MATIC',
|
|
286
|
+
'oec': 'OEC',
|
|
287
|
+
'btctron': 'BTCTRON',
|
|
288
|
+
'xrp': 'XRP',
|
|
289
|
+
},
|
|
290
|
+
'defaultNetworks': {
|
|
291
|
+
'USDT': 'TRC20',
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
async fetchTime(params = {}) {
|
|
297
|
+
/**
|
|
298
|
+
* @method
|
|
299
|
+
* @name lbank2#fetchTime
|
|
300
|
+
* @description fetches the current integer timestamp in milliseconds from the exchange server
|
|
301
|
+
* @see https://www.lbank.com/en-US/docs/index.html#get-timestamp
|
|
302
|
+
* @see https://www.lbank.com/en-US/docs/contract.html#get-the-current-time
|
|
303
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
304
|
+
* @returns {int} the current integer timestamp in milliseconds from the exchange server
|
|
305
|
+
*/
|
|
306
|
+
let type = undefined;
|
|
307
|
+
[type, params] = this.handleMarketTypeAndParams('fetchTime', undefined, params);
|
|
308
|
+
let response = undefined;
|
|
309
|
+
if (type === 'swap') {
|
|
310
|
+
response = await this.contractPublicGetCfdOpenApiV1PubGetTime(params);
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
response = await this.spotPublicGetTimestamp(params);
|
|
314
|
+
}
|
|
315
|
+
//
|
|
316
|
+
// spot
|
|
317
|
+
//
|
|
318
|
+
// {
|
|
319
|
+
// "result": "true",
|
|
320
|
+
// "data": 1691789627950,
|
|
321
|
+
// "error_code": 0,
|
|
322
|
+
// "ts": 1691789627950
|
|
323
|
+
// }
|
|
324
|
+
//
|
|
325
|
+
// swap
|
|
326
|
+
//
|
|
327
|
+
// {
|
|
328
|
+
// "data": 1691789627950,
|
|
329
|
+
// "error_code": 0,
|
|
330
|
+
// "msg": "Success",
|
|
331
|
+
// "result": "true",
|
|
332
|
+
// "success": true
|
|
333
|
+
// }
|
|
334
|
+
//
|
|
335
|
+
return this.safeInteger(response, 'data');
|
|
336
|
+
}
|
|
337
|
+
async fetchMarkets(params = {}) {
|
|
338
|
+
/**
|
|
339
|
+
* @method
|
|
340
|
+
* @name lbank2#fetchMarkets
|
|
341
|
+
* @description retrieves data on all markets for lbank2
|
|
342
|
+
* @see https://www.lbank.com/en-US/docs/index.html#trading-pairs
|
|
343
|
+
* @see https://www.lbank.com/en-US/docs/contract.html#query-contract-information-list
|
|
344
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
345
|
+
* @returns {object[]} an array of objects representing market data
|
|
346
|
+
*/
|
|
347
|
+
const marketsPromises = [
|
|
348
|
+
this.fetchSpotMarkets(params),
|
|
349
|
+
this.fetchSwapMarkets(params),
|
|
350
|
+
];
|
|
351
|
+
const resolvedMarkets = await Promise.all(marketsPromises);
|
|
352
|
+
return this.arrayConcat(resolvedMarkets[0], resolvedMarkets[1]);
|
|
353
|
+
}
|
|
354
|
+
async fetchSpotMarkets(params = {}) {
|
|
355
|
+
const response = await this.spotPublicGetAccuracy(params);
|
|
356
|
+
//
|
|
357
|
+
// {
|
|
358
|
+
// "result": "true",
|
|
359
|
+
// "data": [
|
|
360
|
+
// {
|
|
361
|
+
// "symbol": "btc_usdt",
|
|
362
|
+
// "quantityAccuracy": "4",
|
|
363
|
+
// "minTranQua": "0.0001",
|
|
364
|
+
// "priceAccuracy": "2"
|
|
365
|
+
// },
|
|
366
|
+
// ],
|
|
367
|
+
// "error_code": 0,
|
|
368
|
+
// "ts": 1691560288484
|
|
369
|
+
// }
|
|
370
|
+
//
|
|
371
|
+
const data = this.safeValue(response, 'data', []);
|
|
372
|
+
const result = [];
|
|
373
|
+
for (let i = 0; i < data.length; i++) {
|
|
374
|
+
const market = data[i];
|
|
375
|
+
const marketId = this.safeString(market, 'symbol');
|
|
376
|
+
const parts = marketId.split('_');
|
|
377
|
+
const baseId = parts[0];
|
|
378
|
+
const quoteId = parts[1];
|
|
379
|
+
const base = this.safeCurrencyCode(baseId);
|
|
380
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
381
|
+
const symbol = base + '/' + quote;
|
|
382
|
+
result.push({
|
|
383
|
+
'id': marketId,
|
|
384
|
+
'symbol': symbol,
|
|
385
|
+
'base': base,
|
|
386
|
+
'quote': quote,
|
|
387
|
+
'baseId': baseId,
|
|
388
|
+
'quoteId': quoteId,
|
|
389
|
+
'settle': undefined,
|
|
390
|
+
'settleId': undefined,
|
|
391
|
+
'type': 'spot',
|
|
392
|
+
'spot': true,
|
|
393
|
+
'margin': false,
|
|
394
|
+
'swap': false,
|
|
395
|
+
'future': false,
|
|
396
|
+
'option': false,
|
|
397
|
+
'active': true,
|
|
398
|
+
'contract': false,
|
|
399
|
+
'linear': undefined,
|
|
400
|
+
'inverse': undefined,
|
|
401
|
+
'contractSize': undefined,
|
|
402
|
+
'expiry': undefined,
|
|
403
|
+
'expiryDatetime': undefined,
|
|
404
|
+
'strike': undefined,
|
|
405
|
+
'optionType': undefined,
|
|
406
|
+
'precision': {
|
|
407
|
+
'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'quantityAccuracy'))),
|
|
408
|
+
'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'priceAccuracy'))),
|
|
409
|
+
},
|
|
410
|
+
'limits': {
|
|
411
|
+
'leverage': {
|
|
412
|
+
'min': undefined,
|
|
413
|
+
'max': undefined,
|
|
414
|
+
},
|
|
415
|
+
'amount': {
|
|
416
|
+
'min': this.safeNumber(market, 'minTranQua'),
|
|
417
|
+
'max': undefined,
|
|
418
|
+
},
|
|
419
|
+
'price': {
|
|
420
|
+
'min': undefined,
|
|
421
|
+
'max': undefined,
|
|
422
|
+
},
|
|
423
|
+
'cost': {
|
|
424
|
+
'min': undefined,
|
|
425
|
+
'max': undefined,
|
|
426
|
+
},
|
|
427
|
+
},
|
|
428
|
+
'created': undefined,
|
|
429
|
+
'info': market,
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
return result;
|
|
433
|
+
}
|
|
434
|
+
async fetchSwapMarkets(params = {}) {
|
|
435
|
+
const request = {
|
|
436
|
+
'productGroup': 'SwapU',
|
|
437
|
+
};
|
|
438
|
+
const response = await this.contractPublicGetCfdOpenApiV1PubInstrument(this.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
|
+
const data = this.safeValue(response, 'data', []);
|
|
468
|
+
const result = [];
|
|
469
|
+
for (let i = 0; i < data.length; i++) {
|
|
470
|
+
const market = data[i];
|
|
471
|
+
const marketId = this.safeString(market, 'symbol');
|
|
472
|
+
const baseId = this.safeString(market, 'baseCurrency');
|
|
473
|
+
const settleId = this.safeString(market, 'clearCurrency');
|
|
474
|
+
const quoteId = settleId;
|
|
475
|
+
const base = this.safeCurrencyCode(baseId);
|
|
476
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
477
|
+
const settle = this.safeCurrencyCode(settleId);
|
|
478
|
+
const symbol = base + '/' + quote + ':' + settle;
|
|
479
|
+
result.push({
|
|
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': undefined,
|
|
498
|
+
'contractSize': this.safeNumber(market, 'volumeMultiple'),
|
|
499
|
+
'expiry': undefined,
|
|
500
|
+
'expiryDatetime': undefined,
|
|
501
|
+
'strike': undefined,
|
|
502
|
+
'optionType': undefined,
|
|
503
|
+
'precision': {
|
|
504
|
+
'amount': this.safeNumber(market, 'volumeTick'),
|
|
505
|
+
'price': this.safeNumber(market, 'priceTick'),
|
|
506
|
+
},
|
|
507
|
+
'limits': {
|
|
508
|
+
'leverage': {
|
|
509
|
+
'min': undefined,
|
|
510
|
+
'max': undefined,
|
|
511
|
+
},
|
|
512
|
+
'amount': {
|
|
513
|
+
'min': this.safeNumber(market, 'minOrderVolume'),
|
|
514
|
+
'max': this.safeNumber(market, 'maxOrderVolume'),
|
|
515
|
+
},
|
|
516
|
+
'price': {
|
|
517
|
+
'min': this.safeNumber(market, 'priceLimitLowerValue'),
|
|
518
|
+
'max': this.safeNumber(market, 'priceLimitUpperValue'),
|
|
519
|
+
},
|
|
520
|
+
'cost': {
|
|
521
|
+
'min': this.safeNumber(market, 'minOrderCost'),
|
|
522
|
+
'max': undefined,
|
|
523
|
+
},
|
|
524
|
+
},
|
|
525
|
+
'created': undefined,
|
|
526
|
+
'info': market,
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
return result;
|
|
530
|
+
}
|
|
531
|
+
parseTicker(ticker, market = undefined) {
|
|
532
|
+
//
|
|
533
|
+
// spot: fetchTicker, fetchTickers
|
|
534
|
+
//
|
|
535
|
+
// {
|
|
536
|
+
// "symbol": "btc_usdt",
|
|
537
|
+
// "ticker": {
|
|
538
|
+
// "high": "29695.57",
|
|
539
|
+
// "vol": "6890.2789",
|
|
540
|
+
// "low": "29110",
|
|
541
|
+
// "change": "0.58",
|
|
542
|
+
// "turnover": "202769821.06",
|
|
543
|
+
// "latest": "29405.98"
|
|
544
|
+
// },
|
|
545
|
+
// "timestamp": :1692064274908
|
|
546
|
+
// }
|
|
547
|
+
//
|
|
548
|
+
// swap: fetchTickers
|
|
549
|
+
//
|
|
550
|
+
// {
|
|
551
|
+
// "prePositionFeeRate": "0.000053",
|
|
552
|
+
// "volume": "2435.459",
|
|
553
|
+
// "symbol": "BTCUSDT",
|
|
554
|
+
// "highestPrice": "29446.5",
|
|
555
|
+
// "lowestPrice": "29362.9",
|
|
556
|
+
// "openPrice": "29419.5",
|
|
557
|
+
// "markedPrice": "29385.1",
|
|
558
|
+
// "turnover": "36345526.2438402",
|
|
559
|
+
// "lastPrice": "29387.0"
|
|
560
|
+
// }
|
|
561
|
+
//
|
|
562
|
+
const timestamp = this.safeInteger(ticker, 'timestamp');
|
|
563
|
+
const marketId = this.safeString(ticker, 'symbol');
|
|
564
|
+
const symbol = this.safeSymbol(marketId, market);
|
|
565
|
+
const tickerData = this.safeValue(ticker, 'ticker', {});
|
|
566
|
+
market = this.safeMarket(marketId, market);
|
|
567
|
+
const data = (market['contract']) ? ticker : tickerData;
|
|
568
|
+
return this.safeTicker({
|
|
569
|
+
'symbol': symbol,
|
|
570
|
+
'timestamp': timestamp,
|
|
571
|
+
'datetime': this.iso8601(timestamp),
|
|
572
|
+
'high': this.safeString2(data, 'high', 'highestPrice'),
|
|
573
|
+
'low': this.safeString2(data, 'low', 'lowestPrice'),
|
|
574
|
+
'bid': undefined,
|
|
575
|
+
'bidVolume': undefined,
|
|
576
|
+
'ask': undefined,
|
|
577
|
+
'askVolume': undefined,
|
|
578
|
+
'vwap': undefined,
|
|
579
|
+
'open': this.safeString(data, 'openPrice'),
|
|
580
|
+
'close': undefined,
|
|
581
|
+
'last': this.safeString2(data, 'latest', 'lastPrice'),
|
|
582
|
+
'previousClose': undefined,
|
|
583
|
+
'change': undefined,
|
|
584
|
+
'percentage': this.safeString(data, 'change'),
|
|
585
|
+
'average': undefined,
|
|
586
|
+
'baseVolume': this.safeString2(data, 'vol', 'volume'),
|
|
587
|
+
'quoteVolume': this.safeString(data, 'turnover'),
|
|
588
|
+
'info': ticker,
|
|
589
|
+
}, market);
|
|
590
|
+
}
|
|
591
|
+
async fetchTicker(symbol, params = {}) {
|
|
592
|
+
/**
|
|
593
|
+
* @method
|
|
594
|
+
* @name lbank2#fetchTicker
|
|
595
|
+
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
596
|
+
* @see https://www.lbank.com/en-US/docs/index.html#query-current-market-data-new
|
|
597
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
598
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
599
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
600
|
+
*/
|
|
601
|
+
await this.loadMarkets();
|
|
602
|
+
const market = this.market(symbol);
|
|
603
|
+
if (market['swap']) {
|
|
604
|
+
const responseForSwap = await this.fetchTickers([market['symbol']], params);
|
|
605
|
+
return this.safeValue(responseForSwap, market['symbol']);
|
|
606
|
+
}
|
|
607
|
+
const request = {
|
|
608
|
+
'symbol': market['id'],
|
|
609
|
+
};
|
|
610
|
+
const response = await this.spotPublicGetTicker24hr(this.extend(request, params));
|
|
611
|
+
//
|
|
612
|
+
// {
|
|
613
|
+
// "result": "true",
|
|
614
|
+
// "data": [
|
|
615
|
+
// {
|
|
616
|
+
// "symbol": "btc_usdt",
|
|
617
|
+
// "ticker": {
|
|
618
|
+
// "high": "29695.57",
|
|
619
|
+
// "vol": "6890.2789",
|
|
620
|
+
// "low": "29110",
|
|
621
|
+
// "change": "0.58",
|
|
622
|
+
// "turnover": "202769821.06",
|
|
623
|
+
// "latest": "29405.98"
|
|
624
|
+
// },
|
|
625
|
+
// "timestamp": :1692064274908
|
|
626
|
+
// }
|
|
627
|
+
// ],
|
|
628
|
+
// "error_code": 0,
|
|
629
|
+
// "ts": :1692064276872
|
|
630
|
+
// }
|
|
631
|
+
//
|
|
632
|
+
const data = this.safeValue(response, 'data', []);
|
|
633
|
+
const first = this.safeValue(data, 0, {});
|
|
634
|
+
return this.parseTicker(first, market);
|
|
635
|
+
}
|
|
636
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
637
|
+
/**
|
|
638
|
+
* @method
|
|
639
|
+
* @name lbank2#fetchTickers
|
|
640
|
+
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
641
|
+
* @see https://www.lbank.com/en-US/docs/index.html#query-current-market-data-new
|
|
642
|
+
* @see https://www.lbank.com/en-US/docs/contract.html#query-contract-market-list
|
|
643
|
+
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
644
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
645
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
646
|
+
*/
|
|
647
|
+
await this.loadMarkets();
|
|
648
|
+
let market = undefined;
|
|
649
|
+
if (symbols !== undefined) {
|
|
650
|
+
symbols = this.marketSymbols(symbols);
|
|
651
|
+
const symbolsLength = symbols.length;
|
|
652
|
+
if (symbolsLength > 0) {
|
|
653
|
+
market = this.market(symbols[0]);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
const request = {};
|
|
657
|
+
let type = undefined;
|
|
658
|
+
[type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
|
|
659
|
+
let response = undefined;
|
|
660
|
+
if (type === 'swap') {
|
|
661
|
+
request['productGroup'] = 'SwapU';
|
|
662
|
+
response = await this.contractPublicGetCfdOpenApiV1PubMarketData(this.extend(request, params));
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
request['symbol'] = 'all';
|
|
666
|
+
response = await this.spotPublicGetTicker24hr(this.extend(request, params));
|
|
667
|
+
}
|
|
668
|
+
//
|
|
669
|
+
// spot
|
|
670
|
+
//
|
|
671
|
+
// {
|
|
672
|
+
// "result": "true",
|
|
673
|
+
// "data": [
|
|
674
|
+
// {
|
|
675
|
+
// "symbol": "btc_usdt",
|
|
676
|
+
// "ticker": {
|
|
677
|
+
// "high": "29695.57",
|
|
678
|
+
// "vol": "6890.2789",
|
|
679
|
+
// "low": "29110",
|
|
680
|
+
// "change": "0.58",
|
|
681
|
+
// "turnover": "202769821.06",
|
|
682
|
+
// "latest": "29405.98"
|
|
683
|
+
// },
|
|
684
|
+
// "timestamp": :1692064274908
|
|
685
|
+
// }
|
|
686
|
+
// ],
|
|
687
|
+
// "error_code": 0,
|
|
688
|
+
// "ts": :1692064276872
|
|
689
|
+
// }
|
|
690
|
+
//
|
|
691
|
+
// swap
|
|
692
|
+
//
|
|
693
|
+
// {
|
|
694
|
+
// "data": [
|
|
695
|
+
// {
|
|
696
|
+
// "prePositionFeeRate": "0.000053",
|
|
697
|
+
// "volume": "2435.459",
|
|
698
|
+
// "symbol": "BTCUSDT",
|
|
699
|
+
// "highestPrice": "29446.5",
|
|
700
|
+
// "lowestPrice": "29362.9",
|
|
701
|
+
// "openPrice": "29419.5",
|
|
702
|
+
// "markedPrice": "29385.1",
|
|
703
|
+
// "turnover": "36345526.2438402",
|
|
704
|
+
// "lastPrice": "29387.0"
|
|
705
|
+
// },
|
|
706
|
+
// ],
|
|
707
|
+
// "error_code": 0,
|
|
708
|
+
// "msg": "Success",
|
|
709
|
+
// "result": "true",
|
|
710
|
+
// "success": true
|
|
711
|
+
// }
|
|
712
|
+
//
|
|
713
|
+
const data = this.safeValue(response, 'data', []);
|
|
714
|
+
return this.parseTickers(data, symbols);
|
|
715
|
+
}
|
|
716
|
+
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
717
|
+
/**
|
|
718
|
+
* @method
|
|
719
|
+
* @name lbank2#fetchOrderBook
|
|
720
|
+
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
721
|
+
* @see https://www.lbank.com/en-US/docs/index.html#query-market-depth
|
|
722
|
+
* @see https://www.lbank.com/en-US/docs/contract.html#get-handicap
|
|
723
|
+
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
724
|
+
* @param {int} [limit] the maximum amount of order book entries to return
|
|
725
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
726
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
727
|
+
*/
|
|
728
|
+
await this.loadMarkets();
|
|
729
|
+
const market = this.market(symbol);
|
|
730
|
+
if (limit === undefined) {
|
|
731
|
+
limit = 60;
|
|
732
|
+
}
|
|
733
|
+
const request = {
|
|
734
|
+
'symbol': market['id'],
|
|
735
|
+
};
|
|
736
|
+
let type = undefined;
|
|
737
|
+
[type, params] = this.handleMarketTypeAndParams('fetchOrderBook', market, params);
|
|
738
|
+
let response = undefined;
|
|
739
|
+
if (type === 'swap') {
|
|
740
|
+
request['depth'] = limit;
|
|
741
|
+
response = await this.contractPublicGetCfdOpenApiV1PubMarketOrder(this.extend(request, params));
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
request['size'] = limit;
|
|
745
|
+
response = await this.spotPublicGetDepth(this.extend(request, params));
|
|
746
|
+
}
|
|
747
|
+
//
|
|
748
|
+
// spot
|
|
749
|
+
//
|
|
750
|
+
// {
|
|
751
|
+
// "result": "true",
|
|
752
|
+
// "data": {
|
|
753
|
+
// "asks": [
|
|
754
|
+
// ["29243.37", "2.8783"],
|
|
755
|
+
// ["29243.39", "2.2842"],
|
|
756
|
+
// ["29243.4", "0.0337"]
|
|
757
|
+
// ],
|
|
758
|
+
// "bids": [
|
|
759
|
+
// ["29243.36", "1.5258"],
|
|
760
|
+
// ["29243.34", "0.8218"],
|
|
761
|
+
// ["29243.28", "1.285"]
|
|
762
|
+
// ],
|
|
763
|
+
// "timestamp": :1692157328820
|
|
764
|
+
// },
|
|
765
|
+
// "error_code": 0,
|
|
766
|
+
// "ts": :1692157328820
|
|
767
|
+
// }
|
|
768
|
+
//
|
|
769
|
+
// swap
|
|
770
|
+
//
|
|
771
|
+
// {
|
|
772
|
+
// "data": {
|
|
773
|
+
// "symbol": "BTCUSDT",
|
|
774
|
+
// "asks": [
|
|
775
|
+
// {
|
|
776
|
+
// "volume": "14.6535",
|
|
777
|
+
// "price": "29234.2",
|
|
778
|
+
// "orders": "1"
|
|
779
|
+
// },
|
|
780
|
+
// ],
|
|
781
|
+
// "bids": [
|
|
782
|
+
// {
|
|
783
|
+
// "volume": "13.4899",
|
|
784
|
+
// "price": "29234.1",
|
|
785
|
+
// "orders": "4"
|
|
786
|
+
// },
|
|
787
|
+
// ]
|
|
788
|
+
// },
|
|
789
|
+
// "error_code": 0,
|
|
790
|
+
// "msg": "Success",
|
|
791
|
+
// "result": "true",
|
|
792
|
+
// "success": true
|
|
793
|
+
// }
|
|
794
|
+
//
|
|
795
|
+
const orderbook = this.safeValue(response, 'data', {});
|
|
796
|
+
const timestamp = this.milliseconds();
|
|
797
|
+
if (market['swap']) {
|
|
798
|
+
return this.parseOrderBook(orderbook, market['symbol'], timestamp, 'bids', 'asks', 'price', 'volume');
|
|
799
|
+
}
|
|
800
|
+
return this.parseOrderBook(orderbook, market['symbol'], timestamp);
|
|
801
|
+
}
|
|
802
|
+
parseTrade(trade, market = undefined) {
|
|
803
|
+
//
|
|
804
|
+
// fetchTrades (old) spotPublicGetTrades
|
|
805
|
+
//
|
|
806
|
+
// {
|
|
807
|
+
// "date_ms":1647021989789,
|
|
808
|
+
// "amount":0.0028,
|
|
809
|
+
// "price":38804.2,
|
|
810
|
+
// "type":"buy",
|
|
811
|
+
// "tid":"52d5616ee35c43019edddebe59b3e094"
|
|
812
|
+
// }
|
|
813
|
+
//
|
|
814
|
+
//
|
|
815
|
+
// fetchTrades (new) spotPublicGetTradesSupplement
|
|
816
|
+
//
|
|
817
|
+
// {
|
|
818
|
+
// "quoteQty":1675.048485,
|
|
819
|
+
// "price":0.127545,
|
|
820
|
+
// "qty":13133,
|
|
821
|
+
// "id":"3589541dc22e4357b227283650f714e2",
|
|
822
|
+
// "time":1648058297110,
|
|
823
|
+
// "isBuyerMaker":false
|
|
824
|
+
// }
|
|
825
|
+
//
|
|
826
|
+
// fetchMyTrades (private)
|
|
827
|
+
//
|
|
828
|
+
// {
|
|
829
|
+
// "orderUuid":"38b4e7a4-14f6-45fd-aba1-1a37024124a0",
|
|
830
|
+
// "tradeFeeRate":0.0010000000,
|
|
831
|
+
// "dealTime":1648500944496,
|
|
832
|
+
// "dealQuantity":30.00000000000000000000,
|
|
833
|
+
// "tradeFee":0.00453300000000000000,
|
|
834
|
+
// "txUuid":"11f3850cc6214ea3b495adad3a032794",
|
|
835
|
+
// "dealPrice":0.15111300000000000000,
|
|
836
|
+
// "dealVolumePrice":4.53339000000000000000,
|
|
837
|
+
// "tradeType":"sell_market"
|
|
838
|
+
// }
|
|
839
|
+
//
|
|
840
|
+
let timestamp = this.safeInteger2(trade, 'date_ms', 'time');
|
|
841
|
+
if (timestamp === undefined) {
|
|
842
|
+
timestamp = this.safeInteger(trade, 'dealTime');
|
|
843
|
+
}
|
|
844
|
+
let amountString = this.safeString2(trade, 'amount', 'qty');
|
|
845
|
+
if (amountString === undefined) {
|
|
846
|
+
amountString = this.safeString(trade, 'dealQuantity');
|
|
847
|
+
}
|
|
848
|
+
let priceString = this.safeString(trade, 'price');
|
|
849
|
+
if (priceString === undefined) {
|
|
850
|
+
priceString = this.safeString(trade, 'dealPrice');
|
|
851
|
+
}
|
|
852
|
+
let costString = this.safeString(trade, 'quoteQty');
|
|
853
|
+
if (costString === undefined) {
|
|
854
|
+
costString = this.safeString(trade, 'dealVolumePrice');
|
|
855
|
+
}
|
|
856
|
+
let side = this.safeString2(trade, 'tradeType', 'type');
|
|
857
|
+
let type = undefined;
|
|
858
|
+
let takerOrMaker = undefined;
|
|
859
|
+
if (side !== undefined) {
|
|
860
|
+
const parts = side.split('_');
|
|
861
|
+
side = this.safeString(parts, 0);
|
|
862
|
+
const typePart = this.safeString(parts, 1);
|
|
863
|
+
type = 'limit';
|
|
864
|
+
takerOrMaker = 'taker';
|
|
865
|
+
if (typePart !== undefined) {
|
|
866
|
+
if (typePart === 'market') {
|
|
867
|
+
type = 'market';
|
|
868
|
+
}
|
|
869
|
+
else if (typePart === 'maker') {
|
|
870
|
+
takerOrMaker = 'maker';
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
let id = this.safeString2(trade, 'tid', 'id');
|
|
875
|
+
if (id === undefined) {
|
|
876
|
+
id = this.safeString(trade, 'txUuid');
|
|
877
|
+
}
|
|
878
|
+
const order = this.safeString(trade, 'orderUuid');
|
|
879
|
+
const symbol = this.safeSymbol(undefined, market);
|
|
880
|
+
let fee = undefined;
|
|
881
|
+
const feeCost = this.safeString(trade, 'tradeFee');
|
|
882
|
+
if (feeCost !== undefined) {
|
|
883
|
+
fee = {
|
|
884
|
+
'cost': feeCost,
|
|
885
|
+
'currency': (side === 'buy') ? market['base'] : market['quote'],
|
|
886
|
+
'rate': this.safeString(trade, 'tradeFeeRate'),
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
return this.safeTrade({
|
|
890
|
+
'timestamp': timestamp,
|
|
891
|
+
'datetime': this.iso8601(timestamp),
|
|
892
|
+
'symbol': symbol,
|
|
893
|
+
'id': id,
|
|
894
|
+
'order': order,
|
|
895
|
+
'type': type,
|
|
896
|
+
'takerOrMaker': takerOrMaker,
|
|
897
|
+
'side': side,
|
|
898
|
+
'price': priceString,
|
|
899
|
+
'amount': amountString,
|
|
900
|
+
'cost': costString,
|
|
901
|
+
'fee': fee,
|
|
902
|
+
'info': trade,
|
|
903
|
+
}, market);
|
|
904
|
+
}
|
|
905
|
+
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
906
|
+
/**
|
|
907
|
+
* @method
|
|
908
|
+
* @name lbank2#fetchTrades
|
|
909
|
+
* @description get the list of most recent trades for a particular symbol
|
|
910
|
+
* @see https://www.lbank.com/en-US/docs/index.html#query-historical-transactions
|
|
911
|
+
* @see https://www.lbank.com/en-US/docs/index.html#recent-transactions-list
|
|
912
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
913
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
914
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
915
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
916
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
917
|
+
*/
|
|
918
|
+
await this.loadMarkets();
|
|
919
|
+
const market = this.market(symbol);
|
|
920
|
+
const request = {
|
|
921
|
+
'symbol': market['id'],
|
|
922
|
+
};
|
|
923
|
+
if (since !== undefined) {
|
|
924
|
+
request['time'] = since;
|
|
925
|
+
}
|
|
926
|
+
if (limit !== undefined) {
|
|
927
|
+
request['size'] = Math.min(limit, 600);
|
|
928
|
+
}
|
|
929
|
+
else {
|
|
930
|
+
request['size'] = 600; // max
|
|
931
|
+
}
|
|
932
|
+
const options = this.safeValue(this.options, 'fetchTrades', {});
|
|
933
|
+
const defaultMethod = this.safeString(options, 'method', 'spotPublicGetTrades');
|
|
934
|
+
const method = this.safeString(params, 'method', defaultMethod);
|
|
935
|
+
params = this.omit(params, 'method');
|
|
936
|
+
let response = undefined;
|
|
937
|
+
if (method === 'spotPublicGetSupplementTrades') {
|
|
938
|
+
response = await this.spotPublicGetSupplementTrades(this.extend(request, params));
|
|
939
|
+
}
|
|
940
|
+
else {
|
|
941
|
+
response = await this.spotPublicGetTrades(this.extend(request, params));
|
|
942
|
+
}
|
|
943
|
+
//
|
|
944
|
+
// {
|
|
945
|
+
// "result":"true",
|
|
946
|
+
// "data": [
|
|
947
|
+
// {
|
|
948
|
+
// "date_ms":1647021989789,
|
|
949
|
+
// "amount":0.0028,
|
|
950
|
+
// "price":38804.2,
|
|
951
|
+
// "type":"buy",
|
|
952
|
+
// "tid":"52d5616ee35c43019edddebe59b3e094"
|
|
953
|
+
// }
|
|
954
|
+
// ],
|
|
955
|
+
// "error_code":0,
|
|
956
|
+
// "ts":1647021999308
|
|
957
|
+
// }
|
|
958
|
+
//
|
|
959
|
+
const trades = this.safeValue(response, 'data', []);
|
|
960
|
+
return this.parseTrades(trades, market, since, limit);
|
|
961
|
+
}
|
|
962
|
+
parseOHLCV(ohlcv, market = undefined) {
|
|
963
|
+
//
|
|
964
|
+
// [
|
|
965
|
+
// 1482311500, // timestamp
|
|
966
|
+
// 5423.23, // open
|
|
967
|
+
// 5472.80, // high
|
|
968
|
+
// 5516.09, // low
|
|
969
|
+
// 5462, // close
|
|
970
|
+
// 234.3250 // volume
|
|
971
|
+
// ],
|
|
972
|
+
//
|
|
973
|
+
return [
|
|
974
|
+
this.safeTimestamp(ohlcv, 0),
|
|
975
|
+
this.safeNumber(ohlcv, 1),
|
|
976
|
+
this.safeNumber(ohlcv, 2),
|
|
977
|
+
this.safeNumber(ohlcv, 3),
|
|
978
|
+
this.safeNumber(ohlcv, 4),
|
|
979
|
+
this.safeNumber(ohlcv, 5), // volume
|
|
980
|
+
];
|
|
981
|
+
}
|
|
982
|
+
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
983
|
+
/**
|
|
984
|
+
* @method
|
|
985
|
+
* @name lbank2#fetchOHLCV
|
|
986
|
+
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
987
|
+
* @see https://www.lbank.com/en-US/docs/index.html#query-k-bar-data
|
|
988
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
989
|
+
* @param {string} timeframe the length of time each candle represents
|
|
990
|
+
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
991
|
+
* @param {int} [limit] the maximum amount of candles to fetch
|
|
992
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
993
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
994
|
+
*/
|
|
995
|
+
// endpoint doesnt work
|
|
996
|
+
await this.loadMarkets();
|
|
997
|
+
const market = this.market(symbol);
|
|
998
|
+
if (limit === undefined) {
|
|
999
|
+
limit = 100;
|
|
1000
|
+
}
|
|
1001
|
+
if (since === undefined) {
|
|
1002
|
+
const duration = this.parseTimeframe(timeframe);
|
|
1003
|
+
since = this.milliseconds() - duration * 1000 * limit;
|
|
1004
|
+
}
|
|
1005
|
+
const request = {
|
|
1006
|
+
'symbol': market['id'],
|
|
1007
|
+
'type': this.safeString(this.timeframes, timeframe, timeframe),
|
|
1008
|
+
'time': this.parseToInt(since / 1000),
|
|
1009
|
+
'size': limit, // max 2000
|
|
1010
|
+
};
|
|
1011
|
+
const response = await this.spotPublicGetKline(this.extend(request, params));
|
|
1012
|
+
const ohlcvs = this.safeValue(response, 'data', []);
|
|
1013
|
+
//
|
|
1014
|
+
//
|
|
1015
|
+
// [
|
|
1016
|
+
// [
|
|
1017
|
+
// 1482311500,
|
|
1018
|
+
// 5423.23,
|
|
1019
|
+
// 5472.80,
|
|
1020
|
+
// 5516.09,
|
|
1021
|
+
// 5462,
|
|
1022
|
+
// 234.3250
|
|
1023
|
+
// ],
|
|
1024
|
+
// [
|
|
1025
|
+
// 1482311400,
|
|
1026
|
+
// 5432.52,
|
|
1027
|
+
// 5459.87,
|
|
1028
|
+
// 5414.30,
|
|
1029
|
+
// 5428.23,
|
|
1030
|
+
// 213.7329
|
|
1031
|
+
// ]
|
|
1032
|
+
// ]
|
|
1033
|
+
//
|
|
1034
|
+
return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
|
|
1035
|
+
}
|
|
1036
|
+
parseBalance(response) {
|
|
1037
|
+
//
|
|
1038
|
+
// spotPrivatePostUserInfo
|
|
1039
|
+
//
|
|
1040
|
+
// {
|
|
1041
|
+
// "toBtc": {
|
|
1042
|
+
// "egc:": "0",
|
|
1043
|
+
// "iog": "0",
|
|
1044
|
+
// "ksm": "0",
|
|
1045
|
+
// },
|
|
1046
|
+
// "freeze": {
|
|
1047
|
+
// "egc": "0",
|
|
1048
|
+
// "iog": "0",
|
|
1049
|
+
// "ksm": "0" ,
|
|
1050
|
+
// },
|
|
1051
|
+
// "asset": {
|
|
1052
|
+
// "egc": "0",
|
|
1053
|
+
// "iog": "0",
|
|
1054
|
+
// "ksm": "0",
|
|
1055
|
+
// },
|
|
1056
|
+
// "free": {
|
|
1057
|
+
// "egc": "0",
|
|
1058
|
+
// "iog": "0",
|
|
1059
|
+
// "ksm": "0",
|
|
1060
|
+
// }
|
|
1061
|
+
// }
|
|
1062
|
+
//
|
|
1063
|
+
// spotPrivatePostSupplementUserInfoAccount
|
|
1064
|
+
//
|
|
1065
|
+
// {
|
|
1066
|
+
// "balances":[
|
|
1067
|
+
// {
|
|
1068
|
+
// "asset":"lbk",
|
|
1069
|
+
// "free":"0",
|
|
1070
|
+
// "locked":"0"
|
|
1071
|
+
// }, ...
|
|
1072
|
+
// ]
|
|
1073
|
+
// }
|
|
1074
|
+
//
|
|
1075
|
+
// spotPrivatePostSupplementUserInfo
|
|
1076
|
+
//
|
|
1077
|
+
// [
|
|
1078
|
+
// {
|
|
1079
|
+
// "usableAmt":"31.45130723",
|
|
1080
|
+
// "assetAmt":"31.45130723",
|
|
1081
|
+
// "networkList":[
|
|
1082
|
+
// {
|
|
1083
|
+
// "isDefault":true,
|
|
1084
|
+
// "withdrawFeeRate":"",
|
|
1085
|
+
// "name":"bep20(bsc)",
|
|
1086
|
+
// "withdrawMin":30,
|
|
1087
|
+
// "minLimit":0.0001,
|
|
1088
|
+
// "minDeposit":0.0001,
|
|
1089
|
+
// "feeAssetCode":"doge",
|
|
1090
|
+
// "withdrawFee":"30",
|
|
1091
|
+
// "type":1,
|
|
1092
|
+
// "coin":"doge",
|
|
1093
|
+
// "network":"bsc"
|
|
1094
|
+
// },
|
|
1095
|
+
// {
|
|
1096
|
+
// "isDefault":false,
|
|
1097
|
+
// "withdrawFeeRate":"",
|
|
1098
|
+
// "name":"dogecoin",
|
|
1099
|
+
// "withdrawMin":10,
|
|
1100
|
+
// "minLimit":0.0001,
|
|
1101
|
+
// "minDeposit":10,
|
|
1102
|
+
// "feeAssetCode":"doge",
|
|
1103
|
+
// "withdrawFee":"10",
|
|
1104
|
+
// "type":1,
|
|
1105
|
+
// "coin":"doge",
|
|
1106
|
+
// "network":"dogecoin"
|
|
1107
|
+
// }
|
|
1108
|
+
// ],
|
|
1109
|
+
// "freezeAmt":"0",
|
|
1110
|
+
// "coin":"doge"
|
|
1111
|
+
// }, ...
|
|
1112
|
+
// ]
|
|
1113
|
+
//
|
|
1114
|
+
const timestamp = this.safeInteger(response, 'ts');
|
|
1115
|
+
const result = {
|
|
1116
|
+
'info': response,
|
|
1117
|
+
'timestamp': timestamp,
|
|
1118
|
+
'datetime': this.iso8601(timestamp),
|
|
1119
|
+
};
|
|
1120
|
+
const data = this.safeValue(response, 'data');
|
|
1121
|
+
// from spotPrivatePostUserInfo
|
|
1122
|
+
const toBtc = this.safeValue(data, 'toBtc');
|
|
1123
|
+
if (toBtc !== undefined) {
|
|
1124
|
+
const used = this.safeValue(data, 'freeze', {});
|
|
1125
|
+
const free = this.safeValue(data, 'free', {});
|
|
1126
|
+
const currencies = Object.keys(free);
|
|
1127
|
+
for (let i = 0; i < currencies.length; i++) {
|
|
1128
|
+
const currencyId = currencies[i];
|
|
1129
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
1130
|
+
const account = this.account();
|
|
1131
|
+
account['used'] = this.safeString(used, currencyId);
|
|
1132
|
+
account['free'] = this.safeString(free, currencyId);
|
|
1133
|
+
result[code] = account;
|
|
1134
|
+
}
|
|
1135
|
+
return this.safeBalance(result);
|
|
1136
|
+
}
|
|
1137
|
+
// from spotPrivatePostSupplementUserInfoAccount
|
|
1138
|
+
const balances = this.safeValue(data, 'balances');
|
|
1139
|
+
if (balances !== undefined) {
|
|
1140
|
+
for (let i = 0; i < balances.length; i++) {
|
|
1141
|
+
const item = balances[i];
|
|
1142
|
+
const currencyId = this.safeString(item, 'asset');
|
|
1143
|
+
const codeInner = this.safeCurrencyCode(currencyId);
|
|
1144
|
+
const account = this.account();
|
|
1145
|
+
account['free'] = this.safeString(item, 'free');
|
|
1146
|
+
account['used'] = this.safeString(item, 'locked');
|
|
1147
|
+
result[codeInner] = account;
|
|
1148
|
+
}
|
|
1149
|
+
return this.safeBalance(result);
|
|
1150
|
+
}
|
|
1151
|
+
// from spotPrivatePostSupplementUserInfo
|
|
1152
|
+
const isArray = Array.isArray(data);
|
|
1153
|
+
if (isArray === true) {
|
|
1154
|
+
for (let i = 0; i < data.length; i++) {
|
|
1155
|
+
const item = data[i];
|
|
1156
|
+
const currencyId = this.safeString(item, 'coin');
|
|
1157
|
+
const codeInner = this.safeCurrencyCode(currencyId);
|
|
1158
|
+
const account = this.account();
|
|
1159
|
+
account['free'] = this.safeString(item, 'usableAmt');
|
|
1160
|
+
account['used'] = this.safeString(item, 'freezeAmt');
|
|
1161
|
+
result[codeInner] = account;
|
|
1162
|
+
}
|
|
1163
|
+
return this.safeBalance(result);
|
|
1164
|
+
}
|
|
1165
|
+
return undefined;
|
|
1166
|
+
}
|
|
1167
|
+
async fetchBalance(params = {}) {
|
|
1168
|
+
/**
|
|
1169
|
+
* @method
|
|
1170
|
+
* @name lbank2#fetchBalance
|
|
1171
|
+
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
1172
|
+
* @see https://www.lbank.com/en-US/docs/index.html#asset-information
|
|
1173
|
+
* @see https://www.lbank.com/en-US/docs/index.html#account-information
|
|
1174
|
+
* @see https://www.lbank.com/en-US/docs/index.html#get-all-coins-information
|
|
1175
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1176
|
+
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
1177
|
+
*/
|
|
1178
|
+
await this.loadMarkets();
|
|
1179
|
+
const options = this.safeValue(this.options, 'fetchBalance', {});
|
|
1180
|
+
const defaultMethod = this.safeString(options, 'method', 'spotPrivatePostSupplementUserInfo');
|
|
1181
|
+
const method = this.safeString(params, 'method', defaultMethod);
|
|
1182
|
+
let response = undefined;
|
|
1183
|
+
if (method === 'spotPrivatePostSupplementUserInfoAccount') {
|
|
1184
|
+
response = await this.spotPrivatePostSupplementUserInfoAccount();
|
|
1185
|
+
}
|
|
1186
|
+
else if (method === 'spotPrivatePostUserInfo') {
|
|
1187
|
+
response = await this.spotPrivatePostUserInfo();
|
|
1188
|
+
}
|
|
1189
|
+
else {
|
|
1190
|
+
response = await this.spotPrivatePostSupplementUserInfo();
|
|
1191
|
+
}
|
|
1192
|
+
//
|
|
1193
|
+
// {
|
|
1194
|
+
// "result": "true",
|
|
1195
|
+
// "data": [
|
|
1196
|
+
// {
|
|
1197
|
+
// "usableAmt": "14.36",
|
|
1198
|
+
// "assetAmt": "14.36",
|
|
1199
|
+
// "networkList": [
|
|
1200
|
+
// {
|
|
1201
|
+
// "isDefault": false,
|
|
1202
|
+
// "withdrawFeeRate": "",
|
|
1203
|
+
// "name": "erc20",
|
|
1204
|
+
// "withdrawMin": 30,
|
|
1205
|
+
// "minLimit": 0.0001,
|
|
1206
|
+
// "minDeposit": 20,
|
|
1207
|
+
// "feeAssetCode": "usdt",
|
|
1208
|
+
// "withdrawFee": "30",
|
|
1209
|
+
// "type": 1,
|
|
1210
|
+
// "coin": "usdt",
|
|
1211
|
+
// "network": "eth"
|
|
1212
|
+
// },
|
|
1213
|
+
// ...
|
|
1214
|
+
// ],
|
|
1215
|
+
// "freezeAmt": "0",
|
|
1216
|
+
// "coin": "ada"
|
|
1217
|
+
// }
|
|
1218
|
+
// ],
|
|
1219
|
+
// "code": 0
|
|
1220
|
+
// }
|
|
1221
|
+
//
|
|
1222
|
+
return this.parseBalance(response);
|
|
1223
|
+
}
|
|
1224
|
+
parseTradingFee(fee, market = undefined) {
|
|
1225
|
+
//
|
|
1226
|
+
// {
|
|
1227
|
+
// "symbol":"skt_usdt",
|
|
1228
|
+
// "makerCommission":"0.10",
|
|
1229
|
+
// "takerCommission":"0.10"
|
|
1230
|
+
// }
|
|
1231
|
+
//
|
|
1232
|
+
const marketId = this.safeString(fee, 'symbol');
|
|
1233
|
+
const symbol = this.safeSymbol(marketId);
|
|
1234
|
+
return {
|
|
1235
|
+
'info': fee,
|
|
1236
|
+
'symbol': symbol,
|
|
1237
|
+
'maker': this.safeNumber(fee, 'makerCommission'),
|
|
1238
|
+
'taker': this.safeNumber(fee, 'takerCommission'),
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
async fetchTradingFee(symbol, params = {}) {
|
|
1242
|
+
/**
|
|
1243
|
+
* @method
|
|
1244
|
+
* @name lbank2#fetchTradingFee
|
|
1245
|
+
* @description fetch the trading fees for a market
|
|
1246
|
+
* @see https://www.lbank.com/en-US/docs/index.html#transaction-fee-rate-query
|
|
1247
|
+
* @param {string} symbol unified market symbol
|
|
1248
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1249
|
+
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
1250
|
+
*/
|
|
1251
|
+
const market = this.market(symbol);
|
|
1252
|
+
const result = await this.fetchTradingFees(this.extend(params, { 'category': market['id'] }));
|
|
1253
|
+
return result;
|
|
1254
|
+
}
|
|
1255
|
+
async fetchTradingFees(params = {}) {
|
|
1256
|
+
/**
|
|
1257
|
+
* @method
|
|
1258
|
+
* @name lbank2#fetchTradingFees
|
|
1259
|
+
* @description fetch the trading fees for multiple markets
|
|
1260
|
+
* @see https://www.lbank.com/en-US/docs/index.html#transaction-fee-rate-query
|
|
1261
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1262
|
+
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
|
|
1263
|
+
*/
|
|
1264
|
+
await this.loadMarkets();
|
|
1265
|
+
const request = {};
|
|
1266
|
+
const response = await this.spotPrivatePostSupplementCustomerTradeFee(this.extend(request, params));
|
|
1267
|
+
const fees = this.safeValue(response, 'data', []);
|
|
1268
|
+
const result = {};
|
|
1269
|
+
for (let i = 0; i < fees.length; i++) {
|
|
1270
|
+
const fee = this.parseTradingFee(fees[i]);
|
|
1271
|
+
const symbol = fee['symbol'];
|
|
1272
|
+
result[symbol] = fee;
|
|
1273
|
+
}
|
|
1274
|
+
return result;
|
|
1275
|
+
}
|
|
1276
|
+
async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
|
|
1277
|
+
/**
|
|
1278
|
+
* @method
|
|
1279
|
+
* @name lbank#createMarketBuyOrderWithCost
|
|
1280
|
+
* @description create a market buy order by providing the symbol and cost
|
|
1281
|
+
* @see https://www.lbank.com/en-US/docs/index.html#place-order
|
|
1282
|
+
* @see https://www.lbank.com/en-US/docs/index.html#place-an-order
|
|
1283
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
1284
|
+
* @param {float} cost how much you want to trade in units of the quote currency
|
|
1285
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1286
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1287
|
+
*/
|
|
1288
|
+
await this.loadMarkets();
|
|
1289
|
+
const market = this.market(symbol);
|
|
1290
|
+
if (!market['spot']) {
|
|
1291
|
+
throw new errors.NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
|
|
1292
|
+
}
|
|
1293
|
+
params['createMarketBuyOrderRequiresPrice'] = false;
|
|
1294
|
+
return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
|
|
1295
|
+
}
|
|
1296
|
+
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
1297
|
+
/**
|
|
1298
|
+
* @method
|
|
1299
|
+
* @name lbank2#createOrder
|
|
1300
|
+
* @description create a trade order
|
|
1301
|
+
* @see https://www.lbank.com/en-US/docs/index.html#place-order
|
|
1302
|
+
* @see https://www.lbank.com/en-US/docs/index.html#place-an-order
|
|
1303
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
1304
|
+
* @param {string} type 'market' or 'limit'
|
|
1305
|
+
* @param {string} side 'buy' or 'sell'
|
|
1306
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
1307
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
1308
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1309
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1310
|
+
*/
|
|
1311
|
+
await this.loadMarkets();
|
|
1312
|
+
const market = this.market(symbol);
|
|
1313
|
+
const clientOrderId = this.safeString2(params, 'custom_id', 'clientOrderId');
|
|
1314
|
+
const postOnly = this.safeValue(params, 'postOnly', false);
|
|
1315
|
+
const timeInForce = this.safeStringUpper(params, 'timeInForce');
|
|
1316
|
+
params = this.omit(params, ['custom_id', 'clientOrderId', 'timeInForce', 'postOnly']);
|
|
1317
|
+
const request = {
|
|
1318
|
+
'symbol': market['id'],
|
|
1319
|
+
};
|
|
1320
|
+
const ioc = (timeInForce === 'IOC');
|
|
1321
|
+
const fok = (timeInForce === 'FOK');
|
|
1322
|
+
const maker = (postOnly || (timeInForce === 'PO'));
|
|
1323
|
+
if ((type === 'market') && (ioc || fok || maker)) {
|
|
1324
|
+
throw new errors.InvalidOrder(this.id + ' createOrder () does not allow market FOK, IOC, or postOnly orders. Only limit IOC, FOK, and postOnly orders are allowed');
|
|
1325
|
+
}
|
|
1326
|
+
if (type === 'limit') {
|
|
1327
|
+
request['type'] = side;
|
|
1328
|
+
request['price'] = this.priceToPrecision(symbol, price);
|
|
1329
|
+
request['amount'] = this.amountToPrecision(symbol, amount);
|
|
1330
|
+
if (ioc) {
|
|
1331
|
+
request['type'] = side + '_' + 'ioc';
|
|
1332
|
+
}
|
|
1333
|
+
else if (fok) {
|
|
1334
|
+
request['type'] = side + '_' + 'fok';
|
|
1335
|
+
}
|
|
1336
|
+
else if (maker) {
|
|
1337
|
+
request['type'] = side + '_' + 'maker';
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
else if (type === 'market') {
|
|
1341
|
+
if (side === 'sell') {
|
|
1342
|
+
request['type'] = side + '_' + 'market';
|
|
1343
|
+
request['amount'] = this.amountToPrecision(symbol, amount);
|
|
1344
|
+
}
|
|
1345
|
+
else if (side === 'buy') {
|
|
1346
|
+
request['type'] = side + '_' + 'market';
|
|
1347
|
+
let quoteAmount = undefined;
|
|
1348
|
+
let createMarketBuyOrderRequiresPrice = true;
|
|
1349
|
+
[createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
|
|
1350
|
+
const cost = this.safeNumber(params, 'cost');
|
|
1351
|
+
params = this.omit(params, 'cost');
|
|
1352
|
+
if (cost !== undefined) {
|
|
1353
|
+
quoteAmount = this.costToPrecision(symbol, cost);
|
|
1354
|
+
}
|
|
1355
|
+
else if (createMarketBuyOrderRequiresPrice) {
|
|
1356
|
+
if (price === undefined) {
|
|
1357
|
+
throw new errors.InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend in the amount argument');
|
|
1358
|
+
}
|
|
1359
|
+
else {
|
|
1360
|
+
const amountString = this.numberToString(amount);
|
|
1361
|
+
const priceString = this.numberToString(price);
|
|
1362
|
+
const costRequest = Precise["default"].stringMul(amountString, priceString);
|
|
1363
|
+
quoteAmount = this.costToPrecision(symbol, costRequest);
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
else {
|
|
1367
|
+
quoteAmount = this.costToPrecision(symbol, amount);
|
|
1368
|
+
}
|
|
1369
|
+
// market buys require filling the price param instead of the amount param, for market buys the price is treated as the cost by lbank
|
|
1370
|
+
request['price'] = quoteAmount;
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
if (clientOrderId !== undefined) {
|
|
1374
|
+
request['custom_id'] = clientOrderId;
|
|
1375
|
+
}
|
|
1376
|
+
const options = this.safeValue(this.options, 'createOrder', {});
|
|
1377
|
+
const defaultMethod = this.safeString(options, 'method', 'spotPrivatePostSupplementCreateOrder');
|
|
1378
|
+
const method = this.safeString(params, 'method', defaultMethod);
|
|
1379
|
+
params = this.omit(params, 'method');
|
|
1380
|
+
let response = undefined;
|
|
1381
|
+
if (method === 'spotPrivatePostCreateOrder') {
|
|
1382
|
+
response = await this.spotPrivatePostCreateOrder(this.extend(request, params));
|
|
1383
|
+
}
|
|
1384
|
+
else {
|
|
1385
|
+
response = await this.spotPrivatePostSupplementCreateOrder(this.extend(request, params));
|
|
1386
|
+
}
|
|
1387
|
+
//
|
|
1388
|
+
// {
|
|
1389
|
+
// "result":true,
|
|
1390
|
+
// "data":{
|
|
1391
|
+
// "symbol":"doge_usdt",
|
|
1392
|
+
// "order_id":"0cf8a3de-4597-4296-af45-be7abaa06b07"
|
|
1393
|
+
// },
|
|
1394
|
+
// "error_code":0,
|
|
1395
|
+
// "ts":1648162321043
|
|
1396
|
+
// }
|
|
1397
|
+
//
|
|
1398
|
+
const result = this.safeValue(response, 'data', {});
|
|
1399
|
+
return this.safeOrder({
|
|
1400
|
+
'id': this.safeString(result, 'order_id'),
|
|
1401
|
+
'info': result,
|
|
1402
|
+
}, market);
|
|
1403
|
+
}
|
|
1404
|
+
parseOrderStatus(status) {
|
|
1405
|
+
const statuses = {
|
|
1406
|
+
'-1': 'canceled',
|
|
1407
|
+
'0': 'open',
|
|
1408
|
+
'1': 'open',
|
|
1409
|
+
'2': 'closed',
|
|
1410
|
+
'3': 'canceled',
|
|
1411
|
+
'4': 'closed', // disposal processing
|
|
1412
|
+
};
|
|
1413
|
+
return this.safeString(statuses, status, status);
|
|
1414
|
+
}
|
|
1415
|
+
parseOrder(order, market = undefined) {
|
|
1416
|
+
//
|
|
1417
|
+
// fetchOrderSupplement (private)
|
|
1418
|
+
//
|
|
1419
|
+
// {
|
|
1420
|
+
// "cummulativeQuoteQty":0,
|
|
1421
|
+
// "symbol":"doge_usdt",
|
|
1422
|
+
// "executedQty":0,
|
|
1423
|
+
// "orderId":"53d2d53e-70fb-4398-b722-f48571a5f61e",
|
|
1424
|
+
// "origQty":1E+2,
|
|
1425
|
+
// "price":0.05,
|
|
1426
|
+
// "clientOrderId":null,
|
|
1427
|
+
// "origQuoteOrderQty":5,
|
|
1428
|
+
// "updateTime":1648163406000,
|
|
1429
|
+
// "time":1648163139387,
|
|
1430
|
+
// "type":"buy_maker",
|
|
1431
|
+
// "status":-1
|
|
1432
|
+
// }
|
|
1433
|
+
//
|
|
1434
|
+
//
|
|
1435
|
+
// fetchOrderDefault (private)
|
|
1436
|
+
//
|
|
1437
|
+
// {
|
|
1438
|
+
// "symbol":"shib_usdt",
|
|
1439
|
+
// "amount":1,
|
|
1440
|
+
// "create_time":1649367863356,
|
|
1441
|
+
// "price":0.0000246103,
|
|
1442
|
+
// "avg_price":0.00002466180000000104,
|
|
1443
|
+
// "type":"buy_market",
|
|
1444
|
+
// "order_id":"abe8b92d-86d9-4d6d-b71e-d14f5fb53ddf",
|
|
1445
|
+
// "custom_id": "007", // field only present if user creates it at order time
|
|
1446
|
+
// "deal_amount":40548.54065802,
|
|
1447
|
+
// "status":2
|
|
1448
|
+
// }
|
|
1449
|
+
//
|
|
1450
|
+
// fetchOpenOrders (private)
|
|
1451
|
+
//
|
|
1452
|
+
// {
|
|
1453
|
+
// "cummulativeQuoteQty":0,
|
|
1454
|
+
// "symbol":"doge_usdt",
|
|
1455
|
+
// "executedQty":0,
|
|
1456
|
+
// "orderId":"73878edf-008d-4e4c-8041-df1f1b2cd8bb",
|
|
1457
|
+
// "origQty":100,
|
|
1458
|
+
// "price":0.05,
|
|
1459
|
+
// "origQuoteOrderQty":5,
|
|
1460
|
+
// "updateTime":1648501762000,
|
|
1461
|
+
// "time":1648501762353,
|
|
1462
|
+
// "type":"buy",
|
|
1463
|
+
// "status":0
|
|
1464
|
+
// }
|
|
1465
|
+
//
|
|
1466
|
+
// fetchOrders (private)
|
|
1467
|
+
//
|
|
1468
|
+
// {
|
|
1469
|
+
// "cummulativeQuoteQty":0,
|
|
1470
|
+
// "symbol":"doge_usdt",
|
|
1471
|
+
// "executedQty":0,
|
|
1472
|
+
// "orderId":"2cadc7cc-b5f6-486b-a5b4-d6ac49a9c186",
|
|
1473
|
+
// "origQty":100,
|
|
1474
|
+
// "price":0.05,
|
|
1475
|
+
// "origQuoteOrderQty":5,
|
|
1476
|
+
// "updateTime":1648501384000,
|
|
1477
|
+
// "time":1648501363889,
|
|
1478
|
+
// "type":"buy",
|
|
1479
|
+
// "status":-1
|
|
1480
|
+
// }
|
|
1481
|
+
//
|
|
1482
|
+
const id = this.safeString2(order, 'orderId', 'order_id');
|
|
1483
|
+
const clientOrderId = this.safeString2(order, 'clientOrderId', 'custom_id');
|
|
1484
|
+
const timestamp = this.safeInteger2(order, 'time', 'create_time');
|
|
1485
|
+
const rawStatus = this.safeString(order, 'status');
|
|
1486
|
+
const marketId = this.safeString(order, 'symbol');
|
|
1487
|
+
market = this.safeMarket(marketId, market);
|
|
1488
|
+
let timeInForce = undefined;
|
|
1489
|
+
let postOnly = false;
|
|
1490
|
+
let type = 'limit';
|
|
1491
|
+
const rawType = this.safeString(order, 'type'); // buy, sell, buy_market, sell_market, buy_maker,sell_maker,buy_ioc,sell_ioc, buy_fok, sell_fok
|
|
1492
|
+
const parts = rawType.split('_');
|
|
1493
|
+
const side = this.safeString(parts, 0);
|
|
1494
|
+
const typePart = this.safeString(parts, 1); // market, maker, ioc, fok or undefined (limit)
|
|
1495
|
+
if (typePart === 'market') {
|
|
1496
|
+
type = 'market';
|
|
1497
|
+
}
|
|
1498
|
+
if (typePart === 'maker') {
|
|
1499
|
+
postOnly = true;
|
|
1500
|
+
timeInForce = 'PO';
|
|
1501
|
+
}
|
|
1502
|
+
if (typePart === 'ioc') {
|
|
1503
|
+
timeInForce = 'IOC';
|
|
1504
|
+
}
|
|
1505
|
+
if (typePart === 'fok') {
|
|
1506
|
+
timeInForce = 'FOK';
|
|
1507
|
+
}
|
|
1508
|
+
const price = this.safeString(order, 'price');
|
|
1509
|
+
const costString = this.safeString(order, 'cummulativeQuoteQty');
|
|
1510
|
+
let amountString = undefined;
|
|
1511
|
+
if (rawType !== 'buy_market') {
|
|
1512
|
+
amountString = this.safeString2(order, 'origQty', 'amount');
|
|
1513
|
+
}
|
|
1514
|
+
const filledString = this.safeString2(order, 'executedQty', 'deal_amount');
|
|
1515
|
+
return this.safeOrder({
|
|
1516
|
+
'id': id,
|
|
1517
|
+
'clientOrderId': clientOrderId,
|
|
1518
|
+
'datetime': this.iso8601(timestamp),
|
|
1519
|
+
'timestamp': timestamp,
|
|
1520
|
+
'lastTradeTimestamp': undefined,
|
|
1521
|
+
'status': this.parseOrderStatus(rawStatus),
|
|
1522
|
+
'symbol': market['symbol'],
|
|
1523
|
+
'type': type,
|
|
1524
|
+
'timeInForce': timeInForce,
|
|
1525
|
+
'postOnly': postOnly,
|
|
1526
|
+
'side': side,
|
|
1527
|
+
'price': price,
|
|
1528
|
+
'stopPrice': undefined,
|
|
1529
|
+
'triggerPrice': undefined,
|
|
1530
|
+
'cost': costString,
|
|
1531
|
+
'amount': amountString,
|
|
1532
|
+
'filled': filledString,
|
|
1533
|
+
'remaining': undefined,
|
|
1534
|
+
'trades': undefined,
|
|
1535
|
+
'fee': undefined,
|
|
1536
|
+
'info': order,
|
|
1537
|
+
'average': undefined,
|
|
1538
|
+
}, market);
|
|
1539
|
+
}
|
|
1540
|
+
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
1541
|
+
/**
|
|
1542
|
+
* @method
|
|
1543
|
+
* @name lbank2#fetchOrder
|
|
1544
|
+
* @description fetches information on an order made by the user
|
|
1545
|
+
* @see https://www.lbank.com/en-US/docs/index.html#query-order
|
|
1546
|
+
* @see https://www.lbank.com/en-US/docs/index.html#query-order-new
|
|
1547
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
1548
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1549
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1550
|
+
*/
|
|
1551
|
+
await this.loadMarkets();
|
|
1552
|
+
let method = this.safeString(params, 'method');
|
|
1553
|
+
if (method === undefined) {
|
|
1554
|
+
const options = this.safeValue(this.options, 'fetchOrder', {});
|
|
1555
|
+
method = this.safeString(options, 'method', 'fetchOrderSupplement');
|
|
1556
|
+
}
|
|
1557
|
+
if (method === 'fetchOrderSupplement') {
|
|
1558
|
+
return await this.fetchOrderSupplement(id, symbol, params);
|
|
1559
|
+
}
|
|
1560
|
+
return await this.fetchOrderDefault(id, symbol, params);
|
|
1561
|
+
}
|
|
1562
|
+
async fetchOrderSupplement(id, symbol = undefined, params = {}) {
|
|
1563
|
+
if (symbol === undefined) {
|
|
1564
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
|
|
1565
|
+
}
|
|
1566
|
+
await this.loadMarkets();
|
|
1567
|
+
const market = this.market(symbol);
|
|
1568
|
+
const request = {
|
|
1569
|
+
'symbol': market['id'],
|
|
1570
|
+
'orderId': id,
|
|
1571
|
+
};
|
|
1572
|
+
const response = await this.spotPrivatePostSupplementOrdersInfo(this.extend(request, params));
|
|
1573
|
+
//
|
|
1574
|
+
// {
|
|
1575
|
+
// "result":true,
|
|
1576
|
+
// "data":{
|
|
1577
|
+
// "cummulativeQuoteQty":0,
|
|
1578
|
+
// "symbol":"doge_usdt",
|
|
1579
|
+
// "executedQty":0,
|
|
1580
|
+
// "orderId":"53d2d53e-70fb-4398-b722-f48571a5f61e",
|
|
1581
|
+
// "origQty":1E+2,
|
|
1582
|
+
// "price":0.05,
|
|
1583
|
+
// "clientOrderId":null,
|
|
1584
|
+
// "origQuoteOrderQty":5,
|
|
1585
|
+
// "updateTime":1648163406000,
|
|
1586
|
+
// "time":1648163139387,
|
|
1587
|
+
// "type":"buy_maker",
|
|
1588
|
+
// "status":-1
|
|
1589
|
+
// },
|
|
1590
|
+
// "error_code":0,
|
|
1591
|
+
// "ts":1648164471827
|
|
1592
|
+
// }
|
|
1593
|
+
//
|
|
1594
|
+
const result = this.safeValue(response, 'data', {});
|
|
1595
|
+
return this.parseOrder(result);
|
|
1596
|
+
}
|
|
1597
|
+
async fetchOrderDefault(id, symbol = undefined, params = {}) {
|
|
1598
|
+
// Id can be a list of ids delimited by a comma
|
|
1599
|
+
if (symbol === undefined) {
|
|
1600
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
|
|
1601
|
+
}
|
|
1602
|
+
await this.loadMarkets();
|
|
1603
|
+
const market = this.market(symbol);
|
|
1604
|
+
const request = {
|
|
1605
|
+
'symbol': market['id'],
|
|
1606
|
+
'order_id': id,
|
|
1607
|
+
};
|
|
1608
|
+
const response = await this.spotPrivatePostOrdersInfo(this.extend(request, params));
|
|
1609
|
+
//
|
|
1610
|
+
// {
|
|
1611
|
+
// "result":true,
|
|
1612
|
+
// "data":[
|
|
1613
|
+
// {
|
|
1614
|
+
// "symbol":"doge_usdt",
|
|
1615
|
+
// "amount":18,
|
|
1616
|
+
// "create_time":1647455223186,
|
|
1617
|
+
// "price":0,
|
|
1618
|
+
// "avg_price":0.113344,
|
|
1619
|
+
// "type":"sell_market",
|
|
1620
|
+
// "order_id":"d4ca1ddd-40d9-42c1-9717-5de435865bec",
|
|
1621
|
+
// "deal_amount":18,
|
|
1622
|
+
// "status":2
|
|
1623
|
+
// }
|
|
1624
|
+
// ],
|
|
1625
|
+
// "error_code":0,
|
|
1626
|
+
// "ts":1647455270776
|
|
1627
|
+
// }
|
|
1628
|
+
//
|
|
1629
|
+
const result = this.safeValue(response, 'data', []);
|
|
1630
|
+
const numOrders = result.length;
|
|
1631
|
+
if (numOrders === 1) {
|
|
1632
|
+
return this.parseOrder(result[0]);
|
|
1633
|
+
}
|
|
1634
|
+
else {
|
|
1635
|
+
// const parsedOrders = [];
|
|
1636
|
+
// for (let i = 0; i < numOrders; i++) {
|
|
1637
|
+
// const parsedOrder = this.parseOrder (result[i]);
|
|
1638
|
+
// parsedOrders.push (parsedOrder);
|
|
1639
|
+
// }
|
|
1640
|
+
// return parsedOrders;
|
|
1641
|
+
throw new errors.BadRequest(this.id + ' fetchOrder() can only fetch one order at a time');
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1645
|
+
/**
|
|
1646
|
+
* @method
|
|
1647
|
+
* @name lbank2#fetchMyTrades
|
|
1648
|
+
* @description fetch all trades made by the user
|
|
1649
|
+
* @see https://www.lbank.com/en-US/docs/index.html#past-transaction-details
|
|
1650
|
+
* @param {string} symbol unified market symbol
|
|
1651
|
+
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
1652
|
+
* @param {int} [limit] the maximum number of trade structures to retrieve
|
|
1653
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1654
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
1655
|
+
*/
|
|
1656
|
+
if (symbol === undefined) {
|
|
1657
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
|
|
1658
|
+
}
|
|
1659
|
+
await this.loadMarkets();
|
|
1660
|
+
const market = this.market(symbol);
|
|
1661
|
+
since = this.safeValue(params, 'start_date', since);
|
|
1662
|
+
params = this.omit(params, 'start_date');
|
|
1663
|
+
const request = {
|
|
1664
|
+
'symbol': market['id'],
|
|
1665
|
+
// 'start_date' Start time yyyy-mm-dd, the maximum is today, the default is yesterday
|
|
1666
|
+
// 'end_date' Finish time yyyy-mm-dd, the maximum is today, the default is today
|
|
1667
|
+
// 'The start': and end date of the query window is up to 2 days
|
|
1668
|
+
// 'from' Initial transaction number inquiring
|
|
1669
|
+
// 'direct' inquire direction,The default is the 'next' which is the positive sequence of dealing time,the 'prev' is inverted order of dealing time
|
|
1670
|
+
// 'size' Query the number of defaults to 100
|
|
1671
|
+
};
|
|
1672
|
+
if (limit !== undefined) {
|
|
1673
|
+
request['size'] = limit;
|
|
1674
|
+
}
|
|
1675
|
+
if (since !== undefined) {
|
|
1676
|
+
request['start_date'] = this.ymd(since, '-'); // max query 2 days ago
|
|
1677
|
+
request['end_date'] = this.ymd(since + 86400000, '-'); // will cover 2 days
|
|
1678
|
+
}
|
|
1679
|
+
const response = await this.spotPrivatePostTransactionHistory(this.extend(request, params));
|
|
1680
|
+
//
|
|
1681
|
+
// {
|
|
1682
|
+
// "result":true,
|
|
1683
|
+
// "data":[
|
|
1684
|
+
// {
|
|
1685
|
+
// "orderUuid":"38b4e7a4-14f6-45fd-aba1-1a37024124a0",
|
|
1686
|
+
// "tradeFeeRate":0.0010000000,
|
|
1687
|
+
// "dealTime":1648500944496,
|
|
1688
|
+
// "dealQuantity":30.00000000000000000000,
|
|
1689
|
+
// "tradeFee":0.00453300000000000000,
|
|
1690
|
+
// "txUuid":"11f3850cc6214ea3b495adad3a032794",
|
|
1691
|
+
// "dealPrice":0.15111300000000000000,
|
|
1692
|
+
// "dealVolumePrice":4.53339000000000000000,
|
|
1693
|
+
// "tradeType":"sell_market"
|
|
1694
|
+
// }
|
|
1695
|
+
// ],
|
|
1696
|
+
// "error_code":0,
|
|
1697
|
+
// "ts":1648509742164
|
|
1698
|
+
// }
|
|
1699
|
+
//
|
|
1700
|
+
const trades = this.safeValue(response, 'data', []);
|
|
1701
|
+
return this.parseTrades(trades, market, since, limit);
|
|
1702
|
+
}
|
|
1703
|
+
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1704
|
+
/**
|
|
1705
|
+
* @method
|
|
1706
|
+
* @name lbank2#fetchOrders
|
|
1707
|
+
* @description fetches information on multiple orders made by the user
|
|
1708
|
+
* @see https://www.lbank.com/en-US/docs/index.html#query-all-orders
|
|
1709
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
1710
|
+
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
1711
|
+
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
1712
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1713
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1714
|
+
*/
|
|
1715
|
+
// default query is for canceled and completely filled orders
|
|
1716
|
+
// does not return open orders unless specified explicitly
|
|
1717
|
+
if (symbol === undefined) {
|
|
1718
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchOrders() requires a symbol argument');
|
|
1719
|
+
}
|
|
1720
|
+
await this.loadMarkets();
|
|
1721
|
+
const market = this.market(symbol);
|
|
1722
|
+
if (limit === undefined) {
|
|
1723
|
+
limit = 100;
|
|
1724
|
+
}
|
|
1725
|
+
const request = {
|
|
1726
|
+
'symbol': market['id'],
|
|
1727
|
+
'current_page': 1,
|
|
1728
|
+
'page_length': limit,
|
|
1729
|
+
// 'status' -1: Cancelled, 0: Unfilled, 1: Partially filled, 2: Completely filled, 3: Partially filled and cancelled, 4: Cancellation is being processed
|
|
1730
|
+
};
|
|
1731
|
+
const response = await this.spotPrivatePostSupplementOrdersInfoHistory(this.extend(request, params));
|
|
1732
|
+
//
|
|
1733
|
+
// {
|
|
1734
|
+
// "result":true,
|
|
1735
|
+
// "data":{
|
|
1736
|
+
// "total":1,
|
|
1737
|
+
// "page_length":100,
|
|
1738
|
+
// "orders":[
|
|
1739
|
+
// {
|
|
1740
|
+
// "cummulativeQuoteQty":0,
|
|
1741
|
+
// "symbol":"doge_usdt",
|
|
1742
|
+
// "executedQty":0,
|
|
1743
|
+
// "orderId":"2cadc7cc-b5f6-486b-a5b4-d6ac49a9c186",
|
|
1744
|
+
// "origQty":100,
|
|
1745
|
+
// "price":0.05,
|
|
1746
|
+
// "origQuoteOrderQty":5,
|
|
1747
|
+
// "updateTime":1648501384000,
|
|
1748
|
+
// "time":1648501363889,
|
|
1749
|
+
// "type":"buy",
|
|
1750
|
+
// "status":-1
|
|
1751
|
+
// }, ...
|
|
1752
|
+
// ],
|
|
1753
|
+
// "current_page":1
|
|
1754
|
+
// },
|
|
1755
|
+
// "error_code":0,
|
|
1756
|
+
// "ts":1648505706348
|
|
1757
|
+
// }
|
|
1758
|
+
//
|
|
1759
|
+
const result = this.safeValue(response, 'data', {});
|
|
1760
|
+
const orders = this.safeValue(result, 'orders', []);
|
|
1761
|
+
return this.parseOrders(orders, market, since, limit);
|
|
1762
|
+
}
|
|
1763
|
+
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1764
|
+
/**
|
|
1765
|
+
* @method
|
|
1766
|
+
* @name lbank2#fetchOpenOrders
|
|
1767
|
+
* @description fetch all unfilled currently open orders
|
|
1768
|
+
* @see https://www.lbank.com/en-US/docs/index.html#current-pending-order
|
|
1769
|
+
* @param {string} symbol unified market symbol
|
|
1770
|
+
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
1771
|
+
* @param {int} [limit] the maximum number of open order structures to retrieve
|
|
1772
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1773
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1774
|
+
*/
|
|
1775
|
+
if (symbol === undefined) {
|
|
1776
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchOpenOrders() requires a symbol argument');
|
|
1777
|
+
}
|
|
1778
|
+
await this.loadMarkets();
|
|
1779
|
+
const market = this.market(symbol);
|
|
1780
|
+
if (limit === undefined) {
|
|
1781
|
+
limit = 100;
|
|
1782
|
+
}
|
|
1783
|
+
const request = {
|
|
1784
|
+
'symbol': market['id'],
|
|
1785
|
+
'current_page': 1,
|
|
1786
|
+
'page_length': limit,
|
|
1787
|
+
};
|
|
1788
|
+
const response = await this.spotPrivatePostSupplementOrdersInfoNoDeal(this.extend(request, params));
|
|
1789
|
+
//
|
|
1790
|
+
// {
|
|
1791
|
+
// "result":true,
|
|
1792
|
+
// "data":{
|
|
1793
|
+
// "total":1,
|
|
1794
|
+
// "page_length":100,
|
|
1795
|
+
// "orders":[
|
|
1796
|
+
// {
|
|
1797
|
+
// "cummulativeQuoteQty":0,
|
|
1798
|
+
// "symbol":"doge_usdt",
|
|
1799
|
+
// "executedQty":0,
|
|
1800
|
+
// "orderId":"73878edf-008d-4e4c-8041-df1f1b2cd8bb",
|
|
1801
|
+
// "origQty":100,
|
|
1802
|
+
// "price":0.05,
|
|
1803
|
+
// "origQuoteOrderQty":5,
|
|
1804
|
+
// "updateTime":1648501762000,
|
|
1805
|
+
// "time":1648501762353,
|
|
1806
|
+
// "type":"buy",
|
|
1807
|
+
// "status":0
|
|
1808
|
+
// }, ...
|
|
1809
|
+
// ],
|
|
1810
|
+
// "current_page":1
|
|
1811
|
+
// },
|
|
1812
|
+
// "error_code":0,
|
|
1813
|
+
// "ts":1648506110196
|
|
1814
|
+
// }
|
|
1815
|
+
//
|
|
1816
|
+
const result = this.safeValue(response, 'data', {});
|
|
1817
|
+
const orders = this.safeValue(result, 'orders', []);
|
|
1818
|
+
return this.parseOrders(orders, market, since, limit);
|
|
1819
|
+
}
|
|
1820
|
+
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
1821
|
+
/**
|
|
1822
|
+
* @method
|
|
1823
|
+
* @name lbank2#cancelOrder
|
|
1824
|
+
* @description cancels an open order
|
|
1825
|
+
* @see https://www.lbank.com/en-US/docs/index.html#cancel-order-new
|
|
1826
|
+
* @param {string} id order id
|
|
1827
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
1828
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1829
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1830
|
+
*/
|
|
1831
|
+
if (symbol === undefined) {
|
|
1832
|
+
throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
|
|
1833
|
+
}
|
|
1834
|
+
await this.loadMarkets();
|
|
1835
|
+
const clientOrderId = this.safeString2(params, 'origClientOrderId', 'clientOrderId');
|
|
1836
|
+
params = this.omit(params, ['origClientOrderId', 'clientOrderId']);
|
|
1837
|
+
const market = this.market(symbol);
|
|
1838
|
+
const request = {
|
|
1839
|
+
'symbol': market['id'],
|
|
1840
|
+
'orderId': id,
|
|
1841
|
+
};
|
|
1842
|
+
if (clientOrderId !== undefined) {
|
|
1843
|
+
request['origClientOrderId'] = clientOrderId;
|
|
1844
|
+
}
|
|
1845
|
+
const response = await this.spotPrivatePostSupplementCancelOrder(this.extend(request, params));
|
|
1846
|
+
//
|
|
1847
|
+
// {
|
|
1848
|
+
// "result":true,
|
|
1849
|
+
// "data":{
|
|
1850
|
+
// "executedQty":0.0,
|
|
1851
|
+
// "price":0.05,
|
|
1852
|
+
// "origQty":100.0,
|
|
1853
|
+
// "tradeType":"buy",
|
|
1854
|
+
// "status":0
|
|
1855
|
+
// },
|
|
1856
|
+
// "error_code":0,
|
|
1857
|
+
// "ts":1648501286196
|
|
1858
|
+
// }
|
|
1859
|
+
const result = this.safeValue(response, 'data', {});
|
|
1860
|
+
return result;
|
|
1861
|
+
}
|
|
1862
|
+
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
1863
|
+
/**
|
|
1864
|
+
* @method
|
|
1865
|
+
* @name lbank2#cancelAllOrders
|
|
1866
|
+
* @description cancel all open orders in a market
|
|
1867
|
+
* @see https://www.lbank.com/en-US/docs/index.html#cancel-all-pending-orders-for-a-single-trading-pair
|
|
1868
|
+
* @param {string} symbol unified market symbol of the market to cancel orders in
|
|
1869
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1870
|
+
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1871
|
+
*/
|
|
1872
|
+
if (symbol === undefined) {
|
|
1873
|
+
throw new errors.ArgumentsRequired(this.id + ' cancelAllOrders() requires a symbol argument');
|
|
1874
|
+
}
|
|
1875
|
+
await this.loadMarkets();
|
|
1876
|
+
const market = this.market(symbol);
|
|
1877
|
+
const request = {
|
|
1878
|
+
'symbol': market['id'],
|
|
1879
|
+
};
|
|
1880
|
+
const response = await this.spotPrivatePostSupplementCancelOrderBySymbol(this.extend(request, params));
|
|
1881
|
+
//
|
|
1882
|
+
// {
|
|
1883
|
+
// "result":"true",
|
|
1884
|
+
// "data":[
|
|
1885
|
+
// {
|
|
1886
|
+
// "executedQty":0.00000000000000000000,
|
|
1887
|
+
// "orderId":"293ef71b-3e67-4962-af93-aa06990a045f",
|
|
1888
|
+
// "price":0.05000000000000000000,
|
|
1889
|
+
// "origQty":100.00000000000000000000,
|
|
1890
|
+
// "tradeType":"buy",
|
|
1891
|
+
// "status":0
|
|
1892
|
+
// },
|
|
1893
|
+
// ],
|
|
1894
|
+
// "error_code":0,
|
|
1895
|
+
// "ts":1648506641469
|
|
1896
|
+
// }
|
|
1897
|
+
//
|
|
1898
|
+
const result = this.safeValue(response, 'data', []);
|
|
1899
|
+
return result;
|
|
1900
|
+
}
|
|
1901
|
+
getNetworkCodeForCurrency(currencyCode, params) {
|
|
1902
|
+
const defaultNetworks = this.safeValue(this.options, 'defaultNetworks');
|
|
1903
|
+
const defaultNetwork = this.safeStringUpper(defaultNetworks, currencyCode);
|
|
1904
|
+
const networks = this.safeValue(this.options, 'networks', {});
|
|
1905
|
+
let network = this.safeStringUpper(params, 'network', defaultNetwork); // this line allows the user to specify either ERC20 or ETH
|
|
1906
|
+
network = this.safeString(networks, network, network); // handle ERC20>ETH alias
|
|
1907
|
+
return network;
|
|
1908
|
+
}
|
|
1909
|
+
async fetchDepositAddress(code, params = {}) {
|
|
1910
|
+
/**
|
|
1911
|
+
* @method
|
|
1912
|
+
* @name lbank2#fetchDepositAddress
|
|
1913
|
+
* @description fetch the deposit address for a currency associated with this account
|
|
1914
|
+
* @see https://www.lbank.com/en-US/docs/index.html#get-deposit-address
|
|
1915
|
+
* @see https://www.lbank.com/en-US/docs/index.html#the-user-obtains-the-deposit-address
|
|
1916
|
+
* @param {string} code unified currency code
|
|
1917
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1918
|
+
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
1919
|
+
*/
|
|
1920
|
+
await this.loadMarkets();
|
|
1921
|
+
const options = this.safeValue(this.options, 'fetchDepositAddress', {});
|
|
1922
|
+
const defaultMethod = this.safeString(options, 'method', 'fetchDepositAddressDefault');
|
|
1923
|
+
const method = this.safeString(params, 'method', defaultMethod);
|
|
1924
|
+
params = this.omit(params, 'method');
|
|
1925
|
+
let response = undefined;
|
|
1926
|
+
if (method === 'fetchDepositAddressSupplement') {
|
|
1927
|
+
response = await this.fetchDepositAddressSupplement(code, params);
|
|
1928
|
+
}
|
|
1929
|
+
else {
|
|
1930
|
+
response = await this.fetchDepositAddressDefault(code, params);
|
|
1931
|
+
}
|
|
1932
|
+
return response;
|
|
1933
|
+
}
|
|
1934
|
+
async fetchDepositAddressDefault(code, params = {}) {
|
|
1935
|
+
await this.loadMarkets();
|
|
1936
|
+
const currency = this.currency(code);
|
|
1937
|
+
const request = {
|
|
1938
|
+
'assetCode': currency['id'],
|
|
1939
|
+
};
|
|
1940
|
+
const network = this.getNetworkCodeForCurrency(code, params);
|
|
1941
|
+
if (network !== undefined) {
|
|
1942
|
+
request['netWork'] = network; // ... yes, really lol
|
|
1943
|
+
params = this.omit(params, 'network');
|
|
1944
|
+
}
|
|
1945
|
+
const response = await this.spotPrivatePostGetDepositAddress(this.extend(request, params));
|
|
1946
|
+
//
|
|
1947
|
+
// {
|
|
1948
|
+
// "result":true,
|
|
1949
|
+
// "data":{
|
|
1950
|
+
// "assetCode":"usdt",
|
|
1951
|
+
// "address":"0xc85689d37ca650bf2f2161364cdedee21eb6ca53",
|
|
1952
|
+
// "memo":null,
|
|
1953
|
+
// "netWork":"bep20(bsc)"
|
|
1954
|
+
// },
|
|
1955
|
+
// "error_code":0,
|
|
1956
|
+
// "ts":1648075865103
|
|
1957
|
+
// }
|
|
1958
|
+
//
|
|
1959
|
+
const result = this.safeValue(response, 'data');
|
|
1960
|
+
const address = this.safeString(result, 'address');
|
|
1961
|
+
const tag = this.safeString(result, 'memo');
|
|
1962
|
+
const networkId = this.safeString(result, 'netWork');
|
|
1963
|
+
const inverseNetworks = this.safeValue(this.options, 'inverse-networks', {});
|
|
1964
|
+
const networkCode = this.safeStringUpper(inverseNetworks, networkId, networkId);
|
|
1965
|
+
return {
|
|
1966
|
+
'currency': code,
|
|
1967
|
+
'address': address,
|
|
1968
|
+
'tag': tag,
|
|
1969
|
+
'network': networkCode,
|
|
1970
|
+
'info': response,
|
|
1971
|
+
};
|
|
1972
|
+
}
|
|
1973
|
+
async fetchDepositAddressSupplement(code, params = {}) {
|
|
1974
|
+
// returns the address for whatever the default network is...
|
|
1975
|
+
await this.loadMarkets();
|
|
1976
|
+
const currency = this.currency(code);
|
|
1977
|
+
const request = {
|
|
1978
|
+
'coin': currency['id'],
|
|
1979
|
+
};
|
|
1980
|
+
const networks = this.safeValue(this.options, 'networks');
|
|
1981
|
+
let network = this.safeStringUpper(params, 'network');
|
|
1982
|
+
network = this.safeString(networks, network, network);
|
|
1983
|
+
if (network !== undefined) {
|
|
1984
|
+
request['networkName'] = network;
|
|
1985
|
+
params = this.omit(params, 'network');
|
|
1986
|
+
}
|
|
1987
|
+
const response = await this.spotPrivatePostSupplementGetDepositAddress(this.extend(request, params));
|
|
1988
|
+
//
|
|
1989
|
+
// {
|
|
1990
|
+
// "result":true,
|
|
1991
|
+
// "data":{
|
|
1992
|
+
// "address":"TDxtabCC8iQwaxUUrPcE4WL2jArGAfvQ5A",
|
|
1993
|
+
// "memo":null,
|
|
1994
|
+
// "coin":"usdt"
|
|
1995
|
+
// },
|
|
1996
|
+
// "error_code":0,
|
|
1997
|
+
// "ts":1648073818880
|
|
1998
|
+
// }
|
|
1999
|
+
//
|
|
2000
|
+
const result = this.safeValue(response, 'data');
|
|
2001
|
+
const address = this.safeString(result, 'address');
|
|
2002
|
+
const tag = this.safeString(result, 'memo');
|
|
2003
|
+
const inverseNetworks = this.safeValue(this.options, 'inverse-networks', {});
|
|
2004
|
+
const networkCode = this.safeStringUpper(inverseNetworks, network, network);
|
|
2005
|
+
return {
|
|
2006
|
+
'currency': code,
|
|
2007
|
+
'address': address,
|
|
2008
|
+
'tag': tag,
|
|
2009
|
+
'network': networkCode,
|
|
2010
|
+
'info': response,
|
|
2011
|
+
};
|
|
2012
|
+
}
|
|
2013
|
+
async withdraw(code, amount, address, tag = undefined, params = {}) {
|
|
2014
|
+
/**
|
|
2015
|
+
* @method
|
|
2016
|
+
* @name lbank2#withdraw
|
|
2017
|
+
* @description make a withdrawal
|
|
2018
|
+
* @see https://www.lbank.com/en-US/docs/index.html#withdrawal
|
|
2019
|
+
* @param {string} code unified currency code
|
|
2020
|
+
* @param {float} amount the amount to withdraw
|
|
2021
|
+
* @param {string} address the address to withdraw to
|
|
2022
|
+
* @param {string} tag
|
|
2023
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2024
|
+
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
2025
|
+
*/
|
|
2026
|
+
[tag, params] = this.handleWithdrawTagAndParams(tag, params);
|
|
2027
|
+
this.checkAddress(address);
|
|
2028
|
+
await this.loadMarkets();
|
|
2029
|
+
const fee = this.safeString(params, 'fee');
|
|
2030
|
+
params = this.omit(params, 'fee');
|
|
2031
|
+
// 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, this can also be found in fetchDepositWithdrawFees ().
|
|
2032
|
+
this.checkRequiredArgument('withdraw', fee, 'fee');
|
|
2033
|
+
const currency = this.currency(code);
|
|
2034
|
+
const request = {
|
|
2035
|
+
'address': address,
|
|
2036
|
+
'coin': currency['id'],
|
|
2037
|
+
'amount': amount,
|
|
2038
|
+
'fee': fee, // the correct coin-network fee must be supplied, which can be found by calling fetchDepositWithdrawFees (private)
|
|
2039
|
+
// 'networkName': defaults to the defaultNetwork of the coin which can be found in the /supplement/user_info endpoint
|
|
2040
|
+
// 'memo': memo: memo word of bts and dct
|
|
2041
|
+
// 'mark': Withdrawal Notes
|
|
2042
|
+
// 'name': Remarks of the address. After filling in this parameter, it will be added to the withdrawal address book of the currency.
|
|
2043
|
+
// 'withdrawOrderId': withdrawOrderId
|
|
2044
|
+
// 'type': type=1 is for intra-site transfer
|
|
2045
|
+
};
|
|
2046
|
+
if (tag !== undefined) {
|
|
2047
|
+
request['memo'] = tag;
|
|
2048
|
+
}
|
|
2049
|
+
const network = this.safeStringUpper2(params, 'network', 'networkName');
|
|
2050
|
+
params = this.omit(params, ['network', 'networkName']);
|
|
2051
|
+
const networks = this.safeValue(this.options, 'networks');
|
|
2052
|
+
const networkId = this.safeString(networks, network, network);
|
|
2053
|
+
if (networkId !== undefined) {
|
|
2054
|
+
request['networkName'] = networkId;
|
|
2055
|
+
}
|
|
2056
|
+
const response = await this.spotPrivatePostSupplementWithdraw(this.extend(request, params));
|
|
2057
|
+
//
|
|
2058
|
+
// {
|
|
2059
|
+
// "result":true,
|
|
2060
|
+
// "data": {
|
|
2061
|
+
// "fee":10.00000000000000000000,
|
|
2062
|
+
// "withdrawId":1900376
|
|
2063
|
+
// },
|
|
2064
|
+
// "error_code":0,
|
|
2065
|
+
// "ts":1648992501414
|
|
2066
|
+
// }
|
|
2067
|
+
//
|
|
2068
|
+
const result = this.safeValue(response, 'data', {});
|
|
2069
|
+
return {
|
|
2070
|
+
'info': result,
|
|
2071
|
+
'id': this.safeString(result, 'withdrawId'),
|
|
2072
|
+
};
|
|
2073
|
+
}
|
|
2074
|
+
parseTransactionStatus(status, type) {
|
|
2075
|
+
const statuses = {
|
|
2076
|
+
'deposit': {
|
|
2077
|
+
'1': 'pending',
|
|
2078
|
+
'2': 'ok',
|
|
2079
|
+
'3': 'failed',
|
|
2080
|
+
'4': 'canceled',
|
|
2081
|
+
'5': 'transfer',
|
|
2082
|
+
},
|
|
2083
|
+
'withdrawal': {
|
|
2084
|
+
'1': 'pending',
|
|
2085
|
+
'2': 'canceled',
|
|
2086
|
+
'3': 'failed',
|
|
2087
|
+
'4': 'ok',
|
|
2088
|
+
},
|
|
2089
|
+
};
|
|
2090
|
+
return this.safeString(this.safeValue(statuses, type, {}), status, status);
|
|
2091
|
+
}
|
|
2092
|
+
parseTransaction(transaction, currency = undefined) {
|
|
2093
|
+
//
|
|
2094
|
+
// fetchDeposits (private)
|
|
2095
|
+
//
|
|
2096
|
+
// {
|
|
2097
|
+
// "insertTime":1649012310000,
|
|
2098
|
+
// "amount":9.00000000000000000000,
|
|
2099
|
+
// "address":"TYASr5UV6HEcXatwdFQfmLVUqQQQMUxHLS",
|
|
2100
|
+
// "networkName":"trc20",
|
|
2101
|
+
// "txId":"081e4e9351dd0274922168da5f2d14ea6c495b1c3b440244f4a6dd9fe196bf2b",
|
|
2102
|
+
// "coin":"usdt",
|
|
2103
|
+
// "status":"2"
|
|
2104
|
+
// }
|
|
2105
|
+
//
|
|
2106
|
+
//
|
|
2107
|
+
// fetchWithdrawals (private)
|
|
2108
|
+
//
|
|
2109
|
+
// {
|
|
2110
|
+
// "amount":2.00000000000000000000,
|
|
2111
|
+
// "address":"TBjrW5JHDyPZjFc5nrRMhRWUDaJmhGhmD6",
|
|
2112
|
+
// "fee":1.00000000000000000000,
|
|
2113
|
+
// "networkName":"trc20",
|
|
2114
|
+
// "coid":"usdt",
|
|
2115
|
+
// "transferType":"数字资产提现",
|
|
2116
|
+
// "txId":"47eeee2763ad49b8817524dacfa7d092fb58f8b0ab7e5d25473314df1a793c3d",
|
|
2117
|
+
// "id":1902194,
|
|
2118
|
+
// "applyTime":1649014002000,
|
|
2119
|
+
// "status":"4"
|
|
2120
|
+
// }
|
|
2121
|
+
//
|
|
2122
|
+
const id = this.safeString(transaction, 'id');
|
|
2123
|
+
let type = undefined;
|
|
2124
|
+
if (id === undefined) {
|
|
2125
|
+
type = 'deposit';
|
|
2126
|
+
}
|
|
2127
|
+
else {
|
|
2128
|
+
type = 'withdrawal';
|
|
2129
|
+
}
|
|
2130
|
+
const txid = this.safeString(transaction, 'txId');
|
|
2131
|
+
const timestamp = this.safeInteger2(transaction, 'insertTime', 'applyTime');
|
|
2132
|
+
const networks = this.safeValue(this.options, 'inverse-networks', {});
|
|
2133
|
+
const networkId = this.safeString(transaction, 'networkName');
|
|
2134
|
+
const network = this.safeString(networks, networkId, networkId);
|
|
2135
|
+
const address = this.safeString(transaction, 'address');
|
|
2136
|
+
let addressFrom = undefined;
|
|
2137
|
+
let addressTo = undefined;
|
|
2138
|
+
if (type === 'deposit') {
|
|
2139
|
+
addressFrom = address;
|
|
2140
|
+
}
|
|
2141
|
+
else {
|
|
2142
|
+
addressTo = address;
|
|
2143
|
+
}
|
|
2144
|
+
const amount = this.safeNumber(transaction, 'amount');
|
|
2145
|
+
const currencyId = this.safeString2(transaction, 'coin', 'coid');
|
|
2146
|
+
const code = this.safeCurrencyCode(currencyId, currency);
|
|
2147
|
+
const status = this.parseTransactionStatus(this.safeString(transaction, 'status'), type);
|
|
2148
|
+
let fee = undefined;
|
|
2149
|
+
const feeCost = this.safeNumber(transaction, 'fee');
|
|
2150
|
+
if (feeCost !== undefined) {
|
|
2151
|
+
fee = {
|
|
2152
|
+
'cost': feeCost,
|
|
2153
|
+
'currency': code,
|
|
2154
|
+
};
|
|
2155
|
+
}
|
|
2156
|
+
return {
|
|
2157
|
+
'info': transaction,
|
|
2158
|
+
'id': id,
|
|
2159
|
+
'txid': txid,
|
|
2160
|
+
'timestamp': timestamp,
|
|
2161
|
+
'datetime': this.iso8601(timestamp),
|
|
2162
|
+
'network': network,
|
|
2163
|
+
'address': address,
|
|
2164
|
+
'addressTo': addressTo,
|
|
2165
|
+
'addressFrom': addressFrom,
|
|
2166
|
+
'tag': undefined,
|
|
2167
|
+
'tagTo': undefined,
|
|
2168
|
+
'tagFrom': undefined,
|
|
2169
|
+
'type': type,
|
|
2170
|
+
'amount': amount,
|
|
2171
|
+
'currency': code,
|
|
2172
|
+
'status': status,
|
|
2173
|
+
'updated': undefined,
|
|
2174
|
+
'comment': undefined,
|
|
2175
|
+
'internal': (status === 'transfer'),
|
|
2176
|
+
'fee': fee,
|
|
2177
|
+
};
|
|
2178
|
+
}
|
|
2179
|
+
async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2180
|
+
/**
|
|
2181
|
+
* @method
|
|
2182
|
+
* @name lbank2#fetchDeposits
|
|
2183
|
+
* @description fetch all deposits made to an account
|
|
2184
|
+
* @see https://www.lbank.com/en-US/docs/index.html#get-recharge-history
|
|
2185
|
+
* @param {string} code unified currency code
|
|
2186
|
+
* @param {int} [since] the earliest time in ms to fetch deposits for
|
|
2187
|
+
* @param {int} [limit] the maximum number of deposits structures to retrieve
|
|
2188
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2189
|
+
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
2190
|
+
*/
|
|
2191
|
+
await this.loadMarkets();
|
|
2192
|
+
const request = {
|
|
2193
|
+
// 'status': Recharge status: ("1","Applying"),("2","Recharge successful"),("3","Recharge failed"),("4","Already Cancel"), ("5", "Transfer")
|
|
2194
|
+
// 'endTime': end time, timestamp in milliseconds, default now
|
|
2195
|
+
};
|
|
2196
|
+
let currency = undefined;
|
|
2197
|
+
if (code !== undefined) {
|
|
2198
|
+
currency = this.currency(code);
|
|
2199
|
+
request['coin'] = currency['id'];
|
|
2200
|
+
}
|
|
2201
|
+
if (since !== undefined) {
|
|
2202
|
+
request['startTime'] = since;
|
|
2203
|
+
}
|
|
2204
|
+
const response = await this.spotPrivatePostSupplementDepositHistory(this.extend(request, params));
|
|
2205
|
+
//
|
|
2206
|
+
// {
|
|
2207
|
+
// "result":true,
|
|
2208
|
+
// "data": {
|
|
2209
|
+
// "total":1,
|
|
2210
|
+
// "depositOrders": [
|
|
2211
|
+
// {
|
|
2212
|
+
// "insertTime":1649012310000,
|
|
2213
|
+
// "amount":9.00000000000000000000,
|
|
2214
|
+
// "address":"TYASr5UV6HEcXatwdFQfmLVUqQQQMUxHLS",
|
|
2215
|
+
// "networkName":"trc20",
|
|
2216
|
+
// "txId":"081e4e9351dd0274922168da5f2d14ea6c495b1c3b440244f4a6dd9fe196bf2b",
|
|
2217
|
+
// "coin":"usdt",
|
|
2218
|
+
// "status":"2"
|
|
2219
|
+
// },
|
|
2220
|
+
// ],
|
|
2221
|
+
// "page_length":20,
|
|
2222
|
+
// "current_page":1
|
|
2223
|
+
// },
|
|
2224
|
+
// "error_code":0,
|
|
2225
|
+
// "ts":1649719721758
|
|
2226
|
+
// }
|
|
2227
|
+
//
|
|
2228
|
+
const data = this.safeValue(response, 'data', {});
|
|
2229
|
+
const deposits = this.safeValue(data, 'depositOrders', []);
|
|
2230
|
+
return this.parseTransactions(deposits, currency, since, limit);
|
|
2231
|
+
}
|
|
2232
|
+
async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2233
|
+
/**
|
|
2234
|
+
* @method
|
|
2235
|
+
* @name lbank2#fetchWithdrawals
|
|
2236
|
+
* @description fetch all withdrawals made from an account
|
|
2237
|
+
* @see https://www.lbank.com/en-US/docs/index.html#get-withdrawal-history
|
|
2238
|
+
* @param {string} code unified currency code
|
|
2239
|
+
* @param {int} [since] the earliest time in ms to fetch withdrawals for
|
|
2240
|
+
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
|
|
2241
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2242
|
+
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
2243
|
+
*/
|
|
2244
|
+
await this.loadMarkets();
|
|
2245
|
+
const request = {
|
|
2246
|
+
// 'status': Recharge status: ("1","Applying"),("2","Recharge successful"),("3","Recharge failed"),("4","Already Cancel"), ("5", "Transfer")
|
|
2247
|
+
// 'endTime': end time, timestamp in milliseconds, default now
|
|
2248
|
+
// 'withdrawOrderId': Custom withdrawal id
|
|
2249
|
+
};
|
|
2250
|
+
let currency = undefined;
|
|
2251
|
+
if (code !== undefined) {
|
|
2252
|
+
currency = this.currency(code);
|
|
2253
|
+
request['coin'] = currency['id'];
|
|
2254
|
+
}
|
|
2255
|
+
if (since !== undefined) {
|
|
2256
|
+
request['startTime'] = since;
|
|
2257
|
+
}
|
|
2258
|
+
const response = await this.spotPrivatePostSupplementWithdraws(this.extend(request, params));
|
|
2259
|
+
//
|
|
2260
|
+
// {
|
|
2261
|
+
// "result":true,
|
|
2262
|
+
// "data": {
|
|
2263
|
+
// "total":1,
|
|
2264
|
+
// "withdraws": [
|
|
2265
|
+
// {
|
|
2266
|
+
// "amount":2.00000000000000000000,
|
|
2267
|
+
// "address":"TBjrW5JHDyPZjFc5nrRMhRWUDaJmhGhmD6",
|
|
2268
|
+
// "fee":1.00000000000000000000,
|
|
2269
|
+
// "networkName":"trc20",
|
|
2270
|
+
// "coid":"usdt",
|
|
2271
|
+
// "transferType":"数字资产提现",
|
|
2272
|
+
// "txId":"47eeee2763ad49b8817524dacfa7d092fb58f8b0ab7e5d25473314df1a793c3d",
|
|
2273
|
+
// "id":1902194,
|
|
2274
|
+
// "applyTime":1649014002000,
|
|
2275
|
+
// "status":"4"
|
|
2276
|
+
// },
|
|
2277
|
+
// ],
|
|
2278
|
+
// "page_length":20,
|
|
2279
|
+
// "current_page":1
|
|
2280
|
+
// },
|
|
2281
|
+
// "error_code":0,
|
|
2282
|
+
// "ts":1649720362362
|
|
2283
|
+
// }
|
|
2284
|
+
//
|
|
2285
|
+
const data = this.safeValue(response, 'data', {});
|
|
2286
|
+
const withdraws = this.safeValue(data, 'withdraws', []);
|
|
2287
|
+
return this.parseTransactions(withdraws, currency, since, limit);
|
|
2288
|
+
}
|
|
2289
|
+
async fetchTransactionFees(codes = undefined, params = {}) {
|
|
2290
|
+
/**
|
|
2291
|
+
* @method
|
|
2292
|
+
* @name lbank2#fetchTransactionFees
|
|
2293
|
+
* @deprecated
|
|
2294
|
+
* @description please use fetchDepositWithdrawFees instead
|
|
2295
|
+
* @param {string[]|undefined} codes not used by lbank2 fetchTransactionFees ()
|
|
2296
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2297
|
+
* @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
2298
|
+
*/
|
|
2299
|
+
// private only returns information for currencies with non-zero balance
|
|
2300
|
+
await this.loadMarkets();
|
|
2301
|
+
const isAuthorized = this.checkRequiredCredentials(false);
|
|
2302
|
+
let result = undefined;
|
|
2303
|
+
if (isAuthorized === true) {
|
|
2304
|
+
const options = this.safeValue(this.options, 'fetchTransactionFees', {});
|
|
2305
|
+
const defaultMethod = this.safeString(options, 'method', 'fetchPrivateTransactionFees');
|
|
2306
|
+
const method = this.safeString(params, 'method', defaultMethod);
|
|
2307
|
+
params = this.omit(params, 'method');
|
|
2308
|
+
if (method === 'fetchPublicTransactionFees') {
|
|
2309
|
+
result = await this.fetchPublicTransactionFees(params);
|
|
2310
|
+
}
|
|
2311
|
+
else {
|
|
2312
|
+
result = await this.fetchPrivateTransactionFees(params);
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
else {
|
|
2316
|
+
result = await this.fetchPublicTransactionFees(params);
|
|
2317
|
+
}
|
|
2318
|
+
return result;
|
|
2319
|
+
}
|
|
2320
|
+
async fetchPrivateTransactionFees(params = {}) {
|
|
2321
|
+
// complete response
|
|
2322
|
+
// incl. for coins which undefined in public method
|
|
2323
|
+
await this.loadMarkets();
|
|
2324
|
+
const response = await this.spotPrivatePostSupplementUserInfo();
|
|
2325
|
+
//
|
|
2326
|
+
// {
|
|
2327
|
+
// "result": "true",
|
|
2328
|
+
// "data": [
|
|
2329
|
+
// {
|
|
2330
|
+
// "usableAmt": "14.36",
|
|
2331
|
+
// "assetAmt": "14.36",
|
|
2332
|
+
// "networkList": [
|
|
2333
|
+
// {
|
|
2334
|
+
// "isDefault": false,
|
|
2335
|
+
// "withdrawFeeRate": "",
|
|
2336
|
+
// "name": "erc20",
|
|
2337
|
+
// "withdrawMin": 30,
|
|
2338
|
+
// "minLimit": 0.0001,
|
|
2339
|
+
// "minDeposit": 20,
|
|
2340
|
+
// "feeAssetCode": "usdt",
|
|
2341
|
+
// "withdrawFee": "30",
|
|
2342
|
+
// "type": 1,
|
|
2343
|
+
// "coin": "usdt",
|
|
2344
|
+
// "network": "eth"
|
|
2345
|
+
// },
|
|
2346
|
+
// ...
|
|
2347
|
+
// ],
|
|
2348
|
+
// "freezeAmt": "0",
|
|
2349
|
+
// "coin": "ada"
|
|
2350
|
+
// }
|
|
2351
|
+
// ],
|
|
2352
|
+
// "code": 0
|
|
2353
|
+
// }
|
|
2354
|
+
//
|
|
2355
|
+
const result = this.safeValue(response, 'data', []);
|
|
2356
|
+
const withdrawFees = {};
|
|
2357
|
+
for (let i = 0; i < result.length; i++) {
|
|
2358
|
+
const entry = result[i];
|
|
2359
|
+
const currencyId = this.safeString(entry, 'coin');
|
|
2360
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
2361
|
+
const networkList = this.safeValue(entry, 'networkList', []);
|
|
2362
|
+
withdrawFees[code] = {};
|
|
2363
|
+
for (let j = 0; j < networkList.length; j++) {
|
|
2364
|
+
const networkEntry = networkList[j];
|
|
2365
|
+
const networkId = this.safeString(networkEntry, 'name');
|
|
2366
|
+
const networkCode = this.safeString(this.options['inverse-networks'], networkId, networkId);
|
|
2367
|
+
const fee = this.safeNumber(networkEntry, 'withdrawFee');
|
|
2368
|
+
if (fee !== undefined) {
|
|
2369
|
+
withdrawFees[code][networkCode] = fee;
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
return {
|
|
2374
|
+
'withdraw': withdrawFees,
|
|
2375
|
+
'deposit': {},
|
|
2376
|
+
'info': response,
|
|
2377
|
+
};
|
|
2378
|
+
}
|
|
2379
|
+
async fetchPublicTransactionFees(params = {}) {
|
|
2380
|
+
// extremely incomplete response
|
|
2381
|
+
// vast majority fees undefined
|
|
2382
|
+
await this.loadMarkets();
|
|
2383
|
+
const code = this.safeString2(params, 'coin', 'assetCode');
|
|
2384
|
+
params = this.omit(params, ['coin', 'assetCode']);
|
|
2385
|
+
const request = {};
|
|
2386
|
+
if (code !== undefined) {
|
|
2387
|
+
const currency = this.currency(code);
|
|
2388
|
+
request['assetCode'] = currency['id'];
|
|
2389
|
+
}
|
|
2390
|
+
const response = await this.spotPublicGetWithdrawConfigs(this.extend(request, params));
|
|
2391
|
+
//
|
|
2392
|
+
// {
|
|
2393
|
+
// "result": "true",
|
|
2394
|
+
// "data": [
|
|
2395
|
+
// {
|
|
2396
|
+
// "amountScale": "4",
|
|
2397
|
+
// "chain": "heco",
|
|
2398
|
+
// "assetCode": "lbk",
|
|
2399
|
+
// "min": "200",
|
|
2400
|
+
// "transferAmtScale": "4",
|
|
2401
|
+
// "canWithDraw": true,
|
|
2402
|
+
// "fee": "100",
|
|
2403
|
+
// "minTransfer": "0.0001",
|
|
2404
|
+
// "type": "1"
|
|
2405
|
+
// },
|
|
2406
|
+
// ...
|
|
2407
|
+
// ],
|
|
2408
|
+
// "error_code": "0",
|
|
2409
|
+
// "ts": "1663364435973"
|
|
2410
|
+
// }
|
|
2411
|
+
//
|
|
2412
|
+
const result = this.safeValue(response, 'data', []);
|
|
2413
|
+
const withdrawFees = {};
|
|
2414
|
+
for (let i = 0; i < result.length; i++) {
|
|
2415
|
+
const item = result[i];
|
|
2416
|
+
const canWithdraw = this.safeValue(item, 'canWithDraw');
|
|
2417
|
+
if (canWithdraw === 'true') {
|
|
2418
|
+
const currencyId = this.safeString(item, 'assetCode');
|
|
2419
|
+
const codeInner = this.safeCurrencyCode(currencyId);
|
|
2420
|
+
const chain = this.safeString(item, 'chain');
|
|
2421
|
+
let network = this.safeString(this.options['inverse-networks'], chain, chain);
|
|
2422
|
+
if (network === undefined) {
|
|
2423
|
+
network = codeInner;
|
|
2424
|
+
}
|
|
2425
|
+
const fee = this.safeString(item, 'fee');
|
|
2426
|
+
if (withdrawFees[codeInner] === undefined) {
|
|
2427
|
+
withdrawFees[codeInner] = {};
|
|
2428
|
+
}
|
|
2429
|
+
withdrawFees[codeInner][network] = this.parseNumber(fee);
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
return {
|
|
2433
|
+
'withdraw': withdrawFees,
|
|
2434
|
+
'deposit': {},
|
|
2435
|
+
'info': response,
|
|
2436
|
+
};
|
|
2437
|
+
}
|
|
2438
|
+
async fetchDepositWithdrawFees(codes = undefined, params = {}) {
|
|
2439
|
+
/**
|
|
2440
|
+
* @method
|
|
2441
|
+
* @name lbank2#fetchDepositWithdrawFees
|
|
2442
|
+
* @description when using private endpoint, only returns information for currencies with non-zero balance, use public method by specifying this.options['fetchDepositWithdrawFees']['method'] = 'fetchPublicDepositWithdrawFees'
|
|
2443
|
+
* @see https://www.lbank.com/en-US/docs/index.html#get-all-coins-information
|
|
2444
|
+
* @see https://www.lbank.com/en-US/docs/index.html#withdrawal-configurations
|
|
2445
|
+
* @param {string[]|undefined} codes array of unified currency codes
|
|
2446
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2447
|
+
* @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
2448
|
+
*/
|
|
2449
|
+
await this.loadMarkets();
|
|
2450
|
+
const isAuthorized = this.checkRequiredCredentials(false);
|
|
2451
|
+
const response = undefined;
|
|
2452
|
+
if (isAuthorized === true) {
|
|
2453
|
+
const options = this.safeValue(this.options, 'fetchDepositWithdrawFees', {});
|
|
2454
|
+
const defaultMethod = this.safeString(options, 'method', 'fetchPrivateDepositWithdrawFees');
|
|
2455
|
+
const method = this.safeString(params, 'method', defaultMethod);
|
|
2456
|
+
params = this.omit(params, 'method');
|
|
2457
|
+
if (method === 'fetchPublicDepositWithdrawFees') {
|
|
2458
|
+
await this.fetchPublicDepositWithdrawFees(codes, params);
|
|
2459
|
+
}
|
|
2460
|
+
else {
|
|
2461
|
+
await this.fetchPrivateDepositWithdrawFees(codes, params);
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
else {
|
|
2465
|
+
await this.fetchPublicDepositWithdrawFees(codes, params);
|
|
2466
|
+
}
|
|
2467
|
+
return response;
|
|
2468
|
+
}
|
|
2469
|
+
async fetchPrivateDepositWithdrawFees(codes = undefined, params = {}) {
|
|
2470
|
+
// complete response
|
|
2471
|
+
// incl. for coins which undefined in public method
|
|
2472
|
+
await this.loadMarkets();
|
|
2473
|
+
const response = await this.spotPrivatePostSupplementUserInfo(params);
|
|
2474
|
+
//
|
|
2475
|
+
// {
|
|
2476
|
+
// "result": "true",
|
|
2477
|
+
// "data": [
|
|
2478
|
+
// {
|
|
2479
|
+
// "usableAmt": "14.36",
|
|
2480
|
+
// "assetAmt": "14.36",
|
|
2481
|
+
// "networkList": [
|
|
2482
|
+
// {
|
|
2483
|
+
// "isDefault": false,
|
|
2484
|
+
// "withdrawFeeRate": "",
|
|
2485
|
+
// "name": "erc20",
|
|
2486
|
+
// "withdrawMin": 30,
|
|
2487
|
+
// "minLimit": 0.0001,
|
|
2488
|
+
// "minDeposit": 20,
|
|
2489
|
+
// "feeAssetCode": "usdt",
|
|
2490
|
+
// "withdrawFee": "30",
|
|
2491
|
+
// "type": 1,
|
|
2492
|
+
// "coin": "usdt",
|
|
2493
|
+
// "network": "eth"
|
|
2494
|
+
// },
|
|
2495
|
+
// ...
|
|
2496
|
+
// ],
|
|
2497
|
+
// "freezeAmt": "0",
|
|
2498
|
+
// "coin": "ada"
|
|
2499
|
+
// }
|
|
2500
|
+
// ],
|
|
2501
|
+
// "code": 0
|
|
2502
|
+
// }
|
|
2503
|
+
//
|
|
2504
|
+
const data = this.safeValue(response, 'data', []);
|
|
2505
|
+
return this.parseDepositWithdrawFees(data, codes, 'coin');
|
|
2506
|
+
}
|
|
2507
|
+
async fetchPublicDepositWithdrawFees(codes = undefined, params = {}) {
|
|
2508
|
+
// extremely incomplete response
|
|
2509
|
+
// vast majority fees undefined
|
|
2510
|
+
await this.loadMarkets();
|
|
2511
|
+
const request = {};
|
|
2512
|
+
const response = await this.spotPublicGetWithdrawConfigs(this.extend(request, params));
|
|
2513
|
+
//
|
|
2514
|
+
// {
|
|
2515
|
+
// "result": "true",
|
|
2516
|
+
// "data": [
|
|
2517
|
+
// {
|
|
2518
|
+
// "amountScale": "4",
|
|
2519
|
+
// "chain": "heco",
|
|
2520
|
+
// "assetCode": "lbk",
|
|
2521
|
+
// "min": "200",
|
|
2522
|
+
// "transferAmtScale": "4",
|
|
2523
|
+
// "canWithDraw": true,
|
|
2524
|
+
// "fee": "100",
|
|
2525
|
+
// "minTransfer": "0.0001",
|
|
2526
|
+
// "type": "1"
|
|
2527
|
+
// },
|
|
2528
|
+
// ...
|
|
2529
|
+
// ],
|
|
2530
|
+
// "error_code": "0",
|
|
2531
|
+
// "ts": "1663364435973"
|
|
2532
|
+
// }
|
|
2533
|
+
//
|
|
2534
|
+
const data = this.safeValue(response, 'data', []);
|
|
2535
|
+
return this.parsePublicDepositWithdrawFees(data, codes);
|
|
2536
|
+
}
|
|
2537
|
+
parsePublicDepositWithdrawFees(response, codes = undefined) {
|
|
2538
|
+
//
|
|
2539
|
+
// [
|
|
2540
|
+
// {
|
|
2541
|
+
// "amountScale": "4",
|
|
2542
|
+
// "chain": "heco",
|
|
2543
|
+
// "assetCode": "lbk",
|
|
2544
|
+
// "min": "200",
|
|
2545
|
+
// "transferAmtScale": "4",
|
|
2546
|
+
// "canWithDraw": true,
|
|
2547
|
+
// "fee": "100",
|
|
2548
|
+
// "minTransfer": "0.0001",
|
|
2549
|
+
// "type": "1"
|
|
2550
|
+
// },
|
|
2551
|
+
// ...
|
|
2552
|
+
// ]
|
|
2553
|
+
//
|
|
2554
|
+
const result = {};
|
|
2555
|
+
for (let i = 0; i < response.length; i++) {
|
|
2556
|
+
const fee = response[i];
|
|
2557
|
+
const canWithdraw = this.safeValue(fee, 'canWithDraw');
|
|
2558
|
+
if (canWithdraw === true) {
|
|
2559
|
+
const currencyId = this.safeString(fee, 'assetCode');
|
|
2560
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
2561
|
+
if (codes === undefined || this.inArray(code, codes)) {
|
|
2562
|
+
const withdrawFee = this.safeNumber(fee, 'fee');
|
|
2563
|
+
if (withdrawFee !== undefined) {
|
|
2564
|
+
const resultValue = this.safeValue(result, code);
|
|
2565
|
+
if (resultValue === undefined) {
|
|
2566
|
+
result[code] = this.depositWithdrawFee([fee]);
|
|
2567
|
+
}
|
|
2568
|
+
else {
|
|
2569
|
+
result[code]['info'].push(fee);
|
|
2570
|
+
}
|
|
2571
|
+
const chain = this.safeString(fee, 'chain');
|
|
2572
|
+
const networkCode = this.safeString(this.options['inverse-networks'], chain, chain);
|
|
2573
|
+
if (networkCode !== undefined) {
|
|
2574
|
+
result[code]['networks'][networkCode] = {
|
|
2575
|
+
'withdraw': {
|
|
2576
|
+
'fee': withdrawFee,
|
|
2577
|
+
'percentage': undefined,
|
|
2578
|
+
},
|
|
2579
|
+
'deposit': {
|
|
2580
|
+
'fee': undefined,
|
|
2581
|
+
'percentage': undefined,
|
|
2582
|
+
},
|
|
2583
|
+
};
|
|
2584
|
+
}
|
|
2585
|
+
else {
|
|
2586
|
+
result[code]['withdraw'] = {
|
|
2587
|
+
'fee': withdrawFee,
|
|
2588
|
+
'percentage': undefined,
|
|
2589
|
+
};
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
return result;
|
|
2596
|
+
}
|
|
2597
|
+
parseDepositWithdrawFee(fee, currency = undefined) {
|
|
2598
|
+
//
|
|
2599
|
+
// * only used for fetchPrivateDepositWithdrawFees
|
|
2600
|
+
//
|
|
2601
|
+
// {
|
|
2602
|
+
// "usableAmt": "14.36",
|
|
2603
|
+
// "assetAmt": "14.36",
|
|
2604
|
+
// "networkList": [
|
|
2605
|
+
// {
|
|
2606
|
+
// "isDefault": false,
|
|
2607
|
+
// "withdrawFeeRate": "",
|
|
2608
|
+
// "name": "erc20",
|
|
2609
|
+
// "withdrawMin": 30,
|
|
2610
|
+
// "minLimit": 0.0001,
|
|
2611
|
+
// "minDeposit": 20,
|
|
2612
|
+
// "feeAssetCode": "usdt",
|
|
2613
|
+
// "withdrawFee": "30",
|
|
2614
|
+
// "type": 1,
|
|
2615
|
+
// "coin": "usdt",
|
|
2616
|
+
// "network": "eth"
|
|
2617
|
+
// },
|
|
2618
|
+
// ...
|
|
2619
|
+
// ],
|
|
2620
|
+
// "freezeAmt": "0",
|
|
2621
|
+
// "coin": "ada"
|
|
2622
|
+
// }
|
|
2623
|
+
//
|
|
2624
|
+
const result = this.depositWithdrawFee(fee);
|
|
2625
|
+
const networkList = this.safeValue(fee, 'networkList', []);
|
|
2626
|
+
for (let j = 0; j < networkList.length; j++) {
|
|
2627
|
+
const networkEntry = networkList[j];
|
|
2628
|
+
const networkId = this.safeString(networkEntry, 'name');
|
|
2629
|
+
const networkCode = this.safeStringUpper(this.options['inverse-networks'], networkId, networkId);
|
|
2630
|
+
const withdrawFee = this.safeNumber(networkEntry, 'withdrawFee');
|
|
2631
|
+
const isDefault = this.safeValue(networkEntry, 'isDefault');
|
|
2632
|
+
if (withdrawFee !== undefined) {
|
|
2633
|
+
if (isDefault) {
|
|
2634
|
+
result['withdraw'] = {
|
|
2635
|
+
'fee': withdrawFee,
|
|
2636
|
+
'percentage': undefined,
|
|
2637
|
+
};
|
|
2638
|
+
}
|
|
2639
|
+
result['networks'][networkCode] = {
|
|
2640
|
+
'withdraw': {
|
|
2641
|
+
'fee': withdrawFee,
|
|
2642
|
+
'percentage': undefined,
|
|
2643
|
+
},
|
|
2644
|
+
'deposit': {
|
|
2645
|
+
'fee': undefined,
|
|
2646
|
+
'percentage': undefined,
|
|
2647
|
+
},
|
|
2648
|
+
};
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
return result;
|
|
2652
|
+
}
|
|
2653
|
+
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
2654
|
+
let query = this.omit(params, this.extractParams(path));
|
|
2655
|
+
let url = this.urls['api']['rest'] + '/' + this.version + '/' + this.implodeParams(path, params);
|
|
2656
|
+
// Every spot endpoint ends with ".do"
|
|
2657
|
+
if (api[0] === 'spot') {
|
|
2658
|
+
url += '.do';
|
|
2659
|
+
}
|
|
2660
|
+
else {
|
|
2661
|
+
url = this.urls['api']['contract'] + '/' + this.implodeParams(path, params);
|
|
2662
|
+
}
|
|
2663
|
+
if (api[1] === 'public') {
|
|
2664
|
+
if (Object.keys(query).length) {
|
|
2665
|
+
url += '?' + this.urlencode(this.keysort(query));
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
else {
|
|
2669
|
+
this.checkRequiredCredentials();
|
|
2670
|
+
const timestamp = this.milliseconds().toString();
|
|
2671
|
+
const echostr = this.uuid22() + this.uuid16();
|
|
2672
|
+
query = this.extend({
|
|
2673
|
+
'api_key': this.apiKey,
|
|
2674
|
+
}, query);
|
|
2675
|
+
let signatureMethod = undefined;
|
|
2676
|
+
if (this.secret.length > 32) {
|
|
2677
|
+
signatureMethod = 'RSA';
|
|
2678
|
+
}
|
|
2679
|
+
else {
|
|
2680
|
+
signatureMethod = 'HmacSHA256';
|
|
2681
|
+
}
|
|
2682
|
+
const auth = this.rawencode(this.keysort(this.extend({
|
|
2683
|
+
'echostr': echostr,
|
|
2684
|
+
'signature_method': signatureMethod,
|
|
2685
|
+
'timestamp': timestamp,
|
|
2686
|
+
}, query)));
|
|
2687
|
+
const encoded = this.encode(auth);
|
|
2688
|
+
const hash = this.hash(encoded, md5.md5);
|
|
2689
|
+
const uppercaseHash = hash.toUpperCase();
|
|
2690
|
+
let sign = undefined;
|
|
2691
|
+
if (signatureMethod === 'RSA') {
|
|
2692
|
+
const cacheSecretAsPem = this.safeValue(this.options, 'cacheSecretAsPem', true);
|
|
2693
|
+
let pem = undefined;
|
|
2694
|
+
if (cacheSecretAsPem) {
|
|
2695
|
+
pem = this.safeValue(this.options, 'pem');
|
|
2696
|
+
if (pem === undefined) {
|
|
2697
|
+
pem = this.convertSecretToPem(this.encode(this.secret));
|
|
2698
|
+
this.options['pem'] = pem;
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
else {
|
|
2702
|
+
pem = this.convertSecretToPem(this.encode(this.secret));
|
|
2703
|
+
}
|
|
2704
|
+
sign = rsa.rsa(uppercaseHash, pem, sha256.sha256);
|
|
2705
|
+
}
|
|
2706
|
+
else if (signatureMethod === 'HmacSHA256') {
|
|
2707
|
+
sign = this.hmac(this.encode(uppercaseHash), this.encode(this.secret), sha256.sha256);
|
|
2708
|
+
}
|
|
2709
|
+
query['sign'] = sign;
|
|
2710
|
+
body = this.urlencode(this.keysort(query));
|
|
2711
|
+
headers = {
|
|
2712
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
2713
|
+
'timestamp': timestamp,
|
|
2714
|
+
'signature_method': signatureMethod,
|
|
2715
|
+
'echostr': echostr,
|
|
2716
|
+
};
|
|
2717
|
+
}
|
|
2718
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
2719
|
+
}
|
|
2720
|
+
convertSecretToPem(secret) {
|
|
2721
|
+
const lineLength = 64;
|
|
2722
|
+
const secretLength = secret.length - 0;
|
|
2723
|
+
let numLines = this.parseToInt(secretLength / lineLength);
|
|
2724
|
+
numLines = this.sum(numLines, 1);
|
|
2725
|
+
let pem = "-----BEGIN PRIVATE KEY-----\n"; // eslint-disable-line
|
|
2726
|
+
for (let i = 0; i < numLines; i++) {
|
|
2727
|
+
const start = i * lineLength;
|
|
2728
|
+
const end = this.sum(start, lineLength);
|
|
2729
|
+
pem += this.secret.slice(start, end) + "\n"; // eslint-disable-line
|
|
2730
|
+
}
|
|
2731
|
+
return pem + '-----END PRIVATE KEY-----';
|
|
2732
|
+
}
|
|
2733
|
+
handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
2734
|
+
if (response === undefined) {
|
|
2735
|
+
return undefined;
|
|
2736
|
+
}
|
|
2737
|
+
const success = this.safeValue(response, 'result');
|
|
2738
|
+
if (success === 'false' || !success) {
|
|
2739
|
+
const errorCode = this.safeString(response, 'error_code');
|
|
2740
|
+
const message = this.safeString({
|
|
2741
|
+
'10000': 'Internal error',
|
|
2742
|
+
'10001': 'The required parameters can not be empty',
|
|
2743
|
+
'10002': 'Validation failed',
|
|
2744
|
+
'10003': 'Invalid parameter',
|
|
2745
|
+
'10004': 'Request too frequent',
|
|
2746
|
+
'10005': 'Secret key does not exist',
|
|
2747
|
+
'10006': 'User does not exist',
|
|
2748
|
+
'10007': 'Invalid signature',
|
|
2749
|
+
'10008': 'Invalid Trading Pair',
|
|
2750
|
+
'10009': 'Price and/or Amount are required for limit order',
|
|
2751
|
+
'10010': 'Price and/or Amount must be less than minimum requirement',
|
|
2752
|
+
// '10011': 'Market orders can not be missing the amount of the order',
|
|
2753
|
+
// '10012': 'market sell orders can not be missing orders',
|
|
2754
|
+
'10013': 'The amount is too small',
|
|
2755
|
+
'10014': 'Insufficient amount of money in the account',
|
|
2756
|
+
'10015': 'Invalid order type',
|
|
2757
|
+
'10016': 'Insufficient account balance',
|
|
2758
|
+
'10017': 'Server Error',
|
|
2759
|
+
'10018': 'Page size should be between 1 and 50',
|
|
2760
|
+
'10019': 'Cancel NO more than 3 orders in one request',
|
|
2761
|
+
'10020': 'Volume < 0.001',
|
|
2762
|
+
'10021': 'Price < 0.01',
|
|
2763
|
+
'10022': 'Invalid authorization',
|
|
2764
|
+
'10023': 'Market Order is not supported yet',
|
|
2765
|
+
'10024': 'User cannot trade on this pair',
|
|
2766
|
+
'10025': 'Order has been filled',
|
|
2767
|
+
'10026': 'Order has been cancelld',
|
|
2768
|
+
'10027': 'Order is cancelling',
|
|
2769
|
+
'10028': 'Wrong query time',
|
|
2770
|
+
'10029': 'from is not in the query time',
|
|
2771
|
+
'10030': 'from do not match the transaction type of inqury',
|
|
2772
|
+
'10031': 'echostr length must be valid and length must be from 30 to 40',
|
|
2773
|
+
'10033': 'Failed to create order',
|
|
2774
|
+
'10036': 'customID duplicated',
|
|
2775
|
+
'10100': 'Has no privilege to withdraw',
|
|
2776
|
+
'10101': 'Invalid fee rate to withdraw',
|
|
2777
|
+
'10102': 'Too little to withdraw',
|
|
2778
|
+
'10103': 'Exceed daily limitation of withdraw',
|
|
2779
|
+
'10104': 'Cancel was rejected',
|
|
2780
|
+
'10105': 'Request has been cancelled',
|
|
2781
|
+
'10106': 'None trade time',
|
|
2782
|
+
'10107': 'Start price exception',
|
|
2783
|
+
'10108': 'can not create order',
|
|
2784
|
+
'10109': 'wallet address is not mapping',
|
|
2785
|
+
'10110': 'transfer fee is not mapping',
|
|
2786
|
+
'10111': 'mount > 0',
|
|
2787
|
+
'10112': 'fee is too lower',
|
|
2788
|
+
'10113': 'transfer fee is 0',
|
|
2789
|
+
'10600': 'intercepted by replay attacks filter, check timestamp',
|
|
2790
|
+
'10601': 'Interface closed unavailable',
|
|
2791
|
+
'10701': 'invalid asset code',
|
|
2792
|
+
'10702': 'not allowed deposit',
|
|
2793
|
+
}, errorCode, this.json(response));
|
|
2794
|
+
const ErrorClass = this.safeValue({
|
|
2795
|
+
'10001': errors.BadRequest,
|
|
2796
|
+
'10002': errors.AuthenticationError,
|
|
2797
|
+
'10003': errors.BadRequest,
|
|
2798
|
+
'10004': errors.RateLimitExceeded,
|
|
2799
|
+
'10005': errors.AuthenticationError,
|
|
2800
|
+
'10006': errors.AuthenticationError,
|
|
2801
|
+
'10007': errors.AuthenticationError,
|
|
2802
|
+
'10008': errors.BadSymbol,
|
|
2803
|
+
'10009': errors.InvalidOrder,
|
|
2804
|
+
'10010': errors.InvalidOrder,
|
|
2805
|
+
'10013': errors.InvalidOrder,
|
|
2806
|
+
'10014': errors.InsufficientFunds,
|
|
2807
|
+
'10015': errors.InvalidOrder,
|
|
2808
|
+
'10016': errors.InsufficientFunds,
|
|
2809
|
+
'10017': errors.ExchangeError,
|
|
2810
|
+
'10018': errors.BadRequest,
|
|
2811
|
+
'10019': errors.BadRequest,
|
|
2812
|
+
'10020': errors.BadRequest,
|
|
2813
|
+
'10021': errors.InvalidOrder,
|
|
2814
|
+
'10022': errors.PermissionDenied,
|
|
2815
|
+
'10023': errors.InvalidOrder,
|
|
2816
|
+
'10024': errors.PermissionDenied,
|
|
2817
|
+
'10025': errors.InvalidOrder,
|
|
2818
|
+
'10026': errors.InvalidOrder,
|
|
2819
|
+
'10027': errors.InvalidOrder,
|
|
2820
|
+
'10028': errors.BadRequest,
|
|
2821
|
+
'10029': errors.BadRequest,
|
|
2822
|
+
'10030': errors.BadRequest,
|
|
2823
|
+
'10031': errors.InvalidNonce,
|
|
2824
|
+
'10033': errors.ExchangeError,
|
|
2825
|
+
'10036': errors.DuplicateOrderId,
|
|
2826
|
+
'10100': errors.PermissionDenied,
|
|
2827
|
+
'10101': errors.BadRequest,
|
|
2828
|
+
'10102': errors.InsufficientFunds,
|
|
2829
|
+
'10103': errors.ExchangeError,
|
|
2830
|
+
'10104': errors.ExchangeError,
|
|
2831
|
+
'10105': errors.ExchangeError,
|
|
2832
|
+
'10106': errors.BadRequest,
|
|
2833
|
+
'10107': errors.BadRequest,
|
|
2834
|
+
'10108': errors.ExchangeError,
|
|
2835
|
+
'10109': errors.InvalidAddress,
|
|
2836
|
+
'10110': errors.ExchangeError,
|
|
2837
|
+
'10111': errors.BadRequest,
|
|
2838
|
+
'10112': errors.BadRequest,
|
|
2839
|
+
'10113': errors.BadRequest,
|
|
2840
|
+
'10600': errors.BadRequest,
|
|
2841
|
+
'10601': errors.ExchangeError,
|
|
2842
|
+
'10701': errors.BadSymbol,
|
|
2843
|
+
'10702': errors.PermissionDenied, // 'not allowed deposit',
|
|
2844
|
+
}, errorCode, errors.ExchangeError);
|
|
2845
|
+
throw new ErrorClass(message);
|
|
2846
|
+
}
|
|
2847
|
+
return undefined;
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
|
|
2851
|
+
module.exports = lbank;
|