ccxt 4.2.11 → 4.2.12
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 +640 -261
- 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 +2142 -0
- package/dist/cjs/js/src/binance.js +9729 -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 +3737 -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 +8284 -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 +3274 -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 +7054 -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 +9024 -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 +759 -0
- package/dist/cjs/js/src/indodax.js +1069 -0
- package/dist/cjs/js/src/kraken.js +2861 -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 +2825 -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 +7329 -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 +4715 -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 +1558 -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 +1865 -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 +2715 -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/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/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 +1 -2
- package/js/src/bigone.js +340 -145
- package/js/src/binance.js +15 -8
- package/js/src/bingx.js +9 -2
- package/js/src/bitfinex.d.ts +2 -2
- package/js/src/bitfinex.js +2 -3
- package/js/src/bitget.js +21 -8
- package/js/src/bitmart.d.ts +2 -2
- package/js/src/bitmart.js +3 -3
- package/js/src/bitmex.js +1 -0
- package/js/src/bybit.js +2 -0
- package/js/src/coinlist.js +2 -3
- 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 +22 -3
- package/js/src/hitbtc.d.ts +4 -4
- package/js/src/hitbtc.js +2 -3
- package/js/src/htx.js +4 -7
- package/js/src/huobijp.js +2 -3
- package/js/src/kraken.js +1 -0
- package/js/src/mexc.js +2 -1
- package/js/src/okx.js +13 -3
- 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/poloniex.d.ts +2 -2
- package/js/src/upbit.d.ts +3 -101
- package/js/src/upbit.js +12 -12
- package/js/src/woo.js +2 -0
- package/package.json +1 -1
- package/skip-tests.json +5 -0
|
@@ -0,0 +1,1968 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var bitvavo$1 = require('./abstract/bitvavo.js');
|
|
4
|
+
var errors = require('./base/errors.js');
|
|
5
|
+
var number = require('./base/functions/number.js');
|
|
6
|
+
var Precise = require('./base/Precise.js');
|
|
7
|
+
var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
|
|
8
|
+
|
|
9
|
+
// ----------------------------------------------------------------------------
|
|
10
|
+
// ----------------------------------------------------------------------------
|
|
11
|
+
/**
|
|
12
|
+
* @class bitvavo
|
|
13
|
+
* @augments Exchange
|
|
14
|
+
*/
|
|
15
|
+
class bitvavo extends bitvavo$1 {
|
|
16
|
+
describe() {
|
|
17
|
+
return this.deepExtend(super.describe(), {
|
|
18
|
+
'id': 'bitvavo',
|
|
19
|
+
'name': 'Bitvavo',
|
|
20
|
+
'countries': ['NL'],
|
|
21
|
+
'rateLimit': 60,
|
|
22
|
+
'version': 'v2',
|
|
23
|
+
'certified': false,
|
|
24
|
+
'pro': true,
|
|
25
|
+
'has': {
|
|
26
|
+
'CORS': undefined,
|
|
27
|
+
'spot': true,
|
|
28
|
+
'margin': false,
|
|
29
|
+
'swap': false,
|
|
30
|
+
'future': false,
|
|
31
|
+
'option': false,
|
|
32
|
+
'addMargin': false,
|
|
33
|
+
'cancelAllOrders': true,
|
|
34
|
+
'cancelOrder': true,
|
|
35
|
+
'closeAllPositions': false,
|
|
36
|
+
'closePosition': false,
|
|
37
|
+
'createOrder': true,
|
|
38
|
+
'createReduceOnlyOrder': false,
|
|
39
|
+
'createStopLimitOrder': true,
|
|
40
|
+
'createStopMarketOrder': true,
|
|
41
|
+
'createStopOrder': true,
|
|
42
|
+
'editOrder': true,
|
|
43
|
+
'fetchBalance': true,
|
|
44
|
+
'fetchBorrowRateHistories': false,
|
|
45
|
+
'fetchBorrowRateHistory': false,
|
|
46
|
+
'fetchCrossBorrowRate': false,
|
|
47
|
+
'fetchCrossBorrowRates': false,
|
|
48
|
+
'fetchCurrencies': true,
|
|
49
|
+
'fetchDepositAddress': true,
|
|
50
|
+
'fetchDeposits': true,
|
|
51
|
+
'fetchDepositWithdrawFee': 'emulated',
|
|
52
|
+
'fetchDepositWithdrawFees': true,
|
|
53
|
+
'fetchFundingHistory': false,
|
|
54
|
+
'fetchFundingRate': false,
|
|
55
|
+
'fetchFundingRateHistory': false,
|
|
56
|
+
'fetchFundingRates': false,
|
|
57
|
+
'fetchIndexOHLCV': false,
|
|
58
|
+
'fetchIsolatedBorrowRate': false,
|
|
59
|
+
'fetchIsolatedBorrowRates': false,
|
|
60
|
+
'fetchLeverage': false,
|
|
61
|
+
'fetchLeverageTiers': false,
|
|
62
|
+
'fetchMarginMode': false,
|
|
63
|
+
'fetchMarkets': true,
|
|
64
|
+
'fetchMarkOHLCV': false,
|
|
65
|
+
'fetchMyTrades': true,
|
|
66
|
+
'fetchOHLCV': true,
|
|
67
|
+
'fetchOpenInterestHistory': false,
|
|
68
|
+
'fetchOpenOrders': true,
|
|
69
|
+
'fetchOrder': true,
|
|
70
|
+
'fetchOrderBook': true,
|
|
71
|
+
'fetchOrders': true,
|
|
72
|
+
'fetchPosition': false,
|
|
73
|
+
'fetchPositionMode': false,
|
|
74
|
+
'fetchPositions': false,
|
|
75
|
+
'fetchPositionsRisk': false,
|
|
76
|
+
'fetchPremiumIndexOHLCV': false,
|
|
77
|
+
'fetchTicker': true,
|
|
78
|
+
'fetchTickers': true,
|
|
79
|
+
'fetchTime': true,
|
|
80
|
+
'fetchTrades': true,
|
|
81
|
+
'fetchTradingFee': false,
|
|
82
|
+
'fetchTradingFees': true,
|
|
83
|
+
'fetchTransfer': false,
|
|
84
|
+
'fetchTransfers': false,
|
|
85
|
+
'fetchWithdrawals': true,
|
|
86
|
+
'reduceMargin': false,
|
|
87
|
+
'setLeverage': false,
|
|
88
|
+
'setMarginMode': false,
|
|
89
|
+
'setPositionMode': false,
|
|
90
|
+
'transfer': false,
|
|
91
|
+
'withdraw': true,
|
|
92
|
+
},
|
|
93
|
+
'timeframes': {
|
|
94
|
+
'1m': '1m',
|
|
95
|
+
'5m': '5m',
|
|
96
|
+
'15m': '15m',
|
|
97
|
+
'30m': '30m',
|
|
98
|
+
'1h': '1h',
|
|
99
|
+
'2h': '2h',
|
|
100
|
+
'4h': '4h',
|
|
101
|
+
'6h': '6h',
|
|
102
|
+
'8h': '8h',
|
|
103
|
+
'12h': '12h',
|
|
104
|
+
'1d': '1d',
|
|
105
|
+
},
|
|
106
|
+
'urls': {
|
|
107
|
+
'logo': 'https://user-images.githubusercontent.com/1294454/169202626-bd130fc5-fcf9-41bb-8d97-6093225c73cd.jpg',
|
|
108
|
+
'api': {
|
|
109
|
+
'public': 'https://api.bitvavo.com',
|
|
110
|
+
'private': 'https://api.bitvavo.com',
|
|
111
|
+
},
|
|
112
|
+
'www': 'https://bitvavo.com/',
|
|
113
|
+
'doc': 'https://docs.bitvavo.com/',
|
|
114
|
+
'fees': 'https://bitvavo.com/en/fees',
|
|
115
|
+
'referral': 'https://bitvavo.com/?a=24F34952F7',
|
|
116
|
+
},
|
|
117
|
+
'api': {
|
|
118
|
+
'public': {
|
|
119
|
+
'get': {
|
|
120
|
+
'time': 1,
|
|
121
|
+
'markets': 1,
|
|
122
|
+
'assets': 1,
|
|
123
|
+
'{market}/book': 1,
|
|
124
|
+
'{market}/trades': 5,
|
|
125
|
+
'{market}/candles': 1,
|
|
126
|
+
'ticker/price': 1,
|
|
127
|
+
'ticker/book': 1,
|
|
128
|
+
'ticker/24h': { 'cost': 1, 'noMarket': 25 },
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
'private': {
|
|
132
|
+
'get': {
|
|
133
|
+
'account': 1,
|
|
134
|
+
'order': 1,
|
|
135
|
+
'orders': 5,
|
|
136
|
+
'ordersOpen': { 'cost': 1, 'noMarket': 25 },
|
|
137
|
+
'trades': 5,
|
|
138
|
+
'balance': 5,
|
|
139
|
+
'deposit': 1,
|
|
140
|
+
'depositHistory': 5,
|
|
141
|
+
'withdrawalHistory': 5,
|
|
142
|
+
},
|
|
143
|
+
'post': {
|
|
144
|
+
'order': 1,
|
|
145
|
+
'withdrawal': 1,
|
|
146
|
+
},
|
|
147
|
+
'put': {
|
|
148
|
+
'order': 1,
|
|
149
|
+
},
|
|
150
|
+
'delete': {
|
|
151
|
+
'order': 1,
|
|
152
|
+
'orders': 1,
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
'fees': {
|
|
157
|
+
'trading': {
|
|
158
|
+
'tierBased': true,
|
|
159
|
+
'percentage': true,
|
|
160
|
+
'taker': this.parseNumber('0.0025'),
|
|
161
|
+
'maker': this.parseNumber('0.002'),
|
|
162
|
+
'tiers': {
|
|
163
|
+
'taker': [
|
|
164
|
+
[this.parseNumber('0'), this.parseNumber('0.0025')],
|
|
165
|
+
[this.parseNumber('100000'), this.parseNumber('0.0020')],
|
|
166
|
+
[this.parseNumber('250000'), this.parseNumber('0.0016')],
|
|
167
|
+
[this.parseNumber('500000'), this.parseNumber('0.0012')],
|
|
168
|
+
[this.parseNumber('1000000'), this.parseNumber('0.0010')],
|
|
169
|
+
[this.parseNumber('2500000'), this.parseNumber('0.0008')],
|
|
170
|
+
[this.parseNumber('5000000'), this.parseNumber('0.0006')],
|
|
171
|
+
[this.parseNumber('10000000'), this.parseNumber('0.0005')],
|
|
172
|
+
[this.parseNumber('25000000'), this.parseNumber('0.0004')],
|
|
173
|
+
],
|
|
174
|
+
'maker': [
|
|
175
|
+
[this.parseNumber('0'), this.parseNumber('0.0015')],
|
|
176
|
+
[this.parseNumber('100000'), this.parseNumber('0.0010')],
|
|
177
|
+
[this.parseNumber('250000'), this.parseNumber('0.0008')],
|
|
178
|
+
[this.parseNumber('500000'), this.parseNumber('0.0006')],
|
|
179
|
+
[this.parseNumber('1000000'), this.parseNumber('0.0005')],
|
|
180
|
+
[this.parseNumber('2500000'), this.parseNumber('0.0004')],
|
|
181
|
+
[this.parseNumber('5000000'), this.parseNumber('0.0004')],
|
|
182
|
+
[this.parseNumber('10000000'), this.parseNumber('0.0003')],
|
|
183
|
+
[this.parseNumber('25000000'), this.parseNumber('0.0003')],
|
|
184
|
+
],
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
'requiredCredentials': {
|
|
189
|
+
'apiKey': true,
|
|
190
|
+
'secret': true,
|
|
191
|
+
},
|
|
192
|
+
'exceptions': {
|
|
193
|
+
'exact': {
|
|
194
|
+
'101': errors.ExchangeError,
|
|
195
|
+
'102': errors.BadRequest,
|
|
196
|
+
'103': errors.RateLimitExceeded,
|
|
197
|
+
'104': errors.RateLimitExceeded,
|
|
198
|
+
'105': errors.PermissionDenied,
|
|
199
|
+
'107': errors.ExchangeNotAvailable,
|
|
200
|
+
'108': errors.ExchangeNotAvailable,
|
|
201
|
+
'109': errors.ExchangeNotAvailable,
|
|
202
|
+
'110': errors.BadRequest,
|
|
203
|
+
'200': errors.BadRequest,
|
|
204
|
+
'201': errors.BadRequest,
|
|
205
|
+
'202': errors.BadRequest,
|
|
206
|
+
'203': errors.BadSymbol,
|
|
207
|
+
'204': errors.BadRequest,
|
|
208
|
+
'205': errors.BadRequest,
|
|
209
|
+
'206': errors.BadRequest,
|
|
210
|
+
'210': errors.InvalidOrder,
|
|
211
|
+
'211': errors.InvalidOrder,
|
|
212
|
+
'212': errors.InvalidOrder,
|
|
213
|
+
'213': errors.InvalidOrder,
|
|
214
|
+
'214': errors.InvalidOrder,
|
|
215
|
+
'215': errors.InvalidOrder,
|
|
216
|
+
'216': errors.InsufficientFunds,
|
|
217
|
+
'217': errors.InvalidOrder,
|
|
218
|
+
'230': errors.ExchangeError,
|
|
219
|
+
'231': errors.ExchangeError,
|
|
220
|
+
'232': errors.BadRequest,
|
|
221
|
+
'233': errors.InvalidOrder,
|
|
222
|
+
'234': errors.InvalidOrder,
|
|
223
|
+
'235': errors.ExchangeError,
|
|
224
|
+
'236': errors.BadRequest,
|
|
225
|
+
'240': errors.OrderNotFound,
|
|
226
|
+
'300': errors.AuthenticationError,
|
|
227
|
+
'301': errors.AuthenticationError,
|
|
228
|
+
'302': errors.AuthenticationError,
|
|
229
|
+
'303': errors.AuthenticationError,
|
|
230
|
+
'304': errors.AuthenticationError,
|
|
231
|
+
// "304": AuthenticationError, // Authentication is required for this endpoint.
|
|
232
|
+
'305': errors.AuthenticationError,
|
|
233
|
+
'306': errors.AuthenticationError,
|
|
234
|
+
'307': errors.PermissionDenied,
|
|
235
|
+
'308': errors.AuthenticationError,
|
|
236
|
+
'309': errors.AuthenticationError,
|
|
237
|
+
'310': errors.PermissionDenied,
|
|
238
|
+
'311': errors.PermissionDenied,
|
|
239
|
+
'312': errors.PermissionDenied,
|
|
240
|
+
'315': errors.BadRequest,
|
|
241
|
+
'317': errors.AccountSuspended,
|
|
242
|
+
'400': errors.ExchangeError,
|
|
243
|
+
'401': errors.ExchangeError,
|
|
244
|
+
'402': errors.PermissionDenied,
|
|
245
|
+
'403': errors.PermissionDenied,
|
|
246
|
+
'404': errors.OnMaintenance,
|
|
247
|
+
'405': errors.ExchangeError,
|
|
248
|
+
'406': errors.BadRequest,
|
|
249
|
+
'407': errors.ExchangeError,
|
|
250
|
+
'408': errors.InsufficientFunds,
|
|
251
|
+
'409': errors.InvalidAddress,
|
|
252
|
+
'410': errors.ExchangeError,
|
|
253
|
+
'411': errors.BadRequest,
|
|
254
|
+
'412': errors.InvalidAddress,
|
|
255
|
+
'413': errors.InvalidAddress,
|
|
256
|
+
'414': errors.ExchangeError, // You cannot withdraw assets within 2 minutes of logging in.
|
|
257
|
+
},
|
|
258
|
+
'broad': {
|
|
259
|
+
'start parameter is invalid': errors.BadRequest,
|
|
260
|
+
'symbol parameter is invalid': errors.BadSymbol,
|
|
261
|
+
'amount parameter is invalid': errors.InvalidOrder,
|
|
262
|
+
'orderId parameter is invalid': errors.InvalidOrder, // {"errorCode":205,"error":"orderId parameter is invalid."}
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
'options': {
|
|
266
|
+
'BITVAVO-ACCESS-WINDOW': 10000,
|
|
267
|
+
'networks': {
|
|
268
|
+
'ERC20': 'ETH',
|
|
269
|
+
'TRC20': 'TRX',
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
'precisionMode': number.SIGNIFICANT_DIGITS,
|
|
273
|
+
'commonCurrencies': {
|
|
274
|
+
'MIOTA': 'IOTA', // https://github.com/ccxt/ccxt/issues/7487
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
currencyToPrecision(code, fee, networkCode = undefined) {
|
|
279
|
+
return this.decimalToPrecision(fee, 0, this.currencies[code]['precision'], number.DECIMAL_PLACES);
|
|
280
|
+
}
|
|
281
|
+
amountToPrecision(symbol, amount) {
|
|
282
|
+
// https://docs.bitfinex.com/docs/introduction#amount-precision
|
|
283
|
+
// The amount field allows up to 8 decimals.
|
|
284
|
+
// Anything exceeding this will be rounded to the 8th decimal.
|
|
285
|
+
return this.decimalToPrecision(amount, number.TRUNCATE, this.markets[symbol]['precision']['amount'], number.DECIMAL_PLACES);
|
|
286
|
+
}
|
|
287
|
+
priceToPrecision(symbol, price) {
|
|
288
|
+
price = this.decimalToPrecision(price, number.ROUND, this.markets[symbol]['precision']['price'], this.precisionMode);
|
|
289
|
+
// https://docs.bitfinex.com/docs/introduction#price-precision
|
|
290
|
+
// The precision level of all trading prices is based on significant figures.
|
|
291
|
+
// All pairs on Bitfinex use up to 5 significant digits and up to 8 decimals (e.g. 1.2345, 123.45, 1234.5, 0.00012345).
|
|
292
|
+
// Prices submit with a precision larger than 5 will be cut by the API.
|
|
293
|
+
return this.decimalToPrecision(price, number.TRUNCATE, 8, number.DECIMAL_PLACES);
|
|
294
|
+
}
|
|
295
|
+
async fetchTime(params = {}) {
|
|
296
|
+
/**
|
|
297
|
+
* @method
|
|
298
|
+
* @name bitvavo#fetchTime
|
|
299
|
+
* @description fetches the current integer timestamp in milliseconds from the exchange server
|
|
300
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
301
|
+
* @returns {int} the current integer timestamp in milliseconds from the exchange server
|
|
302
|
+
*/
|
|
303
|
+
const response = await this.publicGetTime(params);
|
|
304
|
+
//
|
|
305
|
+
// { "time": 1590379519148 }
|
|
306
|
+
//
|
|
307
|
+
return this.safeInteger(response, 'time');
|
|
308
|
+
}
|
|
309
|
+
async fetchMarkets(params = {}) {
|
|
310
|
+
/**
|
|
311
|
+
* @method
|
|
312
|
+
* @name bitvavo#fetchMarkets
|
|
313
|
+
* @description retrieves data on all markets for bitvavo
|
|
314
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
315
|
+
* @returns {object[]} an array of objects representing market data
|
|
316
|
+
*/
|
|
317
|
+
const response = await this.publicGetMarkets(params);
|
|
318
|
+
//
|
|
319
|
+
// [
|
|
320
|
+
// {
|
|
321
|
+
// "market":"ADA-BTC",
|
|
322
|
+
// "status":"trading", // "trading" "halted" "auction"
|
|
323
|
+
// "base":"ADA",
|
|
324
|
+
// "quote":"BTC",
|
|
325
|
+
// "pricePrecision":5,
|
|
326
|
+
// "minOrderInBaseAsset":"100",
|
|
327
|
+
// "minOrderInQuoteAsset":"0.001",
|
|
328
|
+
// "orderTypes": [ "market", "limit" ]
|
|
329
|
+
// }
|
|
330
|
+
// ]
|
|
331
|
+
//
|
|
332
|
+
const currencies = this.currencies;
|
|
333
|
+
const currenciesById = this.indexBy(currencies, 'id');
|
|
334
|
+
const result = [];
|
|
335
|
+
const fees = this.fees;
|
|
336
|
+
for (let i = 0; i < response.length; i++) {
|
|
337
|
+
const market = response[i];
|
|
338
|
+
const id = this.safeString(market, 'market');
|
|
339
|
+
const baseId = this.safeString(market, 'base');
|
|
340
|
+
const quoteId = this.safeString(market, 'quote');
|
|
341
|
+
const base = this.safeCurrencyCode(baseId);
|
|
342
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
343
|
+
const status = this.safeString(market, 'status');
|
|
344
|
+
const baseCurrency = this.safeValue(currenciesById, baseId);
|
|
345
|
+
const basePrecision = this.safeInteger(baseCurrency, 'precision');
|
|
346
|
+
result.push(this.safeMarketStructure({
|
|
347
|
+
'id': id,
|
|
348
|
+
'symbol': base + '/' + quote,
|
|
349
|
+
'base': base,
|
|
350
|
+
'quote': quote,
|
|
351
|
+
'settle': undefined,
|
|
352
|
+
'baseId': baseId,
|
|
353
|
+
'quoteId': quoteId,
|
|
354
|
+
'settleId': undefined,
|
|
355
|
+
'type': 'spot',
|
|
356
|
+
'spot': true,
|
|
357
|
+
'margin': false,
|
|
358
|
+
'swap': false,
|
|
359
|
+
'future': false,
|
|
360
|
+
'option': false,
|
|
361
|
+
'active': (status === 'trading'),
|
|
362
|
+
'contract': false,
|
|
363
|
+
'linear': undefined,
|
|
364
|
+
'inverse': undefined,
|
|
365
|
+
'contractSize': undefined,
|
|
366
|
+
'expiry': undefined,
|
|
367
|
+
'expiryDatetime': undefined,
|
|
368
|
+
'strike': undefined,
|
|
369
|
+
'optionType': undefined,
|
|
370
|
+
'taker': fees['trading']['taker'],
|
|
371
|
+
'maker': fees['trading']['maker'],
|
|
372
|
+
'precision': {
|
|
373
|
+
'amount': this.safeInteger(baseCurrency, 'decimals', basePrecision),
|
|
374
|
+
'price': this.safeInteger(market, 'pricePrecision'),
|
|
375
|
+
},
|
|
376
|
+
'limits': {
|
|
377
|
+
'leverage': {
|
|
378
|
+
'min': undefined,
|
|
379
|
+
'max': undefined,
|
|
380
|
+
},
|
|
381
|
+
'amount': {
|
|
382
|
+
'min': this.safeNumber(market, 'minOrderInBaseAsset'),
|
|
383
|
+
'max': undefined,
|
|
384
|
+
},
|
|
385
|
+
'price': {
|
|
386
|
+
'min': undefined,
|
|
387
|
+
'max': undefined,
|
|
388
|
+
},
|
|
389
|
+
'cost': {
|
|
390
|
+
'min': this.safeNumber(market, 'minOrderInQuoteAsset'),
|
|
391
|
+
'max': undefined,
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
'created': undefined,
|
|
395
|
+
'info': market,
|
|
396
|
+
}));
|
|
397
|
+
}
|
|
398
|
+
return result;
|
|
399
|
+
}
|
|
400
|
+
async fetchCurrencies(params = {}) {
|
|
401
|
+
/**
|
|
402
|
+
* @method
|
|
403
|
+
* @name bitvavo#fetchCurrencies
|
|
404
|
+
* @description fetches all available currencies on an exchange
|
|
405
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
406
|
+
* @returns {object} an associative dictionary of currencies
|
|
407
|
+
*/
|
|
408
|
+
const response = await this.publicGetAssets(params);
|
|
409
|
+
//
|
|
410
|
+
// [
|
|
411
|
+
// {
|
|
412
|
+
// "symbol": "USDT",
|
|
413
|
+
// "displayTicker": "USDT",
|
|
414
|
+
// "name": "Tether",
|
|
415
|
+
// "slug": "tether",
|
|
416
|
+
// "popularity": -1,
|
|
417
|
+
// "decimals": 6,
|
|
418
|
+
// "depositFee": "0",
|
|
419
|
+
// "depositConfirmations": 64,
|
|
420
|
+
// "depositStatus": "OK",
|
|
421
|
+
// "withdrawalFee": "3.2",
|
|
422
|
+
// "withdrawalMinAmount": "3.2",
|
|
423
|
+
// "withdrawalStatus": "OK",
|
|
424
|
+
// "networks": [
|
|
425
|
+
// "ETH"
|
|
426
|
+
// ],
|
|
427
|
+
// "light": {
|
|
428
|
+
// "color": "#009393",
|
|
429
|
+
// "icon": { "hash": "4ad7c699", "svg": "https://...", "webp16": "https://...", "webp32": "https://...", "webp64": "https://...", "webp128": "https://...", "webp256": "https://...", "png16": "https://...", "png32": "https://...", "png64": "https://...", "png128": "https://...", "png256": "https://..."
|
|
430
|
+
// }
|
|
431
|
+
// },
|
|
432
|
+
// "dark": {
|
|
433
|
+
// "color": "#009393",
|
|
434
|
+
// "icon": { "hash": "4ad7c699", "svg": "https://...", "webp16": "https://...", "webp32": "https://...", "webp64": "https://...", "webp128": "https://...", "webp256": "https://...", "png16": "https://...", "png32": "https://...", "png64": "https://...", "png128": "https://...", "png256": "https://..."
|
|
435
|
+
// }
|
|
436
|
+
// },
|
|
437
|
+
// "visibility": "PUBLIC",
|
|
438
|
+
// "message": ""
|
|
439
|
+
// },
|
|
440
|
+
// ]
|
|
441
|
+
//
|
|
442
|
+
const result = {};
|
|
443
|
+
for (let i = 0; i < response.length; i++) {
|
|
444
|
+
const currency = response[i];
|
|
445
|
+
const id = this.safeString(currency, 'symbol');
|
|
446
|
+
const code = this.safeCurrencyCode(id);
|
|
447
|
+
const networks = {};
|
|
448
|
+
const networksArray = this.safeValue(currency, 'networks', []);
|
|
449
|
+
const networksLength = networksArray.length;
|
|
450
|
+
const isOneNetwork = (networksLength === 1);
|
|
451
|
+
const deposit = (this.safeValue(currency, 'depositStatus') === 'OK');
|
|
452
|
+
const withdrawal = (this.safeValue(currency, 'withdrawalStatus') === 'OK');
|
|
453
|
+
const active = deposit && withdrawal;
|
|
454
|
+
const withdrawFee = this.safeNumber(currency, 'withdrawalFee');
|
|
455
|
+
const precision = this.safeInteger(currency, 'decimals', 8);
|
|
456
|
+
const minWithdraw = this.safeNumber(currency, 'withdrawalMinAmount');
|
|
457
|
+
// absolutely all of them have 1 network atm - ETH. So, we can reliably assign that inside networks
|
|
458
|
+
if (isOneNetwork) {
|
|
459
|
+
const networkId = networksArray[0];
|
|
460
|
+
const networkCode = this.networkIdToCode(networkId);
|
|
461
|
+
networks[networkCode] = {
|
|
462
|
+
'info': currency,
|
|
463
|
+
'id': networkId,
|
|
464
|
+
'network': networkCode,
|
|
465
|
+
'active': active,
|
|
466
|
+
'deposit': deposit,
|
|
467
|
+
'withdraw': withdrawal,
|
|
468
|
+
'fee': withdrawFee,
|
|
469
|
+
'precision': precision,
|
|
470
|
+
'limits': {
|
|
471
|
+
'withdraw': {
|
|
472
|
+
'min': minWithdraw,
|
|
473
|
+
'max': undefined,
|
|
474
|
+
},
|
|
475
|
+
},
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
result[code] = {
|
|
479
|
+
'info': currency,
|
|
480
|
+
'id': id,
|
|
481
|
+
'code': code,
|
|
482
|
+
'name': this.safeString(currency, 'name'),
|
|
483
|
+
'active': active,
|
|
484
|
+
'deposit': deposit,
|
|
485
|
+
'withdraw': withdrawal,
|
|
486
|
+
'networks': networks,
|
|
487
|
+
'fee': withdrawFee,
|
|
488
|
+
'precision': precision,
|
|
489
|
+
'limits': {
|
|
490
|
+
'amount': {
|
|
491
|
+
'min': undefined,
|
|
492
|
+
'max': undefined,
|
|
493
|
+
},
|
|
494
|
+
'deposit': {
|
|
495
|
+
'min': undefined,
|
|
496
|
+
'max': undefined,
|
|
497
|
+
},
|
|
498
|
+
'withdraw': {
|
|
499
|
+
'min': minWithdraw,
|
|
500
|
+
'max': undefined,
|
|
501
|
+
},
|
|
502
|
+
},
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
// set currencies here to avoid calling publicGetAssets twice
|
|
506
|
+
this.currencies = this.deepExtend(this.currencies, result);
|
|
507
|
+
return result;
|
|
508
|
+
}
|
|
509
|
+
async fetchTicker(symbol, params = {}) {
|
|
510
|
+
/**
|
|
511
|
+
* @method
|
|
512
|
+
* @name bitvavo#fetchTicker
|
|
513
|
+
* @see https://docs.bitvavo.com/#tag/Market-Data/paths/~1ticker~124h/get
|
|
514
|
+
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
515
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
516
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
517
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
518
|
+
*/
|
|
519
|
+
await this.loadMarkets();
|
|
520
|
+
const market = this.market(symbol);
|
|
521
|
+
const request = {
|
|
522
|
+
'market': market['id'],
|
|
523
|
+
};
|
|
524
|
+
const response = await this.publicGetTicker24h(this.extend(request, params));
|
|
525
|
+
//
|
|
526
|
+
// {
|
|
527
|
+
// "market":"ETH-BTC",
|
|
528
|
+
// "open":"0.022578",
|
|
529
|
+
// "high":"0.023019",
|
|
530
|
+
// "low":"0.022573",
|
|
531
|
+
// "last":"0.023019",
|
|
532
|
+
// "volume":"25.16366324",
|
|
533
|
+
// "volumeQuote":"0.57333305",
|
|
534
|
+
// "bid":"0.023039",
|
|
535
|
+
// "bidSize":"0.53500578",
|
|
536
|
+
// "ask":"0.023041",
|
|
537
|
+
// "askSize":"0.47859202",
|
|
538
|
+
// "timestamp":1590381666900
|
|
539
|
+
// }
|
|
540
|
+
//
|
|
541
|
+
return this.parseTicker(response, market);
|
|
542
|
+
}
|
|
543
|
+
parseTicker(ticker, market = undefined) {
|
|
544
|
+
//
|
|
545
|
+
// fetchTicker
|
|
546
|
+
//
|
|
547
|
+
// {
|
|
548
|
+
// "market":"ETH-BTC",
|
|
549
|
+
// "open":"0.022578",
|
|
550
|
+
// "high":"0.023019",
|
|
551
|
+
// "low":"0.022573",
|
|
552
|
+
// "last":"0.023019",
|
|
553
|
+
// "volume":"25.16366324",
|
|
554
|
+
// "volumeQuote":"0.57333305",
|
|
555
|
+
// "bid":"0.023039",
|
|
556
|
+
// "bidSize":"0.53500578",
|
|
557
|
+
// "ask":"0.023041",
|
|
558
|
+
// "askSize":"0.47859202",
|
|
559
|
+
// "timestamp":1590381666900
|
|
560
|
+
// }
|
|
561
|
+
//
|
|
562
|
+
const marketId = this.safeString(ticker, 'market');
|
|
563
|
+
const symbol = this.safeSymbol(marketId, market, '-');
|
|
564
|
+
const timestamp = this.safeInteger(ticker, 'timestamp');
|
|
565
|
+
const last = this.safeString(ticker, 'last');
|
|
566
|
+
const baseVolume = this.safeString(ticker, 'volume');
|
|
567
|
+
const quoteVolume = this.safeString(ticker, 'volumeQuote');
|
|
568
|
+
const open = this.safeString(ticker, 'open');
|
|
569
|
+
return this.safeTicker({
|
|
570
|
+
'symbol': symbol,
|
|
571
|
+
'timestamp': timestamp,
|
|
572
|
+
'datetime': this.iso8601(timestamp),
|
|
573
|
+
'high': this.safeString(ticker, 'high'),
|
|
574
|
+
'low': this.safeString(ticker, 'low'),
|
|
575
|
+
'bid': this.safeString(ticker, 'bid'),
|
|
576
|
+
'bidVolume': this.safeString(ticker, 'bidSize'),
|
|
577
|
+
'ask': this.safeString(ticker, 'ask'),
|
|
578
|
+
'askVolume': this.safeString(ticker, 'askSize'),
|
|
579
|
+
'vwap': undefined,
|
|
580
|
+
'open': open,
|
|
581
|
+
'close': last,
|
|
582
|
+
'last': last,
|
|
583
|
+
'previousClose': undefined,
|
|
584
|
+
'change': undefined,
|
|
585
|
+
'percentage': undefined,
|
|
586
|
+
'average': undefined,
|
|
587
|
+
'baseVolume': baseVolume,
|
|
588
|
+
'quoteVolume': quoteVolume,
|
|
589
|
+
'info': ticker,
|
|
590
|
+
}, market);
|
|
591
|
+
}
|
|
592
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
593
|
+
/**
|
|
594
|
+
* @method
|
|
595
|
+
* @name bitvavo#fetchTickers
|
|
596
|
+
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
597
|
+
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
598
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
599
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
600
|
+
*/
|
|
601
|
+
await this.loadMarkets();
|
|
602
|
+
const response = await this.publicGetTicker24h(params);
|
|
603
|
+
//
|
|
604
|
+
// [
|
|
605
|
+
// {
|
|
606
|
+
// "market":"ADA-BTC",
|
|
607
|
+
// "open":"0.0000059595",
|
|
608
|
+
// "high":"0.0000059765",
|
|
609
|
+
// "low":"0.0000059595",
|
|
610
|
+
// "last":"0.0000059765",
|
|
611
|
+
// "volume":"2923.172",
|
|
612
|
+
// "volumeQuote":"0.01743483",
|
|
613
|
+
// "bid":"0.0000059515",
|
|
614
|
+
// "bidSize":"1117.630919",
|
|
615
|
+
// "ask":"0.0000059585",
|
|
616
|
+
// "askSize":"809.999739",
|
|
617
|
+
// "timestamp":1590382266324
|
|
618
|
+
// }
|
|
619
|
+
// ]
|
|
620
|
+
//
|
|
621
|
+
return this.parseTickers(response, symbols);
|
|
622
|
+
}
|
|
623
|
+
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
624
|
+
/**
|
|
625
|
+
* @method
|
|
626
|
+
* @name bitvavo#fetchTrades
|
|
627
|
+
* @see https://docs.bitvavo.com/#tag/Market-Data/paths/~1{market}~1trades/get
|
|
628
|
+
* @description get the list of most recent trades for a particular symbol
|
|
629
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
630
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
631
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
632
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
633
|
+
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
634
|
+
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
635
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
636
|
+
*/
|
|
637
|
+
await this.loadMarkets();
|
|
638
|
+
const market = this.market(symbol);
|
|
639
|
+
let paginate = false;
|
|
640
|
+
[paginate, params] = this.handleOptionAndParams(params, 'fetchTrades', 'paginate');
|
|
641
|
+
if (paginate) {
|
|
642
|
+
return await this.fetchPaginatedCallDynamic('fetchTrades', symbol, since, limit, params);
|
|
643
|
+
}
|
|
644
|
+
let request = {
|
|
645
|
+
'market': market['id'],
|
|
646
|
+
// "limit": 500, // default 500, max 1000
|
|
647
|
+
// "start": since,
|
|
648
|
+
// "end": this.milliseconds (),
|
|
649
|
+
// "tradeIdFrom": "57b1159b-6bf5-4cde-9e2c-6bd6a5678baf",
|
|
650
|
+
// "tradeIdTo": "57b1159b-6bf5-4cde-9e2c-6bd6a5678baf",
|
|
651
|
+
};
|
|
652
|
+
if (limit !== undefined) {
|
|
653
|
+
request['limit'] = Math.min(limit, 1000);
|
|
654
|
+
}
|
|
655
|
+
if (since !== undefined) {
|
|
656
|
+
request['start'] = since;
|
|
657
|
+
}
|
|
658
|
+
[request, params] = this.handleUntilOption('end', request, params);
|
|
659
|
+
const response = await this.publicGetMarketTrades(this.extend(request, params));
|
|
660
|
+
//
|
|
661
|
+
// [
|
|
662
|
+
// {
|
|
663
|
+
// "id":"94154c98-6e8b-4e33-92a8-74e33fc05650",
|
|
664
|
+
// "timestamp":1590382761859,
|
|
665
|
+
// "amount":"0.06026079",
|
|
666
|
+
// "price":"8095.3",
|
|
667
|
+
// "side":"buy"
|
|
668
|
+
// }
|
|
669
|
+
// ]
|
|
670
|
+
//
|
|
671
|
+
return this.parseTrades(response, market, since, limit);
|
|
672
|
+
}
|
|
673
|
+
parseTrade(trade, market = undefined) {
|
|
674
|
+
//
|
|
675
|
+
// fetchTrades (public)
|
|
676
|
+
//
|
|
677
|
+
// {
|
|
678
|
+
// "id":"94154c98-6e8b-4e33-92a8-74e33fc05650",
|
|
679
|
+
// "timestamp":1590382761859,
|
|
680
|
+
// "amount":"0.06026079",
|
|
681
|
+
// "price":"8095.3",
|
|
682
|
+
// "side":"buy"
|
|
683
|
+
// }
|
|
684
|
+
//
|
|
685
|
+
// createOrder, fetchOpenOrders, fetchOrders, editOrder (private)
|
|
686
|
+
//
|
|
687
|
+
// {
|
|
688
|
+
// "id":"b0c86aa5-6ed3-4a2d-ba3a-be9a964220f4",
|
|
689
|
+
// "timestamp":1590505649245,
|
|
690
|
+
// "amount":"0.249825",
|
|
691
|
+
// "price":"183.49",
|
|
692
|
+
// "taker":true,
|
|
693
|
+
// "fee":"0.12038925",
|
|
694
|
+
// "feeCurrency":"EUR",
|
|
695
|
+
// "settled":true
|
|
696
|
+
// }
|
|
697
|
+
//
|
|
698
|
+
// fetchMyTrades (private)
|
|
699
|
+
//
|
|
700
|
+
// {
|
|
701
|
+
// "id":"b0c86aa5-6ed3-4a2d-ba3a-be9a964220f4",
|
|
702
|
+
// "orderId":"af76d6ce-9f7c-4006-b715-bb5d430652d0",
|
|
703
|
+
// "timestamp":1590505649245,
|
|
704
|
+
// "market":"ETH-EUR",
|
|
705
|
+
// "side":"sell",
|
|
706
|
+
// "amount":"0.249825",
|
|
707
|
+
// "price":"183.49",
|
|
708
|
+
// "taker":true,
|
|
709
|
+
// "fee":"0.12038925",
|
|
710
|
+
// "feeCurrency":"EUR",
|
|
711
|
+
// "settled":true
|
|
712
|
+
// }
|
|
713
|
+
//
|
|
714
|
+
// watchMyTrades (private)
|
|
715
|
+
//
|
|
716
|
+
// {
|
|
717
|
+
// "event": "fill",
|
|
718
|
+
// "timestamp": 1590964470132,
|
|
719
|
+
// "market": "ETH-EUR",
|
|
720
|
+
// "orderId": "85d082e1-eda4-4209-9580-248281a29a9a",
|
|
721
|
+
// "fillId": "861d2da5-aa93-475c-8d9a-dce431bd4211",
|
|
722
|
+
// "side": "sell",
|
|
723
|
+
// "amount": "0.1",
|
|
724
|
+
// "price": "211.46",
|
|
725
|
+
// "taker": true,
|
|
726
|
+
// "fee": "0.056",
|
|
727
|
+
// "feeCurrency": "EUR"
|
|
728
|
+
// }
|
|
729
|
+
//
|
|
730
|
+
const priceString = this.safeString(trade, 'price');
|
|
731
|
+
const amountString = this.safeString(trade, 'amount');
|
|
732
|
+
const timestamp = this.safeInteger(trade, 'timestamp');
|
|
733
|
+
const side = this.safeString(trade, 'side');
|
|
734
|
+
const id = this.safeString2(trade, 'id', 'fillId');
|
|
735
|
+
const marketId = this.safeString(trade, 'market');
|
|
736
|
+
const symbol = this.safeSymbol(marketId, market, '-');
|
|
737
|
+
const taker = this.safeValue(trade, 'taker');
|
|
738
|
+
let takerOrMaker = undefined;
|
|
739
|
+
if (taker !== undefined) {
|
|
740
|
+
takerOrMaker = taker ? 'taker' : 'maker';
|
|
741
|
+
}
|
|
742
|
+
const feeCostString = this.safeString(trade, 'fee');
|
|
743
|
+
let fee = undefined;
|
|
744
|
+
if (feeCostString !== undefined) {
|
|
745
|
+
const feeCurrencyId = this.safeString(trade, 'feeCurrency');
|
|
746
|
+
const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
|
|
747
|
+
fee = {
|
|
748
|
+
'cost': feeCostString,
|
|
749
|
+
'currency': feeCurrencyCode,
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
const orderId = this.safeString(trade, 'orderId');
|
|
753
|
+
return this.safeTrade({
|
|
754
|
+
'info': trade,
|
|
755
|
+
'id': id,
|
|
756
|
+
'symbol': symbol,
|
|
757
|
+
'timestamp': timestamp,
|
|
758
|
+
'datetime': this.iso8601(timestamp),
|
|
759
|
+
'order': orderId,
|
|
760
|
+
'type': undefined,
|
|
761
|
+
'side': side,
|
|
762
|
+
'takerOrMaker': takerOrMaker,
|
|
763
|
+
'price': priceString,
|
|
764
|
+
'amount': amountString,
|
|
765
|
+
'cost': undefined,
|
|
766
|
+
'fee': fee,
|
|
767
|
+
}, market);
|
|
768
|
+
}
|
|
769
|
+
async fetchTradingFees(params = {}) {
|
|
770
|
+
/**
|
|
771
|
+
* @method
|
|
772
|
+
* @name bitvavo#fetchTradingFees
|
|
773
|
+
* @description fetch the trading fees for multiple markets
|
|
774
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
775
|
+
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
|
|
776
|
+
*/
|
|
777
|
+
await this.loadMarkets();
|
|
778
|
+
const response = await this.privateGetAccount(params);
|
|
779
|
+
//
|
|
780
|
+
// {
|
|
781
|
+
// "fees": {
|
|
782
|
+
// "taker": "0.0025",
|
|
783
|
+
// "maker": "0.0015",
|
|
784
|
+
// "volume": "10000.00"
|
|
785
|
+
// }
|
|
786
|
+
// }
|
|
787
|
+
//
|
|
788
|
+
const fees = this.safeValue(response, 'fees');
|
|
789
|
+
const maker = this.safeNumber(fees, 'maker');
|
|
790
|
+
const taker = this.safeNumber(fees, 'taker');
|
|
791
|
+
const result = {};
|
|
792
|
+
for (let i = 0; i < this.symbols.length; i++) {
|
|
793
|
+
const symbol = this.symbols[i];
|
|
794
|
+
result[symbol] = {
|
|
795
|
+
'info': response,
|
|
796
|
+
'symbol': symbol,
|
|
797
|
+
'maker': maker,
|
|
798
|
+
'taker': taker,
|
|
799
|
+
'percentage': true,
|
|
800
|
+
'tierBased': true,
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
return result;
|
|
804
|
+
}
|
|
805
|
+
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
806
|
+
/**
|
|
807
|
+
* @method
|
|
808
|
+
* @name bitvavo#fetchOrderBook
|
|
809
|
+
* @see https://docs.bitvavo.com/#tag/Market-Data/paths/~1{market}~1book/get
|
|
810
|
+
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
811
|
+
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
812
|
+
* @param {int} [limit] the maximum amount of order book entries to return
|
|
813
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
814
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
815
|
+
*/
|
|
816
|
+
await this.loadMarkets();
|
|
817
|
+
const market = this.market(symbol);
|
|
818
|
+
const request = {
|
|
819
|
+
'market': market['id'],
|
|
820
|
+
};
|
|
821
|
+
if (limit !== undefined) {
|
|
822
|
+
request['depth'] = limit;
|
|
823
|
+
}
|
|
824
|
+
const response = await this.publicGetMarketBook(this.extend(request, params));
|
|
825
|
+
//
|
|
826
|
+
// {
|
|
827
|
+
// "market":"BTC-EUR",
|
|
828
|
+
// "nonce":35883831,
|
|
829
|
+
// "bids":[
|
|
830
|
+
// ["8097.4","0.6229099"],
|
|
831
|
+
// ["8097.2","0.64151283"],
|
|
832
|
+
// ["8097.1","0.24966294"],
|
|
833
|
+
// ],
|
|
834
|
+
// "asks":[
|
|
835
|
+
// ["8097.5","1.36916911"],
|
|
836
|
+
// ["8098.8","0.33462248"],
|
|
837
|
+
// ["8099.3","1.12908646"],
|
|
838
|
+
// ]
|
|
839
|
+
// }
|
|
840
|
+
//
|
|
841
|
+
const orderbook = this.parseOrderBook(response, market['symbol']);
|
|
842
|
+
orderbook['nonce'] = this.safeInteger(response, 'nonce');
|
|
843
|
+
return orderbook;
|
|
844
|
+
}
|
|
845
|
+
parseOHLCV(ohlcv, market = undefined) {
|
|
846
|
+
//
|
|
847
|
+
// [
|
|
848
|
+
// 1590383700000,
|
|
849
|
+
// "8088.5",
|
|
850
|
+
// "8088.5",
|
|
851
|
+
// "8088.5",
|
|
852
|
+
// "8088.5",
|
|
853
|
+
// "0.04788623"
|
|
854
|
+
// ]
|
|
855
|
+
//
|
|
856
|
+
return [
|
|
857
|
+
this.safeInteger(ohlcv, 0),
|
|
858
|
+
this.safeNumber(ohlcv, 1),
|
|
859
|
+
this.safeNumber(ohlcv, 2),
|
|
860
|
+
this.safeNumber(ohlcv, 3),
|
|
861
|
+
this.safeNumber(ohlcv, 4),
|
|
862
|
+
this.safeNumber(ohlcv, 5),
|
|
863
|
+
];
|
|
864
|
+
}
|
|
865
|
+
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
866
|
+
/**
|
|
867
|
+
* @method
|
|
868
|
+
* @name bitvavo#fetchOHLCV
|
|
869
|
+
* @see https://docs.bitvavo.com/#tag/Market-Data/paths/~1{market}~1candles/get
|
|
870
|
+
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
871
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
872
|
+
* @param {string} timeframe the length of time each candle represents
|
|
873
|
+
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
874
|
+
* @param {int} [limit] the maximum amount of candles to fetch
|
|
875
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
876
|
+
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
877
|
+
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
878
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
879
|
+
*/
|
|
880
|
+
await this.loadMarkets();
|
|
881
|
+
const market = this.market(symbol);
|
|
882
|
+
let paginate = false;
|
|
883
|
+
[paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
|
|
884
|
+
if (paginate) {
|
|
885
|
+
return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1440);
|
|
886
|
+
}
|
|
887
|
+
let request = {
|
|
888
|
+
'market': market['id'],
|
|
889
|
+
'interval': this.safeString(this.timeframes, timeframe, timeframe),
|
|
890
|
+
// "limit": 1440, // default 1440, max 1440
|
|
891
|
+
// "start": since,
|
|
892
|
+
// "end": this.milliseconds (),
|
|
893
|
+
};
|
|
894
|
+
if (since !== undefined) {
|
|
895
|
+
// https://github.com/ccxt/ccxt/issues/9227
|
|
896
|
+
const duration = this.parseTimeframe(timeframe);
|
|
897
|
+
request['start'] = since;
|
|
898
|
+
if (limit === undefined) {
|
|
899
|
+
limit = 1440;
|
|
900
|
+
}
|
|
901
|
+
request['end'] = this.sum(since, limit * duration * 1000);
|
|
902
|
+
}
|
|
903
|
+
[request, params] = this.handleUntilOption('end', request, params);
|
|
904
|
+
if (limit !== undefined) {
|
|
905
|
+
request['limit'] = limit; // default 1440, max 1440
|
|
906
|
+
}
|
|
907
|
+
const response = await this.publicGetMarketCandles(this.extend(request, params));
|
|
908
|
+
//
|
|
909
|
+
// [
|
|
910
|
+
// [1590383700000,"8088.5","8088.5","8088.5","8088.5","0.04788623"],
|
|
911
|
+
// [1590383580000,"8091.3","8091.5","8091.3","8091.5","0.04931221"],
|
|
912
|
+
// [1590383520000,"8090.3","8092.7","8090.3","8092.5","0.04001286"],
|
|
913
|
+
// ]
|
|
914
|
+
//
|
|
915
|
+
return this.parseOHLCVs(response, market, timeframe, since, limit);
|
|
916
|
+
}
|
|
917
|
+
parseBalance(response) {
|
|
918
|
+
const result = {
|
|
919
|
+
'info': response,
|
|
920
|
+
'timestamp': undefined,
|
|
921
|
+
'datetime': undefined,
|
|
922
|
+
};
|
|
923
|
+
for (let i = 0; i < response.length; i++) {
|
|
924
|
+
const balance = response[i];
|
|
925
|
+
const currencyId = this.safeString(balance, 'symbol');
|
|
926
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
927
|
+
const account = this.account();
|
|
928
|
+
account['free'] = this.safeString(balance, 'available');
|
|
929
|
+
account['used'] = this.safeString(balance, 'inOrder');
|
|
930
|
+
result[code] = account;
|
|
931
|
+
}
|
|
932
|
+
return this.safeBalance(result);
|
|
933
|
+
}
|
|
934
|
+
async fetchBalance(params = {}) {
|
|
935
|
+
/**
|
|
936
|
+
* @method
|
|
937
|
+
* @name bitvavo#fetchBalance
|
|
938
|
+
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
939
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
940
|
+
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
941
|
+
*/
|
|
942
|
+
await this.loadMarkets();
|
|
943
|
+
const response = await this.privateGetBalance(params);
|
|
944
|
+
//
|
|
945
|
+
// [
|
|
946
|
+
// {
|
|
947
|
+
// "symbol": "BTC",
|
|
948
|
+
// "available": "1.57593193",
|
|
949
|
+
// "inOrder": "0.74832374"
|
|
950
|
+
// }
|
|
951
|
+
// ]
|
|
952
|
+
//
|
|
953
|
+
return this.parseBalance(response);
|
|
954
|
+
}
|
|
955
|
+
async fetchDepositAddress(code, params = {}) {
|
|
956
|
+
/**
|
|
957
|
+
* @method
|
|
958
|
+
* @name bitvavo#fetchDepositAddress
|
|
959
|
+
* @description fetch the deposit address for a currency associated with this account
|
|
960
|
+
* @param {string} code unified currency code
|
|
961
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
962
|
+
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
963
|
+
*/
|
|
964
|
+
await this.loadMarkets();
|
|
965
|
+
const currency = this.currency(code);
|
|
966
|
+
const request = {
|
|
967
|
+
'symbol': currency['id'],
|
|
968
|
+
};
|
|
969
|
+
const response = await this.privateGetDeposit(this.extend(request, params));
|
|
970
|
+
//
|
|
971
|
+
// {
|
|
972
|
+
// "address": "0x449889e3234514c45d57f7c5a571feba0c7ad567",
|
|
973
|
+
// "paymentId": "10002653"
|
|
974
|
+
// }
|
|
975
|
+
//
|
|
976
|
+
const address = this.safeString(response, 'address');
|
|
977
|
+
const tag = this.safeString(response, 'paymentId');
|
|
978
|
+
this.checkAddress(address);
|
|
979
|
+
return {
|
|
980
|
+
'currency': code,
|
|
981
|
+
'address': address,
|
|
982
|
+
'tag': tag,
|
|
983
|
+
'network': undefined,
|
|
984
|
+
'info': response,
|
|
985
|
+
};
|
|
986
|
+
}
|
|
987
|
+
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
988
|
+
/**
|
|
989
|
+
* @method
|
|
990
|
+
* @name bitvavo#createOrder
|
|
991
|
+
* @description create a trade order
|
|
992
|
+
* @see https://docs.bitvavo.com/#tag/Trading-endpoints/paths/~1order/post
|
|
993
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
994
|
+
* @param {string} type 'market' or 'limit'
|
|
995
|
+
* @param {string} side 'buy' or 'sell'
|
|
996
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
997
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
998
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
999
|
+
* @param {string} [params.timeInForce] "GTC", "IOC", or "PO"
|
|
1000
|
+
* @param {float} [params.stopPrice] The price at which a trigger order is triggered at
|
|
1001
|
+
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
|
|
1002
|
+
* @param {bool} [params.postOnly] If true, the order will only be posted to the order book and not executed immediately
|
|
1003
|
+
* @param {float} [params.stopLossPrice] The price at which a stop loss order is triggered at
|
|
1004
|
+
* @param {float} [params.takeProfitPrice] The price at which a take profit order is triggered at
|
|
1005
|
+
* @param {string} [params.triggerType] "price"
|
|
1006
|
+
* @param {string} [params.triggerReference] "lastTrade", "bestBid", "bestAsk", "midPrice" Only for stop orders: Use this to determine which parameter will trigger the order
|
|
1007
|
+
* @param {string} [params.selfTradePrevention] "decrementAndCancel", "cancelOldest", "cancelNewest", "cancelBoth"
|
|
1008
|
+
* @param {bool} [params.disableMarketProtection] don't cancel if the next fill price is 10% worse than the best fill price
|
|
1009
|
+
* @param {bool} [params.responseRequired] Set this to 'false' when only an acknowledgement of success or failure is required, this is faster.
|
|
1010
|
+
* @param {string} [params.clientOrderId] An ID supplied by the client that must be unique among all open orders for the same market
|
|
1011
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1012
|
+
*/
|
|
1013
|
+
await this.loadMarkets();
|
|
1014
|
+
const market = this.market(symbol);
|
|
1015
|
+
const request = {
|
|
1016
|
+
'market': market['id'],
|
|
1017
|
+
'side': side,
|
|
1018
|
+
'orderType': type,
|
|
1019
|
+
};
|
|
1020
|
+
const isMarketOrder = (type === 'market') || (type === 'stopLoss') || (type === 'takeProfit');
|
|
1021
|
+
const isLimitOrder = (type === 'limit') || (type === 'stopLossLimit') || (type === 'takeProfitLimit');
|
|
1022
|
+
const timeInForce = this.safeString(params, 'timeInForce');
|
|
1023
|
+
let triggerPrice = this.safeStringN(params, ['triggerPrice', 'stopPrice', 'triggerAmount']);
|
|
1024
|
+
const postOnly = this.isPostOnly(isMarketOrder, false, params);
|
|
1025
|
+
const stopLossPrice = this.safeValue(params, 'stopLossPrice'); // trigger when price crosses from above to below this value
|
|
1026
|
+
const takeProfitPrice = this.safeValue(params, 'takeProfitPrice'); // trigger when price crosses from below to above this value
|
|
1027
|
+
params = this.omit(params, ['timeInForce', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice']);
|
|
1028
|
+
if (isMarketOrder) {
|
|
1029
|
+
let cost = undefined;
|
|
1030
|
+
if (price !== undefined) {
|
|
1031
|
+
const priceString = this.numberToString(price);
|
|
1032
|
+
const amountString = this.numberToString(amount);
|
|
1033
|
+
const quoteAmount = Precise["default"].stringMul(amountString, priceString);
|
|
1034
|
+
cost = this.parseNumber(quoteAmount);
|
|
1035
|
+
}
|
|
1036
|
+
else {
|
|
1037
|
+
cost = this.safeNumber(params, 'cost');
|
|
1038
|
+
}
|
|
1039
|
+
if (cost !== undefined) {
|
|
1040
|
+
const precision = this.currency(market['quote'])['precision'];
|
|
1041
|
+
request['amountQuote'] = this.decimalToPrecision(cost, number.TRUNCATE, precision, this.precisionMode);
|
|
1042
|
+
}
|
|
1043
|
+
else {
|
|
1044
|
+
request['amount'] = this.amountToPrecision(symbol, amount);
|
|
1045
|
+
}
|
|
1046
|
+
params = this.omit(params, ['cost']);
|
|
1047
|
+
}
|
|
1048
|
+
else if (isLimitOrder) {
|
|
1049
|
+
request['price'] = this.priceToPrecision(symbol, price);
|
|
1050
|
+
request['amount'] = this.amountToPrecision(symbol, amount);
|
|
1051
|
+
}
|
|
1052
|
+
const isTakeProfit = (takeProfitPrice !== undefined) || (type === 'takeProfit') || (type === 'takeProfitLimit');
|
|
1053
|
+
const isStopLoss = (stopLossPrice !== undefined) || (triggerPrice !== undefined) && (!isTakeProfit) || (type === 'stopLoss') || (type === 'stopLossLimit');
|
|
1054
|
+
if (isStopLoss) {
|
|
1055
|
+
if (stopLossPrice !== undefined) {
|
|
1056
|
+
triggerPrice = stopLossPrice;
|
|
1057
|
+
}
|
|
1058
|
+
request['orderType'] = isMarketOrder ? 'stopLoss' : 'stopLossLimit';
|
|
1059
|
+
}
|
|
1060
|
+
else if (isTakeProfit) {
|
|
1061
|
+
if (takeProfitPrice !== undefined) {
|
|
1062
|
+
triggerPrice = takeProfitPrice;
|
|
1063
|
+
}
|
|
1064
|
+
request['orderType'] = isMarketOrder ? 'takeProfit' : 'takeProfitLimit';
|
|
1065
|
+
}
|
|
1066
|
+
if (triggerPrice !== undefined) {
|
|
1067
|
+
request['triggerAmount'] = this.priceToPrecision(symbol, triggerPrice);
|
|
1068
|
+
request['triggerType'] = 'price';
|
|
1069
|
+
request['triggerReference'] = 'lastTrade'; // 'bestBid', 'bestAsk', 'midPrice'
|
|
1070
|
+
}
|
|
1071
|
+
if ((timeInForce !== undefined) && (timeInForce !== 'PO')) {
|
|
1072
|
+
request['timeInForce'] = timeInForce;
|
|
1073
|
+
}
|
|
1074
|
+
if (postOnly) {
|
|
1075
|
+
request['postOnly'] = true;
|
|
1076
|
+
}
|
|
1077
|
+
const response = await this.privatePostOrder(this.extend(request, params));
|
|
1078
|
+
//
|
|
1079
|
+
// {
|
|
1080
|
+
// "orderId":"dec6a640-5b4c-45bc-8d22-3b41c6716630",
|
|
1081
|
+
// "market":"DOGE-EUR",
|
|
1082
|
+
// "created":1654789135146,
|
|
1083
|
+
// "updated":1654789135153,
|
|
1084
|
+
// "status":"new",
|
|
1085
|
+
// "side":"buy",
|
|
1086
|
+
// "orderType":"stopLossLimit",
|
|
1087
|
+
// "amount":"200",
|
|
1088
|
+
// "amountRemaining":"200",
|
|
1089
|
+
// "price":"0.07471",
|
|
1090
|
+
// "triggerPrice":"0.0747",
|
|
1091
|
+
// "triggerAmount":"0.0747",
|
|
1092
|
+
// "triggerType":"price",
|
|
1093
|
+
// "triggerReference":"lastTrade",
|
|
1094
|
+
// "onHold":"14.98",
|
|
1095
|
+
// "onHoldCurrency":"EUR",
|
|
1096
|
+
// "filledAmount":"0",
|
|
1097
|
+
// "filledAmountQuote":"0",
|
|
1098
|
+
// "feePaid":"0",
|
|
1099
|
+
// "feeCurrency":"EUR",
|
|
1100
|
+
// "fills":[ // filled with market orders only
|
|
1101
|
+
// {
|
|
1102
|
+
// "id":"b0c86aa5-6ed3-4a2d-ba3a-be9a964220f4",
|
|
1103
|
+
// "timestamp":1590505649245,
|
|
1104
|
+
// "amount":"0.249825",
|
|
1105
|
+
// "price":"183.49",
|
|
1106
|
+
// "taker":true,
|
|
1107
|
+
// "fee":"0.12038925",
|
|
1108
|
+
// "feeCurrency":"EUR",
|
|
1109
|
+
// "settled":true
|
|
1110
|
+
// }
|
|
1111
|
+
// ],
|
|
1112
|
+
// "selfTradePrevention":"decrementAndCancel",
|
|
1113
|
+
// "visible":true,
|
|
1114
|
+
// "timeInForce":"GTC",
|
|
1115
|
+
// "postOnly":false
|
|
1116
|
+
// }
|
|
1117
|
+
//
|
|
1118
|
+
return this.parseOrder(response, market);
|
|
1119
|
+
}
|
|
1120
|
+
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
1121
|
+
/**
|
|
1122
|
+
* @method
|
|
1123
|
+
* @name bitvavo#editOrder
|
|
1124
|
+
* @description edit a trade order
|
|
1125
|
+
* @see https://docs.bitvavo.com/#tag/Trading-endpoints/paths/~1order/put
|
|
1126
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
1127
|
+
* @param {string} type 'market' or 'limit'
|
|
1128
|
+
* @param {string} side 'buy' or 'sell'
|
|
1129
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
1130
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
1131
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1132
|
+
* @param {string} [params.timeInForce] "GTC", "IOC", or "PO"
|
|
1133
|
+
* @param {bool} [params.postOnly] If true, the order will only be posted to the order book and not executed immediately
|
|
1134
|
+
* @param {float} [params.stopPrice] The price at which a trigger order is triggered at
|
|
1135
|
+
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
|
|
1136
|
+
* @param {string} [params.selfTradePrevention] "decrementAndCancel", "cancelOldest", "cancelNewest", "cancelBoth"
|
|
1137
|
+
* @param {bool} [params.responseRequired] Set this to 'false' when only an acknowledgement of success or failure is required, this is faster.
|
|
1138
|
+
* @param {string} [params.clientOrderId] An ID supplied by the client
|
|
1139
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1140
|
+
*/
|
|
1141
|
+
await this.loadMarkets();
|
|
1142
|
+
const market = this.market(symbol);
|
|
1143
|
+
const request = {
|
|
1144
|
+
'market': market['id'],
|
|
1145
|
+
};
|
|
1146
|
+
const clientOrderId = this.safeString(params, 'clientOrderId');
|
|
1147
|
+
if (clientOrderId === undefined) {
|
|
1148
|
+
request['orderId'] = id;
|
|
1149
|
+
}
|
|
1150
|
+
const amountRemaining = this.safeNumber(params, 'amountRemaining');
|
|
1151
|
+
const triggerPrice = this.safeStringN(params, ['triggerPrice', 'stopPrice', 'triggerAmount']);
|
|
1152
|
+
params = this.omit(params, ['amountRemaining', 'triggerPrice', 'stopPrice', 'triggerAmount']);
|
|
1153
|
+
let updateRequest = {};
|
|
1154
|
+
if (price !== undefined) {
|
|
1155
|
+
updateRequest['price'] = this.priceToPrecision(symbol, price);
|
|
1156
|
+
}
|
|
1157
|
+
if (amount !== undefined) {
|
|
1158
|
+
updateRequest['amount'] = this.amountToPrecision(symbol, amount);
|
|
1159
|
+
}
|
|
1160
|
+
if (amountRemaining !== undefined) {
|
|
1161
|
+
updateRequest['amountRemaining'] = this.amountToPrecision(symbol, amountRemaining);
|
|
1162
|
+
}
|
|
1163
|
+
if (triggerPrice !== undefined) {
|
|
1164
|
+
updateRequest['triggerAmount'] = this.priceToPrecision(symbol, triggerPrice);
|
|
1165
|
+
}
|
|
1166
|
+
updateRequest = this.extend(updateRequest, params);
|
|
1167
|
+
if (Object.keys(updateRequest).length) {
|
|
1168
|
+
const response = await this.privatePutOrder(this.extend(request, updateRequest));
|
|
1169
|
+
return this.parseOrder(response, market);
|
|
1170
|
+
}
|
|
1171
|
+
else {
|
|
1172
|
+
throw new errors.ArgumentsRequired(this.id + ' editOrder() requires an amount argument, or a price argument, or non-empty params');
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
1176
|
+
/**
|
|
1177
|
+
* @method
|
|
1178
|
+
* @name bitvavo#cancelOrder
|
|
1179
|
+
* @description cancels an open order
|
|
1180
|
+
* @see https://docs.bitvavo.com/#tag/Trading-endpoints/paths/~1order/delete
|
|
1181
|
+
* @param {string} id order id
|
|
1182
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
1183
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1184
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1185
|
+
*/
|
|
1186
|
+
if (symbol === undefined) {
|
|
1187
|
+
throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
|
|
1188
|
+
}
|
|
1189
|
+
await this.loadMarkets();
|
|
1190
|
+
const market = this.market(symbol);
|
|
1191
|
+
const request = {
|
|
1192
|
+
'market': market['id'],
|
|
1193
|
+
};
|
|
1194
|
+
const clientOrderId = this.safeString(params, 'clientOrderId');
|
|
1195
|
+
if (clientOrderId === undefined) {
|
|
1196
|
+
request['orderId'] = id;
|
|
1197
|
+
}
|
|
1198
|
+
const response = await this.privateDeleteOrder(this.extend(request, params));
|
|
1199
|
+
//
|
|
1200
|
+
// {
|
|
1201
|
+
// "orderId": "2e7ce7fc-44e2-4d80-a4a7-d079c4750b61"
|
|
1202
|
+
// }
|
|
1203
|
+
//
|
|
1204
|
+
return this.parseOrder(response, market);
|
|
1205
|
+
}
|
|
1206
|
+
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
1207
|
+
/**
|
|
1208
|
+
* @method
|
|
1209
|
+
* @name bitvavo#cancelAllOrders
|
|
1210
|
+
* @description cancel all open orders
|
|
1211
|
+
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
1212
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1213
|
+
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1214
|
+
*/
|
|
1215
|
+
await this.loadMarkets();
|
|
1216
|
+
const request = {};
|
|
1217
|
+
let market = undefined;
|
|
1218
|
+
if (symbol !== undefined) {
|
|
1219
|
+
market = this.market(symbol);
|
|
1220
|
+
request['market'] = market['id'];
|
|
1221
|
+
}
|
|
1222
|
+
const response = await this.privateDeleteOrders(this.extend(request, params));
|
|
1223
|
+
//
|
|
1224
|
+
// [
|
|
1225
|
+
// {
|
|
1226
|
+
// "orderId": "1be6d0df-d5dc-4b53-a250-3376f3b393e6"
|
|
1227
|
+
// }
|
|
1228
|
+
// ]
|
|
1229
|
+
//
|
|
1230
|
+
return this.parseOrders(response, market);
|
|
1231
|
+
}
|
|
1232
|
+
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
1233
|
+
/**
|
|
1234
|
+
* @method
|
|
1235
|
+
* @name bitvavo#fetchOrder
|
|
1236
|
+
* @description fetches information on an order made by the user
|
|
1237
|
+
* @see https://docs.bitvavo.com/#tag/Trading-endpoints/paths/~1order/get
|
|
1238
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
1239
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1240
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1241
|
+
*/
|
|
1242
|
+
if (symbol === undefined) {
|
|
1243
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
|
|
1244
|
+
}
|
|
1245
|
+
await this.loadMarkets();
|
|
1246
|
+
const market = this.market(symbol);
|
|
1247
|
+
const request = {
|
|
1248
|
+
'market': market['id'],
|
|
1249
|
+
};
|
|
1250
|
+
const clientOrderId = this.safeString(params, 'clientOrderId');
|
|
1251
|
+
if (clientOrderId === undefined) {
|
|
1252
|
+
request['orderId'] = id;
|
|
1253
|
+
}
|
|
1254
|
+
const response = await this.privateGetOrder(this.extend(request, params));
|
|
1255
|
+
//
|
|
1256
|
+
// {
|
|
1257
|
+
// "orderId":"af76d6ce-9f7c-4006-b715-bb5d430652d0",
|
|
1258
|
+
// "market":"ETH-EUR",
|
|
1259
|
+
// "created":1590505649241,
|
|
1260
|
+
// "updated":1590505649241,
|
|
1261
|
+
// "status":"filled",
|
|
1262
|
+
// "side":"sell",
|
|
1263
|
+
// "orderType":"market",
|
|
1264
|
+
// "amount":"0.249825",
|
|
1265
|
+
// "amountRemaining":"0",
|
|
1266
|
+
// "onHold":"0",
|
|
1267
|
+
// "onHoldCurrency":"ETH",
|
|
1268
|
+
// "filledAmount":"0.249825",
|
|
1269
|
+
// "filledAmountQuote":"45.84038925",
|
|
1270
|
+
// "feePaid":"0.12038925",
|
|
1271
|
+
// "feeCurrency":"EUR",
|
|
1272
|
+
// "fills":[
|
|
1273
|
+
// {
|
|
1274
|
+
// "id":"b0c86aa5-6ed3-4a2d-ba3a-be9a964220f4",
|
|
1275
|
+
// "timestamp":1590505649245,
|
|
1276
|
+
// "amount":"0.249825",
|
|
1277
|
+
// "price":"183.49",
|
|
1278
|
+
// "taker":true,
|
|
1279
|
+
// "fee":"0.12038925",
|
|
1280
|
+
// "feeCurrency":"EUR",
|
|
1281
|
+
// "settled":true
|
|
1282
|
+
// }
|
|
1283
|
+
// ],
|
|
1284
|
+
// "selfTradePrevention":"decrementAndCancel",
|
|
1285
|
+
// "visible":false,
|
|
1286
|
+
// "disableMarketProtection":false
|
|
1287
|
+
// }
|
|
1288
|
+
//
|
|
1289
|
+
return this.parseOrder(response, market);
|
|
1290
|
+
}
|
|
1291
|
+
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1292
|
+
/**
|
|
1293
|
+
* @method
|
|
1294
|
+
* @name bitvavo#fetchOrders
|
|
1295
|
+
* @see https://docs.bitvavo.com/#tag/Trading-endpoints/paths/~1orders/get
|
|
1296
|
+
* @description fetches information on multiple orders made by the user
|
|
1297
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
1298
|
+
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
1299
|
+
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
1300
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1301
|
+
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
1302
|
+
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
1303
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1304
|
+
*/
|
|
1305
|
+
if (symbol === undefined) {
|
|
1306
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchOrders() requires a symbol argument');
|
|
1307
|
+
}
|
|
1308
|
+
await this.loadMarkets();
|
|
1309
|
+
let paginate = false;
|
|
1310
|
+
[paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate');
|
|
1311
|
+
if (paginate) {
|
|
1312
|
+
return await this.fetchPaginatedCallDynamic('fetchOrders', symbol, since, limit, params);
|
|
1313
|
+
}
|
|
1314
|
+
const market = this.market(symbol);
|
|
1315
|
+
let request = {
|
|
1316
|
+
'market': market['id'],
|
|
1317
|
+
// "limit": 500,
|
|
1318
|
+
// "start": since,
|
|
1319
|
+
// "end": this.milliseconds (),
|
|
1320
|
+
// "orderIdFrom": "af76d6ce-9f7c-4006-b715-bb5d430652d0",
|
|
1321
|
+
// "orderIdTo": "af76d6ce-9f7c-4006-b715-bb5d430652d0",
|
|
1322
|
+
};
|
|
1323
|
+
if (since !== undefined) {
|
|
1324
|
+
request['start'] = since;
|
|
1325
|
+
}
|
|
1326
|
+
if (limit !== undefined) {
|
|
1327
|
+
request['limit'] = limit; // default 500, max 1000
|
|
1328
|
+
}
|
|
1329
|
+
[request, params] = this.handleUntilOption('end', request, params);
|
|
1330
|
+
const response = await this.privateGetOrders(this.extend(request, params));
|
|
1331
|
+
//
|
|
1332
|
+
// [
|
|
1333
|
+
// {
|
|
1334
|
+
// "orderId":"af76d6ce-9f7c-4006-b715-bb5d430652d0",
|
|
1335
|
+
// "market":"ETH-EUR",
|
|
1336
|
+
// "created":1590505649241,
|
|
1337
|
+
// "updated":1590505649241,
|
|
1338
|
+
// "status":"filled",
|
|
1339
|
+
// "side":"sell",
|
|
1340
|
+
// "orderType":"market",
|
|
1341
|
+
// "amount":"0.249825",
|
|
1342
|
+
// "amountRemaining":"0",
|
|
1343
|
+
// "onHold":"0",
|
|
1344
|
+
// "onHoldCurrency":"ETH",
|
|
1345
|
+
// "filledAmount":"0.249825",
|
|
1346
|
+
// "filledAmountQuote":"45.84038925",
|
|
1347
|
+
// "feePaid":"0.12038925",
|
|
1348
|
+
// "feeCurrency":"EUR",
|
|
1349
|
+
// "fills":[
|
|
1350
|
+
// {
|
|
1351
|
+
// "id":"b0c86aa5-6ed3-4a2d-ba3a-be9a964220f4",
|
|
1352
|
+
// "timestamp":1590505649245,
|
|
1353
|
+
// "amount":"0.249825",
|
|
1354
|
+
// "price":"183.49",
|
|
1355
|
+
// "taker":true,
|
|
1356
|
+
// "fee":"0.12038925",
|
|
1357
|
+
// "feeCurrency":"EUR",
|
|
1358
|
+
// "settled":true
|
|
1359
|
+
// }
|
|
1360
|
+
// ],
|
|
1361
|
+
// "selfTradePrevention":"decrementAndCancel",
|
|
1362
|
+
// "visible":false,
|
|
1363
|
+
// "disableMarketProtection":false
|
|
1364
|
+
// }
|
|
1365
|
+
// ]
|
|
1366
|
+
//
|
|
1367
|
+
return this.parseOrders(response, market, since, limit);
|
|
1368
|
+
}
|
|
1369
|
+
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1370
|
+
/**
|
|
1371
|
+
* @method
|
|
1372
|
+
* @name bitvavo#fetchOpenOrders
|
|
1373
|
+
* @description fetch all unfilled currently open orders
|
|
1374
|
+
* @param {string} symbol unified market symbol
|
|
1375
|
+
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
1376
|
+
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
1377
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1378
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1379
|
+
*/
|
|
1380
|
+
await this.loadMarkets();
|
|
1381
|
+
const request = {
|
|
1382
|
+
// "market": market["id"], // rate limit 25 without a market, 1 with market specified
|
|
1383
|
+
};
|
|
1384
|
+
let market = undefined;
|
|
1385
|
+
if (symbol !== undefined) {
|
|
1386
|
+
market = this.market(symbol);
|
|
1387
|
+
request['market'] = market['id'];
|
|
1388
|
+
}
|
|
1389
|
+
const response = await this.privateGetOrdersOpen(this.extend(request, params));
|
|
1390
|
+
//
|
|
1391
|
+
// [
|
|
1392
|
+
// {
|
|
1393
|
+
// "orderId":"af76d6ce-9f7c-4006-b715-bb5d430652d0",
|
|
1394
|
+
// "market":"ETH-EUR",
|
|
1395
|
+
// "created":1590505649241,
|
|
1396
|
+
// "updated":1590505649241,
|
|
1397
|
+
// "status":"filled",
|
|
1398
|
+
// "side":"sell",
|
|
1399
|
+
// "orderType":"market",
|
|
1400
|
+
// "amount":"0.249825",
|
|
1401
|
+
// "amountRemaining":"0",
|
|
1402
|
+
// "onHold":"0",
|
|
1403
|
+
// "onHoldCurrency":"ETH",
|
|
1404
|
+
// "filledAmount":"0.249825",
|
|
1405
|
+
// "filledAmountQuote":"45.84038925",
|
|
1406
|
+
// "feePaid":"0.12038925",
|
|
1407
|
+
// "feeCurrency":"EUR",
|
|
1408
|
+
// "fills":[
|
|
1409
|
+
// {
|
|
1410
|
+
// "id":"b0c86aa5-6ed3-4a2d-ba3a-be9a964220f4",
|
|
1411
|
+
// "timestamp":1590505649245,
|
|
1412
|
+
// "amount":"0.249825",
|
|
1413
|
+
// "price":"183.49",
|
|
1414
|
+
// "taker":true,
|
|
1415
|
+
// "fee":"0.12038925",
|
|
1416
|
+
// "feeCurrency":"EUR",
|
|
1417
|
+
// "settled":true
|
|
1418
|
+
// }
|
|
1419
|
+
// ],
|
|
1420
|
+
// "selfTradePrevention":"decrementAndCancel",
|
|
1421
|
+
// "visible":false,
|
|
1422
|
+
// "disableMarketProtection":false
|
|
1423
|
+
// }
|
|
1424
|
+
// ]
|
|
1425
|
+
//
|
|
1426
|
+
return this.parseOrders(response, market, since, limit);
|
|
1427
|
+
}
|
|
1428
|
+
parseOrderStatus(status) {
|
|
1429
|
+
const statuses = {
|
|
1430
|
+
'new': 'open',
|
|
1431
|
+
'canceled': 'canceled',
|
|
1432
|
+
'canceledAuction': 'canceled',
|
|
1433
|
+
'canceledSelfTradePrevention': 'canceled',
|
|
1434
|
+
'canceledIOC': 'canceled',
|
|
1435
|
+
'canceledFOK': 'canceled',
|
|
1436
|
+
'canceledMarketProtection': 'canceled',
|
|
1437
|
+
'canceledPostOnly': 'canceled',
|
|
1438
|
+
'filled': 'closed',
|
|
1439
|
+
'partiallyFilled': 'open',
|
|
1440
|
+
'expired': 'canceled',
|
|
1441
|
+
'rejected': 'canceled',
|
|
1442
|
+
'awaitingTrigger': 'open', // https://github.com/ccxt/ccxt/issues/8489
|
|
1443
|
+
};
|
|
1444
|
+
return this.safeString(statuses, status, status);
|
|
1445
|
+
}
|
|
1446
|
+
parseOrder(order, market = undefined) {
|
|
1447
|
+
//
|
|
1448
|
+
// cancelOrder, cancelAllOrders
|
|
1449
|
+
//
|
|
1450
|
+
// {
|
|
1451
|
+
// "orderId": "2e7ce7fc-44e2-4d80-a4a7-d079c4750b61"
|
|
1452
|
+
// }
|
|
1453
|
+
//
|
|
1454
|
+
// createOrder, fetchOrder, fetchOpenOrders, fetchOrders, editOrder
|
|
1455
|
+
//
|
|
1456
|
+
// {
|
|
1457
|
+
// "orderId":"af76d6ce-9f7c-4006-b715-bb5d430652d0",
|
|
1458
|
+
// "market":"ETH-EUR",
|
|
1459
|
+
// "created":1590505649241,
|
|
1460
|
+
// "updated":1590505649241,
|
|
1461
|
+
// "status":"filled",
|
|
1462
|
+
// "side":"sell",
|
|
1463
|
+
// "orderType":"market",
|
|
1464
|
+
// "amount":"0.249825",
|
|
1465
|
+
// "amountRemaining":"0",
|
|
1466
|
+
// "price": "183.49", // limit orders only
|
|
1467
|
+
// "onHold":"0",
|
|
1468
|
+
// "onHoldCurrency":"ETH",
|
|
1469
|
+
// "filledAmount":"0.249825",
|
|
1470
|
+
// "filledAmountQuote":"45.84038925",
|
|
1471
|
+
// "feePaid":"0.12038925",
|
|
1472
|
+
// "feeCurrency":"EUR",
|
|
1473
|
+
// "fills":[
|
|
1474
|
+
// {
|
|
1475
|
+
// "id":"b0c86aa5-6ed3-4a2d-ba3a-be9a964220f4",
|
|
1476
|
+
// "timestamp":1590505649245,
|
|
1477
|
+
// "amount":"0.249825",
|
|
1478
|
+
// "price":"183.49",
|
|
1479
|
+
// "taker":true,
|
|
1480
|
+
// "fee":"0.12038925",
|
|
1481
|
+
// "feeCurrency":"EUR",
|
|
1482
|
+
// "settled":true
|
|
1483
|
+
// }
|
|
1484
|
+
// ],
|
|
1485
|
+
// "selfTradePrevention":"decrementAndCancel",
|
|
1486
|
+
// "visible":false,
|
|
1487
|
+
// "disableMarketProtection":false
|
|
1488
|
+
// "timeInForce": "GTC",
|
|
1489
|
+
// "postOnly": true,
|
|
1490
|
+
// }
|
|
1491
|
+
//
|
|
1492
|
+
const id = this.safeString(order, 'orderId');
|
|
1493
|
+
const timestamp = this.safeInteger(order, 'created');
|
|
1494
|
+
const marketId = this.safeString(order, 'market');
|
|
1495
|
+
market = this.safeMarket(marketId, market, '-');
|
|
1496
|
+
const symbol = market['symbol'];
|
|
1497
|
+
const status = this.parseOrderStatus(this.safeString(order, 'status'));
|
|
1498
|
+
const side = this.safeString(order, 'side');
|
|
1499
|
+
const type = this.safeString(order, 'orderType');
|
|
1500
|
+
const price = this.safeString(order, 'price');
|
|
1501
|
+
const amount = this.safeString(order, 'amount');
|
|
1502
|
+
const remaining = this.safeString(order, 'amountRemaining');
|
|
1503
|
+
const filled = this.safeString(order, 'filledAmount');
|
|
1504
|
+
let cost = this.safeString(order, 'filledAmountQuote');
|
|
1505
|
+
if (cost === undefined) {
|
|
1506
|
+
const amountQuote = this.safeString(order, 'amountQuote');
|
|
1507
|
+
const amountQuoteRemaining = this.safeString(order, 'amountQuoteRemaining');
|
|
1508
|
+
cost = Precise["default"].stringSub(amountQuote, amountQuoteRemaining);
|
|
1509
|
+
}
|
|
1510
|
+
let fee = undefined;
|
|
1511
|
+
const feeCost = this.safeNumber(order, 'feePaid');
|
|
1512
|
+
if (feeCost !== undefined) {
|
|
1513
|
+
const feeCurrencyId = this.safeString(order, 'feeCurrency');
|
|
1514
|
+
const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
|
|
1515
|
+
fee = {
|
|
1516
|
+
'cost': feeCost,
|
|
1517
|
+
'currency': feeCurrencyCode,
|
|
1518
|
+
};
|
|
1519
|
+
}
|
|
1520
|
+
const rawTrades = this.safeValue(order, 'fills', []);
|
|
1521
|
+
const timeInForce = this.safeString(order, 'timeInForce');
|
|
1522
|
+
const postOnly = this.safeValue(order, 'postOnly');
|
|
1523
|
+
// https://github.com/ccxt/ccxt/issues/8489
|
|
1524
|
+
const stopPrice = this.safeNumber(order, 'triggerPrice');
|
|
1525
|
+
return this.safeOrder({
|
|
1526
|
+
'info': order,
|
|
1527
|
+
'id': id,
|
|
1528
|
+
'clientOrderId': undefined,
|
|
1529
|
+
'timestamp': timestamp,
|
|
1530
|
+
'datetime': this.iso8601(timestamp),
|
|
1531
|
+
'lastTradeTimestamp': undefined,
|
|
1532
|
+
'symbol': symbol,
|
|
1533
|
+
'type': type,
|
|
1534
|
+
'timeInForce': timeInForce,
|
|
1535
|
+
'postOnly': postOnly,
|
|
1536
|
+
'side': side,
|
|
1537
|
+
'price': price,
|
|
1538
|
+
'stopPrice': stopPrice,
|
|
1539
|
+
'triggerPrice': stopPrice,
|
|
1540
|
+
'amount': amount,
|
|
1541
|
+
'cost': cost,
|
|
1542
|
+
'average': undefined,
|
|
1543
|
+
'filled': filled,
|
|
1544
|
+
'remaining': remaining,
|
|
1545
|
+
'status': status,
|
|
1546
|
+
'fee': fee,
|
|
1547
|
+
'trades': rawTrades,
|
|
1548
|
+
}, market);
|
|
1549
|
+
}
|
|
1550
|
+
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1551
|
+
/**
|
|
1552
|
+
* @method
|
|
1553
|
+
* @name bitvavo#fetchMyTrades
|
|
1554
|
+
* @see https://docs.bitvavo.com/#tag/Trades/paths/~1trades/get
|
|
1555
|
+
* @description fetch all trades made by the user
|
|
1556
|
+
* @param {string} symbol unified market symbol
|
|
1557
|
+
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
1558
|
+
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
1559
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1560
|
+
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
1561
|
+
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
1562
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
1563
|
+
*/
|
|
1564
|
+
if (symbol === undefined) {
|
|
1565
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
|
|
1566
|
+
}
|
|
1567
|
+
await this.loadMarkets();
|
|
1568
|
+
let paginate = false;
|
|
1569
|
+
[paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
|
|
1570
|
+
if (paginate) {
|
|
1571
|
+
return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params);
|
|
1572
|
+
}
|
|
1573
|
+
const market = this.market(symbol);
|
|
1574
|
+
let request = {
|
|
1575
|
+
'market': market['id'],
|
|
1576
|
+
// "limit": 500,
|
|
1577
|
+
// "start": since,
|
|
1578
|
+
// "end": this.milliseconds (),
|
|
1579
|
+
// "tradeIdFrom": "af76d6ce-9f7c-4006-b715-bb5d430652d0",
|
|
1580
|
+
// "tradeIdTo": "af76d6ce-9f7c-4006-b715-bb5d430652d0",
|
|
1581
|
+
};
|
|
1582
|
+
if (since !== undefined) {
|
|
1583
|
+
request['start'] = since;
|
|
1584
|
+
}
|
|
1585
|
+
if (limit !== undefined) {
|
|
1586
|
+
request['limit'] = limit; // default 500, max 1000
|
|
1587
|
+
}
|
|
1588
|
+
[request, params] = this.handleUntilOption('end', request, params);
|
|
1589
|
+
const response = await this.privateGetTrades(this.extend(request, params));
|
|
1590
|
+
//
|
|
1591
|
+
// [
|
|
1592
|
+
// {
|
|
1593
|
+
// "id":"b0c86aa5-6ed3-4a2d-ba3a-be9a964220f4",
|
|
1594
|
+
// "orderId":"af76d6ce-9f7c-4006-b715-bb5d430652d0",
|
|
1595
|
+
// "timestamp":1590505649245,
|
|
1596
|
+
// "market":"ETH-EUR",
|
|
1597
|
+
// "side":"sell",
|
|
1598
|
+
// "amount":"0.249825",
|
|
1599
|
+
// "price":"183.49",
|
|
1600
|
+
// "taker":true,
|
|
1601
|
+
// "fee":"0.12038925",
|
|
1602
|
+
// "feeCurrency":"EUR",
|
|
1603
|
+
// "settled":true
|
|
1604
|
+
// }
|
|
1605
|
+
// ]
|
|
1606
|
+
//
|
|
1607
|
+
return this.parseTrades(response, market, since, limit);
|
|
1608
|
+
}
|
|
1609
|
+
async withdraw(code, amount, address, tag = undefined, params = {}) {
|
|
1610
|
+
/**
|
|
1611
|
+
* @method
|
|
1612
|
+
* @name bitvavo#withdraw
|
|
1613
|
+
* @description make a withdrawal
|
|
1614
|
+
* @param {string} code unified currency code
|
|
1615
|
+
* @param {float} amount the amount to withdraw
|
|
1616
|
+
* @param {string} address the address to withdraw to
|
|
1617
|
+
* @param {string} tag
|
|
1618
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1619
|
+
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1620
|
+
*/
|
|
1621
|
+
[tag, params] = this.handleWithdrawTagAndParams(tag, params);
|
|
1622
|
+
this.checkAddress(address);
|
|
1623
|
+
await this.loadMarkets();
|
|
1624
|
+
const currency = this.currency(code);
|
|
1625
|
+
const request = {
|
|
1626
|
+
'symbol': currency['id'],
|
|
1627
|
+
'amount': this.currencyToPrecision(code, amount),
|
|
1628
|
+
'address': address, // address or IBAN
|
|
1629
|
+
// "internal": false, // transfer to another Bitvavo user address, no fees
|
|
1630
|
+
// "addWithdrawalFee": false, // true = add the fee on top, otherwise the fee is subtracted from the amount
|
|
1631
|
+
};
|
|
1632
|
+
if (tag !== undefined) {
|
|
1633
|
+
request['paymentId'] = tag;
|
|
1634
|
+
}
|
|
1635
|
+
const response = await this.privatePostWithdrawal(this.extend(request, params));
|
|
1636
|
+
//
|
|
1637
|
+
// {
|
|
1638
|
+
// "success": true,
|
|
1639
|
+
// "symbol": "BTC",
|
|
1640
|
+
// "amount": "1.5"
|
|
1641
|
+
// }
|
|
1642
|
+
//
|
|
1643
|
+
return this.parseTransaction(response, currency);
|
|
1644
|
+
}
|
|
1645
|
+
async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1646
|
+
/**
|
|
1647
|
+
* @method
|
|
1648
|
+
* @name bitvavo#fetchWithdrawals
|
|
1649
|
+
* @description fetch all withdrawals made from an account
|
|
1650
|
+
* @param {string} code unified currency code
|
|
1651
|
+
* @param {int} [since] the earliest time in ms to fetch withdrawals for
|
|
1652
|
+
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
|
|
1653
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1654
|
+
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1655
|
+
*/
|
|
1656
|
+
await this.loadMarkets();
|
|
1657
|
+
const request = {
|
|
1658
|
+
// 'symbol': currency['id'],
|
|
1659
|
+
// 'limit': 500, // default 500, max 1000
|
|
1660
|
+
// 'start': since,
|
|
1661
|
+
// 'end': this.milliseconds (),
|
|
1662
|
+
};
|
|
1663
|
+
let currency = undefined;
|
|
1664
|
+
if (code !== undefined) {
|
|
1665
|
+
currency = this.currency(code);
|
|
1666
|
+
request['symbol'] = currency['id'];
|
|
1667
|
+
}
|
|
1668
|
+
if (since !== undefined) {
|
|
1669
|
+
request['start'] = since;
|
|
1670
|
+
}
|
|
1671
|
+
if (limit !== undefined) {
|
|
1672
|
+
request['limit'] = limit; // default 500, max 1000
|
|
1673
|
+
}
|
|
1674
|
+
const response = await this.privateGetWithdrawalHistory(this.extend(request, params));
|
|
1675
|
+
//
|
|
1676
|
+
// [
|
|
1677
|
+
// {
|
|
1678
|
+
// "timestamp":1590531212000,
|
|
1679
|
+
// "symbol":"ETH",
|
|
1680
|
+
// "amount":"0.091",
|
|
1681
|
+
// "fee":"0.009",
|
|
1682
|
+
// "status":"awaiting_bitvavo_inspection",
|
|
1683
|
+
// "address":"0xe42b309f1eE9F0cbf7f54CcF3bc2159eBfA6735b",
|
|
1684
|
+
// "paymentId": "10002653",
|
|
1685
|
+
// "txId": "927b3ea50c5bb52c6854152d305dfa1e27fc01d10464cf10825d96d69d235eb3",
|
|
1686
|
+
// }
|
|
1687
|
+
// ]
|
|
1688
|
+
//
|
|
1689
|
+
return this.parseTransactions(response, currency, since, limit, { 'type': 'withdrawal' });
|
|
1690
|
+
}
|
|
1691
|
+
async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1692
|
+
/**
|
|
1693
|
+
* @method
|
|
1694
|
+
* @name bitvavo#fetchDeposits
|
|
1695
|
+
* @description fetch all deposits made to an account
|
|
1696
|
+
* @param {string} code unified currency code
|
|
1697
|
+
* @param {int} [since] the earliest time in ms to fetch deposits for
|
|
1698
|
+
* @param {int} [limit] the maximum number of deposits structures to retrieve
|
|
1699
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1700
|
+
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1701
|
+
*/
|
|
1702
|
+
await this.loadMarkets();
|
|
1703
|
+
const request = {
|
|
1704
|
+
// 'symbol': currency['id'],
|
|
1705
|
+
// 'limit': 500, // default 500, max 1000
|
|
1706
|
+
// 'start': since,
|
|
1707
|
+
// 'end': this.milliseconds (),
|
|
1708
|
+
};
|
|
1709
|
+
let currency = undefined;
|
|
1710
|
+
if (code !== undefined) {
|
|
1711
|
+
currency = this.currency(code);
|
|
1712
|
+
request['symbol'] = currency['id'];
|
|
1713
|
+
}
|
|
1714
|
+
if (since !== undefined) {
|
|
1715
|
+
request['start'] = since;
|
|
1716
|
+
}
|
|
1717
|
+
if (limit !== undefined) {
|
|
1718
|
+
request['limit'] = limit; // default 500, max 1000
|
|
1719
|
+
}
|
|
1720
|
+
const response = await this.privateGetDepositHistory(this.extend(request, params));
|
|
1721
|
+
//
|
|
1722
|
+
// [
|
|
1723
|
+
// {
|
|
1724
|
+
// "timestamp":1590492401000,
|
|
1725
|
+
// "symbol":"ETH",
|
|
1726
|
+
// "amount":"0.249825",
|
|
1727
|
+
// "fee":"0",
|
|
1728
|
+
// "status":"completed",
|
|
1729
|
+
// "txId":"0x5167b473fd37811f9ef22364c3d54726a859ef9d98934b3a1e11d7baa8d2c2e2"
|
|
1730
|
+
// }
|
|
1731
|
+
// ]
|
|
1732
|
+
//
|
|
1733
|
+
return this.parseTransactions(response, currency, since, limit, { 'type': 'deposit' });
|
|
1734
|
+
}
|
|
1735
|
+
parseTransactionStatus(status) {
|
|
1736
|
+
const statuses = {
|
|
1737
|
+
'awaiting_processing': 'pending',
|
|
1738
|
+
'awaiting_email_confirmation': 'pending',
|
|
1739
|
+
'awaiting_bitvavo_inspection': 'pending',
|
|
1740
|
+
'approved': 'pending',
|
|
1741
|
+
'sending': 'pending',
|
|
1742
|
+
'in_mempool': 'pending',
|
|
1743
|
+
'processed': 'pending',
|
|
1744
|
+
'completed': 'ok',
|
|
1745
|
+
'canceled': 'canceled',
|
|
1746
|
+
};
|
|
1747
|
+
return this.safeString(statuses, status, status);
|
|
1748
|
+
}
|
|
1749
|
+
parseTransaction(transaction, currency = undefined) {
|
|
1750
|
+
//
|
|
1751
|
+
// withdraw
|
|
1752
|
+
//
|
|
1753
|
+
// {
|
|
1754
|
+
// "success": true,
|
|
1755
|
+
// "symbol": "BTC",
|
|
1756
|
+
// "amount": "1.5"
|
|
1757
|
+
// }
|
|
1758
|
+
//
|
|
1759
|
+
// fetchWithdrawals
|
|
1760
|
+
//
|
|
1761
|
+
// {
|
|
1762
|
+
// "timestamp": 1542967486256,
|
|
1763
|
+
// "symbol": "BTC",
|
|
1764
|
+
// "amount": "0.99994",
|
|
1765
|
+
// "address": "BitcoinAddress",
|
|
1766
|
+
// "paymentId": "10002653",
|
|
1767
|
+
// "txId": "927b3ea50c5bb52c6854152d305dfa1e27fc01d10464cf10825d96d69d235eb3",
|
|
1768
|
+
// "fee": "0.00006",
|
|
1769
|
+
// "status": "awaiting_processing"
|
|
1770
|
+
// }
|
|
1771
|
+
//
|
|
1772
|
+
// fetchDeposits
|
|
1773
|
+
//
|
|
1774
|
+
// {
|
|
1775
|
+
// "timestamp":1590492401000,
|
|
1776
|
+
// "symbol":"ETH",
|
|
1777
|
+
// "amount":"0.249825",
|
|
1778
|
+
// "fee":"0",
|
|
1779
|
+
// "status":"completed",
|
|
1780
|
+
// "txId":"0x5167b473fd37811f9ef22364c3d54726a859ef9d98934b3a1e11d7baa8d2c2e2"
|
|
1781
|
+
// }
|
|
1782
|
+
//
|
|
1783
|
+
const id = undefined;
|
|
1784
|
+
const timestamp = this.safeInteger(transaction, 'timestamp');
|
|
1785
|
+
const currencyId = this.safeString(transaction, 'symbol');
|
|
1786
|
+
const code = this.safeCurrencyCode(currencyId, currency);
|
|
1787
|
+
const status = this.parseTransactionStatus(this.safeString(transaction, 'status'));
|
|
1788
|
+
const amount = this.safeNumber(transaction, 'amount');
|
|
1789
|
+
const address = this.safeString(transaction, 'address');
|
|
1790
|
+
const txid = this.safeString(transaction, 'txId');
|
|
1791
|
+
let fee = undefined;
|
|
1792
|
+
const feeCost = this.safeNumber(transaction, 'fee');
|
|
1793
|
+
if (feeCost !== undefined) {
|
|
1794
|
+
fee = {
|
|
1795
|
+
'cost': feeCost,
|
|
1796
|
+
'currency': code,
|
|
1797
|
+
};
|
|
1798
|
+
}
|
|
1799
|
+
let type = undefined;
|
|
1800
|
+
if (('success' in transaction) || ('address' in transaction)) {
|
|
1801
|
+
type = 'withdrawal';
|
|
1802
|
+
}
|
|
1803
|
+
else {
|
|
1804
|
+
type = 'deposit';
|
|
1805
|
+
}
|
|
1806
|
+
const tag = this.safeString(transaction, 'paymentId');
|
|
1807
|
+
return {
|
|
1808
|
+
'info': transaction,
|
|
1809
|
+
'id': id,
|
|
1810
|
+
'txid': txid,
|
|
1811
|
+
'timestamp': timestamp,
|
|
1812
|
+
'datetime': this.iso8601(timestamp),
|
|
1813
|
+
'addressFrom': undefined,
|
|
1814
|
+
'address': address,
|
|
1815
|
+
'addressTo': address,
|
|
1816
|
+
'tagFrom': undefined,
|
|
1817
|
+
'tag': tag,
|
|
1818
|
+
'tagTo': tag,
|
|
1819
|
+
'type': type,
|
|
1820
|
+
'amount': amount,
|
|
1821
|
+
'currency': code,
|
|
1822
|
+
'status': status,
|
|
1823
|
+
'updated': undefined,
|
|
1824
|
+
'fee': fee,
|
|
1825
|
+
'network': undefined,
|
|
1826
|
+
'comment': undefined,
|
|
1827
|
+
'internal': undefined,
|
|
1828
|
+
};
|
|
1829
|
+
}
|
|
1830
|
+
parseDepositWithdrawFee(fee, currency = undefined) {
|
|
1831
|
+
//
|
|
1832
|
+
// {
|
|
1833
|
+
// "symbol": "1INCH",
|
|
1834
|
+
// "name": "1inch",
|
|
1835
|
+
// "decimals": 8,
|
|
1836
|
+
// "depositFee": "0",
|
|
1837
|
+
// "depositConfirmations": 64,
|
|
1838
|
+
// "depositStatus": "OK",
|
|
1839
|
+
// "withdrawalFee": "6.1",
|
|
1840
|
+
// "withdrawalMinAmount": "6.1",
|
|
1841
|
+
// "withdrawalStatus": "OK",
|
|
1842
|
+
// "networks": [
|
|
1843
|
+
// "ETH"
|
|
1844
|
+
// ],
|
|
1845
|
+
// "message": ""
|
|
1846
|
+
// }
|
|
1847
|
+
//
|
|
1848
|
+
const result = {
|
|
1849
|
+
'info': fee,
|
|
1850
|
+
'withdraw': {
|
|
1851
|
+
'fee': this.safeNumber(fee, 'withdrawalFee'),
|
|
1852
|
+
'percentage': false,
|
|
1853
|
+
},
|
|
1854
|
+
'deposit': {
|
|
1855
|
+
'fee': this.safeNumber(fee, 'depositFee'),
|
|
1856
|
+
'percentage': false,
|
|
1857
|
+
},
|
|
1858
|
+
'networks': {},
|
|
1859
|
+
};
|
|
1860
|
+
const networks = this.safeValue(fee, 'networks');
|
|
1861
|
+
let networkId = this.safeValue(networks, 0); // Bitvavo currently only supports one network per currency
|
|
1862
|
+
const currencyCode = this.safeString(currency, 'code');
|
|
1863
|
+
if (networkId === 'Mainnet') {
|
|
1864
|
+
networkId = currencyCode;
|
|
1865
|
+
}
|
|
1866
|
+
const networkCode = this.networkIdToCode(networkId, currencyCode);
|
|
1867
|
+
result['networks'][networkCode] = {
|
|
1868
|
+
'deposit': result['deposit'],
|
|
1869
|
+
'withdraw': result['withdraw'],
|
|
1870
|
+
};
|
|
1871
|
+
return result;
|
|
1872
|
+
}
|
|
1873
|
+
async fetchDepositWithdrawFees(codes = undefined, params = {}) {
|
|
1874
|
+
/**
|
|
1875
|
+
* @method
|
|
1876
|
+
* @name bitvavo#fetchDepositWithdrawFees
|
|
1877
|
+
* @description fetch deposit and withdraw fees
|
|
1878
|
+
* @see https://docs.bitvavo.com/#tag/General/paths/~1assets/get
|
|
1879
|
+
* @param {string[]|undefined} codes list of unified currency codes
|
|
1880
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1881
|
+
* @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
1882
|
+
*/
|
|
1883
|
+
await this.loadMarkets();
|
|
1884
|
+
const response = await this.publicGetAssets(params);
|
|
1885
|
+
//
|
|
1886
|
+
// [
|
|
1887
|
+
// {
|
|
1888
|
+
// "symbol": "1INCH",
|
|
1889
|
+
// "name": "1inch",
|
|
1890
|
+
// "decimals": 8,
|
|
1891
|
+
// "depositFee": "0",
|
|
1892
|
+
// "depositConfirmations": 64,
|
|
1893
|
+
// "depositStatus": "OK",
|
|
1894
|
+
// "withdrawalFee": "6.1",
|
|
1895
|
+
// "withdrawalMinAmount": "6.1",
|
|
1896
|
+
// "withdrawalStatus": "OK",
|
|
1897
|
+
// "networks": [
|
|
1898
|
+
// "ETH"
|
|
1899
|
+
// ],
|
|
1900
|
+
// "message": ""
|
|
1901
|
+
// },
|
|
1902
|
+
// ]
|
|
1903
|
+
//
|
|
1904
|
+
return this.parseDepositWithdrawFees(response, codes, 'symbol');
|
|
1905
|
+
}
|
|
1906
|
+
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
1907
|
+
const query = this.omit(params, this.extractParams(path));
|
|
1908
|
+
let url = '/' + this.version + '/' + this.implodeParams(path, params);
|
|
1909
|
+
const getOrDelete = (method === 'GET') || (method === 'DELETE');
|
|
1910
|
+
if (getOrDelete) {
|
|
1911
|
+
if (Object.keys(query).length) {
|
|
1912
|
+
url += '?' + this.urlencode(query);
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
if (api === 'private') {
|
|
1916
|
+
this.checkRequiredCredentials();
|
|
1917
|
+
let payload = '';
|
|
1918
|
+
if (!getOrDelete) {
|
|
1919
|
+
if (Object.keys(query).length) {
|
|
1920
|
+
body = this.json(query);
|
|
1921
|
+
payload = body;
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
const timestamp = this.milliseconds().toString();
|
|
1925
|
+
const auth = timestamp + method + url + payload;
|
|
1926
|
+
const signature = this.hmac(this.encode(auth), this.encode(this.secret), sha256.sha256);
|
|
1927
|
+
const accessWindow = this.safeString(this.options, 'BITVAVO-ACCESS-WINDOW', '10000');
|
|
1928
|
+
headers = {
|
|
1929
|
+
'BITVAVO-ACCESS-KEY': this.apiKey,
|
|
1930
|
+
'BITVAVO-ACCESS-SIGNATURE': signature,
|
|
1931
|
+
'BITVAVO-ACCESS-TIMESTAMP': timestamp,
|
|
1932
|
+
'BITVAVO-ACCESS-WINDOW': accessWindow,
|
|
1933
|
+
};
|
|
1934
|
+
if (!getOrDelete) {
|
|
1935
|
+
headers['Content-Type'] = 'application/json';
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
url = this.urls['api'][api] + url;
|
|
1939
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
1940
|
+
}
|
|
1941
|
+
handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
1942
|
+
if (response === undefined) {
|
|
1943
|
+
return undefined; // fallback to default error handler
|
|
1944
|
+
}
|
|
1945
|
+
//
|
|
1946
|
+
// {"errorCode":308,"error":"The signature length is invalid (HMAC-SHA256 should return a 64 length hexadecimal string)."}
|
|
1947
|
+
// {"errorCode":203,"error":"symbol parameter is required."}
|
|
1948
|
+
// {"errorCode":205,"error":"symbol parameter is invalid."}
|
|
1949
|
+
//
|
|
1950
|
+
const errorCode = this.safeString(response, 'errorCode');
|
|
1951
|
+
const error = this.safeString(response, 'error');
|
|
1952
|
+
if (errorCode !== undefined) {
|
|
1953
|
+
const feedback = this.id + ' ' + body;
|
|
1954
|
+
this.throwBroadlyMatchedException(this.exceptions['broad'], error, feedback);
|
|
1955
|
+
this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
|
|
1956
|
+
throw new errors.ExchangeError(feedback); // unknown message
|
|
1957
|
+
}
|
|
1958
|
+
return undefined;
|
|
1959
|
+
}
|
|
1960
|
+
calculateRateLimiterCost(api, method, path, params, config = {}) {
|
|
1961
|
+
if (('noMarket' in config) && !('market' in params)) {
|
|
1962
|
+
return config['noMarket'];
|
|
1963
|
+
}
|
|
1964
|
+
return this.safeValue(config, 'cost', 1);
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
module.exports = bitvavo;
|