ccxt 4.2.11 → 4.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/build.sh +2 -2
- package/dist/ccxt.browser.js +640 -261
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/_virtual/agent.js +7 -0
- package/dist/cjs/_virtual/parse-proxy-response.js +7 -0
- package/dist/cjs/_virtual/promisify.js +7 -0
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/js/ccxt.js +474 -0
- package/dist/cjs/js/src/abstract/ace.js +9 -0
- package/dist/cjs/js/src/abstract/alpaca.js +9 -0
- package/dist/cjs/js/src/abstract/ascendex.js +9 -0
- package/dist/cjs/js/src/abstract/bigone.js +9 -0
- package/dist/cjs/js/src/abstract/binance.js +9 -0
- package/dist/cjs/js/src/abstract/bingx.js +9 -0
- package/dist/cjs/js/src/abstract/bit2c.js +9 -0
- package/dist/cjs/js/src/abstract/bitbank.js +9 -0
- package/dist/cjs/js/src/abstract/bitbns.js +9 -0
- package/dist/cjs/js/src/abstract/bitfinex.js +9 -0
- package/dist/cjs/js/src/abstract/bitfinex2.js +9 -0
- package/dist/cjs/js/src/abstract/bitflyer.js +9 -0
- package/dist/cjs/js/src/abstract/bitforex.js +9 -0
- package/dist/cjs/js/src/abstract/bitget.js +9 -0
- package/dist/cjs/js/src/abstract/bithumb.js +9 -0
- package/dist/cjs/js/src/abstract/bitmart.js +9 -0
- package/dist/cjs/js/src/abstract/bitmex.js +9 -0
- package/dist/cjs/js/src/abstract/bitopro.js +9 -0
- package/dist/cjs/js/src/abstract/bitpanda.js +9 -0
- package/dist/cjs/js/src/abstract/bitrue.js +9 -0
- package/dist/cjs/js/src/abstract/bitso.js +9 -0
- package/dist/cjs/js/src/abstract/bitstamp.js +9 -0
- package/dist/cjs/js/src/abstract/bitteam.js +9 -0
- package/dist/cjs/js/src/abstract/bitvavo.js +9 -0
- package/dist/cjs/js/src/abstract/bl3p.js +9 -0
- package/dist/cjs/js/src/abstract/blockchaincom.js +9 -0
- package/dist/cjs/js/src/abstract/btcalpha.js +9 -0
- package/dist/cjs/js/src/abstract/btcbox.js +9 -0
- package/dist/cjs/js/src/abstract/btcmarkets.js +9 -0
- package/dist/cjs/js/src/abstract/btcturk.js +9 -0
- package/dist/cjs/js/src/abstract/bybit.js +9 -0
- package/dist/cjs/js/src/abstract/cex.js +9 -0
- package/dist/cjs/js/src/abstract/coinbase.js +9 -0
- package/dist/cjs/js/src/abstract/coinbasepro.js +9 -0
- package/dist/cjs/js/src/abstract/coincheck.js +9 -0
- package/dist/cjs/js/src/abstract/coinex.js +9 -0
- package/dist/cjs/js/src/abstract/coinlist.js +9 -0
- package/dist/cjs/js/src/abstract/coinmate.js +9 -0
- package/dist/cjs/js/src/abstract/coinone.js +9 -0
- package/dist/cjs/js/src/abstract/coinsph.js +9 -0
- package/dist/cjs/js/src/abstract/coinspot.js +9 -0
- package/dist/cjs/js/src/abstract/cryptocom.js +9 -0
- package/dist/cjs/js/src/abstract/currencycom.js +9 -0
- package/dist/cjs/js/src/abstract/delta.js +9 -0
- package/dist/cjs/js/src/abstract/deribit.js +9 -0
- package/dist/cjs/js/src/abstract/digifinex.js +9 -0
- package/dist/cjs/js/src/abstract/exmo.js +9 -0
- package/dist/cjs/js/src/abstract/gate.js +9 -0
- package/dist/cjs/js/src/abstract/gemini.js +9 -0
- package/dist/cjs/js/src/abstract/hitbtc.js +9 -0
- package/dist/cjs/js/src/abstract/hollaex.js +9 -0
- package/dist/cjs/js/src/abstract/htx.js +9 -0
- package/dist/cjs/js/src/abstract/huobijp.js +9 -0
- package/dist/cjs/js/src/abstract/idex.js +9 -0
- package/dist/cjs/js/src/abstract/independentreserve.js +9 -0
- package/dist/cjs/js/src/abstract/indodax.js +9 -0
- package/dist/cjs/js/src/abstract/kraken.js +9 -0
- package/dist/cjs/js/src/abstract/krakenfutures.js +9 -0
- package/dist/cjs/js/src/abstract/kucoin.js +9 -0
- package/dist/cjs/js/src/abstract/kucoinfutures.js +9 -0
- package/dist/cjs/js/src/abstract/kuna.js +9 -0
- package/dist/cjs/js/src/abstract/latoken.js +9 -0
- package/dist/cjs/js/src/abstract/lbank.js +9 -0
- package/dist/cjs/js/src/abstract/luno.js +9 -0
- package/dist/cjs/js/src/abstract/lykke.js +9 -0
- package/dist/cjs/js/src/abstract/mercado.js +9 -0
- package/dist/cjs/js/src/abstract/mexc.js +9 -0
- package/dist/cjs/js/src/abstract/ndax.js +9 -0
- package/dist/cjs/js/src/abstract/novadax.js +9 -0
- package/dist/cjs/js/src/abstract/oceanex.js +9 -0
- package/dist/cjs/js/src/abstract/okcoin.js +9 -0
- package/dist/cjs/js/src/abstract/okx.js +9 -0
- package/dist/cjs/js/src/abstract/p2b.js +9 -0
- package/dist/cjs/js/src/abstract/paymium.js +9 -0
- package/dist/cjs/js/src/abstract/phemex.js +9 -0
- package/dist/cjs/js/src/abstract/poloniex.js +9 -0
- package/dist/cjs/js/src/abstract/poloniexfutures.js +9 -0
- package/dist/cjs/js/src/abstract/probit.js +9 -0
- package/dist/cjs/js/src/abstract/timex.js +9 -0
- package/dist/cjs/js/src/abstract/tokocrypto.js +9 -0
- package/dist/cjs/js/src/abstract/upbit.js +9 -0
- package/dist/cjs/js/src/abstract/wavesexchange.js +9 -0
- package/dist/cjs/js/src/abstract/wazirx.js +9 -0
- package/dist/cjs/js/src/abstract/whitebit.js +9 -0
- package/dist/cjs/js/src/abstract/woo.js +9 -0
- package/dist/cjs/js/src/abstract/yobit.js +9 -0
- package/dist/cjs/js/src/abstract/zaif.js +9 -0
- package/dist/cjs/js/src/abstract/zonda.js +9 -0
- package/dist/cjs/js/src/ace.js +1058 -0
- package/dist/cjs/js/src/alpaca.js +1125 -0
- package/dist/cjs/js/src/ascendex.js +3360 -0
- package/dist/cjs/js/src/base/Exchange.js +5110 -0
- package/dist/cjs/js/src/base/Precise.js +263 -0
- package/dist/cjs/js/src/base/errors.js +299 -0
- package/dist/cjs/js/src/base/functions/crypto.js +78 -0
- package/dist/cjs/js/src/base/functions/encode.js +44 -0
- package/dist/cjs/js/src/base/functions/generic.js +193 -0
- package/dist/cjs/js/src/base/functions/misc.js +96 -0
- package/dist/cjs/js/src/base/functions/number.js +297 -0
- package/dist/cjs/js/src/base/functions/platform.js +28 -0
- package/dist/cjs/js/src/base/functions/rsa.js +34 -0
- package/dist/cjs/js/src/base/functions/string.js +48 -0
- package/dist/cjs/js/src/base/functions/throttle.js +66 -0
- package/dist/cjs/js/src/base/functions/time.js +187 -0
- package/dist/cjs/js/src/base/functions/totp.js +24 -0
- package/dist/cjs/js/src/base/functions/type.js +162 -0
- package/dist/cjs/js/src/base/functions.js +157 -0
- package/dist/cjs/js/src/base/ws/Cache.js +254 -0
- package/dist/cjs/js/src/base/ws/Client.js +299 -0
- package/dist/cjs/js/src/base/ws/Future.js +34 -0
- package/dist/cjs/js/src/base/ws/OrderBook.js +107 -0
- package/dist/cjs/js/src/base/ws/OrderBookSide.js +281 -0
- package/dist/cjs/js/src/base/ws/WsClient.js +69 -0
- package/dist/cjs/js/src/bequant.js +33 -0
- package/dist/cjs/js/src/bigone.js +2142 -0
- package/dist/cjs/js/src/binance.js +9729 -0
- package/dist/cjs/js/src/binancecoinm.js +45 -0
- package/dist/cjs/js/src/binanceus.js +84 -0
- package/dist/cjs/js/src/binanceusdm.js +58 -0
- package/dist/cjs/js/src/bingx.js +3737 -0
- package/dist/cjs/js/src/bit2c.js +916 -0
- package/dist/cjs/js/src/bitbank.js +1000 -0
- package/dist/cjs/js/src/bitbay.js +17 -0
- package/dist/cjs/js/src/bitbns.js +1220 -0
- package/dist/cjs/js/src/bitcoincom.js +17 -0
- package/dist/cjs/js/src/bitfinex.js +1670 -0
- package/dist/cjs/js/src/bitfinex2.js +2990 -0
- package/dist/cjs/js/src/bitflyer.js +1045 -0
- package/dist/cjs/js/src/bitforex.js +852 -0
- package/dist/cjs/js/src/bitget.js +8284 -0
- package/dist/cjs/js/src/bithumb.js +1090 -0
- package/dist/cjs/js/src/bitmart.js +4454 -0
- package/dist/cjs/js/src/bitmex.js +2884 -0
- package/dist/cjs/js/src/bitopro.js +1724 -0
- package/dist/cjs/js/src/bitpanda.js +2002 -0
- package/dist/cjs/js/src/bitrue.js +3253 -0
- package/dist/cjs/js/src/bitso.js +1753 -0
- package/dist/cjs/js/src/bitstamp.js +2188 -0
- package/dist/cjs/js/src/bitteam.js +2309 -0
- package/dist/cjs/js/src/bitvavo.js +1968 -0
- package/dist/cjs/js/src/bl3p.js +447 -0
- package/dist/cjs/js/src/blockchaincom.js +1160 -0
- package/dist/cjs/js/src/btcalpha.js +929 -0
- package/dist/cjs/js/src/btcbox.js +565 -0
- package/dist/cjs/js/src/btcmarkets.js +1237 -0
- package/dist/cjs/js/src/btcturk.js +929 -0
- package/dist/cjs/js/src/bybit.js +7646 -0
- package/dist/cjs/js/src/cex.js +1693 -0
- package/dist/cjs/js/src/coinbase.js +3274 -0
- package/dist/cjs/js/src/coinbasepro.js +1866 -0
- package/dist/cjs/js/src/coincheck.js +843 -0
- package/dist/cjs/js/src/coinex.js +5414 -0
- package/dist/cjs/js/src/coinlist.js +2329 -0
- package/dist/cjs/js/src/coinmate.js +989 -0
- package/dist/cjs/js/src/coinone.js +1185 -0
- package/dist/cjs/js/src/coinsph.js +1933 -0
- package/dist/cjs/js/src/coinspot.js +548 -0
- package/dist/cjs/js/src/cryptocom.js +3007 -0
- package/dist/cjs/js/src/currencycom.js +2015 -0
- package/dist/cjs/js/src/delta.js +3256 -0
- package/dist/cjs/js/src/deribit.js +3306 -0
- package/dist/cjs/js/src/digifinex.js +4307 -0
- package/dist/cjs/js/src/exmo.js +2645 -0
- package/dist/cjs/js/src/fmfwio.js +34 -0
- package/dist/cjs/js/src/gate.js +7054 -0
- package/dist/cjs/js/src/gateio.js +16 -0
- package/dist/cjs/js/src/gemini.js +1801 -0
- package/dist/cjs/js/src/hitbtc.js +3660 -0
- package/dist/cjs/js/src/hitbtc3.js +19 -0
- package/dist/cjs/js/src/hollaex.js +1882 -0
- package/dist/cjs/js/src/htx.js +9024 -0
- package/dist/cjs/js/src/huobi.js +16 -0
- package/dist/cjs/js/src/huobijp.js +1918 -0
- package/dist/cjs/js/src/idex.js +1770 -0
- package/dist/cjs/js/src/independentreserve.js +759 -0
- package/dist/cjs/js/src/indodax.js +1069 -0
- package/dist/cjs/js/src/kraken.js +2861 -0
- package/dist/cjs/js/src/krakenfutures.js +2407 -0
- package/dist/cjs/js/src/kucoin.js +4489 -0
- package/dist/cjs/js/src/kucoinfutures.js +2475 -0
- package/dist/cjs/js/src/kuna.js +1949 -0
- package/dist/cjs/js/src/latoken.js +1729 -0
- package/dist/cjs/js/src/lbank.js +2825 -0
- package/dist/cjs/js/src/luno.js +1044 -0
- package/dist/cjs/js/src/lykke.js +1303 -0
- package/dist/cjs/js/src/mercado.js +897 -0
- package/dist/cjs/js/src/mexc.js +5407 -0
- package/dist/cjs/js/src/ndax.js +2450 -0
- package/dist/cjs/js/src/novadax.js +1556 -0
- package/dist/cjs/js/src/oceanex.js +964 -0
- package/dist/cjs/js/src/okcoin.js +3115 -0
- package/dist/cjs/js/src/okx.js +7329 -0
- package/dist/cjs/js/src/p2b.js +1243 -0
- package/dist/cjs/js/src/paymium.js +597 -0
- package/dist/cjs/js/src/phemex.js +4715 -0
- package/dist/cjs/js/src/poloniex.js +2356 -0
- package/dist/cjs/js/src/poloniexfutures.js +1794 -0
- package/dist/cjs/js/src/pro/alpaca.js +714 -0
- package/dist/cjs/js/src/pro/ascendex.js +957 -0
- package/dist/cjs/js/src/pro/bequant.js +33 -0
- package/dist/cjs/js/src/pro/binance.js +2796 -0
- package/dist/cjs/js/src/pro/binancecoinm.js +23 -0
- package/dist/cjs/js/src/pro/binanceus.js +51 -0
- package/dist/cjs/js/src/pro/binanceusdm.js +32 -0
- package/dist/cjs/js/src/pro/bingx.js +944 -0
- package/dist/cjs/js/src/pro/bitcoincom.js +29 -0
- package/dist/cjs/js/src/pro/bitfinex.js +672 -0
- package/dist/cjs/js/src/pro/bitfinex2.js +1159 -0
- package/dist/cjs/js/src/pro/bitget.js +1733 -0
- package/dist/cjs/js/src/pro/bitmart.js +1486 -0
- package/dist/cjs/js/src/pro/bitmex.js +1576 -0
- package/dist/cjs/js/src/pro/bitopro.js +327 -0
- package/dist/cjs/js/src/pro/bitpanda.js +1341 -0
- package/dist/cjs/js/src/pro/bitrue.js +462 -0
- package/dist/cjs/js/src/pro/bitstamp.js +547 -0
- package/dist/cjs/js/src/pro/bitvavo.js +704 -0
- package/dist/cjs/js/src/pro/blockchaincom.js +794 -0
- package/dist/cjs/js/src/pro/bybit.js +1843 -0
- package/dist/cjs/js/src/pro/cex.js +1510 -0
- package/dist/cjs/js/src/pro/coinbase.js +561 -0
- package/dist/cjs/js/src/pro/coinbasepro.js +968 -0
- package/dist/cjs/js/src/pro/coinex.js +1095 -0
- package/dist/cjs/js/src/pro/cryptocom.js +1020 -0
- package/dist/cjs/js/src/pro/currencycom.js +563 -0
- package/dist/cjs/js/src/pro/deribit.js +825 -0
- package/dist/cjs/js/src/pro/exmo.js +658 -0
- package/dist/cjs/js/src/pro/gate.js +1316 -0
- package/dist/cjs/js/src/pro/gateio.js +16 -0
- package/dist/cjs/js/src/pro/gemini.js +649 -0
- package/dist/cjs/js/src/pro/hitbtc.js +1293 -0
- package/dist/cjs/js/src/pro/hollaex.js +597 -0
- package/dist/cjs/js/src/pro/htx.js +2383 -0
- package/dist/cjs/js/src/pro/huobi.js +16 -0
- package/dist/cjs/js/src/pro/huobijp.js +606 -0
- package/dist/cjs/js/src/pro/idex.js +714 -0
- package/dist/cjs/js/src/pro/independentreserve.js +280 -0
- package/dist/cjs/js/src/pro/kraken.js +1364 -0
- package/dist/cjs/js/src/pro/krakenfutures.js +1500 -0
- package/dist/cjs/js/src/pro/kucoin.js +1052 -0
- package/dist/cjs/js/src/pro/kucoinfutures.js +981 -0
- package/dist/cjs/js/src/pro/luno.js +322 -0
- package/dist/cjs/js/src/pro/mexc.js +1170 -0
- package/dist/cjs/js/src/pro/ndax.js +545 -0
- package/dist/cjs/js/src/pro/okcoin.js +760 -0
- package/dist/cjs/js/src/pro/okx.js +1558 -0
- package/dist/cjs/js/src/pro/phemex.js +1511 -0
- package/dist/cjs/js/src/pro/poloniex.js +1253 -0
- package/dist/cjs/js/src/pro/poloniexfutures.js +1014 -0
- package/dist/cjs/js/src/pro/probit.js +586 -0
- package/dist/cjs/js/src/pro/upbit.js +234 -0
- package/dist/cjs/js/src/pro/wazirx.js +776 -0
- package/dist/cjs/js/src/pro/whitebit.js +927 -0
- package/dist/cjs/js/src/pro/woo.js +769 -0
- package/dist/cjs/js/src/probit.js +1865 -0
- package/dist/cjs/js/src/static_dependencies/fflake/browser.js +401 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncrypt.js +195 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +308 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +554 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +94 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +70 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +91 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +16 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +1760 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +52 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +81 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +376 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +70 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +1580 -0
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +74 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/_shortw_utils.js +24 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/curve.js +158 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/edwards.js +429 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +176 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/modular.js +324 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/montgomery.js +163 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/utils.js +245 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +1018 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/ed25519.js +383 -0
- package/dist/cjs/js/src/static_dependencies/noble-curves/secp256k1.js +258 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/_assert.js +53 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/_sha2.js +120 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/_u64.js +69 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/crypto.js +7 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/hmac.js +83 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/md5.js +240 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha1.js +91 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha256.js +130 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha3.js +214 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha512.js +239 -0
- package/dist/cjs/js/src/static_dependencies/noble-hashes/utils.js +93 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/body.js +354 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/errors/abort-error.js +16 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/errors/base.js +20 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/errors/fetch-error.js +30 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/headers.js +239 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/index.js +372 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/request.js +273 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/response.js +139 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/get-search.js +14 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is-redirect.js +16 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is.js +81 -0
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/referrer.js +292 -0
- package/dist/cjs/js/src/static_dependencies/proxies/agent-base/index.js +103 -0
- package/dist/cjs/js/src/static_dependencies/proxies/http-proxy-agent/index.js +140 -0
- package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/index.js +175 -0
- package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +95 -0
- package/dist/cjs/js/src/static_dependencies/qs/index.cjs.js +7 -0
- package/dist/cjs/js/src/static_dependencies/scure-base/index.js +383 -0
- package/dist/cjs/js/src/timex.js +1562 -0
- package/dist/cjs/js/src/tokocrypto.js +2542 -0
- package/dist/cjs/js/src/upbit.js +1844 -0
- package/dist/cjs/js/src/wavesexchange.js +2607 -0
- package/dist/cjs/js/src/wazirx.js +953 -0
- package/dist/cjs/js/src/whitebit.js +2309 -0
- package/dist/cjs/js/src/woo.js +2715 -0
- package/dist/cjs/js/src/yobit.js +1314 -0
- package/dist/cjs/js/src/zaif.js +736 -0
- package/dist/cjs/js/src/zonda.js +1883 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bigone.d.ts +18 -0
- package/js/src/abstract/binance.d.ts +2 -0
- package/js/src/abstract/binancecoinm.d.ts +2 -0
- package/js/src/abstract/binanceus.d.ts +2 -0
- package/js/src/abstract/binanceusdm.d.ts +2 -0
- package/js/src/abstract/bybit.d.ts +1 -0
- package/js/src/abstract/gate.d.ts +11 -0
- package/js/src/abstract/gateio.d.ts +11 -0
- package/js/src/alpaca.js +18 -18
- package/js/src/base/Exchange.d.ts +5 -1
- package/js/src/base/Exchange.js +101 -12
- package/js/src/bigone.d.ts +1 -2
- package/js/src/bigone.js +340 -145
- package/js/src/binance.js +15 -8
- package/js/src/bingx.js +9 -2
- package/js/src/bitfinex.d.ts +2 -2
- package/js/src/bitfinex.js +2 -3
- package/js/src/bitget.js +21 -8
- package/js/src/bitmart.d.ts +2 -2
- package/js/src/bitmart.js +3 -3
- package/js/src/bitmex.js +1 -0
- package/js/src/bybit.js +2 -0
- package/js/src/coinlist.js +2 -3
- package/js/src/coinsph.js +2 -3
- package/js/src/deribit.js +1 -0
- package/js/src/gate.d.ts +4 -4
- package/js/src/gate.js +22 -3
- package/js/src/hitbtc.d.ts +4 -4
- package/js/src/hitbtc.js +2 -3
- package/js/src/htx.js +4 -7
- package/js/src/huobijp.js +2 -3
- package/js/src/kraken.js +1 -0
- package/js/src/mexc.js +2 -1
- package/js/src/okx.js +13 -3
- package/js/src/pro/binance.d.ts +2 -23
- package/js/src/pro/binance.js +58 -22
- package/js/src/pro/coinbase.d.ts +2 -2
- package/js/src/pro/coinbase.js +4 -1
- package/js/src/pro/coinbasepro.d.ts +2 -2
- package/js/src/pro/hitbtc.d.ts +2 -2
- package/js/src/pro/poloniex.d.ts +2 -2
- package/js/src/upbit.d.ts +3 -101
- package/js/src/upbit.js +12 -12
- package/js/src/woo.js +2 -0
- package/package.json +1 -1
- package/skip-tests.json +5 -0
|
@@ -0,0 +1,2715 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var woo$1 = require('./abstract/woo.js');
|
|
4
|
+
var errors = require('./base/errors.js');
|
|
5
|
+
var Precise = require('./base/Precise.js');
|
|
6
|
+
var number = require('./base/functions/number.js');
|
|
7
|
+
var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
|
|
8
|
+
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
/**
|
|
12
|
+
* @class woo
|
|
13
|
+
* @augments Exchange
|
|
14
|
+
*/
|
|
15
|
+
class woo extends woo$1 {
|
|
16
|
+
describe() {
|
|
17
|
+
return this.deepExtend(super.describe(), {
|
|
18
|
+
'id': 'woo',
|
|
19
|
+
'name': 'WOO X',
|
|
20
|
+
'countries': ['KY'],
|
|
21
|
+
'rateLimit': 100,
|
|
22
|
+
'version': 'v1',
|
|
23
|
+
'certified': true,
|
|
24
|
+
'pro': true,
|
|
25
|
+
'hostname': 'woo.org',
|
|
26
|
+
'has': {
|
|
27
|
+
'CORS': undefined,
|
|
28
|
+
'spot': true,
|
|
29
|
+
'margin': true,
|
|
30
|
+
'swap': true,
|
|
31
|
+
'future': false,
|
|
32
|
+
'option': false,
|
|
33
|
+
'addMargin': false,
|
|
34
|
+
'cancelAllOrders': true,
|
|
35
|
+
'cancelOrder': true,
|
|
36
|
+
'cancelWithdraw': false,
|
|
37
|
+
'closeAllPositions': false,
|
|
38
|
+
'closePosition': false,
|
|
39
|
+
'createDepositAddress': false,
|
|
40
|
+
'createMarketBuyOrderWithCost': true,
|
|
41
|
+
'createMarketOrder': false,
|
|
42
|
+
'createMarketOrderWithCost': false,
|
|
43
|
+
'createMarketSellOrderWithCost': false,
|
|
44
|
+
'createTrailingAmountOrder': true,
|
|
45
|
+
'createTrailingPercentOrder': true,
|
|
46
|
+
'createOrder': true,
|
|
47
|
+
'createReduceOnlyOrder': true,
|
|
48
|
+
'createStopLimitOrder': false,
|
|
49
|
+
'createStopMarketOrder': false,
|
|
50
|
+
'createStopOrder': false,
|
|
51
|
+
'fetchAccounts': true,
|
|
52
|
+
'fetchBalance': true,
|
|
53
|
+
'fetchCanceledOrders': false,
|
|
54
|
+
'fetchClosedOrder': false,
|
|
55
|
+
'fetchClosedOrders': false,
|
|
56
|
+
'fetchCurrencies': true,
|
|
57
|
+
'fetchDepositAddress': false,
|
|
58
|
+
'fetchDeposits': true,
|
|
59
|
+
'fetchDepositsWithdrawals': true,
|
|
60
|
+
'fetchFundingHistory': true,
|
|
61
|
+
'fetchFundingRate': true,
|
|
62
|
+
'fetchFundingRateHistory': true,
|
|
63
|
+
'fetchFundingRates': true,
|
|
64
|
+
'fetchIndexOHLCV': false,
|
|
65
|
+
'fetchLedger': true,
|
|
66
|
+
'fetchLeverage': true,
|
|
67
|
+
'fetchMarginMode': false,
|
|
68
|
+
'fetchMarkets': true,
|
|
69
|
+
'fetchMarkOHLCV': false,
|
|
70
|
+
'fetchMyTrades': true,
|
|
71
|
+
'fetchOHLCV': true,
|
|
72
|
+
'fetchOpenInterestHistory': false,
|
|
73
|
+
'fetchOpenOrder': false,
|
|
74
|
+
'fetchOpenOrders': false,
|
|
75
|
+
'fetchOrder': true,
|
|
76
|
+
'fetchOrderBook': true,
|
|
77
|
+
'fetchOrders': true,
|
|
78
|
+
'fetchOrderTrades': true,
|
|
79
|
+
'fetchPosition': true,
|
|
80
|
+
'fetchPositionMode': false,
|
|
81
|
+
'fetchPositions': true,
|
|
82
|
+
'fetchPremiumIndexOHLCV': false,
|
|
83
|
+
'fetchStatus': false,
|
|
84
|
+
'fetchTicker': false,
|
|
85
|
+
'fetchTickers': false,
|
|
86
|
+
'fetchTime': false,
|
|
87
|
+
'fetchTrades': true,
|
|
88
|
+
'fetchTradingFee': false,
|
|
89
|
+
'fetchTradingFees': true,
|
|
90
|
+
'fetchTransactions': 'emulated',
|
|
91
|
+
'fetchTransfers': true,
|
|
92
|
+
'fetchWithdrawals': true,
|
|
93
|
+
'reduceMargin': false,
|
|
94
|
+
'setLeverage': true,
|
|
95
|
+
'setMargin': false,
|
|
96
|
+
'transfer': true,
|
|
97
|
+
'withdraw': true, // exchange have that endpoint disabled atm, but was once implemented in ccxt per old docs: https://kronosresearch.github.io/wootrade-documents/#token-withdraw
|
|
98
|
+
},
|
|
99
|
+
'timeframes': {
|
|
100
|
+
'1m': '1m',
|
|
101
|
+
'5m': '5m',
|
|
102
|
+
'15m': '15m',
|
|
103
|
+
'30m': '30m',
|
|
104
|
+
'1h': '1h',
|
|
105
|
+
'4h': '4h',
|
|
106
|
+
'12h': '12h',
|
|
107
|
+
'1d': '1d',
|
|
108
|
+
'1w': '1w',
|
|
109
|
+
'1M': '1mon',
|
|
110
|
+
'1y': '1y',
|
|
111
|
+
},
|
|
112
|
+
'urls': {
|
|
113
|
+
'logo': 'https://user-images.githubusercontent.com/1294454/150730761-1a00e5e0-d28c-480f-9e65-089ce3e6ef3b.jpg',
|
|
114
|
+
'api': {
|
|
115
|
+
'pub': 'https://api-pub.woo.org',
|
|
116
|
+
'public': 'https://api.{hostname}',
|
|
117
|
+
'private': 'https://api.{hostname}',
|
|
118
|
+
},
|
|
119
|
+
'test': {
|
|
120
|
+
'pub': 'https://api-pub.staging.woo.org',
|
|
121
|
+
'public': 'https://api.staging.woo.org',
|
|
122
|
+
'private': 'https://api.staging.woo.org',
|
|
123
|
+
},
|
|
124
|
+
'www': 'https://woo.org/',
|
|
125
|
+
'doc': [
|
|
126
|
+
'https://docs.woo.org/',
|
|
127
|
+
],
|
|
128
|
+
'fees': [
|
|
129
|
+
'https://support.woo.org/hc/en-001/articles/4404611795353--Trading-Fees',
|
|
130
|
+
],
|
|
131
|
+
'referral': {
|
|
132
|
+
'url': 'https://x.woo.org/register?ref=YWOWC96B',
|
|
133
|
+
'discount': 0.35,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
'api': {
|
|
137
|
+
'v1': {
|
|
138
|
+
'pub': {
|
|
139
|
+
'get': {
|
|
140
|
+
'hist/kline': 10,
|
|
141
|
+
'hist/trades': 1,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
'public': {
|
|
145
|
+
'get': {
|
|
146
|
+
'info': 1,
|
|
147
|
+
'info/{symbol}': 1,
|
|
148
|
+
'system_info': 1,
|
|
149
|
+
'market_trades': 1,
|
|
150
|
+
'token': 1,
|
|
151
|
+
'token_network': 1,
|
|
152
|
+
'funding_rates': 1,
|
|
153
|
+
'funding_rate/{symbol}': 1,
|
|
154
|
+
'funding_rate_history': 1,
|
|
155
|
+
'futures': 1,
|
|
156
|
+
'futures/{symbol}': 1,
|
|
157
|
+
'orderbook/{symbol}': 1,
|
|
158
|
+
'kline': 1,
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
'private': {
|
|
162
|
+
'get': {
|
|
163
|
+
'client/token': 1,
|
|
164
|
+
'order/{oid}': 1,
|
|
165
|
+
'client/order/{client_order_id}': 1,
|
|
166
|
+
'orders': 1,
|
|
167
|
+
'client/trade/{tid}': 1,
|
|
168
|
+
'order/{oid}/trades': 1,
|
|
169
|
+
'client/trades': 1,
|
|
170
|
+
'asset/deposit': 10,
|
|
171
|
+
'asset/history': 60,
|
|
172
|
+
'sub_account/all': 60,
|
|
173
|
+
'sub_account/assets': 60,
|
|
174
|
+
'token_interest': 60,
|
|
175
|
+
'token_interest/{token}': 60,
|
|
176
|
+
'interest/history': 60,
|
|
177
|
+
'interest/repay': 60,
|
|
178
|
+
'funding_fee/history': 30,
|
|
179
|
+
'positions': 3.33,
|
|
180
|
+
'position/{symbol}': 3.33,
|
|
181
|
+
'client/transaction_history': 60,
|
|
182
|
+
},
|
|
183
|
+
'post': {
|
|
184
|
+
'order': 5,
|
|
185
|
+
'asset/main_sub_transfer': 30,
|
|
186
|
+
'asset/withdraw': 30,
|
|
187
|
+
'interest/repay': 60,
|
|
188
|
+
'client/account_mode': 120,
|
|
189
|
+
'client/leverage': 120,
|
|
190
|
+
},
|
|
191
|
+
'delete': {
|
|
192
|
+
'order': 1,
|
|
193
|
+
'client/order': 1,
|
|
194
|
+
'orders': 1,
|
|
195
|
+
'asset/withdraw': 120, // implemented in ccxt, disabled on the exchange side https://kronosresearch.github.io/wootrade-documents/#cancel-withdraw-request
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
'v2': {
|
|
200
|
+
'private': {
|
|
201
|
+
'get': {
|
|
202
|
+
'client/holding': 1,
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
'v3': {
|
|
207
|
+
'public': {
|
|
208
|
+
'get': {
|
|
209
|
+
'insuranceFund': 3,
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
'private': {
|
|
213
|
+
'get': {
|
|
214
|
+
'algo/order/{oid}': 1,
|
|
215
|
+
'algo/orders': 1,
|
|
216
|
+
'balances': 1,
|
|
217
|
+
'accountinfo': 60,
|
|
218
|
+
'positions': 3.33,
|
|
219
|
+
'buypower': 1,
|
|
220
|
+
'referrals': 60,
|
|
221
|
+
'referral_rewards': 60,
|
|
222
|
+
'convert/exchangeInfo': 1,
|
|
223
|
+
'convert/assetInfo': 1,
|
|
224
|
+
'convert/rfq': 60,
|
|
225
|
+
'convert/trade': 1,
|
|
226
|
+
'convert/trades': 1,
|
|
227
|
+
},
|
|
228
|
+
'post': {
|
|
229
|
+
'algo/order': 5,
|
|
230
|
+
'convert/rft': 60,
|
|
231
|
+
},
|
|
232
|
+
'put': {
|
|
233
|
+
'order/{oid}': 2,
|
|
234
|
+
'order/client/{client_order_id}': 2,
|
|
235
|
+
'algo/order/{oid}': 2,
|
|
236
|
+
'algo/order/client/{client_order_id}': 2,
|
|
237
|
+
},
|
|
238
|
+
'delete': {
|
|
239
|
+
'algo/order/{order_id}': 1,
|
|
240
|
+
'algo/orders/pending': 1,
|
|
241
|
+
'algo/orders/pending/{symbol}': 1,
|
|
242
|
+
'orders/pending': 1,
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
'fees': {
|
|
248
|
+
'trading': {
|
|
249
|
+
'tierBased': true,
|
|
250
|
+
'percentage': true,
|
|
251
|
+
'maker': this.parseNumber('0.0002'),
|
|
252
|
+
'taker': this.parseNumber('0.0005'),
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
'options': {
|
|
256
|
+
'sandboxMode': false,
|
|
257
|
+
'createMarketBuyOrderRequiresPrice': true,
|
|
258
|
+
// these network aliases require manual mapping here
|
|
259
|
+
'network-aliases-for-tokens': {
|
|
260
|
+
'HT': 'ERC20',
|
|
261
|
+
'OMG': 'ERC20',
|
|
262
|
+
'UATOM': 'ATOM',
|
|
263
|
+
'ZRX': 'ZRX',
|
|
264
|
+
},
|
|
265
|
+
'networks': {
|
|
266
|
+
'TRX': 'TRON',
|
|
267
|
+
'TRC20': 'TRON',
|
|
268
|
+
'ERC20': 'ETH',
|
|
269
|
+
'BEP20': 'BSC',
|
|
270
|
+
},
|
|
271
|
+
// override defaultNetworkCodePriorities for a specific currency
|
|
272
|
+
'defaultNetworkCodeForCurrencies': {
|
|
273
|
+
// 'USDT': 'TRC20',
|
|
274
|
+
// 'BTC': 'BTC',
|
|
275
|
+
},
|
|
276
|
+
'transfer': {
|
|
277
|
+
'fillResponseFromRequest': true,
|
|
278
|
+
},
|
|
279
|
+
'brokerId': 'bc830de7-50f3-460b-9ee0-f430f83f9dad',
|
|
280
|
+
},
|
|
281
|
+
'commonCurrencies': {},
|
|
282
|
+
'exceptions': {
|
|
283
|
+
'exact': {
|
|
284
|
+
'-1000': errors.ExchangeError,
|
|
285
|
+
'-1001': errors.AuthenticationError,
|
|
286
|
+
'-1002': errors.AuthenticationError,
|
|
287
|
+
'-1003': errors.RateLimitExceeded,
|
|
288
|
+
'-1004': errors.BadRequest,
|
|
289
|
+
'-1005': errors.BadRequest,
|
|
290
|
+
'-1006': errors.BadRequest,
|
|
291
|
+
'-1007': errors.BadRequest,
|
|
292
|
+
'-1008': errors.InvalidOrder,
|
|
293
|
+
'-1009': errors.BadRequest,
|
|
294
|
+
'-1011': errors.ExchangeError,
|
|
295
|
+
'-1012': errors.BadRequest,
|
|
296
|
+
'-1101': errors.InvalidOrder,
|
|
297
|
+
'-1102': errors.InvalidOrder,
|
|
298
|
+
'-1103': errors.InvalidOrder,
|
|
299
|
+
'-1104': errors.InvalidOrder,
|
|
300
|
+
'-1105': errors.InvalidOrder, // { "code": -1105, "message": "Price is X% too high or X% too low from the mid price." }
|
|
301
|
+
},
|
|
302
|
+
'broad': {
|
|
303
|
+
'symbol must not be blank': errors.BadRequest,
|
|
304
|
+
'The token is not supported': errors.BadRequest,
|
|
305
|
+
'Your order and symbol are not valid or already canceled': errors.BadRequest,
|
|
306
|
+
'Insufficient WOO. Please enable margin trading for leverage trading': errors.BadRequest, // when selling insufficent token [-1012]
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
'precisionMode': number.TICK_SIZE,
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
async fetchMarkets(params = {}) {
|
|
313
|
+
/**
|
|
314
|
+
* @method
|
|
315
|
+
* @name woo#fetchMarkets
|
|
316
|
+
* @description retrieves data on all markets for woo
|
|
317
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
318
|
+
* @returns {object[]} an array of objects representing market data
|
|
319
|
+
*/
|
|
320
|
+
const response = await this.v1PublicGetInfo(params);
|
|
321
|
+
//
|
|
322
|
+
// {
|
|
323
|
+
// "rows": [
|
|
324
|
+
// {
|
|
325
|
+
// "symbol": "SPOT_AAVE_USDT",
|
|
326
|
+
// "quote_min": 0,
|
|
327
|
+
// "quote_max": 100000,
|
|
328
|
+
// "quote_tick": 0.01,
|
|
329
|
+
// "base_min": 0.01,
|
|
330
|
+
// "base_max": 7284,
|
|
331
|
+
// "base_tick": 0.0001,
|
|
332
|
+
// "min_notional": 10,
|
|
333
|
+
// "price_range": 0.1,
|
|
334
|
+
// "created_time": "0",
|
|
335
|
+
// "updated_time": "1639107647.988",
|
|
336
|
+
// "is_stable": 0
|
|
337
|
+
// },
|
|
338
|
+
// ...
|
|
339
|
+
// "success": true
|
|
340
|
+
// }
|
|
341
|
+
//
|
|
342
|
+
const data = this.safeValue(response, 'rows', []);
|
|
343
|
+
return this.parseMarkets(data);
|
|
344
|
+
}
|
|
345
|
+
parseMarket(market) {
|
|
346
|
+
const marketId = this.safeString(market, 'symbol');
|
|
347
|
+
const parts = marketId.split('_');
|
|
348
|
+
const first = this.safeString(parts, 0);
|
|
349
|
+
let marketType;
|
|
350
|
+
let spot = false;
|
|
351
|
+
let swap = false;
|
|
352
|
+
if (first === 'SPOT') {
|
|
353
|
+
spot = true;
|
|
354
|
+
marketType = 'spot';
|
|
355
|
+
}
|
|
356
|
+
else if (first === 'PERP') {
|
|
357
|
+
swap = true;
|
|
358
|
+
marketType = 'swap';
|
|
359
|
+
}
|
|
360
|
+
const baseId = this.safeString(parts, 1);
|
|
361
|
+
const quoteId = this.safeString(parts, 2);
|
|
362
|
+
const base = this.safeCurrencyCode(baseId);
|
|
363
|
+
const quote = this.safeCurrencyCode(quoteId);
|
|
364
|
+
let settleId = undefined;
|
|
365
|
+
let settle = undefined;
|
|
366
|
+
let symbol = base + '/' + quote;
|
|
367
|
+
let contractSize = undefined;
|
|
368
|
+
let linear = undefined;
|
|
369
|
+
let margin = true;
|
|
370
|
+
const contract = swap;
|
|
371
|
+
if (contract) {
|
|
372
|
+
margin = false;
|
|
373
|
+
settleId = this.safeString(parts, 2);
|
|
374
|
+
settle = this.safeCurrencyCode(settleId);
|
|
375
|
+
symbol = base + '/' + quote + ':' + settle;
|
|
376
|
+
contractSize = this.parseNumber('1');
|
|
377
|
+
linear = true;
|
|
378
|
+
}
|
|
379
|
+
return {
|
|
380
|
+
'id': marketId,
|
|
381
|
+
'symbol': symbol,
|
|
382
|
+
'base': base,
|
|
383
|
+
'quote': quote,
|
|
384
|
+
'settle': settle,
|
|
385
|
+
'baseId': baseId,
|
|
386
|
+
'quoteId': quoteId,
|
|
387
|
+
'settleId': settleId,
|
|
388
|
+
'type': marketType,
|
|
389
|
+
'spot': spot,
|
|
390
|
+
'margin': margin,
|
|
391
|
+
'swap': swap,
|
|
392
|
+
'future': false,
|
|
393
|
+
'option': false,
|
|
394
|
+
'active': undefined,
|
|
395
|
+
'contract': contract,
|
|
396
|
+
'linear': linear,
|
|
397
|
+
'inverse': undefined,
|
|
398
|
+
'contractSize': contractSize,
|
|
399
|
+
'expiry': undefined,
|
|
400
|
+
'expiryDatetime': undefined,
|
|
401
|
+
'strike': undefined,
|
|
402
|
+
'optionType': undefined,
|
|
403
|
+
'precision': {
|
|
404
|
+
'amount': this.safeNumber(market, 'base_tick'),
|
|
405
|
+
'price': this.safeNumber(market, 'quote_tick'),
|
|
406
|
+
},
|
|
407
|
+
'limits': {
|
|
408
|
+
'leverage': {
|
|
409
|
+
'min': undefined,
|
|
410
|
+
'max': undefined,
|
|
411
|
+
},
|
|
412
|
+
'amount': {
|
|
413
|
+
'min': this.safeNumber(market, 'base_min'),
|
|
414
|
+
'max': this.safeNumber(market, 'base_max'),
|
|
415
|
+
},
|
|
416
|
+
'price': {
|
|
417
|
+
'min': this.safeNumber(market, 'quote_min'),
|
|
418
|
+
'max': this.safeNumber(market, 'quote_max'),
|
|
419
|
+
},
|
|
420
|
+
'cost': {
|
|
421
|
+
'min': this.safeNumber(market, 'min_notional'),
|
|
422
|
+
'max': undefined,
|
|
423
|
+
},
|
|
424
|
+
},
|
|
425
|
+
'created': this.safeTimestamp(market, 'created_time'),
|
|
426
|
+
'info': market,
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
430
|
+
/**
|
|
431
|
+
* @method
|
|
432
|
+
* @name woo#fetchTrades
|
|
433
|
+
* @description get the list of most recent trades for a particular symbol
|
|
434
|
+
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
435
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
436
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
437
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
438
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
439
|
+
*/
|
|
440
|
+
await this.loadMarkets();
|
|
441
|
+
const market = this.market(symbol);
|
|
442
|
+
const request = {
|
|
443
|
+
'symbol': market['id'],
|
|
444
|
+
};
|
|
445
|
+
if (limit !== undefined) {
|
|
446
|
+
request['limit'] = limit;
|
|
447
|
+
}
|
|
448
|
+
const response = await this.v1PublicGetMarketTrades(this.extend(request, params));
|
|
449
|
+
//
|
|
450
|
+
// {
|
|
451
|
+
// "success": true,
|
|
452
|
+
// "rows": [
|
|
453
|
+
// {
|
|
454
|
+
// "symbol": "SPOT_BTC_USDT",
|
|
455
|
+
// "side": "SELL",
|
|
456
|
+
// "executed_price": 46222.35,
|
|
457
|
+
// "executed_quantity": 0.0012,
|
|
458
|
+
// "executed_timestamp": "1641241162.329"
|
|
459
|
+
// },
|
|
460
|
+
// {
|
|
461
|
+
// "symbol": "SPOT_BTC_USDT",
|
|
462
|
+
// "side": "SELL",
|
|
463
|
+
// "executed_price": 46222.35,
|
|
464
|
+
// "executed_quantity": 0.0012,
|
|
465
|
+
// "executed_timestamp": "1641241162.329"
|
|
466
|
+
// },
|
|
467
|
+
// {
|
|
468
|
+
// "symbol": "SPOT_BTC_USDT",
|
|
469
|
+
// "side": "BUY",
|
|
470
|
+
// "executed_price": 46224.32,
|
|
471
|
+
// "executed_quantity": 0.00039,
|
|
472
|
+
// "executed_timestamp": "1641241162.287"
|
|
473
|
+
// },
|
|
474
|
+
// ...
|
|
475
|
+
// ]
|
|
476
|
+
// }
|
|
477
|
+
//
|
|
478
|
+
const resultResponse = this.safeValue(response, 'rows', {});
|
|
479
|
+
return this.parseTrades(resultResponse, market, since, limit);
|
|
480
|
+
}
|
|
481
|
+
parseTrade(trade, market = undefined) {
|
|
482
|
+
//
|
|
483
|
+
// public/market_trades
|
|
484
|
+
//
|
|
485
|
+
// {
|
|
486
|
+
// "symbol": "SPOT_BTC_USDT",
|
|
487
|
+
// "side": "SELL",
|
|
488
|
+
// "executed_price": 46222.35,
|
|
489
|
+
// "executed_quantity": 0.0012,
|
|
490
|
+
// "executed_timestamp": "1641241162.329"
|
|
491
|
+
// }
|
|
492
|
+
//
|
|
493
|
+
// fetchOrderTrades, fetchOrder
|
|
494
|
+
//
|
|
495
|
+
// {
|
|
496
|
+
// "id": "99119876",
|
|
497
|
+
// "symbol": "SPOT_WOO_USDT",
|
|
498
|
+
// "fee": "0.0024",
|
|
499
|
+
// "side": "BUY",
|
|
500
|
+
// "executed_timestamp": "1641481113.084",
|
|
501
|
+
// "order_id": "87001234",
|
|
502
|
+
// "order_tag": "default", <-- this param only in "fetchOrderTrades"
|
|
503
|
+
// "executed_price": "1",
|
|
504
|
+
// "executed_quantity": "12",
|
|
505
|
+
// "fee_asset": "WOO",
|
|
506
|
+
// "is_maker": "1"
|
|
507
|
+
// }
|
|
508
|
+
//
|
|
509
|
+
const isFromFetchOrder = ('id' in trade);
|
|
510
|
+
const timestamp = this.safeTimestamp(trade, 'executed_timestamp');
|
|
511
|
+
const marketId = this.safeString(trade, 'symbol');
|
|
512
|
+
market = this.safeMarket(marketId, market);
|
|
513
|
+
const symbol = market['symbol'];
|
|
514
|
+
const price = this.safeString(trade, 'executed_price');
|
|
515
|
+
const amount = this.safeString(trade, 'executed_quantity');
|
|
516
|
+
const order_id = this.safeString(trade, 'order_id');
|
|
517
|
+
const fee = this.parseTokenAndFeeTemp(trade, 'fee_asset', 'fee');
|
|
518
|
+
const cost = Precise["default"].stringMul(price, amount);
|
|
519
|
+
const side = this.safeStringLower(trade, 'side');
|
|
520
|
+
const id = this.safeString(trade, 'id');
|
|
521
|
+
let takerOrMaker = undefined;
|
|
522
|
+
if (isFromFetchOrder) {
|
|
523
|
+
const isMaker = this.safeString(trade, 'is_maker') === '1';
|
|
524
|
+
takerOrMaker = isMaker ? 'maker' : 'taker';
|
|
525
|
+
}
|
|
526
|
+
return this.safeTrade({
|
|
527
|
+
'id': id,
|
|
528
|
+
'timestamp': timestamp,
|
|
529
|
+
'datetime': this.iso8601(timestamp),
|
|
530
|
+
'symbol': symbol,
|
|
531
|
+
'side': side,
|
|
532
|
+
'price': price,
|
|
533
|
+
'amount': amount,
|
|
534
|
+
'cost': cost,
|
|
535
|
+
'order': order_id,
|
|
536
|
+
'takerOrMaker': takerOrMaker,
|
|
537
|
+
'type': undefined,
|
|
538
|
+
'fee': fee,
|
|
539
|
+
'info': trade,
|
|
540
|
+
}, market);
|
|
541
|
+
}
|
|
542
|
+
parseTokenAndFeeTemp(item, feeTokenKey, feeAmountKey) {
|
|
543
|
+
const feeCost = this.safeString(item, feeAmountKey);
|
|
544
|
+
let fee = undefined;
|
|
545
|
+
if (feeCost !== undefined) {
|
|
546
|
+
const feeCurrencyId = this.safeString(item, feeTokenKey);
|
|
547
|
+
const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
|
|
548
|
+
fee = {
|
|
549
|
+
'cost': feeCost,
|
|
550
|
+
'currency': feeCurrencyCode,
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
return fee;
|
|
554
|
+
}
|
|
555
|
+
async fetchTradingFees(params = {}) {
|
|
556
|
+
/**
|
|
557
|
+
* @method
|
|
558
|
+
* @name woo#fetchTradingFees
|
|
559
|
+
* @description fetch the trading fees for multiple markets
|
|
560
|
+
* @see https://docs.woo.org/#get-account-information-new
|
|
561
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
562
|
+
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
|
|
563
|
+
*/
|
|
564
|
+
await this.loadMarkets();
|
|
565
|
+
const response = await this.v3PrivateGetAccountinfo(params);
|
|
566
|
+
//
|
|
567
|
+
// {
|
|
568
|
+
// "success": true,
|
|
569
|
+
// "data": {
|
|
570
|
+
// "applicationId": "dsa",
|
|
571
|
+
// "account": "dsa",
|
|
572
|
+
// "alias": "haha",
|
|
573
|
+
// "accountMode": "MARGIN",
|
|
574
|
+
// "leverage": 1,
|
|
575
|
+
// "takerFeeRate": 1,
|
|
576
|
+
// "makerFeeRate": 1,
|
|
577
|
+
// "interestRate": 1,
|
|
578
|
+
// "futuresTakerFeeRate": 1,
|
|
579
|
+
// "futuresMakerFeeRate": 1,
|
|
580
|
+
// "otpauth": true,
|
|
581
|
+
// "marginRatio": 1,
|
|
582
|
+
// "openMarginRatio": 1,
|
|
583
|
+
// "initialMarginRatio": 1,
|
|
584
|
+
// "maintenanceMarginRatio": 1,
|
|
585
|
+
// "totalCollateral": 1,
|
|
586
|
+
// "freeCollateral": 1,
|
|
587
|
+
// "totalAccountValue": 1,
|
|
588
|
+
// "totalVaultValue": 1,
|
|
589
|
+
// "totalStakingValue": 1
|
|
590
|
+
// },
|
|
591
|
+
// "timestamp": 1673323685109
|
|
592
|
+
// }
|
|
593
|
+
//
|
|
594
|
+
const data = this.safeValue(response, 'data', {});
|
|
595
|
+
const maker = this.safeString(data, 'makerFeeRate');
|
|
596
|
+
const taker = this.safeString(data, 'takerFeeRate');
|
|
597
|
+
const result = {};
|
|
598
|
+
for (let i = 0; i < this.symbols.length; i++) {
|
|
599
|
+
const symbol = this.symbols[i];
|
|
600
|
+
result[symbol] = {
|
|
601
|
+
'info': response,
|
|
602
|
+
'symbol': symbol,
|
|
603
|
+
'maker': this.parseNumber(Precise["default"].stringDiv(maker, '10000')),
|
|
604
|
+
'taker': this.parseNumber(Precise["default"].stringDiv(taker, '10000')),
|
|
605
|
+
'percentage': true,
|
|
606
|
+
'tierBased': true,
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
return result;
|
|
610
|
+
}
|
|
611
|
+
async fetchCurrencies(params = {}) {
|
|
612
|
+
/**
|
|
613
|
+
* @method
|
|
614
|
+
* @name woo#fetchCurrencies
|
|
615
|
+
* @description fetches all available currencies on an exchange
|
|
616
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
617
|
+
* @returns {object} an associative dictionary of currencies
|
|
618
|
+
*/
|
|
619
|
+
const result = {};
|
|
620
|
+
const tokenResponse = await this.v1PublicGetToken(params);
|
|
621
|
+
//
|
|
622
|
+
// {
|
|
623
|
+
// "rows": [
|
|
624
|
+
// {
|
|
625
|
+
// "token": "ETH_USDT",
|
|
626
|
+
// "fullname": "Tether",
|
|
627
|
+
// "decimals": 6,
|
|
628
|
+
// "balance_token": "USDT",
|
|
629
|
+
// "created_time": "0",
|
|
630
|
+
// "updated_time": "0"
|
|
631
|
+
// },
|
|
632
|
+
// {
|
|
633
|
+
// "token": "BSC_USDT",
|
|
634
|
+
// "fullname": "Tether",
|
|
635
|
+
// "decimals": 18,
|
|
636
|
+
// "balance_token": "USDT",
|
|
637
|
+
// "created_time": "0",
|
|
638
|
+
// "updated_time": "0"
|
|
639
|
+
// },
|
|
640
|
+
// {
|
|
641
|
+
// "token": "ZEC",
|
|
642
|
+
// "fullname": "ZCash",
|
|
643
|
+
// "decimals": 8,
|
|
644
|
+
// "balance_token": "ZEC",
|
|
645
|
+
// "created_time": "0",
|
|
646
|
+
// "updated_time": "0"
|
|
647
|
+
// },
|
|
648
|
+
// ...
|
|
649
|
+
// ],
|
|
650
|
+
// "success": true
|
|
651
|
+
// }
|
|
652
|
+
//
|
|
653
|
+
// only make one request for currrencies...
|
|
654
|
+
// const tokenNetworkResponse = await this.v1PublicGetTokenNetwork (params);
|
|
655
|
+
//
|
|
656
|
+
// {
|
|
657
|
+
// "rows": [
|
|
658
|
+
// {
|
|
659
|
+
// "protocol": "ERC20",
|
|
660
|
+
// "token": "USDT",
|
|
661
|
+
// "name": "Ethereum",
|
|
662
|
+
// "minimum_withdrawal": 30,
|
|
663
|
+
// "withdrawal_fee": 25,
|
|
664
|
+
// "allow_deposit": 1,
|
|
665
|
+
// "allow_withdraw": 1
|
|
666
|
+
// },
|
|
667
|
+
// {
|
|
668
|
+
// "protocol": "TRC20",
|
|
669
|
+
// "token": "USDT",
|
|
670
|
+
// "name": "Tron",
|
|
671
|
+
// "minimum_withdrawal": 30,
|
|
672
|
+
// "withdrawal_fee": 1,
|
|
673
|
+
// "allow_deposit": 1,
|
|
674
|
+
// "allow_withdraw": 1
|
|
675
|
+
// },
|
|
676
|
+
// ...
|
|
677
|
+
// ],
|
|
678
|
+
// "success": true
|
|
679
|
+
// }
|
|
680
|
+
//
|
|
681
|
+
const tokenRows = this.safeValue(tokenResponse, 'rows', []);
|
|
682
|
+
const networksByCurrencyId = this.groupBy(tokenRows, 'balance_token');
|
|
683
|
+
const currencyIds = Object.keys(networksByCurrencyId);
|
|
684
|
+
for (let i = 0; i < currencyIds.length; i++) {
|
|
685
|
+
const currencyId = currencyIds[i];
|
|
686
|
+
const networks = networksByCurrencyId[currencyId];
|
|
687
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
688
|
+
let name = undefined;
|
|
689
|
+
let minPrecision = undefined;
|
|
690
|
+
const resultingNetworks = {};
|
|
691
|
+
for (let j = 0; j < networks.length; j++) {
|
|
692
|
+
const network = networks[j];
|
|
693
|
+
name = this.safeString(network, 'fullname');
|
|
694
|
+
const networkId = this.safeString(network, 'token');
|
|
695
|
+
const splitted = networkId.split('_');
|
|
696
|
+
const unifiedNetwork = splitted[0];
|
|
697
|
+
const precision = this.parsePrecision(this.safeString(network, 'decimals'));
|
|
698
|
+
if (precision !== undefined) {
|
|
699
|
+
minPrecision = (minPrecision === undefined) ? precision : Precise["default"].stringMin(precision, minPrecision);
|
|
700
|
+
}
|
|
701
|
+
resultingNetworks[unifiedNetwork] = {
|
|
702
|
+
'id': networkId,
|
|
703
|
+
'network': unifiedNetwork,
|
|
704
|
+
'limits': {
|
|
705
|
+
'withdraw': {
|
|
706
|
+
'min': undefined,
|
|
707
|
+
'max': undefined,
|
|
708
|
+
},
|
|
709
|
+
'deposit': {
|
|
710
|
+
'min': undefined,
|
|
711
|
+
'max': undefined,
|
|
712
|
+
},
|
|
713
|
+
},
|
|
714
|
+
'active': undefined,
|
|
715
|
+
'deposit': undefined,
|
|
716
|
+
'withdraw': undefined,
|
|
717
|
+
'fee': undefined,
|
|
718
|
+
'precision': this.parseNumber(precision),
|
|
719
|
+
'info': network,
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
result[code] = {
|
|
723
|
+
'id': currencyId,
|
|
724
|
+
'name': name,
|
|
725
|
+
'code': code,
|
|
726
|
+
'precision': this.parseNumber(minPrecision),
|
|
727
|
+
'active': undefined,
|
|
728
|
+
'fee': undefined,
|
|
729
|
+
'networks': resultingNetworks,
|
|
730
|
+
'deposit': undefined,
|
|
731
|
+
'withdraw': undefined,
|
|
732
|
+
'limits': {
|
|
733
|
+
'deposit': {
|
|
734
|
+
'min': undefined,
|
|
735
|
+
'max': undefined,
|
|
736
|
+
},
|
|
737
|
+
'withdraw': {
|
|
738
|
+
'min': undefined,
|
|
739
|
+
'max': undefined,
|
|
740
|
+
},
|
|
741
|
+
},
|
|
742
|
+
'info': networks,
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
return result;
|
|
746
|
+
}
|
|
747
|
+
async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
|
|
748
|
+
/**
|
|
749
|
+
* @method
|
|
750
|
+
* @name woo#createMarketBuyOrderWithCost
|
|
751
|
+
* @description create a market buy order by providing the symbol and cost
|
|
752
|
+
* @see https://docs.woo.org/#send-order
|
|
753
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
754
|
+
* @param {float} cost how much you want to trade in units of the quote currency
|
|
755
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
756
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
757
|
+
*/
|
|
758
|
+
await this.loadMarkets();
|
|
759
|
+
const market = this.market(symbol);
|
|
760
|
+
if (!market['spot']) {
|
|
761
|
+
throw new errors.NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
|
|
762
|
+
}
|
|
763
|
+
params['createMarketBuyOrderRequiresPrice'] = false;
|
|
764
|
+
return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
|
|
765
|
+
}
|
|
766
|
+
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
767
|
+
/**
|
|
768
|
+
* @method
|
|
769
|
+
* @name woo#createOrder
|
|
770
|
+
* @description create a trade order
|
|
771
|
+
* @see https://docs.woo.org/#send-order
|
|
772
|
+
* @see https://docs.woo.org/#send-algo-order
|
|
773
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
774
|
+
* @param {string} type 'market' or 'limit'
|
|
775
|
+
* @param {string} side 'buy' or 'sell'
|
|
776
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
777
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
778
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
779
|
+
* @param {float} [params.triggerPrice] The price a trigger order is triggered at
|
|
780
|
+
* @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered (perpetual swap markets only)
|
|
781
|
+
* @param {float} [params.takeProfit.triggerPrice] take profit trigger price
|
|
782
|
+
* @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered (perpetual swap markets only)
|
|
783
|
+
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
|
|
784
|
+
* @param {float} [params.algoType] 'STOP'or 'TRAILING_STOP' or 'OCO' or 'CLOSE_POSITION'
|
|
785
|
+
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
786
|
+
* @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
|
|
787
|
+
* @param {string} [params.trailingPercent] the percent to trail away from the current market price
|
|
788
|
+
* @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
|
|
789
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
790
|
+
*/
|
|
791
|
+
const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
|
|
792
|
+
params = this.omit(params, ['reduceOnly', 'reduce_only']);
|
|
793
|
+
const orderType = type.toUpperCase();
|
|
794
|
+
await this.loadMarkets();
|
|
795
|
+
const market = this.market(symbol);
|
|
796
|
+
const orderSide = side.toUpperCase();
|
|
797
|
+
const request = {
|
|
798
|
+
'symbol': market['id'],
|
|
799
|
+
'side': orderSide,
|
|
800
|
+
};
|
|
801
|
+
const stopPrice = this.safeNumber2(params, 'triggerPrice', 'stopPrice');
|
|
802
|
+
const stopLoss = this.safeValue(params, 'stopLoss');
|
|
803
|
+
const takeProfit = this.safeValue(params, 'takeProfit');
|
|
804
|
+
const algoType = this.safeString(params, 'algoType');
|
|
805
|
+
const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activatedPrice', price);
|
|
806
|
+
const trailingAmount = this.safeString2(params, 'trailingAmount', 'callbackValue');
|
|
807
|
+
const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
|
|
808
|
+
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
809
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
810
|
+
const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
|
|
811
|
+
const isStop = isTrailing || stopPrice !== undefined || stopLoss !== undefined || takeProfit !== undefined || (this.safeValue(params, 'childOrders') !== undefined);
|
|
812
|
+
const isMarket = orderType === 'MARKET';
|
|
813
|
+
const timeInForce = this.safeStringLower(params, 'timeInForce');
|
|
814
|
+
const postOnly = this.isPostOnly(isMarket, undefined, params);
|
|
815
|
+
const reduceOnlyKey = isStop ? 'reduceOnly' : 'reduce_only';
|
|
816
|
+
const clientOrderIdKey = isStop ? 'clientOrderId' : 'client_order_id';
|
|
817
|
+
const orderQtyKey = isStop ? 'quantity' : 'order_quantity';
|
|
818
|
+
const priceKey = isStop ? 'price' : 'order_price';
|
|
819
|
+
const typeKey = isStop ? 'type' : 'order_type';
|
|
820
|
+
request[typeKey] = orderType; // LIMIT/MARKET/IOC/FOK/POST_ONLY/ASK/BID
|
|
821
|
+
if (!isStop) {
|
|
822
|
+
if (postOnly) {
|
|
823
|
+
request['order_type'] = 'POST_ONLY';
|
|
824
|
+
}
|
|
825
|
+
else if (timeInForce === 'fok') {
|
|
826
|
+
request['order_type'] = 'FOK';
|
|
827
|
+
}
|
|
828
|
+
else if (timeInForce === 'ioc') {
|
|
829
|
+
request['order_type'] = 'IOC';
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
if (reduceOnly) {
|
|
833
|
+
request[reduceOnlyKey] = reduceOnly;
|
|
834
|
+
}
|
|
835
|
+
if (price !== undefined) {
|
|
836
|
+
request[priceKey] = this.priceToPrecision(symbol, price);
|
|
837
|
+
}
|
|
838
|
+
if (isMarket && !isStop) {
|
|
839
|
+
// for market buy it requires the amount of quote currency to spend
|
|
840
|
+
if (market['spot'] && orderSide === 'BUY') {
|
|
841
|
+
let quoteAmount = undefined;
|
|
842
|
+
let createMarketBuyOrderRequiresPrice = true;
|
|
843
|
+
[createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
|
|
844
|
+
const cost = this.safeNumber2(params, 'cost', 'order_amount');
|
|
845
|
+
params = this.omit(params, ['cost', 'order_amount']);
|
|
846
|
+
if (cost !== undefined) {
|
|
847
|
+
quoteAmount = this.costToPrecision(symbol, cost);
|
|
848
|
+
}
|
|
849
|
+
else if (createMarketBuyOrderRequiresPrice) {
|
|
850
|
+
if (price === undefined) {
|
|
851
|
+
throw new errors.InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument');
|
|
852
|
+
}
|
|
853
|
+
else {
|
|
854
|
+
const amountString = this.numberToString(amount);
|
|
855
|
+
const priceString = this.numberToString(price);
|
|
856
|
+
const costRequest = Precise["default"].stringMul(amountString, priceString);
|
|
857
|
+
quoteAmount = this.costToPrecision(symbol, costRequest);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
else {
|
|
861
|
+
quoteAmount = this.costToPrecision(symbol, amount);
|
|
862
|
+
}
|
|
863
|
+
request['order_amount'] = quoteAmount;
|
|
864
|
+
}
|
|
865
|
+
else {
|
|
866
|
+
request['order_quantity'] = this.amountToPrecision(symbol, amount);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
else if (algoType !== 'POSITIONAL_TP_SL') {
|
|
870
|
+
request[orderQtyKey] = this.amountToPrecision(symbol, amount);
|
|
871
|
+
}
|
|
872
|
+
const clientOrderId = this.safeStringN(params, ['clOrdID', 'clientOrderId', 'client_order_id']);
|
|
873
|
+
if (clientOrderId !== undefined) {
|
|
874
|
+
request[clientOrderIdKey] = clientOrderId;
|
|
875
|
+
}
|
|
876
|
+
if (isTrailing) {
|
|
877
|
+
if (trailingTriggerPrice === undefined) {
|
|
878
|
+
throw new errors.ArgumentsRequired(this.id + ' createOrder() requires a trailingTriggerPrice parameter for trailing orders');
|
|
879
|
+
}
|
|
880
|
+
request['activatedPrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
|
|
881
|
+
request['algoType'] = 'TRAILING_STOP';
|
|
882
|
+
if (isTrailingAmountOrder) {
|
|
883
|
+
request['callbackValue'] = trailingAmount;
|
|
884
|
+
}
|
|
885
|
+
else if (isTrailingPercentOrder) {
|
|
886
|
+
const convertedTrailingPercent = Precise["default"].stringDiv(trailingPercent, '100');
|
|
887
|
+
request['callbackRate'] = convertedTrailingPercent;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
else if (stopPrice !== undefined) {
|
|
891
|
+
if (algoType !== 'TRAILING_STOP') {
|
|
892
|
+
request['triggerPrice'] = this.priceToPrecision(symbol, stopPrice);
|
|
893
|
+
request['algoType'] = 'STOP';
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
else if ((stopLoss !== undefined) || (takeProfit !== undefined)) {
|
|
897
|
+
request['algoType'] = 'BRACKET';
|
|
898
|
+
const outterOrder = {
|
|
899
|
+
'symbol': market['id'],
|
|
900
|
+
'reduceOnly': false,
|
|
901
|
+
'algoType': 'POSITIONAL_TP_SL',
|
|
902
|
+
'childOrders': [],
|
|
903
|
+
};
|
|
904
|
+
const closeSide = (orderSide === 'BUY') ? 'SELL' : 'BUY';
|
|
905
|
+
if (stopLoss !== undefined) {
|
|
906
|
+
const stopLossPrice = this.safeNumber2(stopLoss, 'triggerPrice', 'price', stopLoss);
|
|
907
|
+
const stopLossOrder = {
|
|
908
|
+
'side': closeSide,
|
|
909
|
+
'algoType': 'STOP_LOSS',
|
|
910
|
+
'triggerPrice': this.priceToPrecision(symbol, stopLossPrice),
|
|
911
|
+
'type': 'CLOSE_POSITION',
|
|
912
|
+
'reduceOnly': true,
|
|
913
|
+
};
|
|
914
|
+
outterOrder['childOrders'].push(stopLossOrder);
|
|
915
|
+
}
|
|
916
|
+
if (takeProfit !== undefined) {
|
|
917
|
+
const takeProfitPrice = this.safeNumber2(takeProfit, 'triggerPrice', 'price', takeProfit);
|
|
918
|
+
const takeProfitOrder = {
|
|
919
|
+
'side': closeSide,
|
|
920
|
+
'algoType': 'TAKE_PROFIT',
|
|
921
|
+
'triggerPrice': this.priceToPrecision(symbol, takeProfitPrice),
|
|
922
|
+
'type': 'CLOSE_POSITION',
|
|
923
|
+
'reduceOnly': true,
|
|
924
|
+
};
|
|
925
|
+
outterOrder['childOrders'].push(takeProfitOrder);
|
|
926
|
+
}
|
|
927
|
+
request['childOrders'] = [outterOrder];
|
|
928
|
+
}
|
|
929
|
+
params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'postOnly', 'timeInForce', 'stopPrice', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingPercent', 'trailingAmount', 'trailingTriggerPrice']);
|
|
930
|
+
let response = undefined;
|
|
931
|
+
if (isStop) {
|
|
932
|
+
response = await this.v3PrivatePostAlgoOrder(this.extend(request, params));
|
|
933
|
+
}
|
|
934
|
+
else {
|
|
935
|
+
response = await this.v1PrivatePostOrder(this.extend(request, params));
|
|
936
|
+
}
|
|
937
|
+
// {
|
|
938
|
+
// "success": true,
|
|
939
|
+
// "timestamp": "1641383206.489",
|
|
940
|
+
// "order_id": "86980774",
|
|
941
|
+
// "order_type": "LIMIT",
|
|
942
|
+
// "order_price": "1", // null for "MARKET" order
|
|
943
|
+
// "order_quantity": "12", // null for "MARKET" order
|
|
944
|
+
// "order_amount": null, // NOT-null for "MARKET" order
|
|
945
|
+
// "client_order_id": "0"
|
|
946
|
+
// }
|
|
947
|
+
// stop orders
|
|
948
|
+
// {
|
|
949
|
+
// "success": true,
|
|
950
|
+
// "data": {
|
|
951
|
+
// "rows": [
|
|
952
|
+
// {
|
|
953
|
+
// "orderId": "1578938",
|
|
954
|
+
// "clientOrderId": "0",
|
|
955
|
+
// "algoType": "STOP_LOSS",
|
|
956
|
+
// "quantity": "0.1"
|
|
957
|
+
// }
|
|
958
|
+
// ]
|
|
959
|
+
// },
|
|
960
|
+
// "timestamp": "1686149372216"
|
|
961
|
+
// }
|
|
962
|
+
const data = this.safeValue(response, 'data');
|
|
963
|
+
if (data !== undefined) {
|
|
964
|
+
const rows = this.safeValue(data, 'rows', []);
|
|
965
|
+
return this.parseOrder(rows[0], market);
|
|
966
|
+
}
|
|
967
|
+
const order = this.parseOrder(response, market);
|
|
968
|
+
order['type'] = type;
|
|
969
|
+
return order;
|
|
970
|
+
}
|
|
971
|
+
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
972
|
+
/**
|
|
973
|
+
* @method
|
|
974
|
+
* @name woo#editOrder
|
|
975
|
+
* @description edit a trade order
|
|
976
|
+
* @see https://docs.woo.org/#edit-order
|
|
977
|
+
* @see https://docs.woo.org/#edit-order-by-client_order_id
|
|
978
|
+
* @see https://docs.woo.org/#edit-algo-order
|
|
979
|
+
* @see https://docs.woo.org/#edit-algo-order-by-client_order_id
|
|
980
|
+
* @param {string} id order id
|
|
981
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
982
|
+
* @param {string} type 'market' or 'limit'
|
|
983
|
+
* @param {string} side 'buy' or 'sell'
|
|
984
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
985
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
986
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
987
|
+
* @param {float} [params.triggerPrice] The price a trigger order is triggered at
|
|
988
|
+
* @param {float} [params.stopLossPrice] price to trigger stop-loss orders
|
|
989
|
+
* @param {float} [params.takeProfitPrice] price to trigger take-profit orders
|
|
990
|
+
* @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
|
|
991
|
+
* @param {string} [params.trailingPercent] the percent to trail away from the current market price
|
|
992
|
+
* @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
|
|
993
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
994
|
+
*/
|
|
995
|
+
await this.loadMarkets();
|
|
996
|
+
const market = this.market(symbol);
|
|
997
|
+
const request = {
|
|
998
|
+
// 'quantity': this.amountToPrecision (symbol, amount),
|
|
999
|
+
// 'price': this.priceToPrecision (symbol, price),
|
|
1000
|
+
};
|
|
1001
|
+
if (price !== undefined) {
|
|
1002
|
+
request['price'] = this.priceToPrecision(symbol, price);
|
|
1003
|
+
}
|
|
1004
|
+
if (amount !== undefined) {
|
|
1005
|
+
request['quantity'] = this.amountToPrecision(symbol, amount);
|
|
1006
|
+
}
|
|
1007
|
+
const clientOrderIdUnified = this.safeString2(params, 'clOrdID', 'clientOrderId');
|
|
1008
|
+
const clientOrderIdExchangeSpecific = this.safeString(params, 'client_order_id', clientOrderIdUnified);
|
|
1009
|
+
const isByClientOrder = clientOrderIdExchangeSpecific !== undefined;
|
|
1010
|
+
const stopPrice = this.safeNumberN(params, ['triggerPrice', 'stopPrice', 'takeProfitPrice', 'stopLossPrice']);
|
|
1011
|
+
if (stopPrice !== undefined) {
|
|
1012
|
+
request['triggerPrice'] = this.priceToPrecision(symbol, stopPrice);
|
|
1013
|
+
}
|
|
1014
|
+
const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activatedPrice', price);
|
|
1015
|
+
const trailingAmount = this.safeString2(params, 'trailingAmount', 'callbackValue');
|
|
1016
|
+
const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
|
|
1017
|
+
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
1018
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
1019
|
+
const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
|
|
1020
|
+
if (isTrailing) {
|
|
1021
|
+
if (trailingTriggerPrice !== undefined) {
|
|
1022
|
+
request['activatedPrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
|
|
1023
|
+
}
|
|
1024
|
+
if (isTrailingAmountOrder) {
|
|
1025
|
+
request['callbackValue'] = trailingAmount;
|
|
1026
|
+
}
|
|
1027
|
+
else if (isTrailingPercentOrder) {
|
|
1028
|
+
const convertedTrailingPercent = Precise["default"].stringDiv(trailingPercent, '100');
|
|
1029
|
+
request['callbackRate'] = convertedTrailingPercent;
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'stopPrice', 'triggerPrice', 'takeProfitPrice', 'stopLossPrice', 'trailingTriggerPrice', 'trailingAmount', 'trailingPercent']);
|
|
1033
|
+
const isStop = isTrailing || (stopPrice !== undefined) || (this.safeValue(params, 'childOrders') !== undefined);
|
|
1034
|
+
let response = undefined;
|
|
1035
|
+
if (isByClientOrder) {
|
|
1036
|
+
request['client_order_id'] = clientOrderIdExchangeSpecific;
|
|
1037
|
+
if (isStop) {
|
|
1038
|
+
response = await this.v3PrivatePutAlgoOrderClientClientOrderId(this.extend(request, params));
|
|
1039
|
+
}
|
|
1040
|
+
else {
|
|
1041
|
+
response = await this.v3PrivatePutOrderClientClientOrderId(this.extend(request, params));
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
else {
|
|
1045
|
+
request['oid'] = id;
|
|
1046
|
+
if (isStop) {
|
|
1047
|
+
response = await this.v3PrivatePutAlgoOrderOid(this.extend(request, params));
|
|
1048
|
+
}
|
|
1049
|
+
else {
|
|
1050
|
+
response = await this.v3PrivatePutOrderOid(this.extend(request, params));
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
//
|
|
1054
|
+
// {
|
|
1055
|
+
// "code": 0,
|
|
1056
|
+
// "data": {
|
|
1057
|
+
// "status": "string",
|
|
1058
|
+
// "success": true
|
|
1059
|
+
// },
|
|
1060
|
+
// "message": "string",
|
|
1061
|
+
// "success": true,
|
|
1062
|
+
// "timestamp": 0
|
|
1063
|
+
// }
|
|
1064
|
+
//
|
|
1065
|
+
const data = this.safeValue(response, 'data', {});
|
|
1066
|
+
return this.parseOrder(data, market);
|
|
1067
|
+
}
|
|
1068
|
+
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
1069
|
+
/**
|
|
1070
|
+
* @method
|
|
1071
|
+
* @name woo#cancelOrder
|
|
1072
|
+
* @see https://docs.woo.org/#cancel-algo-order
|
|
1073
|
+
* @see https://docs.woo.org/#cancel-order
|
|
1074
|
+
* @see https://docs.woo.org/#cancel-order-by-client_order_id
|
|
1075
|
+
* @description cancels an open order
|
|
1076
|
+
* @param {string} id order id
|
|
1077
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
1078
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1079
|
+
* @param {boolean} [params.stop] whether the order is a stop/algo order
|
|
1080
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1081
|
+
*/
|
|
1082
|
+
const stop = this.safeValue(params, 'stop', false);
|
|
1083
|
+
params = this.omit(params, 'stop');
|
|
1084
|
+
if (!stop && (symbol === undefined)) {
|
|
1085
|
+
throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
|
|
1086
|
+
}
|
|
1087
|
+
await this.loadMarkets();
|
|
1088
|
+
let market = undefined;
|
|
1089
|
+
if (symbol !== undefined) {
|
|
1090
|
+
market = this.market(symbol);
|
|
1091
|
+
}
|
|
1092
|
+
const request = {};
|
|
1093
|
+
const clientOrderIdUnified = this.safeString2(params, 'clOrdID', 'clientOrderId');
|
|
1094
|
+
const clientOrderIdExchangeSpecific = this.safeString(params, 'client_order_id', clientOrderIdUnified);
|
|
1095
|
+
const isByClientOrder = clientOrderIdExchangeSpecific !== undefined;
|
|
1096
|
+
let response = undefined;
|
|
1097
|
+
if (stop) {
|
|
1098
|
+
request['order_id'] = id;
|
|
1099
|
+
response = await this.v3PrivateDeleteAlgoOrderOrderId(this.extend(request, params));
|
|
1100
|
+
}
|
|
1101
|
+
else {
|
|
1102
|
+
request['symbol'] = market['id'];
|
|
1103
|
+
if (isByClientOrder) {
|
|
1104
|
+
request['client_order_id'] = clientOrderIdExchangeSpecific;
|
|
1105
|
+
params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id']);
|
|
1106
|
+
response = await this.v1PrivateDeleteClientOrder(this.extend(request, params));
|
|
1107
|
+
}
|
|
1108
|
+
else {
|
|
1109
|
+
request['order_id'] = id;
|
|
1110
|
+
response = await this.v1PrivateDeleteOrder(this.extend(request, params));
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
//
|
|
1114
|
+
// { success: true, status: "CANCEL_SENT" }
|
|
1115
|
+
//
|
|
1116
|
+
const extendParams = { 'symbol': symbol };
|
|
1117
|
+
if (isByClientOrder) {
|
|
1118
|
+
extendParams['client_order_id'] = clientOrderIdExchangeSpecific;
|
|
1119
|
+
}
|
|
1120
|
+
else {
|
|
1121
|
+
extendParams['id'] = id;
|
|
1122
|
+
}
|
|
1123
|
+
return this.extend(this.parseOrder(response), extendParams);
|
|
1124
|
+
}
|
|
1125
|
+
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
1126
|
+
/**
|
|
1127
|
+
* @method
|
|
1128
|
+
* @name woo#cancelAllOrders
|
|
1129
|
+
* @see https://docs.woo.org/#cancel-all-pending-orders
|
|
1130
|
+
* @see https://docs.woo.org/#cancel-orders
|
|
1131
|
+
* @see https://docs.woo.org/#cancel-all-pending-algo-orders
|
|
1132
|
+
* @description cancel all open orders in a market
|
|
1133
|
+
* @param {string} symbol unified market symbol
|
|
1134
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1135
|
+
* @param {boolean} [params.stop] whether the order is a stop/algo order
|
|
1136
|
+
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1137
|
+
*/
|
|
1138
|
+
await this.loadMarkets();
|
|
1139
|
+
const stop = this.safeValue(params, 'stop');
|
|
1140
|
+
params = this.omit(params, 'stop');
|
|
1141
|
+
if (stop) {
|
|
1142
|
+
return await this.v3PrivateDeleteAlgoOrdersPending(params);
|
|
1143
|
+
}
|
|
1144
|
+
if (symbol === undefined) {
|
|
1145
|
+
throw new errors.ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument');
|
|
1146
|
+
}
|
|
1147
|
+
const market = this.market(symbol);
|
|
1148
|
+
const request = {
|
|
1149
|
+
'symbol': market['id'],
|
|
1150
|
+
};
|
|
1151
|
+
const response = await this.v1PrivateDeleteOrders(this.extend(request, params));
|
|
1152
|
+
//
|
|
1153
|
+
// {
|
|
1154
|
+
// "success":true,
|
|
1155
|
+
// "status":"CANCEL_ALL_SENT"
|
|
1156
|
+
// }
|
|
1157
|
+
//
|
|
1158
|
+
return response;
|
|
1159
|
+
}
|
|
1160
|
+
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
1161
|
+
/**
|
|
1162
|
+
* @method
|
|
1163
|
+
* @name woo#fetchOrder
|
|
1164
|
+
* @see https://docs.woo.org/#get-algo-order
|
|
1165
|
+
* @see https://docs.woo.org/#get-order
|
|
1166
|
+
* @description fetches information on an order made by the user
|
|
1167
|
+
* @param {string} symbol unified symbol of the market the order was made in
|
|
1168
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1169
|
+
* @param {boolean} [params.stop] whether the order is a stop/algo order
|
|
1170
|
+
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1171
|
+
*/
|
|
1172
|
+
await this.loadMarkets();
|
|
1173
|
+
const market = (symbol !== undefined) ? this.market(symbol) : undefined;
|
|
1174
|
+
const stop = this.safeValue(params, 'stop');
|
|
1175
|
+
params = this.omit(params, 'stop');
|
|
1176
|
+
const request = {};
|
|
1177
|
+
const clientOrderId = this.safeString2(params, 'clOrdID', 'clientOrderId');
|
|
1178
|
+
let response = undefined;
|
|
1179
|
+
if (stop) {
|
|
1180
|
+
request['oid'] = id;
|
|
1181
|
+
response = await this.v3PrivateGetAlgoOrderOid(this.extend(request, params));
|
|
1182
|
+
}
|
|
1183
|
+
else if (clientOrderId) {
|
|
1184
|
+
request['client_order_id'] = clientOrderId;
|
|
1185
|
+
response = await this.v1PrivateGetClientOrderClientOrderId(this.extend(request, params));
|
|
1186
|
+
}
|
|
1187
|
+
else {
|
|
1188
|
+
request['oid'] = id;
|
|
1189
|
+
response = await this.v1PrivateGetOrderOid(this.extend(request, params));
|
|
1190
|
+
}
|
|
1191
|
+
//
|
|
1192
|
+
// {
|
|
1193
|
+
// "success": true,
|
|
1194
|
+
// "symbol": "SPOT_WOO_USDT",
|
|
1195
|
+
// "status": "FILLED", // FILLED, NEW
|
|
1196
|
+
// "side": "BUY",
|
|
1197
|
+
// "created_time": "1641480933.000",
|
|
1198
|
+
// "order_id": "87541111",
|
|
1199
|
+
// "order_tag": "default",
|
|
1200
|
+
// "price": "1",
|
|
1201
|
+
// "type": "LIMIT",
|
|
1202
|
+
// "quantity": "12",
|
|
1203
|
+
// "amount": null,
|
|
1204
|
+
// "visible": "12",
|
|
1205
|
+
// "executed": "12", // or any partial amount
|
|
1206
|
+
// "total_fee": "0.0024",
|
|
1207
|
+
// "fee_asset": "WOO",
|
|
1208
|
+
// "client_order_id": null,
|
|
1209
|
+
// "average_executed_price": "1",
|
|
1210
|
+
// "Transactions": [
|
|
1211
|
+
// {
|
|
1212
|
+
// "id": "99111647",
|
|
1213
|
+
// "symbol": "SPOT_WOO_USDT",
|
|
1214
|
+
// "fee": "0.0024",
|
|
1215
|
+
// "side": "BUY",
|
|
1216
|
+
// "executed_timestamp": "1641482113.084",
|
|
1217
|
+
// "order_id": "87541111",
|
|
1218
|
+
// "executed_price": "1",
|
|
1219
|
+
// "executed_quantity": "12",
|
|
1220
|
+
// "fee_asset": "WOO",
|
|
1221
|
+
// "is_maker": "1"
|
|
1222
|
+
// }
|
|
1223
|
+
// ]
|
|
1224
|
+
// }
|
|
1225
|
+
//
|
|
1226
|
+
const orders = this.safeValue(response, 'data', response);
|
|
1227
|
+
return this.parseOrder(orders, market);
|
|
1228
|
+
}
|
|
1229
|
+
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1230
|
+
/**
|
|
1231
|
+
* @method
|
|
1232
|
+
* @name woo#fetchOrders
|
|
1233
|
+
* @description fetches information on multiple orders made by the user
|
|
1234
|
+
* @see https://docs.woo.org/#get-orders
|
|
1235
|
+
* @see https://docs.woo.org/#get-algo-orders
|
|
1236
|
+
* @param {string} symbol unified market symbol of the market orders were made in
|
|
1237
|
+
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
1238
|
+
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
1239
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1240
|
+
* @param {boolean} [params.stop] whether the order is a stop/algo order
|
|
1241
|
+
* @param {boolean} [params.isTriggered] whether the order has been triggered (false by default)
|
|
1242
|
+
* @param {string} [params.side] 'buy' or 'sell'
|
|
1243
|
+
* @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
|
|
1244
|
+
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1245
|
+
*/
|
|
1246
|
+
await this.loadMarkets();
|
|
1247
|
+
const request = {};
|
|
1248
|
+
let market = undefined;
|
|
1249
|
+
const stop = this.safeValue(params, 'stop');
|
|
1250
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
1251
|
+
params = this.omit(params, ['stop', 'trailing']);
|
|
1252
|
+
if (symbol !== undefined) {
|
|
1253
|
+
market = this.market(symbol);
|
|
1254
|
+
request['symbol'] = market['id'];
|
|
1255
|
+
}
|
|
1256
|
+
if (since !== undefined) {
|
|
1257
|
+
if (stop || trailing) {
|
|
1258
|
+
request['createdTimeStart'] = since;
|
|
1259
|
+
}
|
|
1260
|
+
else {
|
|
1261
|
+
request['start_t'] = since;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
if (stop) {
|
|
1265
|
+
request['algoType'] = 'stop';
|
|
1266
|
+
}
|
|
1267
|
+
else if (trailing) {
|
|
1268
|
+
request['algoType'] = 'TRAILING_STOP';
|
|
1269
|
+
}
|
|
1270
|
+
let response = undefined;
|
|
1271
|
+
if (stop || trailing) {
|
|
1272
|
+
response = await this.v3PrivateGetAlgoOrders(this.extend(request, params));
|
|
1273
|
+
}
|
|
1274
|
+
else {
|
|
1275
|
+
response = await this.v1PrivateGetOrders(this.extend(request, params));
|
|
1276
|
+
}
|
|
1277
|
+
//
|
|
1278
|
+
// {
|
|
1279
|
+
// "success":true,
|
|
1280
|
+
// "meta":{
|
|
1281
|
+
// "total":1,
|
|
1282
|
+
// "records_per_page":100,
|
|
1283
|
+
// "current_page":1
|
|
1284
|
+
// },
|
|
1285
|
+
// "rows":[
|
|
1286
|
+
// {
|
|
1287
|
+
// "symbol":"PERP_BTC_USDT",
|
|
1288
|
+
// "status":"FILLED",
|
|
1289
|
+
// "side":"SELL",
|
|
1290
|
+
// "created_time":"1611617776.000",
|
|
1291
|
+
// "updated_time":"1611617776.000",
|
|
1292
|
+
// "order_id":52121167,
|
|
1293
|
+
// "order_tag":"default",
|
|
1294
|
+
// "price":null,
|
|
1295
|
+
// "type":"MARKET",
|
|
1296
|
+
// "quantity":0.002,
|
|
1297
|
+
// "amount":null,
|
|
1298
|
+
// "visible":0,
|
|
1299
|
+
// "executed":0.002,
|
|
1300
|
+
// "total_fee":0.01732885,
|
|
1301
|
+
// "fee_asset":"USDT",
|
|
1302
|
+
// "client_order_id":null,
|
|
1303
|
+
// "average_executed_price":28881.41
|
|
1304
|
+
// }
|
|
1305
|
+
// ]
|
|
1306
|
+
// }
|
|
1307
|
+
//
|
|
1308
|
+
const data = this.safeValue(response, 'data', response);
|
|
1309
|
+
const orders = this.safeValue(data, 'rows');
|
|
1310
|
+
return this.parseOrders(orders, market, since, limit, params);
|
|
1311
|
+
}
|
|
1312
|
+
parseTimeInForce(timeInForce) {
|
|
1313
|
+
const timeInForces = {
|
|
1314
|
+
'ioc': 'IOC',
|
|
1315
|
+
'fok': 'FOK',
|
|
1316
|
+
'post_only': 'PO',
|
|
1317
|
+
};
|
|
1318
|
+
return this.safeString(timeInForces, timeInForce, undefined);
|
|
1319
|
+
}
|
|
1320
|
+
parseOrder(order, market = undefined) {
|
|
1321
|
+
//
|
|
1322
|
+
// Possible input functions:
|
|
1323
|
+
// * createOrder
|
|
1324
|
+
// * cancelOrder
|
|
1325
|
+
// * fetchOrder
|
|
1326
|
+
// * fetchOrders
|
|
1327
|
+
// const isFromFetchOrder = ('order_tag' in order); TO_DO
|
|
1328
|
+
//
|
|
1329
|
+
// stop order after creating it:
|
|
1330
|
+
// {
|
|
1331
|
+
// "orderId": "1578938",
|
|
1332
|
+
// "clientOrderId": "0",
|
|
1333
|
+
// "algoType": "STOP_LOSS",
|
|
1334
|
+
// "quantity": "0.1"
|
|
1335
|
+
// }
|
|
1336
|
+
// stop order after fetching it:
|
|
1337
|
+
// {
|
|
1338
|
+
// "algoOrderId": "1578958",
|
|
1339
|
+
// "clientOrderId": "0",
|
|
1340
|
+
// "rootAlgoOrderId": "1578958",
|
|
1341
|
+
// "parentAlgoOrderId": "0",
|
|
1342
|
+
// "symbol": "SPOT_LTC_USDT",
|
|
1343
|
+
// "orderTag": "default",
|
|
1344
|
+
// "algoType": "STOP_LOSS",
|
|
1345
|
+
// "side": "BUY",
|
|
1346
|
+
// "quantity": "0.1",
|
|
1347
|
+
// "isTriggered": false,
|
|
1348
|
+
// "triggerPrice": "100",
|
|
1349
|
+
// "triggerStatus": "USELESS",
|
|
1350
|
+
// "type": "LIMIT",
|
|
1351
|
+
// "rootAlgoStatus": "CANCELLED",
|
|
1352
|
+
// "algoStatus": "CANCELLED",
|
|
1353
|
+
// "triggerPriceType": "MARKET_PRICE",
|
|
1354
|
+
// "price": "75",
|
|
1355
|
+
// "triggerTime": "0",
|
|
1356
|
+
// "totalExecutedQuantity": "0",
|
|
1357
|
+
// "averageExecutedPrice": "0",
|
|
1358
|
+
// "totalFee": "0",
|
|
1359
|
+
// "feeAsset": '',
|
|
1360
|
+
// "reduceOnly": false,
|
|
1361
|
+
// "createdTime": "1686149609.744",
|
|
1362
|
+
// "updatedTime": "1686149903.362"
|
|
1363
|
+
// }
|
|
1364
|
+
//
|
|
1365
|
+
const timestamp = this.safeTimestampN(order, ['timestamp', 'created_time', 'createdTime']);
|
|
1366
|
+
const orderId = this.safeStringN(order, ['order_id', 'orderId', 'algoOrderId']);
|
|
1367
|
+
const clientOrderId = this.omitZero(this.safeString2(order, 'client_order_id', 'clientOrderId')); // Somehow, this always returns 0 for limit order
|
|
1368
|
+
const marketId = this.safeString(order, 'symbol');
|
|
1369
|
+
market = this.safeMarket(marketId, market);
|
|
1370
|
+
const symbol = market['symbol'];
|
|
1371
|
+
const price = this.safeString2(order, 'order_price', 'price');
|
|
1372
|
+
const amount = this.safeString2(order, 'order_quantity', 'quantity'); // This is base amount
|
|
1373
|
+
const cost = this.safeString2(order, 'order_amount', 'amount'); // This is quote amount
|
|
1374
|
+
const orderType = this.safeStringLower2(order, 'order_type', 'type');
|
|
1375
|
+
const status = this.safeValue2(order, 'status', 'algoStatus');
|
|
1376
|
+
const side = this.safeStringLower(order, 'side');
|
|
1377
|
+
const filled = this.omitZero(this.safeValue2(order, 'executed', 'totalExecutedQuantity'));
|
|
1378
|
+
const average = this.omitZero(this.safeString2(order, 'average_executed_price', 'averageExecutedPrice'));
|
|
1379
|
+
const remaining = Precise["default"].stringSub(cost, filled);
|
|
1380
|
+
const fee = this.safeValue2(order, 'total_fee', 'totalFee');
|
|
1381
|
+
const feeCurrency = this.safeString2(order, 'fee_asset', 'feeAsset');
|
|
1382
|
+
const transactions = this.safeValue(order, 'Transactions');
|
|
1383
|
+
const stopPrice = this.safeNumber(order, 'triggerPrice');
|
|
1384
|
+
let takeProfitPrice = undefined;
|
|
1385
|
+
let stopLossPrice = undefined;
|
|
1386
|
+
const childOrders = this.safeValue(order, 'childOrders');
|
|
1387
|
+
if (childOrders !== undefined) {
|
|
1388
|
+
const first = this.safeValue(childOrders, 0);
|
|
1389
|
+
const innerChildOrders = this.safeValue(first, 'childOrders', []);
|
|
1390
|
+
const innerChildOrdersLength = innerChildOrders.length;
|
|
1391
|
+
if (innerChildOrdersLength > 0) {
|
|
1392
|
+
const takeProfitOrder = this.safeValue(innerChildOrders, 0);
|
|
1393
|
+
const stopLossOrder = this.safeValue(innerChildOrders, 1);
|
|
1394
|
+
takeProfitPrice = this.safeNumber(takeProfitOrder, 'triggerPrice');
|
|
1395
|
+
stopLossPrice = this.safeNumber(stopLossOrder, 'triggerPrice');
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
const lastUpdateTimestamp = this.safeTimestamp2(order, 'updatedTime', 'updated_time');
|
|
1399
|
+
return this.safeOrder({
|
|
1400
|
+
'id': orderId,
|
|
1401
|
+
'clientOrderId': clientOrderId,
|
|
1402
|
+
'timestamp': timestamp,
|
|
1403
|
+
'datetime': this.iso8601(timestamp),
|
|
1404
|
+
'lastTradeTimestamp': undefined,
|
|
1405
|
+
'lastUpdateTimestamp': lastUpdateTimestamp,
|
|
1406
|
+
'status': this.parseOrderStatus(status),
|
|
1407
|
+
'symbol': symbol,
|
|
1408
|
+
'type': orderType,
|
|
1409
|
+
'timeInForce': this.parseTimeInForce(orderType),
|
|
1410
|
+
'postOnly': undefined,
|
|
1411
|
+
'reduceOnly': this.safeValue(order, 'reduce_only'),
|
|
1412
|
+
'side': side,
|
|
1413
|
+
'price': price,
|
|
1414
|
+
'stopPrice': stopPrice,
|
|
1415
|
+
'triggerPrice': stopPrice,
|
|
1416
|
+
'takeProfitPrice': takeProfitPrice,
|
|
1417
|
+
'stopLossPrice': stopLossPrice,
|
|
1418
|
+
'average': average,
|
|
1419
|
+
'amount': amount,
|
|
1420
|
+
'filled': filled,
|
|
1421
|
+
'remaining': remaining,
|
|
1422
|
+
'cost': cost,
|
|
1423
|
+
'trades': transactions,
|
|
1424
|
+
'fee': {
|
|
1425
|
+
'cost': fee,
|
|
1426
|
+
'currency': feeCurrency,
|
|
1427
|
+
},
|
|
1428
|
+
'info': order,
|
|
1429
|
+
}, market);
|
|
1430
|
+
}
|
|
1431
|
+
parseOrderStatus(status) {
|
|
1432
|
+
if (status !== undefined) {
|
|
1433
|
+
const statuses = {
|
|
1434
|
+
'NEW': 'open',
|
|
1435
|
+
'FILLED': 'closed',
|
|
1436
|
+
'CANCEL_SENT': 'canceled',
|
|
1437
|
+
'CANCEL_ALL_SENT': 'canceled',
|
|
1438
|
+
'CANCELLED': 'canceled',
|
|
1439
|
+
'PARTIAL_FILLED': 'open',
|
|
1440
|
+
'REJECTED': 'rejected',
|
|
1441
|
+
'INCOMPLETE': 'open',
|
|
1442
|
+
'COMPLETED': 'closed',
|
|
1443
|
+
};
|
|
1444
|
+
return this.safeString(statuses, status, status);
|
|
1445
|
+
}
|
|
1446
|
+
return status;
|
|
1447
|
+
}
|
|
1448
|
+
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
1449
|
+
/**
|
|
1450
|
+
* @method
|
|
1451
|
+
* @name woo#fetchOrderBook
|
|
1452
|
+
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
1453
|
+
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
1454
|
+
* @param {int} [limit] the maximum amount of order book entries to return
|
|
1455
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1456
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
1457
|
+
*/
|
|
1458
|
+
await this.loadMarkets();
|
|
1459
|
+
const market = this.market(symbol);
|
|
1460
|
+
const request = {
|
|
1461
|
+
'symbol': market['id'],
|
|
1462
|
+
};
|
|
1463
|
+
if (limit !== undefined) {
|
|
1464
|
+
limit = Math.min(limit, 1000);
|
|
1465
|
+
request['max_level'] = limit;
|
|
1466
|
+
}
|
|
1467
|
+
const response = await this.v1PublicGetOrderbookSymbol(this.extend(request, params));
|
|
1468
|
+
//
|
|
1469
|
+
// {
|
|
1470
|
+
// "success": true,
|
|
1471
|
+
// "timestamp": "1641562961192",
|
|
1472
|
+
// "asks": [
|
|
1473
|
+
// { price: '0.921', quantity: "76.01" },
|
|
1474
|
+
// { price: '0.933', quantity: "477.10" },
|
|
1475
|
+
// ...
|
|
1476
|
+
// ],
|
|
1477
|
+
// "bids": [
|
|
1478
|
+
// { price: '0.940', quantity: "13502.47" },
|
|
1479
|
+
// { price: '0.932', quantity: "43.91" },
|
|
1480
|
+
// ...
|
|
1481
|
+
// ]
|
|
1482
|
+
// }
|
|
1483
|
+
//
|
|
1484
|
+
const timestamp = this.safeInteger(response, 'timestamp');
|
|
1485
|
+
return this.parseOrderBook(response, symbol, timestamp, 'bids', 'asks', 'price', 'quantity');
|
|
1486
|
+
}
|
|
1487
|
+
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
1488
|
+
/**
|
|
1489
|
+
* @method
|
|
1490
|
+
* @name woo#fetchOHLCV
|
|
1491
|
+
* @see https://docs.woo.org/#kline-public
|
|
1492
|
+
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
1493
|
+
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
1494
|
+
* @param {string} timeframe the length of time each candle represents
|
|
1495
|
+
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
1496
|
+
* @param {int} [limit] the maximum amount of candles to fetch
|
|
1497
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1498
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
1499
|
+
*/
|
|
1500
|
+
await this.loadMarkets();
|
|
1501
|
+
const market = this.market(symbol);
|
|
1502
|
+
const request = {
|
|
1503
|
+
'symbol': market['id'],
|
|
1504
|
+
'type': this.safeString(this.timeframes, timeframe, timeframe),
|
|
1505
|
+
};
|
|
1506
|
+
if (limit !== undefined) {
|
|
1507
|
+
request['limit'] = Math.min(limit, 1000);
|
|
1508
|
+
}
|
|
1509
|
+
const response = await this.v1PublicGetKline(this.extend(request, params));
|
|
1510
|
+
// {
|
|
1511
|
+
// "success": true,
|
|
1512
|
+
// "rows": [
|
|
1513
|
+
// {
|
|
1514
|
+
// "open": "0.94238",
|
|
1515
|
+
// "close": "0.94271",
|
|
1516
|
+
// "low": "0.94238",
|
|
1517
|
+
// "high": "0.94296",
|
|
1518
|
+
// "volume": "73.55",
|
|
1519
|
+
// "amount": "69.32040520",
|
|
1520
|
+
// "symbol": "SPOT_WOO_USDT",
|
|
1521
|
+
// "type": "1m",
|
|
1522
|
+
// "start_timestamp": "1641584700000",
|
|
1523
|
+
// "end_timestamp": "1641584760000"
|
|
1524
|
+
// },
|
|
1525
|
+
// {
|
|
1526
|
+
// "open": "0.94186",
|
|
1527
|
+
// "close": "0.94186",
|
|
1528
|
+
// "low": "0.94186",
|
|
1529
|
+
// "high": "0.94186",
|
|
1530
|
+
// "volume": "64.00",
|
|
1531
|
+
// "amount": "60.27904000",
|
|
1532
|
+
// "symbol": "SPOT_WOO_USDT",
|
|
1533
|
+
// "type": "1m",
|
|
1534
|
+
// "start_timestamp": "1641584640000",
|
|
1535
|
+
// "end_timestamp": "1641584700000"
|
|
1536
|
+
// },
|
|
1537
|
+
// ...
|
|
1538
|
+
// ]
|
|
1539
|
+
// }
|
|
1540
|
+
const data = this.safeValue(response, 'rows', []);
|
|
1541
|
+
return this.parseOHLCVs(data, market, timeframe, since, limit);
|
|
1542
|
+
}
|
|
1543
|
+
parseOHLCV(ohlcv, market = undefined) {
|
|
1544
|
+
// example response in fetchOHLCV
|
|
1545
|
+
return [
|
|
1546
|
+
this.safeInteger(ohlcv, 'start_timestamp'),
|
|
1547
|
+
this.safeNumber(ohlcv, 'open'),
|
|
1548
|
+
this.safeNumber(ohlcv, 'high'),
|
|
1549
|
+
this.safeNumber(ohlcv, 'low'),
|
|
1550
|
+
this.safeNumber(ohlcv, 'close'),
|
|
1551
|
+
this.safeNumber(ohlcv, 'volume'),
|
|
1552
|
+
];
|
|
1553
|
+
}
|
|
1554
|
+
async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1555
|
+
/**
|
|
1556
|
+
* @method
|
|
1557
|
+
* @name woo#fetchOrderTrades
|
|
1558
|
+
* @description fetch all the trades made from a single order
|
|
1559
|
+
* @param {string} id order id
|
|
1560
|
+
* @param {string} symbol unified market symbol
|
|
1561
|
+
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
1562
|
+
* @param {int} [limit] the maximum number of trades to retrieve
|
|
1563
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1564
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
1565
|
+
*/
|
|
1566
|
+
await this.loadMarkets();
|
|
1567
|
+
let market = undefined;
|
|
1568
|
+
if (symbol !== undefined) {
|
|
1569
|
+
market = this.market(symbol);
|
|
1570
|
+
}
|
|
1571
|
+
const request = {
|
|
1572
|
+
'oid': id,
|
|
1573
|
+
};
|
|
1574
|
+
const response = await this.v1PrivateGetOrderOidTrades(this.extend(request, params));
|
|
1575
|
+
// {
|
|
1576
|
+
// "success": true,
|
|
1577
|
+
// "rows": [
|
|
1578
|
+
// {
|
|
1579
|
+
// "id": "99111647",
|
|
1580
|
+
// "symbol": "SPOT_WOO_USDT",
|
|
1581
|
+
// "fee": "0.0024",
|
|
1582
|
+
// "side": "BUY",
|
|
1583
|
+
// "executed_timestamp": "1641482113.084",
|
|
1584
|
+
// "order_id": "87541111",
|
|
1585
|
+
// "order_tag": "default",
|
|
1586
|
+
// "executed_price": "1",
|
|
1587
|
+
// "executed_quantity": "12",
|
|
1588
|
+
// "fee_asset": "WOO",
|
|
1589
|
+
// "is_maker": "1"
|
|
1590
|
+
// }
|
|
1591
|
+
// ]
|
|
1592
|
+
// }
|
|
1593
|
+
const trades = this.safeValue(response, 'rows', []);
|
|
1594
|
+
return this.parseTrades(trades, market, since, limit, params);
|
|
1595
|
+
}
|
|
1596
|
+
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1597
|
+
/**
|
|
1598
|
+
* @method
|
|
1599
|
+
* @name woo#fetchMyTrades
|
|
1600
|
+
* @description fetch all trades made by the user
|
|
1601
|
+
* @param {string} symbol unified market symbol
|
|
1602
|
+
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
1603
|
+
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
1604
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1605
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
1606
|
+
*/
|
|
1607
|
+
await this.loadMarkets();
|
|
1608
|
+
const request = {};
|
|
1609
|
+
let market = undefined;
|
|
1610
|
+
if (symbol !== undefined) {
|
|
1611
|
+
market = this.market(symbol);
|
|
1612
|
+
request['symbol'] = market['id'];
|
|
1613
|
+
}
|
|
1614
|
+
if (since !== undefined) {
|
|
1615
|
+
request['start_t'] = since;
|
|
1616
|
+
}
|
|
1617
|
+
const response = await this.v1PrivateGetClientTrades(this.extend(request, params));
|
|
1618
|
+
// {
|
|
1619
|
+
// "success": true,
|
|
1620
|
+
// "meta": {
|
|
1621
|
+
// "records_per_page": 25,
|
|
1622
|
+
// "current_page": 1
|
|
1623
|
+
// },
|
|
1624
|
+
// "rows": [
|
|
1625
|
+
// {
|
|
1626
|
+
// "id": 5,
|
|
1627
|
+
// "symbol": "SPOT_BTC_USDT",
|
|
1628
|
+
// "order_id": 211,
|
|
1629
|
+
// "order_tag": "default",
|
|
1630
|
+
// "executed_price": 10892.84,
|
|
1631
|
+
// "executed_quantity": 0.002,
|
|
1632
|
+
// "is_maker": 0,
|
|
1633
|
+
// "side": "SELL",
|
|
1634
|
+
// "fee": 0,
|
|
1635
|
+
// "fee_asset": "USDT",
|
|
1636
|
+
// "executed_timestamp": "1566264290.250"
|
|
1637
|
+
// },
|
|
1638
|
+
// ...
|
|
1639
|
+
// ]
|
|
1640
|
+
// }
|
|
1641
|
+
const trades = this.safeValue(response, 'rows', []);
|
|
1642
|
+
return this.parseTrades(trades, market, since, limit, params);
|
|
1643
|
+
}
|
|
1644
|
+
async fetchAccounts(params = {}) {
|
|
1645
|
+
/**
|
|
1646
|
+
* @method
|
|
1647
|
+
* @name woo#fetchAccounts
|
|
1648
|
+
* @description fetch all the accounts associated with a profile
|
|
1649
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1650
|
+
* @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
|
|
1651
|
+
*/
|
|
1652
|
+
const response = await this.v1PrivateGetSubAccountAssets(params);
|
|
1653
|
+
//
|
|
1654
|
+
// {
|
|
1655
|
+
// "rows": [{
|
|
1656
|
+
// "application_id": "13e4fc34-e2ff-4cb7-b1e4-4c22fee7d365",
|
|
1657
|
+
// "account": "Main",
|
|
1658
|
+
// "usdt_balance": "4.0"
|
|
1659
|
+
// },
|
|
1660
|
+
// {
|
|
1661
|
+
// "application_id": "432952aa-a401-4e26-aff6-972920aebba3",
|
|
1662
|
+
// "account": "subaccount",
|
|
1663
|
+
// "usdt_balance": "1.0"
|
|
1664
|
+
// }
|
|
1665
|
+
// ],
|
|
1666
|
+
// "success": true
|
|
1667
|
+
// }
|
|
1668
|
+
//
|
|
1669
|
+
const rows = this.safeValue(response, 'rows', []);
|
|
1670
|
+
return this.parseAccounts(rows, params);
|
|
1671
|
+
}
|
|
1672
|
+
parseAccount(account) {
|
|
1673
|
+
//
|
|
1674
|
+
// {
|
|
1675
|
+
// "application_id": "336952aa-a401-4e26-aff6-972920aebba3",
|
|
1676
|
+
// "account": "subaccount",
|
|
1677
|
+
// "usdt_balance": "1.0",
|
|
1678
|
+
// }
|
|
1679
|
+
//
|
|
1680
|
+
const accountId = this.safeString(account, 'account');
|
|
1681
|
+
return {
|
|
1682
|
+
'info': account,
|
|
1683
|
+
'id': this.safeString(account, 'application_id'),
|
|
1684
|
+
'name': accountId,
|
|
1685
|
+
'code': undefined,
|
|
1686
|
+
'type': accountId === 'Main' ? 'main' : 'subaccount',
|
|
1687
|
+
};
|
|
1688
|
+
}
|
|
1689
|
+
async fetchBalance(params = {}) {
|
|
1690
|
+
/**
|
|
1691
|
+
* @method
|
|
1692
|
+
* @name woo#fetchBalance
|
|
1693
|
+
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
1694
|
+
* @see https://docs.woo.org/#get-current-holding-get-balance-new
|
|
1695
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1696
|
+
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
1697
|
+
*/
|
|
1698
|
+
await this.loadMarkets();
|
|
1699
|
+
const response = await this.v3PrivateGetBalances(params);
|
|
1700
|
+
//
|
|
1701
|
+
// {
|
|
1702
|
+
// "success": true,
|
|
1703
|
+
// "data": {
|
|
1704
|
+
// "holding": [
|
|
1705
|
+
// {
|
|
1706
|
+
// "token": "0_token",
|
|
1707
|
+
// "holding": 1,
|
|
1708
|
+
// "frozen": 0,
|
|
1709
|
+
// "staked": 0,
|
|
1710
|
+
// "unbonding": 0,
|
|
1711
|
+
// "vault": 0,
|
|
1712
|
+
// "interest": 0,
|
|
1713
|
+
// "pendingShortQty": 0,
|
|
1714
|
+
// "pendingLongQty": 0,
|
|
1715
|
+
// "availableBalance": 0,
|
|
1716
|
+
// "updatedTime": 312321.121
|
|
1717
|
+
// }
|
|
1718
|
+
// ]
|
|
1719
|
+
// },
|
|
1720
|
+
// "timestamp": 1673323746259
|
|
1721
|
+
// }
|
|
1722
|
+
//
|
|
1723
|
+
const data = this.safeValue(response, 'data');
|
|
1724
|
+
return this.parseBalance(data);
|
|
1725
|
+
}
|
|
1726
|
+
parseBalance(response) {
|
|
1727
|
+
const result = {
|
|
1728
|
+
'info': response,
|
|
1729
|
+
};
|
|
1730
|
+
const balances = this.safeValue(response, 'holding', []);
|
|
1731
|
+
for (let i = 0; i < balances.length; i++) {
|
|
1732
|
+
const balance = balances[i];
|
|
1733
|
+
const code = this.safeCurrencyCode(this.safeString(balance, 'token'));
|
|
1734
|
+
const account = this.account();
|
|
1735
|
+
account['total'] = this.safeString(balance, 'holding');
|
|
1736
|
+
account['free'] = this.safeString(balance, 'availableBalance');
|
|
1737
|
+
result[code] = account;
|
|
1738
|
+
}
|
|
1739
|
+
return this.safeBalance(result);
|
|
1740
|
+
}
|
|
1741
|
+
async fetchDepositAddress(code, params = {}) {
|
|
1742
|
+
/**
|
|
1743
|
+
* @method
|
|
1744
|
+
* @name woo#fetchDepositAddress
|
|
1745
|
+
* @description fetch the deposit address for a currency associated with this account
|
|
1746
|
+
* @param {string} code unified currency code
|
|
1747
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1748
|
+
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
1749
|
+
*/
|
|
1750
|
+
// this method is TODO because of networks unification
|
|
1751
|
+
await this.loadMarkets();
|
|
1752
|
+
const currency = this.currency(code);
|
|
1753
|
+
const networkCodeDefault = this.defaultNetworkCodeForCurrency(code);
|
|
1754
|
+
const networkCode = this.safeString(params, 'network', networkCodeDefault);
|
|
1755
|
+
params = this.omit(params, 'network');
|
|
1756
|
+
const codeForExchange = networkCode + '_' + currency['code'];
|
|
1757
|
+
const request = {
|
|
1758
|
+
'token': codeForExchange,
|
|
1759
|
+
};
|
|
1760
|
+
const response = await this.v1PrivateGetAssetDeposit(this.extend(request, params));
|
|
1761
|
+
// {
|
|
1762
|
+
// "success": true,
|
|
1763
|
+
// "address": "3Jmtjx5544T4smrit9Eroe4PCrRkpDeKjP",
|
|
1764
|
+
// "extra": ''
|
|
1765
|
+
// }
|
|
1766
|
+
const tag = this.safeString(response, 'extra');
|
|
1767
|
+
const address = this.safeString(response, 'address');
|
|
1768
|
+
this.checkAddress(address);
|
|
1769
|
+
return {
|
|
1770
|
+
'currency': code,
|
|
1771
|
+
'address': address,
|
|
1772
|
+
'tag': tag,
|
|
1773
|
+
'network': networkCode,
|
|
1774
|
+
'info': response,
|
|
1775
|
+
};
|
|
1776
|
+
}
|
|
1777
|
+
async getAssetHistoryRows(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1778
|
+
await this.loadMarkets();
|
|
1779
|
+
const request = {};
|
|
1780
|
+
let currency = undefined;
|
|
1781
|
+
if (code !== undefined) {
|
|
1782
|
+
currency = this.currency(code);
|
|
1783
|
+
request['balance_token'] = currency['id'];
|
|
1784
|
+
}
|
|
1785
|
+
if (since !== undefined) {
|
|
1786
|
+
request['start_t'] = since;
|
|
1787
|
+
}
|
|
1788
|
+
if (limit !== undefined) {
|
|
1789
|
+
request['pageSize'] = limit;
|
|
1790
|
+
}
|
|
1791
|
+
const transactionType = this.safeString(params, 'type');
|
|
1792
|
+
params = this.omit(params, 'type');
|
|
1793
|
+
if (transactionType !== undefined) {
|
|
1794
|
+
request['type'] = transactionType;
|
|
1795
|
+
}
|
|
1796
|
+
const response = await this.v1PrivateGetAssetHistory(this.extend(request, params));
|
|
1797
|
+
// {
|
|
1798
|
+
// "rows": [
|
|
1799
|
+
// {
|
|
1800
|
+
// "id": "22010508193900165",
|
|
1801
|
+
// "token": "TRON_USDT",
|
|
1802
|
+
// "extra": '',
|
|
1803
|
+
// "amount": "13.75848500",
|
|
1804
|
+
// "status": "COMPLETED",
|
|
1805
|
+
// "account": null,
|
|
1806
|
+
// "description": null,
|
|
1807
|
+
// "user_id": "42222",
|
|
1808
|
+
// "application_id": "6ad2b303-f354-45c0-8105-9f5f19d0e335",
|
|
1809
|
+
// "external_id": "220105081900134",
|
|
1810
|
+
// "target_address": "TXnyFSnAYad3YCaqtwMw9jvXKkeU39NLnK",
|
|
1811
|
+
// "source_address": "TYDzsYUEpvnYmQk4zGP9sWWcTEd2MiAtW6",
|
|
1812
|
+
// "type": "BALANCE",
|
|
1813
|
+
// "token_side": "DEPOSIT",
|
|
1814
|
+
// "tx_id": "35b0004022f6b3ad07f39a0b7af199f6b258c2c3e2c7cdc93c67efa74fd625ee",
|
|
1815
|
+
// "fee_token": '',
|
|
1816
|
+
// "fee_amount": "0.00000000",
|
|
1817
|
+
// "created_time": "1641370779.442",
|
|
1818
|
+
// "updated_time": "1641370779.465",
|
|
1819
|
+
// "is_new_target_address": null,
|
|
1820
|
+
// "confirmed_number": "29",
|
|
1821
|
+
// "confirming_threshold": "27",
|
|
1822
|
+
// "audit_tag": "1",
|
|
1823
|
+
// "audit_result": "0",
|
|
1824
|
+
// "balance_token": null, // TODO -write to support, that this seems broken. here should be the token id
|
|
1825
|
+
// "network_name": null // TODO -write to support, that this seems broken. here should be the network id
|
|
1826
|
+
// }
|
|
1827
|
+
// ],
|
|
1828
|
+
// "meta": { total: '1', records_per_page: "25", current_page: "1" },
|
|
1829
|
+
// "success": true
|
|
1830
|
+
// }
|
|
1831
|
+
return [currency, this.safeValue(response, 'rows', {})];
|
|
1832
|
+
}
|
|
1833
|
+
async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1834
|
+
/**
|
|
1835
|
+
* @method
|
|
1836
|
+
* @name woo#fetchLedger
|
|
1837
|
+
* @description fetch the history of changes, actions done by the user or operations that altered balance of the user
|
|
1838
|
+
* @param {string} code unified currency code, default is undefined
|
|
1839
|
+
* @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
|
|
1840
|
+
* @param {int} [limit] max number of ledger entrys to return, default is undefined
|
|
1841
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1842
|
+
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
|
|
1843
|
+
*/
|
|
1844
|
+
const [currency, rows] = await this.getAssetHistoryRows(code, since, limit, params);
|
|
1845
|
+
return this.parseLedger(rows, currency, since, limit, params);
|
|
1846
|
+
}
|
|
1847
|
+
parseLedgerEntry(item, currency = undefined) {
|
|
1848
|
+
const networkizedCode = this.safeString(item, 'token');
|
|
1849
|
+
const currencyDefined = this.getCurrencyFromChaincode(networkizedCode, currency);
|
|
1850
|
+
const code = currencyDefined['code'];
|
|
1851
|
+
const amount = this.safeNumber(item, 'amount');
|
|
1852
|
+
const side = this.safeString(item, 'token_side');
|
|
1853
|
+
const direction = (side === 'DEPOSIT') ? 'in' : 'out';
|
|
1854
|
+
const timestamp = this.safeTimestamp(item, 'created_time');
|
|
1855
|
+
const fee = this.parseTokenAndFeeTemp(item, 'fee_token', 'fee_amount');
|
|
1856
|
+
return {
|
|
1857
|
+
'id': this.safeString(item, 'id'),
|
|
1858
|
+
'currency': code,
|
|
1859
|
+
'account': this.safeString(item, 'account'),
|
|
1860
|
+
'referenceAccount': undefined,
|
|
1861
|
+
'referenceId': this.safeString(item, 'tx_id'),
|
|
1862
|
+
'status': this.parseTransactionStatus(this.safeString(item, 'status')),
|
|
1863
|
+
'amount': amount,
|
|
1864
|
+
'before': undefined,
|
|
1865
|
+
'after': undefined,
|
|
1866
|
+
'fee': fee,
|
|
1867
|
+
'direction': direction,
|
|
1868
|
+
'timestamp': timestamp,
|
|
1869
|
+
'datetime': this.iso8601(timestamp),
|
|
1870
|
+
'type': this.parseLedgerEntryType(this.safeString(item, 'type')),
|
|
1871
|
+
'info': item,
|
|
1872
|
+
};
|
|
1873
|
+
}
|
|
1874
|
+
parseLedgerEntryType(type) {
|
|
1875
|
+
const types = {
|
|
1876
|
+
'BALANCE': 'transaction',
|
|
1877
|
+
'COLLATERAL': 'transfer', // Funds moved between portfolios
|
|
1878
|
+
};
|
|
1879
|
+
return this.safeString(types, type, type);
|
|
1880
|
+
}
|
|
1881
|
+
getCurrencyFromChaincode(networkizedCode, currency) {
|
|
1882
|
+
if (currency !== undefined) {
|
|
1883
|
+
return currency;
|
|
1884
|
+
}
|
|
1885
|
+
else {
|
|
1886
|
+
const parts = networkizedCode.split('_');
|
|
1887
|
+
const partsLength = parts.length;
|
|
1888
|
+
const firstPart = this.safeString(parts, 0);
|
|
1889
|
+
let currencyId = this.safeString(parts, 1, firstPart);
|
|
1890
|
+
if (partsLength > 2) {
|
|
1891
|
+
currencyId += '_' + this.safeString(parts, 2);
|
|
1892
|
+
}
|
|
1893
|
+
currency = this.safeCurrency(currencyId);
|
|
1894
|
+
}
|
|
1895
|
+
return currency;
|
|
1896
|
+
}
|
|
1897
|
+
async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1898
|
+
/**
|
|
1899
|
+
* @method
|
|
1900
|
+
* @name woo#fetchDeposits
|
|
1901
|
+
* @description fetch all deposits made to an account
|
|
1902
|
+
* @param {string} code unified currency code
|
|
1903
|
+
* @param {int} [since] the earliest time in ms to fetch deposits for
|
|
1904
|
+
* @param {int} [limit] the maximum number of deposits structures to retrieve
|
|
1905
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1906
|
+
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1907
|
+
*/
|
|
1908
|
+
const request = {
|
|
1909
|
+
'token_side': 'DEPOSIT',
|
|
1910
|
+
};
|
|
1911
|
+
return await this.fetchDepositsWithdrawals(code, since, limit, this.extend(request, params));
|
|
1912
|
+
}
|
|
1913
|
+
async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1914
|
+
/**
|
|
1915
|
+
* @method
|
|
1916
|
+
* @name woo#fetchWithdrawals
|
|
1917
|
+
* @description fetch all withdrawals made from an account
|
|
1918
|
+
* @param {string} code unified currency code
|
|
1919
|
+
* @param {int} [since] the earliest time in ms to fetch withdrawals for
|
|
1920
|
+
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
|
|
1921
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1922
|
+
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1923
|
+
*/
|
|
1924
|
+
const request = {
|
|
1925
|
+
'token_side': 'WITHDRAW',
|
|
1926
|
+
};
|
|
1927
|
+
return await this.fetchDepositsWithdrawals(code, since, limit, this.extend(request, params));
|
|
1928
|
+
}
|
|
1929
|
+
async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1930
|
+
/**
|
|
1931
|
+
* @method
|
|
1932
|
+
* @name woo#fetchDepositsWithdrawals
|
|
1933
|
+
* @description fetch history of deposits and withdrawals
|
|
1934
|
+
* @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
|
|
1935
|
+
* @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
|
|
1936
|
+
* @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
|
|
1937
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1938
|
+
* @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1939
|
+
*/
|
|
1940
|
+
const request = {
|
|
1941
|
+
'type': 'BALANCE',
|
|
1942
|
+
};
|
|
1943
|
+
const [currency, rows] = await this.getAssetHistoryRows(code, since, limit, this.extend(request, params));
|
|
1944
|
+
//
|
|
1945
|
+
// {
|
|
1946
|
+
// "rows":[],
|
|
1947
|
+
// "meta":{
|
|
1948
|
+
// "total":0,
|
|
1949
|
+
// "records_per_page":25,
|
|
1950
|
+
// "current_page":1
|
|
1951
|
+
// },
|
|
1952
|
+
// "success":true
|
|
1953
|
+
// }
|
|
1954
|
+
//
|
|
1955
|
+
return this.parseTransactions(rows, currency, since, limit, params);
|
|
1956
|
+
}
|
|
1957
|
+
parseTransaction(transaction, currency = undefined) {
|
|
1958
|
+
// example in fetchLedger
|
|
1959
|
+
const networkizedCode = this.safeString(transaction, 'token');
|
|
1960
|
+
const currencyDefined = this.getCurrencyFromChaincode(networkizedCode, currency);
|
|
1961
|
+
const code = currencyDefined['code'];
|
|
1962
|
+
let movementDirection = this.safeStringLower(transaction, 'token_side');
|
|
1963
|
+
if (movementDirection === 'withdraw') {
|
|
1964
|
+
movementDirection = 'withdrawal';
|
|
1965
|
+
}
|
|
1966
|
+
const fee = this.parseTokenAndFeeTemp(transaction, 'fee_token', 'fee_amount');
|
|
1967
|
+
const addressTo = this.safeString(transaction, 'target_address');
|
|
1968
|
+
const addressFrom = this.safeString(transaction, 'source_address');
|
|
1969
|
+
const timestamp = this.safeTimestamp(transaction, 'created_time');
|
|
1970
|
+
return {
|
|
1971
|
+
'info': transaction,
|
|
1972
|
+
'id': this.safeString2(transaction, 'id', 'withdraw_id'),
|
|
1973
|
+
'txid': this.safeString(transaction, 'tx_id'),
|
|
1974
|
+
'timestamp': timestamp,
|
|
1975
|
+
'datetime': this.iso8601(timestamp),
|
|
1976
|
+
'address': undefined,
|
|
1977
|
+
'addressFrom': addressFrom,
|
|
1978
|
+
'addressTo': addressTo,
|
|
1979
|
+
'tag': this.safeString(transaction, 'extra'),
|
|
1980
|
+
'tagFrom': undefined,
|
|
1981
|
+
'tagTo': undefined,
|
|
1982
|
+
'type': movementDirection,
|
|
1983
|
+
'amount': this.safeNumber(transaction, 'amount'),
|
|
1984
|
+
'currency': code,
|
|
1985
|
+
'status': this.parseTransactionStatus(this.safeString(transaction, 'status')),
|
|
1986
|
+
'updated': this.safeTimestamp(transaction, 'updated_time'),
|
|
1987
|
+
'comment': undefined,
|
|
1988
|
+
'internal': undefined,
|
|
1989
|
+
'fee': fee,
|
|
1990
|
+
'network': undefined,
|
|
1991
|
+
};
|
|
1992
|
+
}
|
|
1993
|
+
parseTransactionStatus(status) {
|
|
1994
|
+
const statuses = {
|
|
1995
|
+
'NEW': 'pending',
|
|
1996
|
+
'CONFIRMING': 'pending',
|
|
1997
|
+
'PROCESSING': 'pending',
|
|
1998
|
+
'COMPLETED': 'ok',
|
|
1999
|
+
'CANCELED': 'canceled',
|
|
2000
|
+
};
|
|
2001
|
+
return this.safeString(statuses, status, status);
|
|
2002
|
+
}
|
|
2003
|
+
async transfer(code, amount, fromAccount, toAccount, params = {}) {
|
|
2004
|
+
/**
|
|
2005
|
+
* @method
|
|
2006
|
+
* @name woo#transfer
|
|
2007
|
+
* @description transfer currency internally between wallets on the same account
|
|
2008
|
+
* @param {string} code unified currency code
|
|
2009
|
+
* @param {float} amount amount to transfer
|
|
2010
|
+
* @param {string} fromAccount account to transfer from
|
|
2011
|
+
* @param {string} toAccount account to transfer to
|
|
2012
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2013
|
+
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
2014
|
+
*/
|
|
2015
|
+
await this.loadMarkets();
|
|
2016
|
+
const currency = this.currency(code);
|
|
2017
|
+
const request = {
|
|
2018
|
+
'token': currency['id'],
|
|
2019
|
+
'amount': this.parseNumber(amount),
|
|
2020
|
+
'from_application_id': fromAccount,
|
|
2021
|
+
'to_application_id': toAccount,
|
|
2022
|
+
};
|
|
2023
|
+
const response = await this.v1PrivatePostAssetMainSubTransfer(this.extend(request, params));
|
|
2024
|
+
//
|
|
2025
|
+
// {
|
|
2026
|
+
// "success": true,
|
|
2027
|
+
// "id": 200
|
|
2028
|
+
// }
|
|
2029
|
+
//
|
|
2030
|
+
const transfer = this.parseTransfer(response, currency);
|
|
2031
|
+
const transferOptions = this.safeValue(this.options, 'transfer', {});
|
|
2032
|
+
const fillResponseFromRequest = this.safeValue(transferOptions, 'fillResponseFromRequest', true);
|
|
2033
|
+
if (fillResponseFromRequest) {
|
|
2034
|
+
transfer['amount'] = amount;
|
|
2035
|
+
transfer['fromAccount'] = fromAccount;
|
|
2036
|
+
transfer['toAccount'] = toAccount;
|
|
2037
|
+
}
|
|
2038
|
+
return transfer;
|
|
2039
|
+
}
|
|
2040
|
+
async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2041
|
+
/**
|
|
2042
|
+
* @method
|
|
2043
|
+
* @name woo#fetchTransfers
|
|
2044
|
+
* @description fetch a history of internal transfers made on an account
|
|
2045
|
+
* @param {string} code unified currency code of the currency transferred
|
|
2046
|
+
* @param {int} [since] the earliest time in ms to fetch transfers for
|
|
2047
|
+
* @param {int} [limit] the maximum number of transfers structures to retrieve
|
|
2048
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2049
|
+
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
2050
|
+
*/
|
|
2051
|
+
const request = {
|
|
2052
|
+
'type': 'COLLATERAL',
|
|
2053
|
+
};
|
|
2054
|
+
const [currency, rows] = await this.getAssetHistoryRows(code, since, limit, this.extend(request, params));
|
|
2055
|
+
return this.parseTransfers(rows, currency, since, limit, params);
|
|
2056
|
+
}
|
|
2057
|
+
parseTransfer(transfer, currency = undefined) {
|
|
2058
|
+
//
|
|
2059
|
+
// getAssetHistoryRows
|
|
2060
|
+
// {
|
|
2061
|
+
// "created_time": "1579399877.041", // Unix epoch time in seconds
|
|
2062
|
+
// "updated_time": "1579399877.041", // Unix epoch time in seconds
|
|
2063
|
+
// "id": "202029292829292",
|
|
2064
|
+
// "external_id": "202029292829292",
|
|
2065
|
+
// "application_id": null,
|
|
2066
|
+
// "token": "ETH",
|
|
2067
|
+
// "target_address": "0x31d64B3230f8baDD91dE1710A65DF536aF8f7cDa",
|
|
2068
|
+
// "source_address": "0x70fd25717f769c7f9a46b319f0f9103c0d887af0",
|
|
2069
|
+
// "extra": "",
|
|
2070
|
+
// "type": "BALANCE",
|
|
2071
|
+
// "token_side": "DEPOSIT",
|
|
2072
|
+
// "amount": 1000,
|
|
2073
|
+
// "tx_id": "0x8a74c517bc104c8ebad0c3c3f64b1f302ed5f8bca598ae4459c63419038106b6",
|
|
2074
|
+
// "fee_token": null,
|
|
2075
|
+
// "fee_amount": null,
|
|
2076
|
+
// "status": "CONFIRMING"
|
|
2077
|
+
// }
|
|
2078
|
+
//
|
|
2079
|
+
// v1PrivatePostAssetMainSubTransfer
|
|
2080
|
+
// {
|
|
2081
|
+
// "success": true,
|
|
2082
|
+
// "id": 200
|
|
2083
|
+
// }
|
|
2084
|
+
//
|
|
2085
|
+
const networkizedCode = this.safeString(transfer, 'token');
|
|
2086
|
+
const currencyDefined = this.getCurrencyFromChaincode(networkizedCode, currency);
|
|
2087
|
+
const code = currencyDefined['code'];
|
|
2088
|
+
let movementDirection = this.safeStringLower(transfer, 'token_side');
|
|
2089
|
+
if (movementDirection === 'withdraw') {
|
|
2090
|
+
movementDirection = 'withdrawal';
|
|
2091
|
+
}
|
|
2092
|
+
let fromAccount = undefined;
|
|
2093
|
+
let toAccount = undefined;
|
|
2094
|
+
if (movementDirection === 'withdraw') {
|
|
2095
|
+
fromAccount = undefined;
|
|
2096
|
+
toAccount = 'spot';
|
|
2097
|
+
}
|
|
2098
|
+
else if (movementDirection === 'deposit') {
|
|
2099
|
+
fromAccount = 'spot';
|
|
2100
|
+
toAccount = undefined;
|
|
2101
|
+
}
|
|
2102
|
+
const timestamp = this.safeTimestamp(transfer, 'created_time');
|
|
2103
|
+
const success = this.safeValue(transfer, 'success');
|
|
2104
|
+
let status = undefined;
|
|
2105
|
+
if (success !== undefined) {
|
|
2106
|
+
status = success ? 'ok' : 'failed';
|
|
2107
|
+
}
|
|
2108
|
+
return {
|
|
2109
|
+
'id': this.safeString(transfer, 'id'),
|
|
2110
|
+
'timestamp': timestamp,
|
|
2111
|
+
'datetime': this.iso8601(timestamp),
|
|
2112
|
+
'currency': code,
|
|
2113
|
+
'amount': this.safeNumber(transfer, 'amount'),
|
|
2114
|
+
'fromAccount': fromAccount,
|
|
2115
|
+
'toAccount': toAccount,
|
|
2116
|
+
'status': this.parseTransferStatus(this.safeString(transfer, 'status', status)),
|
|
2117
|
+
'info': transfer,
|
|
2118
|
+
};
|
|
2119
|
+
}
|
|
2120
|
+
parseTransferStatus(status) {
|
|
2121
|
+
const statuses = {
|
|
2122
|
+
'NEW': 'pending',
|
|
2123
|
+
'CONFIRMING': 'pending',
|
|
2124
|
+
'PROCESSING': 'pending',
|
|
2125
|
+
'COMPLETED': 'ok',
|
|
2126
|
+
'CANCELED': 'canceled',
|
|
2127
|
+
};
|
|
2128
|
+
return this.safeString(statuses, status, status);
|
|
2129
|
+
}
|
|
2130
|
+
async withdraw(code, amount, address, tag = undefined, params = {}) {
|
|
2131
|
+
/**
|
|
2132
|
+
* @method
|
|
2133
|
+
* @name woo#withdraw
|
|
2134
|
+
* @description make a withdrawal
|
|
2135
|
+
* @param {string} code unified currency code
|
|
2136
|
+
* @param {float} amount the amount to withdraw
|
|
2137
|
+
* @param {string} address the address to withdraw to
|
|
2138
|
+
* @param {string} tag
|
|
2139
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2140
|
+
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
2141
|
+
*/
|
|
2142
|
+
[tag, params] = this.handleWithdrawTagAndParams(tag, params);
|
|
2143
|
+
await this.loadMarkets();
|
|
2144
|
+
this.checkAddress(address);
|
|
2145
|
+
const currency = this.currency(code);
|
|
2146
|
+
const request = {
|
|
2147
|
+
'amount': amount,
|
|
2148
|
+
'address': address,
|
|
2149
|
+
};
|
|
2150
|
+
if (tag !== undefined) {
|
|
2151
|
+
request['extra'] = tag;
|
|
2152
|
+
}
|
|
2153
|
+
const networks = this.safeValue(this.options, 'networks', {});
|
|
2154
|
+
const currencyNetworks = this.safeValue(currency, 'networks', {});
|
|
2155
|
+
const network = this.safeStringUpper(params, 'network');
|
|
2156
|
+
const networkId = this.safeString(networks, network, network);
|
|
2157
|
+
const coinNetwork = this.safeValue(currencyNetworks, networkId, {});
|
|
2158
|
+
const coinNetworkId = this.safeString(coinNetwork, 'id');
|
|
2159
|
+
if (coinNetworkId === undefined) {
|
|
2160
|
+
throw new errors.BadRequest(this.id + ' withdraw() require network parameter');
|
|
2161
|
+
}
|
|
2162
|
+
request['token'] = coinNetworkId;
|
|
2163
|
+
const response = await this.v1PrivatePostAssetWithdraw(this.extend(request, params));
|
|
2164
|
+
//
|
|
2165
|
+
// {
|
|
2166
|
+
// "success": true,
|
|
2167
|
+
// "withdraw_id": "20200119145703654"
|
|
2168
|
+
// }
|
|
2169
|
+
//
|
|
2170
|
+
return this.parseTransaction(response, currency);
|
|
2171
|
+
}
|
|
2172
|
+
async repayMargin(code, amount, symbol = undefined, params = {}) {
|
|
2173
|
+
/**
|
|
2174
|
+
* @method
|
|
2175
|
+
* @name woo#repayMargin
|
|
2176
|
+
* @description repay borrowed margin and interest
|
|
2177
|
+
* @see https://docs.woo.org/#repay-interest
|
|
2178
|
+
* @param {string} code unified currency code of the currency to repay
|
|
2179
|
+
* @param {float} amount the amount to repay
|
|
2180
|
+
* @param {string} symbol not used by woo.repayMargin ()
|
|
2181
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2182
|
+
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
|
2183
|
+
*/
|
|
2184
|
+
await this.loadMarkets();
|
|
2185
|
+
let market = undefined;
|
|
2186
|
+
if (symbol !== undefined) {
|
|
2187
|
+
market = this.market(symbol);
|
|
2188
|
+
symbol = market['symbol'];
|
|
2189
|
+
}
|
|
2190
|
+
const currency = this.currency(code);
|
|
2191
|
+
const request = {
|
|
2192
|
+
'token': currency['id'],
|
|
2193
|
+
'amount': this.currencyToPrecision(code, amount),
|
|
2194
|
+
};
|
|
2195
|
+
const response = await this.v1PrivatePostInterestRepay(this.extend(request, params));
|
|
2196
|
+
//
|
|
2197
|
+
// {
|
|
2198
|
+
// "success": true,
|
|
2199
|
+
// }
|
|
2200
|
+
//
|
|
2201
|
+
const transaction = this.parseMarginLoan(response, currency);
|
|
2202
|
+
return this.extend(transaction, {
|
|
2203
|
+
'amount': amount,
|
|
2204
|
+
'symbol': symbol,
|
|
2205
|
+
});
|
|
2206
|
+
}
|
|
2207
|
+
parseMarginLoan(info, currency = undefined) {
|
|
2208
|
+
//
|
|
2209
|
+
// {
|
|
2210
|
+
// "success": true,
|
|
2211
|
+
// }
|
|
2212
|
+
//
|
|
2213
|
+
return {
|
|
2214
|
+
'id': undefined,
|
|
2215
|
+
'currency': this.safeCurrencyCode(undefined, currency),
|
|
2216
|
+
'amount': undefined,
|
|
2217
|
+
'symbol': undefined,
|
|
2218
|
+
'timestamp': undefined,
|
|
2219
|
+
'datetime': undefined,
|
|
2220
|
+
'info': info,
|
|
2221
|
+
};
|
|
2222
|
+
}
|
|
2223
|
+
nonce() {
|
|
2224
|
+
return this.milliseconds();
|
|
2225
|
+
}
|
|
2226
|
+
sign(path, section = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
2227
|
+
const version = section[0];
|
|
2228
|
+
const access = section[1];
|
|
2229
|
+
const pathWithParams = this.implodeParams(path, params);
|
|
2230
|
+
let url = this.implodeHostname(this.urls['api'][access]);
|
|
2231
|
+
url += '/' + version + '/';
|
|
2232
|
+
params = this.omit(params, this.extractParams(path));
|
|
2233
|
+
params = this.keysort(params);
|
|
2234
|
+
if (access === 'public') {
|
|
2235
|
+
url += access + '/' + pathWithParams;
|
|
2236
|
+
if (Object.keys(params).length) {
|
|
2237
|
+
url += '?' + this.urlencode(params);
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
else {
|
|
2241
|
+
this.checkRequiredCredentials();
|
|
2242
|
+
if (method === 'POST' && (path === 'algo/order' || path === 'order')) {
|
|
2243
|
+
const isSandboxMode = this.safeValue(this.options, 'sandboxMode', false);
|
|
2244
|
+
if (!isSandboxMode) {
|
|
2245
|
+
const applicationId = 'bc830de7-50f3-460b-9ee0-f430f83f9dad';
|
|
2246
|
+
const brokerId = this.safeString(this.options, 'brokerId', applicationId);
|
|
2247
|
+
const isStop = path.indexOf('algo') > -1;
|
|
2248
|
+
if (isStop) {
|
|
2249
|
+
params['brokerId'] = brokerId;
|
|
2250
|
+
}
|
|
2251
|
+
else {
|
|
2252
|
+
params['broker_id'] = brokerId;
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
params = this.keysort(params);
|
|
2256
|
+
}
|
|
2257
|
+
let auth = '';
|
|
2258
|
+
const ts = this.nonce().toString();
|
|
2259
|
+
url += pathWithParams;
|
|
2260
|
+
headers = {
|
|
2261
|
+
'x-api-key': this.apiKey,
|
|
2262
|
+
'x-api-timestamp': ts,
|
|
2263
|
+
};
|
|
2264
|
+
if (version === 'v3') {
|
|
2265
|
+
auth = ts + method + '/' + version + '/' + pathWithParams;
|
|
2266
|
+
if (method === 'POST' || method === 'PUT' || method === 'DELETE') {
|
|
2267
|
+
body = this.json(params);
|
|
2268
|
+
auth += body;
|
|
2269
|
+
}
|
|
2270
|
+
else {
|
|
2271
|
+
if (Object.keys(params).length) {
|
|
2272
|
+
const query = this.urlencode(params);
|
|
2273
|
+
url += '?' + query;
|
|
2274
|
+
auth += '?' + query;
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
headers['content-type'] = 'application/json';
|
|
2278
|
+
}
|
|
2279
|
+
else {
|
|
2280
|
+
auth = this.urlencode(params);
|
|
2281
|
+
if (method === 'POST' || method === 'PUT' || method === 'DELETE') {
|
|
2282
|
+
body = auth;
|
|
2283
|
+
}
|
|
2284
|
+
else {
|
|
2285
|
+
url += '?' + auth;
|
|
2286
|
+
}
|
|
2287
|
+
auth += '|' + ts;
|
|
2288
|
+
headers['content-type'] = 'application/x-www-form-urlencoded';
|
|
2289
|
+
}
|
|
2290
|
+
headers['x-api-signature'] = this.hmac(this.encode(auth), this.encode(this.secret), sha256.sha256);
|
|
2291
|
+
}
|
|
2292
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
2293
|
+
}
|
|
2294
|
+
handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
2295
|
+
if (!response) {
|
|
2296
|
+
return undefined; // fallback to default error handler
|
|
2297
|
+
}
|
|
2298
|
+
//
|
|
2299
|
+
// 400 Bad Request {"success":false,"code":-1012,"message":"Amount is required for buy market orders when margin disabled."}
|
|
2300
|
+
//
|
|
2301
|
+
const success = this.safeValue(response, 'success');
|
|
2302
|
+
const errorCode = this.safeString(response, 'code');
|
|
2303
|
+
if (!success) {
|
|
2304
|
+
const feedback = this.id + ' ' + this.json(response);
|
|
2305
|
+
this.throwBroadlyMatchedException(this.exceptions['broad'], body, feedback);
|
|
2306
|
+
this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
|
|
2307
|
+
}
|
|
2308
|
+
return undefined;
|
|
2309
|
+
}
|
|
2310
|
+
parseIncome(income, market = undefined) {
|
|
2311
|
+
//
|
|
2312
|
+
// {
|
|
2313
|
+
// "id":666666,
|
|
2314
|
+
// "symbol":"PERP_BTC_USDT",
|
|
2315
|
+
// "funding_rate":0.00001198,
|
|
2316
|
+
// "mark_price":28941.04000000,
|
|
2317
|
+
// "funding_fee":0.00069343,
|
|
2318
|
+
// "payment_type":"Pay",
|
|
2319
|
+
// "status":"COMPLETED",
|
|
2320
|
+
// "created_time":"1653616000.666",
|
|
2321
|
+
// "updated_time":"1653616000.605"
|
|
2322
|
+
// }
|
|
2323
|
+
//
|
|
2324
|
+
const marketId = this.safeString(income, 'symbol');
|
|
2325
|
+
const symbol = this.safeSymbol(marketId, market);
|
|
2326
|
+
const amount = this.safeNumber(income, 'funding_fee');
|
|
2327
|
+
const code = this.safeCurrencyCode('USD');
|
|
2328
|
+
const id = this.safeString(income, 'id');
|
|
2329
|
+
const timestamp = this.safeTimestamp(income, 'updated_time');
|
|
2330
|
+
const rate = this.safeNumber(income, 'funding_rate');
|
|
2331
|
+
return {
|
|
2332
|
+
'info': income,
|
|
2333
|
+
'symbol': symbol,
|
|
2334
|
+
'code': code,
|
|
2335
|
+
'timestamp': timestamp,
|
|
2336
|
+
'datetime': this.iso8601(timestamp),
|
|
2337
|
+
'id': id,
|
|
2338
|
+
'amount': amount,
|
|
2339
|
+
'rate': rate,
|
|
2340
|
+
};
|
|
2341
|
+
}
|
|
2342
|
+
async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2343
|
+
await this.loadMarkets();
|
|
2344
|
+
const request = {};
|
|
2345
|
+
let market = undefined;
|
|
2346
|
+
if (symbol !== undefined) {
|
|
2347
|
+
market = this.market(symbol);
|
|
2348
|
+
request['symbol'] = market['id'];
|
|
2349
|
+
}
|
|
2350
|
+
if (since !== undefined) {
|
|
2351
|
+
request['start_t'] = since;
|
|
2352
|
+
}
|
|
2353
|
+
const response = await this.v1PrivateGetFundingFeeHistory(this.extend(request, params));
|
|
2354
|
+
//
|
|
2355
|
+
// {
|
|
2356
|
+
// "rows":[
|
|
2357
|
+
// {
|
|
2358
|
+
// "id":666666,
|
|
2359
|
+
// "symbol":"PERP_BTC_USDT",
|
|
2360
|
+
// "funding_rate":0.00001198,
|
|
2361
|
+
// "mark_price":28941.04000000,
|
|
2362
|
+
// "funding_fee":0.00069343,
|
|
2363
|
+
// "payment_type":"Pay",
|
|
2364
|
+
// "status":"COMPLETED",
|
|
2365
|
+
// "created_time":"1653616000.666",
|
|
2366
|
+
// "updated_time":"1653616000.605"
|
|
2367
|
+
// }
|
|
2368
|
+
// ],
|
|
2369
|
+
// "meta":{
|
|
2370
|
+
// "total":235,
|
|
2371
|
+
// "records_per_page":25,
|
|
2372
|
+
// "current_page":1
|
|
2373
|
+
// },
|
|
2374
|
+
// "success":true
|
|
2375
|
+
// }
|
|
2376
|
+
//
|
|
2377
|
+
const result = this.safeValue(response, 'rows', []);
|
|
2378
|
+
return this.parseIncomes(result, market, since, limit);
|
|
2379
|
+
}
|
|
2380
|
+
parseFundingRate(fundingRate, market = undefined) {
|
|
2381
|
+
//
|
|
2382
|
+
// {
|
|
2383
|
+
// "symbol":"PERP_AAVE_USDT",
|
|
2384
|
+
// "est_funding_rate":-0.00003447,
|
|
2385
|
+
// "est_funding_rate_timestamp":1653633959001,
|
|
2386
|
+
// "last_funding_rate":-0.00002094,
|
|
2387
|
+
// "last_funding_rate_timestamp":1653631200000,
|
|
2388
|
+
// "next_funding_time":1653634800000
|
|
2389
|
+
// }
|
|
2390
|
+
//
|
|
2391
|
+
//
|
|
2392
|
+
const symbol = this.safeString(fundingRate, 'symbol');
|
|
2393
|
+
market = this.market(symbol);
|
|
2394
|
+
const nextFundingTimestamp = this.safeInteger(fundingRate, 'next_funding_time');
|
|
2395
|
+
const estFundingRateTimestamp = this.safeInteger(fundingRate, 'est_funding_rate_timestamp');
|
|
2396
|
+
const lastFundingRateTimestamp = this.safeInteger(fundingRate, 'last_funding_rate_timestamp');
|
|
2397
|
+
return {
|
|
2398
|
+
'info': fundingRate,
|
|
2399
|
+
'symbol': market['symbol'],
|
|
2400
|
+
'markPrice': undefined,
|
|
2401
|
+
'indexPrice': undefined,
|
|
2402
|
+
'interestRate': this.parseNumber('0'),
|
|
2403
|
+
'estimatedSettlePrice': undefined,
|
|
2404
|
+
'timestamp': estFundingRateTimestamp,
|
|
2405
|
+
'datetime': this.iso8601(estFundingRateTimestamp),
|
|
2406
|
+
'fundingRate': this.safeNumber(fundingRate, 'est_funding_rate'),
|
|
2407
|
+
'fundingTimestamp': nextFundingTimestamp,
|
|
2408
|
+
'fundingDatetime': this.iso8601(nextFundingTimestamp),
|
|
2409
|
+
'nextFundingRate': undefined,
|
|
2410
|
+
'nextFundingTimestamp': undefined,
|
|
2411
|
+
'nextFundingDatetime': undefined,
|
|
2412
|
+
'previousFundingRate': this.safeNumber(fundingRate, 'last_funding_rate'),
|
|
2413
|
+
'previousFundingTimestamp': lastFundingRateTimestamp,
|
|
2414
|
+
'previousFundingDatetime': this.iso8601(lastFundingRateTimestamp),
|
|
2415
|
+
};
|
|
2416
|
+
}
|
|
2417
|
+
async fetchFundingRate(symbol, params = {}) {
|
|
2418
|
+
await this.loadMarkets();
|
|
2419
|
+
const market = this.market(symbol);
|
|
2420
|
+
const request = {
|
|
2421
|
+
'symbol': market['id'],
|
|
2422
|
+
};
|
|
2423
|
+
const response = await this.v1PublicGetFundingRateSymbol(this.extend(request, params));
|
|
2424
|
+
//
|
|
2425
|
+
// {
|
|
2426
|
+
// "success":true,
|
|
2427
|
+
// "timestamp":1653640572711,
|
|
2428
|
+
// "symbol":"PERP_BTC_USDT",
|
|
2429
|
+
// "est_funding_rate":0.00000738,
|
|
2430
|
+
// "est_funding_rate_timestamp":1653640559003,
|
|
2431
|
+
// "last_funding_rate":0.00000629,
|
|
2432
|
+
// "last_funding_rate_timestamp":1653638400000,
|
|
2433
|
+
// "next_funding_time":1653642000000
|
|
2434
|
+
// }
|
|
2435
|
+
//
|
|
2436
|
+
return this.parseFundingRate(response, market);
|
|
2437
|
+
}
|
|
2438
|
+
async fetchFundingRates(symbols = undefined, params = {}) {
|
|
2439
|
+
await this.loadMarkets();
|
|
2440
|
+
symbols = this.marketSymbols(symbols);
|
|
2441
|
+
const response = await this.v1PublicGetFundingRates(params);
|
|
2442
|
+
//
|
|
2443
|
+
// {
|
|
2444
|
+
// "success":true,
|
|
2445
|
+
// "rows":[
|
|
2446
|
+
// {
|
|
2447
|
+
// "symbol":"PERP_AAVE_USDT",
|
|
2448
|
+
// "est_funding_rate":-0.00003447,
|
|
2449
|
+
// "est_funding_rate_timestamp":1653633959001,
|
|
2450
|
+
// "last_funding_rate":-0.00002094,
|
|
2451
|
+
// "last_funding_rate_timestamp":1653631200000,
|
|
2452
|
+
// "next_funding_time":1653634800000
|
|
2453
|
+
// }
|
|
2454
|
+
// ],
|
|
2455
|
+
// "timestamp":1653633985646
|
|
2456
|
+
// }
|
|
2457
|
+
//
|
|
2458
|
+
const rows = this.safeValue(response, 'rows', {});
|
|
2459
|
+
const result = this.parseFundingRates(rows);
|
|
2460
|
+
return this.filterByArray(result, 'symbol', symbols);
|
|
2461
|
+
}
|
|
2462
|
+
async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2463
|
+
/**
|
|
2464
|
+
* @method
|
|
2465
|
+
* @name woo#fetchFundingRateHistory
|
|
2466
|
+
* @description fetches historical funding rate prices
|
|
2467
|
+
* @see https://docs.woo.org/#get-funding-rate-history-for-one-market-public
|
|
2468
|
+
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
|
|
2469
|
+
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
|
|
2470
|
+
* @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
|
|
2471
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2472
|
+
* @param {int} [params.until] timestamp in ms of the latest funding rate
|
|
2473
|
+
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
2474
|
+
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
|
|
2475
|
+
*/
|
|
2476
|
+
await this.loadMarkets();
|
|
2477
|
+
let paginate = false;
|
|
2478
|
+
[paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
|
|
2479
|
+
if (paginate) {
|
|
2480
|
+
return await this.fetchPaginatedCallIncremental('fetchFundingRateHistory', symbol, since, limit, params, 'page', 25);
|
|
2481
|
+
}
|
|
2482
|
+
let request = {};
|
|
2483
|
+
if (symbol !== undefined) {
|
|
2484
|
+
const market = this.market(symbol);
|
|
2485
|
+
symbol = market['symbol'];
|
|
2486
|
+
request['symbol'] = market['id'];
|
|
2487
|
+
}
|
|
2488
|
+
if (since !== undefined) {
|
|
2489
|
+
request['start_t'] = this.parseToInt(since / 1000);
|
|
2490
|
+
}
|
|
2491
|
+
[request, params] = this.handleUntilOption('end_t', request, params, 0.001);
|
|
2492
|
+
const response = await this.v1PublicGetFundingRateHistory(this.extend(request, params));
|
|
2493
|
+
//
|
|
2494
|
+
// {
|
|
2495
|
+
// "success":true,
|
|
2496
|
+
// "meta":{
|
|
2497
|
+
// "total":2464,
|
|
2498
|
+
// "records_per_page":25,
|
|
2499
|
+
// "current_page":1
|
|
2500
|
+
// },
|
|
2501
|
+
// "rows":[
|
|
2502
|
+
// {
|
|
2503
|
+
// "symbol":"PERP_BTC_USDT",
|
|
2504
|
+
// "funding_rate":0.00000629,
|
|
2505
|
+
// "funding_rate_timestamp":1653638400000,
|
|
2506
|
+
// "next_funding_time":1653642000000
|
|
2507
|
+
// }
|
|
2508
|
+
// ],
|
|
2509
|
+
// "timestamp":1653640814885
|
|
2510
|
+
// }
|
|
2511
|
+
//
|
|
2512
|
+
const result = this.safeValue(response, 'rows');
|
|
2513
|
+
const rates = [];
|
|
2514
|
+
for (let i = 0; i < result.length; i++) {
|
|
2515
|
+
const entry = result[i];
|
|
2516
|
+
const marketId = this.safeString(entry, 'symbol');
|
|
2517
|
+
const timestamp = this.safeInteger(entry, 'funding_rate_timestamp');
|
|
2518
|
+
rates.push({
|
|
2519
|
+
'info': entry,
|
|
2520
|
+
'symbol': this.safeSymbol(marketId),
|
|
2521
|
+
'fundingRate': this.safeNumber(entry, 'funding_rate'),
|
|
2522
|
+
'timestamp': timestamp,
|
|
2523
|
+
'datetime': this.iso8601(timestamp),
|
|
2524
|
+
});
|
|
2525
|
+
}
|
|
2526
|
+
const sorted = this.sortBy(rates, 'timestamp');
|
|
2527
|
+
return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
|
|
2528
|
+
}
|
|
2529
|
+
async fetchLeverage(symbol, params = {}) {
|
|
2530
|
+
await this.loadMarkets();
|
|
2531
|
+
const response = await this.v3PrivateGetAccountinfo(params);
|
|
2532
|
+
//
|
|
2533
|
+
// {
|
|
2534
|
+
// "success": true,
|
|
2535
|
+
// "data": {
|
|
2536
|
+
// "applicationId": "dsa",
|
|
2537
|
+
// "account": "dsa",
|
|
2538
|
+
// "alias": "haha",
|
|
2539
|
+
// "accountMode": "MARGIN",
|
|
2540
|
+
// "leverage": 1,
|
|
2541
|
+
// "takerFeeRate": 1,
|
|
2542
|
+
// "makerFeeRate": 1,
|
|
2543
|
+
// "interestRate": 1,
|
|
2544
|
+
// "futuresTakerFeeRate": 1,
|
|
2545
|
+
// "futuresMakerFeeRate": 1,
|
|
2546
|
+
// "otpauth": true,
|
|
2547
|
+
// "marginRatio": 1,
|
|
2548
|
+
// "openMarginRatio": 1,
|
|
2549
|
+
// "initialMarginRatio": 1,
|
|
2550
|
+
// "maintenanceMarginRatio": 1,
|
|
2551
|
+
// "totalCollateral": 1,
|
|
2552
|
+
// "freeCollateral": 1,
|
|
2553
|
+
// "totalAccountValue": 1,
|
|
2554
|
+
// "totalVaultValue": 1,
|
|
2555
|
+
// "totalStakingValue": 1
|
|
2556
|
+
// },
|
|
2557
|
+
// "timestamp": 1673323685109
|
|
2558
|
+
// }
|
|
2559
|
+
//
|
|
2560
|
+
const result = this.safeValue(response, 'data');
|
|
2561
|
+
const leverage = this.safeNumber(result, 'leverage');
|
|
2562
|
+
return {
|
|
2563
|
+
'info': response,
|
|
2564
|
+
'leverage': leverage,
|
|
2565
|
+
};
|
|
2566
|
+
}
|
|
2567
|
+
async setLeverage(leverage, symbol = undefined, params = {}) {
|
|
2568
|
+
await this.loadMarkets();
|
|
2569
|
+
if ((leverage < 1) || (leverage > 20)) {
|
|
2570
|
+
throw new errors.BadRequest(this.id + ' leverage should be between 1 and 20');
|
|
2571
|
+
}
|
|
2572
|
+
const request = {
|
|
2573
|
+
'leverage': leverage,
|
|
2574
|
+
};
|
|
2575
|
+
return await this.v1PrivatePostClientLeverage(this.extend(request, params));
|
|
2576
|
+
}
|
|
2577
|
+
async fetchPosition(symbol = undefined, params = {}) {
|
|
2578
|
+
await this.loadMarkets();
|
|
2579
|
+
const market = this.market(symbol);
|
|
2580
|
+
const request = {
|
|
2581
|
+
'symbol': market['id'],
|
|
2582
|
+
};
|
|
2583
|
+
const response = await this.v1PrivateGetPositionSymbol(this.extend(request, params));
|
|
2584
|
+
//
|
|
2585
|
+
// {
|
|
2586
|
+
// "symbol":"PERP_ETC_USDT",
|
|
2587
|
+
// "holding":0.0,
|
|
2588
|
+
// "pnl_24_h":0,
|
|
2589
|
+
// "settle_price":0.0,
|
|
2590
|
+
// "average_open_price":0,
|
|
2591
|
+
// "success":true,
|
|
2592
|
+
// "mark_price":22.6955,
|
|
2593
|
+
// "pending_short_qty":0.0,
|
|
2594
|
+
// "pending_long_qty":0.0,
|
|
2595
|
+
// "fee_24_h":0,
|
|
2596
|
+
// "timestamp":"1652231044.920"
|
|
2597
|
+
// }
|
|
2598
|
+
//
|
|
2599
|
+
return this.parsePosition(response, market);
|
|
2600
|
+
}
|
|
2601
|
+
async fetchPositions(symbols = undefined, params = {}) {
|
|
2602
|
+
await this.loadMarkets();
|
|
2603
|
+
const response = await this.v3PrivateGetPositions(params);
|
|
2604
|
+
//
|
|
2605
|
+
// {
|
|
2606
|
+
// "success": true,
|
|
2607
|
+
// "data": {
|
|
2608
|
+
// "positions": [
|
|
2609
|
+
// {
|
|
2610
|
+
// "symbol": "0_symbol",
|
|
2611
|
+
// "holding": 1,
|
|
2612
|
+
// "pendingLongQty": 0,
|
|
2613
|
+
// "pendingShortQty": 1,
|
|
2614
|
+
// "settlePrice": 1,
|
|
2615
|
+
// "averageOpenPrice": 1,
|
|
2616
|
+
// "pnl24H": 1,
|
|
2617
|
+
// "fee24H": 1,
|
|
2618
|
+
// "markPrice": 1,
|
|
2619
|
+
// "estLiqPrice": 1,
|
|
2620
|
+
// "timestamp": 12321321
|
|
2621
|
+
// }
|
|
2622
|
+
// ]
|
|
2623
|
+
// },
|
|
2624
|
+
// "timestamp": 1673323880342
|
|
2625
|
+
// }
|
|
2626
|
+
//
|
|
2627
|
+
const result = this.safeValue(response, 'data', {});
|
|
2628
|
+
const positions = this.safeValue(result, 'positions', []);
|
|
2629
|
+
return this.parsePositions(positions, symbols);
|
|
2630
|
+
}
|
|
2631
|
+
parsePosition(position, market = undefined) {
|
|
2632
|
+
//
|
|
2633
|
+
// {
|
|
2634
|
+
// "symbol": "0_symbol",
|
|
2635
|
+
// "holding": 1,
|
|
2636
|
+
// "pendingLongQty": 0,
|
|
2637
|
+
// "pendingShortQty": 1,
|
|
2638
|
+
// "settlePrice": 1,
|
|
2639
|
+
// "averageOpenPrice": 1,
|
|
2640
|
+
// "pnl24H": 1,
|
|
2641
|
+
// "fee24H": 1,
|
|
2642
|
+
// "markPrice": 1,
|
|
2643
|
+
// "estLiqPrice": 1,
|
|
2644
|
+
// "timestamp": 12321321
|
|
2645
|
+
// }
|
|
2646
|
+
//
|
|
2647
|
+
const contract = this.safeString(position, 'symbol');
|
|
2648
|
+
market = this.safeMarket(contract, market);
|
|
2649
|
+
let size = this.safeString(position, 'holding');
|
|
2650
|
+
let side = undefined;
|
|
2651
|
+
if (Precise["default"].stringGt(size, '0')) {
|
|
2652
|
+
side = 'long';
|
|
2653
|
+
}
|
|
2654
|
+
else {
|
|
2655
|
+
side = 'short';
|
|
2656
|
+
}
|
|
2657
|
+
const contractSize = this.safeString(market, 'contractSize');
|
|
2658
|
+
const markPrice = this.safeString(position, 'markPrice');
|
|
2659
|
+
const timestamp = this.safeTimestamp(position, 'timestamp');
|
|
2660
|
+
const entryPrice = this.safeString(position, 'averageOpenPrice');
|
|
2661
|
+
const priceDifference = Precise["default"].stringSub(markPrice, entryPrice);
|
|
2662
|
+
const unrealisedPnl = Precise["default"].stringMul(priceDifference, size);
|
|
2663
|
+
size = Precise["default"].stringAbs(size);
|
|
2664
|
+
const notional = Precise["default"].stringMul(size, markPrice);
|
|
2665
|
+
return this.safePosition({
|
|
2666
|
+
'info': position,
|
|
2667
|
+
'id': undefined,
|
|
2668
|
+
'symbol': this.safeString(market, 'symbol'),
|
|
2669
|
+
'timestamp': timestamp,
|
|
2670
|
+
'datetime': this.iso8601(timestamp),
|
|
2671
|
+
'lastUpdateTimestamp': undefined,
|
|
2672
|
+
'initialMargin': undefined,
|
|
2673
|
+
'initialMarginPercentage': undefined,
|
|
2674
|
+
'maintenanceMargin': undefined,
|
|
2675
|
+
'maintenanceMarginPercentage': undefined,
|
|
2676
|
+
'entryPrice': this.parseNumber(entryPrice),
|
|
2677
|
+
'notional': this.parseNumber(notional),
|
|
2678
|
+
'leverage': undefined,
|
|
2679
|
+
'unrealizedPnl': this.parseNumber(unrealisedPnl),
|
|
2680
|
+
'contracts': this.parseNumber(size),
|
|
2681
|
+
'contractSize': this.parseNumber(contractSize),
|
|
2682
|
+
'marginRatio': undefined,
|
|
2683
|
+
'liquidationPrice': this.safeNumber(position, 'estLiqPrice'),
|
|
2684
|
+
'markPrice': this.parseNumber(markPrice),
|
|
2685
|
+
'lastPrice': undefined,
|
|
2686
|
+
'collateral': undefined,
|
|
2687
|
+
'marginMode': 'cross',
|
|
2688
|
+
'marginType': undefined,
|
|
2689
|
+
'side': side,
|
|
2690
|
+
'percentage': undefined,
|
|
2691
|
+
'hedged': undefined,
|
|
2692
|
+
'stopLossPrice': undefined,
|
|
2693
|
+
'takeProfitPrice': undefined,
|
|
2694
|
+
});
|
|
2695
|
+
}
|
|
2696
|
+
defaultNetworkCodeForCurrency(code) {
|
|
2697
|
+
const currencyItem = this.currency(code);
|
|
2698
|
+
const networks = currencyItem['networks'];
|
|
2699
|
+
const networkKeys = Object.keys(networks);
|
|
2700
|
+
for (let i = 0; i < networkKeys.length; i++) {
|
|
2701
|
+
const network = networkKeys[i];
|
|
2702
|
+
if (network === 'ETH') {
|
|
2703
|
+
return network;
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
// if it was not returned according to above options, then return the first network of currency
|
|
2707
|
+
return this.safeValue(networkKeys, 0);
|
|
2708
|
+
}
|
|
2709
|
+
setSandboxMode(enable) {
|
|
2710
|
+
super.setSandboxMode(enable);
|
|
2711
|
+
this.options['sandboxMode'] = enable;
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2715
|
+
module.exports = woo;
|