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,1044 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var luno$1 = require('./abstract/luno.js');
|
|
4
|
+
var errors = require('./base/errors.js');
|
|
5
|
+
var Precise = require('./base/Precise.js');
|
|
6
|
+
var number = require('./base/functions/number.js');
|
|
7
|
+
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
/**
|
|
11
|
+
* @class luno
|
|
12
|
+
* @augments Exchange
|
|
13
|
+
*/
|
|
14
|
+
class luno extends luno$1 {
|
|
15
|
+
describe() {
|
|
16
|
+
return this.deepExtend(super.describe(), {
|
|
17
|
+
'id': 'luno',
|
|
18
|
+
'name': 'luno',
|
|
19
|
+
'countries': ['GB', 'SG', 'ZA'],
|
|
20
|
+
// 300 calls per minute = 5 calls per second = 1000ms / 5 = 200ms between requests
|
|
21
|
+
'rateLimit': 200,
|
|
22
|
+
'version': '1',
|
|
23
|
+
'pro': true,
|
|
24
|
+
'has': {
|
|
25
|
+
'CORS': undefined,
|
|
26
|
+
'spot': true,
|
|
27
|
+
'margin': false,
|
|
28
|
+
'swap': false,
|
|
29
|
+
'future': false,
|
|
30
|
+
'option': false,
|
|
31
|
+
'addMargin': false,
|
|
32
|
+
'cancelOrder': true,
|
|
33
|
+
'closeAllPositions': false,
|
|
34
|
+
'closePosition': false,
|
|
35
|
+
'createOrder': true,
|
|
36
|
+
'createReduceOnlyOrder': false,
|
|
37
|
+
'fetchAccounts': true,
|
|
38
|
+
'fetchBalance': true,
|
|
39
|
+
'fetchBorrowRateHistory': false,
|
|
40
|
+
'fetchClosedOrders': true,
|
|
41
|
+
'fetchCrossBorrowRate': false,
|
|
42
|
+
'fetchCrossBorrowRates': false,
|
|
43
|
+
'fetchFundingHistory': false,
|
|
44
|
+
'fetchFundingRate': false,
|
|
45
|
+
'fetchFundingRateHistory': false,
|
|
46
|
+
'fetchFundingRates': false,
|
|
47
|
+
'fetchIndexOHLCV': false,
|
|
48
|
+
'fetchIsolatedBorrowRate': false,
|
|
49
|
+
'fetchIsolatedBorrowRates': false,
|
|
50
|
+
'fetchLedger': true,
|
|
51
|
+
'fetchLeverage': false,
|
|
52
|
+
'fetchLeverageTiers': false,
|
|
53
|
+
'fetchMarginMode': false,
|
|
54
|
+
'fetchMarkets': true,
|
|
55
|
+
'fetchMarkOHLCV': false,
|
|
56
|
+
'fetchMyTrades': true,
|
|
57
|
+
'fetchOHLCV': false,
|
|
58
|
+
'fetchOpenInterestHistory': false,
|
|
59
|
+
'fetchOpenOrders': true,
|
|
60
|
+
'fetchOrder': true,
|
|
61
|
+
'fetchOrderBook': true,
|
|
62
|
+
'fetchOrders': true,
|
|
63
|
+
'fetchPosition': false,
|
|
64
|
+
'fetchPositionMode': false,
|
|
65
|
+
'fetchPositions': false,
|
|
66
|
+
'fetchPositionsRisk': false,
|
|
67
|
+
'fetchPremiumIndexOHLCV': false,
|
|
68
|
+
'fetchTicker': true,
|
|
69
|
+
'fetchTickers': true,
|
|
70
|
+
'fetchTrades': true,
|
|
71
|
+
'fetchTradingFee': true,
|
|
72
|
+
'fetchTradingFees': false,
|
|
73
|
+
'reduceMargin': false,
|
|
74
|
+
'setLeverage': false,
|
|
75
|
+
'setMarginMode': false,
|
|
76
|
+
'setPositionMode': false,
|
|
77
|
+
},
|
|
78
|
+
'urls': {
|
|
79
|
+
'referral': 'https://www.luno.com/invite/44893A',
|
|
80
|
+
'logo': 'https://user-images.githubusercontent.com/1294454/27766607-8c1a69d8-5ede-11e7-930c-540b5eb9be24.jpg',
|
|
81
|
+
'api': {
|
|
82
|
+
'public': 'https://api.luno.com/api',
|
|
83
|
+
'private': 'https://api.luno.com/api',
|
|
84
|
+
'exchange': 'https://api.luno.com/api/exchange',
|
|
85
|
+
},
|
|
86
|
+
'www': 'https://www.luno.com',
|
|
87
|
+
'doc': [
|
|
88
|
+
'https://www.luno.com/en/api',
|
|
89
|
+
'https://npmjs.org/package/bitx',
|
|
90
|
+
'https://github.com/bausmeier/node-bitx',
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
'api': {
|
|
94
|
+
'exchange': {
|
|
95
|
+
'get': {
|
|
96
|
+
'markets': 1,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
'public': {
|
|
100
|
+
'get': {
|
|
101
|
+
'orderbook': 1,
|
|
102
|
+
'orderbook_top': 1,
|
|
103
|
+
'ticker': 1,
|
|
104
|
+
'tickers': 1,
|
|
105
|
+
'trades': 1,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
'private': {
|
|
109
|
+
'get': {
|
|
110
|
+
'accounts/{id}/pending': 1,
|
|
111
|
+
'accounts/{id}/transactions': 1,
|
|
112
|
+
'balance': 1,
|
|
113
|
+
'beneficiaries': 1,
|
|
114
|
+
'fee_info': 1,
|
|
115
|
+
'funding_address': 1,
|
|
116
|
+
'listorders': 1,
|
|
117
|
+
'listtrades': 1,
|
|
118
|
+
'send_fee': 1,
|
|
119
|
+
'orders/{id}': 1,
|
|
120
|
+
'withdrawals': 1,
|
|
121
|
+
'withdrawals/{id}': 1,
|
|
122
|
+
'transfers': 1,
|
|
123
|
+
// GET /api/exchange/1/move
|
|
124
|
+
// GET /api/exchange/1/move/list_moves
|
|
125
|
+
// GET /api/exchange/1/candles
|
|
126
|
+
// GET /api/exchange/1/transfers
|
|
127
|
+
// GET /api/exchange/2/listorders
|
|
128
|
+
// GET /api/exchange/2/orders/{id}
|
|
129
|
+
// GET /api/exchange/3/order
|
|
130
|
+
},
|
|
131
|
+
'post': {
|
|
132
|
+
'accounts': 1,
|
|
133
|
+
'address/validate': 1,
|
|
134
|
+
'postorder': 1,
|
|
135
|
+
'marketorder': 1,
|
|
136
|
+
'stoporder': 1,
|
|
137
|
+
'funding_address': 1,
|
|
138
|
+
'withdrawals': 1,
|
|
139
|
+
'send': 1,
|
|
140
|
+
'oauth2/grant': 1,
|
|
141
|
+
// POST /api/exchange/1/move
|
|
142
|
+
},
|
|
143
|
+
'put': {
|
|
144
|
+
'accounts/{id}/name': 1,
|
|
145
|
+
},
|
|
146
|
+
'delete': {
|
|
147
|
+
'withdrawals/{id}': 1,
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
'fees': {
|
|
152
|
+
'trading': {
|
|
153
|
+
'tierBased': true,
|
|
154
|
+
'percentage': true,
|
|
155
|
+
'taker': this.parseNumber('0.001'),
|
|
156
|
+
'maker': this.parseNumber('0'),
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
'precisionMode': number.TICK_SIZE,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
async fetchMarkets(params = {}) {
|
|
163
|
+
/**
|
|
164
|
+
* @method
|
|
165
|
+
* @name luno#fetchMarkets
|
|
166
|
+
* @description retrieves data on all markets for luno
|
|
167
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
168
|
+
* @returns {object[]} an array of objects representing market data
|
|
169
|
+
*/
|
|
170
|
+
const response = await this.exchangeGetMarkets(params);
|
|
171
|
+
//
|
|
172
|
+
// {
|
|
173
|
+
// "markets":[
|
|
174
|
+
// {
|
|
175
|
+
// "market_id":"BCHXBT",
|
|
176
|
+
// "trading_status":"ACTIVE",
|
|
177
|
+
// "base_currency":"BCH",
|
|
178
|
+
// "counter_currency":"XBT",
|
|
179
|
+
// "min_volume":"0.01",
|
|
180
|
+
// "max_volume":"100.00",
|
|
181
|
+
// "volume_scale":2,
|
|
182
|
+
// "min_price":"0.0001",
|
|
183
|
+
// "max_price":"1.00",
|
|
184
|
+
// "price_scale":6,
|
|
185
|
+
// "fee_scale":8,
|
|
186
|
+
// },
|
|
187
|
+
// ]
|
|
188
|
+
// }
|
|
189
|
+
//
|
|
190
|
+
const result = [];
|
|
191
|
+
const markets = this.safeValue(response, 'markets', []);
|
|
192
|
+
for (let i = 0; i < markets.length; i++) {
|
|
193
|
+
const market = markets[i];
|
|
194
|
+
const id = this.safeString(market, 'market_id');
|
|
195
|
+
const baseId = this.safeString(market, 'base_currency');
|
|
196
|
+
const quoteId = this.safeString(market, 'counter_currency');
|
|
197
|
+
const base = this.safeCurrencyCode(baseId);
|
|
198
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
199
|
+
const status = this.safeString(market, 'trading_status');
|
|
200
|
+
result.push({
|
|
201
|
+
'id': id,
|
|
202
|
+
'symbol': base + '/' + quote,
|
|
203
|
+
'base': base,
|
|
204
|
+
'quote': quote,
|
|
205
|
+
'settle': undefined,
|
|
206
|
+
'baseId': baseId,
|
|
207
|
+
'quoteId': quoteId,
|
|
208
|
+
'settleId': undefined,
|
|
209
|
+
'type': 'spot',
|
|
210
|
+
'spot': true,
|
|
211
|
+
'margin': false,
|
|
212
|
+
'swap': false,
|
|
213
|
+
'future': false,
|
|
214
|
+
'option': false,
|
|
215
|
+
'active': (status === 'ACTIVE'),
|
|
216
|
+
'contract': false,
|
|
217
|
+
'linear': undefined,
|
|
218
|
+
'inverse': undefined,
|
|
219
|
+
'contractSize': undefined,
|
|
220
|
+
'expiry': undefined,
|
|
221
|
+
'expiryDatetime': undefined,
|
|
222
|
+
'strike': undefined,
|
|
223
|
+
'optionType': undefined,
|
|
224
|
+
'precision': {
|
|
225
|
+
'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'volume_scale'))),
|
|
226
|
+
'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'price_scale'))),
|
|
227
|
+
},
|
|
228
|
+
'limits': {
|
|
229
|
+
'leverage': {
|
|
230
|
+
'min': undefined,
|
|
231
|
+
'max': undefined,
|
|
232
|
+
},
|
|
233
|
+
'amount': {
|
|
234
|
+
'min': this.safeNumber(market, 'min_volume'),
|
|
235
|
+
'max': this.safeNumber(market, 'max_volume'),
|
|
236
|
+
},
|
|
237
|
+
'price': {
|
|
238
|
+
'min': this.safeNumber(market, 'min_price'),
|
|
239
|
+
'max': this.safeNumber(market, 'max_price'),
|
|
240
|
+
},
|
|
241
|
+
'cost': {
|
|
242
|
+
'min': undefined,
|
|
243
|
+
'max': undefined,
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
'created': undefined,
|
|
247
|
+
'info': market,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
return result;
|
|
251
|
+
}
|
|
252
|
+
async fetchAccounts(params = {}) {
|
|
253
|
+
/**
|
|
254
|
+
* @method
|
|
255
|
+
* @name luno#fetchAccounts
|
|
256
|
+
* @description fetch all the accounts associated with a profile
|
|
257
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
258
|
+
* @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
|
|
259
|
+
*/
|
|
260
|
+
const response = await this.privateGetBalance(params);
|
|
261
|
+
const wallets = this.safeValue(response, 'balance', []);
|
|
262
|
+
const result = [];
|
|
263
|
+
for (let i = 0; i < wallets.length; i++) {
|
|
264
|
+
const account = wallets[i];
|
|
265
|
+
const accountId = this.safeString(account, 'account_id');
|
|
266
|
+
const currencyId = this.safeString(account, 'asset');
|
|
267
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
268
|
+
result.push({
|
|
269
|
+
'id': accountId,
|
|
270
|
+
'type': undefined,
|
|
271
|
+
'currency': code,
|
|
272
|
+
'info': account,
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
return result;
|
|
276
|
+
}
|
|
277
|
+
parseBalance(response) {
|
|
278
|
+
const wallets = this.safeValue(response, 'balance', []);
|
|
279
|
+
const result = {
|
|
280
|
+
'info': response,
|
|
281
|
+
'timestamp': undefined,
|
|
282
|
+
'datetime': undefined,
|
|
283
|
+
};
|
|
284
|
+
for (let i = 0; i < wallets.length; i++) {
|
|
285
|
+
const wallet = wallets[i];
|
|
286
|
+
const currencyId = this.safeString(wallet, 'asset');
|
|
287
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
288
|
+
const reserved = this.safeString(wallet, 'reserved');
|
|
289
|
+
const unconfirmed = this.safeString(wallet, 'unconfirmed');
|
|
290
|
+
const balance = this.safeString(wallet, 'balance');
|
|
291
|
+
const reservedUnconfirmed = Precise["default"].stringAdd(reserved, unconfirmed);
|
|
292
|
+
const balanceUnconfirmed = Precise["default"].stringAdd(balance, unconfirmed);
|
|
293
|
+
if (code in result) {
|
|
294
|
+
result[code]['used'] = Precise["default"].stringAdd(result[code]['used'], reservedUnconfirmed);
|
|
295
|
+
result[code]['total'] = Precise["default"].stringAdd(result[code]['total'], balanceUnconfirmed);
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
const account = this.account();
|
|
299
|
+
account['used'] = reservedUnconfirmed;
|
|
300
|
+
account['total'] = balanceUnconfirmed;
|
|
301
|
+
result[code] = account;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return this.safeBalance(result);
|
|
305
|
+
}
|
|
306
|
+
async fetchBalance(params = {}) {
|
|
307
|
+
/**
|
|
308
|
+
* @method
|
|
309
|
+
* @name luno#fetchBalance
|
|
310
|
+
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
311
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
312
|
+
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
313
|
+
*/
|
|
314
|
+
await this.loadMarkets();
|
|
315
|
+
const response = await this.privateGetBalance(params);
|
|
316
|
+
//
|
|
317
|
+
// {
|
|
318
|
+
// "balance": [
|
|
319
|
+
// {'account_id': '119...1336','asset': 'XBT','balance': '0.00','reserved': '0.00',"unconfirmed": "0.00"},
|
|
320
|
+
// {'account_id': '66...289','asset': 'XBT','balance': '0.00','reserved': '0.00',"unconfirmed": "0.00"},
|
|
321
|
+
// {'account_id': '718...5300','asset': 'ETH','balance': '0.00','reserved': '0.00',"unconfirmed": "0.00"},
|
|
322
|
+
// {'account_id': '818...7072','asset': 'ZAR','balance': '0.001417','reserved': '0.00',"unconfirmed": "0.00"}]}
|
|
323
|
+
// ]
|
|
324
|
+
// }
|
|
325
|
+
//
|
|
326
|
+
return this.parseBalance(response);
|
|
327
|
+
}
|
|
328
|
+
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
329
|
+
/**
|
|
330
|
+
* @method
|
|
331
|
+
* @name luno#fetchOrderBook
|
|
332
|
+
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
333
|
+
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
334
|
+
* @param {int} [limit] the maximum amount of order book entries to return
|
|
335
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
336
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
337
|
+
*/
|
|
338
|
+
await this.loadMarkets();
|
|
339
|
+
const market = this.market(symbol);
|
|
340
|
+
const request = {
|
|
341
|
+
'pair': market['id'],
|
|
342
|
+
};
|
|
343
|
+
let response = undefined;
|
|
344
|
+
if (limit !== undefined && limit <= 100) {
|
|
345
|
+
response = await this.publicGetOrderbookTop(this.extend(request, params));
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
response = await this.publicGetOrderbook(this.extend(request, params));
|
|
349
|
+
}
|
|
350
|
+
const timestamp = this.safeInteger(response, 'timestamp');
|
|
351
|
+
return this.parseOrderBook(response, market['symbol'], timestamp, 'bids', 'asks', 'price', 'volume');
|
|
352
|
+
}
|
|
353
|
+
parseOrderStatus(status) {
|
|
354
|
+
const statuses = {
|
|
355
|
+
// todo add other statuses
|
|
356
|
+
'PENDING': 'open',
|
|
357
|
+
};
|
|
358
|
+
return this.safeString(statuses, status, status);
|
|
359
|
+
}
|
|
360
|
+
parseOrder(order, market = undefined) {
|
|
361
|
+
//
|
|
362
|
+
// {
|
|
363
|
+
// "base": "string",
|
|
364
|
+
// "completed_timestamp": "string",
|
|
365
|
+
// "counter": "string",
|
|
366
|
+
// "creation_timestamp": "string",
|
|
367
|
+
// "expiration_timestamp": "string",
|
|
368
|
+
// "fee_base": "string",
|
|
369
|
+
// "fee_counter": "string",
|
|
370
|
+
// "limit_price": "string",
|
|
371
|
+
// "limit_volume": "string",
|
|
372
|
+
// "order_id": "string",
|
|
373
|
+
// "pair": "string",
|
|
374
|
+
// "state": "PENDING",
|
|
375
|
+
// "type": "BID"
|
|
376
|
+
// }
|
|
377
|
+
//
|
|
378
|
+
const timestamp = this.safeInteger(order, 'creation_timestamp');
|
|
379
|
+
let status = this.parseOrderStatus(this.safeString(order, 'state'));
|
|
380
|
+
status = (status === 'open') ? status : status;
|
|
381
|
+
let side = undefined;
|
|
382
|
+
const orderType = this.safeString(order, 'type');
|
|
383
|
+
if ((orderType === 'ASK') || (orderType === 'SELL')) {
|
|
384
|
+
side = 'sell';
|
|
385
|
+
}
|
|
386
|
+
else if ((orderType === 'BID') || (orderType === 'BUY')) {
|
|
387
|
+
side = 'buy';
|
|
388
|
+
}
|
|
389
|
+
const marketId = this.safeString(order, 'pair');
|
|
390
|
+
market = this.safeMarket(marketId, market);
|
|
391
|
+
const price = this.safeString(order, 'limit_price');
|
|
392
|
+
const amount = this.safeString(order, 'limit_volume');
|
|
393
|
+
const quoteFee = this.safeNumber(order, 'fee_counter');
|
|
394
|
+
const baseFee = this.safeNumber(order, 'fee_base');
|
|
395
|
+
const filled = this.safeString(order, 'base');
|
|
396
|
+
const cost = this.safeString(order, 'counter');
|
|
397
|
+
let fee = undefined;
|
|
398
|
+
if (quoteFee !== undefined) {
|
|
399
|
+
fee = {
|
|
400
|
+
'cost': quoteFee,
|
|
401
|
+
'currency': market['quote'],
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
else if (baseFee !== undefined) {
|
|
405
|
+
fee = {
|
|
406
|
+
'cost': baseFee,
|
|
407
|
+
'currency': market['base'],
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
const id = this.safeString(order, 'order_id');
|
|
411
|
+
return this.safeOrder({
|
|
412
|
+
'id': id,
|
|
413
|
+
'clientOrderId': undefined,
|
|
414
|
+
'datetime': this.iso8601(timestamp),
|
|
415
|
+
'timestamp': timestamp,
|
|
416
|
+
'lastTradeTimestamp': undefined,
|
|
417
|
+
'status': status,
|
|
418
|
+
'symbol': market['symbol'],
|
|
419
|
+
'type': undefined,
|
|
420
|
+
'timeInForce': undefined,
|
|
421
|
+
'postOnly': undefined,
|
|
422
|
+
'side': side,
|
|
423
|
+
'price': price,
|
|
424
|
+
'stopPrice': undefined,
|
|
425
|
+
'triggerPrice': undefined,
|
|
426
|
+
'amount': amount,
|
|
427
|
+
'filled': filled,
|
|
428
|
+
'cost': cost,
|
|
429
|
+
'remaining': undefined,
|
|
430
|
+
'trades': undefined,
|
|
431
|
+
'fee': fee,
|
|
432
|
+
'info': order,
|
|
433
|
+
'average': undefined,
|
|
434
|
+
}, market);
|
|
435
|
+
}
|
|
436
|
+
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
437
|
+
/**
|
|
438
|
+
* @method
|
|
439
|
+
* @name luno#fetchOrder
|
|
440
|
+
* @description fetches information on an order made by the user
|
|
441
|
+
* @param {string} symbol not used by luno fetchOrder
|
|
442
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
443
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
444
|
+
*/
|
|
445
|
+
await this.loadMarkets();
|
|
446
|
+
const request = {
|
|
447
|
+
'id': id,
|
|
448
|
+
};
|
|
449
|
+
const response = await this.privateGetOrdersId(this.extend(request, params));
|
|
450
|
+
return this.parseOrder(response);
|
|
451
|
+
}
|
|
452
|
+
async fetchOrdersByState(state = undefined, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
453
|
+
await this.loadMarkets();
|
|
454
|
+
const request = {};
|
|
455
|
+
let market = undefined;
|
|
456
|
+
if (state !== undefined) {
|
|
457
|
+
request['state'] = state;
|
|
458
|
+
}
|
|
459
|
+
if (symbol !== undefined) {
|
|
460
|
+
market = this.market(symbol);
|
|
461
|
+
request['pair'] = market['id'];
|
|
462
|
+
}
|
|
463
|
+
const response = await this.privateGetListorders(this.extend(request, params));
|
|
464
|
+
const orders = this.safeValue(response, 'orders', []);
|
|
465
|
+
return this.parseOrders(orders, market, since, limit);
|
|
466
|
+
}
|
|
467
|
+
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
468
|
+
/**
|
|
469
|
+
* @method
|
|
470
|
+
* @name luno#fetchOrders
|
|
471
|
+
* @description fetches information on multiple orders made by the user
|
|
472
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
473
|
+
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
474
|
+
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
475
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
476
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
477
|
+
*/
|
|
478
|
+
return await this.fetchOrdersByState(undefined, symbol, since, limit, params);
|
|
479
|
+
}
|
|
480
|
+
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
481
|
+
/**
|
|
482
|
+
* @method
|
|
483
|
+
* @name luno#fetchOpenOrders
|
|
484
|
+
* @description fetch all unfilled currently open orders
|
|
485
|
+
* @param {string} symbol unified market symbol
|
|
486
|
+
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
487
|
+
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
488
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
489
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
490
|
+
*/
|
|
491
|
+
return await this.fetchOrdersByState('PENDING', symbol, since, limit, params);
|
|
492
|
+
}
|
|
493
|
+
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
494
|
+
/**
|
|
495
|
+
* @method
|
|
496
|
+
* @name luno#fetchClosedOrders
|
|
497
|
+
* @description fetches information on multiple closed orders made by the user
|
|
498
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
499
|
+
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
500
|
+
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
501
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
502
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
503
|
+
*/
|
|
504
|
+
return await this.fetchOrdersByState('COMPLETE', symbol, since, limit, params);
|
|
505
|
+
}
|
|
506
|
+
parseTicker(ticker, market = undefined) {
|
|
507
|
+
// {
|
|
508
|
+
// "pair":"XBTAUD",
|
|
509
|
+
// "timestamp":1642201439301,
|
|
510
|
+
// "bid":"59972.30000000",
|
|
511
|
+
// "ask":"59997.99000000",
|
|
512
|
+
// "last_trade":"59997.99000000",
|
|
513
|
+
// "rolling_24_hour_volume":"1.89510000",
|
|
514
|
+
// "status":"ACTIVE"
|
|
515
|
+
// }
|
|
516
|
+
const timestamp = this.safeInteger(ticker, 'timestamp');
|
|
517
|
+
const marketId = this.safeString(ticker, 'pair');
|
|
518
|
+
const symbol = this.safeSymbol(marketId, market);
|
|
519
|
+
const last = this.safeString(ticker, 'last_trade');
|
|
520
|
+
return this.safeTicker({
|
|
521
|
+
'symbol': symbol,
|
|
522
|
+
'timestamp': timestamp,
|
|
523
|
+
'datetime': this.iso8601(timestamp),
|
|
524
|
+
'high': undefined,
|
|
525
|
+
'low': undefined,
|
|
526
|
+
'bid': this.safeString(ticker, 'bid'),
|
|
527
|
+
'bidVolume': undefined,
|
|
528
|
+
'ask': this.safeString(ticker, 'ask'),
|
|
529
|
+
'askVolume': undefined,
|
|
530
|
+
'vwap': undefined,
|
|
531
|
+
'open': undefined,
|
|
532
|
+
'close': last,
|
|
533
|
+
'last': last,
|
|
534
|
+
'previousClose': undefined,
|
|
535
|
+
'change': undefined,
|
|
536
|
+
'percentage': undefined,
|
|
537
|
+
'average': undefined,
|
|
538
|
+
'baseVolume': this.safeString(ticker, 'rolling_24_hour_volume'),
|
|
539
|
+
'quoteVolume': undefined,
|
|
540
|
+
'info': ticker,
|
|
541
|
+
}, market);
|
|
542
|
+
}
|
|
543
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
544
|
+
/**
|
|
545
|
+
* @method
|
|
546
|
+
* @name luno#fetchTickers
|
|
547
|
+
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
548
|
+
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
549
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
550
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
551
|
+
*/
|
|
552
|
+
await this.loadMarkets();
|
|
553
|
+
symbols = this.marketSymbols(symbols);
|
|
554
|
+
const response = await this.publicGetTickers(params);
|
|
555
|
+
const tickers = this.indexBy(response['tickers'], 'pair');
|
|
556
|
+
const ids = Object.keys(tickers);
|
|
557
|
+
const result = {};
|
|
558
|
+
for (let i = 0; i < ids.length; i++) {
|
|
559
|
+
const id = ids[i];
|
|
560
|
+
const market = this.safeMarket(id);
|
|
561
|
+
const symbol = market['symbol'];
|
|
562
|
+
const ticker = tickers[id];
|
|
563
|
+
result[symbol] = this.parseTicker(ticker, market);
|
|
564
|
+
}
|
|
565
|
+
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
566
|
+
}
|
|
567
|
+
async fetchTicker(symbol, params = {}) {
|
|
568
|
+
/**
|
|
569
|
+
* @method
|
|
570
|
+
* @name luno#fetchTicker
|
|
571
|
+
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
572
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
573
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
574
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
575
|
+
*/
|
|
576
|
+
await this.loadMarkets();
|
|
577
|
+
const market = this.market(symbol);
|
|
578
|
+
const request = {
|
|
579
|
+
'pair': market['id'],
|
|
580
|
+
};
|
|
581
|
+
const response = await this.publicGetTicker(this.extend(request, params));
|
|
582
|
+
// {
|
|
583
|
+
// "pair":"XBTAUD",
|
|
584
|
+
// "timestamp":1642201439301,
|
|
585
|
+
// "bid":"59972.30000000",
|
|
586
|
+
// "ask":"59997.99000000",
|
|
587
|
+
// "last_trade":"59997.99000000",
|
|
588
|
+
// "rolling_24_hour_volume":"1.89510000",
|
|
589
|
+
// "status":"ACTIVE"
|
|
590
|
+
// }
|
|
591
|
+
return this.parseTicker(response, market);
|
|
592
|
+
}
|
|
593
|
+
parseTrade(trade, market = undefined) {
|
|
594
|
+
//
|
|
595
|
+
// fetchTrades (public)
|
|
596
|
+
//
|
|
597
|
+
// {
|
|
598
|
+
// "sequence":276989,
|
|
599
|
+
// "timestamp":1648651276949,
|
|
600
|
+
// "price":"35773.20000000",
|
|
601
|
+
// "volume":"0.00300000",
|
|
602
|
+
// "is_buy":false
|
|
603
|
+
// }
|
|
604
|
+
//
|
|
605
|
+
// fetchMyTrades (private)
|
|
606
|
+
//
|
|
607
|
+
// {
|
|
608
|
+
// "pair":"LTCXBT",
|
|
609
|
+
// "sequence":3256813,
|
|
610
|
+
// "order_id":"BXEX6XHHDT5EGW2",
|
|
611
|
+
// "type":"ASK",
|
|
612
|
+
// "timestamp":1648652135235,
|
|
613
|
+
// "price":"0.002786",
|
|
614
|
+
// "volume":"0.10",
|
|
615
|
+
// "base":"0.10",
|
|
616
|
+
// "counter":"0.0002786",
|
|
617
|
+
// "fee_base":"0.0001",
|
|
618
|
+
// "fee_counter":"0.00",
|
|
619
|
+
// "is_buy":false,
|
|
620
|
+
// "client_order_id":""
|
|
621
|
+
// }
|
|
622
|
+
//
|
|
623
|
+
// For public trade data (is_buy === True) indicates 'buy' side but for private trade data
|
|
624
|
+
// is_buy indicates maker or taker. The value of "type" (ASK/BID) indicate sell/buy side.
|
|
625
|
+
// Private trade data includes ID field which public trade data does not.
|
|
626
|
+
const orderId = this.safeString(trade, 'order_id');
|
|
627
|
+
const id = this.safeString(trade, 'sequence');
|
|
628
|
+
let takerOrMaker = undefined;
|
|
629
|
+
let side = undefined;
|
|
630
|
+
if (orderId !== undefined) {
|
|
631
|
+
const type = this.safeString(trade, 'type');
|
|
632
|
+
if ((type === 'ASK') || (type === 'SELL')) {
|
|
633
|
+
side = 'sell';
|
|
634
|
+
}
|
|
635
|
+
else if ((type === 'BID') || (type === 'BUY')) {
|
|
636
|
+
side = 'buy';
|
|
637
|
+
}
|
|
638
|
+
if (side === 'sell' && trade['is_buy']) {
|
|
639
|
+
takerOrMaker = 'maker';
|
|
640
|
+
}
|
|
641
|
+
else if (side === 'buy' && !trade['is_buy']) {
|
|
642
|
+
takerOrMaker = 'maker';
|
|
643
|
+
}
|
|
644
|
+
else {
|
|
645
|
+
takerOrMaker = 'taker';
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
else {
|
|
649
|
+
side = trade['is_buy'] ? 'buy' : 'sell';
|
|
650
|
+
}
|
|
651
|
+
const feeBaseString = this.safeString(trade, 'fee_base');
|
|
652
|
+
const feeCounterString = this.safeString(trade, 'fee_counter');
|
|
653
|
+
let feeCurrency = undefined;
|
|
654
|
+
let feeCost = undefined;
|
|
655
|
+
if (feeBaseString !== undefined) {
|
|
656
|
+
if (!Precise["default"].stringEquals(feeBaseString, '0.0')) {
|
|
657
|
+
feeCurrency = market['base'];
|
|
658
|
+
feeCost = feeBaseString;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
else if (feeCounterString !== undefined) {
|
|
662
|
+
if (!Precise["default"].stringEquals(feeCounterString, '0.0')) {
|
|
663
|
+
feeCurrency = market['quote'];
|
|
664
|
+
feeCost = feeCounterString;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
const timestamp = this.safeInteger(trade, 'timestamp');
|
|
668
|
+
return this.safeTrade({
|
|
669
|
+
'info': trade,
|
|
670
|
+
'id': id,
|
|
671
|
+
'timestamp': timestamp,
|
|
672
|
+
'datetime': this.iso8601(timestamp),
|
|
673
|
+
'symbol': market['symbol'],
|
|
674
|
+
'order': orderId,
|
|
675
|
+
'type': undefined,
|
|
676
|
+
'side': side,
|
|
677
|
+
'takerOrMaker': takerOrMaker,
|
|
678
|
+
'price': this.safeString(trade, 'price'),
|
|
679
|
+
'amount': this.safeString2(trade, 'volume', 'base'),
|
|
680
|
+
// Does not include potential fee costs
|
|
681
|
+
'cost': this.safeString(trade, 'counter'),
|
|
682
|
+
'fee': {
|
|
683
|
+
'cost': feeCost,
|
|
684
|
+
'currency': feeCurrency,
|
|
685
|
+
},
|
|
686
|
+
}, market);
|
|
687
|
+
}
|
|
688
|
+
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
689
|
+
/**
|
|
690
|
+
* @method
|
|
691
|
+
* @name luno#fetchTrades
|
|
692
|
+
* @description get the list of most recent trades for a particular symbol
|
|
693
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
694
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
695
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
696
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
697
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
698
|
+
*/
|
|
699
|
+
await this.loadMarkets();
|
|
700
|
+
const market = this.market(symbol);
|
|
701
|
+
const request = {
|
|
702
|
+
'pair': market['id'],
|
|
703
|
+
};
|
|
704
|
+
if (since !== undefined) {
|
|
705
|
+
request['since'] = since;
|
|
706
|
+
}
|
|
707
|
+
const response = await this.publicGetTrades(this.extend(request, params));
|
|
708
|
+
//
|
|
709
|
+
// {
|
|
710
|
+
// "trades":[
|
|
711
|
+
// {
|
|
712
|
+
// "sequence":276989,
|
|
713
|
+
// "timestamp":1648651276949,
|
|
714
|
+
// "price":"35773.20000000",
|
|
715
|
+
// "volume":"0.00300000",
|
|
716
|
+
// "is_buy":false
|
|
717
|
+
// },...
|
|
718
|
+
// ]
|
|
719
|
+
// }
|
|
720
|
+
//
|
|
721
|
+
const trades = this.safeValue(response, 'trades', []);
|
|
722
|
+
return this.parseTrades(trades, market, since, limit);
|
|
723
|
+
}
|
|
724
|
+
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
725
|
+
/**
|
|
726
|
+
* @method
|
|
727
|
+
* @name luno#fetchMyTrades
|
|
728
|
+
* @description fetch all trades made by the user
|
|
729
|
+
* @param {string} symbol unified market symbol
|
|
730
|
+
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
731
|
+
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
732
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
733
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
734
|
+
*/
|
|
735
|
+
if (symbol === undefined) {
|
|
736
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
|
|
737
|
+
}
|
|
738
|
+
await this.loadMarkets();
|
|
739
|
+
const market = this.market(symbol);
|
|
740
|
+
const request = {
|
|
741
|
+
'pair': market['id'],
|
|
742
|
+
};
|
|
743
|
+
if (since !== undefined) {
|
|
744
|
+
request['since'] = since;
|
|
745
|
+
}
|
|
746
|
+
if (limit !== undefined) {
|
|
747
|
+
request['limit'] = limit;
|
|
748
|
+
}
|
|
749
|
+
const response = await this.privateGetListtrades(this.extend(request, params));
|
|
750
|
+
//
|
|
751
|
+
// {
|
|
752
|
+
// "trades":[
|
|
753
|
+
// {
|
|
754
|
+
// "pair":"LTCXBT",
|
|
755
|
+
// "sequence":3256813,
|
|
756
|
+
// "order_id":"BXEX6XHHDT5EGW2",
|
|
757
|
+
// "type":"ASK",
|
|
758
|
+
// "timestamp":1648652135235,
|
|
759
|
+
// "price":"0.002786",
|
|
760
|
+
// "volume":"0.10",
|
|
761
|
+
// "base":"0.10",
|
|
762
|
+
// "counter":"0.0002786",
|
|
763
|
+
// "fee_base":"0.0001",
|
|
764
|
+
// "fee_counter":"0.00",
|
|
765
|
+
// "is_buy":false,
|
|
766
|
+
// "client_order_id":""
|
|
767
|
+
// },...
|
|
768
|
+
// ]
|
|
769
|
+
// }
|
|
770
|
+
//
|
|
771
|
+
const trades = this.safeValue(response, 'trades', []);
|
|
772
|
+
return this.parseTrades(trades, market, since, limit);
|
|
773
|
+
}
|
|
774
|
+
async fetchTradingFee(symbol, params = {}) {
|
|
775
|
+
/**
|
|
776
|
+
* @method
|
|
777
|
+
* @name luno#fetchTradingFee
|
|
778
|
+
* @description fetch the trading fees for a market
|
|
779
|
+
* @param {string} symbol unified market symbol
|
|
780
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
781
|
+
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
782
|
+
*/
|
|
783
|
+
await this.loadMarkets();
|
|
784
|
+
const market = this.market(symbol);
|
|
785
|
+
const request = {
|
|
786
|
+
'pair': market['id'],
|
|
787
|
+
};
|
|
788
|
+
const response = await this.privateGetFeeInfo(this.extend(request, params));
|
|
789
|
+
//
|
|
790
|
+
// {
|
|
791
|
+
// "maker_fee": "0.00250000",
|
|
792
|
+
// "taker_fee": "0.00500000",
|
|
793
|
+
// "thirty_day_volume": "0"
|
|
794
|
+
// }
|
|
795
|
+
//
|
|
796
|
+
return {
|
|
797
|
+
'info': response,
|
|
798
|
+
'symbol': symbol,
|
|
799
|
+
'maker': this.safeNumber(response, 'maker_fee'),
|
|
800
|
+
'taker': this.safeNumber(response, 'taker_fee'),
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
804
|
+
/**
|
|
805
|
+
* @method
|
|
806
|
+
* @name luno#createOrder
|
|
807
|
+
* @description create a trade order
|
|
808
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
809
|
+
* @param {string} type 'market' or 'limit'
|
|
810
|
+
* @param {string} side 'buy' or 'sell'
|
|
811
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
812
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
813
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
814
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
815
|
+
*/
|
|
816
|
+
await this.loadMarkets();
|
|
817
|
+
const market = this.market(symbol);
|
|
818
|
+
const request = {
|
|
819
|
+
'pair': market['id'],
|
|
820
|
+
};
|
|
821
|
+
let response = undefined;
|
|
822
|
+
if (type === 'market') {
|
|
823
|
+
request['type'] = side.toUpperCase();
|
|
824
|
+
// todo add createMarketBuyOrderRequires price logic as it is implemented in the other exchanges
|
|
825
|
+
if (side === 'buy') {
|
|
826
|
+
request['counter_volume'] = this.amountToPrecision(market['symbol'], amount);
|
|
827
|
+
}
|
|
828
|
+
else {
|
|
829
|
+
request['base_volume'] = this.amountToPrecision(market['symbol'], amount);
|
|
830
|
+
}
|
|
831
|
+
response = await this.privatePostMarketorder(this.extend(request, params));
|
|
832
|
+
}
|
|
833
|
+
else {
|
|
834
|
+
request['volume'] = this.amountToPrecision(market['symbol'], amount);
|
|
835
|
+
request['price'] = this.priceToPrecision(market['symbol'], price);
|
|
836
|
+
request['type'] = (side === 'buy') ? 'BID' : 'ASK';
|
|
837
|
+
response = await this.privatePostPostorder(this.extend(request, params));
|
|
838
|
+
}
|
|
839
|
+
return this.safeOrder({
|
|
840
|
+
'info': response,
|
|
841
|
+
'id': response['order_id'],
|
|
842
|
+
}, market);
|
|
843
|
+
}
|
|
844
|
+
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
845
|
+
/**
|
|
846
|
+
* @method
|
|
847
|
+
* @name luno#cancelOrder
|
|
848
|
+
* @description cancels an open order
|
|
849
|
+
* @param {string} id order id
|
|
850
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
851
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
852
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
853
|
+
*/
|
|
854
|
+
await this.loadMarkets();
|
|
855
|
+
const request = {
|
|
856
|
+
'order_id': id,
|
|
857
|
+
};
|
|
858
|
+
return await this.privatePostStoporder(this.extend(request, params));
|
|
859
|
+
}
|
|
860
|
+
async fetchLedgerByEntries(code = undefined, entry = undefined, limit = undefined, params = {}) {
|
|
861
|
+
// by default without entry number or limit number, return most recent entry
|
|
862
|
+
if (entry === undefined) {
|
|
863
|
+
entry = -1;
|
|
864
|
+
}
|
|
865
|
+
if (limit === undefined) {
|
|
866
|
+
limit = 1;
|
|
867
|
+
}
|
|
868
|
+
const since = undefined;
|
|
869
|
+
const request = {
|
|
870
|
+
'min_row': entry,
|
|
871
|
+
'max_row': this.sum(entry, limit),
|
|
872
|
+
};
|
|
873
|
+
return await this.fetchLedger(code, since, limit, this.extend(request, params));
|
|
874
|
+
}
|
|
875
|
+
async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
876
|
+
/**
|
|
877
|
+
* @method
|
|
878
|
+
* @name luno#fetchLedger
|
|
879
|
+
* @description fetch the history of changes, actions done by the user or operations that altered balance of the user
|
|
880
|
+
* @param {string} code unified currency code, default is undefined
|
|
881
|
+
* @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
|
|
882
|
+
* @param {int} [limit] max number of ledger entrys to return, default is undefined
|
|
883
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
884
|
+
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
|
|
885
|
+
*/
|
|
886
|
+
await this.loadMarkets();
|
|
887
|
+
await this.loadAccounts();
|
|
888
|
+
let currency = undefined;
|
|
889
|
+
let id = this.safeString(params, 'id'); // account id
|
|
890
|
+
let min_row = this.safeValue(params, 'min_row');
|
|
891
|
+
let max_row = this.safeValue(params, 'max_row');
|
|
892
|
+
if (id === undefined) {
|
|
893
|
+
if (code === undefined) {
|
|
894
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchLedger() requires a currency code argument if no account id specified in params');
|
|
895
|
+
}
|
|
896
|
+
currency = this.currency(code);
|
|
897
|
+
const accountsByCurrencyCode = this.indexBy(this.accounts, 'currency');
|
|
898
|
+
const account = this.safeValue(accountsByCurrencyCode, code);
|
|
899
|
+
if (account === undefined) {
|
|
900
|
+
throw new errors.ExchangeError(this.id + ' fetchLedger() could not find account id for ' + code);
|
|
901
|
+
}
|
|
902
|
+
id = account['id'];
|
|
903
|
+
}
|
|
904
|
+
if (min_row === undefined && max_row === undefined) {
|
|
905
|
+
max_row = 0; // Default to most recent transactions
|
|
906
|
+
min_row = -1000; // Maximum number of records supported
|
|
907
|
+
}
|
|
908
|
+
else if (min_row === undefined || max_row === undefined) {
|
|
909
|
+
throw new errors.ExchangeError(this.id + " fetchLedger() require both params 'max_row' and 'min_row' or neither to be defined");
|
|
910
|
+
}
|
|
911
|
+
if (limit !== undefined && max_row - min_row > limit) {
|
|
912
|
+
if (max_row <= 0) {
|
|
913
|
+
min_row = max_row - limit;
|
|
914
|
+
}
|
|
915
|
+
else if (min_row > 0) {
|
|
916
|
+
max_row = min_row + limit;
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
if (max_row - min_row > 1000) {
|
|
920
|
+
throw new errors.ExchangeError(this.id + " fetchLedger() requires the params 'max_row' - 'min_row' <= 1000");
|
|
921
|
+
}
|
|
922
|
+
const request = {
|
|
923
|
+
'id': id,
|
|
924
|
+
'min_row': min_row,
|
|
925
|
+
'max_row': max_row,
|
|
926
|
+
};
|
|
927
|
+
const response = await this.privateGetAccountsIdTransactions(this.extend(params, request));
|
|
928
|
+
const entries = this.safeValue(response, 'transactions', []);
|
|
929
|
+
return this.parseLedger(entries, currency, since, limit);
|
|
930
|
+
}
|
|
931
|
+
parseLedgerComment(comment) {
|
|
932
|
+
const words = comment.split(' ');
|
|
933
|
+
const types = {
|
|
934
|
+
'Withdrawal': 'fee',
|
|
935
|
+
'Trading': 'fee',
|
|
936
|
+
'Payment': 'transaction',
|
|
937
|
+
'Sent': 'transaction',
|
|
938
|
+
'Deposit': 'transaction',
|
|
939
|
+
'Received': 'transaction',
|
|
940
|
+
'Released': 'released',
|
|
941
|
+
'Reserved': 'reserved',
|
|
942
|
+
'Sold': 'trade',
|
|
943
|
+
'Bought': 'trade',
|
|
944
|
+
'Failure': 'failed',
|
|
945
|
+
};
|
|
946
|
+
let referenceId = undefined;
|
|
947
|
+
const firstWord = this.safeString(words, 0);
|
|
948
|
+
const thirdWord = this.safeString(words, 2);
|
|
949
|
+
const fourthWord = this.safeString(words, 3);
|
|
950
|
+
let type = this.safeString(types, firstWord, undefined);
|
|
951
|
+
if ((type === undefined) && (thirdWord === 'fee')) {
|
|
952
|
+
type = 'fee';
|
|
953
|
+
}
|
|
954
|
+
if ((type === 'reserved') && (fourthWord === 'order')) {
|
|
955
|
+
referenceId = this.safeString(words, 4);
|
|
956
|
+
}
|
|
957
|
+
return {
|
|
958
|
+
'type': type,
|
|
959
|
+
'referenceId': referenceId,
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
parseLedgerEntry(entry, currency = undefined) {
|
|
963
|
+
// const details = this.safeValue (entry, 'details', {});
|
|
964
|
+
const id = this.safeString(entry, 'row_index');
|
|
965
|
+
const account_id = this.safeString(entry, 'account_id');
|
|
966
|
+
const timestamp = this.safeInteger(entry, 'timestamp');
|
|
967
|
+
const currencyId = this.safeString(entry, 'currency');
|
|
968
|
+
const code = this.safeCurrencyCode(currencyId, currency);
|
|
969
|
+
const available_delta = this.safeString(entry, 'available_delta');
|
|
970
|
+
const balance_delta = this.safeString(entry, 'balance_delta');
|
|
971
|
+
const after = this.safeString(entry, 'balance');
|
|
972
|
+
const comment = this.safeString(entry, 'description');
|
|
973
|
+
let before = after;
|
|
974
|
+
let amount = '0.0';
|
|
975
|
+
const result = this.parseLedgerComment(comment);
|
|
976
|
+
const type = result['type'];
|
|
977
|
+
const referenceId = result['referenceId'];
|
|
978
|
+
let direction = undefined;
|
|
979
|
+
let status = undefined;
|
|
980
|
+
if (!Precise["default"].stringEquals(balance_delta, '0.0')) {
|
|
981
|
+
before = Precise["default"].stringSub(after, balance_delta);
|
|
982
|
+
status = 'ok';
|
|
983
|
+
amount = Precise["default"].stringAbs(balance_delta);
|
|
984
|
+
}
|
|
985
|
+
else if (Precise["default"].stringLt(available_delta, '0.0')) {
|
|
986
|
+
status = 'pending';
|
|
987
|
+
amount = Precise["default"].stringAbs(available_delta);
|
|
988
|
+
}
|
|
989
|
+
else if (Precise["default"].stringGt(available_delta, '0.0')) {
|
|
990
|
+
status = 'canceled';
|
|
991
|
+
amount = Precise["default"].stringAbs(available_delta);
|
|
992
|
+
}
|
|
993
|
+
if (Precise["default"].stringGt(balance_delta, '0') || Precise["default"].stringGt(available_delta, '0')) {
|
|
994
|
+
direction = 'in';
|
|
995
|
+
}
|
|
996
|
+
else if (Precise["default"].stringLt(balance_delta, '0') || Precise["default"].stringLt(available_delta, '0')) {
|
|
997
|
+
direction = 'out';
|
|
998
|
+
}
|
|
999
|
+
return {
|
|
1000
|
+
'id': id,
|
|
1001
|
+
'direction': direction,
|
|
1002
|
+
'account': account_id,
|
|
1003
|
+
'referenceId': referenceId,
|
|
1004
|
+
'referenceAccount': undefined,
|
|
1005
|
+
'type': type,
|
|
1006
|
+
'currency': code,
|
|
1007
|
+
'amount': this.parseNumber(amount),
|
|
1008
|
+
'timestamp': timestamp,
|
|
1009
|
+
'datetime': this.iso8601(timestamp),
|
|
1010
|
+
'before': this.parseNumber(before),
|
|
1011
|
+
'after': this.parseNumber(after),
|
|
1012
|
+
'status': status,
|
|
1013
|
+
'fee': undefined,
|
|
1014
|
+
'info': entry,
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
1018
|
+
let url = this.urls['api'][api] + '/' + this.version + '/' + this.implodeParams(path, params);
|
|
1019
|
+
const query = this.omit(params, this.extractParams(path));
|
|
1020
|
+
if (Object.keys(query).length) {
|
|
1021
|
+
url += '?' + this.urlencode(query);
|
|
1022
|
+
}
|
|
1023
|
+
if (api === 'private') {
|
|
1024
|
+
this.checkRequiredCredentials();
|
|
1025
|
+
const auth = this.stringToBase64(this.apiKey + ':' + this.secret);
|
|
1026
|
+
headers = {
|
|
1027
|
+
'Authorization': 'Basic ' + auth,
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
1031
|
+
}
|
|
1032
|
+
handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
1033
|
+
if (response === undefined) {
|
|
1034
|
+
return undefined;
|
|
1035
|
+
}
|
|
1036
|
+
const error = this.safeValue(response, 'error');
|
|
1037
|
+
if (error !== undefined) {
|
|
1038
|
+
throw new errors.ExchangeError(this.id + ' ' + this.json(response));
|
|
1039
|
+
}
|
|
1040
|
+
return undefined;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
module.exports = luno;
|