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,1753 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var bitso$1 = require('./abstract/bitso.js');
|
|
4
|
+
var errors = require('./base/errors.js');
|
|
5
|
+
var Precise = require('./base/Precise.js');
|
|
6
|
+
var number = require('./base/functions/number.js');
|
|
7
|
+
var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
|
|
8
|
+
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
/**
|
|
12
|
+
* @class bitso
|
|
13
|
+
* @augments Exchange
|
|
14
|
+
*/
|
|
15
|
+
class bitso extends bitso$1 {
|
|
16
|
+
describe() {
|
|
17
|
+
return this.deepExtend(super.describe(), {
|
|
18
|
+
'id': 'bitso',
|
|
19
|
+
'name': 'Bitso',
|
|
20
|
+
'countries': ['MX'],
|
|
21
|
+
'rateLimit': 2000,
|
|
22
|
+
'version': 'v3',
|
|
23
|
+
'has': {
|
|
24
|
+
'CORS': undefined,
|
|
25
|
+
'spot': true,
|
|
26
|
+
'margin': false,
|
|
27
|
+
'swap': false,
|
|
28
|
+
'future': false,
|
|
29
|
+
'option': false,
|
|
30
|
+
'addMargin': false,
|
|
31
|
+
'cancelAllOrders': true,
|
|
32
|
+
'cancelOrder': true,
|
|
33
|
+
'cancelOrders': true,
|
|
34
|
+
'closeAllPositions': false,
|
|
35
|
+
'closePosition': false,
|
|
36
|
+
'createDepositAddress': false,
|
|
37
|
+
'createOrder': true,
|
|
38
|
+
'createReduceOnlyOrder': false,
|
|
39
|
+
'fetchAccounts': false,
|
|
40
|
+
'fetchBalance': true,
|
|
41
|
+
'fetchBorrowRateHistories': false,
|
|
42
|
+
'fetchBorrowRateHistory': false,
|
|
43
|
+
'fetchCrossBorrowRate': false,
|
|
44
|
+
'fetchCrossBorrowRates': false,
|
|
45
|
+
'fetchDeposit': true,
|
|
46
|
+
'fetchDepositAddress': true,
|
|
47
|
+
'fetchDepositAddresses': false,
|
|
48
|
+
'fetchDeposits': true,
|
|
49
|
+
'fetchDepositsWithdrawals': false,
|
|
50
|
+
'fetchDepositWithdrawFee': 'emulated',
|
|
51
|
+
'fetchDepositWithdrawFees': true,
|
|
52
|
+
'fetchFundingHistory': false,
|
|
53
|
+
'fetchFundingRate': false,
|
|
54
|
+
'fetchFundingRateHistory': false,
|
|
55
|
+
'fetchFundingRates': false,
|
|
56
|
+
'fetchIndexOHLCV': false,
|
|
57
|
+
'fetchIsolatedBorrowRate': false,
|
|
58
|
+
'fetchIsolatedBorrowRates': false,
|
|
59
|
+
'fetchLedger': true,
|
|
60
|
+
'fetchLeverage': false,
|
|
61
|
+
'fetchMarginMode': false,
|
|
62
|
+
'fetchMarkets': true,
|
|
63
|
+
'fetchMarkOHLCV': false,
|
|
64
|
+
'fetchMyTrades': true,
|
|
65
|
+
'fetchOHLCV': true,
|
|
66
|
+
'fetchOpenInterestHistory': false,
|
|
67
|
+
'fetchOpenOrders': true,
|
|
68
|
+
'fetchOrder': true,
|
|
69
|
+
'fetchOrderBook': true,
|
|
70
|
+
'fetchOrderTrades': true,
|
|
71
|
+
'fetchPosition': false,
|
|
72
|
+
'fetchPositionMode': false,
|
|
73
|
+
'fetchPositions': false,
|
|
74
|
+
'fetchPositionsRisk': false,
|
|
75
|
+
'fetchPremiumIndexOHLCV': false,
|
|
76
|
+
'fetchTicker': true,
|
|
77
|
+
'fetchTickers': false,
|
|
78
|
+
'fetchTime': false,
|
|
79
|
+
'fetchTrades': true,
|
|
80
|
+
'fetchTradingFee': false,
|
|
81
|
+
'fetchTradingFees': true,
|
|
82
|
+
'fetchTransactionFee': false,
|
|
83
|
+
'fetchTransactionFees': true,
|
|
84
|
+
'fetchTransactions': false,
|
|
85
|
+
'fetchTransfer': false,
|
|
86
|
+
'fetchTransfers': false,
|
|
87
|
+
'reduceMargin': false,
|
|
88
|
+
'setLeverage': false,
|
|
89
|
+
'setMarginMode': false,
|
|
90
|
+
'setPositionMode': false,
|
|
91
|
+
'transfer': false,
|
|
92
|
+
'withdraw': true,
|
|
93
|
+
},
|
|
94
|
+
'urls': {
|
|
95
|
+
'logo': 'https://user-images.githubusercontent.com/51840849/87295554-11f98280-c50e-11ea-80d6-15b3bafa8cbf.jpg',
|
|
96
|
+
'api': {
|
|
97
|
+
'rest': 'https://api.bitso.com',
|
|
98
|
+
},
|
|
99
|
+
'www': 'https://bitso.com',
|
|
100
|
+
'doc': 'https://bitso.com/api_info',
|
|
101
|
+
'fees': 'https://bitso.com/fees',
|
|
102
|
+
'referral': 'https://bitso.com/?ref=itej',
|
|
103
|
+
},
|
|
104
|
+
'precisionMode': number.TICK_SIZE,
|
|
105
|
+
'options': {
|
|
106
|
+
'precision': {
|
|
107
|
+
'XRP': 0.000001,
|
|
108
|
+
'MXN': 0.01,
|
|
109
|
+
'TUSD': 0.01,
|
|
110
|
+
},
|
|
111
|
+
'defaultPrecision': 0.00000001,
|
|
112
|
+
},
|
|
113
|
+
'timeframes': {
|
|
114
|
+
'1m': '60',
|
|
115
|
+
'5m': '300',
|
|
116
|
+
'15m': '900',
|
|
117
|
+
'30m': '1800',
|
|
118
|
+
'1h': '3600',
|
|
119
|
+
'4h': '14400',
|
|
120
|
+
'12h': '43200',
|
|
121
|
+
'1d': '86400',
|
|
122
|
+
'1w': '604800',
|
|
123
|
+
},
|
|
124
|
+
'api': {
|
|
125
|
+
'public': {
|
|
126
|
+
'get': [
|
|
127
|
+
'available_books',
|
|
128
|
+
'ticker',
|
|
129
|
+
'order_book',
|
|
130
|
+
'trades',
|
|
131
|
+
'ohlc',
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
'private': {
|
|
135
|
+
'get': [
|
|
136
|
+
'account_status',
|
|
137
|
+
'balance',
|
|
138
|
+
'fees',
|
|
139
|
+
'fundings',
|
|
140
|
+
'fundings/{fid}',
|
|
141
|
+
'funding_destination',
|
|
142
|
+
'kyc_documents',
|
|
143
|
+
'ledger',
|
|
144
|
+
'ledger/trades',
|
|
145
|
+
'ledger/fees',
|
|
146
|
+
'ledger/fundings',
|
|
147
|
+
'ledger/withdrawals',
|
|
148
|
+
'mx_bank_codes',
|
|
149
|
+
'open_orders',
|
|
150
|
+
'order_trades/{oid}',
|
|
151
|
+
'orders/{oid}',
|
|
152
|
+
'user_trades',
|
|
153
|
+
'user_trades/{tid}',
|
|
154
|
+
'withdrawals/',
|
|
155
|
+
'withdrawals/{wid}',
|
|
156
|
+
],
|
|
157
|
+
'post': [
|
|
158
|
+
'bitcoin_withdrawal',
|
|
159
|
+
'debit_card_withdrawal',
|
|
160
|
+
'ether_withdrawal',
|
|
161
|
+
'orders',
|
|
162
|
+
'phone_number',
|
|
163
|
+
'phone_verification',
|
|
164
|
+
'phone_withdrawal',
|
|
165
|
+
'spei_withdrawal',
|
|
166
|
+
'ripple_withdrawal',
|
|
167
|
+
'bcash_withdrawal',
|
|
168
|
+
'litecoin_withdrawal',
|
|
169
|
+
],
|
|
170
|
+
'delete': [
|
|
171
|
+
'orders',
|
|
172
|
+
'orders/{oid}',
|
|
173
|
+
'orders/all',
|
|
174
|
+
],
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
'exceptions': {
|
|
178
|
+
'0201': errors.AuthenticationError,
|
|
179
|
+
'104': errors.InvalidNonce,
|
|
180
|
+
'0304': errors.BadRequest, // {"success":false,"error":{"code":"0304","message":"The field time_bucket () is either invalid or missing"}}
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
185
|
+
/**
|
|
186
|
+
* @method
|
|
187
|
+
* @name bitso#fetchLedger
|
|
188
|
+
* @description fetch the history of changes, actions done by the user or operations that altered balance of the user
|
|
189
|
+
* @param {string} code unified currency code, default is undefined
|
|
190
|
+
* @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
|
|
191
|
+
* @param {int} [limit] max number of ledger entrys to return, default is undefined
|
|
192
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
193
|
+
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
|
|
194
|
+
*/
|
|
195
|
+
const request = {};
|
|
196
|
+
if (limit !== undefined) {
|
|
197
|
+
request['limit'] = limit;
|
|
198
|
+
}
|
|
199
|
+
const response = await this.privateGetLedger(this.extend(request, params));
|
|
200
|
+
//
|
|
201
|
+
// {
|
|
202
|
+
// "success": true,
|
|
203
|
+
// "payload": [{
|
|
204
|
+
// "eid": "2510b3e2bc1c87f584500a18084f35ed",
|
|
205
|
+
// "created_at": "2022-06-08T12:21:42+0000",
|
|
206
|
+
// "balance_updates": [{
|
|
207
|
+
// "amount": "0.00080000",
|
|
208
|
+
// "currency": "btc"
|
|
209
|
+
// }],
|
|
210
|
+
// "operation": "funding",
|
|
211
|
+
// "details": {
|
|
212
|
+
// "network": "btc",
|
|
213
|
+
// "method": "btc",
|
|
214
|
+
// "method_name": "Bitcoin",
|
|
215
|
+
// "asset": "btc",
|
|
216
|
+
// "protocol": "btc",
|
|
217
|
+
// "integration": "bitgo-v2",
|
|
218
|
+
// "fid": "6112c6369100d6ecceb7f54f17cf0511"
|
|
219
|
+
// }
|
|
220
|
+
// }]
|
|
221
|
+
// }
|
|
222
|
+
//
|
|
223
|
+
const payload = this.safeValue(response, 'payload', []);
|
|
224
|
+
const currency = this.safeCurrency(code);
|
|
225
|
+
return this.parseLedger(payload, currency, since, limit);
|
|
226
|
+
}
|
|
227
|
+
parseLedgerEntryType(type) {
|
|
228
|
+
const types = {
|
|
229
|
+
'funding': 'transaction',
|
|
230
|
+
'withdrawal': 'transaction',
|
|
231
|
+
'trade': 'trade',
|
|
232
|
+
'fee': 'fee',
|
|
233
|
+
};
|
|
234
|
+
return this.safeString(types, type, type);
|
|
235
|
+
}
|
|
236
|
+
parseLedgerEntry(item, currency = undefined) {
|
|
237
|
+
//
|
|
238
|
+
// {
|
|
239
|
+
// "eid": "2510b3e2bc1c87f584500a18084f35ed",
|
|
240
|
+
// "created_at": "2022-06-08T12:21:42+0000",
|
|
241
|
+
// "balance_updates": [{
|
|
242
|
+
// "amount": "0.00080000",
|
|
243
|
+
// "currency": "btc"
|
|
244
|
+
// }],
|
|
245
|
+
// "operation": "funding",
|
|
246
|
+
// "details": {
|
|
247
|
+
// "network": "btc",
|
|
248
|
+
// "method": "btc",
|
|
249
|
+
// "method_name": "Bitcoin",
|
|
250
|
+
// "asset": "btc",
|
|
251
|
+
// "protocol": "btc",
|
|
252
|
+
// "integration": "bitgo-v2",
|
|
253
|
+
// "fid": "6112c6369100d6ecceb7f54f17cf0511"
|
|
254
|
+
// }
|
|
255
|
+
// }
|
|
256
|
+
//
|
|
257
|
+
// trade
|
|
258
|
+
// {
|
|
259
|
+
// "eid": "8976c6053f078f704f037d82a813678a",
|
|
260
|
+
// "created_at": "2022-06-08T17:01:48+0000",
|
|
261
|
+
// "balance_updates": [{
|
|
262
|
+
// "amount": "59.21320500",
|
|
263
|
+
// "currency": "mxn"
|
|
264
|
+
// },
|
|
265
|
+
// {
|
|
266
|
+
// "amount": "-0.00010000",
|
|
267
|
+
// "currency": "btc"
|
|
268
|
+
// }
|
|
269
|
+
// ],
|
|
270
|
+
// "operation": "trade",
|
|
271
|
+
// "details": {
|
|
272
|
+
// "tid": "72145428",
|
|
273
|
+
// "oid": "JO5TZmMZjzjlZDyT"
|
|
274
|
+
// }
|
|
275
|
+
// }
|
|
276
|
+
//
|
|
277
|
+
// fee
|
|
278
|
+
// {
|
|
279
|
+
// "eid": "cbbb3c8d4e41723d25d2850dcb7c3c74",
|
|
280
|
+
// "created_at": "2022-06-08T17:01:48+0000",
|
|
281
|
+
// "balance_updates": [{
|
|
282
|
+
// "amount": "-0.38488583",
|
|
283
|
+
// "currency": "mxn"
|
|
284
|
+
// }],
|
|
285
|
+
// "operation": "fee",
|
|
286
|
+
// "details": {
|
|
287
|
+
// "tid": "72145428",
|
|
288
|
+
// "oid": "JO5TZmMZjzjlZDyT"
|
|
289
|
+
// }
|
|
290
|
+
// }
|
|
291
|
+
const operation = this.safeString(item, 'operation');
|
|
292
|
+
const type = this.parseLedgerEntryType(operation);
|
|
293
|
+
const balanceUpdates = this.safeValue(item, 'balance_updates', []);
|
|
294
|
+
const firstBalance = this.safeValue(balanceUpdates, 0, {});
|
|
295
|
+
let direction = undefined;
|
|
296
|
+
let fee = undefined;
|
|
297
|
+
const amount = this.safeString(firstBalance, 'amount');
|
|
298
|
+
const currencyId = this.safeString(firstBalance, 'currency');
|
|
299
|
+
const code = this.safeCurrencyCode(currencyId, currency);
|
|
300
|
+
const details = this.safeValue(item, 'details', {});
|
|
301
|
+
let referenceId = this.safeString2(details, 'fid', 'wid');
|
|
302
|
+
if (referenceId === undefined) {
|
|
303
|
+
referenceId = this.safeString(details, 'tid');
|
|
304
|
+
}
|
|
305
|
+
if (operation === 'funding') {
|
|
306
|
+
direction = 'in';
|
|
307
|
+
}
|
|
308
|
+
else if (operation === 'withdrawal') {
|
|
309
|
+
direction = 'out';
|
|
310
|
+
}
|
|
311
|
+
else if (operation === 'trade') {
|
|
312
|
+
direction = undefined;
|
|
313
|
+
}
|
|
314
|
+
else if (operation === 'fee') {
|
|
315
|
+
direction = 'out';
|
|
316
|
+
const cost = Precise["default"].stringAbs(amount);
|
|
317
|
+
fee = {
|
|
318
|
+
'cost': cost,
|
|
319
|
+
'currency': currency,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
const timestamp = this.parse8601(this.safeString(item, 'created_at'));
|
|
323
|
+
return this.safeLedgerEntry({
|
|
324
|
+
'id': this.safeString(item, 'eid'),
|
|
325
|
+
'direction': direction,
|
|
326
|
+
'account': undefined,
|
|
327
|
+
'referenceId': referenceId,
|
|
328
|
+
'referenceAccount': undefined,
|
|
329
|
+
'type': type,
|
|
330
|
+
'currency': code,
|
|
331
|
+
'amount': amount,
|
|
332
|
+
'timestamp': timestamp,
|
|
333
|
+
'datetime': this.iso8601(timestamp),
|
|
334
|
+
'before': undefined,
|
|
335
|
+
'after': undefined,
|
|
336
|
+
'status': 'ok',
|
|
337
|
+
'fee': fee,
|
|
338
|
+
'info': item,
|
|
339
|
+
}, currency);
|
|
340
|
+
}
|
|
341
|
+
async fetchMarkets(params = {}) {
|
|
342
|
+
/**
|
|
343
|
+
* @method
|
|
344
|
+
* @name bitso#fetchMarkets
|
|
345
|
+
* @description retrieves data on all markets for bitso
|
|
346
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
347
|
+
* @returns {object[]} an array of objects representing market data
|
|
348
|
+
*/
|
|
349
|
+
const response = await this.publicGetAvailableBooks(params);
|
|
350
|
+
//
|
|
351
|
+
// {
|
|
352
|
+
// "success":true,
|
|
353
|
+
// "payload":[
|
|
354
|
+
// {
|
|
355
|
+
// "book":"btc_mxn",
|
|
356
|
+
// "minimum_price":"500",
|
|
357
|
+
// "maximum_price":"10000000",
|
|
358
|
+
// "minimum_amount":"0.00005",
|
|
359
|
+
// "maximum_amount":"500",
|
|
360
|
+
// "minimum_value":"5",
|
|
361
|
+
// "maximum_value":"10000000",
|
|
362
|
+
// "tick_size":"0.01",
|
|
363
|
+
// "fees":{
|
|
364
|
+
// "flat_rate":{"maker":"0.500","taker":"0.650"},
|
|
365
|
+
// "structure":[
|
|
366
|
+
// {"volume":"1500000","maker":"0.00500","taker":"0.00650"},
|
|
367
|
+
// {"volume":"2000000","maker":"0.00490","taker":"0.00637"},
|
|
368
|
+
// {"volume":"5000000","maker":"0.00480","taker":"0.00624"},
|
|
369
|
+
// {"volume":"7000000","maker":"0.00440","taker":"0.00572"},
|
|
370
|
+
// {"volume":"10000000","maker":"0.00420","taker":"0.00546"},
|
|
371
|
+
// {"volume":"15000000","maker":"0.00400","taker":"0.00520"},
|
|
372
|
+
// {"volume":"35000000","maker":"0.00370","taker":"0.00481"},
|
|
373
|
+
// {"volume":"50000000","maker":"0.00300","taker":"0.00390"},
|
|
374
|
+
// {"volume":"150000000","maker":"0.00200","taker":"0.00260"},
|
|
375
|
+
// {"volume":"250000000","maker":"0.00100","taker":"0.00130"},
|
|
376
|
+
// {"volume":"9999999999","maker":"0.00000","taker":"0.00130"},
|
|
377
|
+
// ]
|
|
378
|
+
// }
|
|
379
|
+
// },
|
|
380
|
+
// ]
|
|
381
|
+
// }
|
|
382
|
+
const markets = this.safeValue(response, 'payload', []);
|
|
383
|
+
const result = [];
|
|
384
|
+
for (let i = 0; i < markets.length; i++) {
|
|
385
|
+
const market = markets[i];
|
|
386
|
+
const id = this.safeString(market, 'book');
|
|
387
|
+
const [baseId, quoteId] = id.split('_');
|
|
388
|
+
let base = baseId.toUpperCase();
|
|
389
|
+
let quote = quoteId.toUpperCase();
|
|
390
|
+
base = this.safeCurrencyCode(base);
|
|
391
|
+
quote = this.safeCurrencyCode(quote);
|
|
392
|
+
const fees = this.safeValue(market, 'fees', {});
|
|
393
|
+
const flatRate = this.safeValue(fees, 'flat_rate', {});
|
|
394
|
+
const takerString = this.safeString(flatRate, 'taker');
|
|
395
|
+
const makerString = this.safeString(flatRate, 'maker');
|
|
396
|
+
const taker = this.parseNumber(Precise["default"].stringDiv(takerString, '100'));
|
|
397
|
+
const maker = this.parseNumber(Precise["default"].stringDiv(makerString, '100'));
|
|
398
|
+
const feeTiers = this.safeValue(fees, 'structure', []);
|
|
399
|
+
const fee = {
|
|
400
|
+
'taker': taker,
|
|
401
|
+
'maker': maker,
|
|
402
|
+
'percentage': true,
|
|
403
|
+
'tierBased': true,
|
|
404
|
+
};
|
|
405
|
+
const takerFees = [];
|
|
406
|
+
const makerFees = [];
|
|
407
|
+
for (let j = 0; j < feeTiers.length; j++) {
|
|
408
|
+
const tier = feeTiers[j];
|
|
409
|
+
const volume = this.safeNumber(tier, 'volume');
|
|
410
|
+
const takerFee = this.safeNumber(tier, 'taker');
|
|
411
|
+
const makerFee = this.safeNumber(tier, 'maker');
|
|
412
|
+
takerFees.push([volume, takerFee]);
|
|
413
|
+
makerFees.push([volume, makerFee]);
|
|
414
|
+
if (j === 0) {
|
|
415
|
+
fee['taker'] = takerFee;
|
|
416
|
+
fee['maker'] = makerFee;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
const tiers = {
|
|
420
|
+
'taker': takerFees,
|
|
421
|
+
'maker': makerFees,
|
|
422
|
+
};
|
|
423
|
+
fee['tiers'] = tiers;
|
|
424
|
+
// TODO: precisions can be also set from https://bitso.com/api/v3/catalogues ->available_currency_conversions->currencies (or ->currencies->metadata) or https://bitso.com/api/v3/get_exchange_rates/mxn
|
|
425
|
+
const defaultPricePrecision = this.safeNumber(this.options['precision'], quote, this.options['defaultPrecision']);
|
|
426
|
+
result.push(this.extend({
|
|
427
|
+
'id': id,
|
|
428
|
+
'symbol': base + '/' + quote,
|
|
429
|
+
'base': base,
|
|
430
|
+
'quote': quote,
|
|
431
|
+
'settle': undefined,
|
|
432
|
+
'baseId': baseId,
|
|
433
|
+
'quoteId': quoteId,
|
|
434
|
+
'settleId': undefined,
|
|
435
|
+
'type': 'spot',
|
|
436
|
+
'spot': true,
|
|
437
|
+
'margin': false,
|
|
438
|
+
'swap': false,
|
|
439
|
+
'future': false,
|
|
440
|
+
'option': false,
|
|
441
|
+
'active': undefined,
|
|
442
|
+
'contract': false,
|
|
443
|
+
'linear': undefined,
|
|
444
|
+
'inverse': undefined,
|
|
445
|
+
'taker': taker,
|
|
446
|
+
'maker': maker,
|
|
447
|
+
'contractSize': undefined,
|
|
448
|
+
'expiry': undefined,
|
|
449
|
+
'expiryDatetime': undefined,
|
|
450
|
+
'strike': undefined,
|
|
451
|
+
'optionType': undefined,
|
|
452
|
+
'precision': {
|
|
453
|
+
'amount': this.safeNumber(this.options['precision'], base, this.options['defaultPrecision']),
|
|
454
|
+
'price': this.safeNumber(market, 'tick_size', defaultPricePrecision),
|
|
455
|
+
},
|
|
456
|
+
'limits': {
|
|
457
|
+
'leverage': {
|
|
458
|
+
'min': undefined,
|
|
459
|
+
'max': undefined,
|
|
460
|
+
},
|
|
461
|
+
'amount': {
|
|
462
|
+
'min': this.safeNumber(market, 'minimum_amount'),
|
|
463
|
+
'max': this.safeNumber(market, 'maximum_amount'),
|
|
464
|
+
},
|
|
465
|
+
'price': {
|
|
466
|
+
'min': this.safeNumber(market, 'minimum_price'),
|
|
467
|
+
'max': this.safeNumber(market, 'maximum_price'),
|
|
468
|
+
},
|
|
469
|
+
'cost': {
|
|
470
|
+
'min': this.safeNumber(market, 'minimum_value'),
|
|
471
|
+
'max': this.safeNumber(market, 'maximum_value'),
|
|
472
|
+
},
|
|
473
|
+
},
|
|
474
|
+
'created': undefined,
|
|
475
|
+
'info': market,
|
|
476
|
+
}, fee));
|
|
477
|
+
}
|
|
478
|
+
return result;
|
|
479
|
+
}
|
|
480
|
+
parseBalance(response) {
|
|
481
|
+
const payload = this.safeValue(response, 'payload', {});
|
|
482
|
+
const balances = this.safeValue(payload, 'balances', []);
|
|
483
|
+
const result = {
|
|
484
|
+
'info': response,
|
|
485
|
+
'timestamp': undefined,
|
|
486
|
+
'datetime': undefined,
|
|
487
|
+
};
|
|
488
|
+
for (let i = 0; i < balances.length; i++) {
|
|
489
|
+
const balance = balances[i];
|
|
490
|
+
const currencyId = this.safeString(balance, 'currency');
|
|
491
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
492
|
+
const account = this.account();
|
|
493
|
+
account['free'] = this.safeString(balance, 'available');
|
|
494
|
+
account['used'] = this.safeString(balance, 'locked');
|
|
495
|
+
account['total'] = this.safeString(balance, 'total');
|
|
496
|
+
result[code] = account;
|
|
497
|
+
}
|
|
498
|
+
return this.safeBalance(result);
|
|
499
|
+
}
|
|
500
|
+
async fetchBalance(params = {}) {
|
|
501
|
+
/**
|
|
502
|
+
* @method
|
|
503
|
+
* @name bitso#fetchBalance
|
|
504
|
+
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
505
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
506
|
+
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
507
|
+
*/
|
|
508
|
+
await this.loadMarkets();
|
|
509
|
+
const response = await this.privateGetBalance(params);
|
|
510
|
+
//
|
|
511
|
+
// {
|
|
512
|
+
// "success": true,
|
|
513
|
+
// "payload": {
|
|
514
|
+
// "balances": [
|
|
515
|
+
// {
|
|
516
|
+
// "currency": "bat",
|
|
517
|
+
// "available": "0.00000000",
|
|
518
|
+
// "locked": "0.00000000",
|
|
519
|
+
// "total": "0.00000000",
|
|
520
|
+
// "pending_deposit": "0.00000000",
|
|
521
|
+
// "pending_withdrawal": "0.00000000"
|
|
522
|
+
// },
|
|
523
|
+
// {
|
|
524
|
+
// "currency": "bch",
|
|
525
|
+
// "available": "0.00000000",
|
|
526
|
+
// "locked": "0.00000000",
|
|
527
|
+
// "total": "0.00000000",
|
|
528
|
+
// "pending_deposit": "0.00000000",
|
|
529
|
+
// "pending_withdrawal": "0.00000000"
|
|
530
|
+
// },
|
|
531
|
+
// ],
|
|
532
|
+
// },
|
|
533
|
+
// }
|
|
534
|
+
//
|
|
535
|
+
return this.parseBalance(response);
|
|
536
|
+
}
|
|
537
|
+
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
538
|
+
/**
|
|
539
|
+
* @method
|
|
540
|
+
* @name bitso#fetchOrderBook
|
|
541
|
+
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
542
|
+
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
543
|
+
* @param {int} [limit] the maximum amount of order book entries to return
|
|
544
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
545
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
546
|
+
*/
|
|
547
|
+
await this.loadMarkets();
|
|
548
|
+
const market = this.market(symbol);
|
|
549
|
+
const request = {
|
|
550
|
+
'book': market['id'],
|
|
551
|
+
};
|
|
552
|
+
const response = await this.publicGetOrderBook(this.extend(request, params));
|
|
553
|
+
const orderbook = this.safeValue(response, 'payload');
|
|
554
|
+
const timestamp = this.parse8601(this.safeString(orderbook, 'updated_at'));
|
|
555
|
+
return this.parseOrderBook(orderbook, market['symbol'], timestamp, 'bids', 'asks', 'price', 'amount');
|
|
556
|
+
}
|
|
557
|
+
parseTicker(ticker, market = undefined) {
|
|
558
|
+
//
|
|
559
|
+
// {
|
|
560
|
+
// "high":"37446.85",
|
|
561
|
+
// "last":"36599.54",
|
|
562
|
+
// "created_at":"2022-01-28T12:06:11+00:00",
|
|
563
|
+
// "book":"btc_usdt",
|
|
564
|
+
// "volume":"7.29075419",
|
|
565
|
+
// "vwap":"36579.1564400307",
|
|
566
|
+
// "low":"35578.52",
|
|
567
|
+
// "ask":"36574.76",
|
|
568
|
+
// "bid":"36538.22",
|
|
569
|
+
// "change_24":"-105.64"
|
|
570
|
+
// }
|
|
571
|
+
//
|
|
572
|
+
const symbol = this.safeSymbol(undefined, market);
|
|
573
|
+
const timestamp = this.parse8601(this.safeString(ticker, 'created_at'));
|
|
574
|
+
const vwap = this.safeString(ticker, 'vwap');
|
|
575
|
+
const baseVolume = this.safeString(ticker, 'volume');
|
|
576
|
+
const quoteVolume = Precise["default"].stringMul(baseVolume, vwap);
|
|
577
|
+
const last = this.safeString(ticker, 'last');
|
|
578
|
+
return this.safeTicker({
|
|
579
|
+
'symbol': symbol,
|
|
580
|
+
'timestamp': timestamp,
|
|
581
|
+
'datetime': this.iso8601(timestamp),
|
|
582
|
+
'high': this.safeString(ticker, 'high'),
|
|
583
|
+
'low': this.safeString(ticker, 'low'),
|
|
584
|
+
'bid': this.safeString(ticker, 'bid'),
|
|
585
|
+
'bidVolume': undefined,
|
|
586
|
+
'ask': this.safeString(ticker, 'ask'),
|
|
587
|
+
'askVolume': undefined,
|
|
588
|
+
'vwap': vwap,
|
|
589
|
+
'open': undefined,
|
|
590
|
+
'close': last,
|
|
591
|
+
'last': last,
|
|
592
|
+
'previousClose': undefined,
|
|
593
|
+
'change': undefined,
|
|
594
|
+
'percentage': undefined,
|
|
595
|
+
'average': undefined,
|
|
596
|
+
'baseVolume': baseVolume,
|
|
597
|
+
'quoteVolume': quoteVolume,
|
|
598
|
+
'info': ticker,
|
|
599
|
+
}, market);
|
|
600
|
+
}
|
|
601
|
+
async fetchTicker(symbol, params = {}) {
|
|
602
|
+
/**
|
|
603
|
+
* @method
|
|
604
|
+
* @name bitso#fetchTicker
|
|
605
|
+
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
606
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
607
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
608
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
609
|
+
*/
|
|
610
|
+
await this.loadMarkets();
|
|
611
|
+
const market = this.market(symbol);
|
|
612
|
+
const request = {
|
|
613
|
+
'book': market['id'],
|
|
614
|
+
};
|
|
615
|
+
const response = await this.publicGetTicker(this.extend(request, params));
|
|
616
|
+
const ticker = this.safeValue(response, 'payload');
|
|
617
|
+
//
|
|
618
|
+
// {
|
|
619
|
+
// "success":true,
|
|
620
|
+
// "payload":{
|
|
621
|
+
// "high":"37446.85",
|
|
622
|
+
// "last":"37051.96",
|
|
623
|
+
// "created_at":"2022-01-28T17:03:29+00:00",
|
|
624
|
+
// "book":"btc_usdt",
|
|
625
|
+
// "volume":"6.16176186",
|
|
626
|
+
// "vwap":"36582.6293169472",
|
|
627
|
+
// "low":"35578.52",
|
|
628
|
+
// "ask":"37083.62",
|
|
629
|
+
// "bid":"37039.66",
|
|
630
|
+
// "change_24":"478.45"
|
|
631
|
+
// }
|
|
632
|
+
// }
|
|
633
|
+
//
|
|
634
|
+
return this.parseTicker(ticker, market);
|
|
635
|
+
}
|
|
636
|
+
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
637
|
+
/**
|
|
638
|
+
* @method
|
|
639
|
+
* @name bitso#fetchOHLCV
|
|
640
|
+
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
641
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
642
|
+
* @param {string} timeframe the length of time each candle represents
|
|
643
|
+
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
644
|
+
* @param {int} [limit] the maximum amount of candles to fetch
|
|
645
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
646
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
647
|
+
*/
|
|
648
|
+
await this.loadMarkets();
|
|
649
|
+
const market = this.market(symbol);
|
|
650
|
+
const request = {
|
|
651
|
+
'book': market['id'],
|
|
652
|
+
'time_bucket': this.safeString(this.timeframes, timeframe, timeframe),
|
|
653
|
+
};
|
|
654
|
+
if (since !== undefined) {
|
|
655
|
+
request['start'] = since;
|
|
656
|
+
if (limit !== undefined) {
|
|
657
|
+
const duration = this.parseTimeframe(timeframe);
|
|
658
|
+
request['end'] = this.sum(since, duration * limit * 1000);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
else if (limit !== undefined) {
|
|
662
|
+
const now = this.milliseconds();
|
|
663
|
+
request['end'] = now;
|
|
664
|
+
request['start'] = now - this.parseTimeframe(timeframe) * 1000 * limit;
|
|
665
|
+
}
|
|
666
|
+
const response = await this.publicGetOhlc(this.extend(request, params));
|
|
667
|
+
//
|
|
668
|
+
// {
|
|
669
|
+
// "success":true,
|
|
670
|
+
// "payload": [
|
|
671
|
+
// {
|
|
672
|
+
// "bucket_start_time":1648219140000,
|
|
673
|
+
// "first_trade_time":1648219154990,
|
|
674
|
+
// "last_trade_time":1648219189441,
|
|
675
|
+
// "first_rate":"44958.60",
|
|
676
|
+
// "last_rate":"44979.88",
|
|
677
|
+
// "min_rate":"44957.33",
|
|
678
|
+
// "max_rate":"44979.88",
|
|
679
|
+
// "trade_count":8,
|
|
680
|
+
// "volume":"0.00082814",
|
|
681
|
+
// "vwap":"44965.02"
|
|
682
|
+
// },
|
|
683
|
+
// ]
|
|
684
|
+
// }
|
|
685
|
+
//
|
|
686
|
+
const payload = this.safeValue(response, 'payload', []);
|
|
687
|
+
return this.parseOHLCVs(payload, market, timeframe, since, limit);
|
|
688
|
+
}
|
|
689
|
+
parseOHLCV(ohlcv, market = undefined) {
|
|
690
|
+
//
|
|
691
|
+
// {
|
|
692
|
+
// "bucket_start_time":1648219140000,
|
|
693
|
+
// "first_trade_time":1648219154990,
|
|
694
|
+
// "last_trade_time":1648219189441,
|
|
695
|
+
// "first_rate":"44958.60",
|
|
696
|
+
// "last_rate":"44979.88",
|
|
697
|
+
// "min_rate":"44957.33",
|
|
698
|
+
// "max_rate":"44979.88",
|
|
699
|
+
// "trade_count":8,
|
|
700
|
+
// "volume":"0.00082814",
|
|
701
|
+
// "vwap":"44965.02"
|
|
702
|
+
// },
|
|
703
|
+
//
|
|
704
|
+
return [
|
|
705
|
+
this.safeInteger(ohlcv, 'bucket_start_time'),
|
|
706
|
+
this.safeNumber(ohlcv, 'first_rate'),
|
|
707
|
+
this.safeNumber(ohlcv, 'max_rate'),
|
|
708
|
+
this.safeNumber(ohlcv, 'min_rate'),
|
|
709
|
+
this.safeNumber(ohlcv, 'last_rate'),
|
|
710
|
+
this.safeNumber(ohlcv, 'volume'),
|
|
711
|
+
];
|
|
712
|
+
}
|
|
713
|
+
parseTrade(trade, market = undefined) {
|
|
714
|
+
//
|
|
715
|
+
// fetchTrades (public)
|
|
716
|
+
//
|
|
717
|
+
// {
|
|
718
|
+
// "book": "btc_usdt",
|
|
719
|
+
// "created_at": "2021-11-24T12:14:53+0000",
|
|
720
|
+
// "amount": "0.00026562",
|
|
721
|
+
// "maker_side": "sell",
|
|
722
|
+
// "price": "56471.55",
|
|
723
|
+
// "tid": "52557338"
|
|
724
|
+
// }
|
|
725
|
+
//
|
|
726
|
+
// fetchMyTrades (private)
|
|
727
|
+
//
|
|
728
|
+
// {
|
|
729
|
+
// "book": "btc_usdt",
|
|
730
|
+
// "created_at": "2021-11-24T12:31:03+0000",
|
|
731
|
+
// "minor": "11.30356000",
|
|
732
|
+
// "major": "-0.00020000",
|
|
733
|
+
// "fees_amount": "0.01119052",
|
|
734
|
+
// "fees_currency": "usdt",
|
|
735
|
+
// "minor_currency": "usdt",
|
|
736
|
+
// "major_currency": "btc",
|
|
737
|
+
// "oid": "djTzMIWx2Vi3iMjl",
|
|
738
|
+
// "tid": "52559051",
|
|
739
|
+
// "price": "56517.80",
|
|
740
|
+
// "side": "sell",
|
|
741
|
+
// "maker_side": "buy"
|
|
742
|
+
// }
|
|
743
|
+
//
|
|
744
|
+
// fetchOrderTrades (private)
|
|
745
|
+
//
|
|
746
|
+
// {
|
|
747
|
+
// "book": "btc_usdt",
|
|
748
|
+
// "created_at": "2021-11-24T12:30:52+0000",
|
|
749
|
+
// "minor": "-11.33047916",
|
|
750
|
+
// "major": "0.00020020",
|
|
751
|
+
// "fees_amount": "0.00000020",
|
|
752
|
+
// "fees_currency": "btc",
|
|
753
|
+
// "minor_currency": "usdt",
|
|
754
|
+
// "major_currency": "btc",
|
|
755
|
+
// "oid": "O0D2zcljjjQF5xlG",
|
|
756
|
+
// "tid": "52559030",
|
|
757
|
+
// "price": "56595.80",
|
|
758
|
+
// "side": "buy",
|
|
759
|
+
// "maker_side": "sell"
|
|
760
|
+
// }
|
|
761
|
+
//
|
|
762
|
+
const timestamp = this.parse8601(this.safeString(trade, 'created_at'));
|
|
763
|
+
const marketId = this.safeString(trade, 'book');
|
|
764
|
+
const symbol = this.safeSymbol(marketId, market, '_');
|
|
765
|
+
let side = this.safeString(trade, 'side');
|
|
766
|
+
const makerSide = this.safeString(trade, 'maker_side');
|
|
767
|
+
let takerOrMaker = undefined;
|
|
768
|
+
if (side !== undefined) {
|
|
769
|
+
if (side === makerSide) {
|
|
770
|
+
takerOrMaker = 'maker';
|
|
771
|
+
}
|
|
772
|
+
else {
|
|
773
|
+
takerOrMaker = 'taker';
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
else {
|
|
777
|
+
if (makerSide === 'buy') {
|
|
778
|
+
side = 'sell';
|
|
779
|
+
}
|
|
780
|
+
else {
|
|
781
|
+
side = 'buy';
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
let amount = this.safeString2(trade, 'amount', 'major');
|
|
785
|
+
if (amount !== undefined) {
|
|
786
|
+
amount = Precise["default"].stringAbs(amount);
|
|
787
|
+
}
|
|
788
|
+
let fee = undefined;
|
|
789
|
+
const feeCost = this.safeString(trade, 'fees_amount');
|
|
790
|
+
if (feeCost !== undefined) {
|
|
791
|
+
const feeCurrencyId = this.safeString(trade, 'fees_currency');
|
|
792
|
+
const feeCurrency = this.safeCurrencyCode(feeCurrencyId);
|
|
793
|
+
fee = {
|
|
794
|
+
'cost': feeCost,
|
|
795
|
+
'currency': feeCurrency,
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
let cost = this.safeString(trade, 'minor');
|
|
799
|
+
if (cost !== undefined) {
|
|
800
|
+
cost = Precise["default"].stringAbs(cost);
|
|
801
|
+
}
|
|
802
|
+
const price = this.safeString(trade, 'price');
|
|
803
|
+
const orderId = this.safeString(trade, 'oid');
|
|
804
|
+
const id = this.safeString(trade, 'tid');
|
|
805
|
+
return this.safeTrade({
|
|
806
|
+
'id': id,
|
|
807
|
+
'info': trade,
|
|
808
|
+
'timestamp': timestamp,
|
|
809
|
+
'datetime': this.iso8601(timestamp),
|
|
810
|
+
'symbol': symbol,
|
|
811
|
+
'order': orderId,
|
|
812
|
+
'type': undefined,
|
|
813
|
+
'side': side,
|
|
814
|
+
'takerOrMaker': takerOrMaker,
|
|
815
|
+
'price': price,
|
|
816
|
+
'amount': amount,
|
|
817
|
+
'cost': cost,
|
|
818
|
+
'fee': fee,
|
|
819
|
+
}, market);
|
|
820
|
+
}
|
|
821
|
+
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
822
|
+
/**
|
|
823
|
+
* @method
|
|
824
|
+
* @name bitso#fetchTrades
|
|
825
|
+
* @description get the list of most recent trades for a particular symbol
|
|
826
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
827
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
828
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
829
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
830
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
831
|
+
*/
|
|
832
|
+
await this.loadMarkets();
|
|
833
|
+
const market = this.market(symbol);
|
|
834
|
+
const request = {
|
|
835
|
+
'book': market['id'],
|
|
836
|
+
};
|
|
837
|
+
const response = await this.publicGetTrades(this.extend(request, params));
|
|
838
|
+
return this.parseTrades(response['payload'], market, since, limit);
|
|
839
|
+
}
|
|
840
|
+
async fetchTradingFees(params = {}) {
|
|
841
|
+
/**
|
|
842
|
+
* @method
|
|
843
|
+
* @name bitso#fetchTradingFees
|
|
844
|
+
* @description fetch the trading fees for multiple markets
|
|
845
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
846
|
+
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
|
|
847
|
+
*/
|
|
848
|
+
await this.loadMarkets();
|
|
849
|
+
const response = await this.privateGetFees(params);
|
|
850
|
+
//
|
|
851
|
+
// {
|
|
852
|
+
// "success": true,
|
|
853
|
+
// "payload": {
|
|
854
|
+
// "fees": [
|
|
855
|
+
// {
|
|
856
|
+
// "book": "btc_mxn",
|
|
857
|
+
// "fee_percent": "0.6500",
|
|
858
|
+
// "fee_decimal": "0.00650000",
|
|
859
|
+
// "taker_fee_percent": "0.6500",
|
|
860
|
+
// "taker_fee_decimal": "0.00650000",
|
|
861
|
+
// "maker_fee_percent": "0.5000",
|
|
862
|
+
// "maker_fee_decimal": "0.00500000",
|
|
863
|
+
// "volume_currency": "mxn",
|
|
864
|
+
// "current_volume": "0.00",
|
|
865
|
+
// "next_volume": "1500000.00",
|
|
866
|
+
// "next_maker_fee_percent": "0.490",
|
|
867
|
+
// "next_taker_fee_percent": "0.637",
|
|
868
|
+
// "nextVolume": "1500000.00",
|
|
869
|
+
// "nextFee": "0.490",
|
|
870
|
+
// "nextTakerFee": "0.637"
|
|
871
|
+
// },
|
|
872
|
+
// ...
|
|
873
|
+
// ],
|
|
874
|
+
// "deposit_fees": [
|
|
875
|
+
// {
|
|
876
|
+
// "currency": "btc",
|
|
877
|
+
// "method": "rewards",
|
|
878
|
+
// "fee": "0.00",
|
|
879
|
+
// "is_fixed": false
|
|
880
|
+
// },
|
|
881
|
+
// ...
|
|
882
|
+
// ],
|
|
883
|
+
// "withdrawal_fees": {
|
|
884
|
+
// "ada": "0.20958100",
|
|
885
|
+
// "bch": "0.00009437",
|
|
886
|
+
// "ars": "0",
|
|
887
|
+
// "btc": "0.00001209",
|
|
888
|
+
// ...
|
|
889
|
+
// }
|
|
890
|
+
// }
|
|
891
|
+
// }
|
|
892
|
+
//
|
|
893
|
+
const payload = this.safeValue(response, 'payload', {});
|
|
894
|
+
const fees = this.safeValue(payload, 'fees', []);
|
|
895
|
+
const result = {};
|
|
896
|
+
for (let i = 0; i < fees.length; i++) {
|
|
897
|
+
const fee = fees[i];
|
|
898
|
+
const marketId = this.safeString(fee, 'book');
|
|
899
|
+
const symbol = this.safeSymbol(marketId, undefined, '_');
|
|
900
|
+
result[symbol] = {
|
|
901
|
+
'info': fee,
|
|
902
|
+
'symbol': symbol,
|
|
903
|
+
'maker': this.safeNumber(fee, 'maker_fee_decimal'),
|
|
904
|
+
'taker': this.safeNumber(fee, 'taker_fee_decimal'),
|
|
905
|
+
'percentage': true,
|
|
906
|
+
'tierBased': true,
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
return result;
|
|
910
|
+
}
|
|
911
|
+
async fetchMyTrades(symbol = undefined, since = undefined, limit = 25, params = {}) {
|
|
912
|
+
/**
|
|
913
|
+
* @method
|
|
914
|
+
* @name bitso#fetchMyTrades
|
|
915
|
+
* @description fetch all trades made by the user
|
|
916
|
+
* @param {string} symbol unified market symbol
|
|
917
|
+
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
918
|
+
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
919
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
920
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
921
|
+
*/
|
|
922
|
+
await this.loadMarkets();
|
|
923
|
+
const market = this.market(symbol);
|
|
924
|
+
// the don't support fetching trades starting from a date yet
|
|
925
|
+
// use the `marker` extra param for that
|
|
926
|
+
// this is not a typo, the variable name is 'marker' (don't confuse with 'market')
|
|
927
|
+
const markerInParams = ('marker' in params);
|
|
928
|
+
// warn the user with an exception if the user wants to filter
|
|
929
|
+
// starting from since timestamp, but does not set the trade id with an extra 'marker' param
|
|
930
|
+
if ((since !== undefined) && !markerInParams) {
|
|
931
|
+
throw new errors.ExchangeError(this.id + ' fetchMyTrades() does not support fetching trades starting from a timestamp with the `since` argument, use the `marker` extra param to filter starting from an integer trade id');
|
|
932
|
+
}
|
|
933
|
+
// convert it to an integer unconditionally
|
|
934
|
+
if (markerInParams) {
|
|
935
|
+
params = this.extend(params, {
|
|
936
|
+
'marker': parseInt(params['marker']),
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
const request = {
|
|
940
|
+
'book': market['id'],
|
|
941
|
+
'limit': limit, // default = 25, max = 100
|
|
942
|
+
// 'sort': 'desc', // default = desc
|
|
943
|
+
// 'marker': id, // integer id to start from
|
|
944
|
+
};
|
|
945
|
+
const response = await this.privateGetUserTrades(this.extend(request, params));
|
|
946
|
+
return this.parseTrades(response['payload'], market, since, limit);
|
|
947
|
+
}
|
|
948
|
+
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
949
|
+
/**
|
|
950
|
+
* @method
|
|
951
|
+
* @name bitso#createOrder
|
|
952
|
+
* @description create a trade order
|
|
953
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
954
|
+
* @param {string} type 'market' or 'limit'
|
|
955
|
+
* @param {string} side 'buy' or 'sell'
|
|
956
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
957
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
958
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
959
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
960
|
+
*/
|
|
961
|
+
await this.loadMarkets();
|
|
962
|
+
const market = this.market(symbol);
|
|
963
|
+
const request = {
|
|
964
|
+
'book': market['id'],
|
|
965
|
+
'side': side,
|
|
966
|
+
'type': type,
|
|
967
|
+
'major': this.amountToPrecision(market['symbol'], amount),
|
|
968
|
+
};
|
|
969
|
+
if (type === 'limit') {
|
|
970
|
+
request['price'] = this.priceToPrecision(market['symbol'], price);
|
|
971
|
+
}
|
|
972
|
+
const response = await this.privatePostOrders(this.extend(request, params));
|
|
973
|
+
const id = this.safeString(response['payload'], 'oid');
|
|
974
|
+
return this.safeOrder({
|
|
975
|
+
'info': response,
|
|
976
|
+
'id': id,
|
|
977
|
+
}, market);
|
|
978
|
+
}
|
|
979
|
+
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
980
|
+
/**
|
|
981
|
+
* @method
|
|
982
|
+
* @name bitso#cancelOrder
|
|
983
|
+
* @description cancels an open order
|
|
984
|
+
* @param {string} id order id
|
|
985
|
+
* @param {string} symbol not used by bitso cancelOrder ()
|
|
986
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
987
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
988
|
+
*/
|
|
989
|
+
await this.loadMarkets();
|
|
990
|
+
const request = {
|
|
991
|
+
'oid': id,
|
|
992
|
+
};
|
|
993
|
+
return await this.privateDeleteOrdersOid(this.extend(request, params));
|
|
994
|
+
}
|
|
995
|
+
async cancelOrders(ids, symbol = undefined, params = {}) {
|
|
996
|
+
/**
|
|
997
|
+
* @method
|
|
998
|
+
* @name bitso#cancelOrders
|
|
999
|
+
* @description cancel multiple orders
|
|
1000
|
+
* @param {string[]} ids order ids
|
|
1001
|
+
* @param {string} symbol unified market symbol
|
|
1002
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1003
|
+
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1004
|
+
*/
|
|
1005
|
+
if (!Array.isArray(ids)) {
|
|
1006
|
+
throw new errors.ArgumentsRequired(this.id + ' cancelOrders() ids argument should be an array');
|
|
1007
|
+
}
|
|
1008
|
+
let market = undefined;
|
|
1009
|
+
if (symbol !== undefined) {
|
|
1010
|
+
market = this.market(symbol);
|
|
1011
|
+
}
|
|
1012
|
+
const oids = ids.join(',');
|
|
1013
|
+
const request = {
|
|
1014
|
+
'oids': oids,
|
|
1015
|
+
};
|
|
1016
|
+
const response = await this.privateDeleteOrders(this.extend(request, params));
|
|
1017
|
+
//
|
|
1018
|
+
// {
|
|
1019
|
+
// "success": true,
|
|
1020
|
+
// "payload": ["yWTQGxDMZ0VimZgZ"]
|
|
1021
|
+
// }
|
|
1022
|
+
//
|
|
1023
|
+
const payload = this.safeValue(response, 'payload', []);
|
|
1024
|
+
const orders = [];
|
|
1025
|
+
for (let i = 0; i < payload.length; i++) {
|
|
1026
|
+
const id = payload[i];
|
|
1027
|
+
orders.push(this.parseOrder(id, market));
|
|
1028
|
+
}
|
|
1029
|
+
return orders;
|
|
1030
|
+
}
|
|
1031
|
+
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
1032
|
+
/**
|
|
1033
|
+
* @method
|
|
1034
|
+
* @name bitso#cancelAllOrders
|
|
1035
|
+
* @description cancel all open orders
|
|
1036
|
+
* @param {undefined} symbol bitso does not support canceling orders for only a specific market
|
|
1037
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1038
|
+
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1039
|
+
*/
|
|
1040
|
+
if (symbol !== undefined) {
|
|
1041
|
+
throw new errors.NotSupported(this.id + ' cancelAllOrders() deletes all orders for user, it does not support filtering by symbol.');
|
|
1042
|
+
}
|
|
1043
|
+
const response = await this.privateDeleteOrdersAll(params);
|
|
1044
|
+
//
|
|
1045
|
+
// {
|
|
1046
|
+
// "success": true,
|
|
1047
|
+
// "payload": ["NWUZUYNT12ljwzDT", "kZUkZmQ2TTjkkYTY"]
|
|
1048
|
+
// }
|
|
1049
|
+
//
|
|
1050
|
+
const payload = this.safeValue(response, 'payload', []);
|
|
1051
|
+
const canceledOrders = [];
|
|
1052
|
+
for (let i = 0; i < payload.length; i++) {
|
|
1053
|
+
const order = this.parseOrder(payload[i]);
|
|
1054
|
+
canceledOrders.push(order);
|
|
1055
|
+
}
|
|
1056
|
+
return canceledOrders;
|
|
1057
|
+
}
|
|
1058
|
+
parseOrderStatus(status) {
|
|
1059
|
+
const statuses = {
|
|
1060
|
+
'partial-fill': 'open',
|
|
1061
|
+
'partially filled': 'open',
|
|
1062
|
+
'queued': 'open',
|
|
1063
|
+
'completed': 'closed',
|
|
1064
|
+
};
|
|
1065
|
+
return this.safeString(statuses, status, status);
|
|
1066
|
+
}
|
|
1067
|
+
parseOrder(order, market = undefined) {
|
|
1068
|
+
//
|
|
1069
|
+
//
|
|
1070
|
+
// canceledOrder
|
|
1071
|
+
// yWTQGxDMZ0VimZgZ
|
|
1072
|
+
//
|
|
1073
|
+
let id = undefined;
|
|
1074
|
+
if (typeof order === 'string') {
|
|
1075
|
+
id = order;
|
|
1076
|
+
}
|
|
1077
|
+
else {
|
|
1078
|
+
id = this.safeString(order, 'oid');
|
|
1079
|
+
}
|
|
1080
|
+
const side = this.safeString(order, 'side');
|
|
1081
|
+
const status = this.parseOrderStatus(this.safeString(order, 'status'));
|
|
1082
|
+
const marketId = this.safeString(order, 'book');
|
|
1083
|
+
const symbol = this.safeSymbol(marketId, market, '_');
|
|
1084
|
+
const orderType = this.safeString(order, 'type');
|
|
1085
|
+
const timestamp = this.parse8601(this.safeString(order, 'created_at'));
|
|
1086
|
+
const price = this.safeString(order, 'price');
|
|
1087
|
+
const amount = this.safeString(order, 'original_amount');
|
|
1088
|
+
const remaining = this.safeString(order, 'unfilled_amount');
|
|
1089
|
+
const clientOrderId = this.safeString(order, 'client_id');
|
|
1090
|
+
return this.safeOrder({
|
|
1091
|
+
'info': order,
|
|
1092
|
+
'id': id,
|
|
1093
|
+
'clientOrderId': clientOrderId,
|
|
1094
|
+
'timestamp': timestamp,
|
|
1095
|
+
'datetime': this.iso8601(timestamp),
|
|
1096
|
+
'lastTradeTimestamp': undefined,
|
|
1097
|
+
'symbol': symbol,
|
|
1098
|
+
'type': orderType,
|
|
1099
|
+
'timeInForce': undefined,
|
|
1100
|
+
'postOnly': undefined,
|
|
1101
|
+
'side': side,
|
|
1102
|
+
'price': price,
|
|
1103
|
+
'stopPrice': undefined,
|
|
1104
|
+
'triggerPrice': undefined,
|
|
1105
|
+
'amount': amount,
|
|
1106
|
+
'cost': undefined,
|
|
1107
|
+
'remaining': remaining,
|
|
1108
|
+
'filled': undefined,
|
|
1109
|
+
'status': status,
|
|
1110
|
+
'fee': undefined,
|
|
1111
|
+
'average': undefined,
|
|
1112
|
+
'trades': undefined,
|
|
1113
|
+
}, market);
|
|
1114
|
+
}
|
|
1115
|
+
async fetchOpenOrders(symbol = undefined, since = undefined, limit = 25, params = {}) {
|
|
1116
|
+
/**
|
|
1117
|
+
* @method
|
|
1118
|
+
* @name bitso#fetchOpenOrders
|
|
1119
|
+
* @description fetch all unfilled currently open orders
|
|
1120
|
+
* @param {string} symbol unified market symbol
|
|
1121
|
+
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
1122
|
+
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
1123
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1124
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1125
|
+
*/
|
|
1126
|
+
await this.loadMarkets();
|
|
1127
|
+
const market = this.market(symbol);
|
|
1128
|
+
// the don't support fetching trades starting from a date yet
|
|
1129
|
+
// use the `marker` extra param for that
|
|
1130
|
+
// this is not a typo, the variable name is 'marker' (don't confuse with 'market')
|
|
1131
|
+
const markerInParams = ('marker' in params);
|
|
1132
|
+
// warn the user with an exception if the user wants to filter
|
|
1133
|
+
// starting from since timestamp, but does not set the trade id with an extra 'marker' param
|
|
1134
|
+
if ((since !== undefined) && !markerInParams) {
|
|
1135
|
+
throw new errors.ExchangeError(this.id + ' fetchOpenOrders() does not support fetching orders starting from a timestamp with the `since` argument, use the `marker` extra param to filter starting from an integer trade id');
|
|
1136
|
+
}
|
|
1137
|
+
// convert it to an integer unconditionally
|
|
1138
|
+
if (markerInParams) {
|
|
1139
|
+
params = this.extend(params, {
|
|
1140
|
+
'marker': parseInt(params['marker']),
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
const request = {
|
|
1144
|
+
'book': market['id'],
|
|
1145
|
+
'limit': limit, // default = 25, max = 100
|
|
1146
|
+
// 'sort': 'desc', // default = desc
|
|
1147
|
+
// 'marker': id, // integer id to start from
|
|
1148
|
+
};
|
|
1149
|
+
const response = await this.privateGetOpenOrders(this.extend(request, params));
|
|
1150
|
+
const orders = this.parseOrders(response['payload'], market, since, limit);
|
|
1151
|
+
return orders;
|
|
1152
|
+
}
|
|
1153
|
+
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
1154
|
+
/**
|
|
1155
|
+
* @method
|
|
1156
|
+
* @name bitso#fetchOrder
|
|
1157
|
+
* @description fetches information on an order made by the user
|
|
1158
|
+
* @param {string} symbol not used by bitso fetchOrder
|
|
1159
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1160
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1161
|
+
*/
|
|
1162
|
+
await this.loadMarkets();
|
|
1163
|
+
const response = await this.privateGetOrdersOid({
|
|
1164
|
+
'oid': id,
|
|
1165
|
+
});
|
|
1166
|
+
const payload = this.safeValue(response, 'payload');
|
|
1167
|
+
if (Array.isArray(payload)) {
|
|
1168
|
+
const numOrders = response['payload'].length;
|
|
1169
|
+
if (numOrders === 1) {
|
|
1170
|
+
return this.parseOrder(payload[0]);
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
throw new errors.OrderNotFound(this.id + ': The order ' + id + ' not found.');
|
|
1174
|
+
}
|
|
1175
|
+
async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1176
|
+
/**
|
|
1177
|
+
* @method
|
|
1178
|
+
* @name bitso#fetchOrderTrades
|
|
1179
|
+
* @description fetch all the trades made from a single order
|
|
1180
|
+
* @param {string} id order id
|
|
1181
|
+
* @param {string} symbol unified market symbol
|
|
1182
|
+
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
1183
|
+
* @param {int} [limit] the maximum number of trades to retrieve
|
|
1184
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1185
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
1186
|
+
*/
|
|
1187
|
+
await this.loadMarkets();
|
|
1188
|
+
const market = this.market(symbol);
|
|
1189
|
+
const request = {
|
|
1190
|
+
'oid': id,
|
|
1191
|
+
};
|
|
1192
|
+
const response = await this.privateGetOrderTradesOid(this.extend(request, params));
|
|
1193
|
+
return this.parseTrades(response['payload'], market);
|
|
1194
|
+
}
|
|
1195
|
+
async fetchDeposit(id, code = undefined, params = {}) {
|
|
1196
|
+
/**
|
|
1197
|
+
* @method
|
|
1198
|
+
* @name bitso#fetchDeposit
|
|
1199
|
+
* @description fetch information on a deposit
|
|
1200
|
+
* @param {string} id deposit id
|
|
1201
|
+
* @param {string} code bitso does not support filtering by currency code and will ignore this argument
|
|
1202
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1203
|
+
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1204
|
+
*/
|
|
1205
|
+
await this.loadMarkets();
|
|
1206
|
+
const request = {
|
|
1207
|
+
'fid': id,
|
|
1208
|
+
};
|
|
1209
|
+
const response = await this.privateGetFundingsFid(this.extend(request, params));
|
|
1210
|
+
//
|
|
1211
|
+
// {
|
|
1212
|
+
// "success": true,
|
|
1213
|
+
// "payload": [{
|
|
1214
|
+
// "fid": "6112c6369100d6ecceb7f54f17cf0511",
|
|
1215
|
+
// "status": "complete",
|
|
1216
|
+
// "created_at": "2022-06-08T12:02:49+0000",
|
|
1217
|
+
// "currency": "btc",
|
|
1218
|
+
// "method": "btc",
|
|
1219
|
+
// "method_name": "Bitcoin",
|
|
1220
|
+
// "amount": "0.00080000",
|
|
1221
|
+
// "asset": "btc",
|
|
1222
|
+
// "network": "btc",
|
|
1223
|
+
// "protocol": "btc",
|
|
1224
|
+
// "integration": "bitgo-v2",
|
|
1225
|
+
// "details": {
|
|
1226
|
+
// "receiving_address": "3N2vbcYKhogs6RoTb4eYCUJ3beRSqLgSif",
|
|
1227
|
+
// "tx_hash": "327f3838531f211485ec59f9d0a119fea1595591e274d942b2c10b9b8262eb1d",
|
|
1228
|
+
// "confirmations": "4"
|
|
1229
|
+
// }
|
|
1230
|
+
// }]
|
|
1231
|
+
// }
|
|
1232
|
+
//
|
|
1233
|
+
const transactions = this.safeValue(response, 'payload', []);
|
|
1234
|
+
const first = this.safeValue(transactions, 0, {});
|
|
1235
|
+
return this.parseTransaction(first);
|
|
1236
|
+
}
|
|
1237
|
+
async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1238
|
+
/**
|
|
1239
|
+
* @method
|
|
1240
|
+
* @name bitso#fetchDeposits
|
|
1241
|
+
* @description fetch all deposits made to an account
|
|
1242
|
+
* @param {string} code unified currency code
|
|
1243
|
+
* @param {int} [since] the earliest time in ms to fetch deposits for
|
|
1244
|
+
* @param {int} [limit] the maximum number of deposits structures to retrieve
|
|
1245
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1246
|
+
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1247
|
+
*/
|
|
1248
|
+
await this.loadMarkets();
|
|
1249
|
+
let currency = undefined;
|
|
1250
|
+
if (code !== undefined) {
|
|
1251
|
+
currency = this.currency(code);
|
|
1252
|
+
}
|
|
1253
|
+
const response = await this.privateGetFundings(params);
|
|
1254
|
+
//
|
|
1255
|
+
// {
|
|
1256
|
+
// "success": true,
|
|
1257
|
+
// "payload": [{
|
|
1258
|
+
// "fid": "6112c6369100d6ecceb7f54f17cf0511",
|
|
1259
|
+
// "status": "complete",
|
|
1260
|
+
// "created_at": "2022-06-08T12:02:49+0000",
|
|
1261
|
+
// "currency": "btc",
|
|
1262
|
+
// "method": "btc",
|
|
1263
|
+
// "method_name": "Bitcoin",
|
|
1264
|
+
// "amount": "0.00080000",
|
|
1265
|
+
// "asset": "btc",
|
|
1266
|
+
// "network": "btc",
|
|
1267
|
+
// "protocol": "btc",
|
|
1268
|
+
// "integration": "bitgo-v2",
|
|
1269
|
+
// "details": {
|
|
1270
|
+
// "receiving_address": "3N2vbcYKhogs6RoTb4eYCUJ3beRSqLgSif",
|
|
1271
|
+
// "tx_hash": "327f3838531f211485ec59f9d0a119fea1595591e274d942b2c10b9b8262eb1d",
|
|
1272
|
+
// "confirmations": "4"
|
|
1273
|
+
// }
|
|
1274
|
+
// }]
|
|
1275
|
+
// }
|
|
1276
|
+
//
|
|
1277
|
+
const transactions = this.safeValue(response, 'payload', []);
|
|
1278
|
+
return this.parseTransactions(transactions, currency, since, limit, params);
|
|
1279
|
+
}
|
|
1280
|
+
async fetchDepositAddress(code, params = {}) {
|
|
1281
|
+
/**
|
|
1282
|
+
* @method
|
|
1283
|
+
* @name bitso#fetchDepositAddress
|
|
1284
|
+
* @description fetch the deposit address for a currency associated with this account
|
|
1285
|
+
* @param {string} code unified currency code
|
|
1286
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1287
|
+
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
1288
|
+
*/
|
|
1289
|
+
await this.loadMarkets();
|
|
1290
|
+
const currency = this.currency(code);
|
|
1291
|
+
const request = {
|
|
1292
|
+
'fund_currency': currency['id'],
|
|
1293
|
+
};
|
|
1294
|
+
const response = await this.privateGetFundingDestination(this.extend(request, params));
|
|
1295
|
+
let address = this.safeString(response['payload'], 'account_identifier');
|
|
1296
|
+
let tag = undefined;
|
|
1297
|
+
if (address.indexOf('?dt=') >= 0) {
|
|
1298
|
+
const parts = address.split('?dt=');
|
|
1299
|
+
address = this.safeString(parts, 0);
|
|
1300
|
+
tag = this.safeString(parts, 1);
|
|
1301
|
+
}
|
|
1302
|
+
this.checkAddress(address);
|
|
1303
|
+
return {
|
|
1304
|
+
'currency': code,
|
|
1305
|
+
'address': address,
|
|
1306
|
+
'tag': tag,
|
|
1307
|
+
'network': undefined,
|
|
1308
|
+
'info': response,
|
|
1309
|
+
};
|
|
1310
|
+
}
|
|
1311
|
+
async fetchTransactionFees(codes = undefined, params = {}) {
|
|
1312
|
+
/**
|
|
1313
|
+
* @method
|
|
1314
|
+
* @name bitso#fetchTransactionFees
|
|
1315
|
+
* @deprecated
|
|
1316
|
+
* @description please use fetchDepositWithdrawFees instead
|
|
1317
|
+
* @see https://bitso.com/api_info#fees
|
|
1318
|
+
* @param {string[]|undefined} codes list of unified currency codes
|
|
1319
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1320
|
+
* @returns {object[]} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
1321
|
+
*/
|
|
1322
|
+
await this.loadMarkets();
|
|
1323
|
+
const response = await this.privateGetFees(params);
|
|
1324
|
+
//
|
|
1325
|
+
// {
|
|
1326
|
+
// "success": true,
|
|
1327
|
+
// "payload": {
|
|
1328
|
+
// "fees": [
|
|
1329
|
+
// {
|
|
1330
|
+
// "book": "btc_mxn",
|
|
1331
|
+
// "fee_percent": "0.6500",
|
|
1332
|
+
// "fee_decimal": "0.00650000",
|
|
1333
|
+
// "taker_fee_percent": "0.6500",
|
|
1334
|
+
// "taker_fee_decimal": "0.00650000",
|
|
1335
|
+
// "maker_fee_percent": "0.5000",
|
|
1336
|
+
// "maker_fee_decimal": "0.00500000",
|
|
1337
|
+
// "volume_currency": "mxn",
|
|
1338
|
+
// "current_volume": "0.00",
|
|
1339
|
+
// "next_volume": "1500000.00",
|
|
1340
|
+
// "next_maker_fee_percent": "0.490",
|
|
1341
|
+
// "next_taker_fee_percent": "0.637",
|
|
1342
|
+
// "nextVolume": "1500000.00",
|
|
1343
|
+
// "nextFee": "0.490",
|
|
1344
|
+
// "nextTakerFee": "0.637"
|
|
1345
|
+
// },
|
|
1346
|
+
// ...
|
|
1347
|
+
// ],
|
|
1348
|
+
// "deposit_fees": [
|
|
1349
|
+
// {
|
|
1350
|
+
// "currency": "btc",
|
|
1351
|
+
// "method": "rewards",
|
|
1352
|
+
// "fee": "0.00",
|
|
1353
|
+
// "is_fixed": false
|
|
1354
|
+
// },
|
|
1355
|
+
// ...
|
|
1356
|
+
// ],
|
|
1357
|
+
// "withdrawal_fees": {
|
|
1358
|
+
// "ada": "0.20958100",
|
|
1359
|
+
// "bch": "0.00009437",
|
|
1360
|
+
// "ars": "0",
|
|
1361
|
+
// "btc": "0.00001209",
|
|
1362
|
+
// ...
|
|
1363
|
+
// }
|
|
1364
|
+
// }
|
|
1365
|
+
// }
|
|
1366
|
+
//
|
|
1367
|
+
const result = {};
|
|
1368
|
+
const payload = this.safeValue(response, 'payload', {});
|
|
1369
|
+
const depositFees = this.safeValue(payload, 'deposit_fees', []);
|
|
1370
|
+
for (let i = 0; i < depositFees.length; i++) {
|
|
1371
|
+
const depositFee = depositFees[i];
|
|
1372
|
+
const currencyId = this.safeString(depositFee, 'currency');
|
|
1373
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
1374
|
+
if ((codes !== undefined) && !this.inArray(code, codes)) {
|
|
1375
|
+
continue;
|
|
1376
|
+
}
|
|
1377
|
+
result[code] = {
|
|
1378
|
+
'deposit': this.safeNumber(depositFee, 'fee'),
|
|
1379
|
+
'withdraw': undefined,
|
|
1380
|
+
'info': {
|
|
1381
|
+
'deposit': depositFee,
|
|
1382
|
+
'withdraw': undefined,
|
|
1383
|
+
},
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
const withdrawalFees = this.safeValue(payload, 'withdrawal_fees', []);
|
|
1387
|
+
const currencyIds = Object.keys(withdrawalFees);
|
|
1388
|
+
for (let i = 0; i < currencyIds.length; i++) {
|
|
1389
|
+
const currencyId = currencyIds[i];
|
|
1390
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
1391
|
+
if ((codes !== undefined) && !this.inArray(code, codes)) {
|
|
1392
|
+
continue;
|
|
1393
|
+
}
|
|
1394
|
+
result[code] = {
|
|
1395
|
+
'deposit': this.safeValue(result[code], 'deposit'),
|
|
1396
|
+
'withdraw': this.safeNumber(withdrawalFees, currencyId),
|
|
1397
|
+
'info': {
|
|
1398
|
+
'deposit': this.safeValue(result[code]['info'], 'deposit'),
|
|
1399
|
+
'withdraw': this.safeNumber(withdrawalFees, currencyId),
|
|
1400
|
+
},
|
|
1401
|
+
};
|
|
1402
|
+
}
|
|
1403
|
+
return result;
|
|
1404
|
+
}
|
|
1405
|
+
async fetchDepositWithdrawFees(codes = undefined, params = {}) {
|
|
1406
|
+
/**
|
|
1407
|
+
* @method
|
|
1408
|
+
* @name bitso#fetchDepositWithdrawFees
|
|
1409
|
+
* @description fetch deposit and withdraw fees
|
|
1410
|
+
* @see https://bitso.com/api_info#fees
|
|
1411
|
+
* @param {string[]|undefined} codes list of unified currency codes
|
|
1412
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1413
|
+
* @returns {object[]} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
1414
|
+
*/
|
|
1415
|
+
await this.loadMarkets();
|
|
1416
|
+
const response = await this.privateGetFees(params);
|
|
1417
|
+
//
|
|
1418
|
+
// {
|
|
1419
|
+
// "success": true,
|
|
1420
|
+
// "payload": {
|
|
1421
|
+
// "fees": [
|
|
1422
|
+
// {
|
|
1423
|
+
// "book": "btc_mxn",
|
|
1424
|
+
// "fee_percent": "0.6500",
|
|
1425
|
+
// "fee_decimal": "0.00650000",
|
|
1426
|
+
// "taker_fee_percent": "0.6500",
|
|
1427
|
+
// "taker_fee_decimal": "0.00650000",
|
|
1428
|
+
// "maker_fee_percent": "0.5000",
|
|
1429
|
+
// "maker_fee_decimal": "0.00500000",
|
|
1430
|
+
// "volume_currency": "mxn",
|
|
1431
|
+
// "current_volume": "0.00",
|
|
1432
|
+
// "next_volume": "1500000.00",
|
|
1433
|
+
// "next_maker_fee_percent": "0.490",
|
|
1434
|
+
// "next_taker_fee_percent": "0.637",
|
|
1435
|
+
// "nextVolume": "1500000.00",
|
|
1436
|
+
// "nextFee": "0.490",
|
|
1437
|
+
// "nextTakerFee": "0.637"
|
|
1438
|
+
// },
|
|
1439
|
+
// ...
|
|
1440
|
+
// ],
|
|
1441
|
+
// "deposit_fees": [
|
|
1442
|
+
// {
|
|
1443
|
+
// "currency": "btc",
|
|
1444
|
+
// "method": "rewards",
|
|
1445
|
+
// "fee": "0.00",
|
|
1446
|
+
// "is_fixed": false
|
|
1447
|
+
// },
|
|
1448
|
+
// ...
|
|
1449
|
+
// ],
|
|
1450
|
+
// "withdrawal_fees": {
|
|
1451
|
+
// "ada": "0.20958100",
|
|
1452
|
+
// "bch": "0.00009437",
|
|
1453
|
+
// "ars": "0",
|
|
1454
|
+
// "btc": "0.00001209",
|
|
1455
|
+
// ...
|
|
1456
|
+
// }
|
|
1457
|
+
// }
|
|
1458
|
+
// }
|
|
1459
|
+
//
|
|
1460
|
+
const payload = this.safeValue(response, 'payload', {});
|
|
1461
|
+
return this.parseDepositWithdrawFees(payload, codes);
|
|
1462
|
+
}
|
|
1463
|
+
parseDepositWithdrawFees(response, codes = undefined, currencyIdKey = undefined) {
|
|
1464
|
+
//
|
|
1465
|
+
// {
|
|
1466
|
+
// "fees": [
|
|
1467
|
+
// {
|
|
1468
|
+
// "book": "btc_mxn",
|
|
1469
|
+
// "fee_percent": "0.6500",
|
|
1470
|
+
// "fee_decimal": "0.00650000",
|
|
1471
|
+
// "taker_fee_percent": "0.6500",
|
|
1472
|
+
// "taker_fee_decimal": "0.00650000",
|
|
1473
|
+
// "maker_fee_percent": "0.5000",
|
|
1474
|
+
// "maker_fee_decimal": "0.00500000",
|
|
1475
|
+
// "volume_currency": "mxn",
|
|
1476
|
+
// "current_volume": "0.00",
|
|
1477
|
+
// "next_volume": "1500000.00",
|
|
1478
|
+
// "next_maker_fee_percent": "0.490",
|
|
1479
|
+
// "next_taker_fee_percent": "0.637",
|
|
1480
|
+
// "nextVolume": "1500000.00",
|
|
1481
|
+
// "nextFee": "0.490",
|
|
1482
|
+
// "nextTakerFee": "0.637"
|
|
1483
|
+
// },
|
|
1484
|
+
// ...
|
|
1485
|
+
// ],
|
|
1486
|
+
// "deposit_fees": [
|
|
1487
|
+
// {
|
|
1488
|
+
// "currency": "btc",
|
|
1489
|
+
// "method": "rewards",
|
|
1490
|
+
// "fee": "0.00",
|
|
1491
|
+
// "is_fixed": false
|
|
1492
|
+
// },
|
|
1493
|
+
// ...
|
|
1494
|
+
// ],
|
|
1495
|
+
// "withdrawal_fees": {
|
|
1496
|
+
// "ada": "0.20958100",
|
|
1497
|
+
// "bch": "0.00009437",
|
|
1498
|
+
// "ars": "0",
|
|
1499
|
+
// "btc": "0.00001209",
|
|
1500
|
+
// ...
|
|
1501
|
+
// }
|
|
1502
|
+
// }
|
|
1503
|
+
//
|
|
1504
|
+
const result = {};
|
|
1505
|
+
const depositResponse = this.safeValue(response, 'deposit_fees', []);
|
|
1506
|
+
const withdrawalResponse = this.safeValue(response, 'withdrawal_fees', []);
|
|
1507
|
+
for (let i = 0; i < depositResponse.length; i++) {
|
|
1508
|
+
const entry = depositResponse[i];
|
|
1509
|
+
const currencyId = this.safeString(entry, 'currency');
|
|
1510
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
1511
|
+
if ((codes === undefined) || (code in codes)) {
|
|
1512
|
+
result[code] = {
|
|
1513
|
+
'deposit': {
|
|
1514
|
+
'fee': this.safeNumber(entry, 'fee'),
|
|
1515
|
+
'percentage': !this.safeValue(entry, 'is_fixed'),
|
|
1516
|
+
},
|
|
1517
|
+
'withdraw': {
|
|
1518
|
+
'fee': undefined,
|
|
1519
|
+
'percentage': undefined,
|
|
1520
|
+
},
|
|
1521
|
+
'networks': {},
|
|
1522
|
+
'info': entry,
|
|
1523
|
+
};
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
const withdrawalKeys = Object.keys(withdrawalResponse);
|
|
1527
|
+
for (let i = 0; i < withdrawalKeys.length; i++) {
|
|
1528
|
+
const currencyId = withdrawalKeys[i];
|
|
1529
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
1530
|
+
if ((codes === undefined) || (code in codes)) {
|
|
1531
|
+
const withdrawFee = this.parseNumber(withdrawalResponse[currencyId]);
|
|
1532
|
+
const resultValue = this.safeValue(result, code);
|
|
1533
|
+
if (resultValue === undefined) {
|
|
1534
|
+
result[code] = this.depositWithdrawFee({});
|
|
1535
|
+
}
|
|
1536
|
+
result[code]['withdraw']['fee'] = withdrawFee;
|
|
1537
|
+
result[code]['info'][code] = withdrawFee;
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
return result;
|
|
1541
|
+
}
|
|
1542
|
+
async withdraw(code, amount, address, tag = undefined, params = {}) {
|
|
1543
|
+
/**
|
|
1544
|
+
* @method
|
|
1545
|
+
* @name bitso#withdraw
|
|
1546
|
+
* @description make a withdrawal
|
|
1547
|
+
* @param {string} code unified currency code
|
|
1548
|
+
* @param {float} amount the amount to withdraw
|
|
1549
|
+
* @param {string} address the address to withdraw to
|
|
1550
|
+
* @param {string} tag
|
|
1551
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1552
|
+
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1553
|
+
*/
|
|
1554
|
+
[tag, params] = this.handleWithdrawTagAndParams(tag, params);
|
|
1555
|
+
this.checkAddress(address);
|
|
1556
|
+
await this.loadMarkets();
|
|
1557
|
+
const methods = {
|
|
1558
|
+
'BTC': 'Bitcoin',
|
|
1559
|
+
'ETH': 'Ether',
|
|
1560
|
+
'XRP': 'Ripple',
|
|
1561
|
+
'BCH': 'Bcash',
|
|
1562
|
+
'LTC': 'Litecoin',
|
|
1563
|
+
};
|
|
1564
|
+
const currency = this.currency(code);
|
|
1565
|
+
const method = (code in methods) ? methods[code] : undefined;
|
|
1566
|
+
if (method === undefined) {
|
|
1567
|
+
throw new errors.ExchangeError(this.id + ' not valid withdraw coin: ' + code);
|
|
1568
|
+
}
|
|
1569
|
+
const request = {
|
|
1570
|
+
'amount': amount,
|
|
1571
|
+
'address': address,
|
|
1572
|
+
'destination_tag': tag,
|
|
1573
|
+
};
|
|
1574
|
+
const classMethod = 'privatePost' + method + 'Withdrawal';
|
|
1575
|
+
const response = await this[classMethod](this.extend(request, params));
|
|
1576
|
+
//
|
|
1577
|
+
// {
|
|
1578
|
+
// "success": true,
|
|
1579
|
+
// "payload": [
|
|
1580
|
+
// {
|
|
1581
|
+
// "wid": "c5b8d7f0768ee91d3b33bee648318688",
|
|
1582
|
+
// "status": "pending",
|
|
1583
|
+
// "created_at": "2016-04-08T17:52:31.000+00:00",
|
|
1584
|
+
// "currency": "btc",
|
|
1585
|
+
// "method": "Bitcoin",
|
|
1586
|
+
// "amount": "0.48650929",
|
|
1587
|
+
// "details": {
|
|
1588
|
+
// "withdrawal_address": "18MsnATiNiKLqUHDTRKjurwMg7inCrdNEp",
|
|
1589
|
+
// "tx_hash": "d4f28394693e9fb5fffcaf730c11f32d1922e5837f76ca82189d3bfe30ded433"
|
|
1590
|
+
// }
|
|
1591
|
+
// },
|
|
1592
|
+
// ]
|
|
1593
|
+
// }
|
|
1594
|
+
//
|
|
1595
|
+
const payload = this.safeValue(response, 'payload', []);
|
|
1596
|
+
const first = this.safeValue(payload, 0);
|
|
1597
|
+
return this.parseTransaction(first, currency);
|
|
1598
|
+
}
|
|
1599
|
+
safeNetwork(networkId) {
|
|
1600
|
+
if (networkId === undefined) {
|
|
1601
|
+
return undefined;
|
|
1602
|
+
}
|
|
1603
|
+
networkId = networkId.toUpperCase();
|
|
1604
|
+
const networksById = {
|
|
1605
|
+
'trx': 'TRC20',
|
|
1606
|
+
'erc20': 'ERC20',
|
|
1607
|
+
'bsc': 'BEP20',
|
|
1608
|
+
'bep2': 'BEP2',
|
|
1609
|
+
};
|
|
1610
|
+
return this.safeString(networksById, networkId, networkId);
|
|
1611
|
+
}
|
|
1612
|
+
parseTransaction(transaction, currency = undefined) {
|
|
1613
|
+
//
|
|
1614
|
+
// deposit
|
|
1615
|
+
// {
|
|
1616
|
+
// "fid": "6112c6369100d6ecceb7f54f17cf0511",
|
|
1617
|
+
// "status": "complete",
|
|
1618
|
+
// "created_at": "2022-06-08T12:02:49+0000",
|
|
1619
|
+
// "currency": "btc",
|
|
1620
|
+
// "method": "btc",
|
|
1621
|
+
// "method_name": "Bitcoin",
|
|
1622
|
+
// "amount": "0.00080000",
|
|
1623
|
+
// "asset": "btc",
|
|
1624
|
+
// "network": "btc",
|
|
1625
|
+
// "protocol": "btc",
|
|
1626
|
+
// "integration": "bitgo-v2",
|
|
1627
|
+
// "details": {
|
|
1628
|
+
// "receiving_address": "3NmvbcYKhogs6RoTb4eYCUJ3beRSqLgSif",
|
|
1629
|
+
// "tx_hash": "327f3838531f611485ec59f9d0a119fea1595591e274d942b2c10b9b8262eb1d",
|
|
1630
|
+
// "confirmations": "4"
|
|
1631
|
+
// }
|
|
1632
|
+
// }
|
|
1633
|
+
//
|
|
1634
|
+
// withdraw
|
|
1635
|
+
//
|
|
1636
|
+
// {
|
|
1637
|
+
// "wid": "c5b8d7f0768ee91d3b33bee648318688",
|
|
1638
|
+
// "status": "pending",
|
|
1639
|
+
// "created_at": "2016-04-08T17:52:31.000+00:00",
|
|
1640
|
+
// "currency": "btc",
|
|
1641
|
+
// "method": "Bitcoin",
|
|
1642
|
+
// "amount": "0.48650929",
|
|
1643
|
+
// "details": {
|
|
1644
|
+
// "withdrawal_address": "18MsnATiNiKLqUHDTRKjurwMg7inCrdNEp",
|
|
1645
|
+
// "tx_hash": "d4f28394693e9fb5fffcaf730c11f32d1922e5837f76ca82189d3bfe30ded433"
|
|
1646
|
+
// }
|
|
1647
|
+
// }
|
|
1648
|
+
//
|
|
1649
|
+
const currencyId = this.safeString2(transaction, 'currency', 'asset');
|
|
1650
|
+
currency = this.safeCurrency(currencyId, currency);
|
|
1651
|
+
const details = this.safeValue(transaction, 'details', {});
|
|
1652
|
+
const datetime = this.safeString(transaction, 'created_at');
|
|
1653
|
+
const withdrawalAddress = this.safeString(details, 'withdrawal_address');
|
|
1654
|
+
const receivingAddress = this.safeString(details, 'receiving_address');
|
|
1655
|
+
const networkId = this.safeString2(transaction, 'network', 'method');
|
|
1656
|
+
const status = this.safeString(transaction, 'status');
|
|
1657
|
+
const withdrawId = this.safeString(transaction, 'wid');
|
|
1658
|
+
return {
|
|
1659
|
+
'id': this.safeString2(transaction, 'wid', 'fid'),
|
|
1660
|
+
'txid': this.safeString(details, 'tx_hash'),
|
|
1661
|
+
'timestamp': this.parse8601(datetime),
|
|
1662
|
+
'datetime': datetime,
|
|
1663
|
+
'network': this.safeNetwork(networkId),
|
|
1664
|
+
'addressFrom': receivingAddress,
|
|
1665
|
+
'address': (withdrawalAddress !== undefined) ? withdrawalAddress : receivingAddress,
|
|
1666
|
+
'addressTo': withdrawalAddress,
|
|
1667
|
+
'amount': this.safeNumber(transaction, 'amount'),
|
|
1668
|
+
'type': (withdrawId === undefined) ? 'deposit' : 'withdrawal',
|
|
1669
|
+
'currency': this.safeCurrencyCode(currencyId, currency),
|
|
1670
|
+
'status': this.parseTransactionStatus(status),
|
|
1671
|
+
'updated': undefined,
|
|
1672
|
+
'tagFrom': undefined,
|
|
1673
|
+
'tag': undefined,
|
|
1674
|
+
'tagTo': undefined,
|
|
1675
|
+
'comment': undefined,
|
|
1676
|
+
'internal': undefined,
|
|
1677
|
+
'fee': undefined,
|
|
1678
|
+
'info': transaction,
|
|
1679
|
+
};
|
|
1680
|
+
}
|
|
1681
|
+
parseTransactionStatus(status) {
|
|
1682
|
+
const statuses = {
|
|
1683
|
+
'pending': 'pending',
|
|
1684
|
+
'in_progress': 'pending',
|
|
1685
|
+
'complete': 'ok',
|
|
1686
|
+
'failed': 'failed',
|
|
1687
|
+
};
|
|
1688
|
+
return this.safeString(statuses, status, status);
|
|
1689
|
+
}
|
|
1690
|
+
nonce() {
|
|
1691
|
+
return this.milliseconds();
|
|
1692
|
+
}
|
|
1693
|
+
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
1694
|
+
let endpoint = '/' + this.version + '/' + this.implodeParams(path, params);
|
|
1695
|
+
const query = this.omit(params, this.extractParams(path));
|
|
1696
|
+
if (method === 'GET' || method === 'DELETE') {
|
|
1697
|
+
if (Object.keys(query).length) {
|
|
1698
|
+
endpoint += '?' + this.urlencode(query);
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
const url = this.urls['api']['rest'] + endpoint;
|
|
1702
|
+
if (api === 'private') {
|
|
1703
|
+
this.checkRequiredCredentials();
|
|
1704
|
+
const nonce = this.nonce().toString();
|
|
1705
|
+
let request = [nonce, method, endpoint].join('');
|
|
1706
|
+
if (method !== 'GET' && method !== 'DELETE') {
|
|
1707
|
+
if (Object.keys(query).length) {
|
|
1708
|
+
body = this.json(query);
|
|
1709
|
+
request += body;
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
const signature = this.hmac(this.encode(request), this.encode(this.secret), sha256.sha256);
|
|
1713
|
+
const auth = this.apiKey + ':' + nonce + ':' + signature;
|
|
1714
|
+
headers = {
|
|
1715
|
+
'Authorization': 'Bitso ' + auth,
|
|
1716
|
+
'Content-Type': 'application/json',
|
|
1717
|
+
};
|
|
1718
|
+
}
|
|
1719
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
1720
|
+
}
|
|
1721
|
+
handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
1722
|
+
if (response === undefined) {
|
|
1723
|
+
return undefined; // fallback to default error handler
|
|
1724
|
+
}
|
|
1725
|
+
if ('success' in response) {
|
|
1726
|
+
//
|
|
1727
|
+
// {"success":false,"error":{"code":104,"message":"Cannot perform request - nonce must be higher than 1520307203724237"}}
|
|
1728
|
+
//
|
|
1729
|
+
let success = this.safeValue(response, 'success', false);
|
|
1730
|
+
if (typeof success === 'string') {
|
|
1731
|
+
if ((success === 'true') || (success === '1')) {
|
|
1732
|
+
success = true;
|
|
1733
|
+
}
|
|
1734
|
+
else {
|
|
1735
|
+
success = false;
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
if (!success) {
|
|
1739
|
+
const feedback = this.id + ' ' + this.json(response);
|
|
1740
|
+
const error = this.safeValue(response, 'error');
|
|
1741
|
+
if (error === undefined) {
|
|
1742
|
+
throw new errors.ExchangeError(feedback);
|
|
1743
|
+
}
|
|
1744
|
+
const code = this.safeString(error, 'code');
|
|
1745
|
+
this.throwExactlyMatchedException(this.exceptions, code, feedback);
|
|
1746
|
+
throw new errors.ExchangeError(feedback);
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
return undefined;
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
module.exports = bitso;
|