ccxt 4.2.11 → 4.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/build.sh +2 -2
- package/dist/ccxt.browser.js +1347 -490
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/_virtual/agent.js +7 -0
- package/dist/cjs/_virtual/parse-proxy-response.js +7 -0
- package/dist/cjs/_virtual/promisify.js +7 -0
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/js/ccxt.js +474 -0
- package/dist/cjs/js/src/abstract/ace.js +9 -0
- package/dist/cjs/js/src/abstract/alpaca.js +9 -0
- package/dist/cjs/js/src/abstract/ascendex.js +9 -0
- package/dist/cjs/js/src/abstract/bigone.js +9 -0
- package/dist/cjs/js/src/abstract/binance.js +9 -0
- package/dist/cjs/js/src/abstract/bingx.js +9 -0
- package/dist/cjs/js/src/abstract/bit2c.js +9 -0
- package/dist/cjs/js/src/abstract/bitbank.js +9 -0
- package/dist/cjs/js/src/abstract/bitbns.js +9 -0
- package/dist/cjs/js/src/abstract/bitfinex.js +9 -0
- package/dist/cjs/js/src/abstract/bitfinex2.js +9 -0
- package/dist/cjs/js/src/abstract/bitflyer.js +9 -0
- package/dist/cjs/js/src/abstract/bitforex.js +9 -0
- package/dist/cjs/js/src/abstract/bitget.js +9 -0
- package/dist/cjs/js/src/abstract/bithumb.js +9 -0
- package/dist/cjs/js/src/abstract/bitmart.js +9 -0
- package/dist/cjs/js/src/abstract/bitmex.js +9 -0
- package/dist/cjs/js/src/abstract/bitopro.js +9 -0
- package/dist/cjs/js/src/abstract/bitpanda.js +9 -0
- package/dist/cjs/js/src/abstract/bitrue.js +9 -0
- package/dist/cjs/js/src/abstract/bitso.js +9 -0
- package/dist/cjs/js/src/abstract/bitstamp.js +9 -0
- package/dist/cjs/js/src/abstract/bitteam.js +9 -0
- package/dist/cjs/js/src/abstract/bitvavo.js +9 -0
- package/dist/cjs/js/src/abstract/bl3p.js +9 -0
- package/dist/cjs/js/src/abstract/blockchaincom.js +9 -0
- package/dist/cjs/js/src/abstract/btcalpha.js +9 -0
- package/dist/cjs/js/src/abstract/btcbox.js +9 -0
- package/dist/cjs/js/src/abstract/btcmarkets.js +9 -0
- package/dist/cjs/js/src/abstract/btcturk.js +9 -0
- package/dist/cjs/js/src/abstract/bybit.js +9 -0
- package/dist/cjs/js/src/abstract/cex.js +9 -0
- package/dist/cjs/js/src/abstract/coinbase.js +9 -0
- package/dist/cjs/js/src/abstract/coinbasepro.js +9 -0
- package/dist/cjs/js/src/abstract/coincheck.js +9 -0
- package/dist/cjs/js/src/abstract/coinex.js +9 -0
- package/dist/cjs/js/src/abstract/coinlist.js +9 -0
- package/dist/cjs/js/src/abstract/coinmate.js +9 -0
- package/dist/cjs/js/src/abstract/coinone.js +9 -0
- package/dist/cjs/js/src/abstract/coinsph.js +9 -0
- package/dist/cjs/js/src/abstract/coinspot.js +9 -0
- package/dist/cjs/js/src/abstract/cryptocom.js +9 -0
- package/dist/cjs/js/src/abstract/currencycom.js +9 -0
- package/dist/cjs/js/src/abstract/delta.js +9 -0
- package/dist/cjs/js/src/abstract/deribit.js +9 -0
- package/dist/cjs/js/src/abstract/digifinex.js +9 -0
- package/dist/cjs/js/src/abstract/exmo.js +9 -0
- package/dist/cjs/js/src/abstract/gate.js +9 -0
- package/dist/cjs/js/src/abstract/gemini.js +9 -0
- package/dist/cjs/js/src/abstract/hitbtc.js +9 -0
- package/dist/cjs/js/src/abstract/hollaex.js +9 -0
- package/dist/cjs/js/src/abstract/htx.js +9 -0
- package/dist/cjs/js/src/abstract/huobijp.js +9 -0
- package/dist/cjs/js/src/abstract/idex.js +9 -0
- package/dist/cjs/js/src/abstract/independentreserve.js +9 -0
- package/dist/cjs/js/src/abstract/indodax.js +9 -0
- package/dist/cjs/js/src/abstract/kraken.js +9 -0
- package/dist/cjs/js/src/abstract/krakenfutures.js +9 -0
- package/dist/cjs/js/src/abstract/kucoin.js +9 -0
- package/dist/cjs/js/src/abstract/kucoinfutures.js +9 -0
- package/dist/cjs/js/src/abstract/kuna.js +9 -0
- package/dist/cjs/js/src/abstract/latoken.js +9 -0
- package/dist/cjs/js/src/abstract/lbank.js +9 -0
- package/dist/cjs/js/src/abstract/luno.js +9 -0
- package/dist/cjs/js/src/abstract/lykke.js +9 -0
- package/dist/cjs/js/src/abstract/mercado.js +9 -0
- package/dist/cjs/js/src/abstract/mexc.js +9 -0
- package/dist/cjs/js/src/abstract/ndax.js +9 -0
- package/dist/cjs/js/src/abstract/novadax.js +9 -0
- package/dist/cjs/js/src/abstract/oceanex.js +9 -0
- package/dist/cjs/js/src/abstract/okcoin.js +9 -0
- package/dist/cjs/js/src/abstract/okx.js +9 -0
- package/dist/cjs/js/src/abstract/p2b.js +9 -0
- package/dist/cjs/js/src/abstract/paymium.js +9 -0
- package/dist/cjs/js/src/abstract/phemex.js +9 -0
- package/dist/cjs/js/src/abstract/poloniex.js +9 -0
- package/dist/cjs/js/src/abstract/poloniexfutures.js +9 -0
- package/dist/cjs/js/src/abstract/probit.js +9 -0
- package/dist/cjs/js/src/abstract/timex.js +9 -0
- package/dist/cjs/js/src/abstract/tokocrypto.js +9 -0
- package/dist/cjs/js/src/abstract/upbit.js +9 -0
- package/dist/cjs/js/src/abstract/wavesexchange.js +9 -0
- package/dist/cjs/js/src/abstract/wazirx.js +9 -0
- package/dist/cjs/js/src/abstract/whitebit.js +9 -0
- package/dist/cjs/js/src/abstract/woo.js +9 -0
- package/dist/cjs/js/src/abstract/yobit.js +9 -0
- package/dist/cjs/js/src/abstract/zaif.js +9 -0
- package/dist/cjs/js/src/abstract/zonda.js +9 -0
- package/dist/cjs/js/src/ace.js +1058 -0
- package/dist/cjs/js/src/alpaca.js +1125 -0
- package/dist/cjs/js/src/ascendex.js +3360 -0
- package/dist/cjs/js/src/base/Exchange.js +5110 -0
- package/dist/cjs/js/src/base/Precise.js +263 -0
- package/dist/cjs/js/src/base/errors.js +299 -0
- package/dist/cjs/js/src/base/functions/crypto.js +78 -0
- package/dist/cjs/js/src/base/functions/encode.js +44 -0
- package/dist/cjs/js/src/base/functions/generic.js +193 -0
- package/dist/cjs/js/src/base/functions/misc.js +96 -0
- package/dist/cjs/js/src/base/functions/number.js +297 -0
- package/dist/cjs/js/src/base/functions/platform.js +28 -0
- package/dist/cjs/js/src/base/functions/rsa.js +34 -0
- package/dist/cjs/js/src/base/functions/string.js +48 -0
- package/dist/cjs/js/src/base/functions/throttle.js +66 -0
- package/dist/cjs/js/src/base/functions/time.js +187 -0
- package/dist/cjs/js/src/base/functions/totp.js +24 -0
- package/dist/cjs/js/src/base/functions/type.js +162 -0
- package/dist/cjs/js/src/base/functions.js +157 -0
- package/dist/cjs/js/src/base/ws/Cache.js +254 -0
- package/dist/cjs/js/src/base/ws/Client.js +299 -0
- package/dist/cjs/js/src/base/ws/Future.js +34 -0
- package/dist/cjs/js/src/base/ws/OrderBook.js +107 -0
- package/dist/cjs/js/src/base/ws/OrderBookSide.js +281 -0
- package/dist/cjs/js/src/base/ws/WsClient.js +69 -0
- package/dist/cjs/js/src/bequant.js +33 -0
- package/dist/cjs/js/src/bigone.js +2209 -0
- package/dist/cjs/js/src/binance.js +9736 -0
- package/dist/cjs/js/src/binancecoinm.js +45 -0
- package/dist/cjs/js/src/binanceus.js +84 -0
- package/dist/cjs/js/src/binanceusdm.js +58 -0
- package/dist/cjs/js/src/bingx.js +3807 -0
- package/dist/cjs/js/src/bit2c.js +916 -0
- package/dist/cjs/js/src/bitbank.js +1000 -0
- package/dist/cjs/js/src/bitbay.js +17 -0
- package/dist/cjs/js/src/bitbns.js +1220 -0
- package/dist/cjs/js/src/bitcoincom.js +17 -0
- package/dist/cjs/js/src/bitfinex.js +1670 -0
- package/dist/cjs/js/src/bitfinex2.js +2990 -0
- package/dist/cjs/js/src/bitflyer.js +1045 -0
- package/dist/cjs/js/src/bitforex.js +852 -0
- package/dist/cjs/js/src/bitget.js +8291 -0
- package/dist/cjs/js/src/bithumb.js +1090 -0
- package/dist/cjs/js/src/bitmart.js +4454 -0
- package/dist/cjs/js/src/bitmex.js +2884 -0
- package/dist/cjs/js/src/bitopro.js +1724 -0
- package/dist/cjs/js/src/bitpanda.js +2002 -0
- package/dist/cjs/js/src/bitrue.js +3253 -0
- package/dist/cjs/js/src/bitso.js +1753 -0
- package/dist/cjs/js/src/bitstamp.js +2188 -0
- package/dist/cjs/js/src/bitteam.js +2309 -0
- package/dist/cjs/js/src/bitvavo.js +1968 -0
- package/dist/cjs/js/src/bl3p.js +447 -0
- package/dist/cjs/js/src/blockchaincom.js +1160 -0
- package/dist/cjs/js/src/btcalpha.js +929 -0
- package/dist/cjs/js/src/btcbox.js +565 -0
- package/dist/cjs/js/src/btcmarkets.js +1237 -0
- package/dist/cjs/js/src/btcturk.js +929 -0
- package/dist/cjs/js/src/bybit.js +7646 -0
- package/dist/cjs/js/src/cex.js +1693 -0
- package/dist/cjs/js/src/coinbase.js +3424 -0
- package/dist/cjs/js/src/coinbasepro.js +1866 -0
- package/dist/cjs/js/src/coincheck.js +843 -0
- package/dist/cjs/js/src/coinex.js +5414 -0
- package/dist/cjs/js/src/coinlist.js +2329 -0
- package/dist/cjs/js/src/coinmate.js +989 -0
- package/dist/cjs/js/src/coinone.js +1185 -0
- package/dist/cjs/js/src/coinsph.js +1933 -0
- package/dist/cjs/js/src/coinspot.js +548 -0
- package/dist/cjs/js/src/cryptocom.js +3007 -0
- package/dist/cjs/js/src/currencycom.js +2015 -0
- package/dist/cjs/js/src/delta.js +3256 -0
- package/dist/cjs/js/src/deribit.js +3306 -0
- package/dist/cjs/js/src/digifinex.js +4307 -0
- package/dist/cjs/js/src/exmo.js +2645 -0
- package/dist/cjs/js/src/fmfwio.js +34 -0
- package/dist/cjs/js/src/gate.js +7072 -0
- package/dist/cjs/js/src/gateio.js +16 -0
- package/dist/cjs/js/src/gemini.js +1801 -0
- package/dist/cjs/js/src/hitbtc.js +3660 -0
- package/dist/cjs/js/src/hitbtc3.js +19 -0
- package/dist/cjs/js/src/hollaex.js +1882 -0
- package/dist/cjs/js/src/htx.js +9049 -0
- package/dist/cjs/js/src/huobi.js +16 -0
- package/dist/cjs/js/src/huobijp.js +1918 -0
- package/dist/cjs/js/src/idex.js +1770 -0
- package/dist/cjs/js/src/independentreserve.js +761 -0
- package/dist/cjs/js/src/indodax.js +1069 -0
- package/dist/cjs/js/src/kraken.js +2857 -0
- package/dist/cjs/js/src/krakenfutures.js +2407 -0
- package/dist/cjs/js/src/kucoin.js +4489 -0
- package/dist/cjs/js/src/kucoinfutures.js +2475 -0
- package/dist/cjs/js/src/kuna.js +1949 -0
- package/dist/cjs/js/src/latoken.js +1729 -0
- package/dist/cjs/js/src/lbank.js +2851 -0
- package/dist/cjs/js/src/luno.js +1044 -0
- package/dist/cjs/js/src/lykke.js +1303 -0
- package/dist/cjs/js/src/mercado.js +897 -0
- package/dist/cjs/js/src/mexc.js +5407 -0
- package/dist/cjs/js/src/ndax.js +2450 -0
- package/dist/cjs/js/src/novadax.js +1556 -0
- package/dist/cjs/js/src/oceanex.js +964 -0
- package/dist/cjs/js/src/okcoin.js +3115 -0
- package/dist/cjs/js/src/okx.js +7330 -0
- package/dist/cjs/js/src/p2b.js +1243 -0
- package/dist/cjs/js/src/paymium.js +597 -0
- package/dist/cjs/js/src/phemex.js +4722 -0
- package/dist/cjs/js/src/poloniex.js +2356 -0
- package/dist/cjs/js/src/poloniexfutures.js +1794 -0
- package/dist/cjs/js/src/pro/alpaca.js +714 -0
- package/dist/cjs/js/src/pro/ascendex.js +957 -0
- package/dist/cjs/js/src/pro/bequant.js +33 -0
- package/dist/cjs/js/src/pro/binance.js +2796 -0
- package/dist/cjs/js/src/pro/binancecoinm.js +23 -0
- package/dist/cjs/js/src/pro/binanceus.js +51 -0
- package/dist/cjs/js/src/pro/binanceusdm.js +32 -0
- package/dist/cjs/js/src/pro/bingx.js +944 -0
- package/dist/cjs/js/src/pro/bitcoincom.js +29 -0
- package/dist/cjs/js/src/pro/bitfinex.js +672 -0
- package/dist/cjs/js/src/pro/bitfinex2.js +1159 -0
- package/dist/cjs/js/src/pro/bitget.js +1733 -0
- package/dist/cjs/js/src/pro/bitmart.js +1486 -0
- package/dist/cjs/js/src/pro/bitmex.js +1576 -0
- package/dist/cjs/js/src/pro/bitopro.js +327 -0
- package/dist/cjs/js/src/pro/bitpanda.js +1341 -0
- package/dist/cjs/js/src/pro/bitrue.js +462 -0
- package/dist/cjs/js/src/pro/bitstamp.js +547 -0
- package/dist/cjs/js/src/pro/bitvavo.js +704 -0
- package/dist/cjs/js/src/pro/blockchaincom.js +794 -0
- package/dist/cjs/js/src/pro/bybit.js +1843 -0
- package/dist/cjs/js/src/pro/cex.js +1510 -0
- package/dist/cjs/js/src/pro/coinbase.js +561 -0
- package/dist/cjs/js/src/pro/coinbasepro.js +968 -0
- package/dist/cjs/js/src/pro/coinex.js +1095 -0
- package/dist/cjs/js/src/pro/cryptocom.js +1020 -0
- package/dist/cjs/js/src/pro/currencycom.js +563 -0
- package/dist/cjs/js/src/pro/deribit.js +825 -0
- package/dist/cjs/js/src/pro/exmo.js +658 -0
- package/dist/cjs/js/src/pro/gate.js +1316 -0
- package/dist/cjs/js/src/pro/gateio.js +16 -0
- package/dist/cjs/js/src/pro/gemini.js +649 -0
- package/dist/cjs/js/src/pro/hitbtc.js +1293 -0
- package/dist/cjs/js/src/pro/hollaex.js +597 -0
- package/dist/cjs/js/src/pro/htx.js +2383 -0
- package/dist/cjs/js/src/pro/huobi.js +16 -0
- package/dist/cjs/js/src/pro/huobijp.js +606 -0
- package/dist/cjs/js/src/pro/idex.js +714 -0
- package/dist/cjs/js/src/pro/independentreserve.js +280 -0
- package/dist/cjs/js/src/pro/kraken.js +1364 -0
- package/dist/cjs/js/src/pro/krakenfutures.js +1500 -0
- package/dist/cjs/js/src/pro/kucoin.js +1052 -0
- package/dist/cjs/js/src/pro/kucoinfutures.js +981 -0
- package/dist/cjs/js/src/pro/luno.js +322 -0
- package/dist/cjs/js/src/pro/mexc.js +1170 -0
- package/dist/cjs/js/src/pro/ndax.js +545 -0
- package/dist/cjs/js/src/pro/okcoin.js +760 -0
- package/dist/cjs/js/src/pro/okx.js +1608 -0
- package/dist/cjs/js/src/pro/phemex.js +1511 -0
- package/dist/cjs/js/src/pro/poloniex.js +1253 -0
- package/dist/cjs/js/src/pro/poloniexfutures.js +1014 -0
- package/dist/cjs/js/src/pro/probit.js +586 -0
- package/dist/cjs/js/src/pro/upbit.js +234 -0
- package/dist/cjs/js/src/pro/wazirx.js +776 -0
- package/dist/cjs/js/src/pro/whitebit.js +927 -0
- package/dist/cjs/js/src/pro/woo.js +769 -0
- package/dist/cjs/js/src/probit.js +1867 -0
- package/dist/cjs/js/src/static_dependencies/fflake/browser.js +401 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncrypt.js +195 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +308 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +554 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +94 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +70 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +91 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +16 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +1760 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +52 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +81 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +376 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +70 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +1580 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +74 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/_shortw_utils.js +24 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/curve.js +158 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/edwards.js +429 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +176 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/modular.js +324 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/montgomery.js +163 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/utils.js +245 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +1018 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/ed25519.js +383 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/secp256k1.js +258 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/_assert.js +53 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/_sha2.js +120 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/_u64.js +69 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/crypto.js +7 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/hmac.js +83 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/md5.js +240 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha1.js +91 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha256.js +130 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha3.js +214 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha512.js +239 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/utils.js +93 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/body.js +354 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/errors/abort-error.js +16 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/errors/base.js +20 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/errors/fetch-error.js +30 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/headers.js +239 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/index.js +372 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/request.js +273 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/response.js +139 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/get-search.js +14 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is-redirect.js +16 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is.js +81 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/referrer.js +292 -0
- package/dist/cjs/js/src/static_dependencies/proxies/agent-base/index.js +103 -0
- package/dist/cjs/js/src/static_dependencies/proxies/http-proxy-agent/index.js +140 -0
- package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/index.js +175 -0
- package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +95 -0
- package/dist/cjs/js/src/static_dependencies/qs/index.cjs.js +7 -0
- package/dist/cjs/js/src/static_dependencies/scure-base/index.js +383 -0
- package/dist/cjs/js/src/timex.js +1562 -0
- package/dist/cjs/js/src/tokocrypto.js +2542 -0
- package/dist/cjs/js/src/upbit.js +1844 -0
- package/dist/cjs/js/src/wavesexchange.js +2607 -0
- package/dist/cjs/js/src/wazirx.js +953 -0
- package/dist/cjs/js/src/whitebit.js +2309 -0
- package/dist/cjs/js/src/woo.js +2765 -0
- package/dist/cjs/js/src/yobit.js +1314 -0
- package/dist/cjs/js/src/zaif.js +736 -0
- package/dist/cjs/js/src/zonda.js +1883 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bigone.d.ts +18 -0
- package/js/src/abstract/binance.d.ts +2 -0
- package/js/src/abstract/binancecoinm.d.ts +2 -0
- package/js/src/abstract/binanceus.d.ts +2 -0
- package/js/src/abstract/binanceusdm.d.ts +2 -0
- package/js/src/abstract/bingx.d.ts +2 -0
- package/js/src/abstract/bybit.d.ts +1 -0
- package/js/src/abstract/gate.d.ts +11 -0
- package/js/src/abstract/gateio.d.ts +11 -0
- package/js/src/abstract/okx.d.ts +1 -0
- package/js/src/alpaca.js +18 -18
- package/js/src/base/Exchange.d.ts +5 -1
- package/js/src/base/Exchange.js +101 -12
- package/js/src/bigone.d.ts +3 -2
- package/js/src/bigone.js +429 -167
- package/js/src/binance.js +48 -34
- package/js/src/bingx.js +115 -38
- package/js/src/bitfinex.d.ts +2 -2
- package/js/src/bitfinex.js +2 -3
- package/js/src/bitget.js +33 -13
- package/js/src/bitmart.d.ts +2 -2
- package/js/src/bitmart.js +5 -5
- package/js/src/bitmex.js +1 -0
- package/js/src/bybit.js +2 -0
- package/js/src/coinbase.d.ts +26 -3
- package/js/src/coinbase.js +176 -26
- package/js/src/coinlist.js +3 -4
- package/js/src/coinone.js +1 -1
- package/js/src/coinsph.js +2 -3
- package/js/src/deribit.js +1 -0
- package/js/src/gate.d.ts +4 -4
- package/js/src/gate.js +96 -59
- package/js/src/gemini.js +1 -1
- package/js/src/hitbtc.d.ts +4 -4
- package/js/src/hitbtc.js +2 -3
- package/js/src/htx.d.ts +1 -0
- package/js/src/htx.js +29 -7
- package/js/src/huobijp.js +2 -3
- package/js/src/independentreserve.js +7 -5
- package/js/src/kraken.js +3 -6
- package/js/src/lbank.js +59 -33
- package/js/src/mexc.js +2 -1
- package/js/src/oceanex.js +1 -1
- package/js/src/okx.js +14 -3
- package/js/src/phemex.js +9 -2
- package/js/src/pro/binance.d.ts +2 -23
- package/js/src/pro/binance.js +58 -22
- package/js/src/pro/coinbase.d.ts +2 -2
- package/js/src/pro/coinbase.js +4 -1
- package/js/src/pro/coinbasepro.d.ts +2 -2
- package/js/src/pro/hitbtc.d.ts +2 -2
- package/js/src/pro/kraken.js +1 -1
- package/js/src/pro/okx.d.ts +1 -0
- package/js/src/pro/okx.js +52 -2
- package/js/src/pro/poloniex.d.ts +2 -2
- package/js/src/probit.js +4 -2
- package/js/src/upbit.d.ts +3 -101
- package/js/src/upbit.js +12 -12
- package/js/src/wavesexchange.js +1 -1
- package/js/src/woo.d.ts +2 -0
- package/js/src/woo.js +52 -0
- package/package.json +1 -1
- package/skip-tests.json +5 -0
|
@@ -0,0 +1,4307 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var digifinex$1 = require('./abstract/digifinex.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 digifinex
|
|
13
|
+
* @augments Exchange
|
|
14
|
+
*/
|
|
15
|
+
class digifinex extends digifinex$1 {
|
|
16
|
+
describe() {
|
|
17
|
+
return this.deepExtend(super.describe(), {
|
|
18
|
+
'id': 'digifinex',
|
|
19
|
+
'name': 'DigiFinex',
|
|
20
|
+
'countries': ['SG'],
|
|
21
|
+
'version': 'v3',
|
|
22
|
+
'rateLimit': 900,
|
|
23
|
+
'has': {
|
|
24
|
+
'CORS': undefined,
|
|
25
|
+
'spot': true,
|
|
26
|
+
'margin': true,
|
|
27
|
+
'swap': true,
|
|
28
|
+
'future': false,
|
|
29
|
+
'option': false,
|
|
30
|
+
'addMargin': true,
|
|
31
|
+
'cancelOrder': true,
|
|
32
|
+
'cancelOrders': true,
|
|
33
|
+
'createMarketBuyOrderWithCost': true,
|
|
34
|
+
'createMarketOrderWithCost': false,
|
|
35
|
+
'createMarketSellOrderWithCost': false,
|
|
36
|
+
'createOrder': true,
|
|
37
|
+
'createOrders': true,
|
|
38
|
+
'createPostOnlyOrder': true,
|
|
39
|
+
'createReduceOnlyOrder': true,
|
|
40
|
+
'createStopLimitOrder': false,
|
|
41
|
+
'createStopMarketOrder': false,
|
|
42
|
+
'createStopOrder': false,
|
|
43
|
+
'fetchBalance': true,
|
|
44
|
+
'fetchBorrowInterest': true,
|
|
45
|
+
'fetchBorrowRateHistories': false,
|
|
46
|
+
'fetchBorrowRateHistory': false,
|
|
47
|
+
'fetchCrossBorrowRate': true,
|
|
48
|
+
'fetchCrossBorrowRates': true,
|
|
49
|
+
'fetchCurrencies': true,
|
|
50
|
+
'fetchDepositAddress': true,
|
|
51
|
+
'fetchDeposits': true,
|
|
52
|
+
'fetchDepositWithdrawFee': 'emulated',
|
|
53
|
+
'fetchDepositWithdrawFees': true,
|
|
54
|
+
'fetchFundingHistory': true,
|
|
55
|
+
'fetchFundingRate': true,
|
|
56
|
+
'fetchFundingRateHistory': true,
|
|
57
|
+
'fetchFundingRates': false,
|
|
58
|
+
'fetchIndexOHLCV': false,
|
|
59
|
+
'fetchIsolatedBorrowRate': false,
|
|
60
|
+
'fetchIsolatedBorrowRates': false,
|
|
61
|
+
'fetchLedger': true,
|
|
62
|
+
'fetchLeverage': false,
|
|
63
|
+
'fetchLeverageTiers': true,
|
|
64
|
+
'fetchMarginMode': false,
|
|
65
|
+
'fetchMarketLeverageTiers': true,
|
|
66
|
+
'fetchMarkets': true,
|
|
67
|
+
'fetchMarkOHLCV': false,
|
|
68
|
+
'fetchMyTrades': true,
|
|
69
|
+
'fetchOHLCV': true,
|
|
70
|
+
'fetchOpenOrders': true,
|
|
71
|
+
'fetchOrder': true,
|
|
72
|
+
'fetchOrderBook': true,
|
|
73
|
+
'fetchOrders': true,
|
|
74
|
+
'fetchPosition': true,
|
|
75
|
+
'fetchPositionMode': false,
|
|
76
|
+
'fetchPositions': true,
|
|
77
|
+
'fetchPositionsRisk': false,
|
|
78
|
+
'fetchPremiumIndexOHLCV': false,
|
|
79
|
+
'fetchStatus': true,
|
|
80
|
+
'fetchTicker': true,
|
|
81
|
+
'fetchTickers': true,
|
|
82
|
+
'fetchTime': true,
|
|
83
|
+
'fetchTrades': true,
|
|
84
|
+
'fetchTradingFee': true,
|
|
85
|
+
'fetchTradingFees': false,
|
|
86
|
+
'fetchTransfers': true,
|
|
87
|
+
'fetchWithdrawals': true,
|
|
88
|
+
'reduceMargin': true,
|
|
89
|
+
'setLeverage': true,
|
|
90
|
+
'setMargin': false,
|
|
91
|
+
'setMarginMode': true,
|
|
92
|
+
'setPositionMode': false,
|
|
93
|
+
'transfer': true,
|
|
94
|
+
'withdraw': true,
|
|
95
|
+
},
|
|
96
|
+
'timeframes': {
|
|
97
|
+
'1m': '1',
|
|
98
|
+
'5m': '5',
|
|
99
|
+
'15m': '15',
|
|
100
|
+
'30m': '30',
|
|
101
|
+
'1h': '60',
|
|
102
|
+
'4h': '240',
|
|
103
|
+
'12h': '720',
|
|
104
|
+
'1d': '1D',
|
|
105
|
+
'1w': '1W',
|
|
106
|
+
},
|
|
107
|
+
'urls': {
|
|
108
|
+
'logo': 'https://user-images.githubusercontent.com/51840849/87443315-01283a00-c5fe-11ea-8628-c2a0feaf07ac.jpg',
|
|
109
|
+
'api': {
|
|
110
|
+
'rest': 'https://openapi.digifinex.com',
|
|
111
|
+
},
|
|
112
|
+
'www': 'https://www.digifinex.com',
|
|
113
|
+
'doc': [
|
|
114
|
+
'https://docs.digifinex.com',
|
|
115
|
+
],
|
|
116
|
+
'fees': 'https://digifinex.zendesk.com/hc/en-us/articles/360000328422-Fee-Structure-on-DigiFinex',
|
|
117
|
+
'referral': 'https://www.digifinex.com/en-ww/from/DhOzBg?channelCode=ljaUPp',
|
|
118
|
+
},
|
|
119
|
+
'api': {
|
|
120
|
+
'public': {
|
|
121
|
+
'spot': {
|
|
122
|
+
'get': [
|
|
123
|
+
'{market}/symbols',
|
|
124
|
+
'kline',
|
|
125
|
+
'margin/currencies',
|
|
126
|
+
'margin/symbols',
|
|
127
|
+
'markets',
|
|
128
|
+
'order_book',
|
|
129
|
+
'ping',
|
|
130
|
+
'spot/symbols',
|
|
131
|
+
'time',
|
|
132
|
+
'trades',
|
|
133
|
+
'trades/symbols',
|
|
134
|
+
'ticker',
|
|
135
|
+
'currencies',
|
|
136
|
+
],
|
|
137
|
+
},
|
|
138
|
+
'swap': {
|
|
139
|
+
'get': [
|
|
140
|
+
'public/api_weight',
|
|
141
|
+
'public/candles',
|
|
142
|
+
'public/candles_history',
|
|
143
|
+
'public/depth',
|
|
144
|
+
'public/funding_rate',
|
|
145
|
+
'public/funding_rate_history',
|
|
146
|
+
'public/instrument',
|
|
147
|
+
'public/instruments',
|
|
148
|
+
'public/ticker',
|
|
149
|
+
'public/tickers',
|
|
150
|
+
'public/time',
|
|
151
|
+
'public/trades',
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
'private': {
|
|
156
|
+
'spot': {
|
|
157
|
+
'get': [
|
|
158
|
+
'{market}/financelog',
|
|
159
|
+
'{market}/mytrades',
|
|
160
|
+
'{market}/order',
|
|
161
|
+
'{market}/order/detail',
|
|
162
|
+
'{market}/order/current',
|
|
163
|
+
'{market}/order/history',
|
|
164
|
+
'margin/assets',
|
|
165
|
+
'margin/financelog',
|
|
166
|
+
'margin/mytrades',
|
|
167
|
+
'margin/order',
|
|
168
|
+
'margin/order/current',
|
|
169
|
+
'margin/order/history',
|
|
170
|
+
'margin/positions',
|
|
171
|
+
'otc/financelog',
|
|
172
|
+
'spot/assets',
|
|
173
|
+
'spot/financelog',
|
|
174
|
+
'spot/mytrades',
|
|
175
|
+
'spot/order',
|
|
176
|
+
'spot/order/current',
|
|
177
|
+
'spot/order/history',
|
|
178
|
+
'deposit/address',
|
|
179
|
+
'deposit/history',
|
|
180
|
+
'withdraw/history',
|
|
181
|
+
],
|
|
182
|
+
'post': [
|
|
183
|
+
'{market}/order/cancel',
|
|
184
|
+
'{market}/order/new',
|
|
185
|
+
'{market}/order/batch_new',
|
|
186
|
+
'margin/order/cancel',
|
|
187
|
+
'margin/order/new',
|
|
188
|
+
'margin/position/close',
|
|
189
|
+
'spot/order/cancel',
|
|
190
|
+
'spot/order/new',
|
|
191
|
+
'transfer',
|
|
192
|
+
'withdraw/new',
|
|
193
|
+
'withdraw/cancel',
|
|
194
|
+
],
|
|
195
|
+
},
|
|
196
|
+
'swap': {
|
|
197
|
+
'get': [
|
|
198
|
+
'account/balance',
|
|
199
|
+
'account/positions',
|
|
200
|
+
'account/finance_record',
|
|
201
|
+
'account/trading_fee_rate',
|
|
202
|
+
'account/transfer_record',
|
|
203
|
+
'account/funding_fee',
|
|
204
|
+
'trade/history_orders',
|
|
205
|
+
'trade/history_trades',
|
|
206
|
+
'trade/open_orders',
|
|
207
|
+
'trade/order_info',
|
|
208
|
+
],
|
|
209
|
+
'post': [
|
|
210
|
+
'account/leverage',
|
|
211
|
+
'account/position_mode',
|
|
212
|
+
'account/position_margin',
|
|
213
|
+
'trade/batch_cancel_order',
|
|
214
|
+
'trade/batch_order',
|
|
215
|
+
'trade/cancel_order',
|
|
216
|
+
'trade/order_place',
|
|
217
|
+
'follow/sponsor_order',
|
|
218
|
+
'follow/close_order',
|
|
219
|
+
'follow/cancel_order',
|
|
220
|
+
'follow/user_center_current',
|
|
221
|
+
'follow/user_center_history',
|
|
222
|
+
'follow/expert_current_open_order',
|
|
223
|
+
'follow/add_algo',
|
|
224
|
+
'follow/cancel_algo',
|
|
225
|
+
'follow/account_available',
|
|
226
|
+
'follow/plan_task',
|
|
227
|
+
'follow/instrument_list',
|
|
228
|
+
],
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
'fees': {
|
|
233
|
+
'trading': {
|
|
234
|
+
'tierBased': true,
|
|
235
|
+
'percentage': true,
|
|
236
|
+
'maker': this.parseNumber('0.002'),
|
|
237
|
+
'taker': this.parseNumber('0.002'),
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
'precisionMode': number.TICK_SIZE,
|
|
241
|
+
'exceptions': {
|
|
242
|
+
'exact': {
|
|
243
|
+
'10001': [errors.BadRequest, "Wrong request method, please check it's a GET ot POST request"],
|
|
244
|
+
'10002': [errors.AuthenticationError, 'Invalid ApiKey'],
|
|
245
|
+
'10003': [errors.AuthenticationError, "Sign doesn't match"],
|
|
246
|
+
'10004': [errors.BadRequest, 'Illegal request parameters'],
|
|
247
|
+
'10005': [errors.DDoSProtection, 'Request frequency exceeds the limit'],
|
|
248
|
+
'10006': [errors.PermissionDenied, 'Unauthorized to execute this request'],
|
|
249
|
+
'10007': [errors.PermissionDenied, 'IP address Unauthorized'],
|
|
250
|
+
'10008': [errors.InvalidNonce, 'Timestamp for this request is invalid, timestamp must within 1 minute'],
|
|
251
|
+
'10009': [errors.NetworkError, 'Unexist endpoint, please check endpoint URL'],
|
|
252
|
+
'10011': [errors.AccountSuspended, 'ApiKey expired. Please go to client side to re-create an ApiKey'],
|
|
253
|
+
'20001': [errors.PermissionDenied, 'Trade is not open for this trading pair'],
|
|
254
|
+
'20002': [errors.PermissionDenied, 'Trade of this trading pair is suspended'],
|
|
255
|
+
'20003': [errors.InvalidOrder, 'Invalid price or amount'],
|
|
256
|
+
'20007': [errors.InvalidOrder, 'Price precision error'],
|
|
257
|
+
'20008': [errors.InvalidOrder, 'Amount precision error'],
|
|
258
|
+
'20009': [errors.InvalidOrder, 'Amount is less than the minimum requirement'],
|
|
259
|
+
'20010': [errors.InvalidOrder, 'Cash Amount is less than the minimum requirement'],
|
|
260
|
+
'20011': [errors.InsufficientFunds, 'Insufficient balance'],
|
|
261
|
+
'20012': [errors.BadRequest, 'Invalid trade type, valid value: buy/sell)'],
|
|
262
|
+
'20013': [errors.InvalidOrder, 'No order info found'],
|
|
263
|
+
'20014': [errors.BadRequest, 'Invalid date, Valid format: 2018-07-25)'],
|
|
264
|
+
'20015': [errors.BadRequest, 'Date exceeds the limit'],
|
|
265
|
+
'20018': [errors.PermissionDenied, 'Your trading rights have been banned by the system'],
|
|
266
|
+
'20019': [errors.BadSymbol, 'Wrong trading pair symbol. Correct format:"usdt_btc". Quote asset is in the front'],
|
|
267
|
+
'20020': [errors.DDoSProtection, "You have violated the API operation trading rules and temporarily forbid trading. At present, we have certain restrictions on the user's transaction rate and withdrawal rate."],
|
|
268
|
+
'50000': [errors.ExchangeError, 'Exception error'],
|
|
269
|
+
'20021': [errors.BadRequest, 'Invalid currency'],
|
|
270
|
+
'20022': [errors.BadRequest, 'The ending timestamp must be larger than the starting timestamp'],
|
|
271
|
+
'20023': [errors.BadRequest, 'Invalid transfer type'],
|
|
272
|
+
'20024': [errors.BadRequest, 'Invalid amount'],
|
|
273
|
+
'20025': [errors.BadRequest, 'This currency is not transferable at the moment'],
|
|
274
|
+
'20026': [errors.InsufficientFunds, 'Transfer amount exceed your balance'],
|
|
275
|
+
'20027': [errors.PermissionDenied, 'Abnormal account status'],
|
|
276
|
+
'20028': [errors.PermissionDenied, 'Blacklist for transfer'],
|
|
277
|
+
'20029': [errors.PermissionDenied, 'Transfer amount exceed your daily limit'],
|
|
278
|
+
'20030': [errors.BadRequest, 'You have no position on this trading pair'],
|
|
279
|
+
'20032': [errors.PermissionDenied, 'Withdrawal limited'],
|
|
280
|
+
'20033': [errors.BadRequest, 'Wrong Withdrawal ID'],
|
|
281
|
+
'20034': [errors.PermissionDenied, 'Withdrawal service of this crypto has been closed'],
|
|
282
|
+
'20035': [errors.PermissionDenied, 'Withdrawal limit'],
|
|
283
|
+
'20036': [errors.ExchangeError, 'Withdrawal cancellation failed'],
|
|
284
|
+
'20037': [errors.InvalidAddress, 'The withdrawal address, Tag or chain type is not included in the withdrawal management list'],
|
|
285
|
+
'20038': [errors.InvalidAddress, 'The withdrawal address is not on the white list'],
|
|
286
|
+
'20039': [errors.ExchangeError, "Can't be canceled in current status"],
|
|
287
|
+
'20040': [errors.RateLimitExceeded, 'Withdraw too frequently; limitation: 3 times a minute, 100 times a day'],
|
|
288
|
+
'20041': [errors.PermissionDenied, 'Beyond the daily withdrawal limit'],
|
|
289
|
+
'20042': [errors.BadSymbol, 'Current trading pair does not support API trading'],
|
|
290
|
+
'400002': [errors.BadRequest, 'Invalid Parameter'],
|
|
291
|
+
},
|
|
292
|
+
'broad': {},
|
|
293
|
+
},
|
|
294
|
+
'options': {
|
|
295
|
+
'defaultType': 'spot',
|
|
296
|
+
'types': ['spot', 'margin', 'otc'],
|
|
297
|
+
'createMarketBuyOrderRequiresPrice': true,
|
|
298
|
+
'accountsByType': {
|
|
299
|
+
'spot': '1',
|
|
300
|
+
'margin': '2',
|
|
301
|
+
'OTC': '3',
|
|
302
|
+
},
|
|
303
|
+
'networks': {
|
|
304
|
+
'ARBITRUM': 'Arbitrum',
|
|
305
|
+
'AVALANCEC': 'AVAX-CCHAIN',
|
|
306
|
+
'AVALANCEX': 'AVAX-XCHAIN',
|
|
307
|
+
'BEP20': 'BEP20',
|
|
308
|
+
'BSC': 'BEP20',
|
|
309
|
+
'CARDANO': 'Cardano',
|
|
310
|
+
'CELO': 'Celo',
|
|
311
|
+
'CHILIZ': 'Chiliz',
|
|
312
|
+
'COSMOS': 'COSMOS',
|
|
313
|
+
'CRC20': 'Crypto.com',
|
|
314
|
+
'CRONOS': 'Crypto.com',
|
|
315
|
+
'DOGECOIN': 'DogeChain',
|
|
316
|
+
'ERC20': 'ERC20',
|
|
317
|
+
'ETH': 'ERC20',
|
|
318
|
+
'ETHW': 'ETHW',
|
|
319
|
+
'IOTA': 'MIOTA',
|
|
320
|
+
'KLAYTN': 'KLAY',
|
|
321
|
+
'MATIC': 'Polygon',
|
|
322
|
+
'METIS': 'MetisDAO',
|
|
323
|
+
'MOONBEAM': 'GLMR',
|
|
324
|
+
'MOONRIVER': 'Moonriver',
|
|
325
|
+
'OPTIMISM': 'OPETH',
|
|
326
|
+
'POLYGON': 'Polygon',
|
|
327
|
+
'RIPPLE': 'XRP',
|
|
328
|
+
'SOLANA': 'SOL',
|
|
329
|
+
'STELLAR': 'Stella',
|
|
330
|
+
'TERRACLASSIC': 'TerraClassic',
|
|
331
|
+
'TERRA': 'Terra',
|
|
332
|
+
'TON': 'Ton',
|
|
333
|
+
'TRC20': 'TRC20',
|
|
334
|
+
'TRON': 'TRC20',
|
|
335
|
+
'TRX': 'TRC20',
|
|
336
|
+
'VECHAIN': 'Vechain', // VET
|
|
337
|
+
},
|
|
338
|
+
},
|
|
339
|
+
'commonCurrencies': {
|
|
340
|
+
'BHT': 'Black House Test',
|
|
341
|
+
'EPS': 'Epanus',
|
|
342
|
+
'FREE': 'FreeRossDAO',
|
|
343
|
+
'MBN': 'Mobilian Coin',
|
|
344
|
+
'TEL': 'TEL666',
|
|
345
|
+
},
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
async fetchCurrencies(params = {}) {
|
|
349
|
+
/**
|
|
350
|
+
* @method
|
|
351
|
+
* @name digifinex#fetchCurrencies
|
|
352
|
+
* @description fetches all available currencies on an exchange
|
|
353
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
354
|
+
* @returns {object} an associative dictionary of currencies
|
|
355
|
+
*/
|
|
356
|
+
const response = await this.publicSpotGetCurrencies(params);
|
|
357
|
+
//
|
|
358
|
+
// {
|
|
359
|
+
// "data":[
|
|
360
|
+
// {
|
|
361
|
+
// "deposit_status":1,
|
|
362
|
+
// "min_deposit_amount":10,
|
|
363
|
+
// "withdraw_fee_rate":0,
|
|
364
|
+
// "min_withdraw_amount":10,
|
|
365
|
+
// "min_withdraw_fee":5,
|
|
366
|
+
// "currency":"USDT",
|
|
367
|
+
// "withdraw_status":0,
|
|
368
|
+
// "chain":"OMNI"
|
|
369
|
+
// },
|
|
370
|
+
// {
|
|
371
|
+
// "deposit_status":1,
|
|
372
|
+
// "min_deposit_amount":10,
|
|
373
|
+
// "withdraw_fee_rate":0,
|
|
374
|
+
// "min_withdraw_amount":10,
|
|
375
|
+
// "min_withdraw_fee":3,
|
|
376
|
+
// "currency":"USDT",
|
|
377
|
+
// "withdraw_status":1,
|
|
378
|
+
// "chain":"ERC20"
|
|
379
|
+
// },
|
|
380
|
+
// {
|
|
381
|
+
// "deposit_status":0,
|
|
382
|
+
// "min_deposit_amount":0,
|
|
383
|
+
// "withdraw_fee_rate":0,
|
|
384
|
+
// "min_withdraw_amount":0,
|
|
385
|
+
// "min_withdraw_fee":0,
|
|
386
|
+
// "currency":"DGF13",
|
|
387
|
+
// "withdraw_status":0,
|
|
388
|
+
// "chain":""
|
|
389
|
+
// },
|
|
390
|
+
// ],
|
|
391
|
+
// "code":200
|
|
392
|
+
// }
|
|
393
|
+
//
|
|
394
|
+
const data = this.safeValue(response, 'data', []);
|
|
395
|
+
const result = {};
|
|
396
|
+
for (let i = 0; i < data.length; i++) {
|
|
397
|
+
const currency = data[i];
|
|
398
|
+
const id = this.safeString(currency, 'currency');
|
|
399
|
+
const code = this.safeCurrencyCode(id);
|
|
400
|
+
const depositStatus = this.safeInteger(currency, 'deposit_status', 1);
|
|
401
|
+
const withdrawStatus = this.safeInteger(currency, 'withdraw_status', 1);
|
|
402
|
+
const deposit = depositStatus > 0;
|
|
403
|
+
const withdraw = withdrawStatus > 0;
|
|
404
|
+
const active = deposit && withdraw;
|
|
405
|
+
const feeString = this.safeString(currency, 'min_withdraw_fee'); // withdraw_fee_rate was zero for all currencies, so this was the worst case scenario
|
|
406
|
+
const minWithdrawString = this.safeString(currency, 'min_withdraw_amount');
|
|
407
|
+
const minDepositString = this.safeString(currency, 'min_deposit_amount');
|
|
408
|
+
const minDeposit = this.parseNumber(minDepositString);
|
|
409
|
+
const minWithdraw = this.parseNumber(minWithdrawString);
|
|
410
|
+
const fee = this.parseNumber(feeString);
|
|
411
|
+
// define precision with temporary way
|
|
412
|
+
const minFoundPrecision = Precise["default"].stringMin(feeString, Precise["default"].stringMin(minDepositString, minWithdrawString));
|
|
413
|
+
const precision = this.parseNumber(minFoundPrecision);
|
|
414
|
+
const networkId = this.safeString(currency, 'chain');
|
|
415
|
+
const networkCode = this.networkIdToCode(networkId);
|
|
416
|
+
const network = {
|
|
417
|
+
'info': currency,
|
|
418
|
+
'id': networkId,
|
|
419
|
+
'network': networkCode,
|
|
420
|
+
'active': active,
|
|
421
|
+
'fee': fee,
|
|
422
|
+
'precision': precision,
|
|
423
|
+
'deposit': deposit,
|
|
424
|
+
'withdraw': withdraw,
|
|
425
|
+
'limits': {
|
|
426
|
+
'amount': {
|
|
427
|
+
'min': undefined,
|
|
428
|
+
'max': undefined,
|
|
429
|
+
},
|
|
430
|
+
'withdraw': {
|
|
431
|
+
'min': minWithdraw,
|
|
432
|
+
'max': undefined,
|
|
433
|
+
},
|
|
434
|
+
'deposit': {
|
|
435
|
+
'min': minDeposit,
|
|
436
|
+
'max': undefined,
|
|
437
|
+
},
|
|
438
|
+
},
|
|
439
|
+
};
|
|
440
|
+
if (code in result) {
|
|
441
|
+
if (Array.isArray(result[code]['info'])) {
|
|
442
|
+
result[code]['info'].push(currency);
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
result[code]['info'] = [result[code]['info'], currency];
|
|
446
|
+
}
|
|
447
|
+
if (withdraw) {
|
|
448
|
+
result[code]['withdraw'] = true;
|
|
449
|
+
result[code]['limits']['withdraw']['min'] = Math.min(result[code]['limits']['withdraw']['min'], minWithdraw);
|
|
450
|
+
}
|
|
451
|
+
if (deposit) {
|
|
452
|
+
result[code]['deposit'] = true;
|
|
453
|
+
result[code]['limits']['deposit']['min'] = Math.min(result[code]['limits']['deposit']['min'], minDeposit);
|
|
454
|
+
}
|
|
455
|
+
if (active) {
|
|
456
|
+
result[code]['active'] = true;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
else {
|
|
460
|
+
result[code] = {
|
|
461
|
+
'id': id,
|
|
462
|
+
'code': code,
|
|
463
|
+
'info': currency,
|
|
464
|
+
'type': undefined,
|
|
465
|
+
'name': undefined,
|
|
466
|
+
'active': active,
|
|
467
|
+
'deposit': deposit,
|
|
468
|
+
'withdraw': withdraw,
|
|
469
|
+
'fee': this.parseNumber(feeString),
|
|
470
|
+
'precision': undefined,
|
|
471
|
+
'limits': {
|
|
472
|
+
'amount': {
|
|
473
|
+
'min': undefined,
|
|
474
|
+
'max': undefined,
|
|
475
|
+
},
|
|
476
|
+
'withdraw': {
|
|
477
|
+
'min': minWithdraw,
|
|
478
|
+
'max': undefined,
|
|
479
|
+
},
|
|
480
|
+
'deposit': {
|
|
481
|
+
'min': minDeposit,
|
|
482
|
+
'max': undefined,
|
|
483
|
+
},
|
|
484
|
+
},
|
|
485
|
+
'networks': {},
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
if (networkId !== undefined) {
|
|
489
|
+
result[code]['networks'][networkId] = network;
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
result[code]['active'] = active;
|
|
493
|
+
result[code]['fee'] = this.parseNumber(feeString);
|
|
494
|
+
result[code]['deposit'] = deposit;
|
|
495
|
+
result[code]['withdraw'] = withdraw;
|
|
496
|
+
result[code]['limits'] = {
|
|
497
|
+
'amount': {
|
|
498
|
+
'min': undefined,
|
|
499
|
+
'max': undefined,
|
|
500
|
+
},
|
|
501
|
+
'withdraw': {
|
|
502
|
+
'min': minWithdraw,
|
|
503
|
+
'max': undefined,
|
|
504
|
+
},
|
|
505
|
+
'deposit': {
|
|
506
|
+
'min': minDeposit,
|
|
507
|
+
'max': undefined,
|
|
508
|
+
},
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
result[code]['precision'] = (result[code]['precision'] === undefined) ? precision : Math.max(result[code]['precision'], precision);
|
|
512
|
+
}
|
|
513
|
+
return result;
|
|
514
|
+
}
|
|
515
|
+
async fetchMarkets(params = {}) {
|
|
516
|
+
/**
|
|
517
|
+
* @method
|
|
518
|
+
* @name digifinex#fetchMarkets
|
|
519
|
+
* @description retrieves data on all markets for digifinex
|
|
520
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
521
|
+
* @returns {object[]} an array of objects representing market data
|
|
522
|
+
*/
|
|
523
|
+
const options = this.safeValue(this.options, 'fetchMarkets', {});
|
|
524
|
+
const method = this.safeString(options, 'method', 'fetch_markets_v2');
|
|
525
|
+
if (method === 'fetch_markets_v2') {
|
|
526
|
+
return await this.fetchMarketsV2(params);
|
|
527
|
+
}
|
|
528
|
+
return await this.fetchMarketsV1(params);
|
|
529
|
+
}
|
|
530
|
+
async fetchMarketsV2(params = {}) {
|
|
531
|
+
const defaultType = this.safeString(this.options, 'defaultType');
|
|
532
|
+
const [marginMode, query] = this.handleMarginModeAndParams('fetchMarketsV2', params);
|
|
533
|
+
const promisesRaw = [];
|
|
534
|
+
if (marginMode !== undefined) {
|
|
535
|
+
promisesRaw.push(this.publicSpotGetMarginSymbols(query));
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
promisesRaw.push(this.publicSpotGetTradesSymbols(query));
|
|
539
|
+
}
|
|
540
|
+
promisesRaw.push(this.publicSwapGetPublicInstruments(params));
|
|
541
|
+
const promises = await Promise.all(promisesRaw);
|
|
542
|
+
const spotMarkets = promises[0];
|
|
543
|
+
const swapMarkets = promises[1];
|
|
544
|
+
//
|
|
545
|
+
// spot and margin
|
|
546
|
+
//
|
|
547
|
+
// {
|
|
548
|
+
// "symbol_list":[
|
|
549
|
+
// {
|
|
550
|
+
// "order_types":["LIMIT","MARKET"],
|
|
551
|
+
// "quote_asset":"USDT",
|
|
552
|
+
// "minimum_value":2,
|
|
553
|
+
// "amount_precision":4,
|
|
554
|
+
// "status":"TRADING",
|
|
555
|
+
// "minimum_amount":0.0001,
|
|
556
|
+
// "symbol":"BTC_USDT",
|
|
557
|
+
// "is_allow":1,
|
|
558
|
+
// "zone":"MAIN",
|
|
559
|
+
// "base_asset":"BTC",
|
|
560
|
+
// "price_precision":2
|
|
561
|
+
// }
|
|
562
|
+
// ],
|
|
563
|
+
// "code":0
|
|
564
|
+
// }
|
|
565
|
+
//
|
|
566
|
+
// swap
|
|
567
|
+
//
|
|
568
|
+
// {
|
|
569
|
+
// "code": 0,
|
|
570
|
+
// "data": [
|
|
571
|
+
// {
|
|
572
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
573
|
+
// "type": "REAL",
|
|
574
|
+
// "contract_type": "PERPETUAL",
|
|
575
|
+
// "base_currency": "BTC",
|
|
576
|
+
// "quote_currency": "USDT",
|
|
577
|
+
// "clear_currency": "USDT",
|
|
578
|
+
// "contract_value": "0.001",
|
|
579
|
+
// "contract_value_currency": "BTC",
|
|
580
|
+
// "is_inverse": false,
|
|
581
|
+
// "is_trading": true,
|
|
582
|
+
// "status": "ONLINE",
|
|
583
|
+
// "price_precision": 4,
|
|
584
|
+
// "tick_size": "0.0001",
|
|
585
|
+
// "min_order_amount": 1,
|
|
586
|
+
// "open_max_limits": [
|
|
587
|
+
// {
|
|
588
|
+
// "leverage": "50",
|
|
589
|
+
// "max_limit": "1000000"
|
|
590
|
+
// }
|
|
591
|
+
// ]
|
|
592
|
+
// },
|
|
593
|
+
// ]
|
|
594
|
+
// }
|
|
595
|
+
//
|
|
596
|
+
const spotData = this.safeValue(spotMarkets, 'symbol_list', []);
|
|
597
|
+
const swapData = this.safeValue(swapMarkets, 'data', []);
|
|
598
|
+
const response = this.arrayConcat(spotData, swapData);
|
|
599
|
+
const result = [];
|
|
600
|
+
for (let i = 0; i < response.length; i++) {
|
|
601
|
+
const market = response[i];
|
|
602
|
+
const id = this.safeString2(market, 'symbol', 'instrument_id');
|
|
603
|
+
const baseId = this.safeString2(market, 'base_asset', 'base_currency');
|
|
604
|
+
const quoteId = this.safeString2(market, 'quote_asset', 'quote_currency');
|
|
605
|
+
const settleId = this.safeString(market, 'clear_currency');
|
|
606
|
+
const base = this.safeCurrencyCode(baseId);
|
|
607
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
608
|
+
const settle = this.safeCurrencyCode(settleId);
|
|
609
|
+
//
|
|
610
|
+
// The status is documented in the exchange API docs as follows:
|
|
611
|
+
// TRADING, HALT (delisted), BREAK (trading paused)
|
|
612
|
+
// https://docs.digifinex.vip/en-ww/v3/#/public/spot/symbols
|
|
613
|
+
// However, all spot markets actually have status === 'HALT'
|
|
614
|
+
// despite that they appear to be active on the exchange website.
|
|
615
|
+
// Apparently, we can't trust this status.
|
|
616
|
+
// const status = this.safeString (market, 'status');
|
|
617
|
+
// const active = (status === 'TRADING');
|
|
618
|
+
//
|
|
619
|
+
let isAllowed = this.safeInteger(market, 'is_allow', 1);
|
|
620
|
+
let type = (defaultType === 'margin') ? 'margin' : 'spot';
|
|
621
|
+
const spot = settle === undefined;
|
|
622
|
+
const swap = !spot;
|
|
623
|
+
const margin = (marginMode !== undefined) ? true : undefined;
|
|
624
|
+
let symbol = base + '/' + quote;
|
|
625
|
+
let isInverse = undefined;
|
|
626
|
+
let isLinear = undefined;
|
|
627
|
+
if (swap) {
|
|
628
|
+
type = 'swap';
|
|
629
|
+
symbol = base + '/' + quote + ':' + settle;
|
|
630
|
+
isInverse = this.safeValue(market, 'is_inverse');
|
|
631
|
+
isLinear = (!isInverse) ? true : false;
|
|
632
|
+
const isTrading = this.safeValue(market, 'isTrading');
|
|
633
|
+
if (isTrading) {
|
|
634
|
+
isAllowed = 1;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
result.push({
|
|
638
|
+
'id': id,
|
|
639
|
+
'symbol': symbol,
|
|
640
|
+
'base': base,
|
|
641
|
+
'quote': quote,
|
|
642
|
+
'settle': settle,
|
|
643
|
+
'baseId': baseId,
|
|
644
|
+
'quoteId': quoteId,
|
|
645
|
+
'settleId': settleId,
|
|
646
|
+
'type': type,
|
|
647
|
+
'spot': spot,
|
|
648
|
+
'margin': margin,
|
|
649
|
+
'swap': swap,
|
|
650
|
+
'future': false,
|
|
651
|
+
'option': false,
|
|
652
|
+
'active': isAllowed ? true : false,
|
|
653
|
+
'contract': swap,
|
|
654
|
+
'linear': isLinear,
|
|
655
|
+
'inverse': isInverse,
|
|
656
|
+
'contractSize': this.safeNumber(market, 'contract_value'),
|
|
657
|
+
'expiry': undefined,
|
|
658
|
+
'expiryDatetime': undefined,
|
|
659
|
+
'strike': undefined,
|
|
660
|
+
'optionType': undefined,
|
|
661
|
+
'precision': {
|
|
662
|
+
'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'amount_precision'))),
|
|
663
|
+
'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'price_precision'))),
|
|
664
|
+
},
|
|
665
|
+
'limits': {
|
|
666
|
+
'leverage': {
|
|
667
|
+
'min': undefined,
|
|
668
|
+
'max': undefined,
|
|
669
|
+
},
|
|
670
|
+
'amount': {
|
|
671
|
+
'min': this.safeNumber2(market, 'minimum_amount', 'min_order_amount'),
|
|
672
|
+
'max': undefined,
|
|
673
|
+
},
|
|
674
|
+
'price': {
|
|
675
|
+
'min': this.safeNumber(market, 'tick_size'),
|
|
676
|
+
'max': undefined,
|
|
677
|
+
},
|
|
678
|
+
'cost': {
|
|
679
|
+
'min': this.safeNumber(market, 'minimum_value'),
|
|
680
|
+
'max': undefined,
|
|
681
|
+
},
|
|
682
|
+
},
|
|
683
|
+
'created': undefined,
|
|
684
|
+
'info': market,
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
return result;
|
|
688
|
+
}
|
|
689
|
+
async fetchMarketsV1(params = {}) {
|
|
690
|
+
const response = await this.publicSpotGetMarkets(params);
|
|
691
|
+
//
|
|
692
|
+
// {
|
|
693
|
+
// "data": [
|
|
694
|
+
// {
|
|
695
|
+
// "volume_precision":4,
|
|
696
|
+
// "price_precision":2,
|
|
697
|
+
// "market":"btc_usdt",
|
|
698
|
+
// "min_amount":2,
|
|
699
|
+
// "min_volume":0.0001
|
|
700
|
+
// },
|
|
701
|
+
// ],
|
|
702
|
+
// "date":1564507456,
|
|
703
|
+
// "code":0
|
|
704
|
+
// }
|
|
705
|
+
//
|
|
706
|
+
const markets = this.safeValue(response, 'data', []);
|
|
707
|
+
const result = [];
|
|
708
|
+
for (let i = 0; i < markets.length; i++) {
|
|
709
|
+
const market = markets[i];
|
|
710
|
+
const id = this.safeString(market, 'market');
|
|
711
|
+
const [baseId, quoteId] = id.split('_');
|
|
712
|
+
const base = this.safeCurrencyCode(baseId);
|
|
713
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
714
|
+
result.push({
|
|
715
|
+
'id': id,
|
|
716
|
+
'symbol': base + '/' + quote,
|
|
717
|
+
'base': base,
|
|
718
|
+
'quote': quote,
|
|
719
|
+
'settle': undefined,
|
|
720
|
+
'baseId': baseId,
|
|
721
|
+
'quoteId': quoteId,
|
|
722
|
+
'settleId': undefined,
|
|
723
|
+
'type': 'spot',
|
|
724
|
+
'spot': true,
|
|
725
|
+
'margin': undefined,
|
|
726
|
+
'swap': false,
|
|
727
|
+
'future': false,
|
|
728
|
+
'option': false,
|
|
729
|
+
'active': undefined,
|
|
730
|
+
'contract': false,
|
|
731
|
+
'linear': undefined,
|
|
732
|
+
'inverse': undefined,
|
|
733
|
+
'contractSize': undefined,
|
|
734
|
+
'expiry': undefined,
|
|
735
|
+
'expiryDatetime': undefined,
|
|
736
|
+
'strike': undefined,
|
|
737
|
+
'optionType': undefined,
|
|
738
|
+
'precision': {
|
|
739
|
+
'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'price_precision'))),
|
|
740
|
+
'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'volume_precision'))),
|
|
741
|
+
},
|
|
742
|
+
'limits': {
|
|
743
|
+
'leverage': {
|
|
744
|
+
'min': undefined,
|
|
745
|
+
'max': undefined,
|
|
746
|
+
},
|
|
747
|
+
'amount': {
|
|
748
|
+
'min': this.safeNumber(market, 'min_volume'),
|
|
749
|
+
'max': undefined,
|
|
750
|
+
},
|
|
751
|
+
'price': {
|
|
752
|
+
'min': undefined,
|
|
753
|
+
'max': undefined,
|
|
754
|
+
},
|
|
755
|
+
'cost': {
|
|
756
|
+
'min': this.safeNumber(market, 'min_amount'),
|
|
757
|
+
'max': undefined,
|
|
758
|
+
},
|
|
759
|
+
},
|
|
760
|
+
'info': market,
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
return result;
|
|
764
|
+
}
|
|
765
|
+
parseBalance(response) {
|
|
766
|
+
//
|
|
767
|
+
// spot and margin
|
|
768
|
+
//
|
|
769
|
+
// {
|
|
770
|
+
// "currency": "BTC",
|
|
771
|
+
// "free": 4723846.89208129,
|
|
772
|
+
// "total": 0
|
|
773
|
+
// }
|
|
774
|
+
//
|
|
775
|
+
// swap
|
|
776
|
+
//
|
|
777
|
+
// {
|
|
778
|
+
// "equity": "0",
|
|
779
|
+
// "currency": "BTC",
|
|
780
|
+
// "margin": "0",
|
|
781
|
+
// "frozen_margin": "0",
|
|
782
|
+
// "frozen_money": "0",
|
|
783
|
+
// "margin_ratio": "0",
|
|
784
|
+
// "realized_pnl": "0",
|
|
785
|
+
// "avail_balance": "0",
|
|
786
|
+
// "unrealized_pnl": "0",
|
|
787
|
+
// "time_stamp": 1661487402396
|
|
788
|
+
// }
|
|
789
|
+
//
|
|
790
|
+
const result = { 'info': response };
|
|
791
|
+
for (let i = 0; i < response.length; i++) {
|
|
792
|
+
const balance = response[i];
|
|
793
|
+
const currencyId = this.safeString(balance, 'currency');
|
|
794
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
795
|
+
const account = this.account();
|
|
796
|
+
const free = this.safeString2(balance, 'free', 'avail_balance');
|
|
797
|
+
const total = this.safeString2(balance, 'total', 'equity');
|
|
798
|
+
account['free'] = free;
|
|
799
|
+
account['used'] = Precise["default"].stringSub(total, free);
|
|
800
|
+
account['total'] = total;
|
|
801
|
+
result[code] = account;
|
|
802
|
+
}
|
|
803
|
+
return this.safeBalance(result);
|
|
804
|
+
}
|
|
805
|
+
async fetchBalance(params = {}) {
|
|
806
|
+
/**
|
|
807
|
+
* @method
|
|
808
|
+
* @name digifinex#fetchBalance
|
|
809
|
+
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
810
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#spot-account-assets
|
|
811
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
|
|
812
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#accountbalance
|
|
813
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
814
|
+
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
815
|
+
*/
|
|
816
|
+
await this.loadMarkets();
|
|
817
|
+
let marketType = undefined;
|
|
818
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
|
|
819
|
+
const [marginMode, query] = this.handleMarginModeAndParams('fetchBalance', params);
|
|
820
|
+
let response = undefined;
|
|
821
|
+
if (marginMode !== undefined || marketType === 'margin') {
|
|
822
|
+
marketType = 'margin';
|
|
823
|
+
response = await this.privateSpotGetMarginAssets(query);
|
|
824
|
+
}
|
|
825
|
+
else if (marketType === 'spot') {
|
|
826
|
+
response = await this.privateSpotGetSpotAssets(query);
|
|
827
|
+
}
|
|
828
|
+
else if (marketType === 'swap') {
|
|
829
|
+
response = await this.privateSwapGetAccountBalance(query);
|
|
830
|
+
}
|
|
831
|
+
else {
|
|
832
|
+
throw new errors.NotSupported(this.id + ' fetchBalance() not support this market type');
|
|
833
|
+
}
|
|
834
|
+
//
|
|
835
|
+
// spot and margin
|
|
836
|
+
//
|
|
837
|
+
// {
|
|
838
|
+
// "code": 0,
|
|
839
|
+
// "list": [
|
|
840
|
+
// {
|
|
841
|
+
// "currency": "BTC",
|
|
842
|
+
// "free": 4723846.89208129,
|
|
843
|
+
// "total": 0
|
|
844
|
+
// },
|
|
845
|
+
// ...
|
|
846
|
+
// ]
|
|
847
|
+
// }
|
|
848
|
+
//
|
|
849
|
+
// swap
|
|
850
|
+
//
|
|
851
|
+
// {
|
|
852
|
+
// "code": 0,
|
|
853
|
+
// "data": [
|
|
854
|
+
// {
|
|
855
|
+
// "equity": "0",
|
|
856
|
+
// "currency": "BTC",
|
|
857
|
+
// "margin": "0",
|
|
858
|
+
// "frozen_margin": "0",
|
|
859
|
+
// "frozen_money": "0",
|
|
860
|
+
// "margin_ratio": "0",
|
|
861
|
+
// "realized_pnl": "0",
|
|
862
|
+
// "avail_balance": "0",
|
|
863
|
+
// "unrealized_pnl": "0",
|
|
864
|
+
// "time_stamp": 1661487402396
|
|
865
|
+
// },
|
|
866
|
+
// ...
|
|
867
|
+
// ]
|
|
868
|
+
// }
|
|
869
|
+
//
|
|
870
|
+
const balanceRequest = (marketType === 'swap') ? 'data' : 'list';
|
|
871
|
+
const balances = this.safeValue(response, balanceRequest, []);
|
|
872
|
+
return this.parseBalance(balances);
|
|
873
|
+
}
|
|
874
|
+
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
875
|
+
/**
|
|
876
|
+
* @method
|
|
877
|
+
* @name digifinex#fetchOrderBook
|
|
878
|
+
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
879
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-orderbook
|
|
880
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderbook
|
|
881
|
+
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
882
|
+
* @param {int} [limit] the maximum amount of order book entries to return
|
|
883
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
884
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
885
|
+
*/
|
|
886
|
+
await this.loadMarkets();
|
|
887
|
+
const market = this.market(symbol);
|
|
888
|
+
const [marketType, query] = this.handleMarketTypeAndParams('fetchOrderBook', market, params);
|
|
889
|
+
const request = {};
|
|
890
|
+
if (limit !== undefined) {
|
|
891
|
+
request['limit'] = limit;
|
|
892
|
+
}
|
|
893
|
+
let response = undefined;
|
|
894
|
+
if (marketType === 'swap') {
|
|
895
|
+
request['instrument_id'] = market['id'];
|
|
896
|
+
response = await this.publicSwapGetPublicDepth(this.extend(request, query));
|
|
897
|
+
}
|
|
898
|
+
else {
|
|
899
|
+
request['symbol'] = market['id'];
|
|
900
|
+
response = await this.publicSpotGetOrderBook(this.extend(request, query));
|
|
901
|
+
}
|
|
902
|
+
//
|
|
903
|
+
// spot
|
|
904
|
+
//
|
|
905
|
+
// {
|
|
906
|
+
// "bids": [
|
|
907
|
+
// [9605.77,0.0016],
|
|
908
|
+
// [9605.46,0.0003],
|
|
909
|
+
// [9602.04,0.0127],
|
|
910
|
+
// ],
|
|
911
|
+
// "asks": [
|
|
912
|
+
// [9627.22,0.025803],
|
|
913
|
+
// [9627.12,0.168543],
|
|
914
|
+
// [9626.52,0.0011529],
|
|
915
|
+
// ],
|
|
916
|
+
// "date":1564509499,
|
|
917
|
+
// "code":0
|
|
918
|
+
// }
|
|
919
|
+
//
|
|
920
|
+
// swap
|
|
921
|
+
//
|
|
922
|
+
// {
|
|
923
|
+
// "code": 0,
|
|
924
|
+
// "data": {
|
|
925
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
926
|
+
// "timestamp": 1667975290425,
|
|
927
|
+
// "asks": [
|
|
928
|
+
// ["18384.7",3492],
|
|
929
|
+
// ["18402.7",5000],
|
|
930
|
+
// ["18406.7",5000],
|
|
931
|
+
// ],
|
|
932
|
+
// "bids": [
|
|
933
|
+
// ["18366.2",4395],
|
|
934
|
+
// ["18364.3",3070],
|
|
935
|
+
// ["18359.4",5000],
|
|
936
|
+
// ]
|
|
937
|
+
// }
|
|
938
|
+
// }
|
|
939
|
+
//
|
|
940
|
+
let timestamp = undefined;
|
|
941
|
+
let orderBook = undefined;
|
|
942
|
+
if (marketType === 'swap') {
|
|
943
|
+
orderBook = this.safeValue(response, 'data', {});
|
|
944
|
+
timestamp = this.safeInteger(orderBook, 'timestamp');
|
|
945
|
+
}
|
|
946
|
+
else {
|
|
947
|
+
orderBook = response;
|
|
948
|
+
timestamp = this.safeTimestamp(response, 'date');
|
|
949
|
+
}
|
|
950
|
+
return this.parseOrderBook(orderBook, market['symbol'], timestamp);
|
|
951
|
+
}
|
|
952
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
953
|
+
/**
|
|
954
|
+
* @method
|
|
955
|
+
* @name digifinex#fetchTickers
|
|
956
|
+
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
957
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#ticker-price
|
|
958
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#tickers
|
|
959
|
+
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
960
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
961
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
962
|
+
*/
|
|
963
|
+
await this.loadMarkets();
|
|
964
|
+
symbols = this.marketSymbols(symbols);
|
|
965
|
+
const first = this.safeString(symbols, 0);
|
|
966
|
+
let market = undefined;
|
|
967
|
+
if (first !== undefined) {
|
|
968
|
+
market = this.market(first);
|
|
969
|
+
}
|
|
970
|
+
let type = undefined;
|
|
971
|
+
[type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
|
|
972
|
+
const request = {};
|
|
973
|
+
let response = undefined;
|
|
974
|
+
if (type === 'swap') {
|
|
975
|
+
response = await this.publicSwapGetPublicTickers(this.extend(request, params));
|
|
976
|
+
}
|
|
977
|
+
else {
|
|
978
|
+
response = await this.publicSpotGetTicker(this.extend(request, params));
|
|
979
|
+
}
|
|
980
|
+
//
|
|
981
|
+
// spot
|
|
982
|
+
//
|
|
983
|
+
// {
|
|
984
|
+
// "ticker": [{
|
|
985
|
+
// "vol": 40717.4461,
|
|
986
|
+
// "change": -1.91,
|
|
987
|
+
// "base_vol": 392447999.65374,
|
|
988
|
+
// "sell": 9592.23,
|
|
989
|
+
// "last": 9592.22,
|
|
990
|
+
// "symbol": "btc_usdt",
|
|
991
|
+
// "low": 9476.24,
|
|
992
|
+
// "buy": 9592.03,
|
|
993
|
+
// "high": 9793.87
|
|
994
|
+
// }],
|
|
995
|
+
// "date": 1589874294,
|
|
996
|
+
// "code": 0
|
|
997
|
+
// }
|
|
998
|
+
//
|
|
999
|
+
// swap
|
|
1000
|
+
//
|
|
1001
|
+
// {
|
|
1002
|
+
// "code": 0,
|
|
1003
|
+
// "data": [
|
|
1004
|
+
// {
|
|
1005
|
+
// "instrument_id": "SUSHIUSDTPERP",
|
|
1006
|
+
// "index_price": "1.1297",
|
|
1007
|
+
// "mark_price": "1.1289",
|
|
1008
|
+
// "max_buy_price": "1.1856",
|
|
1009
|
+
// "min_sell_price": "1.0726",
|
|
1010
|
+
// "best_bid": "1.1278",
|
|
1011
|
+
// "best_bid_size": "500",
|
|
1012
|
+
// "best_ask": "1.1302",
|
|
1013
|
+
// "best_ask_size": "471",
|
|
1014
|
+
// "high_24h": "1.2064",
|
|
1015
|
+
// "open_24h": "1.1938",
|
|
1016
|
+
// "low_24h": "1.1239",
|
|
1017
|
+
// "last": "1.1302",
|
|
1018
|
+
// "last_qty": "29",
|
|
1019
|
+
// "volume_24h": "4946163",
|
|
1020
|
+
// "price_change_percent": "-0.053275255486681085",
|
|
1021
|
+
// "open_interest": "-",
|
|
1022
|
+
// "timestamp": 1663222782100
|
|
1023
|
+
// },
|
|
1024
|
+
// ...
|
|
1025
|
+
// ]
|
|
1026
|
+
// }
|
|
1027
|
+
//
|
|
1028
|
+
const result = {};
|
|
1029
|
+
const tickers = this.safeValue2(response, 'ticker', 'data', []);
|
|
1030
|
+
const date = this.safeInteger(response, 'date');
|
|
1031
|
+
for (let i = 0; i < tickers.length; i++) {
|
|
1032
|
+
const rawTicker = this.extend({
|
|
1033
|
+
'date': date,
|
|
1034
|
+
}, tickers[i]);
|
|
1035
|
+
const ticker = this.parseTicker(rawTicker);
|
|
1036
|
+
const symbol = ticker['symbol'];
|
|
1037
|
+
result[symbol] = ticker;
|
|
1038
|
+
}
|
|
1039
|
+
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
1040
|
+
}
|
|
1041
|
+
async fetchTicker(symbol, params = {}) {
|
|
1042
|
+
/**
|
|
1043
|
+
* @method
|
|
1044
|
+
* @name digifinex#fetchTicker
|
|
1045
|
+
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
1046
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#ticker-price
|
|
1047
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#ticker
|
|
1048
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
1049
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1050
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1051
|
+
*/
|
|
1052
|
+
await this.loadMarkets();
|
|
1053
|
+
const market = this.market(symbol);
|
|
1054
|
+
const request = {};
|
|
1055
|
+
let response = undefined;
|
|
1056
|
+
if (market['swap']) {
|
|
1057
|
+
request['instrument_id'] = market['id'];
|
|
1058
|
+
response = await this.publicSwapGetPublicTicker(this.extend(request, params));
|
|
1059
|
+
}
|
|
1060
|
+
else {
|
|
1061
|
+
request['symbol'] = market['id'];
|
|
1062
|
+
response = await this.publicSpotGetTicker(this.extend(request, params));
|
|
1063
|
+
}
|
|
1064
|
+
//
|
|
1065
|
+
// spot
|
|
1066
|
+
//
|
|
1067
|
+
// {
|
|
1068
|
+
// "ticker": [{
|
|
1069
|
+
// "vol": 40717.4461,
|
|
1070
|
+
// "change": -1.91,
|
|
1071
|
+
// "base_vol": 392447999.65374,
|
|
1072
|
+
// "sell": 9592.23,
|
|
1073
|
+
// "last": 9592.22,
|
|
1074
|
+
// "symbol": "btc_usdt",
|
|
1075
|
+
// "low": 9476.24,
|
|
1076
|
+
// "buy": 9592.03,
|
|
1077
|
+
// "high": 9793.87
|
|
1078
|
+
// }],
|
|
1079
|
+
// "date": 1589874294,
|
|
1080
|
+
// "code": 0
|
|
1081
|
+
// }
|
|
1082
|
+
//
|
|
1083
|
+
// swap
|
|
1084
|
+
//
|
|
1085
|
+
// {
|
|
1086
|
+
// "code": 0,
|
|
1087
|
+
// "data": {
|
|
1088
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
1089
|
+
// "index_price": "20141.9967",
|
|
1090
|
+
// "mark_price": "20139.3404",
|
|
1091
|
+
// "max_buy_price": "21146.4838",
|
|
1092
|
+
// "min_sell_price": "19132.2725",
|
|
1093
|
+
// "best_bid": "20140.0998",
|
|
1094
|
+
// "best_bid_size": "3116",
|
|
1095
|
+
// "best_ask": "20140.0999",
|
|
1096
|
+
// "best_ask_size": "9004",
|
|
1097
|
+
// "high_24h": "20410.6496",
|
|
1098
|
+
// "open_24h": "20308.6998",
|
|
1099
|
+
// "low_24h": "19600",
|
|
1100
|
+
// "last": "20140.0999",
|
|
1101
|
+
// "last_qty": "2",
|
|
1102
|
+
// "volume_24h": "49382816",
|
|
1103
|
+
// "price_change_percent": "-0.008301855936636448",
|
|
1104
|
+
// "open_interest": "-",
|
|
1105
|
+
// "timestamp": 1663221614998
|
|
1106
|
+
// }
|
|
1107
|
+
// }
|
|
1108
|
+
//
|
|
1109
|
+
const date = this.safeInteger(response, 'date');
|
|
1110
|
+
const tickers = this.safeValue(response, 'ticker', []);
|
|
1111
|
+
const data = this.safeValue(response, 'data', {});
|
|
1112
|
+
const firstTicker = this.safeValue(tickers, 0, {});
|
|
1113
|
+
let result = undefined;
|
|
1114
|
+
if (market['swap']) {
|
|
1115
|
+
result = data;
|
|
1116
|
+
}
|
|
1117
|
+
else {
|
|
1118
|
+
result = this.extend({ 'date': date }, firstTicker);
|
|
1119
|
+
}
|
|
1120
|
+
return this.parseTicker(result, market);
|
|
1121
|
+
}
|
|
1122
|
+
parseTicker(ticker, market = undefined) {
|
|
1123
|
+
//
|
|
1124
|
+
// spot: fetchTicker, fetchTickers
|
|
1125
|
+
//
|
|
1126
|
+
// {
|
|
1127
|
+
// "last":0.021957,
|
|
1128
|
+
// "symbol": "btc_usdt",
|
|
1129
|
+
// "base_vol":2249.3521732227,
|
|
1130
|
+
// "change":-0.6,
|
|
1131
|
+
// "vol":102443.5111,
|
|
1132
|
+
// "sell":0.021978,
|
|
1133
|
+
// "low":0.021791,
|
|
1134
|
+
// "buy":0.021946,
|
|
1135
|
+
// "high":0.022266,
|
|
1136
|
+
// "date"1564518452, // injected from fetchTicker/fetchTickers
|
|
1137
|
+
// }
|
|
1138
|
+
//
|
|
1139
|
+
// swap: fetchTicker, fetchTickers
|
|
1140
|
+
//
|
|
1141
|
+
// {
|
|
1142
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
1143
|
+
// "index_price": "20141.9967",
|
|
1144
|
+
// "mark_price": "20139.3404",
|
|
1145
|
+
// "max_buy_price": "21146.4838",
|
|
1146
|
+
// "min_sell_price": "19132.2725",
|
|
1147
|
+
// "best_bid": "20140.0998",
|
|
1148
|
+
// "best_bid_size": "3116",
|
|
1149
|
+
// "best_ask": "20140.0999",
|
|
1150
|
+
// "best_ask_size": "9004",
|
|
1151
|
+
// "high_24h": "20410.6496",
|
|
1152
|
+
// "open_24h": "20308.6998",
|
|
1153
|
+
// "low_24h": "19600",
|
|
1154
|
+
// "last": "20140.0999",
|
|
1155
|
+
// "last_qty": "2",
|
|
1156
|
+
// "volume_24h": "49382816",
|
|
1157
|
+
// "price_change_percent": "-0.008301855936636448",
|
|
1158
|
+
// "open_interest": "-",
|
|
1159
|
+
// "timestamp": 1663221614998
|
|
1160
|
+
// }
|
|
1161
|
+
//
|
|
1162
|
+
const marketId = this.safeStringUpper2(ticker, 'symbol', 'instrument_id');
|
|
1163
|
+
const symbol = this.safeSymbol(marketId, market);
|
|
1164
|
+
market = this.safeMarket(marketId);
|
|
1165
|
+
let timestamp = this.safeTimestamp(ticker, 'date');
|
|
1166
|
+
if (market['swap']) {
|
|
1167
|
+
timestamp = this.safeInteger(ticker, 'timestamp');
|
|
1168
|
+
}
|
|
1169
|
+
const last = this.safeString(ticker, 'last');
|
|
1170
|
+
return this.safeTicker({
|
|
1171
|
+
'symbol': symbol,
|
|
1172
|
+
'timestamp': timestamp,
|
|
1173
|
+
'datetime': this.iso8601(timestamp),
|
|
1174
|
+
'high': this.safeString2(ticker, 'high', 'high_24h'),
|
|
1175
|
+
'low': this.safeString2(ticker, 'low', 'low_24h'),
|
|
1176
|
+
'bid': this.safeString2(ticker, 'buy', 'best_bid'),
|
|
1177
|
+
'bidVolume': this.safeString(ticker, 'best_bid_size'),
|
|
1178
|
+
'ask': this.safeString2(ticker, 'sell', 'best_ask'),
|
|
1179
|
+
'askVolume': this.safeString(ticker, 'best_ask_size'),
|
|
1180
|
+
'vwap': undefined,
|
|
1181
|
+
'open': this.safeString(ticker, 'open_24h'),
|
|
1182
|
+
'close': last,
|
|
1183
|
+
'last': last,
|
|
1184
|
+
'previousClose': undefined,
|
|
1185
|
+
'change': undefined,
|
|
1186
|
+
'percentage': this.safeString2(ticker, 'change', 'price_change_percent'),
|
|
1187
|
+
'average': undefined,
|
|
1188
|
+
'baseVolume': this.safeString2(ticker, 'vol', 'volume_24h'),
|
|
1189
|
+
'quoteVolume': this.safeString(ticker, 'base_vol'),
|
|
1190
|
+
'info': ticker,
|
|
1191
|
+
}, market);
|
|
1192
|
+
}
|
|
1193
|
+
parseTrade(trade, market = undefined) {
|
|
1194
|
+
//
|
|
1195
|
+
// spot: fetchTrades
|
|
1196
|
+
//
|
|
1197
|
+
// {
|
|
1198
|
+
// "date":1564520003,
|
|
1199
|
+
// "id":1596149203,
|
|
1200
|
+
// "amount":0.7073,
|
|
1201
|
+
// "type":"buy",
|
|
1202
|
+
// "price":0.02193,
|
|
1203
|
+
// }
|
|
1204
|
+
//
|
|
1205
|
+
// swap: fetchTrades
|
|
1206
|
+
//
|
|
1207
|
+
// {
|
|
1208
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
1209
|
+
// "trade_id": "1595190773677035521",
|
|
1210
|
+
// "direction": "4",
|
|
1211
|
+
// "volume": "4",
|
|
1212
|
+
// "price": "16188.3",
|
|
1213
|
+
// "trade_time": 1669158092314
|
|
1214
|
+
// }
|
|
1215
|
+
//
|
|
1216
|
+
// spot: fetchMyTrades
|
|
1217
|
+
//
|
|
1218
|
+
// {
|
|
1219
|
+
// "symbol": "BTC_USDT",
|
|
1220
|
+
// "order_id": "6707cbdcda0edfaa7f4ab509e4cbf966",
|
|
1221
|
+
// "id": 28457,
|
|
1222
|
+
// "price": 0.1,
|
|
1223
|
+
// "amount": 0,
|
|
1224
|
+
// "fee": 0.096,
|
|
1225
|
+
// "fee_currency": "USDT",
|
|
1226
|
+
// "timestamp": 1499865549,
|
|
1227
|
+
// "side": "buy", // or "side": "sell_market"
|
|
1228
|
+
// "is_maker": true
|
|
1229
|
+
// }
|
|
1230
|
+
//
|
|
1231
|
+
// swap: fetchMyTrades
|
|
1232
|
+
//
|
|
1233
|
+
// {
|
|
1234
|
+
// "trade_id": "1590136768424841218",
|
|
1235
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
1236
|
+
// "order_id": "1590136768156405760",
|
|
1237
|
+
// "type": 1,
|
|
1238
|
+
// "order_type": 8,
|
|
1239
|
+
// "price": "18514.5",
|
|
1240
|
+
// "size": "1",
|
|
1241
|
+
// "fee": "0.00925725",
|
|
1242
|
+
// "close_profit": "0",
|
|
1243
|
+
// "leverage": "20",
|
|
1244
|
+
// "trade_type": 0,
|
|
1245
|
+
// "match_role": 1,
|
|
1246
|
+
// "trade_time": 1667953123562
|
|
1247
|
+
// }
|
|
1248
|
+
//
|
|
1249
|
+
const id = this.safeString2(trade, 'id', 'trade_id');
|
|
1250
|
+
const orderId = this.safeString(trade, 'order_id');
|
|
1251
|
+
const priceString = this.safeString(trade, 'price');
|
|
1252
|
+
const amountString = this.safeStringN(trade, ['amount', 'volume', 'size']);
|
|
1253
|
+
const marketId = this.safeStringUpper2(trade, 'symbol', 'instrument_id');
|
|
1254
|
+
const symbol = this.safeSymbol(marketId, market);
|
|
1255
|
+
if (market === undefined) {
|
|
1256
|
+
market = this.safeMarket(marketId);
|
|
1257
|
+
}
|
|
1258
|
+
let timestamp = this.safeTimestamp2(trade, 'date', 'timestamp');
|
|
1259
|
+
let side = this.safeString2(trade, 'type', 'side');
|
|
1260
|
+
let type = undefined;
|
|
1261
|
+
let takerOrMaker = undefined;
|
|
1262
|
+
if (market['type'] === 'swap') {
|
|
1263
|
+
timestamp = this.safeInteger(trade, 'trade_time');
|
|
1264
|
+
const orderType = this.safeString(trade, 'order_type');
|
|
1265
|
+
const tradeRole = this.safeString(trade, 'match_role');
|
|
1266
|
+
const direction = this.safeString(trade, 'direction');
|
|
1267
|
+
if (orderType !== undefined) {
|
|
1268
|
+
type = (orderType === '0') ? 'limit' : undefined;
|
|
1269
|
+
}
|
|
1270
|
+
if (tradeRole === '1') {
|
|
1271
|
+
takerOrMaker = 'taker';
|
|
1272
|
+
}
|
|
1273
|
+
else if (tradeRole === '2') {
|
|
1274
|
+
takerOrMaker = 'maker';
|
|
1275
|
+
}
|
|
1276
|
+
else {
|
|
1277
|
+
takerOrMaker = undefined;
|
|
1278
|
+
}
|
|
1279
|
+
if ((side === '1') || (direction === '1')) {
|
|
1280
|
+
// side = 'open long';
|
|
1281
|
+
side = 'buy';
|
|
1282
|
+
}
|
|
1283
|
+
else if ((side === '2') || (direction === '2')) {
|
|
1284
|
+
// side = 'open short';
|
|
1285
|
+
side = 'sell';
|
|
1286
|
+
}
|
|
1287
|
+
else if ((side === '3') || (direction === '3')) {
|
|
1288
|
+
// side = 'close long';
|
|
1289
|
+
side = 'sell';
|
|
1290
|
+
}
|
|
1291
|
+
else if ((side === '4') || (direction === '4')) {
|
|
1292
|
+
// side = 'close short';
|
|
1293
|
+
side = 'buy';
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
else {
|
|
1297
|
+
const parts = side.split('_');
|
|
1298
|
+
side = this.safeString(parts, 0);
|
|
1299
|
+
type = this.safeString(parts, 1);
|
|
1300
|
+
if (type === undefined) {
|
|
1301
|
+
type = 'limit';
|
|
1302
|
+
}
|
|
1303
|
+
const isMaker = this.safeValue(trade, 'is_maker');
|
|
1304
|
+
takerOrMaker = isMaker ? 'maker' : 'taker';
|
|
1305
|
+
}
|
|
1306
|
+
let fee = undefined;
|
|
1307
|
+
const feeCostString = this.safeString(trade, 'fee');
|
|
1308
|
+
if (feeCostString !== undefined) {
|
|
1309
|
+
const feeCurrencyId = this.safeString(trade, 'fee_currency');
|
|
1310
|
+
let feeCurrencyCode = undefined;
|
|
1311
|
+
if (feeCurrencyId !== undefined) {
|
|
1312
|
+
feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
|
|
1313
|
+
}
|
|
1314
|
+
fee = {
|
|
1315
|
+
'cost': feeCostString,
|
|
1316
|
+
'currency': feeCurrencyCode,
|
|
1317
|
+
};
|
|
1318
|
+
}
|
|
1319
|
+
return this.safeTrade({
|
|
1320
|
+
'id': id,
|
|
1321
|
+
'info': trade,
|
|
1322
|
+
'timestamp': timestamp,
|
|
1323
|
+
'datetime': this.iso8601(timestamp),
|
|
1324
|
+
'symbol': symbol,
|
|
1325
|
+
'type': type,
|
|
1326
|
+
'order': orderId,
|
|
1327
|
+
'side': side,
|
|
1328
|
+
'price': priceString,
|
|
1329
|
+
'amount': amountString,
|
|
1330
|
+
'cost': undefined,
|
|
1331
|
+
'takerOrMaker': takerOrMaker,
|
|
1332
|
+
'fee': fee,
|
|
1333
|
+
}, market);
|
|
1334
|
+
}
|
|
1335
|
+
async fetchTime(params = {}) {
|
|
1336
|
+
/**
|
|
1337
|
+
* @method
|
|
1338
|
+
* @name digifinex#fetchTime
|
|
1339
|
+
* @description fetches the current integer timestamp in milliseconds from the exchange server
|
|
1340
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1341
|
+
* @returns {int} the current integer timestamp in milliseconds from the exchange server
|
|
1342
|
+
*/
|
|
1343
|
+
const response = await this.publicSpotGetTime(params);
|
|
1344
|
+
//
|
|
1345
|
+
// {
|
|
1346
|
+
// "server_time": 1589873762,
|
|
1347
|
+
// "code": 0
|
|
1348
|
+
// }
|
|
1349
|
+
//
|
|
1350
|
+
return this.safeTimestamp(response, 'server_time');
|
|
1351
|
+
}
|
|
1352
|
+
async fetchStatus(params = {}) {
|
|
1353
|
+
/**
|
|
1354
|
+
* @method
|
|
1355
|
+
* @name digifinex#fetchStatus
|
|
1356
|
+
* @description the latest known information on the availability of the exchange API
|
|
1357
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1358
|
+
* @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
|
|
1359
|
+
*/
|
|
1360
|
+
const response = await this.publicSpotGetPing(params);
|
|
1361
|
+
//
|
|
1362
|
+
// {
|
|
1363
|
+
// "msg": "pong",
|
|
1364
|
+
// "code": 0
|
|
1365
|
+
// }
|
|
1366
|
+
//
|
|
1367
|
+
const code = this.safeInteger(response, 'code');
|
|
1368
|
+
const status = (code === 0) ? 'ok' : 'maintenance';
|
|
1369
|
+
return {
|
|
1370
|
+
'status': status,
|
|
1371
|
+
'updated': undefined,
|
|
1372
|
+
'eta': undefined,
|
|
1373
|
+
'url': undefined,
|
|
1374
|
+
'info': response,
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
1378
|
+
/**
|
|
1379
|
+
* @method
|
|
1380
|
+
* @name digifinex#fetchTrades
|
|
1381
|
+
* @description get the list of most recent trades for a particular symbol
|
|
1382
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-recent-trades
|
|
1383
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#recenttrades
|
|
1384
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
1385
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
1386
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
1387
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1388
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
1389
|
+
*/
|
|
1390
|
+
await this.loadMarkets();
|
|
1391
|
+
const market = this.market(symbol);
|
|
1392
|
+
const request = {};
|
|
1393
|
+
if (limit !== undefined) {
|
|
1394
|
+
request['limit'] = market['swap'] ? Math.min(limit, 100) : limit;
|
|
1395
|
+
}
|
|
1396
|
+
let response = undefined;
|
|
1397
|
+
if (market['swap']) {
|
|
1398
|
+
request['instrument_id'] = market['id'];
|
|
1399
|
+
response = await this.publicSwapGetPublicTrades(this.extend(request, params));
|
|
1400
|
+
}
|
|
1401
|
+
else {
|
|
1402
|
+
request['symbol'] = market['id'];
|
|
1403
|
+
response = await this.publicSpotGetTrades(this.extend(request, params));
|
|
1404
|
+
}
|
|
1405
|
+
//
|
|
1406
|
+
// spot
|
|
1407
|
+
//
|
|
1408
|
+
// {
|
|
1409
|
+
// "data":[
|
|
1410
|
+
// {
|
|
1411
|
+
// "date":1564520003,
|
|
1412
|
+
// "id":1596149203,
|
|
1413
|
+
// "amount":0.7073,
|
|
1414
|
+
// "type":"buy",
|
|
1415
|
+
// "price":0.02193,
|
|
1416
|
+
// },
|
|
1417
|
+
// {
|
|
1418
|
+
// "date":1564520002,
|
|
1419
|
+
// "id":1596149165,
|
|
1420
|
+
// "amount":0.3232,
|
|
1421
|
+
// "type":"sell",
|
|
1422
|
+
// "price":0.021927,
|
|
1423
|
+
// },
|
|
1424
|
+
// ],
|
|
1425
|
+
// "code": 0,
|
|
1426
|
+
// "date": 1564520003,
|
|
1427
|
+
// }
|
|
1428
|
+
//
|
|
1429
|
+
// swap
|
|
1430
|
+
//
|
|
1431
|
+
// {
|
|
1432
|
+
// "code": 0,
|
|
1433
|
+
// "data": [
|
|
1434
|
+
// {
|
|
1435
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
1436
|
+
// "trade_id": "1595190773677035521",
|
|
1437
|
+
// "direction": "4",
|
|
1438
|
+
// "volume": "4",
|
|
1439
|
+
// "price": "16188.3",
|
|
1440
|
+
// "trade_time": 1669158092314
|
|
1441
|
+
// },
|
|
1442
|
+
// ...
|
|
1443
|
+
// ]
|
|
1444
|
+
// }
|
|
1445
|
+
//
|
|
1446
|
+
const data = this.safeValue(response, 'data', []);
|
|
1447
|
+
return this.parseTrades(data, market, since, limit);
|
|
1448
|
+
}
|
|
1449
|
+
parseOHLCV(ohlcv, market = undefined) {
|
|
1450
|
+
//
|
|
1451
|
+
// [
|
|
1452
|
+
// 1556712900,
|
|
1453
|
+
// 2205.899,
|
|
1454
|
+
// 0.029967,
|
|
1455
|
+
// 0.02997,
|
|
1456
|
+
// 0.029871,
|
|
1457
|
+
// 0.029927
|
|
1458
|
+
// ]
|
|
1459
|
+
//
|
|
1460
|
+
if (market['swap']) {
|
|
1461
|
+
return [
|
|
1462
|
+
this.safeInteger(ohlcv, 0),
|
|
1463
|
+
this.safeNumber(ohlcv, 1),
|
|
1464
|
+
this.safeNumber(ohlcv, 2),
|
|
1465
|
+
this.safeNumber(ohlcv, 3),
|
|
1466
|
+
this.safeNumber(ohlcv, 4),
|
|
1467
|
+
this.safeNumber(ohlcv, 5), // volume
|
|
1468
|
+
];
|
|
1469
|
+
}
|
|
1470
|
+
else {
|
|
1471
|
+
return [
|
|
1472
|
+
this.safeTimestamp(ohlcv, 0),
|
|
1473
|
+
this.safeNumber(ohlcv, 5),
|
|
1474
|
+
this.safeNumber(ohlcv, 3),
|
|
1475
|
+
this.safeNumber(ohlcv, 4),
|
|
1476
|
+
this.safeNumber(ohlcv, 2),
|
|
1477
|
+
this.safeNumber(ohlcv, 1), // volume
|
|
1478
|
+
];
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
1482
|
+
/**
|
|
1483
|
+
* @method
|
|
1484
|
+
* @name digifinex#fetchOHLCV
|
|
1485
|
+
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
1486
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-candles-data
|
|
1487
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#recentcandle
|
|
1488
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
1489
|
+
* @param {string} timeframe the length of time each candle represents
|
|
1490
|
+
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
1491
|
+
* @param {int} [limit] the maximum amount of candles to fetch
|
|
1492
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1493
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
1494
|
+
*/
|
|
1495
|
+
await this.loadMarkets();
|
|
1496
|
+
const market = this.market(symbol);
|
|
1497
|
+
const request = {};
|
|
1498
|
+
let response = undefined;
|
|
1499
|
+
if (market['swap']) {
|
|
1500
|
+
request['instrument_id'] = market['id'];
|
|
1501
|
+
request['granularity'] = timeframe;
|
|
1502
|
+
if (limit !== undefined) {
|
|
1503
|
+
request['limit'] = limit;
|
|
1504
|
+
}
|
|
1505
|
+
response = await this.publicSwapGetPublicCandles(this.extend(request, params));
|
|
1506
|
+
}
|
|
1507
|
+
else {
|
|
1508
|
+
request['symbol'] = market['id'];
|
|
1509
|
+
request['period'] = this.safeString(this.timeframes, timeframe, timeframe);
|
|
1510
|
+
if (since !== undefined) {
|
|
1511
|
+
const startTime = this.parseToInt(since / 1000);
|
|
1512
|
+
request['start_time'] = startTime;
|
|
1513
|
+
if (limit !== undefined) {
|
|
1514
|
+
const duration = this.parseTimeframe(timeframe);
|
|
1515
|
+
request['end_time'] = this.sum(startTime, limit * duration);
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
else if (limit !== undefined) {
|
|
1519
|
+
const endTime = this.seconds();
|
|
1520
|
+
const duration = this.parseTimeframe(timeframe);
|
|
1521
|
+
request['start_time'] = this.sum(endTime, -limit * duration);
|
|
1522
|
+
}
|
|
1523
|
+
response = await this.publicSpotGetKline(this.extend(request, params));
|
|
1524
|
+
}
|
|
1525
|
+
//
|
|
1526
|
+
// spot
|
|
1527
|
+
//
|
|
1528
|
+
// {
|
|
1529
|
+
// "code":0,
|
|
1530
|
+
// "data":[
|
|
1531
|
+
// [1556712900,2205.899,0.029967,0.02997,0.029871,0.029927],
|
|
1532
|
+
// [1556713800,1912.9174,0.029992,0.030014,0.029955,0.02996],
|
|
1533
|
+
// [1556714700,1556.4795,0.029974,0.030019,0.029969,0.02999],
|
|
1534
|
+
// ]
|
|
1535
|
+
// }
|
|
1536
|
+
//
|
|
1537
|
+
// swap
|
|
1538
|
+
//
|
|
1539
|
+
// {
|
|
1540
|
+
// "code": 0,
|
|
1541
|
+
// "data": {
|
|
1542
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
1543
|
+
// "granularity": "1m",
|
|
1544
|
+
// "candles": [
|
|
1545
|
+
// [1588089660000,"6900","6900","6900","6900","0","0"],
|
|
1546
|
+
// [1588089720000,"6900","6900","6900","6900","0","0"],
|
|
1547
|
+
// [1588089780000,"6900","6900","6900","6900","0","0"],
|
|
1548
|
+
// ]
|
|
1549
|
+
// }
|
|
1550
|
+
// }
|
|
1551
|
+
//
|
|
1552
|
+
let candles = undefined;
|
|
1553
|
+
if (market['swap']) {
|
|
1554
|
+
const data = this.safeValue(response, 'data', {});
|
|
1555
|
+
candles = this.safeValue(data, 'candles', []);
|
|
1556
|
+
}
|
|
1557
|
+
else {
|
|
1558
|
+
candles = this.safeValue(response, 'data', []);
|
|
1559
|
+
}
|
|
1560
|
+
return this.parseOHLCVs(candles, market, timeframe, since, limit);
|
|
1561
|
+
}
|
|
1562
|
+
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
1563
|
+
/**
|
|
1564
|
+
* @method
|
|
1565
|
+
* @name digifinex#createOrder
|
|
1566
|
+
* @description create a trade order
|
|
1567
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-new-order
|
|
1568
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderplace
|
|
1569
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
1570
|
+
* @param {string} type 'market' or 'limit'
|
|
1571
|
+
* @param {string} side 'buy' or 'sell'
|
|
1572
|
+
* @param {float} amount how much you want to trade in units of the base currency, spot market orders use the quote currency, swap requires the number of contracts
|
|
1573
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
1574
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1575
|
+
* @param {string} [params.timeInForce] "GTC", "IOC", "FOK", or "PO"
|
|
1576
|
+
* @param {bool} [params.postOnly] true or false
|
|
1577
|
+
* @param {bool} [params.reduceOnly] true or false
|
|
1578
|
+
* @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
|
|
1579
|
+
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
1580
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1581
|
+
*/
|
|
1582
|
+
await this.loadMarkets();
|
|
1583
|
+
const market = this.market(symbol);
|
|
1584
|
+
const marginResult = this.handleMarginModeAndParams('createOrder', params);
|
|
1585
|
+
const marginMode = marginResult[0];
|
|
1586
|
+
const request = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
1587
|
+
let response = undefined;
|
|
1588
|
+
if (market['swap']) {
|
|
1589
|
+
response = await this.privateSwapPostTradeOrderPlace(request);
|
|
1590
|
+
}
|
|
1591
|
+
else {
|
|
1592
|
+
if (marginMode !== undefined) {
|
|
1593
|
+
response = await this.privateSpotPostMarginOrderNew(request);
|
|
1594
|
+
}
|
|
1595
|
+
else {
|
|
1596
|
+
response = await this.privateSpotPostSpotOrderNew(request);
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
//
|
|
1600
|
+
// spot and margin
|
|
1601
|
+
//
|
|
1602
|
+
// {
|
|
1603
|
+
// "code": 0,
|
|
1604
|
+
// "order_id": "198361cecdc65f9c8c9bb2fa68faec40"
|
|
1605
|
+
// }
|
|
1606
|
+
//
|
|
1607
|
+
// swap
|
|
1608
|
+
//
|
|
1609
|
+
// {
|
|
1610
|
+
// "code": 0,
|
|
1611
|
+
// "data": "1590873693003714560"
|
|
1612
|
+
// }
|
|
1613
|
+
//
|
|
1614
|
+
const order = this.parseOrder(response, market);
|
|
1615
|
+
order['symbol'] = market['symbol'];
|
|
1616
|
+
order['type'] = type;
|
|
1617
|
+
order['side'] = side;
|
|
1618
|
+
order['amount'] = amount;
|
|
1619
|
+
order['price'] = price;
|
|
1620
|
+
return order;
|
|
1621
|
+
}
|
|
1622
|
+
async createOrders(orders, params = {}) {
|
|
1623
|
+
/**
|
|
1624
|
+
* @method
|
|
1625
|
+
* @name digifinex#createOrders
|
|
1626
|
+
* @description create a list of trade orders (all orders should be of the same symbol)
|
|
1627
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-multiple-order
|
|
1628
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#batchorder
|
|
1629
|
+
* @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
|
1630
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1631
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1632
|
+
*/
|
|
1633
|
+
await this.loadMarkets();
|
|
1634
|
+
const ordersRequests = [];
|
|
1635
|
+
let symbol = undefined;
|
|
1636
|
+
let marginMode = undefined;
|
|
1637
|
+
for (let i = 0; i < orders.length; i++) {
|
|
1638
|
+
const rawOrder = orders[i];
|
|
1639
|
+
const marketId = this.safeString(rawOrder, 'symbol');
|
|
1640
|
+
if (symbol === undefined) {
|
|
1641
|
+
symbol = marketId;
|
|
1642
|
+
}
|
|
1643
|
+
else {
|
|
1644
|
+
if (symbol !== marketId) {
|
|
1645
|
+
throw new errors.BadRequest(this.id + ' createOrders() requires all orders to have the same symbol');
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
const type = this.safeString(rawOrder, 'type');
|
|
1649
|
+
const side = this.safeString(rawOrder, 'side');
|
|
1650
|
+
const amount = this.safeValue(rawOrder, 'amount');
|
|
1651
|
+
const price = this.safeValue(rawOrder, 'price');
|
|
1652
|
+
const orderParams = this.safeValue(rawOrder, 'params', {});
|
|
1653
|
+
const marginResult = this.handleMarginModeAndParams('createOrders', orderParams);
|
|
1654
|
+
const currentMarginMode = marginResult[0];
|
|
1655
|
+
if (currentMarginMode !== undefined) {
|
|
1656
|
+
if (marginMode === undefined) {
|
|
1657
|
+
marginMode = currentMarginMode;
|
|
1658
|
+
}
|
|
1659
|
+
else {
|
|
1660
|
+
if (marginMode !== currentMarginMode) {
|
|
1661
|
+
throw new errors.BadRequest(this.id + ' createOrders() requires all orders to have the same margin mode (isolated or cross)');
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
|
|
1666
|
+
ordersRequests.push(orderRequest);
|
|
1667
|
+
}
|
|
1668
|
+
const market = this.market(symbol);
|
|
1669
|
+
const request = {};
|
|
1670
|
+
let response = undefined;
|
|
1671
|
+
if (market['swap']) {
|
|
1672
|
+
response = await this.privateSwapPostTradeBatchOrder(ordersRequests);
|
|
1673
|
+
}
|
|
1674
|
+
else {
|
|
1675
|
+
request['market'] = (marginMode !== undefined) ? 'margin' : 'spot';
|
|
1676
|
+
request['symbol'] = market['id'];
|
|
1677
|
+
request['list'] = this.json(ordersRequests);
|
|
1678
|
+
response = await this.privateSpotPostMarketOrderBatchNew(request);
|
|
1679
|
+
}
|
|
1680
|
+
//
|
|
1681
|
+
// spot
|
|
1682
|
+
//
|
|
1683
|
+
// {
|
|
1684
|
+
// "code": 0,
|
|
1685
|
+
// "order_ids": [
|
|
1686
|
+
// "064290fbe2d26e7b28d7e6c0a5cf70a5",
|
|
1687
|
+
// "24c8f9b73d81e4d9d8d7e3280281c258"
|
|
1688
|
+
// ]
|
|
1689
|
+
// }
|
|
1690
|
+
//
|
|
1691
|
+
// swap
|
|
1692
|
+
//
|
|
1693
|
+
// {
|
|
1694
|
+
// "code": 0,
|
|
1695
|
+
// "data": [
|
|
1696
|
+
// "1720297963537829888",
|
|
1697
|
+
// "1720297963537829889"
|
|
1698
|
+
// ]
|
|
1699
|
+
// }
|
|
1700
|
+
//
|
|
1701
|
+
let data = [];
|
|
1702
|
+
if (market['swap']) {
|
|
1703
|
+
data = this.safeValue(response, 'data', []);
|
|
1704
|
+
}
|
|
1705
|
+
else {
|
|
1706
|
+
data = this.safeValue(response, 'order_ids', []);
|
|
1707
|
+
}
|
|
1708
|
+
const result = [];
|
|
1709
|
+
for (let i = 0; i < orders.length; i++) {
|
|
1710
|
+
const rawOrder = orders[i];
|
|
1711
|
+
const individualOrder = {};
|
|
1712
|
+
individualOrder['order_id'] = data[i];
|
|
1713
|
+
individualOrder['instrument_id'] = market['id'];
|
|
1714
|
+
individualOrder['amount'] = this.safeNumber(rawOrder, 'amount');
|
|
1715
|
+
individualOrder['price'] = this.safeNumber(rawOrder, 'price');
|
|
1716
|
+
result.push(individualOrder);
|
|
1717
|
+
}
|
|
1718
|
+
return this.parseOrders(result, market);
|
|
1719
|
+
}
|
|
1720
|
+
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
1721
|
+
/**
|
|
1722
|
+
* @method
|
|
1723
|
+
* @ignore
|
|
1724
|
+
* @name digifinex#createOrderRequest
|
|
1725
|
+
* @description helper function to build request
|
|
1726
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
1727
|
+
* @param {string} type 'market' or 'limit'
|
|
1728
|
+
* @param {string} side 'buy' or 'sell'
|
|
1729
|
+
* @param {float} amount how much you want to trade in units of the base currency, spot market orders use the quote currency, swap requires the number of contracts
|
|
1730
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
1731
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1732
|
+
* @returns {object} request to be sent to the exchange
|
|
1733
|
+
*/
|
|
1734
|
+
const market = this.market(symbol);
|
|
1735
|
+
let marketType = undefined;
|
|
1736
|
+
let marginMode = undefined;
|
|
1737
|
+
[marketType, params] = this.handleMarketTypeAndParams('createOrderRequest', market, params);
|
|
1738
|
+
[marginMode, params] = this.handleMarginModeAndParams('createOrderRequest', params);
|
|
1739
|
+
if (marginMode !== undefined) {
|
|
1740
|
+
marketType = 'margin';
|
|
1741
|
+
}
|
|
1742
|
+
const request = {};
|
|
1743
|
+
const swap = (marketType === 'swap');
|
|
1744
|
+
const isMarketOrder = (type === 'market');
|
|
1745
|
+
const isLimitOrder = (type === 'limit');
|
|
1746
|
+
const marketIdRequest = swap ? 'instrument_id' : 'symbol';
|
|
1747
|
+
request[marketIdRequest] = market['id'];
|
|
1748
|
+
let postOnly = this.isPostOnly(isMarketOrder, false, params);
|
|
1749
|
+
let postOnlyParsed = undefined;
|
|
1750
|
+
if (swap) {
|
|
1751
|
+
const reduceOnly = this.safeValue(params, 'reduceOnly', false);
|
|
1752
|
+
const timeInForce = this.safeString(params, 'timeInForce');
|
|
1753
|
+
let orderType = undefined;
|
|
1754
|
+
if (side === 'buy') {
|
|
1755
|
+
const requestType = (reduceOnly) ? 4 : 1;
|
|
1756
|
+
request['type'] = requestType;
|
|
1757
|
+
}
|
|
1758
|
+
else {
|
|
1759
|
+
const requestType = (reduceOnly) ? 3 : 2;
|
|
1760
|
+
request['type'] = requestType;
|
|
1761
|
+
}
|
|
1762
|
+
if (isLimitOrder) {
|
|
1763
|
+
orderType = 0;
|
|
1764
|
+
}
|
|
1765
|
+
if (timeInForce === 'FOK') {
|
|
1766
|
+
orderType = isMarketOrder ? 15 : 9;
|
|
1767
|
+
}
|
|
1768
|
+
else if (timeInForce === 'IOC') {
|
|
1769
|
+
orderType = isMarketOrder ? 13 : 4;
|
|
1770
|
+
}
|
|
1771
|
+
else if ((timeInForce === 'GTC') || (isMarketOrder)) {
|
|
1772
|
+
orderType = 14;
|
|
1773
|
+
}
|
|
1774
|
+
else if (timeInForce === 'PO') {
|
|
1775
|
+
postOnly = true;
|
|
1776
|
+
}
|
|
1777
|
+
if (price !== undefined) {
|
|
1778
|
+
request['price'] = this.priceToPrecision(symbol, price);
|
|
1779
|
+
}
|
|
1780
|
+
request['order_type'] = orderType;
|
|
1781
|
+
request['size'] = amount; // swap orders require the amount to be the number of contracts
|
|
1782
|
+
params = this.omit(params, ['reduceOnly', 'timeInForce']);
|
|
1783
|
+
}
|
|
1784
|
+
else {
|
|
1785
|
+
postOnlyParsed = (postOnly === true) ? 1 : 2;
|
|
1786
|
+
request['market'] = marketType;
|
|
1787
|
+
let suffix = '';
|
|
1788
|
+
if (type === 'market') {
|
|
1789
|
+
suffix = '_market';
|
|
1790
|
+
}
|
|
1791
|
+
else {
|
|
1792
|
+
request['price'] = this.priceToPrecision(symbol, price);
|
|
1793
|
+
}
|
|
1794
|
+
request['type'] = side + suffix;
|
|
1795
|
+
// limit orders require the amount in the base currency, market orders require the amount in the quote currency
|
|
1796
|
+
let quantity = undefined;
|
|
1797
|
+
let createMarketBuyOrderRequiresPrice = true;
|
|
1798
|
+
[createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrderRequest', 'createMarketBuyOrderRequiresPrice', true);
|
|
1799
|
+
if (isMarketOrder && (side === 'buy')) {
|
|
1800
|
+
const cost = this.safeNumber(params, 'cost');
|
|
1801
|
+
params = this.omit(params, 'cost');
|
|
1802
|
+
if (cost !== undefined) {
|
|
1803
|
+
quantity = this.costToPrecision(symbol, cost);
|
|
1804
|
+
}
|
|
1805
|
+
else if (createMarketBuyOrderRequiresPrice) {
|
|
1806
|
+
if (price === undefined) {
|
|
1807
|
+
throw new errors.InvalidOrder(this.id + ' createOrder() requires a price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend in the amount argument');
|
|
1808
|
+
}
|
|
1809
|
+
else {
|
|
1810
|
+
const amountString = this.numberToString(amount);
|
|
1811
|
+
const priceString = this.numberToString(price);
|
|
1812
|
+
const costRequest = this.parseNumber(Precise["default"].stringMul(amountString, priceString));
|
|
1813
|
+
quantity = this.costToPrecision(symbol, costRequest);
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
else {
|
|
1817
|
+
quantity = this.costToPrecision(symbol, amount);
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
else {
|
|
1821
|
+
quantity = this.amountToPrecision(symbol, amount);
|
|
1822
|
+
}
|
|
1823
|
+
request['amount'] = quantity;
|
|
1824
|
+
}
|
|
1825
|
+
if (postOnly) {
|
|
1826
|
+
if (postOnlyParsed) {
|
|
1827
|
+
request['post_only'] = postOnlyParsed;
|
|
1828
|
+
}
|
|
1829
|
+
else {
|
|
1830
|
+
request['post_only'] = postOnly;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
params = this.omit(params, ['postOnly']);
|
|
1834
|
+
return this.extend(request, params);
|
|
1835
|
+
}
|
|
1836
|
+
async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
|
|
1837
|
+
/**
|
|
1838
|
+
* @method
|
|
1839
|
+
* @name digifinex#createMarketBuyOrderWithCost
|
|
1840
|
+
* @description create a market buy order by providing the symbol and cost
|
|
1841
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-new-order
|
|
1842
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
1843
|
+
* @param {float} cost how much you want to trade in units of the quote currency
|
|
1844
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1845
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1846
|
+
*/
|
|
1847
|
+
await this.loadMarkets();
|
|
1848
|
+
const market = this.market(symbol);
|
|
1849
|
+
if (!market['spot']) {
|
|
1850
|
+
throw new errors.NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
|
|
1851
|
+
}
|
|
1852
|
+
params['createMarketBuyOrderRequiresPrice'] = false;
|
|
1853
|
+
return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
|
|
1854
|
+
}
|
|
1855
|
+
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
1856
|
+
/**
|
|
1857
|
+
* @method
|
|
1858
|
+
* @name digifinex#cancelOrder
|
|
1859
|
+
* @description cancels an open order
|
|
1860
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#cancel-order
|
|
1861
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#cancelorder
|
|
1862
|
+
* @param {string} id order id
|
|
1863
|
+
* @param {string} symbol not used by digifinex cancelOrder ()
|
|
1864
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1865
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1866
|
+
*/
|
|
1867
|
+
await this.loadMarkets();
|
|
1868
|
+
let market = undefined;
|
|
1869
|
+
if (symbol !== undefined) {
|
|
1870
|
+
market = this.market(symbol);
|
|
1871
|
+
}
|
|
1872
|
+
id = id.toString();
|
|
1873
|
+
let marketType = undefined;
|
|
1874
|
+
[marketType, params] = this.handleMarketTypeAndParams('cancelOrder', market, params);
|
|
1875
|
+
const request = {
|
|
1876
|
+
'order_id': id,
|
|
1877
|
+
};
|
|
1878
|
+
if (marketType === 'swap') {
|
|
1879
|
+
if (symbol === undefined) {
|
|
1880
|
+
throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
|
|
1881
|
+
}
|
|
1882
|
+
request['instrument_id'] = market['id'];
|
|
1883
|
+
}
|
|
1884
|
+
else {
|
|
1885
|
+
request['market'] = marketType;
|
|
1886
|
+
}
|
|
1887
|
+
const [marginMode, query] = this.handleMarginModeAndParams('cancelOrder', params);
|
|
1888
|
+
let response = undefined;
|
|
1889
|
+
if (marginMode !== undefined || marketType === 'margin') {
|
|
1890
|
+
marketType = 'margin';
|
|
1891
|
+
response = await this.privateSpotPostMarginOrderCancel(this.extend(request, query));
|
|
1892
|
+
}
|
|
1893
|
+
else if (marketType === 'spot') {
|
|
1894
|
+
response = await this.privateSpotPostSpotOrderCancel(this.extend(request, query));
|
|
1895
|
+
}
|
|
1896
|
+
else if (marketType === 'swap') {
|
|
1897
|
+
response = await this.privateSwapPostTradeCancelOrder(this.extend(request, query));
|
|
1898
|
+
}
|
|
1899
|
+
else {
|
|
1900
|
+
throw new errors.NotSupported(this.id + ' cancelOrder() not support this market type');
|
|
1901
|
+
}
|
|
1902
|
+
//
|
|
1903
|
+
// spot and margin
|
|
1904
|
+
//
|
|
1905
|
+
// {
|
|
1906
|
+
// "code": 0,
|
|
1907
|
+
// "success": [
|
|
1908
|
+
// "198361cecdc65f9c8c9bb2fa68faec40",
|
|
1909
|
+
// "3fb0d98e51c18954f10d439a9cf57de0"
|
|
1910
|
+
// ],
|
|
1911
|
+
// "error": [
|
|
1912
|
+
// "78a7104e3c65cc0c5a212a53e76d0205"
|
|
1913
|
+
// ]
|
|
1914
|
+
// }
|
|
1915
|
+
//
|
|
1916
|
+
// swap
|
|
1917
|
+
//
|
|
1918
|
+
// {
|
|
1919
|
+
// "code": 0,
|
|
1920
|
+
// "data": "1590923061186531328"
|
|
1921
|
+
// }
|
|
1922
|
+
//
|
|
1923
|
+
if ((marketType === 'spot') || (marketType === 'margin')) {
|
|
1924
|
+
const canceledOrders = this.safeValue(response, 'success', []);
|
|
1925
|
+
const numCanceledOrders = canceledOrders.length;
|
|
1926
|
+
if (numCanceledOrders !== 1) {
|
|
1927
|
+
throw new errors.OrderNotFound(this.id + ' cancelOrder() ' + id + ' not found');
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
return response;
|
|
1931
|
+
}
|
|
1932
|
+
async cancelOrders(ids, symbol = undefined, params = {}) {
|
|
1933
|
+
/**
|
|
1934
|
+
* @method
|
|
1935
|
+
* @name digifinex#cancelOrders
|
|
1936
|
+
* @description cancel multiple orders
|
|
1937
|
+
* @param {string[]} ids order ids
|
|
1938
|
+
* @param {string} symbol not used by digifinex cancelOrders ()
|
|
1939
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1940
|
+
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1941
|
+
*/
|
|
1942
|
+
await this.loadMarkets();
|
|
1943
|
+
const defaultType = this.safeString(this.options, 'defaultType', 'spot');
|
|
1944
|
+
const orderType = this.safeString(params, 'type', defaultType);
|
|
1945
|
+
params = this.omit(params, 'type');
|
|
1946
|
+
const request = {
|
|
1947
|
+
'market': orderType,
|
|
1948
|
+
'order_id': ids.join(','),
|
|
1949
|
+
};
|
|
1950
|
+
const response = await this.privateSpotPostSpotOrderCancel(this.extend(request, params));
|
|
1951
|
+
//
|
|
1952
|
+
// {
|
|
1953
|
+
// "code": 0,
|
|
1954
|
+
// "success": [
|
|
1955
|
+
// "198361cecdc65f9c8c9bb2fa68faec40",
|
|
1956
|
+
// "3fb0d98e51c18954f10d439a9cf57de0"
|
|
1957
|
+
// ],
|
|
1958
|
+
// "error": [
|
|
1959
|
+
// "78a7104e3c65cc0c5a212a53e76d0205"
|
|
1960
|
+
// ]
|
|
1961
|
+
// }
|
|
1962
|
+
//
|
|
1963
|
+
const canceledOrders = this.safeValue(response, 'success', []);
|
|
1964
|
+
const numCanceledOrders = canceledOrders.length;
|
|
1965
|
+
if (numCanceledOrders < 1) {
|
|
1966
|
+
throw new errors.OrderNotFound(this.id + ' cancelOrders() error');
|
|
1967
|
+
}
|
|
1968
|
+
return response;
|
|
1969
|
+
}
|
|
1970
|
+
parseOrderStatus(status) {
|
|
1971
|
+
const statuses = {
|
|
1972
|
+
'0': 'open',
|
|
1973
|
+
'1': 'open',
|
|
1974
|
+
'2': 'closed',
|
|
1975
|
+
'3': 'canceled',
|
|
1976
|
+
'4': 'canceled', // partially filled and canceled
|
|
1977
|
+
};
|
|
1978
|
+
return this.safeString(statuses, status, status);
|
|
1979
|
+
}
|
|
1980
|
+
parseOrder(order, market = undefined) {
|
|
1981
|
+
//
|
|
1982
|
+
// spot: createOrder
|
|
1983
|
+
//
|
|
1984
|
+
// {
|
|
1985
|
+
// "code": 0,
|
|
1986
|
+
// "order_id": "198361cecdc65f9c8c9bb2fa68faec40"
|
|
1987
|
+
// }
|
|
1988
|
+
//
|
|
1989
|
+
// swap: createOrder
|
|
1990
|
+
//
|
|
1991
|
+
// {
|
|
1992
|
+
// "code": 0,
|
|
1993
|
+
// "data": "1590873693003714560"
|
|
1994
|
+
// }
|
|
1995
|
+
//
|
|
1996
|
+
// spot and swap: createOrders
|
|
1997
|
+
//
|
|
1998
|
+
// {
|
|
1999
|
+
// "order_id": "d64d92a5e0a120f792f385485bc3d95b",
|
|
2000
|
+
// "instrument_id": "BTC_USDT",
|
|
2001
|
+
// "amount": 0.0001,
|
|
2002
|
+
// "price": 27000
|
|
2003
|
+
// }
|
|
2004
|
+
//
|
|
2005
|
+
// spot: fetchOrder, fetchOpenOrders, fetchOrders
|
|
2006
|
+
//
|
|
2007
|
+
// {
|
|
2008
|
+
// "symbol": "BTC_USDT",
|
|
2009
|
+
// "order_id": "dd3164b333a4afa9d5730bb87f6db8b3",
|
|
2010
|
+
// "created_date": 1562303547,
|
|
2011
|
+
// "finished_date": 0,
|
|
2012
|
+
// "price": 0.1,
|
|
2013
|
+
// "amount": 1,
|
|
2014
|
+
// "cash_amount": 1,
|
|
2015
|
+
// "executed_amount": 0,
|
|
2016
|
+
// "avg_price": 0,
|
|
2017
|
+
// "status": 1,
|
|
2018
|
+
// "type": "buy",
|
|
2019
|
+
// "kind": "margin"
|
|
2020
|
+
// }
|
|
2021
|
+
//
|
|
2022
|
+
// swap: fetchOrder, fetchOpenOrders, fetchOrders
|
|
2023
|
+
//
|
|
2024
|
+
// {
|
|
2025
|
+
// "order_id": "1590898207657824256",
|
|
2026
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
2027
|
+
// "margin_mode": "crossed",
|
|
2028
|
+
// "contract_val": "0.001",
|
|
2029
|
+
// "type": 1,
|
|
2030
|
+
// "order_type": 0,
|
|
2031
|
+
// "price": "14000",
|
|
2032
|
+
// "size": "6",
|
|
2033
|
+
// "filled_qty": "0",
|
|
2034
|
+
// "price_avg": "0",
|
|
2035
|
+
// "fee": "0",
|
|
2036
|
+
// "state": 0,
|
|
2037
|
+
// "leverage": "20",
|
|
2038
|
+
// "turnover": "0",
|
|
2039
|
+
// "has_stop": 0,
|
|
2040
|
+
// "insert_time": 1668134664828,
|
|
2041
|
+
// "time_stamp": 1668134664828
|
|
2042
|
+
// }
|
|
2043
|
+
//
|
|
2044
|
+
let timestamp = undefined;
|
|
2045
|
+
let lastTradeTimestamp = undefined;
|
|
2046
|
+
let timeInForce = undefined;
|
|
2047
|
+
let type = undefined;
|
|
2048
|
+
let side = this.safeString(order, 'type');
|
|
2049
|
+
const marketId = this.safeString2(order, 'symbol', 'instrument_id');
|
|
2050
|
+
const symbol = this.safeSymbol(marketId, market);
|
|
2051
|
+
market = this.market(symbol);
|
|
2052
|
+
if (market['type'] === 'swap') {
|
|
2053
|
+
const orderType = this.safeInteger(order, 'order_type');
|
|
2054
|
+
if (orderType !== undefined) {
|
|
2055
|
+
if ((orderType === 9) || (orderType === 10) || (orderType === 11) || (orderType === 12) || (orderType === 15)) {
|
|
2056
|
+
timeInForce = 'FOK';
|
|
2057
|
+
}
|
|
2058
|
+
else if ((orderType === 1) || (orderType === 2) || (orderType === 3) || (orderType === 4) || (orderType === 13)) {
|
|
2059
|
+
timeInForce = 'IOC';
|
|
2060
|
+
}
|
|
2061
|
+
else if ((orderType === 6) || (orderType === 7) || (orderType === 8) || (orderType === 14)) {
|
|
2062
|
+
timeInForce = 'GTC';
|
|
2063
|
+
}
|
|
2064
|
+
if ((orderType === 0) || (orderType === 1) || (orderType === 4) || (orderType === 5) || (orderType === 9) || (orderType === 10)) {
|
|
2065
|
+
type = 'limit';
|
|
2066
|
+
}
|
|
2067
|
+
else {
|
|
2068
|
+
type = 'market';
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
if (side === '1') {
|
|
2072
|
+
side = 'open long';
|
|
2073
|
+
}
|
|
2074
|
+
else if (side === '2') {
|
|
2075
|
+
side = 'open short';
|
|
2076
|
+
}
|
|
2077
|
+
else if (side === '3') {
|
|
2078
|
+
side = 'close long';
|
|
2079
|
+
}
|
|
2080
|
+
else if (side === '4') {
|
|
2081
|
+
side = 'close short';
|
|
2082
|
+
}
|
|
2083
|
+
timestamp = this.safeInteger(order, 'insert_time');
|
|
2084
|
+
lastTradeTimestamp = this.safeInteger(order, 'time_stamp');
|
|
2085
|
+
}
|
|
2086
|
+
else {
|
|
2087
|
+
timestamp = this.safeTimestamp(order, 'created_date');
|
|
2088
|
+
lastTradeTimestamp = this.safeTimestamp(order, 'finished_date');
|
|
2089
|
+
if (side !== undefined) {
|
|
2090
|
+
const parts = side.split('_');
|
|
2091
|
+
const numParts = parts.length;
|
|
2092
|
+
if (numParts > 1) {
|
|
2093
|
+
side = parts[0];
|
|
2094
|
+
type = parts[1];
|
|
2095
|
+
}
|
|
2096
|
+
else {
|
|
2097
|
+
type = 'limit';
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
return this.safeOrder({
|
|
2102
|
+
'info': order,
|
|
2103
|
+
'id': this.safeString2(order, 'order_id', 'data'),
|
|
2104
|
+
'clientOrderId': undefined,
|
|
2105
|
+
'timestamp': timestamp,
|
|
2106
|
+
'datetime': this.iso8601(timestamp),
|
|
2107
|
+
'lastTradeTimestamp': lastTradeTimestamp,
|
|
2108
|
+
'symbol': symbol,
|
|
2109
|
+
'type': type,
|
|
2110
|
+
'timeInForce': timeInForce,
|
|
2111
|
+
'postOnly': undefined,
|
|
2112
|
+
'side': side,
|
|
2113
|
+
'price': this.safeNumber(order, 'price'),
|
|
2114
|
+
'stopPrice': undefined,
|
|
2115
|
+
'triggerPrice': undefined,
|
|
2116
|
+
'amount': this.safeNumber2(order, 'amount', 'size'),
|
|
2117
|
+
'filled': this.safeNumber2(order, 'executed_amount', 'filled_qty'),
|
|
2118
|
+
'remaining': undefined,
|
|
2119
|
+
'cost': undefined,
|
|
2120
|
+
'average': this.safeNumber2(order, 'avg_price', 'price_avg'),
|
|
2121
|
+
'status': this.parseOrderStatus(this.safeString2(order, 'status', 'state')),
|
|
2122
|
+
'fee': {
|
|
2123
|
+
'cost': this.safeNumber(order, 'fee'),
|
|
2124
|
+
},
|
|
2125
|
+
'trades': undefined,
|
|
2126
|
+
}, market);
|
|
2127
|
+
}
|
|
2128
|
+
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2129
|
+
/**
|
|
2130
|
+
* @method
|
|
2131
|
+
* @name digifinex#fetchOpenOrders
|
|
2132
|
+
* @description fetch all unfilled currently open orders
|
|
2133
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#current-active-orders
|
|
2134
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#openorder
|
|
2135
|
+
* @param {string} symbol unified market symbol
|
|
2136
|
+
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
2137
|
+
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
2138
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2139
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2140
|
+
*/
|
|
2141
|
+
await this.loadMarkets();
|
|
2142
|
+
let market = undefined;
|
|
2143
|
+
if (symbol !== undefined) {
|
|
2144
|
+
market = this.market(symbol);
|
|
2145
|
+
}
|
|
2146
|
+
let marketType = undefined;
|
|
2147
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchOpenOrders', market, params);
|
|
2148
|
+
const [marginMode, query] = this.handleMarginModeAndParams('fetchOpenOrders', params);
|
|
2149
|
+
const request = {};
|
|
2150
|
+
const swap = (marketType === 'swap');
|
|
2151
|
+
if (swap) {
|
|
2152
|
+
if (since !== undefined) {
|
|
2153
|
+
request['start_timestamp'] = since;
|
|
2154
|
+
}
|
|
2155
|
+
if (limit !== undefined) {
|
|
2156
|
+
request['limit'] = limit;
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
else {
|
|
2160
|
+
request['market'] = marketType;
|
|
2161
|
+
}
|
|
2162
|
+
if (market !== undefined) {
|
|
2163
|
+
const marketIdRequest = swap ? 'instrument_id' : 'symbol';
|
|
2164
|
+
request[marketIdRequest] = market['id'];
|
|
2165
|
+
}
|
|
2166
|
+
let response = undefined;
|
|
2167
|
+
if (marginMode !== undefined || marketType === 'margin') {
|
|
2168
|
+
marketType = 'margin';
|
|
2169
|
+
response = await this.privateSpotGetMarginOrderCurrent(this.extend(request, query));
|
|
2170
|
+
}
|
|
2171
|
+
else if (marketType === 'spot') {
|
|
2172
|
+
response = await this.privateSpotGetSpotOrderCurrent(this.extend(request, query));
|
|
2173
|
+
}
|
|
2174
|
+
else if (marketType === 'swap') {
|
|
2175
|
+
response = await this.privateSwapGetTradeOpenOrders(this.extend(request, query));
|
|
2176
|
+
}
|
|
2177
|
+
else {
|
|
2178
|
+
throw new errors.NotSupported(this.id + ' fetchOpenOrders() not support this market type');
|
|
2179
|
+
}
|
|
2180
|
+
//
|
|
2181
|
+
// spot and margin
|
|
2182
|
+
//
|
|
2183
|
+
// {
|
|
2184
|
+
// "code": 0,
|
|
2185
|
+
// "data": [
|
|
2186
|
+
// {
|
|
2187
|
+
// "symbol": "BTC_USDT",
|
|
2188
|
+
// "order_id": "dd3164b333a4afa9d5730bb87f6db8b3",
|
|
2189
|
+
// "created_date": 1562303547,
|
|
2190
|
+
// "finished_date": 0,
|
|
2191
|
+
// "price": 0.1,
|
|
2192
|
+
// "amount": 1,
|
|
2193
|
+
// "cash_amount": 1,
|
|
2194
|
+
// "executed_amount": 0,
|
|
2195
|
+
// "avg_price": 0,
|
|
2196
|
+
// "status": 1,
|
|
2197
|
+
// "type": "buy",
|
|
2198
|
+
// "kind": "margin"
|
|
2199
|
+
// }
|
|
2200
|
+
// ]
|
|
2201
|
+
// }
|
|
2202
|
+
//
|
|
2203
|
+
// swap
|
|
2204
|
+
//
|
|
2205
|
+
// {
|
|
2206
|
+
// "code": 0,
|
|
2207
|
+
// "data": [
|
|
2208
|
+
// {
|
|
2209
|
+
// "order_id": "1590898207657824256",
|
|
2210
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
2211
|
+
// "margin_mode": "crossed",
|
|
2212
|
+
// "contract_val": "0.001",
|
|
2213
|
+
// "type": 1,
|
|
2214
|
+
// "order_type": 0,
|
|
2215
|
+
// "price": "14000",
|
|
2216
|
+
// "size": "6",
|
|
2217
|
+
// "filled_qty": "0",
|
|
2218
|
+
// "price_avg": "0",
|
|
2219
|
+
// "fee": "0",
|
|
2220
|
+
// "state": 0,
|
|
2221
|
+
// "leverage": "20",
|
|
2222
|
+
// "turnover": "0",
|
|
2223
|
+
// "has_stop": 0,
|
|
2224
|
+
// "insert_time": 1668134664828,
|
|
2225
|
+
// "time_stamp": 1668134664828
|
|
2226
|
+
// },
|
|
2227
|
+
// ...
|
|
2228
|
+
// ]
|
|
2229
|
+
// }
|
|
2230
|
+
//
|
|
2231
|
+
const data = this.safeValue(response, 'data', []);
|
|
2232
|
+
return this.parseOrders(data, market, since, limit);
|
|
2233
|
+
}
|
|
2234
|
+
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2235
|
+
/**
|
|
2236
|
+
* @method
|
|
2237
|
+
* @name digifinex#fetchOrders
|
|
2238
|
+
* @description fetches information on multiple orders made by the user
|
|
2239
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-all-orders-including-history-orders
|
|
2240
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#historyorder
|
|
2241
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
2242
|
+
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
2243
|
+
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
2244
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2245
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2246
|
+
*/
|
|
2247
|
+
await this.loadMarkets();
|
|
2248
|
+
let market = undefined;
|
|
2249
|
+
if (symbol !== undefined) {
|
|
2250
|
+
market = this.market(symbol);
|
|
2251
|
+
}
|
|
2252
|
+
let marketType = undefined;
|
|
2253
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchOrders', market, params);
|
|
2254
|
+
const [marginMode, query] = this.handleMarginModeAndParams('fetchOrders', params);
|
|
2255
|
+
const request = {};
|
|
2256
|
+
if (marketType === 'swap') {
|
|
2257
|
+
if (since !== undefined) {
|
|
2258
|
+
request['start_timestamp'] = since;
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
else {
|
|
2262
|
+
request['market'] = marketType;
|
|
2263
|
+
if (since !== undefined) {
|
|
2264
|
+
request['start_time'] = this.parseToInt(since / 1000); // default 3 days from now, max 30 days
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
if (market !== undefined) {
|
|
2268
|
+
const marketIdRequest = (marketType === 'swap') ? 'instrument_id' : 'symbol';
|
|
2269
|
+
request[marketIdRequest] = market['id'];
|
|
2270
|
+
}
|
|
2271
|
+
if (limit !== undefined) {
|
|
2272
|
+
request['limit'] = limit;
|
|
2273
|
+
}
|
|
2274
|
+
let response = undefined;
|
|
2275
|
+
if (marginMode !== undefined || marketType === 'margin') {
|
|
2276
|
+
marketType = 'margin';
|
|
2277
|
+
response = await this.privateSpotGetMarginOrderHistory(this.extend(request, query));
|
|
2278
|
+
}
|
|
2279
|
+
else if (marketType === 'spot') {
|
|
2280
|
+
response = await this.privateSpotGetSpotOrderHistory(this.extend(request, query));
|
|
2281
|
+
}
|
|
2282
|
+
else if (marketType === 'swap') {
|
|
2283
|
+
response = await this.privateSwapGetTradeHistoryOrders(this.extend(request, query));
|
|
2284
|
+
}
|
|
2285
|
+
else {
|
|
2286
|
+
throw new errors.NotSupported(this.id + ' fetchOrders() not support this market type');
|
|
2287
|
+
}
|
|
2288
|
+
//
|
|
2289
|
+
// spot and margin
|
|
2290
|
+
//
|
|
2291
|
+
// {
|
|
2292
|
+
// "code": 0,
|
|
2293
|
+
// "data": [
|
|
2294
|
+
// {
|
|
2295
|
+
// "symbol": "BTC_USDT",
|
|
2296
|
+
// "order_id": "dd3164b333a4afa9d5730bb87f6db8b3",
|
|
2297
|
+
// "created_date": 1562303547,
|
|
2298
|
+
// "finished_date": 0,
|
|
2299
|
+
// "price": 0.1,
|
|
2300
|
+
// "amount": 1,
|
|
2301
|
+
// "cash_amount": 1,
|
|
2302
|
+
// "executed_amount": 0,
|
|
2303
|
+
// "avg_price": 0,
|
|
2304
|
+
// "status": 1,
|
|
2305
|
+
// "type": "buy",
|
|
2306
|
+
// "kind": "margin"
|
|
2307
|
+
// }
|
|
2308
|
+
// ]
|
|
2309
|
+
// }
|
|
2310
|
+
//
|
|
2311
|
+
// swap
|
|
2312
|
+
//
|
|
2313
|
+
// {
|
|
2314
|
+
// "code": 0,
|
|
2315
|
+
// "data": [
|
|
2316
|
+
// {
|
|
2317
|
+
// "order_id": "1590136768156405760",
|
|
2318
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
2319
|
+
// "margin_mode": "crossed",
|
|
2320
|
+
// "contract_val": "0.001",
|
|
2321
|
+
// "type": 1,
|
|
2322
|
+
// "order_type": 8,
|
|
2323
|
+
// "price": "18660.2",
|
|
2324
|
+
// "size": "1",
|
|
2325
|
+
// "filled_qty": "1",
|
|
2326
|
+
// "price_avg": "18514.5",
|
|
2327
|
+
// "fee": "0.00925725",
|
|
2328
|
+
// "state": 2,
|
|
2329
|
+
// "leverage": "20",
|
|
2330
|
+
// "turnover": "18.5145",
|
|
2331
|
+
// "has_stop": 0,
|
|
2332
|
+
// "insert_time": 1667953123526,
|
|
2333
|
+
// "time_stamp": 1667953123596
|
|
2334
|
+
// },
|
|
2335
|
+
// ...
|
|
2336
|
+
// ]
|
|
2337
|
+
// }
|
|
2338
|
+
//
|
|
2339
|
+
const data = this.safeValue(response, 'data', []);
|
|
2340
|
+
return this.parseOrders(data, market, since, limit);
|
|
2341
|
+
}
|
|
2342
|
+
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
2343
|
+
/**
|
|
2344
|
+
* @method
|
|
2345
|
+
* @name digifinex#fetchOrder
|
|
2346
|
+
* @description fetches information on an order made by the user
|
|
2347
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-order-status
|
|
2348
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderinfo
|
|
2349
|
+
* @param {string} id order id
|
|
2350
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
2351
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2352
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2353
|
+
*/
|
|
2354
|
+
await this.loadMarkets();
|
|
2355
|
+
let market = undefined;
|
|
2356
|
+
if (symbol !== undefined) {
|
|
2357
|
+
market = this.market(symbol);
|
|
2358
|
+
}
|
|
2359
|
+
let marketType = undefined;
|
|
2360
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchOrder', market, params);
|
|
2361
|
+
const [marginMode, query] = this.handleMarginModeAndParams('fetchOrder', params);
|
|
2362
|
+
const request = {
|
|
2363
|
+
'order_id': id,
|
|
2364
|
+
};
|
|
2365
|
+
if (marketType === 'swap') {
|
|
2366
|
+
if (market !== undefined) {
|
|
2367
|
+
request['instrument_id'] = market['id'];
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
else {
|
|
2371
|
+
request['market'] = marketType;
|
|
2372
|
+
}
|
|
2373
|
+
let response = undefined;
|
|
2374
|
+
if ((marginMode !== undefined) || (marketType === 'margin')) {
|
|
2375
|
+
marketType = 'margin';
|
|
2376
|
+
response = await this.privateSpotGetMarginOrder(this.extend(request, query));
|
|
2377
|
+
}
|
|
2378
|
+
else if (marketType === 'spot') {
|
|
2379
|
+
response = await this.privateSpotGetSpotOrder(this.extend(request, query));
|
|
2380
|
+
}
|
|
2381
|
+
else if (marketType === 'swap') {
|
|
2382
|
+
response = await this.privateSwapGetTradeOrderInfo(this.extend(request, query));
|
|
2383
|
+
}
|
|
2384
|
+
else {
|
|
2385
|
+
throw new errors.NotSupported(this.id + ' fetchOrder() not support this market type');
|
|
2386
|
+
}
|
|
2387
|
+
//
|
|
2388
|
+
// spot and margin
|
|
2389
|
+
//
|
|
2390
|
+
// {
|
|
2391
|
+
// "code": 0,
|
|
2392
|
+
// "data": [
|
|
2393
|
+
// {
|
|
2394
|
+
// "symbol": "BTC_USDT",
|
|
2395
|
+
// "order_id": "dd3164b333a4afa9d5730bb87f6db8b3",
|
|
2396
|
+
// "created_date": 1562303547,
|
|
2397
|
+
// "finished_date": 0,
|
|
2398
|
+
// "price": 0.1,
|
|
2399
|
+
// "amount": 1,
|
|
2400
|
+
// "cash_amount": 1,
|
|
2401
|
+
// "executed_amount": 0,
|
|
2402
|
+
// "avg_price": 0,
|
|
2403
|
+
// "status": 1,
|
|
2404
|
+
// "type": "buy",
|
|
2405
|
+
// "kind": "margin"
|
|
2406
|
+
// }
|
|
2407
|
+
// ]
|
|
2408
|
+
// }
|
|
2409
|
+
//
|
|
2410
|
+
// swap
|
|
2411
|
+
//
|
|
2412
|
+
// {
|
|
2413
|
+
// "code": 0,
|
|
2414
|
+
// "data": {
|
|
2415
|
+
// "order_id": "1590923061186531328",
|
|
2416
|
+
// "instrument_id": "ETHUSDTPERP",
|
|
2417
|
+
// "margin_mode": "crossed",
|
|
2418
|
+
// "contract_val": "0.01",
|
|
2419
|
+
// "type": 1,
|
|
2420
|
+
// "order_type": 0,
|
|
2421
|
+
// "price": "900",
|
|
2422
|
+
// "size": "6",
|
|
2423
|
+
// "filled_qty": "0",
|
|
2424
|
+
// "price_avg": "0",
|
|
2425
|
+
// "fee": "0",
|
|
2426
|
+
// "state": 0,
|
|
2427
|
+
// "leverage": "20",
|
|
2428
|
+
// "turnover": "0",
|
|
2429
|
+
// "has_stop": 0,
|
|
2430
|
+
// "insert_time": 1668140590372,
|
|
2431
|
+
// "time_stamp": 1668140590372
|
|
2432
|
+
// }
|
|
2433
|
+
// }
|
|
2434
|
+
//
|
|
2435
|
+
const data = this.safeValue(response, 'data');
|
|
2436
|
+
const order = (marketType === 'swap') ? data : this.safeValue(data, 0);
|
|
2437
|
+
if (order === undefined) {
|
|
2438
|
+
throw new errors.OrderNotFound(this.id + ' fetchOrder() order ' + id.toString() + ' not found');
|
|
2439
|
+
}
|
|
2440
|
+
return this.parseOrder(order, market);
|
|
2441
|
+
}
|
|
2442
|
+
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2443
|
+
/**
|
|
2444
|
+
* @method
|
|
2445
|
+
* @name digifinex#fetchMyTrades
|
|
2446
|
+
* @description fetch all trades made by the user
|
|
2447
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#customer-39-s-trades
|
|
2448
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#historytrade
|
|
2449
|
+
* @param {string} symbol unified market symbol
|
|
2450
|
+
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
2451
|
+
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
2452
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2453
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
2454
|
+
*/
|
|
2455
|
+
await this.loadMarkets();
|
|
2456
|
+
let market = undefined;
|
|
2457
|
+
const request = {};
|
|
2458
|
+
if (symbol !== undefined) {
|
|
2459
|
+
market = this.market(symbol);
|
|
2460
|
+
}
|
|
2461
|
+
let marketType = undefined;
|
|
2462
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchMyTrades', market, params);
|
|
2463
|
+
const [marginMode, query] = this.handleMarginModeAndParams('fetchMyTrades', params);
|
|
2464
|
+
if (marketType === 'swap') {
|
|
2465
|
+
if (since !== undefined) {
|
|
2466
|
+
request['start_timestamp'] = since;
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2469
|
+
else {
|
|
2470
|
+
request['market'] = marketType;
|
|
2471
|
+
if (since !== undefined) {
|
|
2472
|
+
request['start_time'] = this.parseToInt(since / 1000); // default 3 days from now, max 30 days
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
const marketIdRequest = (marketType === 'swap') ? 'instrument_id' : 'symbol';
|
|
2476
|
+
if (symbol !== undefined) {
|
|
2477
|
+
request[marketIdRequest] = market['id'];
|
|
2478
|
+
}
|
|
2479
|
+
if (limit !== undefined) {
|
|
2480
|
+
request['limit'] = limit;
|
|
2481
|
+
}
|
|
2482
|
+
let response = undefined;
|
|
2483
|
+
if (marginMode !== undefined || marketType === 'margin') {
|
|
2484
|
+
marketType = 'margin';
|
|
2485
|
+
response = await this.privateSpotGetMarginMytrades(this.extend(request, query));
|
|
2486
|
+
}
|
|
2487
|
+
else if (marketType === 'spot') {
|
|
2488
|
+
response = await this.privateSpotGetSpotMytrades(this.extend(request, query));
|
|
2489
|
+
}
|
|
2490
|
+
else if (marketType === 'swap') {
|
|
2491
|
+
response = await this.privateSwapGetTradeHistoryTrades(this.extend(request, query));
|
|
2492
|
+
}
|
|
2493
|
+
else {
|
|
2494
|
+
throw new errors.NotSupported(this.id + ' fetchMyTrades() not support this market type');
|
|
2495
|
+
}
|
|
2496
|
+
//
|
|
2497
|
+
// spot and margin
|
|
2498
|
+
//
|
|
2499
|
+
// {
|
|
2500
|
+
// "list":[
|
|
2501
|
+
// {
|
|
2502
|
+
// "timestamp":1639506068,
|
|
2503
|
+
// "is_maker":false,
|
|
2504
|
+
// "id":"8975951332",
|
|
2505
|
+
// "amount":31.83,
|
|
2506
|
+
// "side":"sell_market",
|
|
2507
|
+
// "symbol":"DOGE_USDT",
|
|
2508
|
+
// "fee_currency":"USDT",
|
|
2509
|
+
// "fee":0.01163774826
|
|
2510
|
+
// ,"order_id":"32b169792f4a7a19e5907dc29fc123d4",
|
|
2511
|
+
// "price":0.182811
|
|
2512
|
+
// }
|
|
2513
|
+
// ],
|
|
2514
|
+
// "code": 0
|
|
2515
|
+
// }
|
|
2516
|
+
//
|
|
2517
|
+
// swap
|
|
2518
|
+
//
|
|
2519
|
+
// {
|
|
2520
|
+
// "code": 0,
|
|
2521
|
+
// "data": [
|
|
2522
|
+
// {
|
|
2523
|
+
// "trade_id": "1590136768424841218",
|
|
2524
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
2525
|
+
// "order_id": "1590136768156405760",
|
|
2526
|
+
// "type": 1,
|
|
2527
|
+
// "order_type": 8,
|
|
2528
|
+
// "price": "18514.5",
|
|
2529
|
+
// "size": "1",
|
|
2530
|
+
// "fee": "0.00925725",
|
|
2531
|
+
// "close_profit": "0",
|
|
2532
|
+
// "leverage": "20",
|
|
2533
|
+
// "trade_type": 0,
|
|
2534
|
+
// "match_role": 1,
|
|
2535
|
+
// "trade_time": 1667953123562
|
|
2536
|
+
// },
|
|
2537
|
+
// ...
|
|
2538
|
+
// ]
|
|
2539
|
+
// }
|
|
2540
|
+
//
|
|
2541
|
+
const responseRequest = (marketType === 'swap') ? 'data' : 'list';
|
|
2542
|
+
const data = this.safeValue(response, responseRequest, []);
|
|
2543
|
+
return this.parseTrades(data, market, since, limit);
|
|
2544
|
+
}
|
|
2545
|
+
parseLedgerEntryType(type) {
|
|
2546
|
+
const types = {};
|
|
2547
|
+
return this.safeString(types, type, type);
|
|
2548
|
+
}
|
|
2549
|
+
parseLedgerEntry(item, currency = undefined) {
|
|
2550
|
+
//
|
|
2551
|
+
// spot and margin
|
|
2552
|
+
//
|
|
2553
|
+
// {
|
|
2554
|
+
// "currency_mark": "BTC",
|
|
2555
|
+
// "type": 100234,
|
|
2556
|
+
// "num": -10,
|
|
2557
|
+
// "balance": 0.1,
|
|
2558
|
+
// "time": 1546272000
|
|
2559
|
+
// }
|
|
2560
|
+
//
|
|
2561
|
+
// swap
|
|
2562
|
+
//
|
|
2563
|
+
// {
|
|
2564
|
+
// "currency": "USDT",
|
|
2565
|
+
// "finance_type": 17,
|
|
2566
|
+
// "change": "-3.01",
|
|
2567
|
+
// "timestamp": 1650809432000
|
|
2568
|
+
// }
|
|
2569
|
+
//
|
|
2570
|
+
const type = this.parseLedgerEntryType(this.safeString2(item, 'type', 'finance_type'));
|
|
2571
|
+
const code = this.safeCurrencyCode(this.safeString2(item, 'currency_mark', 'currency'), currency);
|
|
2572
|
+
const amount = this.safeNumber2(item, 'num', 'change');
|
|
2573
|
+
const after = this.safeNumber(item, 'balance');
|
|
2574
|
+
let timestamp = this.safeTimestamp(item, 'time');
|
|
2575
|
+
if (timestamp === undefined) {
|
|
2576
|
+
timestamp = this.safeInteger(item, 'timestamp');
|
|
2577
|
+
}
|
|
2578
|
+
return {
|
|
2579
|
+
'info': item,
|
|
2580
|
+
'id': undefined,
|
|
2581
|
+
'direction': undefined,
|
|
2582
|
+
'account': undefined,
|
|
2583
|
+
'referenceId': undefined,
|
|
2584
|
+
'referenceAccount': undefined,
|
|
2585
|
+
'type': type,
|
|
2586
|
+
'currency': code,
|
|
2587
|
+
'amount': amount,
|
|
2588
|
+
'before': undefined,
|
|
2589
|
+
'after': after,
|
|
2590
|
+
'status': undefined,
|
|
2591
|
+
'timestamp': timestamp,
|
|
2592
|
+
'datetime': this.iso8601(timestamp),
|
|
2593
|
+
'fee': undefined,
|
|
2594
|
+
};
|
|
2595
|
+
}
|
|
2596
|
+
async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2597
|
+
/**
|
|
2598
|
+
* @method
|
|
2599
|
+
* @name digifinex#fetchLedger
|
|
2600
|
+
* @description fetch the history of changes, actions done by the user or operations that altered balance of the user
|
|
2601
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#spot-margin-otc-financial-logs
|
|
2602
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#bills
|
|
2603
|
+
* @param {string} code unified currency code, default is undefined
|
|
2604
|
+
* @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
|
|
2605
|
+
* @param {int} [limit] max number of ledger entrys to return, default is undefined
|
|
2606
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2607
|
+
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
|
|
2608
|
+
*/
|
|
2609
|
+
await this.loadMarkets();
|
|
2610
|
+
const request = {};
|
|
2611
|
+
let marketType = undefined;
|
|
2612
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchLedger', undefined, params);
|
|
2613
|
+
const [marginMode, query] = this.handleMarginModeAndParams('fetchLedger', params);
|
|
2614
|
+
if (marketType === 'swap') {
|
|
2615
|
+
if (since !== undefined) {
|
|
2616
|
+
request['start_timestamp'] = since;
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
else {
|
|
2620
|
+
request['market'] = marketType;
|
|
2621
|
+
if (since !== undefined) {
|
|
2622
|
+
request['start_time'] = this.parseToInt(since / 1000); // default 3 days from now, max 30 days
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
const currencyIdRequest = (marketType === 'swap') ? 'currency' : 'currency_mark';
|
|
2626
|
+
let currency = undefined;
|
|
2627
|
+
if (code !== undefined) {
|
|
2628
|
+
currency = this.currency(code);
|
|
2629
|
+
request[currencyIdRequest] = currency['id'];
|
|
2630
|
+
}
|
|
2631
|
+
if (limit !== undefined) {
|
|
2632
|
+
request['limit'] = limit;
|
|
2633
|
+
}
|
|
2634
|
+
let response = undefined;
|
|
2635
|
+
if (marginMode !== undefined || marketType === 'margin') {
|
|
2636
|
+
marketType = 'margin';
|
|
2637
|
+
response = await this.privateSpotGetMarginFinancelog(this.extend(request, query));
|
|
2638
|
+
}
|
|
2639
|
+
else if (marketType === 'spot') {
|
|
2640
|
+
response = await this.privateSpotGetSpotFinancelog(this.extend(request, query));
|
|
2641
|
+
}
|
|
2642
|
+
else if (marketType === 'swap') {
|
|
2643
|
+
response = await this.privateSwapGetAccountFinanceRecord(this.extend(request, query));
|
|
2644
|
+
}
|
|
2645
|
+
else {
|
|
2646
|
+
throw new errors.NotSupported(this.id + ' fetchLedger() not support this market type');
|
|
2647
|
+
}
|
|
2648
|
+
//
|
|
2649
|
+
// spot and margin
|
|
2650
|
+
//
|
|
2651
|
+
// {
|
|
2652
|
+
// "code": 0,
|
|
2653
|
+
// "data": {
|
|
2654
|
+
// "total": 521,
|
|
2655
|
+
// "finance": [
|
|
2656
|
+
// {
|
|
2657
|
+
// "currency_mark": "BTC",
|
|
2658
|
+
// "type": 100234,
|
|
2659
|
+
// "num": 28457,
|
|
2660
|
+
// "balance": 0.1,
|
|
2661
|
+
// "time": 1546272000
|
|
2662
|
+
// }
|
|
2663
|
+
// ]
|
|
2664
|
+
// }
|
|
2665
|
+
// }
|
|
2666
|
+
//
|
|
2667
|
+
// swap
|
|
2668
|
+
//
|
|
2669
|
+
// {
|
|
2670
|
+
// "code": 0,
|
|
2671
|
+
// "data": [
|
|
2672
|
+
// {
|
|
2673
|
+
// "currency": "USDT",
|
|
2674
|
+
// "finance_type": 17,
|
|
2675
|
+
// "change": "3.01",
|
|
2676
|
+
// "timestamp": 1650809432000
|
|
2677
|
+
// },
|
|
2678
|
+
// ]
|
|
2679
|
+
// }
|
|
2680
|
+
//
|
|
2681
|
+
let ledger = undefined;
|
|
2682
|
+
if (marketType === 'swap') {
|
|
2683
|
+
ledger = this.safeValue(response, 'data', []);
|
|
2684
|
+
}
|
|
2685
|
+
else {
|
|
2686
|
+
const data = this.safeValue(response, 'data', {});
|
|
2687
|
+
ledger = this.safeValue(data, 'finance', []);
|
|
2688
|
+
}
|
|
2689
|
+
return this.parseLedger(ledger, currency, since, limit);
|
|
2690
|
+
}
|
|
2691
|
+
parseDepositAddress(depositAddress, currency = undefined) {
|
|
2692
|
+
//
|
|
2693
|
+
// {
|
|
2694
|
+
// "addressTag":"",
|
|
2695
|
+
// "address":"0xf1104d9f8624f89775a3e9d480fc0e75a8ef4373",
|
|
2696
|
+
// "currency":"USDT",
|
|
2697
|
+
// "chain":"ERC20"
|
|
2698
|
+
// }
|
|
2699
|
+
//
|
|
2700
|
+
const address = this.safeString(depositAddress, 'address');
|
|
2701
|
+
const tag = this.safeString(depositAddress, 'addressTag');
|
|
2702
|
+
const currencyId = this.safeStringUpper(depositAddress, 'currency');
|
|
2703
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
2704
|
+
return {
|
|
2705
|
+
'info': depositAddress,
|
|
2706
|
+
'currency': code,
|
|
2707
|
+
'address': address,
|
|
2708
|
+
'tag': tag,
|
|
2709
|
+
'network': undefined,
|
|
2710
|
+
};
|
|
2711
|
+
}
|
|
2712
|
+
async fetchDepositAddress(code, params = {}) {
|
|
2713
|
+
/**
|
|
2714
|
+
* @method
|
|
2715
|
+
* @name digifinex#fetchDepositAddress
|
|
2716
|
+
* @description fetch the deposit address for a currency associated with this account
|
|
2717
|
+
* @param {string} code unified currency code
|
|
2718
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2719
|
+
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
2720
|
+
*/
|
|
2721
|
+
await this.loadMarkets();
|
|
2722
|
+
const currency = this.currency(code);
|
|
2723
|
+
const request = {
|
|
2724
|
+
'currency': currency['id'],
|
|
2725
|
+
};
|
|
2726
|
+
const response = await this.privateSpotGetDepositAddress(this.extend(request, params));
|
|
2727
|
+
//
|
|
2728
|
+
// {
|
|
2729
|
+
// "data":[
|
|
2730
|
+
// {
|
|
2731
|
+
// "addressTag":"",
|
|
2732
|
+
// "address":"0xf1104d9f8624f89775a3e9d480fc0e75a8ef4373",
|
|
2733
|
+
// "currency":"USDT",
|
|
2734
|
+
// "chain":"ERC20"
|
|
2735
|
+
// }
|
|
2736
|
+
// ],
|
|
2737
|
+
// "code":200
|
|
2738
|
+
// }
|
|
2739
|
+
//
|
|
2740
|
+
const data = this.safeValue(response, 'data', []);
|
|
2741
|
+
const addresses = this.parseDepositAddresses(data, [currency['code']]);
|
|
2742
|
+
const address = this.safeValue(addresses, code);
|
|
2743
|
+
if (address === undefined) {
|
|
2744
|
+
throw new errors.InvalidAddress(this.id + ' fetchDepositAddress() did not return an address for ' + code + ' - create the deposit address in the user settings on the exchange website first.');
|
|
2745
|
+
}
|
|
2746
|
+
return address;
|
|
2747
|
+
}
|
|
2748
|
+
async fetchTransactionsByType(type, code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2749
|
+
await this.loadMarkets();
|
|
2750
|
+
let currency = undefined;
|
|
2751
|
+
const request = {
|
|
2752
|
+
// 'currency': currency['id'],
|
|
2753
|
+
// 'from': 'fromId', // When direct is' prev ', from is 1, returning from old to new ascending, when direct is' next ', from is the ID of the most recent record, returned from the old descending order
|
|
2754
|
+
// 'size': 100, // default 100, max 500
|
|
2755
|
+
// 'direct': 'prev', // "prev" ascending, "next" descending
|
|
2756
|
+
};
|
|
2757
|
+
if (code !== undefined) {
|
|
2758
|
+
currency = this.currency(code);
|
|
2759
|
+
request['currency'] = currency['id'];
|
|
2760
|
+
}
|
|
2761
|
+
if (limit !== undefined) {
|
|
2762
|
+
request['size'] = Math.min(500, limit);
|
|
2763
|
+
}
|
|
2764
|
+
let response = undefined;
|
|
2765
|
+
if (type === 'deposit') {
|
|
2766
|
+
response = await this.privateSpotGetDepositHistory(this.extend(request, params));
|
|
2767
|
+
}
|
|
2768
|
+
else {
|
|
2769
|
+
response = await this.privateSpotGetWithdrawHistory(this.extend(request, params));
|
|
2770
|
+
}
|
|
2771
|
+
//
|
|
2772
|
+
// {
|
|
2773
|
+
// "code": 200,
|
|
2774
|
+
// "data": [
|
|
2775
|
+
// {
|
|
2776
|
+
// "id": 1171,
|
|
2777
|
+
// "currency": "xrp",
|
|
2778
|
+
// "hash": "ed03094b84eafbe4bc16e7ef766ee959885ee5bcb265872baaa9c64e1cf86c2b",
|
|
2779
|
+
// "chain": "",
|
|
2780
|
+
// "amount": 7.457467,
|
|
2781
|
+
// "address": "rae93V8d2mdoUQHwBDBdM4NHCMehRJAsbm",
|
|
2782
|
+
// "memo": "100040",
|
|
2783
|
+
// "fee": 0,
|
|
2784
|
+
// "state": "safe",
|
|
2785
|
+
// "created_date": "2020-04-20 11:23:00",
|
|
2786
|
+
// "finished_date": "2020-04-20 13:23:00"
|
|
2787
|
+
// },
|
|
2788
|
+
// ]
|
|
2789
|
+
// }
|
|
2790
|
+
//
|
|
2791
|
+
const data = this.safeValue(response, 'data', []);
|
|
2792
|
+
return this.parseTransactions(data, currency, since, limit, { 'type': type });
|
|
2793
|
+
}
|
|
2794
|
+
async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2795
|
+
/**
|
|
2796
|
+
* @method
|
|
2797
|
+
* @name digifinex#fetchDeposits
|
|
2798
|
+
* @description fetch all deposits made to an account
|
|
2799
|
+
* @param {string} code unified currency code
|
|
2800
|
+
* @param {int} [since] the earliest time in ms to fetch deposits for
|
|
2801
|
+
* @param {int} [limit] the maximum number of deposits structures to retrieve
|
|
2802
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2803
|
+
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
2804
|
+
*/
|
|
2805
|
+
return await this.fetchTransactionsByType('deposit', code, since, limit, params);
|
|
2806
|
+
}
|
|
2807
|
+
async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2808
|
+
/**
|
|
2809
|
+
* @method
|
|
2810
|
+
* @name digifinex#fetchWithdrawals
|
|
2811
|
+
* @description fetch all withdrawals made from an account
|
|
2812
|
+
* @param {string} code unified currency code
|
|
2813
|
+
* @param {int} [since] the earliest time in ms to fetch withdrawals for
|
|
2814
|
+
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
|
|
2815
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2816
|
+
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
2817
|
+
*/
|
|
2818
|
+
return await this.fetchTransactionsByType('withdrawal', code, since, limit, params);
|
|
2819
|
+
}
|
|
2820
|
+
parseTransactionStatus(status) {
|
|
2821
|
+
// deposit state includes: 1 (in deposit), 2 (to be confirmed), 3 (successfully deposited), 4 (stopped)
|
|
2822
|
+
// withdrawal state includes: 1 (application in progress), 2 (to be confirmed), 3 (completed), 4 (rejected)
|
|
2823
|
+
const statuses = {
|
|
2824
|
+
'1': 'pending',
|
|
2825
|
+
'2': 'pending',
|
|
2826
|
+
'3': 'ok',
|
|
2827
|
+
'4': 'failed', // Rejected
|
|
2828
|
+
};
|
|
2829
|
+
return this.safeString(statuses, status, status);
|
|
2830
|
+
}
|
|
2831
|
+
parseTransaction(transaction, currency = undefined) {
|
|
2832
|
+
//
|
|
2833
|
+
// withdraw
|
|
2834
|
+
//
|
|
2835
|
+
// {
|
|
2836
|
+
// "code": 200,
|
|
2837
|
+
// "withdraw_id": 700
|
|
2838
|
+
// }
|
|
2839
|
+
//
|
|
2840
|
+
// fetchDeposits, fetchWithdrawals
|
|
2841
|
+
//
|
|
2842
|
+
// {
|
|
2843
|
+
// "id": 1171,
|
|
2844
|
+
// "currency": "xrp",
|
|
2845
|
+
// "hash": "ed03094b84eafbe4bc16e7ef766ee959885ee5bcb265872baaa9c64e1cf86c2b",
|
|
2846
|
+
// "chain": "",
|
|
2847
|
+
// "amount": 7.457467,
|
|
2848
|
+
// "address": "rae93V8d2mdoUQHwBDBdM4NHCMehRJAsbm",
|
|
2849
|
+
// "memo": "100040",
|
|
2850
|
+
// "fee": 0,
|
|
2851
|
+
// "state": "safe",
|
|
2852
|
+
// "created_date": "2020-04-20 11:23:00",
|
|
2853
|
+
// "finished_date": "2020-04-20 13:23:00"
|
|
2854
|
+
// }
|
|
2855
|
+
//
|
|
2856
|
+
const id = this.safeString2(transaction, 'id', 'withdraw_id');
|
|
2857
|
+
const address = this.safeString(transaction, 'address');
|
|
2858
|
+
const tag = this.safeString(transaction, 'memo');
|
|
2859
|
+
const txid = this.safeString(transaction, 'hash');
|
|
2860
|
+
const currencyId = this.safeStringUpper(transaction, 'currency');
|
|
2861
|
+
const code = this.safeCurrencyCode(currencyId, currency);
|
|
2862
|
+
const timestamp = this.parse8601(this.safeString(transaction, 'created_date'));
|
|
2863
|
+
const updated = this.parse8601(this.safeString(transaction, 'finished_date'));
|
|
2864
|
+
const status = this.parseTransactionStatus(this.safeString(transaction, 'state'));
|
|
2865
|
+
const amount = this.safeNumber(transaction, 'amount');
|
|
2866
|
+
const feeCost = this.safeNumber(transaction, 'fee');
|
|
2867
|
+
let fee = undefined;
|
|
2868
|
+
if (feeCost !== undefined) {
|
|
2869
|
+
fee = { 'currency': code, 'cost': feeCost };
|
|
2870
|
+
}
|
|
2871
|
+
const network = this.safeString(transaction, 'chain');
|
|
2872
|
+
return {
|
|
2873
|
+
'info': transaction,
|
|
2874
|
+
'id': id,
|
|
2875
|
+
'txid': txid,
|
|
2876
|
+
'timestamp': timestamp,
|
|
2877
|
+
'datetime': this.iso8601(timestamp),
|
|
2878
|
+
'network': network,
|
|
2879
|
+
'address': address,
|
|
2880
|
+
'addressTo': address,
|
|
2881
|
+
'addressFrom': undefined,
|
|
2882
|
+
'tag': tag,
|
|
2883
|
+
'tagTo': tag,
|
|
2884
|
+
'tagFrom': undefined,
|
|
2885
|
+
'type': undefined,
|
|
2886
|
+
'amount': amount,
|
|
2887
|
+
'currency': code,
|
|
2888
|
+
'status': status,
|
|
2889
|
+
'updated': updated,
|
|
2890
|
+
'internal': undefined,
|
|
2891
|
+
'comment': undefined,
|
|
2892
|
+
'fee': fee,
|
|
2893
|
+
};
|
|
2894
|
+
}
|
|
2895
|
+
parseTransferStatus(status) {
|
|
2896
|
+
const statuses = {
|
|
2897
|
+
'0': 'ok',
|
|
2898
|
+
};
|
|
2899
|
+
return this.safeString(statuses, status, status);
|
|
2900
|
+
}
|
|
2901
|
+
parseTransfer(transfer, currency = undefined) {
|
|
2902
|
+
//
|
|
2903
|
+
// transfer
|
|
2904
|
+
//
|
|
2905
|
+
// {
|
|
2906
|
+
// "code": 0
|
|
2907
|
+
// }
|
|
2908
|
+
//
|
|
2909
|
+
// fetchTransfers
|
|
2910
|
+
//
|
|
2911
|
+
// {
|
|
2912
|
+
// "transfer_id": 130524,
|
|
2913
|
+
// "type": 1,
|
|
2914
|
+
// "currency": "USDT",
|
|
2915
|
+
// "amount": "24",
|
|
2916
|
+
// "timestamp": 1666505659000
|
|
2917
|
+
// }
|
|
2918
|
+
//
|
|
2919
|
+
let fromAccount = undefined;
|
|
2920
|
+
let toAccount = undefined;
|
|
2921
|
+
const type = this.safeInteger(transfer, 'type');
|
|
2922
|
+
if (type === 1) {
|
|
2923
|
+
fromAccount = 'spot';
|
|
2924
|
+
toAccount = 'swap';
|
|
2925
|
+
}
|
|
2926
|
+
else if (type === 2) {
|
|
2927
|
+
fromAccount = 'swap';
|
|
2928
|
+
toAccount = 'spot';
|
|
2929
|
+
}
|
|
2930
|
+
const timestamp = this.safeInteger(transfer, 'timestamp');
|
|
2931
|
+
return {
|
|
2932
|
+
'info': transfer,
|
|
2933
|
+
'id': this.safeString(transfer, 'transfer_id'),
|
|
2934
|
+
'timestamp': timestamp,
|
|
2935
|
+
'datetime': this.iso8601(timestamp),
|
|
2936
|
+
'currency': this.safeCurrencyCode(this.safeString(transfer, 'currency'), currency),
|
|
2937
|
+
'amount': this.safeNumber(transfer, 'amount'),
|
|
2938
|
+
'fromAccount': fromAccount,
|
|
2939
|
+
'toAccount': toAccount,
|
|
2940
|
+
'status': this.parseTransferStatus(this.safeString(transfer, 'code')),
|
|
2941
|
+
};
|
|
2942
|
+
}
|
|
2943
|
+
async transfer(code, amount, fromAccount, toAccount, params = {}) {
|
|
2944
|
+
/**
|
|
2945
|
+
* @method
|
|
2946
|
+
* @name digifinex#transfer
|
|
2947
|
+
* @description transfer currency internally between wallets on the same account
|
|
2948
|
+
* @param {string} code unified currency code
|
|
2949
|
+
* @param {float} amount amount to transfer
|
|
2950
|
+
* @param {string} fromAccount account to transfer from
|
|
2951
|
+
* @param {string} toAccount account to transfer to
|
|
2952
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2953
|
+
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
2954
|
+
*/
|
|
2955
|
+
await this.loadMarkets();
|
|
2956
|
+
const currency = this.currency(code);
|
|
2957
|
+
const accountsByType = this.safeValue(this.options, 'accountsByType', {});
|
|
2958
|
+
const fromId = this.safeString(accountsByType, fromAccount, fromAccount);
|
|
2959
|
+
const toId = this.safeString(accountsByType, toAccount, toAccount);
|
|
2960
|
+
const request = {
|
|
2961
|
+
'currency_mark': currency['id'],
|
|
2962
|
+
'num': this.currencyToPrecision(code, amount),
|
|
2963
|
+
'from': fromId,
|
|
2964
|
+
'to': toId, // 1 = SPOT, 2 = MARGIN, 3 = OTC
|
|
2965
|
+
};
|
|
2966
|
+
const response = await this.privateSpotPostTransfer(this.extend(request, params));
|
|
2967
|
+
//
|
|
2968
|
+
// {
|
|
2969
|
+
// "code": 0
|
|
2970
|
+
// }
|
|
2971
|
+
//
|
|
2972
|
+
return this.parseTransfer(response, currency);
|
|
2973
|
+
}
|
|
2974
|
+
async withdraw(code, amount, address, tag = undefined, params = {}) {
|
|
2975
|
+
/**
|
|
2976
|
+
* @method
|
|
2977
|
+
* @name digifinex#withdraw
|
|
2978
|
+
* @description make a withdrawal
|
|
2979
|
+
* @param {string} code unified currency code
|
|
2980
|
+
* @param {float} amount the amount to withdraw
|
|
2981
|
+
* @param {string} address the address to withdraw to
|
|
2982
|
+
* @param {string} tag
|
|
2983
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2984
|
+
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
2985
|
+
*/
|
|
2986
|
+
[tag, params] = this.handleWithdrawTagAndParams(tag, params);
|
|
2987
|
+
this.checkAddress(address);
|
|
2988
|
+
await this.loadMarkets();
|
|
2989
|
+
const currency = this.currency(code);
|
|
2990
|
+
const request = {
|
|
2991
|
+
// 'chain': 'ERC20', 'OMNI', 'TRC20', // required for USDT
|
|
2992
|
+
'address': address,
|
|
2993
|
+
'amount': this.currencyToPrecision(code, amount),
|
|
2994
|
+
'currency': currency['id'],
|
|
2995
|
+
};
|
|
2996
|
+
if (tag !== undefined) {
|
|
2997
|
+
request['memo'] = tag;
|
|
2998
|
+
}
|
|
2999
|
+
const response = await this.privateSpotPostWithdrawNew(this.extend(request, params));
|
|
3000
|
+
//
|
|
3001
|
+
// {
|
|
3002
|
+
// "code": 200,
|
|
3003
|
+
// "withdraw_id": 700
|
|
3004
|
+
// }
|
|
3005
|
+
//
|
|
3006
|
+
return this.parseTransaction(response, currency);
|
|
3007
|
+
}
|
|
3008
|
+
async fetchBorrowInterest(code = undefined, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3009
|
+
await this.loadMarkets();
|
|
3010
|
+
const request = {};
|
|
3011
|
+
let market = undefined;
|
|
3012
|
+
if (symbol !== undefined) {
|
|
3013
|
+
market = this.market(symbol);
|
|
3014
|
+
request['symbol'] = market['id'];
|
|
3015
|
+
}
|
|
3016
|
+
const response = await this.privateSpotGetMarginPositions(this.extend(request, params));
|
|
3017
|
+
//
|
|
3018
|
+
// {
|
|
3019
|
+
// "margin": "45.71246418952618",
|
|
3020
|
+
// "code": 0,
|
|
3021
|
+
// "margin_rate": "7.141978570340037",
|
|
3022
|
+
// "positions": [
|
|
3023
|
+
// {
|
|
3024
|
+
// "amount": 0.0006103,
|
|
3025
|
+
// "side": "go_long",
|
|
3026
|
+
// "entry_price": 31428.72,
|
|
3027
|
+
// "liquidation_rate": 0.3,
|
|
3028
|
+
// "liquidation_price": 10225.335481159,
|
|
3029
|
+
// "unrealized_roe": -0.0076885829266987,
|
|
3030
|
+
// "symbol": "BTC_USDT",
|
|
3031
|
+
// "unrealized_pnl": -0.049158102631999,
|
|
3032
|
+
// "leverage_ratio": 3
|
|
3033
|
+
// }
|
|
3034
|
+
// ],
|
|
3035
|
+
// "unrealized_pnl": "-0.049158102631998504"
|
|
3036
|
+
// }
|
|
3037
|
+
//
|
|
3038
|
+
const rows = this.safeValue(response, 'positions');
|
|
3039
|
+
const interest = this.parseBorrowInterests(rows, market);
|
|
3040
|
+
return this.filterByCurrencySinceLimit(interest, code, since, limit);
|
|
3041
|
+
}
|
|
3042
|
+
parseBorrowInterest(info, market = undefined) {
|
|
3043
|
+
//
|
|
3044
|
+
// {
|
|
3045
|
+
// "amount": 0.0006103,
|
|
3046
|
+
// "side": "go_long",
|
|
3047
|
+
// "entry_price": 31428.72,
|
|
3048
|
+
// "liquidation_rate": 0.3,
|
|
3049
|
+
// "liquidation_price": 10225.335481159,
|
|
3050
|
+
// "unrealized_roe": -0.0076885829266987,
|
|
3051
|
+
// "symbol": "BTC_USDT",
|
|
3052
|
+
// "unrealized_pnl": -0.049158102631999,
|
|
3053
|
+
// "leverage_ratio": 3
|
|
3054
|
+
// }
|
|
3055
|
+
//
|
|
3056
|
+
const marketId = this.safeString(info, 'symbol');
|
|
3057
|
+
const amountString = this.safeString(info, 'amount');
|
|
3058
|
+
const leverageString = this.safeString(info, 'leverage_ratio');
|
|
3059
|
+
const amountInvested = Precise["default"].stringDiv(amountString, leverageString);
|
|
3060
|
+
const amountBorrowed = Precise["default"].stringSub(amountString, amountInvested);
|
|
3061
|
+
const currency = (market === undefined) ? undefined : market['base'];
|
|
3062
|
+
const symbol = this.safeSymbol(marketId, market);
|
|
3063
|
+
return {
|
|
3064
|
+
'account': symbol,
|
|
3065
|
+
'symbol': symbol,
|
|
3066
|
+
'currency': currency,
|
|
3067
|
+
'interest': undefined,
|
|
3068
|
+
'interestRate': 0.001,
|
|
3069
|
+
'amountBorrowed': this.parseNumber(amountBorrowed),
|
|
3070
|
+
'timestamp': undefined,
|
|
3071
|
+
'datetime': undefined,
|
|
3072
|
+
'info': info,
|
|
3073
|
+
};
|
|
3074
|
+
}
|
|
3075
|
+
async fetchCrossBorrowRate(code, params = {}) {
|
|
3076
|
+
/**
|
|
3077
|
+
* @method
|
|
3078
|
+
* @name digifinex#fetchCrossBorrowRate
|
|
3079
|
+
* @description fetch the rate of interest to borrow a currency for margin trading
|
|
3080
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
|
|
3081
|
+
* @param {string} code unified currency code
|
|
3082
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3083
|
+
* @returns {object} a [borrow rate structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#borrow-rate-structure}
|
|
3084
|
+
*/
|
|
3085
|
+
await this.loadMarkets();
|
|
3086
|
+
const request = {};
|
|
3087
|
+
const response = await this.privateSpotGetMarginAssets(this.extend(request, params));
|
|
3088
|
+
//
|
|
3089
|
+
// {
|
|
3090
|
+
// "list": [
|
|
3091
|
+
// {
|
|
3092
|
+
// "valuation_rate": 1,
|
|
3093
|
+
// "total": 1.92012186174,
|
|
3094
|
+
// "free": 1.92012186174,
|
|
3095
|
+
// "currency": "USDT"
|
|
3096
|
+
// },
|
|
3097
|
+
// ],
|
|
3098
|
+
// "total": 45.133305540922,
|
|
3099
|
+
// "code": 0,
|
|
3100
|
+
// "unrealized_pnl": 0,
|
|
3101
|
+
// "free": 45.133305540922,
|
|
3102
|
+
// "equity": 45.133305540922
|
|
3103
|
+
// }
|
|
3104
|
+
//
|
|
3105
|
+
const data = this.safeValue(response, 'list', []);
|
|
3106
|
+
let result = [];
|
|
3107
|
+
for (let i = 0; i < data.length; i++) {
|
|
3108
|
+
const entry = data[i];
|
|
3109
|
+
if (this.safeString(entry, 'currency') === code) {
|
|
3110
|
+
result = entry;
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
const currency = this.currency(code);
|
|
3114
|
+
return this.parseBorrowRate(result, currency);
|
|
3115
|
+
}
|
|
3116
|
+
async fetchCrossBorrowRates(params = {}) {
|
|
3117
|
+
/**
|
|
3118
|
+
* @method
|
|
3119
|
+
* @name digifinex#fetchCrossBorrowRates
|
|
3120
|
+
* @description fetch the borrow interest rates of all currencies
|
|
3121
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-assets
|
|
3122
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3123
|
+
* @returns {object} a list of [borrow rate structures]{@link https://docs.ccxt.com/#/?id=borrow-rate-structure}
|
|
3124
|
+
*/
|
|
3125
|
+
await this.loadMarkets();
|
|
3126
|
+
const response = await this.privateSpotGetMarginAssets(params);
|
|
3127
|
+
//
|
|
3128
|
+
// {
|
|
3129
|
+
// "list": [
|
|
3130
|
+
// {
|
|
3131
|
+
// "valuation_rate": 1,
|
|
3132
|
+
// "total": 1.92012186174,
|
|
3133
|
+
// "free": 1.92012186174,
|
|
3134
|
+
// "currency": "USDT"
|
|
3135
|
+
// },
|
|
3136
|
+
// ],
|
|
3137
|
+
// "total": 45.133305540922,
|
|
3138
|
+
// "code": 0,
|
|
3139
|
+
// "unrealized_pnl": 0,
|
|
3140
|
+
// "free": 45.133305540922,
|
|
3141
|
+
// "equity": 45.133305540922
|
|
3142
|
+
// }
|
|
3143
|
+
//
|
|
3144
|
+
const result = this.safeValue(response, 'list', []);
|
|
3145
|
+
return this.parseBorrowRates(result, 'currency');
|
|
3146
|
+
}
|
|
3147
|
+
parseBorrowRate(info, currency = undefined) {
|
|
3148
|
+
//
|
|
3149
|
+
// {
|
|
3150
|
+
// "valuation_rate": 1,
|
|
3151
|
+
// "total": 1.92012186174,
|
|
3152
|
+
// "free": 1.92012186174,
|
|
3153
|
+
// "currency": "USDT"
|
|
3154
|
+
// }
|
|
3155
|
+
//
|
|
3156
|
+
const timestamp = this.milliseconds();
|
|
3157
|
+
const currencyId = this.safeString(info, 'currency');
|
|
3158
|
+
return {
|
|
3159
|
+
'currency': this.safeCurrencyCode(currencyId, currency),
|
|
3160
|
+
'rate': 0.001,
|
|
3161
|
+
'period': 86400000,
|
|
3162
|
+
'timestamp': timestamp,
|
|
3163
|
+
'datetime': this.iso8601(timestamp),
|
|
3164
|
+
'info': info,
|
|
3165
|
+
};
|
|
3166
|
+
}
|
|
3167
|
+
parseBorrowRates(info, codeKey) {
|
|
3168
|
+
//
|
|
3169
|
+
// {
|
|
3170
|
+
// "valuation_rate": 1,
|
|
3171
|
+
// "total": 1.92012186174,
|
|
3172
|
+
// "free": 1.92012186174,
|
|
3173
|
+
// "currency": "USDT"
|
|
3174
|
+
// },
|
|
3175
|
+
//
|
|
3176
|
+
const result = {};
|
|
3177
|
+
for (let i = 0; i < info.length; i++) {
|
|
3178
|
+
const item = info[i];
|
|
3179
|
+
const currency = this.safeString(item, codeKey);
|
|
3180
|
+
const code = this.safeCurrencyCode(currency);
|
|
3181
|
+
const borrowRate = this.parseBorrowRate(item);
|
|
3182
|
+
result[code] = borrowRate;
|
|
3183
|
+
}
|
|
3184
|
+
return result;
|
|
3185
|
+
}
|
|
3186
|
+
async fetchFundingRate(symbol, params = {}) {
|
|
3187
|
+
/**
|
|
3188
|
+
* @method
|
|
3189
|
+
* @name digifinex#fetchFundingRate
|
|
3190
|
+
* @description fetch the current funding rate
|
|
3191
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#currentfundingrate
|
|
3192
|
+
* @param {string} symbol unified market symbol
|
|
3193
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3194
|
+
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
|
3195
|
+
*/
|
|
3196
|
+
await this.loadMarkets();
|
|
3197
|
+
const market = this.market(symbol);
|
|
3198
|
+
if (!market['swap']) {
|
|
3199
|
+
throw new errors.BadSymbol(this.id + ' fetchFundingRate() supports swap contracts only');
|
|
3200
|
+
}
|
|
3201
|
+
const request = {
|
|
3202
|
+
'instrument_id': market['id'],
|
|
3203
|
+
};
|
|
3204
|
+
const response = await this.publicSwapGetPublicFundingRate(this.extend(request, params));
|
|
3205
|
+
//
|
|
3206
|
+
// {
|
|
3207
|
+
// "code": 0,
|
|
3208
|
+
// "data": {
|
|
3209
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
3210
|
+
// "funding_rate": "-0.00012",
|
|
3211
|
+
// "funding_time": 1662710400000,
|
|
3212
|
+
// "next_funding_rate": "0.0001049907085171607",
|
|
3213
|
+
// "next_funding_time": 1662739200000
|
|
3214
|
+
// }
|
|
3215
|
+
// }
|
|
3216
|
+
//
|
|
3217
|
+
const data = this.safeValue(response, 'data', {});
|
|
3218
|
+
return this.parseFundingRate(data, market);
|
|
3219
|
+
}
|
|
3220
|
+
parseFundingRate(contract, market = undefined) {
|
|
3221
|
+
//
|
|
3222
|
+
// {
|
|
3223
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
3224
|
+
// "funding_rate": "-0.00012",
|
|
3225
|
+
// "funding_time": 1662710400000,
|
|
3226
|
+
// "next_funding_rate": "0.0001049907085171607",
|
|
3227
|
+
// "next_funding_time": 1662739200000
|
|
3228
|
+
// }
|
|
3229
|
+
//
|
|
3230
|
+
const marketId = this.safeString(contract, 'instrument_id');
|
|
3231
|
+
const timestamp = this.safeInteger(contract, 'funding_time');
|
|
3232
|
+
const nextTimestamp = this.safeInteger(contract, 'next_funding_time');
|
|
3233
|
+
return {
|
|
3234
|
+
'info': contract,
|
|
3235
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
3236
|
+
'markPrice': undefined,
|
|
3237
|
+
'indexPrice': undefined,
|
|
3238
|
+
'interestRate': undefined,
|
|
3239
|
+
'estimatedSettlePrice': undefined,
|
|
3240
|
+
'timestamp': undefined,
|
|
3241
|
+
'datetime': undefined,
|
|
3242
|
+
'fundingRate': this.safeNumber(contract, 'funding_rate'),
|
|
3243
|
+
'fundingTimestamp': timestamp,
|
|
3244
|
+
'fundingDatetime': this.iso8601(timestamp),
|
|
3245
|
+
'nextFundingRate': this.safeString(contract, 'next_funding_rate'),
|
|
3246
|
+
'nextFundingTimestamp': nextTimestamp,
|
|
3247
|
+
'nextFundingDatetime': this.iso8601(nextTimestamp),
|
|
3248
|
+
'previousFundingRate': undefined,
|
|
3249
|
+
'previousFundingTimestamp': undefined,
|
|
3250
|
+
'previousFundingDatetime': undefined,
|
|
3251
|
+
};
|
|
3252
|
+
}
|
|
3253
|
+
async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3254
|
+
/**
|
|
3255
|
+
* @method
|
|
3256
|
+
* @name digifinex#fetchFundingRateHistory
|
|
3257
|
+
* @description fetches historical funding rate prices
|
|
3258
|
+
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
|
|
3259
|
+
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
|
|
3260
|
+
* @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
|
|
3261
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3262
|
+
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
|
|
3263
|
+
*/
|
|
3264
|
+
if (symbol === undefined) {
|
|
3265
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
|
|
3266
|
+
}
|
|
3267
|
+
await this.loadMarkets();
|
|
3268
|
+
const market = this.market(symbol);
|
|
3269
|
+
if (!market['swap']) {
|
|
3270
|
+
throw new errors.BadSymbol(this.id + ' fetchFundingRateHistory() supports swap contracts only');
|
|
3271
|
+
}
|
|
3272
|
+
const request = {
|
|
3273
|
+
'instrument_id': market['id'],
|
|
3274
|
+
};
|
|
3275
|
+
if (since !== undefined) {
|
|
3276
|
+
request['start_timestamp'] = since;
|
|
3277
|
+
}
|
|
3278
|
+
if (limit !== undefined) {
|
|
3279
|
+
request['limit'] = limit;
|
|
3280
|
+
}
|
|
3281
|
+
const response = await this.publicSwapGetPublicFundingRateHistory(this.extend(request, params));
|
|
3282
|
+
//
|
|
3283
|
+
// {
|
|
3284
|
+
// "code": 0,
|
|
3285
|
+
// "data": {
|
|
3286
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
3287
|
+
// "funding_rates": [
|
|
3288
|
+
// {
|
|
3289
|
+
// "rate": "-0.00375",
|
|
3290
|
+
// "time": 1607673600000
|
|
3291
|
+
// },
|
|
3292
|
+
// ...
|
|
3293
|
+
// ]
|
|
3294
|
+
// }
|
|
3295
|
+
// }
|
|
3296
|
+
//
|
|
3297
|
+
const data = this.safeValue(response, 'data', {});
|
|
3298
|
+
const result = this.safeValue(data, 'funding_rates', []);
|
|
3299
|
+
const rates = [];
|
|
3300
|
+
for (let i = 0; i < result.length; i++) {
|
|
3301
|
+
const entry = result[i];
|
|
3302
|
+
const marketId = this.safeString(data, 'instrument_id');
|
|
3303
|
+
const symbolInner = this.safeSymbol(marketId);
|
|
3304
|
+
const timestamp = this.safeInteger(entry, 'time');
|
|
3305
|
+
rates.push({
|
|
3306
|
+
'info': entry,
|
|
3307
|
+
'symbol': symbolInner,
|
|
3308
|
+
'fundingRate': this.safeNumber(entry, 'rate'),
|
|
3309
|
+
'timestamp': timestamp,
|
|
3310
|
+
'datetime': this.iso8601(timestamp),
|
|
3311
|
+
});
|
|
3312
|
+
}
|
|
3313
|
+
const sorted = this.sortBy(rates, 'timestamp');
|
|
3314
|
+
return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
|
|
3315
|
+
}
|
|
3316
|
+
async fetchTradingFee(symbol, params = {}) {
|
|
3317
|
+
/**
|
|
3318
|
+
* @method
|
|
3319
|
+
* @name digifinex#fetchTradingFee
|
|
3320
|
+
* @description fetch the trading fees for a market
|
|
3321
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#tradingfee
|
|
3322
|
+
* @param {string} symbol unified market symbol
|
|
3323
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3324
|
+
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
3325
|
+
*/
|
|
3326
|
+
await this.loadMarkets();
|
|
3327
|
+
const market = this.market(symbol);
|
|
3328
|
+
if (!market['swap']) {
|
|
3329
|
+
throw new errors.BadRequest(this.id + ' fetchTradingFee() supports swap markets only');
|
|
3330
|
+
}
|
|
3331
|
+
const request = {
|
|
3332
|
+
'instrument_id': market['id'],
|
|
3333
|
+
};
|
|
3334
|
+
const response = await this.privateSwapGetAccountTradingFeeRate(this.extend(request, params));
|
|
3335
|
+
//
|
|
3336
|
+
// {
|
|
3337
|
+
// "code": 0,
|
|
3338
|
+
// "data": {
|
|
3339
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
3340
|
+
// "taker_fee_rate": "0.0005",
|
|
3341
|
+
// "maker_fee_rate": "0.0003"
|
|
3342
|
+
// }
|
|
3343
|
+
// }
|
|
3344
|
+
//
|
|
3345
|
+
const data = this.safeValue(response, 'data', {});
|
|
3346
|
+
return this.parseTradingFee(data, market);
|
|
3347
|
+
}
|
|
3348
|
+
parseTradingFee(fee, market = undefined) {
|
|
3349
|
+
//
|
|
3350
|
+
// {
|
|
3351
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
3352
|
+
// "taker_fee_rate": "0.0005",
|
|
3353
|
+
// "maker_fee_rate": "0.0003"
|
|
3354
|
+
// }
|
|
3355
|
+
//
|
|
3356
|
+
const marketId = this.safeString(fee, 'instrument_id');
|
|
3357
|
+
const symbol = this.safeSymbol(marketId, market);
|
|
3358
|
+
return {
|
|
3359
|
+
'info': fee,
|
|
3360
|
+
'symbol': symbol,
|
|
3361
|
+
'maker': this.safeNumber(fee, 'maker_fee_rate'),
|
|
3362
|
+
'taker': this.safeNumber(fee, 'taker_fee_rate'),
|
|
3363
|
+
};
|
|
3364
|
+
}
|
|
3365
|
+
async fetchPositions(symbols = undefined, params = {}) {
|
|
3366
|
+
/**
|
|
3367
|
+
* @method
|
|
3368
|
+
* @name digifinex#fetchPositions
|
|
3369
|
+
* @description fetch all open positions
|
|
3370
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-positions
|
|
3371
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#positions
|
|
3372
|
+
* @param {string[]|undefined} symbols list of unified market symbols
|
|
3373
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3374
|
+
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
3375
|
+
*/
|
|
3376
|
+
await this.loadMarkets();
|
|
3377
|
+
symbols = this.marketSymbols(symbols);
|
|
3378
|
+
const request = {};
|
|
3379
|
+
let market = undefined;
|
|
3380
|
+
let marketType = undefined;
|
|
3381
|
+
if (symbols !== undefined) {
|
|
3382
|
+
let symbol = undefined;
|
|
3383
|
+
if (Array.isArray(symbols)) {
|
|
3384
|
+
const symbolsLength = symbols.length;
|
|
3385
|
+
if (symbolsLength > 1) {
|
|
3386
|
+
throw new errors.BadRequest(this.id + ' fetchPositions() symbols argument cannot contain more than 1 symbol');
|
|
3387
|
+
}
|
|
3388
|
+
symbol = symbols[0];
|
|
3389
|
+
}
|
|
3390
|
+
else {
|
|
3391
|
+
symbol = symbols;
|
|
3392
|
+
}
|
|
3393
|
+
market = this.market(symbol);
|
|
3394
|
+
}
|
|
3395
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchPositions', market, params);
|
|
3396
|
+
const [marginMode, query] = this.handleMarginModeAndParams('fetchPositions', params);
|
|
3397
|
+
if (marginMode !== undefined) {
|
|
3398
|
+
marketType = 'margin';
|
|
3399
|
+
}
|
|
3400
|
+
if (market !== undefined) {
|
|
3401
|
+
const marketIdRequest = (marketType === 'swap') ? 'instrument_id' : 'symbol';
|
|
3402
|
+
request[marketIdRequest] = market['id'];
|
|
3403
|
+
}
|
|
3404
|
+
let response = undefined;
|
|
3405
|
+
if (marketType === 'spot' || marketType === 'margin') {
|
|
3406
|
+
response = await this.privateSpotGetMarginPositions(this.extend(request, query));
|
|
3407
|
+
}
|
|
3408
|
+
else if (marketType === 'swap') {
|
|
3409
|
+
response = await this.privateSwapGetAccountPositions(this.extend(request, query));
|
|
3410
|
+
}
|
|
3411
|
+
else {
|
|
3412
|
+
throw new errors.NotSupported(this.id + ' fetchPositions() not support this market type');
|
|
3413
|
+
}
|
|
3414
|
+
//
|
|
3415
|
+
// swap
|
|
3416
|
+
//
|
|
3417
|
+
// {
|
|
3418
|
+
// "code": 0,
|
|
3419
|
+
// "data": [
|
|
3420
|
+
// {
|
|
3421
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
3422
|
+
// "margin_mode": "crossed",
|
|
3423
|
+
// "avail_position": "1",
|
|
3424
|
+
// "avg_cost": "18369.3",
|
|
3425
|
+
// "last": "18404.7",
|
|
3426
|
+
// "leverage": "20",
|
|
3427
|
+
// "liquidation_price": "451.12820512820264",
|
|
3428
|
+
// "maint_margin_ratio": "0.005",
|
|
3429
|
+
// "margin": "0.918465",
|
|
3430
|
+
// "position": "1",
|
|
3431
|
+
// "realized_pnl": "0",
|
|
3432
|
+
// "unrealized_pnl": "0.03410000000000224",
|
|
3433
|
+
// "unrealized_pnl_rate": "0.03712716325608732",
|
|
3434
|
+
// "side": "long",
|
|
3435
|
+
// "open_outstanding": "0",
|
|
3436
|
+
// "risk_score": "0.495049504950495",
|
|
3437
|
+
// "margin_ratio": "0.4029464788983229",
|
|
3438
|
+
// "timestamp": 1667960497145
|
|
3439
|
+
// },
|
|
3440
|
+
// ...
|
|
3441
|
+
// ]
|
|
3442
|
+
// }
|
|
3443
|
+
//
|
|
3444
|
+
// margin
|
|
3445
|
+
//
|
|
3446
|
+
// {
|
|
3447
|
+
// "margin": "77.71534772983289",
|
|
3448
|
+
// "code": 0,
|
|
3449
|
+
// "margin_rate": "10.284503769497306",
|
|
3450
|
+
// "positions": [
|
|
3451
|
+
// {
|
|
3452
|
+
// "amount": 0.0010605,
|
|
3453
|
+
// "side": "go_long",
|
|
3454
|
+
// "entry_price": 18321.39,
|
|
3455
|
+
// "liquidation_rate": 0.3,
|
|
3456
|
+
// "liquidation_price": -52754.371758471,
|
|
3457
|
+
// "unrealized_roe": -0.002784390267332,
|
|
3458
|
+
// "symbol": "BTC_USDT",
|
|
3459
|
+
// "unrealized_pnl": -0.010820048189999,
|
|
3460
|
+
// "leverage_ratio": 5
|
|
3461
|
+
// },
|
|
3462
|
+
// ...
|
|
3463
|
+
// ],
|
|
3464
|
+
// "unrealized_pnl": "-0.10681600018999979"
|
|
3465
|
+
// }
|
|
3466
|
+
//
|
|
3467
|
+
const positionRequest = (marketType === 'swap') ? 'data' : 'positions';
|
|
3468
|
+
const positions = this.safeValue(response, positionRequest, []);
|
|
3469
|
+
const result = [];
|
|
3470
|
+
for (let i = 0; i < positions.length; i++) {
|
|
3471
|
+
result.push(this.parsePosition(positions[i], market));
|
|
3472
|
+
}
|
|
3473
|
+
return this.filterByArrayPositions(result, 'symbol', symbols, false);
|
|
3474
|
+
}
|
|
3475
|
+
async fetchPosition(symbol, params = {}) {
|
|
3476
|
+
/**
|
|
3477
|
+
* @method
|
|
3478
|
+
* @name digifinex#fetchPosition
|
|
3479
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#margin-positions
|
|
3480
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#positions
|
|
3481
|
+
* @description fetch data on a single open contract trade position
|
|
3482
|
+
* @param {string} symbol unified market symbol of the market the position is held in
|
|
3483
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3484
|
+
* @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
3485
|
+
*/
|
|
3486
|
+
await this.loadMarkets();
|
|
3487
|
+
const market = this.market(symbol);
|
|
3488
|
+
const request = {};
|
|
3489
|
+
let marketType = undefined;
|
|
3490
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchPosition', market, params);
|
|
3491
|
+
const [marginMode, query] = this.handleMarginModeAndParams('fetchPosition', params);
|
|
3492
|
+
if (marginMode !== undefined) {
|
|
3493
|
+
marketType = 'margin';
|
|
3494
|
+
}
|
|
3495
|
+
const marketIdRequest = (marketType === 'swap') ? 'instrument_id' : 'symbol';
|
|
3496
|
+
request[marketIdRequest] = market['id'];
|
|
3497
|
+
let response = undefined;
|
|
3498
|
+
if (marketType === 'spot' || marketType === 'margin') {
|
|
3499
|
+
response = await this.privateSpotGetMarginPositions(this.extend(request, query));
|
|
3500
|
+
}
|
|
3501
|
+
else if (marketType === 'swap') {
|
|
3502
|
+
response = await this.privateSwapGetAccountPositions(this.extend(request, query));
|
|
3503
|
+
}
|
|
3504
|
+
else {
|
|
3505
|
+
throw new errors.NotSupported(this.id + ' fetchPosition() not support this market type');
|
|
3506
|
+
}
|
|
3507
|
+
//
|
|
3508
|
+
// swap
|
|
3509
|
+
//
|
|
3510
|
+
// {
|
|
3511
|
+
// "code": 0,
|
|
3512
|
+
// "data": [
|
|
3513
|
+
// {
|
|
3514
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
3515
|
+
// "margin_mode": "crossed",
|
|
3516
|
+
// "avail_position": "1",
|
|
3517
|
+
// "avg_cost": "18369.3",
|
|
3518
|
+
// "last": "18388.9",
|
|
3519
|
+
// "leverage": "20",
|
|
3520
|
+
// "liquidation_price": "383.38712921065553",
|
|
3521
|
+
// "maint_margin_ratio": "0.005",
|
|
3522
|
+
// "margin": "0.918465",
|
|
3523
|
+
// "position": "1",
|
|
3524
|
+
// "realized_pnl": "0",
|
|
3525
|
+
// "unrealized_pnl": "0.021100000000004115",
|
|
3526
|
+
// "unrealized_pnl_rate": "0.02297311274790451",
|
|
3527
|
+
// "side": "long",
|
|
3528
|
+
// "open_outstanding": "0",
|
|
3529
|
+
// "risk_score": "0.4901960784313725",
|
|
3530
|
+
// "margin_ratio": "0.40486964045976204",
|
|
3531
|
+
// "timestamp": 1667960241758
|
|
3532
|
+
// }
|
|
3533
|
+
// ]
|
|
3534
|
+
// }
|
|
3535
|
+
//
|
|
3536
|
+
// margin
|
|
3537
|
+
//
|
|
3538
|
+
// {
|
|
3539
|
+
// "margin": "77.71534772983289",
|
|
3540
|
+
// "code": 0,
|
|
3541
|
+
// "margin_rate": "10.284503769497306",
|
|
3542
|
+
// "positions": [
|
|
3543
|
+
// {
|
|
3544
|
+
// "amount": 0.0010605,
|
|
3545
|
+
// "side": "go_long",
|
|
3546
|
+
// "entry_price": 18321.39,
|
|
3547
|
+
// "liquidation_rate": 0.3,
|
|
3548
|
+
// "liquidation_price": -52754.371758471,
|
|
3549
|
+
// "unrealized_roe": -0.002784390267332,
|
|
3550
|
+
// "symbol": "BTC_USDT",
|
|
3551
|
+
// "unrealized_pnl": -0.010820048189999,
|
|
3552
|
+
// "leverage_ratio": 5
|
|
3553
|
+
// }
|
|
3554
|
+
// ],
|
|
3555
|
+
// "unrealized_pnl": "-0.10681600018999979"
|
|
3556
|
+
// }
|
|
3557
|
+
//
|
|
3558
|
+
const dataRequest = (marketType === 'swap') ? 'data' : 'positions';
|
|
3559
|
+
const data = this.safeValue(response, dataRequest, []);
|
|
3560
|
+
const position = this.parsePosition(data[0], market);
|
|
3561
|
+
if (marketType === 'swap') {
|
|
3562
|
+
return position;
|
|
3563
|
+
}
|
|
3564
|
+
else {
|
|
3565
|
+
position['collateral'] = this.safeNumber(response, 'margin');
|
|
3566
|
+
position['marginRatio'] = this.safeNumber(response, 'margin_rate');
|
|
3567
|
+
return position;
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
3570
|
+
parsePosition(position, market = undefined) {
|
|
3571
|
+
//
|
|
3572
|
+
// swap
|
|
3573
|
+
//
|
|
3574
|
+
// {
|
|
3575
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
3576
|
+
// "margin_mode": "crossed",
|
|
3577
|
+
// "avail_position": "1",
|
|
3578
|
+
// "avg_cost": "18369.3",
|
|
3579
|
+
// "last": "18388.9",
|
|
3580
|
+
// "leverage": "20",
|
|
3581
|
+
// "liquidation_price": "383.38712921065553",
|
|
3582
|
+
// "maint_margin_ratio": "0.005",
|
|
3583
|
+
// "margin": "0.918465",
|
|
3584
|
+
// "position": "1",
|
|
3585
|
+
// "realized_pnl": "0",
|
|
3586
|
+
// "unrealized_pnl": "0.021100000000004115",
|
|
3587
|
+
// "unrealized_pnl_rate": "0.02297311274790451",
|
|
3588
|
+
// "side": "long",
|
|
3589
|
+
// "open_outstanding": "0",
|
|
3590
|
+
// "risk_score": "0.4901960784313725",
|
|
3591
|
+
// "margin_ratio": "0.40486964045976204",
|
|
3592
|
+
// "timestamp": 1667960241758
|
|
3593
|
+
// }
|
|
3594
|
+
//
|
|
3595
|
+
// margin
|
|
3596
|
+
//
|
|
3597
|
+
// {
|
|
3598
|
+
// "amount": 0.0010605,
|
|
3599
|
+
// "side": "go_long",
|
|
3600
|
+
// "entry_price": 18321.39,
|
|
3601
|
+
// "liquidation_rate": 0.3,
|
|
3602
|
+
// "liquidation_price": -52754.371758471,
|
|
3603
|
+
// "unrealized_roe": -0.002784390267332,
|
|
3604
|
+
// "symbol": "BTC_USDT",
|
|
3605
|
+
// "unrealized_pnl": -0.010820048189999,
|
|
3606
|
+
// "leverage_ratio": 5
|
|
3607
|
+
// }
|
|
3608
|
+
//
|
|
3609
|
+
const marketId = this.safeString2(position, 'instrument_id', 'symbol');
|
|
3610
|
+
market = this.safeMarket(marketId, market);
|
|
3611
|
+
const symbol = market['symbol'];
|
|
3612
|
+
let marginMode = this.safeString(position, 'margin_mode');
|
|
3613
|
+
if (marginMode !== undefined) {
|
|
3614
|
+
marginMode = (marginMode === 'crossed') ? 'cross' : 'isolated';
|
|
3615
|
+
}
|
|
3616
|
+
else {
|
|
3617
|
+
marginMode = 'crossed';
|
|
3618
|
+
}
|
|
3619
|
+
const timestamp = this.safeInteger(position, 'timestamp');
|
|
3620
|
+
let side = this.safeString(position, 'side');
|
|
3621
|
+
if (side === 'go_long') {
|
|
3622
|
+
side = 'long';
|
|
3623
|
+
}
|
|
3624
|
+
else if (side === 'go_short') {
|
|
3625
|
+
side = 'short';
|
|
3626
|
+
}
|
|
3627
|
+
return this.safePosition({
|
|
3628
|
+
'info': position,
|
|
3629
|
+
'id': undefined,
|
|
3630
|
+
'symbol': symbol,
|
|
3631
|
+
'notional': this.safeNumber(position, 'amount'),
|
|
3632
|
+
'marginMode': marginMode,
|
|
3633
|
+
'liquidationPrice': this.safeNumber(position, 'liquidation_price'),
|
|
3634
|
+
'entryPrice': this.safeNumber2(position, 'avg_cost', 'entry_price'),
|
|
3635
|
+
'unrealizedPnl': this.safeNumber(position, 'unrealized_pnl'),
|
|
3636
|
+
'contracts': this.safeNumber(position, 'avail_position'),
|
|
3637
|
+
'contractSize': this.safeNumber(market, 'contractSize'),
|
|
3638
|
+
'markPrice': this.safeNumber(position, 'last'),
|
|
3639
|
+
'side': side,
|
|
3640
|
+
'hedged': undefined,
|
|
3641
|
+
'timestamp': timestamp,
|
|
3642
|
+
'datetime': this.iso8601(timestamp),
|
|
3643
|
+
'maintenanceMargin': this.safeNumber(position, 'margin'),
|
|
3644
|
+
'maintenanceMarginPercentage': this.safeNumber(position, 'maint_margin_ratio'),
|
|
3645
|
+
'collateral': undefined,
|
|
3646
|
+
'initialMargin': undefined,
|
|
3647
|
+
'initialMarginPercentage': undefined,
|
|
3648
|
+
'leverage': this.safeNumber2(position, 'leverage', 'leverage_ratio'),
|
|
3649
|
+
'marginRatio': this.safeNumber(position, 'margin_ratio'),
|
|
3650
|
+
'percentage': undefined,
|
|
3651
|
+
'stopLossPrice': undefined,
|
|
3652
|
+
'takeProfitPrice': undefined,
|
|
3653
|
+
});
|
|
3654
|
+
}
|
|
3655
|
+
async setLeverage(leverage, symbol = undefined, params = {}) {
|
|
3656
|
+
/**
|
|
3657
|
+
* @method
|
|
3658
|
+
* @name digifinex#setLeverage
|
|
3659
|
+
* @description set the level of leverage for a market
|
|
3660
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#setleverage
|
|
3661
|
+
* @param {float} leverage the rate of leverage
|
|
3662
|
+
* @param {string} symbol unified market symbol
|
|
3663
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3664
|
+
* @param {string} [params.marginMode] either 'cross' or 'isolated', default is cross
|
|
3665
|
+
* @param {string} [params.side] either 'long' or 'short', required for isolated markets only
|
|
3666
|
+
* @returns {object} response from the exchange
|
|
3667
|
+
*/
|
|
3668
|
+
if (symbol === undefined) {
|
|
3669
|
+
throw new errors.ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
|
|
3670
|
+
}
|
|
3671
|
+
await this.loadMarkets();
|
|
3672
|
+
const market = this.market(symbol);
|
|
3673
|
+
if (market['type'] !== 'swap') {
|
|
3674
|
+
throw new errors.BadSymbol(this.id + ' setLeverage() supports swap contracts only');
|
|
3675
|
+
}
|
|
3676
|
+
if ((leverage < 1) || (leverage > 100)) {
|
|
3677
|
+
throw new errors.BadRequest(this.id + ' leverage should be between 1 and 100');
|
|
3678
|
+
}
|
|
3679
|
+
const request = {
|
|
3680
|
+
'instrument_id': market['id'],
|
|
3681
|
+
'leverage': leverage,
|
|
3682
|
+
};
|
|
3683
|
+
const defaultMarginMode = this.safeString2(this.options, 'marginMode', 'defaultMarginMode');
|
|
3684
|
+
let marginMode = this.safeStringLower2(params, 'marginMode', 'defaultMarginMode', defaultMarginMode);
|
|
3685
|
+
if (marginMode !== undefined) {
|
|
3686
|
+
marginMode = (marginMode === 'cross') ? 'crossed' : 'isolated';
|
|
3687
|
+
request['margin_mode'] = marginMode;
|
|
3688
|
+
params = this.omit(params, ['marginMode', 'defaultMarginMode']);
|
|
3689
|
+
}
|
|
3690
|
+
if (marginMode === 'isolated') {
|
|
3691
|
+
const side = this.safeString(params, 'side');
|
|
3692
|
+
if (side !== undefined) {
|
|
3693
|
+
request['side'] = side;
|
|
3694
|
+
params = this.omit(params, 'side');
|
|
3695
|
+
}
|
|
3696
|
+
else {
|
|
3697
|
+
this.checkRequiredArgument('setLeverage', side, 'side', ['long', 'short']);
|
|
3698
|
+
}
|
|
3699
|
+
}
|
|
3700
|
+
return await this.privateSwapPostAccountLeverage(this.extend(request, params));
|
|
3701
|
+
//
|
|
3702
|
+
// {
|
|
3703
|
+
// "code": 0,
|
|
3704
|
+
// "data": {
|
|
3705
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
3706
|
+
// "leverage": 30,
|
|
3707
|
+
// "margin_mode": "crossed",
|
|
3708
|
+
// "side": "both"
|
|
3709
|
+
// }
|
|
3710
|
+
// }
|
|
3711
|
+
//
|
|
3712
|
+
}
|
|
3713
|
+
async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3714
|
+
/**
|
|
3715
|
+
* @method
|
|
3716
|
+
* @name digifinex#fetchTransfers
|
|
3717
|
+
* @description fetch the transfer history, only transfers between spot and swap accounts are supported
|
|
3718
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#transferrecord
|
|
3719
|
+
* @param {string} code unified currency code of the currency transferred
|
|
3720
|
+
* @param {int} [since] the earliest time in ms to fetch transfers for
|
|
3721
|
+
* @param {int} [limit] the maximum number of transfers to retrieve
|
|
3722
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3723
|
+
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
3724
|
+
*/
|
|
3725
|
+
await this.loadMarkets();
|
|
3726
|
+
let currency = undefined;
|
|
3727
|
+
const request = {};
|
|
3728
|
+
if (code !== undefined) {
|
|
3729
|
+
currency = this.safeCurrencyCode(code);
|
|
3730
|
+
request['currency'] = currency['id'];
|
|
3731
|
+
}
|
|
3732
|
+
if (since !== undefined) {
|
|
3733
|
+
request['start_timestamp'] = since;
|
|
3734
|
+
}
|
|
3735
|
+
if (limit !== undefined) {
|
|
3736
|
+
request['limit'] = limit; // default 20 max 100
|
|
3737
|
+
}
|
|
3738
|
+
const response = await this.privateSwapGetAccountTransferRecord(this.extend(request, params));
|
|
3739
|
+
//
|
|
3740
|
+
// {
|
|
3741
|
+
// "code": 0,
|
|
3742
|
+
// "data": [
|
|
3743
|
+
// {
|
|
3744
|
+
// "transfer_id": 130524,
|
|
3745
|
+
// "type": 1,
|
|
3746
|
+
// "currency": "USDT",
|
|
3747
|
+
// "amount": "24",
|
|
3748
|
+
// "timestamp": 1666505659000
|
|
3749
|
+
// },
|
|
3750
|
+
// ...
|
|
3751
|
+
// ]
|
|
3752
|
+
// }
|
|
3753
|
+
//
|
|
3754
|
+
const transfers = this.safeValue(response, 'data', []);
|
|
3755
|
+
return this.parseTransfers(transfers, currency, since, limit);
|
|
3756
|
+
}
|
|
3757
|
+
async fetchLeverageTiers(symbols = undefined, params = {}) {
|
|
3758
|
+
/**
|
|
3759
|
+
* @method
|
|
3760
|
+
* @name digifinex#fetchLeverageTiers
|
|
3761
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#instruments
|
|
3762
|
+
* @description retrieve information on the maximum leverage, for different trade sizes
|
|
3763
|
+
* @param {string[]|undefined} symbols a list of unified market symbols
|
|
3764
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3765
|
+
* @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
|
|
3766
|
+
*/
|
|
3767
|
+
await this.loadMarkets();
|
|
3768
|
+
const response = await this.publicSwapGetPublicInstruments(params);
|
|
3769
|
+
//
|
|
3770
|
+
// {
|
|
3771
|
+
// "code": 0,
|
|
3772
|
+
// "data": [
|
|
3773
|
+
// {
|
|
3774
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
3775
|
+
// "type": "REAL",
|
|
3776
|
+
// "contract_type": "PERPETUAL",
|
|
3777
|
+
// "base_currency": "BTC",
|
|
3778
|
+
// "quote_currency": "USDT",
|
|
3779
|
+
// "clear_currency": "USDT",
|
|
3780
|
+
// "contract_value": "0.001",
|
|
3781
|
+
// "contract_value_currency": "BTC",
|
|
3782
|
+
// "is_inverse": false,
|
|
3783
|
+
// "is_trading": true,
|
|
3784
|
+
// "status": "ONLINE",
|
|
3785
|
+
// "price_precision": 1,
|
|
3786
|
+
// "tick_size": "0.1",
|
|
3787
|
+
// "min_order_amount": 1,
|
|
3788
|
+
// "open_max_limits": [
|
|
3789
|
+
// {
|
|
3790
|
+
// "leverage": "50",
|
|
3791
|
+
// "max_limit": "1000000"
|
|
3792
|
+
// },
|
|
3793
|
+
// ]
|
|
3794
|
+
// },
|
|
3795
|
+
// ]
|
|
3796
|
+
// }
|
|
3797
|
+
//
|
|
3798
|
+
const data = this.safeValue(response, 'data', []);
|
|
3799
|
+
symbols = this.marketSymbols(symbols);
|
|
3800
|
+
return this.parseLeverageTiers(data, symbols, 'symbol');
|
|
3801
|
+
}
|
|
3802
|
+
parseLeverageTiers(response, symbols = undefined, marketIdKey = undefined) {
|
|
3803
|
+
const result = {};
|
|
3804
|
+
for (let i = 0; i < response.length; i++) {
|
|
3805
|
+
const entry = response[i];
|
|
3806
|
+
const marketId = this.safeString(entry, 'instrument_id');
|
|
3807
|
+
const market = this.safeMarket(marketId);
|
|
3808
|
+
const symbol = this.safeSymbol(marketId, market);
|
|
3809
|
+
let symbolsLength = 0;
|
|
3810
|
+
this.parseMarketLeverageTiers(response[i], market);
|
|
3811
|
+
if (symbols !== undefined) {
|
|
3812
|
+
symbolsLength = symbols.length;
|
|
3813
|
+
if (this.inArray(symbol, symbols)) {
|
|
3814
|
+
result[symbol] = this.parseMarketLeverageTiers(response[i], market);
|
|
3815
|
+
}
|
|
3816
|
+
}
|
|
3817
|
+
if (symbol !== undefined && (symbolsLength === 0 || this.inArray(symbols, symbol))) {
|
|
3818
|
+
result[symbol] = this.parseMarketLeverageTiers(response[i], market);
|
|
3819
|
+
}
|
|
3820
|
+
}
|
|
3821
|
+
return result;
|
|
3822
|
+
}
|
|
3823
|
+
async fetchMarketLeverageTiers(symbol, params = {}) {
|
|
3824
|
+
/**
|
|
3825
|
+
* @method
|
|
3826
|
+
* @name digifinex#fetchMarketLeverageTiers
|
|
3827
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#instrument
|
|
3828
|
+
* @description retrieve information on the maximum leverage, for different trade sizes for a single market
|
|
3829
|
+
* @param {string} symbol unified market symbol
|
|
3830
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3831
|
+
* @returns {object} a [leverage tiers structure]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}
|
|
3832
|
+
*/
|
|
3833
|
+
await this.loadMarkets();
|
|
3834
|
+
const market = this.market(symbol);
|
|
3835
|
+
if (!market['swap']) {
|
|
3836
|
+
throw new errors.BadRequest(this.id + ' fetchMarketLeverageTiers() supports swap markets only');
|
|
3837
|
+
}
|
|
3838
|
+
const request = {
|
|
3839
|
+
'instrument_id': market['id'],
|
|
3840
|
+
};
|
|
3841
|
+
const response = await this.publicSwapGetPublicInstrument(this.extend(request, params));
|
|
3842
|
+
//
|
|
3843
|
+
// {
|
|
3844
|
+
// "code": 0,
|
|
3845
|
+
// "data": {
|
|
3846
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
3847
|
+
// "type": "REAL",
|
|
3848
|
+
// "contract_type": "PERPETUAL",
|
|
3849
|
+
// "base_currency": "BTC",
|
|
3850
|
+
// "quote_currency": "USDT",
|
|
3851
|
+
// "clear_currency": "USDT",
|
|
3852
|
+
// "contract_value": "0.001",
|
|
3853
|
+
// "contract_value_currency": "BTC",
|
|
3854
|
+
// "is_inverse": false,
|
|
3855
|
+
// "is_trading": true,
|
|
3856
|
+
// "status": "ONLINE",
|
|
3857
|
+
// "price_precision": 1,
|
|
3858
|
+
// "tick_size": "0.1",
|
|
3859
|
+
// "min_order_amount": 1,
|
|
3860
|
+
// "open_max_limits": [
|
|
3861
|
+
// {
|
|
3862
|
+
// "leverage": "50",
|
|
3863
|
+
// "max_limit": "1000000"
|
|
3864
|
+
// }
|
|
3865
|
+
// ]
|
|
3866
|
+
// }
|
|
3867
|
+
// }
|
|
3868
|
+
//
|
|
3869
|
+
const data = this.safeValue(response, 'data', {});
|
|
3870
|
+
return this.parseMarketLeverageTiers(data, market);
|
|
3871
|
+
}
|
|
3872
|
+
parseMarketLeverageTiers(info, market = undefined) {
|
|
3873
|
+
//
|
|
3874
|
+
// {
|
|
3875
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
3876
|
+
// "type": "REAL",
|
|
3877
|
+
// "contract_type": "PERPETUAL",
|
|
3878
|
+
// "base_currency": "BTC",
|
|
3879
|
+
// "quote_currency": "USDT",
|
|
3880
|
+
// "clear_currency": "USDT",
|
|
3881
|
+
// "contract_value": "0.001",
|
|
3882
|
+
// "contract_value_currency": "BTC",
|
|
3883
|
+
// "is_inverse": false,
|
|
3884
|
+
// "is_trading": true,
|
|
3885
|
+
// "status": "ONLINE",
|
|
3886
|
+
// "price_precision": 1,
|
|
3887
|
+
// "tick_size": "0.1",
|
|
3888
|
+
// "min_order_amount": 1,
|
|
3889
|
+
// "open_max_limits": [
|
|
3890
|
+
// {
|
|
3891
|
+
// "leverage": "50",
|
|
3892
|
+
// "max_limit": "1000000"
|
|
3893
|
+
// }
|
|
3894
|
+
// ]
|
|
3895
|
+
// }
|
|
3896
|
+
//
|
|
3897
|
+
const tiers = [];
|
|
3898
|
+
const brackets = this.safeValue(info, 'open_max_limits', {});
|
|
3899
|
+
for (let i = 0; i < brackets.length; i++) {
|
|
3900
|
+
const tier = brackets[i];
|
|
3901
|
+
const marketId = this.safeString(info, 'instrument_id');
|
|
3902
|
+
market = this.safeMarket(marketId);
|
|
3903
|
+
tiers.push({
|
|
3904
|
+
'tier': this.sum(i, 1),
|
|
3905
|
+
'currency': market['settle'],
|
|
3906
|
+
'minNotional': undefined,
|
|
3907
|
+
'maxNotional': this.safeNumber(tier, 'max_limit'),
|
|
3908
|
+
'maintenanceMarginRate': undefined,
|
|
3909
|
+
'maxLeverage': this.safeNumber(tier, 'leverage'),
|
|
3910
|
+
'info': tier,
|
|
3911
|
+
});
|
|
3912
|
+
}
|
|
3913
|
+
return tiers;
|
|
3914
|
+
}
|
|
3915
|
+
handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
|
|
3916
|
+
/**
|
|
3917
|
+
* @ignore
|
|
3918
|
+
* @method
|
|
3919
|
+
* @description marginMode specified by params["marginMode"], this.options["marginMode"], this.options["defaultMarginMode"], params["margin"] = true or this.options["defaultType"] = 'margin'
|
|
3920
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3921
|
+
* @returns {Array} the marginMode in lowercase
|
|
3922
|
+
*/
|
|
3923
|
+
const defaultType = this.safeString(this.options, 'defaultType');
|
|
3924
|
+
const isMargin = this.safeValue(params, 'margin', false);
|
|
3925
|
+
let marginMode = undefined;
|
|
3926
|
+
[marginMode, params] = super.handleMarginModeAndParams(methodName, params, defaultValue);
|
|
3927
|
+
if (marginMode !== undefined) {
|
|
3928
|
+
if (marginMode !== 'cross') {
|
|
3929
|
+
throw new errors.NotSupported(this.id + ' only cross margin is supported');
|
|
3930
|
+
}
|
|
3931
|
+
}
|
|
3932
|
+
else {
|
|
3933
|
+
if ((defaultType === 'margin') || (isMargin === true)) {
|
|
3934
|
+
marginMode = 'cross';
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3937
|
+
return [marginMode, params];
|
|
3938
|
+
}
|
|
3939
|
+
async fetchDepositWithdrawFees(codes = undefined, params = {}) {
|
|
3940
|
+
/**
|
|
3941
|
+
* @method
|
|
3942
|
+
* @name digifinex#fetchDepositWithdrawFees
|
|
3943
|
+
* @description fetch deposit and withdraw fees
|
|
3944
|
+
* @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-currency-deposit-and-withdrawal-information
|
|
3945
|
+
* @param {string[]|undefined} codes not used by fetchDepositWithdrawFees ()
|
|
3946
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3947
|
+
* @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
3948
|
+
*/
|
|
3949
|
+
await this.loadMarkets();
|
|
3950
|
+
const response = await this.publicSpotGetCurrencies(params);
|
|
3951
|
+
//
|
|
3952
|
+
// {
|
|
3953
|
+
// "data": [
|
|
3954
|
+
// {
|
|
3955
|
+
// "deposit_status": 0,
|
|
3956
|
+
// "min_withdraw_fee": 5,
|
|
3957
|
+
// "withdraw_fee_currency": "USDT",
|
|
3958
|
+
// "chain": "OMNI",
|
|
3959
|
+
// "withdraw_fee_rate": 0,
|
|
3960
|
+
// "min_withdraw_amount": 10,
|
|
3961
|
+
// "currency": "USDT",
|
|
3962
|
+
// "withdraw_status": 0,
|
|
3963
|
+
// "min_deposit_amount": 10
|
|
3964
|
+
// },
|
|
3965
|
+
// {
|
|
3966
|
+
// "deposit_status": 1,
|
|
3967
|
+
// "min_withdraw_fee": 5,
|
|
3968
|
+
// "withdraw_fee_currency": "USDT",
|
|
3969
|
+
// "chain": "ERC20",
|
|
3970
|
+
// "withdraw_fee_rate": 0,
|
|
3971
|
+
// "min_withdraw_amount": 10,
|
|
3972
|
+
// "currency": "USDT",
|
|
3973
|
+
// "withdraw_status": 1,
|
|
3974
|
+
// "min_deposit_amount": 10
|
|
3975
|
+
// },
|
|
3976
|
+
// ],
|
|
3977
|
+
// "code": 200,
|
|
3978
|
+
// }
|
|
3979
|
+
//
|
|
3980
|
+
const data = this.safeValue(response, 'data');
|
|
3981
|
+
return this.parseDepositWithdrawFees(data, codes);
|
|
3982
|
+
}
|
|
3983
|
+
parseDepositWithdrawFees(response, codes = undefined, currencyIdKey = undefined) {
|
|
3984
|
+
//
|
|
3985
|
+
// [
|
|
3986
|
+
// {
|
|
3987
|
+
// "deposit_status": 0,
|
|
3988
|
+
// "min_withdraw_fee": 5,
|
|
3989
|
+
// "withdraw_fee_currency": "USDT",
|
|
3990
|
+
// "chain": "OMNI",
|
|
3991
|
+
// "withdraw_fee_rate": 0,
|
|
3992
|
+
// "min_withdraw_amount": 10,
|
|
3993
|
+
// "currency": "USDT",
|
|
3994
|
+
// "withdraw_status": 0,
|
|
3995
|
+
// "min_deposit_amount": 10
|
|
3996
|
+
// },
|
|
3997
|
+
// {
|
|
3998
|
+
// "deposit_status": 1,
|
|
3999
|
+
// "min_withdraw_fee": 5,
|
|
4000
|
+
// "withdraw_fee_currency": "USDT",
|
|
4001
|
+
// "chain": "ERC20",
|
|
4002
|
+
// "withdraw_fee_rate": 0,
|
|
4003
|
+
// "min_withdraw_amount": 10,
|
|
4004
|
+
// "currency": "USDT",
|
|
4005
|
+
// "withdraw_status": 1,
|
|
4006
|
+
// "min_deposit_amount": 10
|
|
4007
|
+
// },
|
|
4008
|
+
// ]
|
|
4009
|
+
//
|
|
4010
|
+
const depositWithdrawFees = {};
|
|
4011
|
+
codes = this.marketCodes(codes);
|
|
4012
|
+
for (let i = 0; i < response.length; i++) {
|
|
4013
|
+
const entry = response[i];
|
|
4014
|
+
const currencyId = this.safeString(entry, 'currency');
|
|
4015
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
4016
|
+
if ((codes === undefined) || (this.inArray(code, codes))) {
|
|
4017
|
+
const depositWithdrawFee = this.safeValue(depositWithdrawFees, code);
|
|
4018
|
+
if (depositWithdrawFee === undefined) {
|
|
4019
|
+
depositWithdrawFees[code] = this.depositWithdrawFee({});
|
|
4020
|
+
depositWithdrawFees[code]['info'] = [];
|
|
4021
|
+
}
|
|
4022
|
+
depositWithdrawFees[code]['info'].push(entry);
|
|
4023
|
+
const networkId = this.safeString(entry, 'chain');
|
|
4024
|
+
const withdrawFee = this.safeValue(entry, 'min_withdraw_fee');
|
|
4025
|
+
const withdrawResult = {
|
|
4026
|
+
'fee': withdrawFee,
|
|
4027
|
+
'percentage': (withdrawFee !== undefined) ? false : undefined,
|
|
4028
|
+
};
|
|
4029
|
+
const depositResult = {
|
|
4030
|
+
'fee': undefined,
|
|
4031
|
+
'percentage': undefined,
|
|
4032
|
+
};
|
|
4033
|
+
if (networkId !== undefined) {
|
|
4034
|
+
const networkCode = this.networkIdToCode(networkId);
|
|
4035
|
+
depositWithdrawFees[code]['networks'][networkCode] = {
|
|
4036
|
+
'withdraw': withdrawResult,
|
|
4037
|
+
'deposit': depositResult,
|
|
4038
|
+
};
|
|
4039
|
+
}
|
|
4040
|
+
else {
|
|
4041
|
+
depositWithdrawFees[code]['withdraw'] = withdrawResult;
|
|
4042
|
+
depositWithdrawFees[code]['deposit'] = depositResult;
|
|
4043
|
+
}
|
|
4044
|
+
}
|
|
4045
|
+
}
|
|
4046
|
+
const depositWithdrawCodes = Object.keys(depositWithdrawFees);
|
|
4047
|
+
for (let i = 0; i < depositWithdrawCodes.length; i++) {
|
|
4048
|
+
const code = depositWithdrawCodes[i];
|
|
4049
|
+
const currency = this.currency(code);
|
|
4050
|
+
depositWithdrawFees[code] = this.assignDefaultDepositWithdrawFees(depositWithdrawFees[code], currency);
|
|
4051
|
+
}
|
|
4052
|
+
return depositWithdrawFees;
|
|
4053
|
+
}
|
|
4054
|
+
async addMargin(symbol, amount, params = {}) {
|
|
4055
|
+
/**
|
|
4056
|
+
* @method
|
|
4057
|
+
* @name digifinex#addMargin
|
|
4058
|
+
* @description add margin to a position
|
|
4059
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmargin
|
|
4060
|
+
* @param {string} symbol unified market symbol
|
|
4061
|
+
* @param {float} amount amount of margin to add
|
|
4062
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4063
|
+
* @param {string} params.side the position side: 'long' or 'short'
|
|
4064
|
+
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=margin-structure}
|
|
4065
|
+
*/
|
|
4066
|
+
const side = this.safeString(params, 'side');
|
|
4067
|
+
this.checkRequiredArgument('addMargin', side, 'side', ['long', 'short']);
|
|
4068
|
+
return await this.modifyMarginHelper(symbol, amount, 1, params);
|
|
4069
|
+
}
|
|
4070
|
+
async reduceMargin(symbol, amount, params = {}) {
|
|
4071
|
+
/**
|
|
4072
|
+
* @method
|
|
4073
|
+
* @name digifinex#reduceMargin
|
|
4074
|
+
* @description remove margin from a position
|
|
4075
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmargin
|
|
4076
|
+
* @param {string} symbol unified market symbol
|
|
4077
|
+
* @param {float} amount the amount of margin to remove
|
|
4078
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4079
|
+
* @param {string} params.side the position side: 'long' or 'short'
|
|
4080
|
+
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=margin-structure}
|
|
4081
|
+
*/
|
|
4082
|
+
const side = this.safeString(params, 'side');
|
|
4083
|
+
this.checkRequiredArgument('reduceMargin', side, 'side', ['long', 'short']);
|
|
4084
|
+
return await this.modifyMarginHelper(symbol, amount, 2, params);
|
|
4085
|
+
}
|
|
4086
|
+
async modifyMarginHelper(symbol, amount, type, params = {}) {
|
|
4087
|
+
await this.loadMarkets();
|
|
4088
|
+
const side = this.safeString(params, 'side');
|
|
4089
|
+
const market = this.market(symbol);
|
|
4090
|
+
const request = {
|
|
4091
|
+
'instrument_id': market['id'],
|
|
4092
|
+
'amount': this.numberToString(amount),
|
|
4093
|
+
'type': type,
|
|
4094
|
+
'side': side,
|
|
4095
|
+
};
|
|
4096
|
+
const response = await this.privateSwapPostAccountPositionMargin(this.extend(request, params));
|
|
4097
|
+
//
|
|
4098
|
+
// {
|
|
4099
|
+
// "code": 0,
|
|
4100
|
+
// "data": {
|
|
4101
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
4102
|
+
// "side": "long",
|
|
4103
|
+
// "type": 1,
|
|
4104
|
+
// "amount": "3.6834"
|
|
4105
|
+
// }
|
|
4106
|
+
// }
|
|
4107
|
+
//
|
|
4108
|
+
const code = this.safeInteger(response, 'code');
|
|
4109
|
+
const status = (code === 0) ? 'ok' : 'failed';
|
|
4110
|
+
const data = this.safeValue(response, 'data', {});
|
|
4111
|
+
return this.extend(this.parseMarginModification(data, market), {
|
|
4112
|
+
'status': status,
|
|
4113
|
+
});
|
|
4114
|
+
}
|
|
4115
|
+
parseMarginModification(data, market = undefined) {
|
|
4116
|
+
//
|
|
4117
|
+
// {
|
|
4118
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
4119
|
+
// "side": "long",
|
|
4120
|
+
// "type": 1,
|
|
4121
|
+
// "amount": "3.6834"
|
|
4122
|
+
// }
|
|
4123
|
+
//
|
|
4124
|
+
const marketId = this.safeString(data, 'instrument_id');
|
|
4125
|
+
const rawType = this.safeInteger(data, 'type');
|
|
4126
|
+
return {
|
|
4127
|
+
'info': data,
|
|
4128
|
+
'type': (rawType === 1) ? 'add' : 'reduce',
|
|
4129
|
+
'amount': this.safeNumber(data, 'amount'),
|
|
4130
|
+
'total': undefined,
|
|
4131
|
+
'code': market['settle'],
|
|
4132
|
+
'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
|
|
4133
|
+
'status': undefined,
|
|
4134
|
+
};
|
|
4135
|
+
}
|
|
4136
|
+
async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
4137
|
+
/**
|
|
4138
|
+
* @method
|
|
4139
|
+
* @name digifinex#fetchFundingHistory
|
|
4140
|
+
* @description fetch the history of funding payments paid and received on this account
|
|
4141
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#funding-fee
|
|
4142
|
+
* @param {string} [symbol] unified market symbol
|
|
4143
|
+
* @param {int} [since] the earliest time in ms to fetch funding history for
|
|
4144
|
+
* @param {int} [limit] the maximum number of funding history structures to retrieve
|
|
4145
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4146
|
+
* @param {int} [params.until] timestamp in ms of the latest funding payment
|
|
4147
|
+
* @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
|
|
4148
|
+
*/
|
|
4149
|
+
await this.loadMarkets();
|
|
4150
|
+
let request = {};
|
|
4151
|
+
[request, params] = this.handleUntilOption('end_timestamp', request, params);
|
|
4152
|
+
let market = undefined;
|
|
4153
|
+
if (symbol !== undefined) {
|
|
4154
|
+
market = this.market(symbol);
|
|
4155
|
+
request['instrument_id'] = market['id'];
|
|
4156
|
+
}
|
|
4157
|
+
if (limit !== undefined) {
|
|
4158
|
+
request['limit'] = limit;
|
|
4159
|
+
}
|
|
4160
|
+
if (since !== undefined) {
|
|
4161
|
+
request['start_timestamp'] = since;
|
|
4162
|
+
}
|
|
4163
|
+
const response = await this.privateSwapGetAccountFundingFee(this.extend(request, params));
|
|
4164
|
+
//
|
|
4165
|
+
// {
|
|
4166
|
+
// "code": 0,
|
|
4167
|
+
// "data": [
|
|
4168
|
+
// {
|
|
4169
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
4170
|
+
// "currency": "USDT",
|
|
4171
|
+
// "amount": "-0.000342814",
|
|
4172
|
+
// "timestamp": 1698768009440
|
|
4173
|
+
// }
|
|
4174
|
+
// ]
|
|
4175
|
+
// }
|
|
4176
|
+
//
|
|
4177
|
+
const data = this.safeValue(response, 'data', []);
|
|
4178
|
+
return this.parseIncomes(data, market, since, limit);
|
|
4179
|
+
}
|
|
4180
|
+
parseIncome(income, market = undefined) {
|
|
4181
|
+
//
|
|
4182
|
+
// {
|
|
4183
|
+
// "instrument_id": "BTCUSDTPERP",
|
|
4184
|
+
// "currency": "USDT",
|
|
4185
|
+
// "amount": "-0.000342814",
|
|
4186
|
+
// "timestamp": 1698768009440
|
|
4187
|
+
// }
|
|
4188
|
+
//
|
|
4189
|
+
const marketId = this.safeString(income, 'instrument_id');
|
|
4190
|
+
const currencyId = this.safeString(income, 'currency');
|
|
4191
|
+
const timestamp = this.safeInteger(income, 'timestamp');
|
|
4192
|
+
return {
|
|
4193
|
+
'info': income,
|
|
4194
|
+
'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
|
|
4195
|
+
'code': this.safeCurrencyCode(currencyId),
|
|
4196
|
+
'timestamp': timestamp,
|
|
4197
|
+
'datetime': this.iso8601(timestamp),
|
|
4198
|
+
'id': undefined,
|
|
4199
|
+
'amount': this.safeNumber(income, 'amount'),
|
|
4200
|
+
};
|
|
4201
|
+
}
|
|
4202
|
+
async setMarginMode(marginMode, symbol = undefined, params = {}) {
|
|
4203
|
+
/**
|
|
4204
|
+
* @method
|
|
4205
|
+
* @name digifinex#setMarginMode
|
|
4206
|
+
* @description set margin mode to 'cross' or 'isolated'
|
|
4207
|
+
* @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#positionmode
|
|
4208
|
+
* @param {string} marginMode 'cross' or 'isolated'
|
|
4209
|
+
* @param {string} symbol unified market symbol
|
|
4210
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4211
|
+
* @returns {object} response from the exchange
|
|
4212
|
+
*/
|
|
4213
|
+
if (symbol === undefined) {
|
|
4214
|
+
throw new errors.ArgumentsRequired(this.id + ' setMarginMode() requires a symbol argument');
|
|
4215
|
+
}
|
|
4216
|
+
await this.loadMarkets();
|
|
4217
|
+
const market = this.market(symbol);
|
|
4218
|
+
marginMode = marginMode.toLowerCase();
|
|
4219
|
+
if (marginMode === 'cross') {
|
|
4220
|
+
marginMode = 'crossed';
|
|
4221
|
+
}
|
|
4222
|
+
const request = {
|
|
4223
|
+
'instrument_id': market['id'],
|
|
4224
|
+
'margin_mode': marginMode,
|
|
4225
|
+
};
|
|
4226
|
+
return await this.privateSwapPostAccountPositionMode(this.extend(request, params));
|
|
4227
|
+
}
|
|
4228
|
+
sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
4229
|
+
const signed = api[0] === 'private';
|
|
4230
|
+
const endpoint = api[1];
|
|
4231
|
+
const pathPart = (endpoint === 'spot') ? '/v3' : '/swap/v2';
|
|
4232
|
+
const request = '/' + this.implodeParams(path, params);
|
|
4233
|
+
const payload = pathPart + request;
|
|
4234
|
+
let url = this.urls['api']['rest'] + payload;
|
|
4235
|
+
const query = this.omit(params, this.extractParams(path));
|
|
4236
|
+
let urlencoded = undefined;
|
|
4237
|
+
if (signed && (pathPart === '/swap/v2') && (method === 'POST')) {
|
|
4238
|
+
urlencoded = JSON.stringify(params);
|
|
4239
|
+
}
|
|
4240
|
+
else {
|
|
4241
|
+
urlencoded = this.urlencode(this.keysort(query));
|
|
4242
|
+
}
|
|
4243
|
+
if (signed) {
|
|
4244
|
+
let auth = undefined;
|
|
4245
|
+
let nonce = undefined;
|
|
4246
|
+
if (pathPart === '/swap/v2') {
|
|
4247
|
+
nonce = this.milliseconds().toString();
|
|
4248
|
+
auth = nonce + method + payload;
|
|
4249
|
+
if (method === 'GET') {
|
|
4250
|
+
if (urlencoded) {
|
|
4251
|
+
auth += '?' + urlencoded;
|
|
4252
|
+
}
|
|
4253
|
+
}
|
|
4254
|
+
else if (method === 'POST') {
|
|
4255
|
+
auth += urlencoded;
|
|
4256
|
+
}
|
|
4257
|
+
}
|
|
4258
|
+
else {
|
|
4259
|
+
nonce = this.nonce().toString();
|
|
4260
|
+
auth = urlencoded;
|
|
4261
|
+
}
|
|
4262
|
+
const signature = this.hmac(this.encode(auth), this.encode(this.secret), sha256.sha256);
|
|
4263
|
+
if (method === 'GET') {
|
|
4264
|
+
if (urlencoded) {
|
|
4265
|
+
url += '?' + urlencoded;
|
|
4266
|
+
}
|
|
4267
|
+
}
|
|
4268
|
+
else if (method === 'POST') {
|
|
4269
|
+
headers = {
|
|
4270
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
4271
|
+
};
|
|
4272
|
+
if (urlencoded) {
|
|
4273
|
+
body = urlencoded;
|
|
4274
|
+
}
|
|
4275
|
+
}
|
|
4276
|
+
headers = {
|
|
4277
|
+
'ACCESS-KEY': this.apiKey,
|
|
4278
|
+
'ACCESS-SIGN': signature,
|
|
4279
|
+
'ACCESS-TIMESTAMP': nonce,
|
|
4280
|
+
};
|
|
4281
|
+
}
|
|
4282
|
+
else {
|
|
4283
|
+
if (urlencoded) {
|
|
4284
|
+
url += '?' + urlencoded;
|
|
4285
|
+
}
|
|
4286
|
+
}
|
|
4287
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
4288
|
+
}
|
|
4289
|
+
handleErrors(statusCode, statusText, url, method, responseHeaders, responseBody, response, requestHeaders, requestBody) {
|
|
4290
|
+
if (!response) {
|
|
4291
|
+
return undefined; // fall back to default error handler
|
|
4292
|
+
}
|
|
4293
|
+
const code = this.safeString(response, 'code');
|
|
4294
|
+
if ((code === '0') || (code === '200')) {
|
|
4295
|
+
return undefined; // no error
|
|
4296
|
+
}
|
|
4297
|
+
const feedback = this.id + ' ' + responseBody;
|
|
4298
|
+
if (code === undefined) {
|
|
4299
|
+
throw new errors.BadResponse(feedback);
|
|
4300
|
+
}
|
|
4301
|
+
const unknownError = [errors.ExchangeError, feedback];
|
|
4302
|
+
const [ExceptionClass, message] = this.safeValue(this.exceptions['exact'], code, unknownError);
|
|
4303
|
+
throw new ExceptionClass(message);
|
|
4304
|
+
}
|
|
4305
|
+
}
|
|
4306
|
+
|
|
4307
|
+
module.exports = digifinex;
|