ccxt 4.4.58 → 4.4.59
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 +29 -32
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -6
- package/dist/cjs/src/abstract/ace.js +1 -1
- package/dist/cjs/src/abstract/alpaca.js +1 -1
- package/dist/cjs/src/abstract/ascendex.js +1 -1
- package/dist/cjs/src/abstract/bigone.js +1 -1
- package/dist/cjs/src/abstract/binance.js +1 -1
- package/dist/cjs/src/abstract/bingx.js +1 -1
- package/dist/cjs/src/abstract/bit2c.js +1 -1
- package/dist/cjs/src/abstract/bitbank.js +1 -1
- package/dist/cjs/src/abstract/bitbns.js +1 -1
- package/dist/cjs/src/abstract/bitfinex.js +1 -1
- package/dist/cjs/src/abstract/bitfinex1.js +1 -1
- package/dist/cjs/src/abstract/bitflyer.js +1 -1
- package/dist/cjs/src/abstract/bitget.js +1 -1
- package/dist/cjs/src/abstract/bithumb.js +1 -1
- package/dist/cjs/src/abstract/bitmart.js +1 -1
- package/dist/cjs/src/abstract/bitmex.js +1 -1
- package/dist/cjs/src/abstract/bitopro.js +1 -1
- package/dist/cjs/src/abstract/bitrue.js +1 -1
- package/dist/cjs/src/abstract/bitso.js +1 -1
- package/dist/cjs/src/abstract/bitstamp.js +1 -1
- package/dist/cjs/src/abstract/bitteam.js +1 -1
- package/dist/cjs/src/abstract/bitvavo.js +1 -1
- package/dist/cjs/src/abstract/bl3p.js +1 -1
- package/dist/cjs/src/abstract/blockchaincom.js +1 -1
- package/dist/cjs/src/abstract/blofin.js +1 -1
- package/dist/cjs/src/abstract/btcalpha.js +1 -1
- package/dist/cjs/src/abstract/btcbox.js +1 -1
- package/dist/cjs/src/abstract/btcmarkets.js +1 -1
- package/dist/cjs/src/abstract/btcturk.js +1 -1
- package/dist/cjs/src/abstract/bybit.js +1 -1
- package/dist/cjs/src/abstract/cex.js +1 -1
- package/dist/cjs/src/abstract/coinbase.js +1 -1
- package/dist/cjs/src/abstract/coinbaseexchange.js +1 -1
- package/dist/cjs/src/abstract/coinbaseinternational.js +1 -1
- package/dist/cjs/src/abstract/coincatch.js +1 -1
- package/dist/cjs/src/abstract/coincheck.js +1 -1
- package/dist/cjs/src/abstract/coinex.js +1 -1
- package/dist/cjs/src/abstract/coinlist.js +1 -1
- package/dist/cjs/src/abstract/coinmate.js +1 -1
- package/dist/cjs/src/abstract/coinmetro.js +1 -1
- package/dist/cjs/src/abstract/coinone.js +1 -1
- package/dist/cjs/src/abstract/coinsph.js +1 -1
- package/dist/cjs/src/abstract/coinspot.js +1 -1
- package/dist/cjs/src/abstract/cryptocom.js +1 -1
- package/dist/cjs/src/abstract/currencycom.js +1 -1
- package/dist/cjs/src/abstract/defx.js +1 -1
- package/dist/cjs/src/abstract/delta.js +1 -1
- package/dist/cjs/src/abstract/deribit.js +1 -1
- package/dist/cjs/src/abstract/digifinex.js +1 -1
- package/dist/cjs/src/abstract/ellipx.js +1 -1
- package/dist/cjs/src/abstract/exmo.js +1 -1
- package/dist/cjs/src/abstract/gate.js +1 -1
- package/dist/cjs/src/abstract/gemini.js +1 -1
- package/dist/cjs/src/abstract/hashkey.js +1 -1
- package/dist/cjs/src/abstract/hitbtc.js +1 -1
- package/dist/cjs/src/abstract/hollaex.js +1 -1
- package/dist/cjs/src/abstract/htx.js +1 -1
- package/dist/cjs/src/abstract/huobijp.js +1 -1
- package/dist/cjs/src/abstract/hyperliquid.js +1 -1
- package/dist/cjs/src/abstract/idex.js +1 -1
- package/dist/cjs/src/abstract/independentreserve.js +1 -1
- package/dist/cjs/src/abstract/indodax.js +1 -1
- package/dist/cjs/src/abstract/kraken.js +1 -1
- package/dist/cjs/src/abstract/krakenfutures.js +1 -1
- package/dist/cjs/src/abstract/kucoin.js +1 -1
- package/dist/cjs/src/abstract/kucoinfutures.js +1 -1
- package/dist/cjs/src/abstract/kuna.js +1 -1
- package/dist/cjs/src/abstract/latoken.js +1 -1
- package/dist/cjs/src/abstract/lbank.js +1 -1
- package/dist/cjs/src/abstract/luno.js +1 -1
- package/dist/cjs/src/abstract/mercado.js +1 -1
- package/dist/cjs/src/abstract/mexc.js +1 -1
- package/dist/cjs/src/abstract/ndax.js +1 -1
- package/dist/cjs/src/abstract/novadax.js +1 -1
- package/dist/cjs/src/abstract/oceanex.js +1 -1
- package/dist/cjs/src/abstract/okcoin.js +1 -1
- package/dist/cjs/src/abstract/okx.js +1 -1
- package/dist/cjs/src/abstract/onetrading.js +1 -1
- package/dist/cjs/src/abstract/oxfun.js +1 -1
- package/dist/cjs/src/abstract/p2b.js +1 -1
- package/dist/cjs/src/abstract/paradex.js +1 -1
- package/dist/cjs/src/abstract/paymium.js +1 -1
- package/dist/cjs/src/abstract/phemex.js +1 -1
- package/dist/cjs/src/abstract/poloniex.js +1 -1
- package/dist/cjs/src/abstract/poloniexfutures.js +1 -1
- package/dist/cjs/src/abstract/probit.js +1 -1
- package/dist/cjs/src/abstract/timex.js +1 -1
- package/dist/cjs/src/abstract/tokocrypto.js +1 -1
- package/dist/cjs/src/abstract/tradeogre.js +1 -1
- package/dist/cjs/src/abstract/upbit.js +1 -1
- package/dist/cjs/src/abstract/vertex.js +1 -1
- package/dist/cjs/src/abstract/wavesexchange.js +1 -1
- package/dist/cjs/src/abstract/wazirx.js +1 -1
- package/dist/cjs/src/abstract/whitebit.js +1 -1
- package/dist/cjs/src/abstract/woo.js +1 -1
- package/dist/cjs/src/abstract/woofipro.js +1 -1
- package/dist/cjs/src/abstract/xt.js +1 -1
- package/dist/cjs/src/abstract/yobit.js +1 -1
- package/dist/cjs/src/abstract/zaif.js +1 -1
- package/dist/cjs/src/abstract/zonda.js +1 -1
- package/dist/cjs/src/ace.js +1 -1
- package/dist/cjs/src/alpaca.js +2 -2
- package/dist/cjs/src/ascendex.js +1 -1
- package/dist/cjs/src/base/Exchange.js +2 -1
- package/dist/cjs/src/base/Precise.js +6 -0
- package/dist/cjs/src/base/errors.js +6 -0
- package/dist/cjs/src/base/functions/crypto.js +1 -1
- package/dist/cjs/src/base/functions/encode.js +1 -1
- package/dist/cjs/src/base/functions/misc.js +1 -0
- package/dist/cjs/src/base/functions/number.js +6 -0
- package/dist/cjs/src/base/functions/platform.js +6 -0
- package/dist/cjs/src/base/functions/rsa.js +1 -0
- package/dist/cjs/src/base/functions/string.js +6 -0
- package/dist/cjs/src/base/functions/throttle.js +1 -1
- package/dist/cjs/src/base/functions/time.js +6 -0
- package/dist/cjs/src/base/functions/totp.js +1 -0
- package/dist/cjs/src/base/functions/type.js +6 -0
- package/dist/cjs/src/base/functions.js +1 -1
- package/dist/cjs/src/base/ws/Cache.js +6 -0
- package/dist/cjs/src/base/ws/Client.js +1 -0
- package/dist/cjs/src/base/ws/Future.js +1 -1
- package/dist/cjs/src/base/ws/OrderBook.js +1 -1
- package/dist/cjs/src/base/ws/OrderBookSide.js +6 -0
- package/dist/cjs/src/base/ws/WsClient.js +1 -1
- package/dist/cjs/src/bequant.js +1 -1
- package/dist/cjs/src/bigone.js +3 -3
- package/dist/cjs/src/binance.js +1 -1
- package/dist/cjs/src/binancecoinm.js +1 -1
- package/dist/cjs/src/binanceus.js +1 -1
- package/dist/cjs/src/binanceusdm.js +1 -1
- package/dist/cjs/src/bingx.js +1 -1
- package/dist/cjs/src/bit2c.js +8 -8
- package/dist/cjs/src/bitbank.js +1 -1
- package/dist/cjs/src/bitbns.js +1 -1
- package/dist/cjs/src/bitcoincom.js +1 -1
- package/dist/cjs/src/bitfinex.js +1 -1
- package/dist/cjs/src/bitfinex1.js +1 -1
- package/dist/cjs/src/bitflyer.js +1 -1
- package/dist/cjs/src/bitget.js +2 -2
- package/dist/cjs/src/bithumb.js +1 -1
- package/dist/cjs/src/bitmart.js +149 -95
- package/dist/cjs/src/bitmex.js +1 -1
- package/dist/cjs/src/bitopro.js +1 -1
- package/dist/cjs/src/bitpanda.js +1 -1
- package/dist/cjs/src/bitrue.js +1 -1
- package/dist/cjs/src/bitso.js +1 -1
- package/dist/cjs/src/bitstamp.js +1 -1
- package/dist/cjs/src/bitteam.js +1 -1
- package/dist/cjs/src/bl3p.js +1 -1
- package/dist/cjs/src/blockchaincom.js +1 -1
- package/dist/cjs/src/blofin.js +1 -1
- package/dist/cjs/src/btcalpha.js +1 -1
- package/dist/cjs/src/btcbox.js +1 -1
- package/dist/cjs/src/btcmarkets.js +1 -1
- package/dist/cjs/src/btcturk.js +1 -1
- package/dist/cjs/src/bybit.js +2 -2
- package/dist/cjs/src/cex.js +1 -1
- package/dist/cjs/src/coinbase.js +1 -1
- package/dist/cjs/src/coinbaseadvanced.js +1 -1
- package/dist/cjs/src/coinbaseinternational.js +1 -1
- package/dist/cjs/src/coincatch.js +1 -1
- package/dist/cjs/src/coincheck.js +1 -1
- package/dist/cjs/src/coinex.js +1 -1
- package/dist/cjs/src/coinlist.js +1 -0
- package/dist/cjs/src/coinmate.js +1 -1
- package/dist/cjs/src/coinmetro.js +1 -1
- package/dist/cjs/src/coinone.js +1 -1
- package/dist/cjs/src/coinsph.js +1 -0
- package/dist/cjs/src/coinspot.js +1 -1
- package/dist/cjs/src/cryptocom.js +1 -1
- package/dist/cjs/src/currencycom.js +1 -1
- package/dist/cjs/src/defx.js +1 -1
- package/dist/cjs/src/delta.js +1 -1
- package/dist/cjs/src/deribit.js +1 -1
- package/dist/cjs/src/digifinex.js +1 -1
- package/dist/cjs/src/ellipx.js +1 -1
- package/dist/cjs/src/exmo.js +1 -1
- package/dist/cjs/src/fmfwio.js +1 -1
- package/dist/cjs/src/gate.js +1 -1
- package/dist/cjs/src/gateio.js +1 -1
- package/dist/cjs/src/gemini.js +1 -1
- package/dist/cjs/src/hashkey.js +1 -1
- package/dist/cjs/src/hitbtc.js +2 -1
- package/dist/cjs/src/hollaex.js +1 -1
- package/dist/cjs/src/htx.js +1 -1
- package/dist/cjs/src/huobi.js +1 -1
- package/dist/cjs/src/huobijp.js +1 -1
- package/dist/cjs/src/hyperliquid.js +87 -2
- package/dist/cjs/src/idex.js +1 -1
- package/dist/cjs/src/independentreserve.js +1 -1
- package/dist/cjs/src/indodax.js +1 -1
- package/dist/cjs/src/kraken.js +1 -1
- package/dist/cjs/src/krakenfutures.js +1 -1
- package/dist/cjs/src/kucoin.js +1 -1
- package/dist/cjs/src/kucoinfutures.js +1 -1
- package/dist/cjs/src/kuna.js +1 -1
- package/dist/cjs/src/latoken.js +1 -1
- package/dist/cjs/src/lbank.js +1 -1
- package/dist/cjs/src/luno.js +1 -1
- package/dist/cjs/src/mercado.js +1 -1
- package/dist/cjs/src/mexc.js +1 -1
- package/dist/cjs/src/myokx.js +1 -1
- package/dist/cjs/src/ndax.js +1 -1
- package/dist/cjs/src/novadax.js +1 -1
- package/dist/cjs/src/oceanex.js +1 -1
- package/dist/cjs/src/okcoin.js +1 -1
- package/dist/cjs/src/okx.js +1 -1
- package/dist/cjs/src/onetrading.js +1 -1
- package/dist/cjs/src/oxfun.js +1 -1
- package/dist/cjs/src/p2b.js +1 -1
- package/dist/cjs/src/paradex.js +1 -1
- package/dist/cjs/src/paymium.js +1 -1
- package/dist/cjs/src/poloniex.js +1 -1
- package/dist/cjs/src/poloniexfutures.js +1 -1
- package/dist/cjs/src/pro/alpaca.js +1 -1
- package/dist/cjs/src/pro/ascendex.js +1 -1
- package/dist/cjs/src/pro/bequant.js +1 -1
- package/dist/cjs/src/pro/binancecoinm.js +1 -1
- package/dist/cjs/src/pro/binanceus.js +2 -2
- package/dist/cjs/src/pro/binanceusdm.js +1 -1
- package/dist/cjs/src/pro/bingx.js +1 -1
- package/dist/cjs/src/pro/bitcoincom.js +1 -1
- package/dist/cjs/src/pro/bitfinex.js +1 -1
- package/dist/cjs/src/pro/bitfinex1.js +1 -1
- package/dist/cjs/src/pro/bitget.js +1 -1
- package/dist/cjs/src/pro/bithumb.js +1 -1
- package/dist/cjs/src/pro/bitmart.js +1 -1
- package/dist/cjs/src/pro/bitmex.js +1 -1
- package/dist/cjs/src/pro/bitpanda.js +1 -1
- package/dist/cjs/src/pro/bitrue.js +1 -1
- package/dist/cjs/src/pro/bitstamp.js +1 -1
- package/dist/cjs/src/pro/bitvavo.js +1 -1
- package/dist/cjs/src/pro/blockchaincom.js +1 -1
- package/dist/cjs/src/pro/blofin.js +1 -1
- package/dist/cjs/src/pro/bybit.js +1 -1
- package/dist/cjs/src/pro/cex.js +1 -1
- package/dist/cjs/src/pro/coinbase.js +1 -1
- package/dist/cjs/src/pro/coinbaseadvanced.js +1 -1
- package/dist/cjs/src/pro/coinbaseexchange.js +1 -1
- package/dist/cjs/src/pro/coinbaseinternational.js +1 -1
- package/dist/cjs/src/pro/coincatch.js +1 -1
- package/dist/cjs/src/pro/coincheck.js +1 -1
- package/dist/cjs/src/pro/coinex.js +1 -1
- package/dist/cjs/src/pro/coinone.js +1 -1
- package/dist/cjs/src/pro/cryptocom.js +1 -1
- package/dist/cjs/src/pro/currencycom.js +1 -1
- package/dist/cjs/src/pro/defx.js +1 -1
- package/dist/cjs/src/pro/deribit.js +1 -1
- package/dist/cjs/src/pro/exmo.js +1 -1
- package/dist/cjs/src/pro/gate.js +1 -1
- package/dist/cjs/src/pro/gateio.js +1 -1
- package/dist/cjs/src/pro/gemini.js +1 -1
- package/dist/cjs/src/pro/hashkey.js +1 -1
- package/dist/cjs/src/pro/hitbtc.js +1 -1
- package/dist/cjs/src/pro/hollaex.js +1 -1
- package/dist/cjs/src/pro/htx.js +1 -1
- package/dist/cjs/src/pro/huobi.js +1 -1
- package/dist/cjs/src/pro/hyperliquid.js +1 -1
- package/dist/cjs/src/pro/idex.js +1 -1
- package/dist/cjs/src/pro/independentreserve.js +1 -1
- package/dist/cjs/src/pro/kraken.js +1 -1
- package/dist/cjs/src/pro/krakenfutures.js +1 -1
- package/dist/cjs/src/pro/kucoin.js +1 -1
- package/dist/cjs/src/pro/kucoinfutures.js +1 -1
- package/dist/cjs/src/pro/lbank.js +1 -0
- package/dist/cjs/src/pro/luno.js +1 -1
- package/dist/cjs/src/pro/mexc.js +1 -1
- package/dist/cjs/src/pro/myokx.js +1 -1
- package/dist/cjs/src/pro/ndax.js +1 -1
- package/dist/cjs/src/pro/okcoin.js +1 -1
- package/dist/cjs/src/pro/okx.js +1 -1
- package/dist/cjs/src/pro/onetrading.js +1 -1
- package/dist/cjs/src/pro/oxfun.js +1 -1
- package/dist/cjs/src/pro/p2b.js +1 -1
- package/dist/cjs/src/pro/paradex.js +1 -1
- package/dist/cjs/src/pro/phemex.js +1 -1
- package/dist/cjs/src/pro/poloniex.js +1 -1
- package/dist/cjs/src/pro/poloniexfutures.js +1 -1
- package/dist/cjs/src/pro/probit.js +1 -1
- package/dist/cjs/src/pro/upbit.js +1 -1
- package/dist/cjs/src/pro/wazirx.js +1 -1
- package/dist/cjs/src/pro/whitebit.js +1 -1
- package/dist/cjs/src/pro/xt.js +1 -1
- package/dist/cjs/src/probit.js +1 -1
- package/dist/cjs/src/static_dependencies/ethers/abi-coder.js +6 -0
- package/dist/cjs/src/static_dependencies/ethers/address/address.js +1 -1
- package/dist/cjs/src/static_dependencies/ethers/coders/abstract-coder.js +6 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/address.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/anonymous.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/array.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/boolean.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/bytes.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/fixed-bytes.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/null.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/number.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/string.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/tuple.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/fragments.js +6 -0
- package/dist/cjs/src/static_dependencies/ethers/hash/typed-data.js +6 -0
- package/dist/cjs/src/static_dependencies/ethers/index.js +1 -10
- package/dist/cjs/src/static_dependencies/ethers/interface.js +6 -0
- package/dist/cjs/src/static_dependencies/ethers/typed.js +6 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/base58.js +1 -13
- package/dist/cjs/src/static_dependencies/ethers/utils/data.js +1 -6
- package/dist/cjs/src/static_dependencies/ethers/utils/errors.js +1 -9
- package/dist/cjs/src/static_dependencies/ethers/utils/events.js +6 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/fixednumber.js +6 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/index.js +1 -7
- package/dist/cjs/src/static_dependencies/ethers/utils/maths.js +1 -5
- package/dist/cjs/src/static_dependencies/ethers/utils/properties.js +6 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/utf8.js +1 -8
- package/dist/cjs/src/static_dependencies/fflake/browser.js +1 -1
- package/dist/cjs/src/static_dependencies/jsencrypt/JSEncrypt.js +1 -0
- package/dist/cjs/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +1 -0
- package/dist/cjs/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +1 -1
- package/dist/cjs/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +6 -0
- package/dist/cjs/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +6 -0
- package/dist/cjs/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +6 -0
- package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +1 -0
- package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +1 -1
- package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +6 -0
- package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +1 -1
- package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +1 -1
- package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsbn/util.js +6 -0
- package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +1 -1
- package/dist/cjs/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +6 -0
- package/dist/cjs/src/static_dependencies/messagepack/msgpack.js +6 -0
- package/dist/cjs/src/static_dependencies/noble-curves/_shortw_utils.js +1 -1
- package/dist/cjs/src/static_dependencies/noble-curves/abstract/curve.js +1 -1
- package/dist/cjs/src/static_dependencies/noble-curves/abstract/edwards.js +1 -1
- package/dist/cjs/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +1 -0
- package/dist/cjs/src/static_dependencies/noble-curves/abstract/modular.js +1 -1
- package/dist/cjs/src/static_dependencies/noble-curves/abstract/montgomery.js +1 -1
- package/dist/cjs/src/static_dependencies/noble-curves/abstract/poseidon.js +1 -1
- package/dist/cjs/src/static_dependencies/noble-curves/abstract/utils.js +6 -0
- package/dist/cjs/src/static_dependencies/noble-curves/abstract/weierstrass.js +1 -1
- package/dist/cjs/src/static_dependencies/noble-curves/ed25519.js +1 -1
- package/dist/cjs/src/static_dependencies/noble-curves/p256.js +1 -1
- package/dist/cjs/src/static_dependencies/noble-curves/secp256k1.js +1 -1
- package/dist/cjs/src/static_dependencies/noble-hashes/_assert.js +6 -0
- package/dist/cjs/src/static_dependencies/noble-hashes/_sha2.js +1 -0
- package/dist/cjs/src/static_dependencies/noble-hashes/_u64.js +6 -0
- package/dist/cjs/src/static_dependencies/noble-hashes/crypto.js +6 -0
- package/dist/cjs/src/static_dependencies/noble-hashes/hmac.js +1 -0
- package/dist/cjs/src/static_dependencies/noble-hashes/md5.js +1 -0
- package/dist/cjs/src/static_dependencies/noble-hashes/sha1.js +1 -0
- package/dist/cjs/src/static_dependencies/noble-hashes/sha256.js +1 -0
- package/dist/cjs/src/static_dependencies/noble-hashes/sha3.js +1 -0
- package/dist/cjs/src/static_dependencies/noble-hashes/sha512.js +1 -0
- package/dist/cjs/src/static_dependencies/noble-hashes/utils.js +1 -1
- package/dist/cjs/src/static_dependencies/node-fetch/body.js +1 -5
- package/dist/cjs/src/static_dependencies/node-fetch/errors/abort-error.js +1 -0
- package/dist/cjs/src/static_dependencies/node-fetch/errors/base.js +6 -0
- package/dist/cjs/src/static_dependencies/node-fetch/errors/fetch-error.js +1 -0
- package/dist/cjs/src/static_dependencies/node-fetch/headers.js +1 -5
- package/dist/cjs/src/static_dependencies/node-fetch/index.js +1 -7
- package/dist/cjs/src/static_dependencies/node-fetch/request.js +1 -7
- package/dist/cjs/src/static_dependencies/node-fetch/response.js +1 -5
- package/dist/cjs/src/static_dependencies/node-fetch/utils/get-search.js +6 -0
- package/dist/cjs/src/static_dependencies/node-fetch/utils/is-redirect.js +6 -0
- package/dist/cjs/src/static_dependencies/node-fetch/utils/is.js +6 -0
- package/dist/cjs/src/static_dependencies/node-fetch/utils/referrer.js +1 -0
- package/dist/cjs/src/static_dependencies/proxies/agent-base/index.js +1 -0
- package/dist/cjs/src/static_dependencies/proxies/http-proxy-agent/index.js +1 -0
- package/dist/cjs/src/static_dependencies/proxies/https-proxy-agent/index.js +1 -0
- package/dist/cjs/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +6 -0
- package/dist/cjs/src/static_dependencies/scure-base/index.js +6 -0
- package/dist/cjs/src/static_dependencies/scure-starknet/index.js +1 -1
- package/dist/cjs/src/static_dependencies/starknet/constants.js +1 -1
- package/dist/cjs/src/static_dependencies/starknet/types/calldata.js +6 -0
- package/dist/cjs/src/static_dependencies/starknet/types/lib/contract/abi.js +6 -0
- package/dist/cjs/src/static_dependencies/starknet/types/lib/contract/index.js +6 -0
- package/dist/cjs/src/static_dependencies/starknet/types/lib/index.js +6 -0
- package/dist/cjs/src/static_dependencies/starknet/types/typedData.js +6 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/assert.js +6 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/cairoDataTypes/felt.js +1 -1
- package/dist/cjs/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.js +1 -1
- package/dist/cjs/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.js +1 -1
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/byteArray.js +1 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/cairo.js +1 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +6 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +6 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +6 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/formatter.js +1 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/index.js +1 -1
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/index.js +1 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +1 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +6 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +1 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/requestParser.js +1 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/responseParser.js +1 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/tuple.js +1 -1
- package/dist/cjs/src/static_dependencies/starknet/utils/calldata/validate.js +1 -4
- package/dist/cjs/src/static_dependencies/starknet/utils/encode.js +1 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/hash/classHash.js +1 -3
- package/dist/cjs/src/static_dependencies/starknet/utils/merkle.js +1 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/num.js +1 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/selector.js +1 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/shortString.js +1 -0
- package/dist/cjs/src/static_dependencies/starknet/utils/typedData.js +1 -1
- package/dist/cjs/src/static_dependencies/watchable/src/unpromise.js +6 -0
- package/dist/cjs/src/timex.js +1 -0
- package/dist/cjs/src/tokocrypto.js +1 -1
- package/dist/cjs/src/tradeogre.js +1 -1
- package/dist/cjs/src/upbit.js +1 -1
- package/dist/cjs/src/vertex.js +2 -2
- package/dist/cjs/src/wavesexchange.js +1 -1
- package/dist/cjs/src/wazirx.js +1 -0
- package/dist/cjs/src/whitebit.js +1 -1
- package/dist/cjs/src/woo.js +1 -1
- package/dist/cjs/src/woofipro.js +1 -1
- package/dist/cjs/src/xt.js +1 -1
- package/dist/cjs/src/yobit.js +1 -1
- package/dist/cjs/src/zaif.js +1 -1
- package/dist/cjs/src/zonda.js +1 -1
- package/js/ccxt.d.ts +2 -8
- package/js/ccxt.js +8 -6
- package/js/src/abstract/ace.js +6 -0
- package/js/src/abstract/alpaca.js +6 -0
- package/js/src/abstract/ascendex.js +6 -0
- package/js/src/abstract/bequant.js +6 -0
- package/js/src/abstract/bigone.js +6 -0
- package/js/src/abstract/binance.js +6 -0
- package/js/src/abstract/binancecoinm.js +6 -0
- package/js/src/abstract/binanceus.js +6 -0
- package/js/src/abstract/binanceusdm.js +6 -0
- package/js/src/abstract/bingx.js +6 -0
- package/js/src/abstract/bit2c.js +6 -0
- package/js/src/abstract/bitbank.js +6 -0
- package/js/src/abstract/bitbns.js +6 -0
- package/js/src/abstract/bitcoincom.js +6 -0
- package/js/src/abstract/bitfinex.js +6 -0
- package/js/src/abstract/bitfinex1.js +6 -0
- package/js/src/abstract/bitflyer.js +6 -0
- package/js/src/abstract/bitget.js +6 -0
- package/js/src/abstract/bithumb.js +6 -0
- package/js/src/abstract/bitmart.js +6 -0
- package/js/src/abstract/bitmex.js +6 -0
- package/js/src/abstract/bitopro.js +6 -0
- package/js/src/abstract/bitpanda.js +6 -0
- package/js/src/abstract/bitrue.js +6 -0
- package/js/src/abstract/bitso.js +6 -0
- package/js/src/abstract/bitstamp.js +6 -0
- package/js/src/abstract/bitteam.js +6 -0
- package/js/src/abstract/bitvavo.js +6 -0
- package/js/src/abstract/bl3p.js +6 -0
- package/js/src/abstract/blockchaincom.js +6 -0
- package/js/src/abstract/blofin.js +6 -0
- package/js/src/abstract/btcalpha.js +6 -0
- package/js/src/abstract/btcbox.js +6 -0
- package/js/src/abstract/btcmarkets.js +6 -0
- package/js/src/abstract/btcturk.js +6 -0
- package/js/src/abstract/bybit.js +6 -0
- package/js/src/abstract/cex.js +6 -0
- package/js/src/abstract/coinbase.js +6 -0
- package/js/src/abstract/coinbaseadvanced.js +6 -0
- package/js/src/abstract/coinbaseexchange.js +6 -0
- package/js/src/abstract/coinbaseinternational.js +6 -0
- package/js/src/abstract/coincatch.js +6 -0
- package/js/src/abstract/coincheck.js +6 -0
- package/js/src/abstract/coinex.js +6 -0
- package/js/src/abstract/coinlist.js +6 -0
- package/js/src/abstract/coinmate.js +6 -0
- package/js/src/abstract/coinmetro.js +6 -0
- package/js/src/abstract/coinone.js +6 -0
- package/js/src/abstract/coinsph.js +6 -0
- package/js/src/abstract/coinspot.js +6 -0
- package/js/src/abstract/cryptocom.js +6 -0
- package/js/src/abstract/currencycom.js +6 -0
- package/js/src/abstract/defx.js +6 -0
- package/js/src/abstract/delta.js +6 -0
- package/js/src/abstract/deribit.js +6 -0
- package/js/src/abstract/digifinex.js +6 -0
- package/js/src/abstract/ellipx.js +6 -0
- package/js/src/abstract/exmo.js +6 -0
- package/js/src/abstract/fmfwio.js +6 -0
- package/js/src/abstract/gate.js +6 -0
- package/js/src/abstract/gateio.js +6 -0
- package/js/src/abstract/gemini.js +6 -0
- package/js/src/abstract/hashkey.js +6 -0
- package/js/src/abstract/hitbtc.js +6 -0
- package/js/src/abstract/hollaex.js +6 -0
- package/js/src/abstract/htx.js +6 -0
- package/js/src/abstract/huobi.js +6 -0
- package/js/src/abstract/huobijp.js +6 -0
- package/js/src/abstract/hyperliquid.js +6 -0
- package/js/src/abstract/idex.js +6 -0
- package/js/src/abstract/independentreserve.js +6 -0
- package/js/src/abstract/indodax.js +6 -0
- package/js/src/abstract/kraken.js +6 -0
- package/js/src/abstract/krakenfutures.js +6 -0
- package/js/src/abstract/kucoin.js +6 -0
- package/js/src/abstract/kucoinfutures.js +6 -0
- package/js/src/abstract/kuna.js +6 -0
- package/js/src/abstract/latoken.js +6 -0
- package/js/src/abstract/lbank.js +6 -0
- package/js/src/abstract/luno.js +6 -0
- package/js/src/abstract/mercado.js +6 -0
- package/js/src/abstract/mexc.js +6 -0
- package/js/src/abstract/myokx.js +6 -0
- package/js/src/abstract/ndax.js +6 -0
- package/js/src/abstract/novadax.js +6 -0
- package/js/src/abstract/oceanex.js +6 -0
- package/js/src/abstract/okcoin.js +6 -0
- package/js/src/abstract/okx.js +6 -0
- package/js/src/abstract/onetrading.js +6 -0
- package/js/src/abstract/oxfun.js +6 -0
- package/js/src/abstract/p2b.js +6 -0
- package/js/src/abstract/paradex.js +6 -0
- package/js/src/abstract/paymium.js +6 -0
- package/js/src/abstract/phemex.js +6 -0
- package/js/src/abstract/poloniex.js +6 -0
- package/js/src/abstract/poloniexfutures.js +6 -0
- package/js/src/abstract/probit.js +6 -0
- package/js/src/abstract/timex.js +6 -0
- package/js/src/abstract/tokocrypto.js +6 -0
- package/js/src/abstract/tradeogre.js +6 -0
- package/js/src/abstract/upbit.js +6 -0
- package/js/src/abstract/vertex.js +6 -0
- package/js/src/abstract/wavesexchange.js +6 -0
- package/js/src/abstract/wazirx.js +6 -0
- package/js/src/abstract/whitebit.js +6 -0
- package/js/src/abstract/woo.js +6 -0
- package/js/src/abstract/woofipro.js +6 -0
- package/js/src/abstract/xt.js +6 -0
- package/js/src/abstract/yobit.js +6 -0
- package/js/src/abstract/zaif.js +6 -0
- package/js/src/abstract/zonda.js +6 -0
- package/js/src/ace.js +6 -0
- package/js/src/alpaca.d.ts +1 -1
- package/js/src/alpaca.js +7 -1
- package/js/src/ascendex.d.ts +1 -1
- package/js/src/ascendex.js +6 -0
- package/js/src/base/Exchange.d.ts +1 -331
- package/js/src/base/Exchange.js +8 -1
- package/js/src/base/Precise.js +6 -0
- package/js/src/base/errorHierarchy.js +6 -0
- package/js/src/base/errors.js +6 -0
- package/js/src/base/functions/crypto.js +6 -0
- package/js/src/base/functions/encode.js +6 -0
- package/js/src/base/functions/generic.js +6 -0
- package/js/src/base/functions/misc.js +6 -0
- package/js/src/base/functions/number.js +6 -0
- package/js/src/base/functions/platform.js +6 -0
- package/js/src/base/functions/rsa.js +6 -0
- package/js/src/base/functions/string.js +6 -0
- package/js/src/base/functions/throttle.js +6 -0
- package/js/src/base/functions/time.js +6 -0
- package/js/src/base/functions/totp.js +6 -0
- package/js/src/base/functions/type.js +6 -0
- package/js/src/base/functions.js +6 -0
- package/js/src/base/types.d.ts +2 -2
- package/js/src/base/types.js +6 -0
- package/js/src/base/ws/Cache.js +6 -0
- package/js/src/base/ws/Client.js +6 -0
- package/js/src/base/ws/Future.js +6 -0
- package/js/src/base/ws/OrderBook.js +6 -0
- package/js/src/base/ws/OrderBookSide.js +6 -0
- package/js/src/base/ws/WsClient.js +6 -0
- package/js/src/base/ws/functions.js +6 -0
- package/js/src/bequant.js +6 -0
- package/js/src/bigone.d.ts +1 -1
- package/js/src/bigone.js +8 -2
- package/js/src/binance.d.ts +1 -1
- package/js/src/binance.js +6 -0
- package/js/src/binancecoinm.js +6 -0
- package/js/src/binanceus.js +6 -0
- package/js/src/binanceusdm.js +6 -0
- package/js/src/bingx.d.ts +1 -1
- package/js/src/bingx.js +6 -0
- package/js/src/bit2c.js +13 -7
- package/js/src/bitbank.js +6 -0
- package/js/src/bitbns.js +6 -0
- package/js/src/bitcoincom.js +6 -0
- package/js/src/bitfinex.js +6 -0
- package/js/src/bitfinex1.js +6 -0
- package/js/src/bitflyer.js +6 -0
- package/js/src/bitget.d.ts +1 -1
- package/js/src/bitget.js +7 -1
- package/js/src/bithumb.js +6 -0
- package/js/src/bitmart.d.ts +5 -1
- package/js/src/bitmart.js +154 -94
- package/js/src/bitmex.js +6 -0
- package/js/src/bitopro.js +6 -0
- package/js/src/bitpanda.js +6 -0
- package/js/src/bitrue.d.ts +1 -1
- package/js/src/bitrue.js +6 -0
- package/js/src/bitso.js +6 -0
- package/js/src/bitstamp.js +6 -0
- package/js/src/bitteam.js +6 -0
- package/js/src/bitvavo.d.ts +1 -1
- package/js/src/bitvavo.js +6 -0
- package/js/src/bl3p.js +6 -0
- package/js/src/blockchaincom.js +6 -0
- package/js/src/blofin.js +6 -0
- package/js/src/btcalpha.js +6 -0
- package/js/src/btcbox.js +6 -0
- package/js/src/btcmarkets.d.ts +1 -1
- package/js/src/btcmarkets.js +6 -0
- package/js/src/btcturk.js +6 -0
- package/js/src/bybit.d.ts +1 -1
- package/js/src/bybit.js +7 -1
- package/js/src/cex.d.ts +1 -1
- package/js/src/cex.js +6 -0
- package/js/src/coinbase.d.ts +1 -1
- package/js/src/coinbase.js +7 -1
- package/js/src/coinbaseadvanced.js +6 -0
- package/js/src/coinbaseexchange.d.ts +2 -2
- package/js/src/coinbaseexchange.js +6 -0
- package/js/src/coinbaseinternational.js +7 -1
- package/js/src/coincatch.d.ts +1 -1
- package/js/src/coincatch.js +6 -0
- package/js/src/coincheck.js +6 -0
- package/js/src/coinex.d.ts +1 -1
- package/js/src/coinex.js +6 -0
- package/js/src/coinlist.d.ts +1 -1
- package/js/src/coinlist.js +6 -0
- package/js/src/coinmate.js +6 -0
- package/js/src/coinmetro.js +6 -0
- package/js/src/coinone.js +6 -0
- package/js/src/coinsph.d.ts +1 -1
- package/js/src/coinsph.js +6 -0
- package/js/src/coinspot.js +6 -0
- package/js/src/cryptocom.js +6 -0
- package/js/src/currencycom.d.ts +1 -1
- package/js/src/currencycom.js +6 -0
- package/js/src/defx.d.ts +1 -1
- package/js/src/defx.js +6 -0
- package/js/src/delta.d.ts +1 -1
- package/js/src/delta.js +6 -0
- package/js/src/deribit.d.ts +1 -1
- package/js/src/deribit.js +6 -0
- package/js/src/digifinex.d.ts +1 -1
- package/js/src/digifinex.js +6 -0
- package/js/src/ellipx.js +6 -0
- package/js/src/exmo.js +6 -0
- package/js/src/fmfwio.js +6 -0
- package/js/src/gate.d.ts +1 -1
- package/js/src/gate.js +6 -0
- package/js/src/gateio.js +6 -0
- package/js/src/gemini.js +6 -0
- package/js/src/hashkey.js +6 -0
- package/js/src/hitbtc.js +7 -1
- package/js/src/hollaex.js +6 -0
- package/js/src/htx.d.ts +1 -1
- package/js/src/htx.js +6 -0
- package/js/src/huobi.js +6 -0
- package/js/src/huobijp.d.ts +1 -1
- package/js/src/huobijp.js +6 -0
- package/js/src/hyperliquid.d.ts +21 -0
- package/js/src/hyperliquid.js +92 -1
- package/js/src/idex.d.ts +1 -1
- package/js/src/idex.js +6 -0
- package/js/src/independentreserve.js +6 -0
- package/js/src/indodax.d.ts +1 -1
- package/js/src/indodax.js +6 -0
- package/js/src/kraken.d.ts +1 -1
- package/js/src/kraken.js +6 -0
- package/js/src/krakenfutures.js +6 -0
- package/js/src/kucoin.d.ts +1 -1
- package/js/src/kucoin.js +6 -0
- package/js/src/kucoinfutures.d.ts +1 -1
- package/js/src/kucoinfutures.js +6 -0
- package/js/src/kuna.d.ts +1 -1
- package/js/src/kuna.js +6 -0
- package/js/src/latoken.d.ts +1 -1
- package/js/src/latoken.js +6 -0
- package/js/src/lbank.d.ts +1 -1
- package/js/src/lbank.js +6 -0
- package/js/src/luno.js +6 -0
- package/js/src/mercado.js +6 -0
- package/js/src/mexc.d.ts +1 -1
- package/js/src/mexc.js +6 -0
- package/js/src/myokx.js +6 -0
- package/js/src/ndax.js +6 -0
- package/js/src/novadax.d.ts +1 -1
- package/js/src/novadax.js +6 -0
- package/js/src/oceanex.d.ts +1 -1
- package/js/src/oceanex.js +6 -0
- package/js/src/okcoin.d.ts +1 -1
- package/js/src/okcoin.js +6 -0
- package/js/src/okx.d.ts +1 -1
- package/js/src/okx.js +6 -0
- package/js/src/onetrading.d.ts +1 -1
- package/js/src/onetrading.js +6 -0
- package/js/src/oxfun.js +6 -0
- package/js/src/p2b.js +6 -0
- package/js/src/paradex.d.ts +1 -1
- package/js/src/paradex.js +6 -0
- package/js/src/paymium.js +6 -0
- package/js/src/phemex.js +6 -0
- package/js/src/poloniex.d.ts +1 -1
- package/js/src/poloniex.js +6 -0
- package/js/src/poloniexfutures.d.ts +1 -1
- package/js/src/poloniexfutures.js +6 -0
- package/js/src/pro/alpaca.js +6 -0
- package/js/src/pro/ascendex.js +6 -0
- package/js/src/pro/bequant.js +6 -0
- package/js/src/pro/binance.js +6 -0
- package/js/src/pro/binancecoinm.js +6 -0
- package/js/src/pro/binanceus.js +7 -1
- package/js/src/pro/binanceusdm.js +6 -0
- package/js/src/pro/bingx.js +6 -0
- package/js/src/pro/bitcoincom.js +6 -0
- package/js/src/pro/bitfinex.js +6 -0
- package/js/src/pro/bitfinex1.js +6 -0
- package/js/src/pro/bitget.js +6 -0
- package/js/src/pro/bithumb.js +6 -0
- package/js/src/pro/bitmart.js +6 -0
- package/js/src/pro/bitmex.js +6 -0
- package/js/src/pro/bitopro.js +6 -0
- package/js/src/pro/bitpanda.js +6 -0
- package/js/src/pro/bitrue.js +6 -0
- package/js/src/pro/bitstamp.js +6 -0
- package/js/src/pro/bitvavo.js +6 -0
- package/js/src/pro/blockchaincom.js +6 -0
- package/js/src/pro/blofin.js +6 -0
- package/js/src/pro/bybit.js +6 -0
- package/js/src/pro/cex.js +6 -0
- package/js/src/pro/coinbase.js +6 -0
- package/js/src/pro/coinbaseadvanced.js +6 -0
- package/js/src/pro/coinbaseexchange.js +6 -0
- package/js/src/pro/coinbaseinternational.js +6 -0
- package/js/src/pro/coincatch.js +6 -0
- package/js/src/pro/coincheck.js +6 -0
- package/js/src/pro/coinex.js +6 -0
- package/js/src/pro/coinone.js +6 -0
- package/js/src/pro/cryptocom.js +6 -0
- package/js/src/pro/currencycom.js +6 -0
- package/js/src/pro/defx.js +6 -0
- package/js/src/pro/deribit.js +6 -0
- package/js/src/pro/exmo.js +6 -0
- package/js/src/pro/gate.js +6 -0
- package/js/src/pro/gateio.js +6 -0
- package/js/src/pro/gemini.js +6 -0
- package/js/src/pro/hashkey.js +6 -0
- package/js/src/pro/hitbtc.js +6 -0
- package/js/src/pro/hollaex.js +6 -0
- package/js/src/pro/htx.js +6 -0
- package/js/src/pro/huobi.js +6 -0
- package/js/src/pro/huobijp.js +6 -0
- package/js/src/pro/hyperliquid.js +6 -0
- package/js/src/pro/idex.js +6 -0
- package/js/src/pro/independentreserve.js +6 -0
- package/js/src/pro/kraken.js +6 -0
- package/js/src/pro/krakenfutures.js +6 -0
- package/js/src/pro/kucoin.js +6 -0
- package/js/src/pro/kucoinfutures.js +6 -0
- package/js/src/pro/lbank.js +6 -0
- package/js/src/pro/luno.js +6 -0
- package/js/src/pro/mexc.js +6 -0
- package/js/src/pro/myokx.js +6 -0
- package/js/src/pro/ndax.js +6 -0
- package/js/src/pro/okcoin.js +6 -0
- package/js/src/pro/okx.js +6 -0
- package/js/src/pro/onetrading.js +6 -0
- package/js/src/pro/oxfun.js +6 -0
- package/js/src/pro/p2b.js +6 -0
- package/js/src/pro/paradex.js +6 -0
- package/js/src/pro/phemex.js +6 -0
- package/js/src/pro/poloniex.js +6 -0
- package/js/src/pro/poloniexfutures.js +6 -0
- package/js/src/pro/probit.js +6 -0
- package/js/src/pro/upbit.js +6 -0
- package/js/src/pro/vertex.js +6 -0
- package/js/src/pro/wazirx.js +6 -0
- package/js/src/pro/whitebit.js +6 -0
- package/js/src/pro/woo.js +6 -0
- package/js/src/pro/woofipro.js +6 -0
- package/js/src/pro/xt.js +6 -0
- package/js/src/probit.d.ts +1 -1
- package/js/src/probit.js +6 -0
- package/js/src/static_dependencies/ethers/abi-coder.js +6 -0
- package/js/src/static_dependencies/ethers/address/address.js +6 -0
- package/js/src/static_dependencies/ethers/address/checks.js +6 -0
- package/js/src/static_dependencies/ethers/address/contract-address.js +6 -0
- package/js/src/static_dependencies/ethers/address/index.js +6 -0
- package/js/src/static_dependencies/ethers/bytes32.js +6 -0
- package/js/src/static_dependencies/ethers/coders/abstract-coder.js +6 -0
- package/js/src/static_dependencies/ethers/coders/address.js +6 -0
- package/js/src/static_dependencies/ethers/coders/anonymous.js +6 -0
- package/js/src/static_dependencies/ethers/coders/array.js +6 -0
- package/js/src/static_dependencies/ethers/coders/boolean.js +6 -0
- package/js/src/static_dependencies/ethers/coders/bytes.js +6 -0
- package/js/src/static_dependencies/ethers/coders/fixed-bytes.js +6 -0
- package/js/src/static_dependencies/ethers/coders/null.js +6 -0
- package/js/src/static_dependencies/ethers/coders/number.js +6 -0
- package/js/src/static_dependencies/ethers/coders/string.js +6 -0
- package/js/src/static_dependencies/ethers/coders/tuple.js +6 -0
- package/js/src/static_dependencies/ethers/fragments.js +6 -0
- package/js/src/static_dependencies/ethers/hash/index.js +6 -0
- package/js/src/static_dependencies/ethers/hash/solidity.js +6 -0
- package/js/src/static_dependencies/ethers/hash/typed-data.js +6 -0
- package/js/src/static_dependencies/ethers/index.js +6 -0
- package/js/src/static_dependencies/ethers/interface.js +6 -0
- package/js/src/static_dependencies/ethers/typed.js +6 -0
- package/js/src/static_dependencies/ethers/utils/base58.js +6 -0
- package/js/src/static_dependencies/ethers/utils/base64-browser.js +6 -0
- package/js/src/static_dependencies/ethers/utils/base64.js +6 -0
- package/js/src/static_dependencies/ethers/utils/data.js +6 -0
- package/js/src/static_dependencies/ethers/utils/errors.js +6 -0
- package/js/src/static_dependencies/ethers/utils/events.js +6 -0
- package/js/src/static_dependencies/ethers/utils/fixednumber.js +6 -0
- package/js/src/static_dependencies/ethers/utils/index.js +6 -0
- package/js/src/static_dependencies/ethers/utils/maths.js +6 -0
- package/js/src/static_dependencies/ethers/utils/properties.js +6 -0
- package/js/src/static_dependencies/ethers/utils/rlp-decode.js +6 -0
- package/js/src/static_dependencies/ethers/utils/rlp-encode.js +6 -0
- package/js/src/static_dependencies/ethers/utils/rlp.js +6 -0
- package/js/src/static_dependencies/ethers/utils/units.js +6 -0
- package/js/src/static_dependencies/ethers/utils/utf8.js +6 -0
- package/js/src/static_dependencies/ethers/utils/uuid.js +6 -0
- package/js/src/static_dependencies/fflake/browser.js +6 -0
- package/js/src/static_dependencies/jsencrypt/JSEncrypt.js +6 -0
- package/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +6 -0
- package/js/src/static_dependencies/jsencrypt/index.js +6 -0
- package/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +6 -0
- package/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +6 -0
- package/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +6 -0
- package/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +6 -0
- package/js/src/static_dependencies/jsencrypt/lib/asn1js/oids.js +6 -0
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +6 -0
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +6 -0
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +6 -0
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +6 -0
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +6 -0
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +6 -0
- package/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +6 -0
- package/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +6 -0
- package/js/src/static_dependencies/messagepack/msgpack.js +6 -0
- package/js/src/static_dependencies/noble-curves/_shortw_utils.js +6 -0
- package/js/src/static_dependencies/noble-curves/abstract/curve.js +6 -0
- package/js/src/static_dependencies/noble-curves/abstract/edwards.js +6 -0
- package/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +6 -0
- package/js/src/static_dependencies/noble-curves/abstract/modular.js +6 -0
- package/js/src/static_dependencies/noble-curves/abstract/montgomery.js +6 -0
- package/js/src/static_dependencies/noble-curves/abstract/poseidon.js +6 -0
- package/js/src/static_dependencies/noble-curves/abstract/utils.js +6 -0
- package/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +6 -0
- package/js/src/static_dependencies/noble-curves/bn.js +6 -0
- package/js/src/static_dependencies/noble-curves/ed25519.js +6 -0
- package/js/src/static_dependencies/noble-curves/ed448.js +6 -0
- package/js/src/static_dependencies/noble-curves/index.js +6 -0
- package/js/src/static_dependencies/noble-curves/jubjub.js +6 -0
- package/js/src/static_dependencies/noble-curves/p256.js +6 -0
- package/js/src/static_dependencies/noble-curves/p384.js +6 -0
- package/js/src/static_dependencies/noble-curves/p521.js +6 -0
- package/js/src/static_dependencies/noble-curves/pasta.js +6 -0
- package/js/src/static_dependencies/noble-curves/secp256k1.js +6 -0
- package/js/src/static_dependencies/noble-hashes/_assert.js +6 -0
- package/js/src/static_dependencies/noble-hashes/_blake2.js +6 -0
- package/js/src/static_dependencies/noble-hashes/_sha2.js +6 -0
- package/js/src/static_dependencies/noble-hashes/_u64.js +6 -0
- package/js/src/static_dependencies/noble-hashes/argon2.js +6 -0
- package/js/src/static_dependencies/noble-hashes/blake2b.js +6 -0
- package/js/src/static_dependencies/noble-hashes/blake2s.js +6 -0
- package/js/src/static_dependencies/noble-hashes/blake3.js +6 -0
- package/js/src/static_dependencies/noble-hashes/crypto.js +6 -0
- package/js/src/static_dependencies/noble-hashes/cryptoNode.js +6 -0
- package/js/src/static_dependencies/noble-hashes/eskdf.js +6 -0
- package/js/src/static_dependencies/noble-hashes/hkdf.js +6 -0
- package/js/src/static_dependencies/noble-hashes/hmac.js +6 -0
- package/js/src/static_dependencies/noble-hashes/index.js +6 -0
- package/js/src/static_dependencies/noble-hashes/md5.js +6 -0
- package/js/src/static_dependencies/noble-hashes/pbkdf2.js +6 -0
- package/js/src/static_dependencies/noble-hashes/ripemd160.js +6 -0
- package/js/src/static_dependencies/noble-hashes/scrypt.js +6 -0
- package/js/src/static_dependencies/noble-hashes/sha1.js +6 -0
- package/js/src/static_dependencies/noble-hashes/sha256.js +6 -0
- package/js/src/static_dependencies/noble-hashes/sha3-addons.js +6 -0
- package/js/src/static_dependencies/noble-hashes/sha3.js +6 -0
- package/js/src/static_dependencies/noble-hashes/sha512.js +6 -0
- package/js/src/static_dependencies/noble-hashes/utils.js +6 -0
- package/js/src/static_dependencies/node-fetch/body.js +6 -0
- package/js/src/static_dependencies/node-fetch/errors/abort-error.js +6 -0
- package/js/src/static_dependencies/node-fetch/errors/base.js +6 -0
- package/js/src/static_dependencies/node-fetch/errors/fetch-error.js +6 -0
- package/js/src/static_dependencies/node-fetch/headers.js +6 -0
- package/js/src/static_dependencies/node-fetch/index.js +6 -0
- package/js/src/static_dependencies/node-fetch/request.js +6 -0
- package/js/src/static_dependencies/node-fetch/response.js +6 -0
- package/js/src/static_dependencies/node-fetch/utils/get-search.js +6 -0
- package/js/src/static_dependencies/node-fetch/utils/is-redirect.js +6 -0
- package/js/src/static_dependencies/node-fetch/utils/is.js +6 -0
- package/js/src/static_dependencies/node-fetch/utils/referrer.js +6 -0
- package/js/src/static_dependencies/proxies/agent-base/helpers.js +6 -0
- package/js/src/static_dependencies/proxies/agent-base/index.js +6 -0
- package/js/src/static_dependencies/proxies/http-proxy-agent/index.js +6 -0
- package/js/src/static_dependencies/proxies/https-proxy-agent/index.js +6 -0
- package/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +6 -0
- package/js/src/static_dependencies/qs/formats.cjs +6 -0
- package/js/src/static_dependencies/qs/index.cjs +6 -0
- package/js/src/static_dependencies/qs/parse.cjs +6 -0
- package/js/src/static_dependencies/qs/stringify.cjs +6 -0
- package/js/src/static_dependencies/qs/utils.cjs +6 -0
- package/js/src/static_dependencies/scure-base/index.js +6 -0
- package/js/src/static_dependencies/scure-starknet/index.js +6 -0
- package/js/src/static_dependencies/starknet/constants.js +6 -0
- package/js/src/static_dependencies/starknet/index.js +6 -0
- package/js/src/static_dependencies/starknet/types/cairoEnum.js +6 -0
- package/js/src/static_dependencies/starknet/types/calldata.js +6 -0
- package/js/src/static_dependencies/starknet/types/index.js +6 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/abi.js +6 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/index.js +6 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/legacy.js +6 -0
- package/js/src/static_dependencies/starknet/types/lib/contract/sierra.js +6 -0
- package/js/src/static_dependencies/starknet/types/lib/index.js +6 -0
- package/js/src/static_dependencies/starknet/types/typedData.js +6 -0
- package/js/src/static_dependencies/starknet/utils/address.js +6 -0
- package/js/src/static_dependencies/starknet/utils/assert.js +6 -0
- package/js/src/static_dependencies/starknet/utils/cairoDataTypes/felt.js +6 -0
- package/js/src/static_dependencies/starknet/utils/cairoDataTypes/uint256.js +6 -0
- package/js/src/static_dependencies/starknet/utils/cairoDataTypes/uint512.js +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/byteArray.js +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/cairo.js +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoCustomEnum.js +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoOption.js +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/CairoResult.js +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/enum/index.js +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/formatter.js +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/index.js +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/index.js +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/interface.js +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/parser-0-1.1.0.js +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/parser/parser-2.0.0.js +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/propertyOrder.js +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/requestParser.js +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/responseParser.js +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/tuple.js +6 -0
- package/js/src/static_dependencies/starknet/utils/calldata/validate.js +6 -0
- package/js/src/static_dependencies/starknet/utils/encode.js +6 -0
- package/js/src/static_dependencies/starknet/utils/hash/classHash.js +6 -0
- package/js/src/static_dependencies/starknet/utils/hash/index.js +6 -0
- package/js/src/static_dependencies/starknet/utils/merkle.js +6 -0
- package/js/src/static_dependencies/starknet/utils/num.js +6 -0
- package/js/src/static_dependencies/starknet/utils/selector.js +6 -0
- package/js/src/static_dependencies/starknet/utils/shortString.js +6 -0
- package/js/src/static_dependencies/starknet/utils/starknetId.js +6 -0
- package/js/src/static_dependencies/starknet/utils/typedData.js +6 -0
- package/js/src/static_dependencies/starknet/utils/uint256.js +6 -0
- package/js/src/static_dependencies/starknet/utils/url.js +6 -0
- package/js/src/static_dependencies/watchable/src/index.js +6 -0
- package/js/src/static_dependencies/watchable/src/types.js +6 -0
- package/js/src/static_dependencies/watchable/src/unpromise.js +6 -0
- package/js/src/timex.d.ts +1 -1
- package/js/src/timex.js +6 -0
- package/js/src/tokocrypto.d.ts +1 -1
- package/js/src/tokocrypto.js +6 -0
- package/js/src/tradeogre.js +6 -0
- package/js/src/upbit.js +6 -0
- package/js/src/vertex.d.ts +1 -1
- package/js/src/vertex.js +7 -1
- package/js/src/wavesexchange.js +6 -0
- package/js/src/whitebit.d.ts +1 -1
- package/js/src/whitebit.js +6 -0
- package/js/src/woo.d.ts +1 -1
- package/js/src/woo.js +6 -0
- package/js/src/woofipro.d.ts +1 -1
- package/js/src/woofipro.js +6 -0
- package/js/src/xt.d.ts +1 -1
- package/js/src/xt.js +6 -0
- package/js/src/yobit.js +6 -0
- package/js/src/zaif.js +6 -0
- package/js/src/zonda.js +6 -0
- package/package.json +1 -1
- package/js/src/bitbay.d.ts +0 -4
- package/js/src/bitbay.js +0 -18
- package/js/src/bitfinex2.d.ts +0 -506
- package/js/src/bitfinex2.js +0 -3778
- package/js/src/wazirx.d.ts +0 -216
- package/js/src/wazirx.js +0 -1362
package/js/src/bitfinex2.js
DELETED
|
@@ -1,3778 +0,0 @@
|
|
|
1
|
-
// ----------------------------------------------------------------------------
|
|
2
|
-
|
|
3
|
-
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
-
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
-
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
-
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
8
|
-
import { ExchangeError, ArgumentsRequired, InsufficientFunds, AuthenticationError, OrderNotFound, InvalidOrder, BadRequest, InvalidNonce, BadSymbol, OnMaintenance, NotSupported, PermissionDenied, ExchangeNotAvailable, RateLimitExceeded } from './base/errors.js';
|
|
9
|
-
import { Precise } from './base/Precise.js';
|
|
10
|
-
import Exchange from './abstract/bitfinex2.js';
|
|
11
|
-
import { SIGNIFICANT_DIGITS, DECIMAL_PLACES, TRUNCATE, ROUND } from './base/functions/number.js';
|
|
12
|
-
import { sha384 } from './static_dependencies/noble-hashes/sha512.js';
|
|
13
|
-
// ---------------------------------------------------------------------------
|
|
14
|
-
/**
|
|
15
|
-
* @class bitfinex2
|
|
16
|
-
* @augments Exchange
|
|
17
|
-
*/
|
|
18
|
-
export default class bitfinex2 extends Exchange {
|
|
19
|
-
describe() {
|
|
20
|
-
return this.deepExtend(super.describe(), {
|
|
21
|
-
'id': 'bitfinex2',
|
|
22
|
-
'name': 'Bitfinex',
|
|
23
|
-
'countries': ['VG'],
|
|
24
|
-
'version': 'v2',
|
|
25
|
-
'certified': false,
|
|
26
|
-
'pro': true,
|
|
27
|
-
// new metainfo interface
|
|
28
|
-
'has': {
|
|
29
|
-
'CORS': undefined,
|
|
30
|
-
'spot': true,
|
|
31
|
-
'margin': true,
|
|
32
|
-
'swap': true,
|
|
33
|
-
'future': false,
|
|
34
|
-
'option': false,
|
|
35
|
-
'addMargin': false,
|
|
36
|
-
'borrowCrossMargin': false,
|
|
37
|
-
'borrowIsolatedMargin': false,
|
|
38
|
-
'cancelAllOrders': true,
|
|
39
|
-
'cancelOrder': true,
|
|
40
|
-
'cancelOrders': true,
|
|
41
|
-
'createDepositAddress': true,
|
|
42
|
-
'createLimitOrder': true,
|
|
43
|
-
'createMarketOrder': true,
|
|
44
|
-
'createOrder': true,
|
|
45
|
-
'createPostOnlyOrder': true,
|
|
46
|
-
'createReduceOnlyOrder': true,
|
|
47
|
-
'createStopLimitOrder': true,
|
|
48
|
-
'createStopMarketOrder': true,
|
|
49
|
-
'createStopOrder': true,
|
|
50
|
-
'createTrailingAmountOrder': true,
|
|
51
|
-
'createTrailingPercentOrder': false,
|
|
52
|
-
'createTriggerOrder': true,
|
|
53
|
-
'editOrder': true,
|
|
54
|
-
'fetchBalance': true,
|
|
55
|
-
'fetchBorrowInterest': false,
|
|
56
|
-
'fetchBorrowRate': false,
|
|
57
|
-
'fetchBorrowRateHistories': false,
|
|
58
|
-
'fetchBorrowRateHistory': false,
|
|
59
|
-
'fetchBorrowRates': false,
|
|
60
|
-
'fetchBorrowRatesPerSymbol': false,
|
|
61
|
-
'fetchClosedOrder': true,
|
|
62
|
-
'fetchClosedOrders': true,
|
|
63
|
-
'fetchCrossBorrowRate': false,
|
|
64
|
-
'fetchCrossBorrowRates': false,
|
|
65
|
-
'fetchCurrencies': true,
|
|
66
|
-
'fetchDepositAddress': true,
|
|
67
|
-
'fetchDepositAddresses': false,
|
|
68
|
-
'fetchDepositAddressesByNetwork': false,
|
|
69
|
-
'fetchDepositsWithdrawals': true,
|
|
70
|
-
'fetchFundingHistory': false,
|
|
71
|
-
'fetchFundingRate': 'emulated',
|
|
72
|
-
'fetchFundingRateHistory': true,
|
|
73
|
-
'fetchFundingRates': true,
|
|
74
|
-
'fetchIndexOHLCV': false,
|
|
75
|
-
'fetchIsolatedBorrowRate': false,
|
|
76
|
-
'fetchIsolatedBorrowRates': false,
|
|
77
|
-
'fetchLedger': true,
|
|
78
|
-
'fetchLeverage': false,
|
|
79
|
-
'fetchLeverageTiers': false,
|
|
80
|
-
'fetchLiquidations': true,
|
|
81
|
-
'fetchMarginMode': false,
|
|
82
|
-
'fetchMarketLeverageTiers': false,
|
|
83
|
-
'fetchMarkOHLCV': false,
|
|
84
|
-
'fetchMyTrades': true,
|
|
85
|
-
'fetchOHLCV': true,
|
|
86
|
-
'fetchOpenInterest': true,
|
|
87
|
-
'fetchOpenInterestHistory': true,
|
|
88
|
-
'fetchOpenOrder': true,
|
|
89
|
-
'fetchOpenOrders': true,
|
|
90
|
-
'fetchOrder': true,
|
|
91
|
-
'fetchOrderBook': true,
|
|
92
|
-
'fetchOrderBooks': false,
|
|
93
|
-
'fetchOrderTrades': true,
|
|
94
|
-
'fetchPosition': false,
|
|
95
|
-
'fetchPositionMode': false,
|
|
96
|
-
'fetchPositions': true,
|
|
97
|
-
'fetchPremiumIndexOHLCV': false,
|
|
98
|
-
'fetchStatus': true,
|
|
99
|
-
'fetchTickers': true,
|
|
100
|
-
'fetchTime': false,
|
|
101
|
-
'fetchTradingFee': false,
|
|
102
|
-
'fetchTradingFees': true,
|
|
103
|
-
'fetchTransactionFees': undefined,
|
|
104
|
-
'fetchTransactions': 'emulated',
|
|
105
|
-
'reduceMargin': false,
|
|
106
|
-
'repayCrossMargin': false,
|
|
107
|
-
'repayIsolatedMargin': false,
|
|
108
|
-
'setLeverage': false,
|
|
109
|
-
'setMargin': true,
|
|
110
|
-
'setMarginMode': false,
|
|
111
|
-
'setPositionMode': false,
|
|
112
|
-
'signIn': false,
|
|
113
|
-
'transfer': true,
|
|
114
|
-
'withdraw': true,
|
|
115
|
-
},
|
|
116
|
-
'timeframes': {
|
|
117
|
-
'1m': '1m',
|
|
118
|
-
'5m': '5m',
|
|
119
|
-
'15m': '15m',
|
|
120
|
-
'30m': '30m',
|
|
121
|
-
'1h': '1h',
|
|
122
|
-
'3h': '3h',
|
|
123
|
-
'4h': '4h',
|
|
124
|
-
'6h': '6h',
|
|
125
|
-
'12h': '12h',
|
|
126
|
-
'1d': '1D',
|
|
127
|
-
'1w': '7D',
|
|
128
|
-
'2w': '14D',
|
|
129
|
-
'1M': '1M',
|
|
130
|
-
},
|
|
131
|
-
// cheapest endpoint is 240 requests per minute => ~ 4 requests per second => ( 1000ms / 4 ) = 250ms between requests on average
|
|
132
|
-
'rateLimit': 250,
|
|
133
|
-
'urls': {
|
|
134
|
-
'logo': 'https://github.com/user-attachments/assets/4a8e947f-ab46-481a-a8ae-8b20e9b03178',
|
|
135
|
-
'api': {
|
|
136
|
-
'v1': 'https://api.bitfinex.com',
|
|
137
|
-
'public': 'https://api-pub.bitfinex.com',
|
|
138
|
-
'private': 'https://api.bitfinex.com',
|
|
139
|
-
},
|
|
140
|
-
'www': 'https://www.bitfinex.com',
|
|
141
|
-
'doc': [
|
|
142
|
-
'https://docs.bitfinex.com/v2/docs/',
|
|
143
|
-
'https://github.com/bitfinexcom/bitfinex-api-node',
|
|
144
|
-
],
|
|
145
|
-
'fees': 'https://www.bitfinex.com/fees',
|
|
146
|
-
},
|
|
147
|
-
'api': {
|
|
148
|
-
'public': {
|
|
149
|
-
'get': {
|
|
150
|
-
'conf/{config}': 2.7,
|
|
151
|
-
'conf/pub:{action}:{object}': 2.7,
|
|
152
|
-
'conf/pub:{action}:{object}:{detail}': 2.7,
|
|
153
|
-
'conf/pub:map:{object}': 2.7,
|
|
154
|
-
'conf/pub:map:{object}:{detail}': 2.7,
|
|
155
|
-
'conf/pub:map:currency:{detail}': 2.7,
|
|
156
|
-
'conf/pub:map:currency:sym': 2.7,
|
|
157
|
-
'conf/pub:map:currency:label': 2.7,
|
|
158
|
-
'conf/pub:map:currency:unit': 2.7,
|
|
159
|
-
'conf/pub:map:currency:undl': 2.7,
|
|
160
|
-
'conf/pub:map:currency:pool': 2.7,
|
|
161
|
-
'conf/pub:map:currency:explorer': 2.7,
|
|
162
|
-
'conf/pub:map:currency:tx:fee': 2.7,
|
|
163
|
-
'conf/pub:map:tx:method': 2.7,
|
|
164
|
-
'conf/pub:list:{object}': 2.7,
|
|
165
|
-
'conf/pub:list:{object}:{detail}': 2.7,
|
|
166
|
-
'conf/pub:list:currency': 2.7,
|
|
167
|
-
'conf/pub:list:pair:exchange': 2.7,
|
|
168
|
-
'conf/pub:list:pair:margin': 2.7,
|
|
169
|
-
'conf/pub:list:pair:futures': 2.7,
|
|
170
|
-
'conf/pub:list:competitions': 2.7,
|
|
171
|
-
'conf/pub:info:{object}': 2.7,
|
|
172
|
-
'conf/pub:info:{object}:{detail}': 2.7,
|
|
173
|
-
'conf/pub:info:pair': 2.7,
|
|
174
|
-
'conf/pub:info:pair:futures': 2.7,
|
|
175
|
-
'conf/pub:info:tx:status': 2.7,
|
|
176
|
-
'conf/pub:fees': 2.7,
|
|
177
|
-
'platform/status': 8,
|
|
178
|
-
'tickers': 2.7,
|
|
179
|
-
'ticker/{symbol}': 2.7,
|
|
180
|
-
'tickers/hist': 2.7,
|
|
181
|
-
'trades/{symbol}/hist': 2.7,
|
|
182
|
-
'book/{symbol}/{precision}': 1,
|
|
183
|
-
'book/{symbol}/P0': 1,
|
|
184
|
-
'book/{symbol}/P1': 1,
|
|
185
|
-
'book/{symbol}/P2': 1,
|
|
186
|
-
'book/{symbol}/P3': 1,
|
|
187
|
-
'book/{symbol}/R0': 1,
|
|
188
|
-
'stats1/{key}:{size}:{symbol}:{side}/{section}': 2.7,
|
|
189
|
-
'stats1/{key}:{size}:{symbol}:{side}/last': 2.7,
|
|
190
|
-
'stats1/{key}:{size}:{symbol}:{side}/hist': 2.7,
|
|
191
|
-
'stats1/{key}:{size}:{symbol}/{section}': 2.7,
|
|
192
|
-
'stats1/{key}:{size}:{symbol}/last': 2.7,
|
|
193
|
-
'stats1/{key}:{size}:{symbol}/hist': 2.7,
|
|
194
|
-
'stats1/{key}:{size}:{symbol}:long/last': 2.7,
|
|
195
|
-
'stats1/{key}:{size}:{symbol}:long/hist': 2.7,
|
|
196
|
-
'stats1/{key}:{size}:{symbol}:short/last': 2.7,
|
|
197
|
-
'stats1/{key}:{size}:{symbol}:short/hist': 2.7,
|
|
198
|
-
'candles/trade:{timeframe}:{symbol}:{period}/{section}': 2.7,
|
|
199
|
-
'candles/trade:{timeframe}:{symbol}/{section}': 2.7,
|
|
200
|
-
'candles/trade:{timeframe}:{symbol}/last': 2.7,
|
|
201
|
-
'candles/trade:{timeframe}:{symbol}/hist': 2.7,
|
|
202
|
-
'status/{type}': 2.7,
|
|
203
|
-
'status/deriv': 2.7,
|
|
204
|
-
'status/deriv/{symbol}/hist': 2.7,
|
|
205
|
-
'liquidations/hist': 80,
|
|
206
|
-
'rankings/{key}:{timeframe}:{symbol}/{section}': 2.7,
|
|
207
|
-
'rankings/{key}:{timeframe}:{symbol}/hist': 2.7,
|
|
208
|
-
'pulse/hist': 2.7,
|
|
209
|
-
'pulse/profile/{nickname}': 2.7,
|
|
210
|
-
'funding/stats/{symbol}/hist': 10,
|
|
211
|
-
'ext/vasps': 1,
|
|
212
|
-
},
|
|
213
|
-
'post': {
|
|
214
|
-
'calc/trade/avg': 2.7,
|
|
215
|
-
'calc/fx': 2.7,
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
'private': {
|
|
219
|
-
'post': {
|
|
220
|
-
// 'auth/r/orders/{symbol}/new', // outdated
|
|
221
|
-
// 'auth/r/stats/perf:{timeframe}/hist', // outdated
|
|
222
|
-
'auth/r/wallets': 2.7,
|
|
223
|
-
'auth/r/wallets/hist': 2.7,
|
|
224
|
-
'auth/r/orders': 2.7,
|
|
225
|
-
'auth/r/orders/{symbol}': 2.7,
|
|
226
|
-
'auth/w/order/submit': 2.7,
|
|
227
|
-
'auth/w/order/update': 2.7,
|
|
228
|
-
'auth/w/order/cancel': 2.7,
|
|
229
|
-
'auth/w/order/multi': 2.7,
|
|
230
|
-
'auth/w/order/cancel/multi': 2.7,
|
|
231
|
-
'auth/r/orders/{symbol}/hist': 2.7,
|
|
232
|
-
'auth/r/orders/hist': 2.7,
|
|
233
|
-
'auth/r/order/{symbol}:{id}/trades': 2.7,
|
|
234
|
-
'auth/r/trades/{symbol}/hist': 2.7,
|
|
235
|
-
'auth/r/trades/hist': 2.7,
|
|
236
|
-
'auth/r/ledgers/{currency}/hist': 2.7,
|
|
237
|
-
'auth/r/ledgers/hist': 2.7,
|
|
238
|
-
'auth/r/info/margin/{key}': 2.7,
|
|
239
|
-
'auth/r/info/margin/base': 2.7,
|
|
240
|
-
'auth/r/info/margin/sym_all': 2.7,
|
|
241
|
-
'auth/r/positions': 2.7,
|
|
242
|
-
'auth/w/position/claim': 2.7,
|
|
243
|
-
'auth/w/position/increase:': 2.7,
|
|
244
|
-
'auth/r/position/increase/info': 2.7,
|
|
245
|
-
'auth/r/positions/hist': 2.7,
|
|
246
|
-
'auth/r/positions/audit': 2.7,
|
|
247
|
-
'auth/r/positions/snap': 2.7,
|
|
248
|
-
'auth/w/deriv/collateral/set': 2.7,
|
|
249
|
-
'auth/w/deriv/collateral/limits': 2.7,
|
|
250
|
-
'auth/r/funding/offers': 2.7,
|
|
251
|
-
'auth/r/funding/offers/{symbol}': 2.7,
|
|
252
|
-
'auth/w/funding/offer/submit': 2.7,
|
|
253
|
-
'auth/w/funding/offer/cancel': 2.7,
|
|
254
|
-
'auth/w/funding/offer/cancel/all': 2.7,
|
|
255
|
-
'auth/w/funding/close': 2.7,
|
|
256
|
-
'auth/w/funding/auto': 2.7,
|
|
257
|
-
'auth/w/funding/keep': 2.7,
|
|
258
|
-
'auth/r/funding/offers/{symbol}/hist': 2.7,
|
|
259
|
-
'auth/r/funding/offers/hist': 2.7,
|
|
260
|
-
'auth/r/funding/loans': 2.7,
|
|
261
|
-
'auth/r/funding/loans/hist': 2.7,
|
|
262
|
-
'auth/r/funding/loans/{symbol}': 2.7,
|
|
263
|
-
'auth/r/funding/loans/{symbol}/hist': 2.7,
|
|
264
|
-
'auth/r/funding/credits': 2.7,
|
|
265
|
-
'auth/r/funding/credits/hist': 2.7,
|
|
266
|
-
'auth/r/funding/credits/{symbol}': 2.7,
|
|
267
|
-
'auth/r/funding/credits/{symbol}/hist': 2.7,
|
|
268
|
-
'auth/r/funding/trades/{symbol}/hist': 2.7,
|
|
269
|
-
'auth/r/funding/trades/hist': 2.7,
|
|
270
|
-
'auth/r/info/funding/{key}': 2.7,
|
|
271
|
-
'auth/r/info/user': 2.7,
|
|
272
|
-
'auth/r/summary': 2.7,
|
|
273
|
-
'auth/r/logins/hist': 2.7,
|
|
274
|
-
'auth/r/permissions': 2.7,
|
|
275
|
-
'auth/w/token': 2.7,
|
|
276
|
-
'auth/r/audit/hist': 2.7,
|
|
277
|
-
'auth/w/transfer': 2.7,
|
|
278
|
-
'auth/w/deposit/address': 24,
|
|
279
|
-
'auth/w/deposit/invoice': 24,
|
|
280
|
-
'auth/w/withdraw': 24,
|
|
281
|
-
'auth/r/movements/{currency}/hist': 2.7,
|
|
282
|
-
'auth/r/movements/hist': 2.7,
|
|
283
|
-
'auth/r/alerts': 5.34,
|
|
284
|
-
'auth/w/alert/set': 2.7,
|
|
285
|
-
'auth/w/alert/price:{symbol}:{price}/del': 2.7,
|
|
286
|
-
'auth/w/alert/{type}:{symbol}:{price}/del': 2.7,
|
|
287
|
-
'auth/calc/order/avail': 2.7,
|
|
288
|
-
'auth/w/settings/set': 2.7,
|
|
289
|
-
'auth/r/settings': 2.7,
|
|
290
|
-
'auth/w/settings/del': 2.7,
|
|
291
|
-
'auth/r/pulse/hist': 2.7,
|
|
292
|
-
'auth/w/pulse/add': 16,
|
|
293
|
-
'auth/w/pulse/del': 2.7,
|
|
294
|
-
},
|
|
295
|
-
},
|
|
296
|
-
},
|
|
297
|
-
'fees': {
|
|
298
|
-
'trading': {
|
|
299
|
-
'feeSide': 'get',
|
|
300
|
-
'percentage': true,
|
|
301
|
-
'tierBased': true,
|
|
302
|
-
'maker': this.parseNumber('0.001'),
|
|
303
|
-
'taker': this.parseNumber('0.002'),
|
|
304
|
-
'tiers': {
|
|
305
|
-
'taker': [
|
|
306
|
-
[this.parseNumber('0'), this.parseNumber('0.002')],
|
|
307
|
-
[this.parseNumber('500000'), this.parseNumber('0.002')],
|
|
308
|
-
[this.parseNumber('1000000'), this.parseNumber('0.002')],
|
|
309
|
-
[this.parseNumber('2500000'), this.parseNumber('0.002')],
|
|
310
|
-
[this.parseNumber('5000000'), this.parseNumber('0.002')],
|
|
311
|
-
[this.parseNumber('7500000'), this.parseNumber('0.002')],
|
|
312
|
-
[this.parseNumber('10000000'), this.parseNumber('0.0018')],
|
|
313
|
-
[this.parseNumber('15000000'), this.parseNumber('0.0016')],
|
|
314
|
-
[this.parseNumber('20000000'), this.parseNumber('0.0014')],
|
|
315
|
-
[this.parseNumber('25000000'), this.parseNumber('0.0012')],
|
|
316
|
-
[this.parseNumber('30000000'), this.parseNumber('0.001')],
|
|
317
|
-
],
|
|
318
|
-
'maker': [
|
|
319
|
-
[this.parseNumber('0'), this.parseNumber('0.001')],
|
|
320
|
-
[this.parseNumber('500000'), this.parseNumber('0.0008')],
|
|
321
|
-
[this.parseNumber('1000000'), this.parseNumber('0.0006')],
|
|
322
|
-
[this.parseNumber('2500000'), this.parseNumber('0.0004')],
|
|
323
|
-
[this.parseNumber('5000000'), this.parseNumber('0.0002')],
|
|
324
|
-
[this.parseNumber('7500000'), this.parseNumber('0')],
|
|
325
|
-
[this.parseNumber('10000000'), this.parseNumber('0')],
|
|
326
|
-
[this.parseNumber('15000000'), this.parseNumber('0')],
|
|
327
|
-
[this.parseNumber('20000000'), this.parseNumber('0')],
|
|
328
|
-
[this.parseNumber('25000000'), this.parseNumber('0')],
|
|
329
|
-
[this.parseNumber('30000000'), this.parseNumber('0')],
|
|
330
|
-
],
|
|
331
|
-
},
|
|
332
|
-
},
|
|
333
|
-
'funding': {
|
|
334
|
-
'withdraw': {},
|
|
335
|
-
},
|
|
336
|
-
},
|
|
337
|
-
'precisionMode': SIGNIFICANT_DIGITS,
|
|
338
|
-
'options': {
|
|
339
|
-
'precision': 'R0',
|
|
340
|
-
// convert 'EXCHANGE MARKET' to lowercase 'market'
|
|
341
|
-
// convert 'EXCHANGE LIMIT' to lowercase 'limit'
|
|
342
|
-
// everything else remains uppercase
|
|
343
|
-
'exchangeTypes': {
|
|
344
|
-
'MARKET': 'market',
|
|
345
|
-
'EXCHANGE MARKET': 'market',
|
|
346
|
-
'LIMIT': 'limit',
|
|
347
|
-
'EXCHANGE LIMIT': 'limit',
|
|
348
|
-
// 'STOP': undefined,
|
|
349
|
-
'EXCHANGE STOP': 'market',
|
|
350
|
-
// 'TRAILING STOP': undefined,
|
|
351
|
-
// 'EXCHANGE TRAILING STOP': undefined,
|
|
352
|
-
// 'FOK': undefined,
|
|
353
|
-
'EXCHANGE FOK': 'limit',
|
|
354
|
-
// 'STOP LIMIT': undefined,
|
|
355
|
-
'EXCHANGE STOP LIMIT': 'limit',
|
|
356
|
-
// 'IOC': undefined,
|
|
357
|
-
'EXCHANGE IOC': 'limit',
|
|
358
|
-
},
|
|
359
|
-
// convert 'market' to 'EXCHANGE MARKET'
|
|
360
|
-
// convert 'limit' 'EXCHANGE LIMIT'
|
|
361
|
-
// everything else remains as is
|
|
362
|
-
'orderTypes': {
|
|
363
|
-
'market': 'EXCHANGE MARKET',
|
|
364
|
-
'limit': 'EXCHANGE LIMIT',
|
|
365
|
-
},
|
|
366
|
-
'fiat': {
|
|
367
|
-
'USD': 'USD',
|
|
368
|
-
'EUR': 'EUR',
|
|
369
|
-
'JPY': 'JPY',
|
|
370
|
-
'GBP': 'GBP',
|
|
371
|
-
'CHN': 'CHN',
|
|
372
|
-
},
|
|
373
|
-
// actually the correct names unlike the v1
|
|
374
|
-
// we don't want to extend this with accountsByType in v1
|
|
375
|
-
'v2AccountsByType': {
|
|
376
|
-
'spot': 'exchange',
|
|
377
|
-
'exchange': 'exchange',
|
|
378
|
-
'funding': 'funding',
|
|
379
|
-
'margin': 'margin',
|
|
380
|
-
'derivatives': 'margin',
|
|
381
|
-
'future': 'margin',
|
|
382
|
-
'swap': 'margin',
|
|
383
|
-
},
|
|
384
|
-
'withdraw': {
|
|
385
|
-
'includeFee': false,
|
|
386
|
-
},
|
|
387
|
-
'networks': {
|
|
388
|
-
'BTC': 'BITCOIN',
|
|
389
|
-
'LTC': 'LITECOIN',
|
|
390
|
-
'ERC20': 'ETHEREUM',
|
|
391
|
-
'OMNI': 'TETHERUSO',
|
|
392
|
-
'LIQUID': 'TETHERUSL',
|
|
393
|
-
'TRC20': 'TETHERUSX',
|
|
394
|
-
'EOS': 'TETHERUSS',
|
|
395
|
-
'AVAX': 'TETHERUSDTAVAX',
|
|
396
|
-
'SOL': 'TETHERUSDTSOL',
|
|
397
|
-
'ALGO': 'TETHERUSDTALG',
|
|
398
|
-
'BCH': 'TETHERUSDTBCH',
|
|
399
|
-
'KSM': 'TETHERUSDTKSM',
|
|
400
|
-
'DVF': 'TETHERUSDTDVF',
|
|
401
|
-
'OMG': 'TETHERUSDTOMG',
|
|
402
|
-
},
|
|
403
|
-
'networksById': {
|
|
404
|
-
'TETHERUSE': 'ERC20',
|
|
405
|
-
},
|
|
406
|
-
},
|
|
407
|
-
'exceptions': {
|
|
408
|
-
'exact': {
|
|
409
|
-
'11010': RateLimitExceeded,
|
|
410
|
-
'10001': PermissionDenied,
|
|
411
|
-
'10020': BadRequest,
|
|
412
|
-
'10100': AuthenticationError,
|
|
413
|
-
'10114': InvalidNonce,
|
|
414
|
-
'20060': OnMaintenance,
|
|
415
|
-
// {"code":503,"error":"temporarily_unavailable","error_description":"Sorry, the service is temporarily unavailable. See https://www.bitfinex.com/ for more info."}
|
|
416
|
-
'temporarily_unavailable': ExchangeNotAvailable,
|
|
417
|
-
},
|
|
418
|
-
'broad': {
|
|
419
|
-
'available balance is only': InsufficientFunds,
|
|
420
|
-
'not enough exchange balance': InsufficientFunds,
|
|
421
|
-
'Order not found': OrderNotFound,
|
|
422
|
-
'symbol: invalid': BadSymbol,
|
|
423
|
-
},
|
|
424
|
-
},
|
|
425
|
-
'commonCurrencies': {
|
|
426
|
-
'UST': 'USDT',
|
|
427
|
-
'EUTF0': 'EURT',
|
|
428
|
-
'USTF0': 'USDT',
|
|
429
|
-
'ALG': 'ALGO',
|
|
430
|
-
'AMP': 'AMPL',
|
|
431
|
-
'ATO': 'ATOM',
|
|
432
|
-
'BCHABC': 'XEC',
|
|
433
|
-
'BCHN': 'BCH',
|
|
434
|
-
'DAT': 'DATA',
|
|
435
|
-
'DOG': 'MDOGE',
|
|
436
|
-
'DSH': 'DASH',
|
|
437
|
-
'EDO': 'PNT',
|
|
438
|
-
'EUS': 'EURS',
|
|
439
|
-
'EUT': 'EURT',
|
|
440
|
-
'HTX': 'HT',
|
|
441
|
-
'IDX': 'ID',
|
|
442
|
-
'IOT': 'IOTA',
|
|
443
|
-
'IQX': 'IQ',
|
|
444
|
-
'LUNA': 'LUNC',
|
|
445
|
-
'LUNA2': 'LUNA',
|
|
446
|
-
'MNA': 'MANA',
|
|
447
|
-
'ORS': 'ORS Group',
|
|
448
|
-
'PAS': 'PASS',
|
|
449
|
-
'QSH': 'QASH',
|
|
450
|
-
'QTM': 'QTUM',
|
|
451
|
-
'RBT': 'RBTC',
|
|
452
|
-
'SNG': 'SNGLS',
|
|
453
|
-
'STJ': 'STORJ',
|
|
454
|
-
'TERRAUST': 'USTC',
|
|
455
|
-
'TSD': 'TUSD',
|
|
456
|
-
'YGG': 'YEED',
|
|
457
|
-
'YYW': 'YOYOW',
|
|
458
|
-
'UDC': 'USDC',
|
|
459
|
-
'VSY': 'VSYS',
|
|
460
|
-
'WAX': 'WAXP',
|
|
461
|
-
'XCH': 'XCHF',
|
|
462
|
-
'ZBT': 'ZB',
|
|
463
|
-
},
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
|
-
isFiat(code) {
|
|
467
|
-
return (code in this.options['fiat']);
|
|
468
|
-
}
|
|
469
|
-
getCurrencyId(code) {
|
|
470
|
-
return 'f' + code;
|
|
471
|
-
}
|
|
472
|
-
getCurrencyName(code) {
|
|
473
|
-
// temporary fix for transpiler recognition, even though this is in parent class
|
|
474
|
-
if (code in this.options['currencyNames']) {
|
|
475
|
-
return this.options['currencyNames'][code];
|
|
476
|
-
}
|
|
477
|
-
throw new NotSupported(this.id + ' ' + code + ' not supported for withdrawal');
|
|
478
|
-
}
|
|
479
|
-
amountToPrecision(symbol, amount) {
|
|
480
|
-
// https://docs.bitfinex.com/docs/introduction#amount-precision
|
|
481
|
-
// The amount field allows up to 8 decimals.
|
|
482
|
-
// Anything exceeding this will be rounded to the 8th decimal.
|
|
483
|
-
symbol = this.safeSymbol(symbol);
|
|
484
|
-
return this.decimalToPrecision(amount, TRUNCATE, this.markets[symbol]['precision']['amount'], DECIMAL_PLACES);
|
|
485
|
-
}
|
|
486
|
-
priceToPrecision(symbol, price) {
|
|
487
|
-
symbol = this.safeSymbol(symbol);
|
|
488
|
-
price = this.decimalToPrecision(price, ROUND, this.markets[symbol]['precision']['price'], this.precisionMode);
|
|
489
|
-
// https://docs.bitfinex.com/docs/introduction#price-precision
|
|
490
|
-
// The precision level of all trading prices is based on significant figures.
|
|
491
|
-
// All pairs on Bitfinex use up to 5 significant digits and up to 8 decimals (e.g. 1.2345, 123.45, 1234.5, 0.00012345).
|
|
492
|
-
// Prices submit with a precision larger than 5 will be cut by the API.
|
|
493
|
-
return this.decimalToPrecision(price, TRUNCATE, 8, DECIMAL_PLACES);
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
|
-
* @method
|
|
497
|
-
* @name bitfinex2#fetchStatus
|
|
498
|
-
* @description the latest known information on the availability of the exchange API
|
|
499
|
-
* @see https://docs.bitfinex.com/reference/rest-public-platform-status
|
|
500
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
501
|
-
* @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
|
|
502
|
-
*/
|
|
503
|
-
async fetchStatus(params = {}) {
|
|
504
|
-
//
|
|
505
|
-
// [1] // operative
|
|
506
|
-
// [0] // maintenance
|
|
507
|
-
//
|
|
508
|
-
const response = await this.publicGetPlatformStatus(params);
|
|
509
|
-
const statusRaw = this.safeString(response, 0);
|
|
510
|
-
return {
|
|
511
|
-
'status': this.safeString({ '0': 'maintenance', '1': 'ok' }, statusRaw, statusRaw),
|
|
512
|
-
'updated': undefined,
|
|
513
|
-
'eta': undefined,
|
|
514
|
-
'url': undefined,
|
|
515
|
-
'info': response,
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
/**
|
|
519
|
-
* @method
|
|
520
|
-
* @name bitfinex2#fetchMarkets
|
|
521
|
-
* @description retrieves data on all markets for bitfinex2
|
|
522
|
-
* @see https://docs.bitfinex.com/reference/rest-public-conf
|
|
523
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
524
|
-
* @returns {object[]} an array of objects representing market data
|
|
525
|
-
*/
|
|
526
|
-
async fetchMarkets(params = {}) {
|
|
527
|
-
const spotMarketsInfoPromise = this.publicGetConfPubInfoPair(params);
|
|
528
|
-
const futuresMarketsInfoPromise = this.publicGetConfPubInfoPairFutures(params);
|
|
529
|
-
const marginIdsPromise = this.publicGetConfPubListPairMargin(params);
|
|
530
|
-
let [spotMarketsInfo, futuresMarketsInfo, marginIds] = await Promise.all([spotMarketsInfoPromise, futuresMarketsInfoPromise, marginIdsPromise]);
|
|
531
|
-
spotMarketsInfo = this.safeList(spotMarketsInfo, 0, []);
|
|
532
|
-
futuresMarketsInfo = this.safeList(futuresMarketsInfo, 0, []);
|
|
533
|
-
const markets = this.arrayConcat(spotMarketsInfo, futuresMarketsInfo);
|
|
534
|
-
marginIds = this.safeValue(marginIds, 0, []);
|
|
535
|
-
//
|
|
536
|
-
// [
|
|
537
|
-
// "1INCH:USD",
|
|
538
|
-
// [
|
|
539
|
-
// null,
|
|
540
|
-
// null,
|
|
541
|
-
// null,
|
|
542
|
-
// "2.0",
|
|
543
|
-
// "100000.0",
|
|
544
|
-
// null,
|
|
545
|
-
// null,
|
|
546
|
-
// null,
|
|
547
|
-
// null,
|
|
548
|
-
// null,
|
|
549
|
-
// null,
|
|
550
|
-
// null
|
|
551
|
-
// ]
|
|
552
|
-
// ]
|
|
553
|
-
//
|
|
554
|
-
const result = [];
|
|
555
|
-
for (let i = 0; i < markets.length; i++) {
|
|
556
|
-
const pair = markets[i];
|
|
557
|
-
const id = this.safeStringUpper(pair, 0);
|
|
558
|
-
const market = this.safeValue(pair, 1, {});
|
|
559
|
-
let spot = true;
|
|
560
|
-
if (id.indexOf('F0') >= 0) {
|
|
561
|
-
spot = false;
|
|
562
|
-
}
|
|
563
|
-
const swap = !spot;
|
|
564
|
-
let baseId = undefined;
|
|
565
|
-
let quoteId = undefined;
|
|
566
|
-
if (id.indexOf(':') >= 0) {
|
|
567
|
-
const parts = id.split(':');
|
|
568
|
-
baseId = parts[0];
|
|
569
|
-
quoteId = parts[1];
|
|
570
|
-
}
|
|
571
|
-
else {
|
|
572
|
-
baseId = id.slice(0, 3);
|
|
573
|
-
quoteId = id.slice(3, 6);
|
|
574
|
-
}
|
|
575
|
-
let base = this.safeCurrencyCode(baseId);
|
|
576
|
-
let quote = this.safeCurrencyCode(quoteId);
|
|
577
|
-
const splitBase = base.split('F0');
|
|
578
|
-
const splitQuote = quote.split('F0');
|
|
579
|
-
base = this.safeString(splitBase, 0);
|
|
580
|
-
quote = this.safeString(splitQuote, 0);
|
|
581
|
-
let symbol = base + '/' + quote;
|
|
582
|
-
baseId = this.getCurrencyId(baseId);
|
|
583
|
-
quoteId = this.getCurrencyId(quoteId);
|
|
584
|
-
let settle = undefined;
|
|
585
|
-
let settleId = undefined;
|
|
586
|
-
if (swap) {
|
|
587
|
-
settle = quote;
|
|
588
|
-
settleId = quote;
|
|
589
|
-
symbol = symbol + ':' + settle;
|
|
590
|
-
}
|
|
591
|
-
const minOrderSizeString = this.safeString(market, 3);
|
|
592
|
-
const maxOrderSizeString = this.safeString(market, 4);
|
|
593
|
-
let margin = false;
|
|
594
|
-
if (spot && this.inArray(id, marginIds)) {
|
|
595
|
-
margin = true;
|
|
596
|
-
}
|
|
597
|
-
result.push({
|
|
598
|
-
'id': 't' + id,
|
|
599
|
-
'symbol': symbol,
|
|
600
|
-
'base': base,
|
|
601
|
-
'quote': quote,
|
|
602
|
-
'settle': settle,
|
|
603
|
-
'baseId': baseId,
|
|
604
|
-
'quoteId': quoteId,
|
|
605
|
-
'settleId': settleId,
|
|
606
|
-
'type': spot ? 'spot' : 'swap',
|
|
607
|
-
'spot': spot,
|
|
608
|
-
'margin': margin,
|
|
609
|
-
'swap': swap,
|
|
610
|
-
'future': false,
|
|
611
|
-
'option': false,
|
|
612
|
-
'active': true,
|
|
613
|
-
'contract': swap,
|
|
614
|
-
'linear': swap ? true : undefined,
|
|
615
|
-
'inverse': swap ? false : undefined,
|
|
616
|
-
'contractSize': swap ? this.parseNumber('1') : undefined,
|
|
617
|
-
'expiry': undefined,
|
|
618
|
-
'expiryDatetime': undefined,
|
|
619
|
-
'strike': undefined,
|
|
620
|
-
'optionType': undefined,
|
|
621
|
-
'precision': {
|
|
622
|
-
'amount': parseInt('8'),
|
|
623
|
-
'price': parseInt('5'),
|
|
624
|
-
},
|
|
625
|
-
'limits': {
|
|
626
|
-
'leverage': {
|
|
627
|
-
'min': undefined,
|
|
628
|
-
'max': undefined,
|
|
629
|
-
},
|
|
630
|
-
'amount': {
|
|
631
|
-
'min': this.parseNumber(minOrderSizeString),
|
|
632
|
-
'max': this.parseNumber(maxOrderSizeString),
|
|
633
|
-
},
|
|
634
|
-
'price': {
|
|
635
|
-
'min': this.parseNumber('1e-8'),
|
|
636
|
-
'max': undefined,
|
|
637
|
-
},
|
|
638
|
-
'cost': {
|
|
639
|
-
'min': undefined,
|
|
640
|
-
'max': undefined,
|
|
641
|
-
},
|
|
642
|
-
},
|
|
643
|
-
'created': undefined,
|
|
644
|
-
'info': market,
|
|
645
|
-
});
|
|
646
|
-
}
|
|
647
|
-
return result;
|
|
648
|
-
}
|
|
649
|
-
/**
|
|
650
|
-
* @method
|
|
651
|
-
* @name bitfinex2#fetchCurrencies
|
|
652
|
-
* @description fetches all available currencies on an exchange
|
|
653
|
-
* @see https://docs.bitfinex.com/reference/rest-public-conf
|
|
654
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
655
|
-
* @returns {object} an associative dictionary of currencies
|
|
656
|
-
*/
|
|
657
|
-
async fetchCurrencies(params = {}) {
|
|
658
|
-
const labels = [
|
|
659
|
-
'pub:list:currency',
|
|
660
|
-
'pub:map:currency:sym',
|
|
661
|
-
'pub:map:currency:label',
|
|
662
|
-
'pub:map:currency:unit',
|
|
663
|
-
'pub:map:currency:undl',
|
|
664
|
-
'pub:map:currency:pool',
|
|
665
|
-
'pub:map:currency:explorer',
|
|
666
|
-
'pub:map:currency:tx:fee',
|
|
667
|
-
'pub:map:tx:method', // maps withdrawal/deposit methods to their API symbols
|
|
668
|
-
];
|
|
669
|
-
const config = labels.join(',');
|
|
670
|
-
const request = {
|
|
671
|
-
'config': config,
|
|
672
|
-
};
|
|
673
|
-
const response = await this.publicGetConfConfig(this.extend(request, params));
|
|
674
|
-
//
|
|
675
|
-
// [
|
|
676
|
-
//
|
|
677
|
-
// a list of symbols
|
|
678
|
-
// ["AAA","ABS","ADA"],
|
|
679
|
-
//
|
|
680
|
-
// // sym
|
|
681
|
-
// // maps symbols to their API symbols, BAB > BCH
|
|
682
|
-
// [
|
|
683
|
-
// [ "BAB", "BCH" ],
|
|
684
|
-
// [ "CNHT", "CNHt" ],
|
|
685
|
-
// [ "DSH", "DASH" ],
|
|
686
|
-
// [ "IOT", "IOTA" ],
|
|
687
|
-
// [ "LES", "LEO-EOS" ],
|
|
688
|
-
// [ "LET", "LEO-ERC20" ],
|
|
689
|
-
// [ "STJ", "STORJ" ],
|
|
690
|
-
// [ "TSD", "TUSD" ],
|
|
691
|
-
// [ "UDC", "USDC" ],
|
|
692
|
-
// [ "USK", "USDK" ],
|
|
693
|
-
// [ "UST", "USDt" ],
|
|
694
|
-
// [ "USTF0", "USDt0" ],
|
|
695
|
-
// [ "XCH", "XCHF" ],
|
|
696
|
-
// [ "YYW", "YOYOW" ],
|
|
697
|
-
// // ...
|
|
698
|
-
// ],
|
|
699
|
-
// // label
|
|
700
|
-
// // verbose friendly names, BNT > Bancor
|
|
701
|
-
// [
|
|
702
|
-
// [ "BAB", "Bitcoin Cash" ],
|
|
703
|
-
// [ "BCH", "Bitcoin Cash" ],
|
|
704
|
-
// [ "LEO", "Unus Sed LEO" ],
|
|
705
|
-
// [ "LES", "Unus Sed LEO (EOS)" ],
|
|
706
|
-
// [ "LET", "Unus Sed LEO (ERC20)" ],
|
|
707
|
-
// // ...
|
|
708
|
-
// ],
|
|
709
|
-
// // unit
|
|
710
|
-
// // maps symbols to unit of measure where applicable
|
|
711
|
-
// [
|
|
712
|
-
// [ "IOT", "Mi|MegaIOTA" ],
|
|
713
|
-
// ],
|
|
714
|
-
// // undl
|
|
715
|
-
// // maps derivatives symbols to their underlying currency
|
|
716
|
-
// [
|
|
717
|
-
// [ "USTF0", "UST" ],
|
|
718
|
-
// [ "BTCF0", "BTC" ],
|
|
719
|
-
// [ "ETHF0", "ETH" ],
|
|
720
|
-
// ],
|
|
721
|
-
// // pool
|
|
722
|
-
// // maps symbols to underlying network/protocol they operate on
|
|
723
|
-
// [
|
|
724
|
-
// [ 'SAN', 'ETH' ], [ 'OMG', 'ETH' ], [ 'AVT', 'ETH' ], [ "EDO", "ETH" ],
|
|
725
|
-
// [ 'ESS', 'ETH' ], [ 'ATD', 'EOS' ], [ 'ADD', 'EOS' ], [ "MTO", "EOS" ],
|
|
726
|
-
// [ 'PNK', 'ETH' ], [ 'BAB', 'BCH' ], [ 'WLO', 'XLM' ], [ "VLD", "ETH" ],
|
|
727
|
-
// [ 'BTT', 'TRX' ], [ 'IMP', 'ETH' ], [ 'SCR', 'ETH' ], [ "GNO", "ETH" ],
|
|
728
|
-
// // ...
|
|
729
|
-
// ],
|
|
730
|
-
// // explorer
|
|
731
|
-
// // maps symbols to their recognised block explorer URLs
|
|
732
|
-
// [
|
|
733
|
-
// [
|
|
734
|
-
// "AIO",
|
|
735
|
-
// [
|
|
736
|
-
// "https://mainnet.aion.network",
|
|
737
|
-
// "https://mainnet.aion.network/#/account/VAL",
|
|
738
|
-
// "https://mainnet.aion.network/#/transaction/VAL"
|
|
739
|
-
// ]
|
|
740
|
-
// ],
|
|
741
|
-
// // ...
|
|
742
|
-
// ],
|
|
743
|
-
// // fee
|
|
744
|
-
// // maps currencies to their withdrawal fees
|
|
745
|
-
// [
|
|
746
|
-
// ["AAA",[0,0]],
|
|
747
|
-
// ["ABS",[0,131.3]],
|
|
748
|
-
// ["ADA",[0,0.3]],
|
|
749
|
-
// ],
|
|
750
|
-
// ]
|
|
751
|
-
//
|
|
752
|
-
const indexed = {
|
|
753
|
-
'sym': this.indexBy(this.safeValue(response, 1, []), 0),
|
|
754
|
-
'label': this.indexBy(this.safeValue(response, 2, []), 0),
|
|
755
|
-
'unit': this.indexBy(this.safeValue(response, 3, []), 0),
|
|
756
|
-
'undl': this.indexBy(this.safeValue(response, 4, []), 0),
|
|
757
|
-
'pool': this.indexBy(this.safeValue(response, 5, []), 0),
|
|
758
|
-
'explorer': this.indexBy(this.safeValue(response, 6, []), 0),
|
|
759
|
-
'fees': this.indexBy(this.safeValue(response, 7, []), 0),
|
|
760
|
-
};
|
|
761
|
-
const ids = this.safeValue(response, 0, []);
|
|
762
|
-
const result = {};
|
|
763
|
-
for (let i = 0; i < ids.length; i++) {
|
|
764
|
-
const id = ids[i];
|
|
765
|
-
if (id.indexOf('F0') >= 0) {
|
|
766
|
-
// we get a lot of F0 currencies, skip those
|
|
767
|
-
continue;
|
|
768
|
-
}
|
|
769
|
-
const code = this.safeCurrencyCode(id);
|
|
770
|
-
const label = this.safeValue(indexed['label'], id, []);
|
|
771
|
-
const name = this.safeString(label, 1);
|
|
772
|
-
const pool = this.safeValue(indexed['pool'], id, []);
|
|
773
|
-
const rawType = this.safeString(pool, 1);
|
|
774
|
-
const isCryptoCoin = (rawType !== undefined) || (id in indexed['explorer']); // "hacky" solution
|
|
775
|
-
let type = undefined;
|
|
776
|
-
if (isCryptoCoin) {
|
|
777
|
-
type = 'crypto';
|
|
778
|
-
}
|
|
779
|
-
const feeValues = this.safeValue(indexed['fees'], id, []);
|
|
780
|
-
const fees = this.safeValue(feeValues, 1, []);
|
|
781
|
-
const fee = this.safeNumber(fees, 1);
|
|
782
|
-
const undl = this.safeValue(indexed['undl'], id, []);
|
|
783
|
-
const precision = '8'; // default precision, todo: fix "magic constants"
|
|
784
|
-
const fid = 'f' + id;
|
|
785
|
-
result[code] = {
|
|
786
|
-
'id': fid,
|
|
787
|
-
'uppercaseId': id,
|
|
788
|
-
'code': code,
|
|
789
|
-
'info': [id, label, pool, feeValues, undl],
|
|
790
|
-
'type': type,
|
|
791
|
-
'name': name,
|
|
792
|
-
'active': true,
|
|
793
|
-
'deposit': undefined,
|
|
794
|
-
'withdraw': undefined,
|
|
795
|
-
'fee': fee,
|
|
796
|
-
'precision': parseInt(precision),
|
|
797
|
-
'limits': {
|
|
798
|
-
'amount': {
|
|
799
|
-
'min': this.parseNumber(this.parsePrecision(precision)),
|
|
800
|
-
'max': undefined,
|
|
801
|
-
},
|
|
802
|
-
'withdraw': {
|
|
803
|
-
'min': fee,
|
|
804
|
-
'max': undefined,
|
|
805
|
-
},
|
|
806
|
-
},
|
|
807
|
-
'networks': {},
|
|
808
|
-
};
|
|
809
|
-
const networks = {};
|
|
810
|
-
const currencyNetworks = this.safeValue(response, 8, []);
|
|
811
|
-
const cleanId = id.replace('F0', '');
|
|
812
|
-
for (let j = 0; j < currencyNetworks.length; j++) {
|
|
813
|
-
const pair = currencyNetworks[j];
|
|
814
|
-
const networkId = this.safeString(pair, 0);
|
|
815
|
-
const currencyId = this.safeString(this.safeValue(pair, 1, []), 0);
|
|
816
|
-
if (currencyId === cleanId) {
|
|
817
|
-
const network = this.networkIdToCode(networkId);
|
|
818
|
-
networks[network] = {
|
|
819
|
-
'info': networkId,
|
|
820
|
-
'id': networkId.toLowerCase(),
|
|
821
|
-
'network': networkId,
|
|
822
|
-
'active': undefined,
|
|
823
|
-
'deposit': undefined,
|
|
824
|
-
'withdraw': undefined,
|
|
825
|
-
'fee': undefined,
|
|
826
|
-
'precision': undefined,
|
|
827
|
-
'limits': {
|
|
828
|
-
'withdraw': {
|
|
829
|
-
'min': undefined,
|
|
830
|
-
'max': undefined,
|
|
831
|
-
},
|
|
832
|
-
},
|
|
833
|
-
};
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
const keysNetworks = Object.keys(networks);
|
|
837
|
-
const networksLength = keysNetworks.length;
|
|
838
|
-
if (networksLength > 0) {
|
|
839
|
-
result[code]['networks'] = networks;
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
return result;
|
|
843
|
-
}
|
|
844
|
-
/**
|
|
845
|
-
* @method
|
|
846
|
-
* @name bitfinex2#fetchBalance
|
|
847
|
-
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
848
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-wallets
|
|
849
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
850
|
-
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
851
|
-
*/
|
|
852
|
-
async fetchBalance(params = {}) {
|
|
853
|
-
// this api call does not return the 'used' amount - use the v1 version instead (which also returns zero balances)
|
|
854
|
-
// there is a difference between this and the v1 api, namely trading wallet is called margin in v2
|
|
855
|
-
await this.loadMarkets();
|
|
856
|
-
const accountsByType = this.safeValue(this.options, 'v2AccountsByType', {});
|
|
857
|
-
const requestedType = this.safeString(params, 'type', 'exchange');
|
|
858
|
-
const accountType = this.safeString(accountsByType, requestedType, requestedType);
|
|
859
|
-
if (accountType === undefined) {
|
|
860
|
-
const keys = Object.keys(accountsByType);
|
|
861
|
-
throw new ExchangeError(this.id + ' fetchBalance() type parameter must be one of ' + keys.join(', '));
|
|
862
|
-
}
|
|
863
|
-
const isDerivative = requestedType === 'derivatives';
|
|
864
|
-
const query = this.omit(params, 'type');
|
|
865
|
-
const response = await this.privatePostAuthRWallets(query);
|
|
866
|
-
const result = { 'info': response };
|
|
867
|
-
for (let i = 0; i < response.length; i++) {
|
|
868
|
-
const balance = response[i];
|
|
869
|
-
const account = this.account();
|
|
870
|
-
const interest = this.safeString(balance, 3);
|
|
871
|
-
if (interest !== '0') {
|
|
872
|
-
account['debt'] = interest;
|
|
873
|
-
}
|
|
874
|
-
const type = this.safeString(balance, 0);
|
|
875
|
-
const currencyId = this.safeStringLower(balance, 1, '');
|
|
876
|
-
const start = currencyId.length - 2;
|
|
877
|
-
const isDerivativeCode = currencyId.slice(start) === 'f0';
|
|
878
|
-
// this will only filter the derivative codes if the requestedType is 'derivatives'
|
|
879
|
-
const derivativeCondition = (!isDerivative || isDerivativeCode);
|
|
880
|
-
if ((accountType === type) && derivativeCondition) {
|
|
881
|
-
const code = this.safeCurrencyCode(currencyId);
|
|
882
|
-
account['total'] = this.safeString(balance, 2);
|
|
883
|
-
account['free'] = this.safeString(balance, 4);
|
|
884
|
-
result[code] = account;
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
return this.safeBalance(result);
|
|
888
|
-
}
|
|
889
|
-
/**
|
|
890
|
-
* @method
|
|
891
|
-
* @name bitfinex2#transfer
|
|
892
|
-
* @description transfer currency internally between wallets on the same account
|
|
893
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-transfer
|
|
894
|
-
* @param {string} code unified currency code
|
|
895
|
-
* @param {float} amount amount to transfer
|
|
896
|
-
* @param {string} fromAccount account to transfer from
|
|
897
|
-
* @param {string} toAccount account to transfer to
|
|
898
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
899
|
-
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
900
|
-
*/
|
|
901
|
-
async transfer(code, amount, fromAccount, toAccount, params = {}) {
|
|
902
|
-
// transferring between derivatives wallet and regular wallet is not documented in their API
|
|
903
|
-
// however we support it in CCXT (from just looking at web inspector)
|
|
904
|
-
await this.loadMarkets();
|
|
905
|
-
const accountsByType = this.safeValue(this.options, 'v2AccountsByType', {});
|
|
906
|
-
const fromId = this.safeString(accountsByType, fromAccount);
|
|
907
|
-
if (fromId === undefined) {
|
|
908
|
-
const keys = Object.keys(accountsByType);
|
|
909
|
-
throw new ArgumentsRequired(this.id + ' transfer() fromAccount must be one of ' + keys.join(', '));
|
|
910
|
-
}
|
|
911
|
-
const toId = this.safeString(accountsByType, toAccount);
|
|
912
|
-
if (toId === undefined) {
|
|
913
|
-
const keys = Object.keys(accountsByType);
|
|
914
|
-
throw new ArgumentsRequired(this.id + ' transfer() toAccount must be one of ' + keys.join(', '));
|
|
915
|
-
}
|
|
916
|
-
const currency = this.currency(code);
|
|
917
|
-
const fromCurrencyId = this.convertDerivativesId(currency, fromAccount);
|
|
918
|
-
const toCurrencyId = this.convertDerivativesId(currency, toAccount);
|
|
919
|
-
const requestedAmount = this.currencyToPrecision(code, amount);
|
|
920
|
-
// this request is slightly different from v1 fromAccount -> from
|
|
921
|
-
const request = {
|
|
922
|
-
'amount': requestedAmount,
|
|
923
|
-
'currency': fromCurrencyId,
|
|
924
|
-
'currency_to': toCurrencyId,
|
|
925
|
-
'from': fromId,
|
|
926
|
-
'to': toId,
|
|
927
|
-
};
|
|
928
|
-
const response = await this.privatePostAuthWTransfer(this.extend(request, params));
|
|
929
|
-
//
|
|
930
|
-
// [
|
|
931
|
-
// 1616451183763,
|
|
932
|
-
// "acc_tf",
|
|
933
|
-
// null,
|
|
934
|
-
// null,
|
|
935
|
-
// [
|
|
936
|
-
// 1616451183763,
|
|
937
|
-
// "exchange",
|
|
938
|
-
// "margin",
|
|
939
|
-
// null,
|
|
940
|
-
// "UST",
|
|
941
|
-
// "UST",
|
|
942
|
-
// null,
|
|
943
|
-
// 1
|
|
944
|
-
// ],
|
|
945
|
-
// null,
|
|
946
|
-
// "SUCCESS",
|
|
947
|
-
// "1.0 Tether USDt transfered from Exchange to Margin"
|
|
948
|
-
// ]
|
|
949
|
-
//
|
|
950
|
-
const error = this.safeString(response, 0);
|
|
951
|
-
if (error === 'error') {
|
|
952
|
-
const message = this.safeString(response, 2, '');
|
|
953
|
-
// same message as in v1
|
|
954
|
-
this.throwExactlyMatchedException(this.exceptions['exact'], message, this.id + ' ' + message);
|
|
955
|
-
throw new ExchangeError(this.id + ' ' + message);
|
|
956
|
-
}
|
|
957
|
-
return this.parseTransfer({ 'result': response }, currency);
|
|
958
|
-
}
|
|
959
|
-
parseTransfer(transfer, currency = undefined) {
|
|
960
|
-
//
|
|
961
|
-
// transfer
|
|
962
|
-
//
|
|
963
|
-
// [
|
|
964
|
-
// 1616451183763,
|
|
965
|
-
// "acc_tf",
|
|
966
|
-
// null,
|
|
967
|
-
// null,
|
|
968
|
-
// [
|
|
969
|
-
// 1616451183763,
|
|
970
|
-
// "exchange",
|
|
971
|
-
// "margin",
|
|
972
|
-
// null,
|
|
973
|
-
// "UST",
|
|
974
|
-
// "UST",
|
|
975
|
-
// null,
|
|
976
|
-
// 1
|
|
977
|
-
// ],
|
|
978
|
-
// null,
|
|
979
|
-
// "SUCCESS",
|
|
980
|
-
// "1.0 Tether USDt transfered from Exchange to Margin"
|
|
981
|
-
// ]
|
|
982
|
-
//
|
|
983
|
-
const result = this.safeList(transfer, 'result');
|
|
984
|
-
const timestamp = this.safeInteger(result, 0);
|
|
985
|
-
const info = this.safeValue(result, 4);
|
|
986
|
-
const fromAccount = this.safeString(info, 1);
|
|
987
|
-
const toAccount = this.safeString(info, 2);
|
|
988
|
-
const currencyId = this.safeString(info, 5);
|
|
989
|
-
const status = this.safeString(result, 6);
|
|
990
|
-
return {
|
|
991
|
-
'id': undefined,
|
|
992
|
-
'timestamp': timestamp,
|
|
993
|
-
'datetime': this.iso8601(timestamp),
|
|
994
|
-
'status': this.parseTransferStatus(status),
|
|
995
|
-
'amount': this.safeNumber(info, 7),
|
|
996
|
-
'currency': this.safeCurrencyCode(currencyId, currency),
|
|
997
|
-
'fromAccount': fromAccount,
|
|
998
|
-
'toAccount': toAccount,
|
|
999
|
-
'info': result,
|
|
1000
|
-
};
|
|
1001
|
-
}
|
|
1002
|
-
parseTransferStatus(status) {
|
|
1003
|
-
const statuses = {
|
|
1004
|
-
'SUCCESS': 'ok',
|
|
1005
|
-
'ERROR': 'failed',
|
|
1006
|
-
'FAILURE': 'failed',
|
|
1007
|
-
};
|
|
1008
|
-
return this.safeString(statuses, status, status);
|
|
1009
|
-
}
|
|
1010
|
-
convertDerivativesId(currency, type) {
|
|
1011
|
-
// there is a difference between this and the v1 api, namely trading wallet is called margin in v2
|
|
1012
|
-
// {
|
|
1013
|
-
// "id": "fUSTF0",
|
|
1014
|
-
// "code": "USTF0",
|
|
1015
|
-
// "info": [ 'USTF0', [], [], [], [ "USTF0", "UST" ] ],
|
|
1016
|
-
const info = this.safeValue(currency, 'info');
|
|
1017
|
-
const transferId = this.safeString(info, 0);
|
|
1018
|
-
const underlying = this.safeValue(info, 4, []);
|
|
1019
|
-
let currencyId = undefined;
|
|
1020
|
-
if (type === 'derivatives') {
|
|
1021
|
-
currencyId = this.safeString(underlying, 0, transferId);
|
|
1022
|
-
const start = currencyId.length - 2;
|
|
1023
|
-
const isDerivativeCode = currencyId.slice(start) === 'F0';
|
|
1024
|
-
if (!isDerivativeCode) {
|
|
1025
|
-
currencyId = currencyId + 'F0';
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
else if (type !== 'margin') {
|
|
1029
|
-
currencyId = this.safeString(underlying, 1, transferId);
|
|
1030
|
-
}
|
|
1031
|
-
else {
|
|
1032
|
-
currencyId = transferId;
|
|
1033
|
-
}
|
|
1034
|
-
return currencyId;
|
|
1035
|
-
}
|
|
1036
|
-
/**
|
|
1037
|
-
* @method
|
|
1038
|
-
* @name bitfinex2#fetchOrderBook
|
|
1039
|
-
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
1040
|
-
* @see https://docs.bitfinex.com/reference/rest-public-book
|
|
1041
|
-
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
1042
|
-
* @param {int} [limit] the maximum amount of order book entries to return, bitfinex only allows 1, 25, or 100
|
|
1043
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1044
|
-
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
1045
|
-
*/
|
|
1046
|
-
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
1047
|
-
await this.loadMarkets();
|
|
1048
|
-
const precision = this.safeValue(this.options, 'precision', 'R0');
|
|
1049
|
-
const market = this.market(symbol);
|
|
1050
|
-
const request = {
|
|
1051
|
-
'symbol': market['id'],
|
|
1052
|
-
'precision': precision,
|
|
1053
|
-
};
|
|
1054
|
-
if (limit !== undefined) {
|
|
1055
|
-
request['len'] = limit;
|
|
1056
|
-
}
|
|
1057
|
-
const fullRequest = this.extend(request, params);
|
|
1058
|
-
const orderbook = await this.publicGetBookSymbolPrecision(fullRequest);
|
|
1059
|
-
const timestamp = this.milliseconds();
|
|
1060
|
-
const result = {
|
|
1061
|
-
'symbol': market['symbol'],
|
|
1062
|
-
'bids': [],
|
|
1063
|
-
'asks': [],
|
|
1064
|
-
'timestamp': timestamp,
|
|
1065
|
-
'datetime': this.iso8601(timestamp),
|
|
1066
|
-
'nonce': undefined,
|
|
1067
|
-
};
|
|
1068
|
-
const priceIndex = (fullRequest['precision'] === 'R0') ? 1 : 0;
|
|
1069
|
-
for (let i = 0; i < orderbook.length; i++) {
|
|
1070
|
-
const order = orderbook[i];
|
|
1071
|
-
const price = this.safeNumber(order, priceIndex);
|
|
1072
|
-
const signedAmount = this.safeString(order, 2);
|
|
1073
|
-
const amount = Precise.stringAbs(signedAmount);
|
|
1074
|
-
const side = Precise.stringGt(signedAmount, '0') ? 'bids' : 'asks';
|
|
1075
|
-
result[side].push([price, this.parseNumber(amount)]);
|
|
1076
|
-
}
|
|
1077
|
-
result['bids'] = this.sortBy(result['bids'], 0, true);
|
|
1078
|
-
result['asks'] = this.sortBy(result['asks'], 0);
|
|
1079
|
-
return result;
|
|
1080
|
-
}
|
|
1081
|
-
parseTicker(ticker, market = undefined) {
|
|
1082
|
-
//
|
|
1083
|
-
// on trading pairs (ex. tBTCUSD)
|
|
1084
|
-
//
|
|
1085
|
-
// {
|
|
1086
|
-
// 'result': [
|
|
1087
|
-
// SYMBOL,
|
|
1088
|
-
// BID,
|
|
1089
|
-
// BID_SIZE,
|
|
1090
|
-
// ASK,
|
|
1091
|
-
// ASK_SIZE,
|
|
1092
|
-
// DAILY_CHANGE,
|
|
1093
|
-
// DAILY_CHANGE_RELATIVE,
|
|
1094
|
-
// LAST_PRICE,
|
|
1095
|
-
// VOLUME,
|
|
1096
|
-
// HIGH,
|
|
1097
|
-
// LOW
|
|
1098
|
-
// ]
|
|
1099
|
-
// }
|
|
1100
|
-
//
|
|
1101
|
-
//
|
|
1102
|
-
// on funding currencies (ex. fUSD)
|
|
1103
|
-
//
|
|
1104
|
-
// {
|
|
1105
|
-
// 'result': [
|
|
1106
|
-
// SYMBOL,
|
|
1107
|
-
// FRR,
|
|
1108
|
-
// BID,
|
|
1109
|
-
// BID_PERIOD,
|
|
1110
|
-
// BID_SIZE,
|
|
1111
|
-
// ASK,
|
|
1112
|
-
// ASK_PERIOD,
|
|
1113
|
-
// ASK_SIZE,
|
|
1114
|
-
// DAILY_CHANGE,
|
|
1115
|
-
// DAILY_CHANGE_RELATIVE,
|
|
1116
|
-
// LAST_PRICE,
|
|
1117
|
-
// VOLUME,
|
|
1118
|
-
// HIGH,
|
|
1119
|
-
// LOW,
|
|
1120
|
-
// _PLACEHOLDER,
|
|
1121
|
-
// _PLACEHOLDER,
|
|
1122
|
-
// FRR_AMOUNT_AVAILABLE
|
|
1123
|
-
// ]
|
|
1124
|
-
// }
|
|
1125
|
-
//
|
|
1126
|
-
const result = this.safeList(ticker, 'result');
|
|
1127
|
-
const symbol = this.safeSymbol(undefined, market);
|
|
1128
|
-
const length = result.length;
|
|
1129
|
-
const last = this.safeString(result, length - 4);
|
|
1130
|
-
const percentage = this.safeString(result, length - 5);
|
|
1131
|
-
return this.safeTicker({
|
|
1132
|
-
'symbol': symbol,
|
|
1133
|
-
'timestamp': undefined,
|
|
1134
|
-
'datetime': undefined,
|
|
1135
|
-
'high': this.safeString(result, length - 2),
|
|
1136
|
-
'low': this.safeString(result, length - 1),
|
|
1137
|
-
'bid': this.safeString(result, length - 10),
|
|
1138
|
-
'bidVolume': this.safeString(result, length - 9),
|
|
1139
|
-
'ask': this.safeString(result, length - 8),
|
|
1140
|
-
'askVolume': this.safeString(result, length - 7),
|
|
1141
|
-
'vwap': undefined,
|
|
1142
|
-
'open': undefined,
|
|
1143
|
-
'close': last,
|
|
1144
|
-
'last': last,
|
|
1145
|
-
'previousClose': undefined,
|
|
1146
|
-
'change': this.safeString(result, length - 6),
|
|
1147
|
-
'percentage': Precise.stringMul(percentage, '100'),
|
|
1148
|
-
'average': undefined,
|
|
1149
|
-
'baseVolume': this.safeString(result, length - 3),
|
|
1150
|
-
'quoteVolume': undefined,
|
|
1151
|
-
'info': result,
|
|
1152
|
-
}, market);
|
|
1153
|
-
}
|
|
1154
|
-
/**
|
|
1155
|
-
* @method
|
|
1156
|
-
* @name bitfinex2#fetchTickers
|
|
1157
|
-
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
1158
|
-
* @see https://docs.bitfinex.com/reference/rest-public-tickers
|
|
1159
|
-
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
1160
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1161
|
-
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1162
|
-
*/
|
|
1163
|
-
async fetchTickers(symbols = undefined, params = {}) {
|
|
1164
|
-
await this.loadMarkets();
|
|
1165
|
-
symbols = this.marketSymbols(symbols);
|
|
1166
|
-
const request = {};
|
|
1167
|
-
if (symbols !== undefined) {
|
|
1168
|
-
const ids = this.marketIds(symbols);
|
|
1169
|
-
request['symbols'] = ids.join(',');
|
|
1170
|
-
}
|
|
1171
|
-
else {
|
|
1172
|
-
request['symbols'] = 'ALL';
|
|
1173
|
-
}
|
|
1174
|
-
const tickers = await this.publicGetTickers(this.extend(request, params));
|
|
1175
|
-
//
|
|
1176
|
-
// [
|
|
1177
|
-
// // on trading pairs (ex. tBTCUSD)
|
|
1178
|
-
// [
|
|
1179
|
-
// SYMBOL,
|
|
1180
|
-
// BID,
|
|
1181
|
-
// BID_SIZE,
|
|
1182
|
-
// ASK,
|
|
1183
|
-
// ASK_SIZE,
|
|
1184
|
-
// DAILY_CHANGE,
|
|
1185
|
-
// DAILY_CHANGE_RELATIVE,
|
|
1186
|
-
// LAST_PRICE,
|
|
1187
|
-
// VOLUME,
|
|
1188
|
-
// HIGH,
|
|
1189
|
-
// LOW
|
|
1190
|
-
// ],
|
|
1191
|
-
// // on funding currencies (ex. fUSD)
|
|
1192
|
-
// [
|
|
1193
|
-
// SYMBOL,
|
|
1194
|
-
// FRR,
|
|
1195
|
-
// BID,
|
|
1196
|
-
// BID_PERIOD,
|
|
1197
|
-
// BID_SIZE,
|
|
1198
|
-
// ASK,
|
|
1199
|
-
// ASK_PERIOD,
|
|
1200
|
-
// ASK_SIZE,
|
|
1201
|
-
// DAILY_CHANGE,
|
|
1202
|
-
// DAILY_CHANGE_RELATIVE,
|
|
1203
|
-
// LAST_PRICE,
|
|
1204
|
-
// VOLUME,
|
|
1205
|
-
// HIGH,
|
|
1206
|
-
// LOW,
|
|
1207
|
-
// _PLACEHOLDER,
|
|
1208
|
-
// _PLACEHOLDER,
|
|
1209
|
-
// FRR_AMOUNT_AVAILABLE
|
|
1210
|
-
// ],
|
|
1211
|
-
// ...
|
|
1212
|
-
// ]
|
|
1213
|
-
//
|
|
1214
|
-
const result = {};
|
|
1215
|
-
for (let i = 0; i < tickers.length; i++) {
|
|
1216
|
-
const ticker = tickers[i];
|
|
1217
|
-
const marketId = this.safeString(ticker, 0);
|
|
1218
|
-
const market = this.safeMarket(marketId);
|
|
1219
|
-
const symbol = market['symbol'];
|
|
1220
|
-
result[symbol] = this.parseTicker({ 'result': ticker }, market);
|
|
1221
|
-
}
|
|
1222
|
-
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
1223
|
-
}
|
|
1224
|
-
/**
|
|
1225
|
-
* @method
|
|
1226
|
-
* @name bitfinex2#fetchTicker
|
|
1227
|
-
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
1228
|
-
* @see https://docs.bitfinex.com/reference/rest-public-ticker
|
|
1229
|
-
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
1230
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1231
|
-
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
1232
|
-
*/
|
|
1233
|
-
async fetchTicker(symbol, params = {}) {
|
|
1234
|
-
await this.loadMarkets();
|
|
1235
|
-
const market = this.market(symbol);
|
|
1236
|
-
const request = {
|
|
1237
|
-
'symbol': market['id'],
|
|
1238
|
-
};
|
|
1239
|
-
const ticker = await this.publicGetTickerSymbol(this.extend(request, params));
|
|
1240
|
-
const result = { 'result': ticker };
|
|
1241
|
-
return this.parseTicker(result, market);
|
|
1242
|
-
}
|
|
1243
|
-
parseTrade(trade, market = undefined) {
|
|
1244
|
-
//
|
|
1245
|
-
// fetchTrades (public)
|
|
1246
|
-
//
|
|
1247
|
-
// [
|
|
1248
|
-
// ID,
|
|
1249
|
-
// MTS, // timestamp
|
|
1250
|
-
// AMOUNT,
|
|
1251
|
-
// PRICE
|
|
1252
|
-
// ]
|
|
1253
|
-
//
|
|
1254
|
-
// fetchMyTrades (private)
|
|
1255
|
-
//
|
|
1256
|
-
// [
|
|
1257
|
-
// ID,
|
|
1258
|
-
// PAIR,
|
|
1259
|
-
// MTS_CREATE,
|
|
1260
|
-
// ORDER_ID,
|
|
1261
|
-
// EXEC_AMOUNT,
|
|
1262
|
-
// EXEC_PRICE,
|
|
1263
|
-
// ORDER_TYPE,
|
|
1264
|
-
// ORDER_PRICE,
|
|
1265
|
-
// MAKER,
|
|
1266
|
-
// FEE,
|
|
1267
|
-
// FEE_CURRENCY,
|
|
1268
|
-
// ...
|
|
1269
|
-
// ]
|
|
1270
|
-
//
|
|
1271
|
-
const tradeList = this.safeList(trade, 'result', []);
|
|
1272
|
-
const tradeLength = tradeList.length;
|
|
1273
|
-
const isPrivate = (tradeLength > 5);
|
|
1274
|
-
const id = this.safeString(tradeList, 0);
|
|
1275
|
-
const amountIndex = isPrivate ? 4 : 2;
|
|
1276
|
-
let side = undefined;
|
|
1277
|
-
let amountString = this.safeString(tradeList, amountIndex);
|
|
1278
|
-
const priceIndex = isPrivate ? 5 : 3;
|
|
1279
|
-
const priceString = this.safeString(tradeList, priceIndex);
|
|
1280
|
-
if (amountString[0] === '-') {
|
|
1281
|
-
side = 'sell';
|
|
1282
|
-
amountString = Precise.stringAbs(amountString);
|
|
1283
|
-
}
|
|
1284
|
-
else {
|
|
1285
|
-
side = 'buy';
|
|
1286
|
-
}
|
|
1287
|
-
let orderId = undefined;
|
|
1288
|
-
let takerOrMaker = undefined;
|
|
1289
|
-
let type = undefined;
|
|
1290
|
-
let fee = undefined;
|
|
1291
|
-
let symbol = this.safeSymbol(undefined, market);
|
|
1292
|
-
const timestampIndex = isPrivate ? 2 : 1;
|
|
1293
|
-
const timestamp = this.safeInteger(tradeList, timestampIndex);
|
|
1294
|
-
if (isPrivate) {
|
|
1295
|
-
const marketId = tradeList[1];
|
|
1296
|
-
symbol = this.safeSymbol(marketId);
|
|
1297
|
-
orderId = this.safeString(tradeList, 3);
|
|
1298
|
-
const maker = this.safeInteger(tradeList, 8);
|
|
1299
|
-
takerOrMaker = (maker === 1) ? 'maker' : 'taker';
|
|
1300
|
-
let feeCostString = this.safeString(tradeList, 9);
|
|
1301
|
-
feeCostString = Precise.stringNeg(feeCostString);
|
|
1302
|
-
const feeCurrencyId = this.safeString(tradeList, 10);
|
|
1303
|
-
const feeCurrency = this.safeCurrencyCode(feeCurrencyId);
|
|
1304
|
-
fee = {
|
|
1305
|
-
'cost': feeCostString,
|
|
1306
|
-
'currency': feeCurrency,
|
|
1307
|
-
};
|
|
1308
|
-
const orderType = tradeList[6];
|
|
1309
|
-
type = this.safeString(this.options['exchangeTypes'], orderType);
|
|
1310
|
-
}
|
|
1311
|
-
return this.safeTrade({
|
|
1312
|
-
'id': id,
|
|
1313
|
-
'timestamp': timestamp,
|
|
1314
|
-
'datetime': this.iso8601(timestamp),
|
|
1315
|
-
'symbol': symbol,
|
|
1316
|
-
'order': orderId,
|
|
1317
|
-
'side': side,
|
|
1318
|
-
'type': type,
|
|
1319
|
-
'takerOrMaker': takerOrMaker,
|
|
1320
|
-
'price': priceString,
|
|
1321
|
-
'amount': amountString,
|
|
1322
|
-
'cost': undefined,
|
|
1323
|
-
'fee': fee,
|
|
1324
|
-
'info': tradeList,
|
|
1325
|
-
}, market);
|
|
1326
|
-
}
|
|
1327
|
-
/**
|
|
1328
|
-
* @method
|
|
1329
|
-
* @name bitfinex2#fetchTrades
|
|
1330
|
-
* @description get the list of most recent trades for a particular symbol
|
|
1331
|
-
* @see https://docs.bitfinex.com/reference/rest-public-trades
|
|
1332
|
-
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
1333
|
-
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
1334
|
-
* @param {int} [limit] the maximum amount of trades to fetch, default 120, max 10000
|
|
1335
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1336
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
1337
|
-
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
1338
|
-
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
1339
|
-
*/
|
|
1340
|
-
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
1341
|
-
await this.loadMarkets();
|
|
1342
|
-
let paginate = false;
|
|
1343
|
-
[paginate, params] = this.handleOptionAndParams(params, 'fetchTrades', 'paginate');
|
|
1344
|
-
if (paginate) {
|
|
1345
|
-
return await this.fetchPaginatedCallDynamic('fetchTrades', symbol, since, limit, params, 10000);
|
|
1346
|
-
}
|
|
1347
|
-
const market = this.market(symbol);
|
|
1348
|
-
let sort = '-1';
|
|
1349
|
-
let request = {
|
|
1350
|
-
'symbol': market['id'],
|
|
1351
|
-
};
|
|
1352
|
-
if (since !== undefined) {
|
|
1353
|
-
request['start'] = since;
|
|
1354
|
-
sort = '1';
|
|
1355
|
-
}
|
|
1356
|
-
if (limit !== undefined) {
|
|
1357
|
-
request['limit'] = Math.min(limit, 10000); // default 120, max 10000
|
|
1358
|
-
}
|
|
1359
|
-
request['sort'] = sort;
|
|
1360
|
-
[request, params] = this.handleUntilOption('end', request, params);
|
|
1361
|
-
const response = await this.publicGetTradesSymbolHist(this.extend(request, params));
|
|
1362
|
-
//
|
|
1363
|
-
// [
|
|
1364
|
-
// [
|
|
1365
|
-
// ID,
|
|
1366
|
-
// MTS, // timestamp
|
|
1367
|
-
// AMOUNT,
|
|
1368
|
-
// PRICE
|
|
1369
|
-
// ]
|
|
1370
|
-
// ]
|
|
1371
|
-
//
|
|
1372
|
-
const trades = this.sortBy(response, 1);
|
|
1373
|
-
const tradesList = [];
|
|
1374
|
-
for (let i = 0; i < trades.length; i++) {
|
|
1375
|
-
tradesList.push({ 'result': trades[i] }); // convert to array of dicts to match parseOrder signature
|
|
1376
|
-
}
|
|
1377
|
-
return this.parseTrades(tradesList, market, undefined, limit);
|
|
1378
|
-
}
|
|
1379
|
-
/**
|
|
1380
|
-
* @method
|
|
1381
|
-
* @name bitfinex2#fetchOHLCV
|
|
1382
|
-
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
1383
|
-
* @see https://docs.bitfinex.com/reference/rest-public-candles
|
|
1384
|
-
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
1385
|
-
* @param {string} timeframe the length of time each candle represents
|
|
1386
|
-
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
1387
|
-
* @param {int} [limit] the maximum amount of candles to fetch, default 100 max 10000
|
|
1388
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1389
|
-
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
1390
|
-
* @param {int} [params.until] timestamp in ms of the latest candle to fetch
|
|
1391
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
1392
|
-
*/
|
|
1393
|
-
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = 100, params = {}) {
|
|
1394
|
-
await this.loadMarkets();
|
|
1395
|
-
let paginate = false;
|
|
1396
|
-
[paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
|
|
1397
|
-
if (paginate) {
|
|
1398
|
-
return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 10000);
|
|
1399
|
-
}
|
|
1400
|
-
const market = this.market(symbol);
|
|
1401
|
-
if (limit === undefined) {
|
|
1402
|
-
limit = 10000;
|
|
1403
|
-
}
|
|
1404
|
-
else {
|
|
1405
|
-
limit = Math.min(limit, 10000);
|
|
1406
|
-
}
|
|
1407
|
-
let request = {
|
|
1408
|
-
'symbol': market['id'],
|
|
1409
|
-
'timeframe': this.safeString(this.timeframes, timeframe, timeframe),
|
|
1410
|
-
'sort': 1,
|
|
1411
|
-
'limit': limit,
|
|
1412
|
-
};
|
|
1413
|
-
if (since !== undefined) {
|
|
1414
|
-
request['start'] = since;
|
|
1415
|
-
}
|
|
1416
|
-
[request, params] = this.handleUntilOption('end', request, params);
|
|
1417
|
-
const response = await this.publicGetCandlesTradeTimeframeSymbolHist(this.extend(request, params));
|
|
1418
|
-
//
|
|
1419
|
-
// [
|
|
1420
|
-
// [1591503840000,0.025069,0.025068,0.025069,0.025068,1.97828998],
|
|
1421
|
-
// [1591504500000,0.025065,0.025065,0.025065,0.025065,1.0164],
|
|
1422
|
-
// [1591504620000,0.025062,0.025062,0.025062,0.025062,0.5],
|
|
1423
|
-
// ]
|
|
1424
|
-
//
|
|
1425
|
-
return this.parseOHLCVs(response, market, timeframe, since, limit);
|
|
1426
|
-
}
|
|
1427
|
-
parseOHLCV(ohlcv, market = undefined) {
|
|
1428
|
-
//
|
|
1429
|
-
// [
|
|
1430
|
-
// 1457539800000,
|
|
1431
|
-
// 0.02594,
|
|
1432
|
-
// 0.02594,
|
|
1433
|
-
// 0.02594,
|
|
1434
|
-
// 0.02594,
|
|
1435
|
-
// 0.1
|
|
1436
|
-
// ]
|
|
1437
|
-
//
|
|
1438
|
-
return [
|
|
1439
|
-
this.safeInteger(ohlcv, 0),
|
|
1440
|
-
this.safeNumber(ohlcv, 1),
|
|
1441
|
-
this.safeNumber(ohlcv, 3),
|
|
1442
|
-
this.safeNumber(ohlcv, 4),
|
|
1443
|
-
this.safeNumber(ohlcv, 2),
|
|
1444
|
-
this.safeNumber(ohlcv, 5),
|
|
1445
|
-
];
|
|
1446
|
-
}
|
|
1447
|
-
parseOrderStatus(status) {
|
|
1448
|
-
if (status === undefined) {
|
|
1449
|
-
return status;
|
|
1450
|
-
}
|
|
1451
|
-
const parts = status.split(' ');
|
|
1452
|
-
const state = this.safeString(parts, 0);
|
|
1453
|
-
const statuses = {
|
|
1454
|
-
'ACTIVE': 'open',
|
|
1455
|
-
'PARTIALLY': 'open',
|
|
1456
|
-
'EXECUTED': 'closed',
|
|
1457
|
-
'CANCELED': 'canceled',
|
|
1458
|
-
'INSUFFICIENT': 'canceled',
|
|
1459
|
-
'POSTONLY CANCELED': 'canceled',
|
|
1460
|
-
'RSN_DUST': 'rejected',
|
|
1461
|
-
'RSN_PAUSE': 'rejected',
|
|
1462
|
-
'IOC CANCELED': 'canceled',
|
|
1463
|
-
'FILLORKILL CANCELED': 'canceled',
|
|
1464
|
-
};
|
|
1465
|
-
return this.safeString(statuses, state, status);
|
|
1466
|
-
}
|
|
1467
|
-
parseOrderFlags(flags) {
|
|
1468
|
-
// flags can be added to each other...
|
|
1469
|
-
const flagValues = {
|
|
1470
|
-
'1024': ['reduceOnly'],
|
|
1471
|
-
'4096': ['postOnly'],
|
|
1472
|
-
'5120': ['reduceOnly', 'postOnly'],
|
|
1473
|
-
// '64': 'hidden', // The hidden order option ensures an order does not appear in the order book
|
|
1474
|
-
// '512': 'close', // Close position if position present.
|
|
1475
|
-
// '16384': 'OCO', // The one cancels other order option allows you to place a pair of orders stipulating that if one order is executed fully or partially, then the other is automatically canceled.
|
|
1476
|
-
// '524288': 'No Var Rates' // Excludes variable rate funding offers from matching against this order, if on margin
|
|
1477
|
-
};
|
|
1478
|
-
return this.safeValue(flagValues, flags, undefined);
|
|
1479
|
-
}
|
|
1480
|
-
parseTimeInForce(orderType) {
|
|
1481
|
-
const orderTypes = {
|
|
1482
|
-
'EXCHANGE IOC': 'IOC',
|
|
1483
|
-
'EXCHANGE FOK': 'FOK',
|
|
1484
|
-
'IOC': 'IOC',
|
|
1485
|
-
'FOK': 'FOK', // Margin
|
|
1486
|
-
};
|
|
1487
|
-
return this.safeString(orderTypes, orderType, 'GTC');
|
|
1488
|
-
}
|
|
1489
|
-
parseOrder(order, market = undefined) {
|
|
1490
|
-
const orderList = this.safeList(order, 'result');
|
|
1491
|
-
const id = this.safeString(orderList, 0);
|
|
1492
|
-
const marketId = this.safeString(orderList, 3);
|
|
1493
|
-
const symbol = this.safeSymbol(marketId);
|
|
1494
|
-
// https://github.com/ccxt/ccxt/issues/6686
|
|
1495
|
-
// const timestamp = this.safeTimestamp (orderObject, 5);
|
|
1496
|
-
const timestamp = this.safeInteger(orderList, 5);
|
|
1497
|
-
const remaining = Precise.stringAbs(this.safeString(orderList, 6));
|
|
1498
|
-
const signedAmount = this.safeString(orderList, 7);
|
|
1499
|
-
const amount = Precise.stringAbs(signedAmount);
|
|
1500
|
-
const side = Precise.stringLt(signedAmount, '0') ? 'sell' : 'buy';
|
|
1501
|
-
const orderType = this.safeString(orderList, 8);
|
|
1502
|
-
const type = this.safeString(this.safeValue(this.options, 'exchangeTypes'), orderType);
|
|
1503
|
-
const timeInForce = this.parseTimeInForce(orderType);
|
|
1504
|
-
const rawFlags = this.safeString(orderList, 12);
|
|
1505
|
-
const flags = this.parseOrderFlags(rawFlags);
|
|
1506
|
-
let postOnly = false;
|
|
1507
|
-
if (flags !== undefined) {
|
|
1508
|
-
for (let i = 0; i < flags.length; i++) {
|
|
1509
|
-
if (flags[i] === 'postOnly') {
|
|
1510
|
-
postOnly = true;
|
|
1511
|
-
}
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
|
-
let price = this.safeString(orderList, 16);
|
|
1515
|
-
let stopPrice = undefined;
|
|
1516
|
-
if ((orderType === 'EXCHANGE STOP') || (orderType === 'EXCHANGE STOP LIMIT')) {
|
|
1517
|
-
price = undefined;
|
|
1518
|
-
stopPrice = this.safeString(orderList, 16);
|
|
1519
|
-
if (orderType === 'EXCHANGE STOP LIMIT') {
|
|
1520
|
-
price = this.safeString(orderList, 19);
|
|
1521
|
-
}
|
|
1522
|
-
}
|
|
1523
|
-
let status = undefined;
|
|
1524
|
-
const statusString = this.safeString(orderList, 13);
|
|
1525
|
-
if (statusString !== undefined) {
|
|
1526
|
-
const parts = statusString.split(' @ ');
|
|
1527
|
-
status = this.parseOrderStatus(this.safeString(parts, 0));
|
|
1528
|
-
}
|
|
1529
|
-
const average = this.safeString(orderList, 17);
|
|
1530
|
-
const clientOrderId = this.safeString(orderList, 2);
|
|
1531
|
-
return this.safeOrder({
|
|
1532
|
-
'info': orderList,
|
|
1533
|
-
'id': id,
|
|
1534
|
-
'clientOrderId': clientOrderId,
|
|
1535
|
-
'timestamp': timestamp,
|
|
1536
|
-
'datetime': this.iso8601(timestamp),
|
|
1537
|
-
'lastTradeTimestamp': undefined,
|
|
1538
|
-
'symbol': symbol,
|
|
1539
|
-
'type': type,
|
|
1540
|
-
'timeInForce': timeInForce,
|
|
1541
|
-
'postOnly': postOnly,
|
|
1542
|
-
'side': side,
|
|
1543
|
-
'price': price,
|
|
1544
|
-
'stopPrice': stopPrice,
|
|
1545
|
-
'triggerPrice': stopPrice,
|
|
1546
|
-
'amount': amount,
|
|
1547
|
-
'cost': undefined,
|
|
1548
|
-
'average': average,
|
|
1549
|
-
'filled': undefined,
|
|
1550
|
-
'remaining': remaining,
|
|
1551
|
-
'status': status,
|
|
1552
|
-
'fee': undefined,
|
|
1553
|
-
'trades': undefined,
|
|
1554
|
-
}, market);
|
|
1555
|
-
}
|
|
1556
|
-
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
1557
|
-
/**
|
|
1558
|
-
* @method
|
|
1559
|
-
* @ignore
|
|
1560
|
-
* @name bitfinex2#createOrderRequest
|
|
1561
|
-
* @description helper function to build an order request
|
|
1562
|
-
* @param {string} symbol unified symbol of the market to create an order in
|
|
1563
|
-
* @param {string} type 'market' or 'limit'
|
|
1564
|
-
* @param {string} side 'buy' or 'sell'
|
|
1565
|
-
* @param {float} amount how much you want to trade in units of the base currency
|
|
1566
|
-
* @param {float} [price] the price of the order, in units of the quote currency, ignored in market orders
|
|
1567
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1568
|
-
* @param {float} [params.stopPrice] The price at which a trigger order is triggered at
|
|
1569
|
-
* @param {string} [params.timeInForce] "GTC", "IOC", "FOK", or "PO"
|
|
1570
|
-
* @param {bool} [params.postOnly]
|
|
1571
|
-
* @param {bool} [params.reduceOnly] Ensures that the executed order does not flip the opened position.
|
|
1572
|
-
* @param {int} [params.flags] additional order parameters: 4096 (Post Only), 1024 (Reduce Only), 16384 (OCO), 64 (Hidden), 512 (Close), 524288 (No Var Rates)
|
|
1573
|
-
* @param {int} [params.lev] leverage for a derivative order, supported by derivative symbol orders only. The value should be between 1 and 100 inclusive.
|
|
1574
|
-
* @param {string} [params.price_traling] The trailing price for a trailing stop order
|
|
1575
|
-
* @param {string} [params.price_aux_limit] Order price for stop limit orders
|
|
1576
|
-
* @param {string} [params.price_oco_stop] OCO stop price
|
|
1577
|
-
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
1578
|
-
*/
|
|
1579
|
-
const market = this.market(symbol);
|
|
1580
|
-
let amountString = this.amountToPrecision(symbol, amount);
|
|
1581
|
-
amountString = (side === 'buy') ? amountString : Precise.stringNeg(amountString);
|
|
1582
|
-
const request = {
|
|
1583
|
-
'symbol': market['id'],
|
|
1584
|
-
'amount': amountString,
|
|
1585
|
-
};
|
|
1586
|
-
const stopPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
|
|
1587
|
-
const trailingAmount = this.safeString(params, 'trailingAmount');
|
|
1588
|
-
const timeInForce = this.safeString(params, 'timeInForce');
|
|
1589
|
-
const postOnlyParam = this.safeBool(params, 'postOnly', false);
|
|
1590
|
-
const reduceOnly = this.safeBool(params, 'reduceOnly', false);
|
|
1591
|
-
const clientOrderId = this.safeValue2(params, 'cid', 'clientOrderId');
|
|
1592
|
-
let orderType = type.toUpperCase();
|
|
1593
|
-
if (trailingAmount !== undefined) {
|
|
1594
|
-
orderType = 'TRAILING STOP';
|
|
1595
|
-
request['price_trailing'] = trailingAmount;
|
|
1596
|
-
}
|
|
1597
|
-
else if (stopPrice !== undefined) {
|
|
1598
|
-
// request['price'] is taken as stopPrice for stop orders
|
|
1599
|
-
request['price'] = this.priceToPrecision(symbol, stopPrice);
|
|
1600
|
-
if (type === 'limit') {
|
|
1601
|
-
orderType = 'STOP LIMIT';
|
|
1602
|
-
request['price_aux_limit'] = this.priceToPrecision(symbol, price);
|
|
1603
|
-
}
|
|
1604
|
-
else {
|
|
1605
|
-
orderType = 'STOP';
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
const ioc = (timeInForce === 'IOC');
|
|
1609
|
-
const fok = (timeInForce === 'FOK');
|
|
1610
|
-
const postOnly = (postOnlyParam || (timeInForce === 'PO'));
|
|
1611
|
-
if ((ioc || fok) && (price === undefined)) {
|
|
1612
|
-
throw new InvalidOrder(this.id + ' createOrder() requires a price argument with IOC and FOK orders');
|
|
1613
|
-
}
|
|
1614
|
-
if ((ioc || fok) && (type === 'market')) {
|
|
1615
|
-
throw new InvalidOrder(this.id + ' createOrder() does not allow market IOC and FOK orders');
|
|
1616
|
-
}
|
|
1617
|
-
if ((type !== 'market') && (stopPrice === undefined)) {
|
|
1618
|
-
request['price'] = this.priceToPrecision(symbol, price);
|
|
1619
|
-
}
|
|
1620
|
-
if (ioc) {
|
|
1621
|
-
orderType = 'IOC';
|
|
1622
|
-
}
|
|
1623
|
-
else if (fok) {
|
|
1624
|
-
orderType = 'FOK';
|
|
1625
|
-
}
|
|
1626
|
-
let marginMode = undefined;
|
|
1627
|
-
[marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
|
|
1628
|
-
if (market['spot'] && (marginMode === undefined)) {
|
|
1629
|
-
// The EXCHANGE prefix is only required for non margin spot markets
|
|
1630
|
-
orderType = 'EXCHANGE ' + orderType;
|
|
1631
|
-
}
|
|
1632
|
-
request['type'] = orderType;
|
|
1633
|
-
// flag values may be summed to combine flags
|
|
1634
|
-
let flags = 0;
|
|
1635
|
-
if (postOnly) {
|
|
1636
|
-
flags = this.sum(flags, 4096);
|
|
1637
|
-
}
|
|
1638
|
-
if (reduceOnly) {
|
|
1639
|
-
flags = this.sum(flags, 1024);
|
|
1640
|
-
}
|
|
1641
|
-
if (flags !== 0) {
|
|
1642
|
-
request['flags'] = flags;
|
|
1643
|
-
}
|
|
1644
|
-
if (clientOrderId !== undefined) {
|
|
1645
|
-
request['cid'] = clientOrderId;
|
|
1646
|
-
}
|
|
1647
|
-
params = this.omit(params, ['triggerPrice', 'stopPrice', 'timeInForce', 'postOnly', 'reduceOnly', 'trailingAmount', 'clientOrderId']);
|
|
1648
|
-
return this.extend(request, params);
|
|
1649
|
-
}
|
|
1650
|
-
/**
|
|
1651
|
-
* @method
|
|
1652
|
-
* @name bitfinex2#createOrder
|
|
1653
|
-
* @description create an order on the exchange
|
|
1654
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-submit-order
|
|
1655
|
-
* @param {string} symbol unified CCXT market symbol
|
|
1656
|
-
* @param {string} type 'limit' or 'market'
|
|
1657
|
-
* @param {string} side 'buy' or 'sell'
|
|
1658
|
-
* @param {float} amount the amount of currency to trade
|
|
1659
|
-
* @param {float} [price] price of the order
|
|
1660
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1661
|
-
* @param {float} [params.stopPrice] the price that triggers a trigger order
|
|
1662
|
-
* @param {string} [params.timeInForce] "GTC", "IOC", "FOK", or "PO"
|
|
1663
|
-
* @param {boolean} [params.postOnly] set to true if you want to make a post only order
|
|
1664
|
-
* @param {boolean} [params.reduceOnly] indicates that the order is to reduce the size of a position
|
|
1665
|
-
* @param {int} [params.flags] additional order parameters: 4096 (Post Only), 1024 (Reduce Only), 16384 (OCO), 64 (Hidden), 512 (Close), 524288 (No Var Rates)
|
|
1666
|
-
* @param {int} [params.lev] leverage for a derivative order, supported by derivative symbol orders only. The value should be between 1 and 100 inclusive.
|
|
1667
|
-
* @param {string} [params.price_aux_limit] order price for stop limit orders
|
|
1668
|
-
* @param {string} [params.price_oco_stop] OCO stop price
|
|
1669
|
-
* @param {string} [params.trailingAmount] *swap only* the quote amount to trail away from the current market price
|
|
1670
|
-
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1671
|
-
*/
|
|
1672
|
-
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
1673
|
-
await this.loadMarkets();
|
|
1674
|
-
const market = this.market(symbol);
|
|
1675
|
-
const request = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
1676
|
-
const response = await this.privatePostAuthWOrderSubmit(request);
|
|
1677
|
-
//
|
|
1678
|
-
// [
|
|
1679
|
-
// 1653325121, // Timestamp in milliseconds
|
|
1680
|
-
// "on-req", // Purpose of notification ('on-req', 'oc-req', "uca", 'fon-req', "foc-req")
|
|
1681
|
-
// null, // unique ID of the message
|
|
1682
|
-
// null,
|
|
1683
|
-
// [
|
|
1684
|
-
// [
|
|
1685
|
-
// 95412102131, // Order ID
|
|
1686
|
-
// null, // Group ID
|
|
1687
|
-
// 1653325121798, // Client Order ID
|
|
1688
|
-
// "tDOGE:UST", // Market ID
|
|
1689
|
-
// 1653325121798, // Millisecond timestamp of creation
|
|
1690
|
-
// 1653325121798, // Millisecond timestamp of update
|
|
1691
|
-
// -10, // Amount (Positive means buy, negative means sell)
|
|
1692
|
-
// -10, // Original amount
|
|
1693
|
-
// "EXCHANGE LIMIT", // Type of the order: LIMIT, EXCHANGE LIMIT, MARKET, EXCHANGE MARKET, STOP, EXCHANGE STOP, STOP LIMIT, EXCHANGE STOP LIMIT, TRAILING STOP, EXCHANGE TRAILING STOP, FOK, EXCHANGE FOK, IOC, EXCHANGE IOC.
|
|
1694
|
-
// null, // Previous order type (stop-limit orders are converted to limit orders so for them previous type is always STOP)
|
|
1695
|
-
// null, // Millisecond timestamp of Time-In-Force: automatic order cancellation
|
|
1696
|
-
// null, // _PLACEHOLDER
|
|
1697
|
-
// 4096, // Flags, see parseOrderFlags()
|
|
1698
|
-
// "ACTIVE", // Order Status, see parseOrderStatus()
|
|
1699
|
-
// null, // _PLACEHOLDER
|
|
1700
|
-
// null, // _PLACEHOLDER
|
|
1701
|
-
// 0.071, // Price (Stop Price for stop-limit orders, Limit Price for limit orders)
|
|
1702
|
-
// 0, // Average Price
|
|
1703
|
-
// 0, // Trailing Price
|
|
1704
|
-
// 0, // Auxiliary Limit price (for STOP LIMIT)
|
|
1705
|
-
// null, // _PLACEHOLDER
|
|
1706
|
-
// null, // _PLACEHOLDER
|
|
1707
|
-
// null, // _PLACEHOLDER
|
|
1708
|
-
// 0, // Hidden (0 if false, 1 if true)
|
|
1709
|
-
// 0, // Placed ID (If another order caused this order to be placed (OCO) this will be that other order's ID)
|
|
1710
|
-
// null, // _PLACEHOLDER
|
|
1711
|
-
// null, // _PLACEHOLDER
|
|
1712
|
-
// null, // _PLACEHOLDER
|
|
1713
|
-
// "API>BFX", // Routing, indicates origin of action: BFX, ETHFX, API>BFX, API>ETHFX
|
|
1714
|
-
// null, // _PLACEHOLDER
|
|
1715
|
-
// null, // _PLACEHOLDER
|
|
1716
|
-
// {"$F7":1} // additional meta information about the order ( $F7 = IS_POST_ONLY (0 if false, 1 if true), $F33 = Leverage (int))
|
|
1717
|
-
// ]
|
|
1718
|
-
// ],
|
|
1719
|
-
// null, // CODE (work in progress)
|
|
1720
|
-
// "SUCCESS", // Status of the request
|
|
1721
|
-
// "Submitting 1 orders." // Message
|
|
1722
|
-
// ]
|
|
1723
|
-
//
|
|
1724
|
-
const status = this.safeString(response, 6);
|
|
1725
|
-
if (status !== 'SUCCESS') {
|
|
1726
|
-
const errorCode = response[5];
|
|
1727
|
-
const errorText = response[7];
|
|
1728
|
-
throw new ExchangeError(this.id + ' ' + response[6] + ': ' + errorText + ' (#' + errorCode + ')');
|
|
1729
|
-
}
|
|
1730
|
-
const orders = this.safeList(response, 4, []);
|
|
1731
|
-
const order = this.safeList(orders, 0);
|
|
1732
|
-
const newOrder = { 'result': order };
|
|
1733
|
-
return this.parseOrder(newOrder, market);
|
|
1734
|
-
}
|
|
1735
|
-
/**
|
|
1736
|
-
* @method
|
|
1737
|
-
* @name bitfinex2#createOrders
|
|
1738
|
-
* @description create a list of trade orders
|
|
1739
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-order-multi
|
|
1740
|
-
* @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
|
1741
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1742
|
-
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1743
|
-
*/
|
|
1744
|
-
async createOrders(orders, params = {}) {
|
|
1745
|
-
await this.loadMarkets();
|
|
1746
|
-
const ordersRequests = [];
|
|
1747
|
-
for (let i = 0; i < orders.length; i++) {
|
|
1748
|
-
const rawOrder = orders[i];
|
|
1749
|
-
const symbol = this.safeString(rawOrder, 'symbol');
|
|
1750
|
-
const type = this.safeString(rawOrder, 'type');
|
|
1751
|
-
const side = this.safeString(rawOrder, 'side');
|
|
1752
|
-
const amount = this.safeNumber(rawOrder, 'amount');
|
|
1753
|
-
const price = this.safeNumber(rawOrder, 'price');
|
|
1754
|
-
const orderParams = this.safeDict(rawOrder, 'params', {});
|
|
1755
|
-
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, orderParams);
|
|
1756
|
-
ordersRequests.push(['on', orderRequest]);
|
|
1757
|
-
}
|
|
1758
|
-
const request = {
|
|
1759
|
-
'ops': ordersRequests,
|
|
1760
|
-
};
|
|
1761
|
-
const response = await this.privatePostAuthWOrderMulti(request);
|
|
1762
|
-
//
|
|
1763
|
-
// [
|
|
1764
|
-
// 1706762515553,
|
|
1765
|
-
// "ox_multi-req",
|
|
1766
|
-
// null,
|
|
1767
|
-
// null,
|
|
1768
|
-
// [
|
|
1769
|
-
// [
|
|
1770
|
-
// 1706762515,
|
|
1771
|
-
// "on-req",
|
|
1772
|
-
// null,
|
|
1773
|
-
// null,
|
|
1774
|
-
// [
|
|
1775
|
-
// [139567428547,null,1706762515551,"tBTCUST",1706762515551,1706762515551,0.0001,0.0001,"EXCHANGE LIMIT",null,null,null,0,"ACTIVE",null,null,35000,0,0,0,null,null,null,0,0,null,null,null,"API>BFX",null,null,{}]
|
|
1776
|
-
// ],
|
|
1777
|
-
// null,
|
|
1778
|
-
// "SUCCESS",
|
|
1779
|
-
// "Submitting 1 orders."
|
|
1780
|
-
// ],
|
|
1781
|
-
// ],
|
|
1782
|
-
// null,
|
|
1783
|
-
// "SUCCESS",
|
|
1784
|
-
// "Submitting 2 order operations."
|
|
1785
|
-
// ]
|
|
1786
|
-
//
|
|
1787
|
-
const results = [];
|
|
1788
|
-
const data = this.safeList(response, 4, []);
|
|
1789
|
-
for (let i = 0; i < data.length; i++) {
|
|
1790
|
-
const entry = data[i];
|
|
1791
|
-
const individualOrder = entry[4];
|
|
1792
|
-
results.push({ 'result': individualOrder[0] });
|
|
1793
|
-
}
|
|
1794
|
-
return this.parseOrders(results);
|
|
1795
|
-
}
|
|
1796
|
-
/**
|
|
1797
|
-
* @method
|
|
1798
|
-
* @name bitfinex2#cancelAllOrders
|
|
1799
|
-
* @description cancel all open orders
|
|
1800
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-cancel-orders-multiple
|
|
1801
|
-
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
1802
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1803
|
-
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1804
|
-
*/
|
|
1805
|
-
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
1806
|
-
await this.loadMarkets();
|
|
1807
|
-
const request = {
|
|
1808
|
-
'all': 1,
|
|
1809
|
-
};
|
|
1810
|
-
const response = await this.privatePostAuthWOrderCancelMulti(this.extend(request, params));
|
|
1811
|
-
const orders = this.safeList(response, 4, []);
|
|
1812
|
-
const ordersList = [];
|
|
1813
|
-
for (let i = 0; i < orders.length; i++) {
|
|
1814
|
-
ordersList.push({ 'result': orders[i] });
|
|
1815
|
-
}
|
|
1816
|
-
return this.parseOrders(ordersList);
|
|
1817
|
-
}
|
|
1818
|
-
/**
|
|
1819
|
-
* @method
|
|
1820
|
-
* @name bitfinex2#cancelOrder
|
|
1821
|
-
* @description cancels an open order
|
|
1822
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-cancel-order
|
|
1823
|
-
* @param {string} id order id
|
|
1824
|
-
* @param {string} symbol Not used by bitfinex2 cancelOrder ()
|
|
1825
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1826
|
-
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1827
|
-
*/
|
|
1828
|
-
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
1829
|
-
await this.loadMarkets();
|
|
1830
|
-
const cid = this.safeValue2(params, 'cid', 'clientOrderId'); // client order id
|
|
1831
|
-
let request = undefined;
|
|
1832
|
-
let market = undefined;
|
|
1833
|
-
if (symbol !== undefined) {
|
|
1834
|
-
market = this.market(symbol);
|
|
1835
|
-
}
|
|
1836
|
-
if (cid !== undefined) {
|
|
1837
|
-
const cidDate = this.safeValue(params, 'cidDate'); // client order id date
|
|
1838
|
-
if (cidDate === undefined) {
|
|
1839
|
-
throw new InvalidOrder(this.id + " canceling an order by clientOrderId ('cid') requires both 'cid' and 'cid_date' ('YYYY-MM-DD')");
|
|
1840
|
-
}
|
|
1841
|
-
request = {
|
|
1842
|
-
'cid': cid,
|
|
1843
|
-
'cid_date': cidDate,
|
|
1844
|
-
};
|
|
1845
|
-
params = this.omit(params, ['cid', 'clientOrderId']);
|
|
1846
|
-
}
|
|
1847
|
-
else {
|
|
1848
|
-
request = {
|
|
1849
|
-
'id': parseInt(id),
|
|
1850
|
-
};
|
|
1851
|
-
}
|
|
1852
|
-
const response = await this.privatePostAuthWOrderCancel(this.extend(request, params));
|
|
1853
|
-
const order = this.safeValue(response, 4);
|
|
1854
|
-
const newOrder = { 'result': order };
|
|
1855
|
-
return this.parseOrder(newOrder, market);
|
|
1856
|
-
}
|
|
1857
|
-
/**
|
|
1858
|
-
* @method
|
|
1859
|
-
* @name bitfinex2#cancelOrders
|
|
1860
|
-
* @description cancel multiple orders at the same time
|
|
1861
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-cancel-orders-multiple
|
|
1862
|
-
* @param {string[]} ids order ids
|
|
1863
|
-
* @param {string} symbol unified market symbol, default is undefined
|
|
1864
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1865
|
-
* @returns {object} an array of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1866
|
-
*/
|
|
1867
|
-
async cancelOrders(ids, symbol = undefined, params = {}) {
|
|
1868
|
-
await this.loadMarkets();
|
|
1869
|
-
for (let i = 0; i < ids.length; i++) {
|
|
1870
|
-
ids[i] = this.parseToNumeric(ids[i]);
|
|
1871
|
-
}
|
|
1872
|
-
const request = {
|
|
1873
|
-
'id': ids,
|
|
1874
|
-
};
|
|
1875
|
-
let market = undefined;
|
|
1876
|
-
if (symbol !== undefined) {
|
|
1877
|
-
market = this.market(symbol);
|
|
1878
|
-
}
|
|
1879
|
-
const response = await this.privatePostAuthWOrderCancelMulti(this.extend(request, params));
|
|
1880
|
-
//
|
|
1881
|
-
// [
|
|
1882
|
-
// 1706740198811,
|
|
1883
|
-
// "oc_multi-req",
|
|
1884
|
-
// null,
|
|
1885
|
-
// null,
|
|
1886
|
-
// [
|
|
1887
|
-
// [
|
|
1888
|
-
// 139530205057,
|
|
1889
|
-
// null,
|
|
1890
|
-
// 1706740132275,
|
|
1891
|
-
// "tBTCF0:USTF0",
|
|
1892
|
-
// 1706740132276,
|
|
1893
|
-
// 1706740132276,
|
|
1894
|
-
// 0.0001,
|
|
1895
|
-
// 0.0001,
|
|
1896
|
-
// "LIMIT",
|
|
1897
|
-
// null,
|
|
1898
|
-
// null,
|
|
1899
|
-
// null,
|
|
1900
|
-
// 0,
|
|
1901
|
-
// "ACTIVE",
|
|
1902
|
-
// null,
|
|
1903
|
-
// null,
|
|
1904
|
-
// 39000,
|
|
1905
|
-
// 0,
|
|
1906
|
-
// 0,
|
|
1907
|
-
// 0,
|
|
1908
|
-
// null,
|
|
1909
|
-
// null,
|
|
1910
|
-
// null,
|
|
1911
|
-
// 0,
|
|
1912
|
-
// 0,
|
|
1913
|
-
// null,
|
|
1914
|
-
// null,
|
|
1915
|
-
// null,
|
|
1916
|
-
// "API>BFX",
|
|
1917
|
-
// null,
|
|
1918
|
-
// null,
|
|
1919
|
-
// {
|
|
1920
|
-
// "lev": 10,
|
|
1921
|
-
// "$F33": 10
|
|
1922
|
-
// }
|
|
1923
|
-
// ],
|
|
1924
|
-
// ],
|
|
1925
|
-
// null,
|
|
1926
|
-
// "SUCCESS",
|
|
1927
|
-
// "Submitting 2 order cancellations."
|
|
1928
|
-
// ]
|
|
1929
|
-
//
|
|
1930
|
-
const orders = this.safeList(response, 4, []);
|
|
1931
|
-
const ordersList = [];
|
|
1932
|
-
for (let i = 0; i < orders.length; i++) {
|
|
1933
|
-
ordersList.push({ 'result': orders[i] });
|
|
1934
|
-
}
|
|
1935
|
-
return this.parseOrders(ordersList, market);
|
|
1936
|
-
}
|
|
1937
|
-
/**
|
|
1938
|
-
* @method
|
|
1939
|
-
* @name bitfinex2#fetchOpenOrder
|
|
1940
|
-
* @description fetch an open order by it's id
|
|
1941
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-retrieve-orders
|
|
1942
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-retrieve-orders-by-symbol
|
|
1943
|
-
* @param {string} id order id
|
|
1944
|
-
* @param {string} symbol unified market symbol, default is undefined
|
|
1945
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1946
|
-
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1947
|
-
*/
|
|
1948
|
-
async fetchOpenOrder(id, symbol = undefined, params = {}) {
|
|
1949
|
-
const request = {
|
|
1950
|
-
'id': [parseInt(id)],
|
|
1951
|
-
};
|
|
1952
|
-
const orders = await this.fetchOpenOrders(symbol, undefined, undefined, this.extend(request, params));
|
|
1953
|
-
const order = this.safeValue(orders, 0);
|
|
1954
|
-
if (order === undefined) {
|
|
1955
|
-
throw new OrderNotFound(this.id + ' order ' + id + ' not found');
|
|
1956
|
-
}
|
|
1957
|
-
return order;
|
|
1958
|
-
}
|
|
1959
|
-
/**
|
|
1960
|
-
* @method
|
|
1961
|
-
* @name bitfinex2#fetchClosedOrder
|
|
1962
|
-
* @description fetch an open order by it's id
|
|
1963
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-retrieve-orders
|
|
1964
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-retrieve-orders-by-symbol
|
|
1965
|
-
* @param {string} id order id
|
|
1966
|
-
* @param {string} symbol unified market symbol, default is undefined
|
|
1967
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1968
|
-
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1969
|
-
*/
|
|
1970
|
-
async fetchClosedOrder(id, symbol = undefined, params = {}) {
|
|
1971
|
-
const request = {
|
|
1972
|
-
'id': [parseInt(id)],
|
|
1973
|
-
};
|
|
1974
|
-
const orders = await this.fetchClosedOrders(symbol, undefined, undefined, this.extend(request, params));
|
|
1975
|
-
const order = this.safeValue(orders, 0);
|
|
1976
|
-
if (order === undefined) {
|
|
1977
|
-
throw new OrderNotFound(this.id + ' order ' + id + ' not found');
|
|
1978
|
-
}
|
|
1979
|
-
return order;
|
|
1980
|
-
}
|
|
1981
|
-
/**
|
|
1982
|
-
* @method
|
|
1983
|
-
* @name bitfinex2#fetchOpenOrders
|
|
1984
|
-
* @description fetch all unfilled currently open orders
|
|
1985
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-retrieve-orders
|
|
1986
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-retrieve-orders-by-symbol
|
|
1987
|
-
* @param {string} symbol unified market symbol
|
|
1988
|
-
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
1989
|
-
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
1990
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1991
|
-
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1992
|
-
*/
|
|
1993
|
-
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1994
|
-
await this.loadMarkets();
|
|
1995
|
-
const request = {};
|
|
1996
|
-
let market = undefined;
|
|
1997
|
-
let response = undefined;
|
|
1998
|
-
if (symbol === undefined) {
|
|
1999
|
-
response = await this.privatePostAuthROrders(this.extend(request, params));
|
|
2000
|
-
}
|
|
2001
|
-
else {
|
|
2002
|
-
market = this.market(symbol);
|
|
2003
|
-
request['symbol'] = market['id'];
|
|
2004
|
-
response = await this.privatePostAuthROrdersSymbol(this.extend(request, params));
|
|
2005
|
-
}
|
|
2006
|
-
//
|
|
2007
|
-
// [
|
|
2008
|
-
// [
|
|
2009
|
-
// 95408916206, // Order ID
|
|
2010
|
-
// null, // Group Order ID
|
|
2011
|
-
// 1653322349926, // Client Order ID
|
|
2012
|
-
// "tDOGE:UST", // Market ID
|
|
2013
|
-
// 1653322349926, // Created Timestamp in milliseconds
|
|
2014
|
-
// 1653322349927, // Updated Timestamp in milliseconds
|
|
2015
|
-
// -10, // Amount remaining (Positive means buy, negative means sell)
|
|
2016
|
-
// -10, // Original amount
|
|
2017
|
-
// "EXCHANGE LIMIT", // Order type
|
|
2018
|
-
// null, // Previous Order Type
|
|
2019
|
-
// null, // _PLACEHOLDER
|
|
2020
|
-
// null, // _PLACEHOLDER
|
|
2021
|
-
// 0, // Flags, see parseOrderFlags()
|
|
2022
|
-
// "ACTIVE", // Order Status, see parseOrderStatus()
|
|
2023
|
-
// null, // _PLACEHOLDER
|
|
2024
|
-
// null, // _PLACEHOLDER
|
|
2025
|
-
// 0.11, // Price
|
|
2026
|
-
// 0, // Average Price
|
|
2027
|
-
// 0, // Trailing Price
|
|
2028
|
-
// 0, // Auxiliary Limit price (for STOP LIMIT)
|
|
2029
|
-
// null, // _PLACEHOLDER
|
|
2030
|
-
// null, // _PLACEHOLDER
|
|
2031
|
-
// null, // _PLACEHOLDER
|
|
2032
|
-
// 0, // Hidden (0 if false, 1 if true)
|
|
2033
|
-
// 0, // Placed ID (If another order caused this order to be placed (OCO) this will be that other order's ID)
|
|
2034
|
-
// null, // _PLACEHOLDER
|
|
2035
|
-
// null, // _PLACEHOLDER
|
|
2036
|
-
// null, // _PLACEHOLDER
|
|
2037
|
-
// "API>BFX", // Routing, indicates origin of action: BFX, ETHFX, API>BFX, API>ETHFX
|
|
2038
|
-
// null, // _PLACEHOLDER
|
|
2039
|
-
// null, // _PLACEHOLDER
|
|
2040
|
-
// {"$F7":1} // additional meta information about the order ( $F7 = IS_POST_ONLY (0 if false, 1 if true), $F33 = Leverage (int))
|
|
2041
|
-
// ],
|
|
2042
|
-
// ]
|
|
2043
|
-
//
|
|
2044
|
-
const ordersList = [];
|
|
2045
|
-
for (let i = 0; i < response.length; i++) {
|
|
2046
|
-
ordersList.push({ 'result': response[i] });
|
|
2047
|
-
}
|
|
2048
|
-
return this.parseOrders(ordersList, market, since, limit);
|
|
2049
|
-
}
|
|
2050
|
-
/**
|
|
2051
|
-
* @method
|
|
2052
|
-
* @name bitfinex2#fetchClosedOrders
|
|
2053
|
-
* @description fetches information on multiple closed orders made by the user
|
|
2054
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-retrieve-orders
|
|
2055
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-retrieve-orders-by-symbol
|
|
2056
|
-
* @param {string} symbol unified market symbol of the market orders were made in
|
|
2057
|
-
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
2058
|
-
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
2059
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2060
|
-
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
2061
|
-
* @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)
|
|
2062
|
-
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2063
|
-
*/
|
|
2064
|
-
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2065
|
-
// returns the most recent closed or canceled orders up to circa two weeks ago
|
|
2066
|
-
await this.loadMarkets();
|
|
2067
|
-
let paginate = false;
|
|
2068
|
-
[paginate, params] = this.handleOptionAndParams(params, 'fetchClosedOrders', 'paginate');
|
|
2069
|
-
if (paginate) {
|
|
2070
|
-
return await this.fetchPaginatedCallDynamic('fetchClosedOrders', symbol, since, limit, params);
|
|
2071
|
-
}
|
|
2072
|
-
let request = {};
|
|
2073
|
-
if (since !== undefined) {
|
|
2074
|
-
request['start'] = since;
|
|
2075
|
-
}
|
|
2076
|
-
if (limit !== undefined) {
|
|
2077
|
-
request['limit'] = limit; // default 25, max 2500
|
|
2078
|
-
}
|
|
2079
|
-
[request, params] = this.handleUntilOption('end', request, params);
|
|
2080
|
-
let market = undefined;
|
|
2081
|
-
let response = undefined;
|
|
2082
|
-
if (symbol === undefined) {
|
|
2083
|
-
response = await this.privatePostAuthROrdersHist(this.extend(request, params));
|
|
2084
|
-
}
|
|
2085
|
-
else {
|
|
2086
|
-
market = this.market(symbol);
|
|
2087
|
-
request['symbol'] = market['id'];
|
|
2088
|
-
response = await this.privatePostAuthROrdersSymbolHist(this.extend(request, params));
|
|
2089
|
-
}
|
|
2090
|
-
//
|
|
2091
|
-
// [
|
|
2092
|
-
// [
|
|
2093
|
-
// 95412102131, // Order ID
|
|
2094
|
-
// null, // Group Order ID
|
|
2095
|
-
// 1653325121798, // Client Order ID
|
|
2096
|
-
// "tDOGE:UST", // Market ID
|
|
2097
|
-
// 1653325122000, // Created Timestamp in milliseconds
|
|
2098
|
-
// 1653325122000, // Updated Timestamp in milliseconds
|
|
2099
|
-
// -10, // Amount remaining (Positive means buy, negative means sell)
|
|
2100
|
-
// -10, // Original amount
|
|
2101
|
-
// "EXCHANGE LIMIT", // Order type
|
|
2102
|
-
// null, // Previous Order Type
|
|
2103
|
-
// null, // Millisecond timestamp of Time-In-Force: automatic order cancellation
|
|
2104
|
-
// null, // _PLACEHOLDER
|
|
2105
|
-
// "4096", // Flags, see parseOrderFlags()
|
|
2106
|
-
// "POSTONLY CANCELED", // Order Status, see parseOrderStatus()
|
|
2107
|
-
// null, // _PLACEHOLDER
|
|
2108
|
-
// null, // _PLACEHOLDER
|
|
2109
|
-
// 0.071, // Price
|
|
2110
|
-
// 0, // Average Price
|
|
2111
|
-
// 0, // Trailing Price
|
|
2112
|
-
// 0, // Auxiliary Limit price (for STOP LIMIT)
|
|
2113
|
-
// null, // _PLACEHOLDER
|
|
2114
|
-
// null, // _PLACEHOLDER
|
|
2115
|
-
// null, // _PLACEHOLDER
|
|
2116
|
-
// 0, // Notify (0 if false, 1 if true)
|
|
2117
|
-
// 0, // Hidden (0 if false, 1 if true)
|
|
2118
|
-
// null, // Placed ID (If another order caused this order to be placed (OCO) this will be that other order's ID)
|
|
2119
|
-
// null, // _PLACEHOLDER
|
|
2120
|
-
// null, // _PLACEHOLDER
|
|
2121
|
-
// "API>BFX", // Routing, indicates origin of action: BFX, ETHFX, API>BFX, API>ETHFX
|
|
2122
|
-
// null, // _PLACEHOLDER
|
|
2123
|
-
// null, // _PLACEHOLDER
|
|
2124
|
-
// {"_$F7":1} // additional meta information about the order ( _$F7 = IS_POST_ONLY (0 if false, 1 if true), _$F33 = Leverage (int))
|
|
2125
|
-
// ]
|
|
2126
|
-
// ]
|
|
2127
|
-
//
|
|
2128
|
-
const ordersList = [];
|
|
2129
|
-
for (let i = 0; i < response.length; i++) {
|
|
2130
|
-
ordersList.push({ 'result': response[i] });
|
|
2131
|
-
}
|
|
2132
|
-
return this.parseOrders(ordersList, market, since, limit);
|
|
2133
|
-
}
|
|
2134
|
-
/**
|
|
2135
|
-
* @method
|
|
2136
|
-
* @name bitfinex2#fetchOrderTrades
|
|
2137
|
-
* @description fetch all the trades made from a single order
|
|
2138
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-order-trades
|
|
2139
|
-
* @param {string} id order id
|
|
2140
|
-
* @param {string} symbol unified market symbol
|
|
2141
|
-
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
2142
|
-
* @param {int} [limit] the maximum number of trades to retrieve
|
|
2143
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2144
|
-
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
2145
|
-
*/
|
|
2146
|
-
async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2147
|
-
if (symbol === undefined) {
|
|
2148
|
-
throw new ArgumentsRequired(this.id + ' fetchOrderTrades() requires a symbol argument');
|
|
2149
|
-
}
|
|
2150
|
-
await this.loadMarkets();
|
|
2151
|
-
const market = this.market(symbol);
|
|
2152
|
-
const orderId = parseInt(id);
|
|
2153
|
-
const request = {
|
|
2154
|
-
'id': orderId,
|
|
2155
|
-
'symbol': market['id'],
|
|
2156
|
-
};
|
|
2157
|
-
// valid for trades upto 10 days old
|
|
2158
|
-
const response = await this.privatePostAuthROrderSymbolIdTrades(this.extend(request, params));
|
|
2159
|
-
const tradesList = [];
|
|
2160
|
-
for (let i = 0; i < response.length; i++) {
|
|
2161
|
-
tradesList.push({ 'result': response[i] }); // convert to array of dicts to match parseOrder signature
|
|
2162
|
-
}
|
|
2163
|
-
return this.parseTrades(tradesList, market, since, limit);
|
|
2164
|
-
}
|
|
2165
|
-
/**
|
|
2166
|
-
* @method
|
|
2167
|
-
* @name bitfinex2#fetchMyTrades
|
|
2168
|
-
* @description fetch all trades made by the user
|
|
2169
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-trades
|
|
2170
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-trades-by-symbol
|
|
2171
|
-
* @param {string} symbol unified market symbol
|
|
2172
|
-
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
2173
|
-
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
2174
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2175
|
-
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
2176
|
-
*/
|
|
2177
|
-
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2178
|
-
await this.loadMarkets();
|
|
2179
|
-
let market = undefined;
|
|
2180
|
-
const request = {
|
|
2181
|
-
'end': this.milliseconds(),
|
|
2182
|
-
};
|
|
2183
|
-
if (since !== undefined) {
|
|
2184
|
-
request['start'] = since;
|
|
2185
|
-
}
|
|
2186
|
-
if (limit !== undefined) {
|
|
2187
|
-
request['limit'] = limit; // default 25, max 1000
|
|
2188
|
-
}
|
|
2189
|
-
let response = undefined;
|
|
2190
|
-
if (symbol !== undefined) {
|
|
2191
|
-
market = this.market(symbol);
|
|
2192
|
-
request['symbol'] = market['id'];
|
|
2193
|
-
response = await this.privatePostAuthRTradesSymbolHist(this.extend(request, params));
|
|
2194
|
-
}
|
|
2195
|
-
else {
|
|
2196
|
-
response = await this.privatePostAuthRTradesHist(this.extend(request, params));
|
|
2197
|
-
}
|
|
2198
|
-
const tradesList = [];
|
|
2199
|
-
for (let i = 0; i < response.length; i++) {
|
|
2200
|
-
tradesList.push({ 'result': response[i] }); // convert to array of dicts to match parseOrder signature
|
|
2201
|
-
}
|
|
2202
|
-
return this.parseTrades(tradesList, market, since, limit);
|
|
2203
|
-
}
|
|
2204
|
-
/**
|
|
2205
|
-
* @method
|
|
2206
|
-
* @name bitfinex2#createDepositAddress
|
|
2207
|
-
* @description create a currency deposit address
|
|
2208
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-deposit-address
|
|
2209
|
-
* @param {string} code unified currency code of the currency for the deposit address
|
|
2210
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2211
|
-
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
2212
|
-
*/
|
|
2213
|
-
async createDepositAddress(code, params = {}) {
|
|
2214
|
-
await this.loadMarkets();
|
|
2215
|
-
const request = {
|
|
2216
|
-
'op_renew': 1,
|
|
2217
|
-
};
|
|
2218
|
-
return await this.fetchDepositAddress(code, this.extend(request, params));
|
|
2219
|
-
}
|
|
2220
|
-
/**
|
|
2221
|
-
* @method
|
|
2222
|
-
* @name bitfinex2#fetchDepositAddress
|
|
2223
|
-
* @description fetch the deposit address for a currency associated with this account
|
|
2224
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-deposit-address
|
|
2225
|
-
* @param {string} code unified currency code
|
|
2226
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2227
|
-
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
2228
|
-
*/
|
|
2229
|
-
async fetchDepositAddress(code, params = {}) {
|
|
2230
|
-
await this.loadMarkets();
|
|
2231
|
-
const currency = this.currency(code);
|
|
2232
|
-
// if not provided explicitly we will try to match using the currency name
|
|
2233
|
-
const network = this.safeString(params, 'network', code);
|
|
2234
|
-
const currencyNetworks = this.safeValue(currency, 'networks', {});
|
|
2235
|
-
const currencyNetwork = this.safeValue(currencyNetworks, network);
|
|
2236
|
-
const networkId = this.safeString(currencyNetwork, 'id');
|
|
2237
|
-
if (networkId === undefined) {
|
|
2238
|
-
throw new ArgumentsRequired(this.id + " fetchDepositAddress() could not find a network for '" + code + "'. You can specify it by providing the 'network' value inside params");
|
|
2239
|
-
}
|
|
2240
|
-
const wallet = this.safeString(params, 'wallet', 'exchange'); // 'exchange', 'margin', 'funding' and also old labels 'exchange', 'trading', 'deposit', respectively
|
|
2241
|
-
params = this.omit(params, 'network', 'wallet');
|
|
2242
|
-
const request = {
|
|
2243
|
-
'method': networkId,
|
|
2244
|
-
'wallet': wallet,
|
|
2245
|
-
'op_renew': 0, // a value of 1 will generate a new address
|
|
2246
|
-
};
|
|
2247
|
-
const response = await this.privatePostAuthWDepositAddress(this.extend(request, params));
|
|
2248
|
-
//
|
|
2249
|
-
// [
|
|
2250
|
-
// 1582269616687, // MTS Millisecond Time Stamp of the update
|
|
2251
|
-
// "acc_dep", // TYPE Purpose of notification "acc_dep" for account deposit
|
|
2252
|
-
// null, // MESSAGE_ID unique ID of the message
|
|
2253
|
-
// null, // not documented
|
|
2254
|
-
// [
|
|
2255
|
-
// null, // PLACEHOLDER
|
|
2256
|
-
// "BITCOIN", // METHOD Method of deposit
|
|
2257
|
-
// "BTC", // CURRENCY_CODE Currency code of new address
|
|
2258
|
-
// null, // PLACEHOLDER
|
|
2259
|
-
// "1BC9PZqpUmjyEB54uggn8TFKj49zSDYzqG", // ADDRESS
|
|
2260
|
-
// null, // POOL_ADDRESS
|
|
2261
|
-
// ],
|
|
2262
|
-
// null, // CODE null or integer work in progress
|
|
2263
|
-
// "SUCCESS", // STATUS Status of the notification, SUCCESS, ERROR, FAILURE
|
|
2264
|
-
// "success", // TEXT Text of the notification
|
|
2265
|
-
// ]
|
|
2266
|
-
//
|
|
2267
|
-
const result = this.safeValue(response, 4, []);
|
|
2268
|
-
const poolAddress = this.safeString(result, 5);
|
|
2269
|
-
const address = (poolAddress === undefined) ? this.safeString(result, 4) : poolAddress;
|
|
2270
|
-
const tag = (poolAddress === undefined) ? undefined : this.safeString(result, 4);
|
|
2271
|
-
this.checkAddress(address);
|
|
2272
|
-
return {
|
|
2273
|
-
'currency': code,
|
|
2274
|
-
'address': address,
|
|
2275
|
-
'tag': tag,
|
|
2276
|
-
'network': undefined,
|
|
2277
|
-
'info': response,
|
|
2278
|
-
};
|
|
2279
|
-
}
|
|
2280
|
-
parseTransactionStatus(status) {
|
|
2281
|
-
const statuses = {
|
|
2282
|
-
'SUCCESS': 'ok',
|
|
2283
|
-
'COMPLETED': 'ok',
|
|
2284
|
-
'ERROR': 'failed',
|
|
2285
|
-
'FAILURE': 'failed',
|
|
2286
|
-
'CANCELED': 'canceled',
|
|
2287
|
-
'PENDING APPROVAL': 'pending',
|
|
2288
|
-
'PENDING': 'pending',
|
|
2289
|
-
'PENDING REVIEW': 'pending',
|
|
2290
|
-
'PENDING CANCELLATION': 'pending',
|
|
2291
|
-
'SENDING': 'pending',
|
|
2292
|
-
'USER APPROVED': 'pending',
|
|
2293
|
-
};
|
|
2294
|
-
return this.safeString(statuses, status, status);
|
|
2295
|
-
}
|
|
2296
|
-
parseTransaction(transaction, currency = undefined) {
|
|
2297
|
-
//
|
|
2298
|
-
// withdraw
|
|
2299
|
-
//
|
|
2300
|
-
// [
|
|
2301
|
-
// 1582271520931, // MTS Millisecond Time Stamp of the update
|
|
2302
|
-
// "acc_wd-req", // TYPE Purpose of notification "acc_wd-req" account withdrawal request
|
|
2303
|
-
// null, // MESSAGE_ID unique ID of the message
|
|
2304
|
-
// null, // not documented
|
|
2305
|
-
// [
|
|
2306
|
-
// 0, // WITHDRAWAL_ID Unique Withdrawal ID
|
|
2307
|
-
// null, // PLACEHOLDER
|
|
2308
|
-
// "bitcoin", // METHOD Method of withdrawal
|
|
2309
|
-
// null, // PAYMENT_ID Payment ID if relevant
|
|
2310
|
-
// "exchange", // WALLET Sending wallet
|
|
2311
|
-
// 1, // AMOUNT Amount of Withdrawal less fee
|
|
2312
|
-
// null, // PLACEHOLDER
|
|
2313
|
-
// null, // PLACEHOLDER
|
|
2314
|
-
// 0.0004, // WITHDRAWAL_FEE Fee on withdrawal
|
|
2315
|
-
// ],
|
|
2316
|
-
// null, // CODE null or integer Work in progress
|
|
2317
|
-
// "SUCCESS", // STATUS Status of the notification, it may vary over time SUCCESS, ERROR, FAILURE
|
|
2318
|
-
// "Invalid bitcoin address (abcdef)", // TEXT Text of the notification
|
|
2319
|
-
// ]
|
|
2320
|
-
//
|
|
2321
|
-
// fetchDepositsWithdrawals
|
|
2322
|
-
//
|
|
2323
|
-
// [
|
|
2324
|
-
// 13293039, // ID
|
|
2325
|
-
// "ETH", // CURRENCY
|
|
2326
|
-
// "ETHEREUM", // CURRENCY_NAME
|
|
2327
|
-
// null,
|
|
2328
|
-
// null,
|
|
2329
|
-
// 1574175052000, // MTS_STARTED
|
|
2330
|
-
// 1574181326000, // MTS_UPDATED
|
|
2331
|
-
// null,
|
|
2332
|
-
// null,
|
|
2333
|
-
// "CANCELED", // STATUS
|
|
2334
|
-
// null,
|
|
2335
|
-
// null,
|
|
2336
|
-
// -0.24, // AMOUNT, negative for withdrawals
|
|
2337
|
-
// -0.00135, // FEES
|
|
2338
|
-
// null,
|
|
2339
|
-
// null,
|
|
2340
|
-
// "0x38110e0Fc932CB2BE...........", // DESTINATION_ADDRESS
|
|
2341
|
-
// null,
|
|
2342
|
-
// null,
|
|
2343
|
-
// null,
|
|
2344
|
-
// "0x523ec8945500.....................................", // TRANSACTION_ID
|
|
2345
|
-
// "Purchase of 100 pizzas", // WITHDRAW_TRANSACTION_NOTE, might also be: null
|
|
2346
|
-
// ]
|
|
2347
|
-
//
|
|
2348
|
-
const transactionLength = transaction.length;
|
|
2349
|
-
let timestamp = undefined;
|
|
2350
|
-
let updated = undefined;
|
|
2351
|
-
let code = undefined;
|
|
2352
|
-
let amount = undefined;
|
|
2353
|
-
let id = undefined;
|
|
2354
|
-
let status = undefined;
|
|
2355
|
-
let tag = undefined;
|
|
2356
|
-
let type = undefined;
|
|
2357
|
-
let feeCost = undefined;
|
|
2358
|
-
let txid = undefined;
|
|
2359
|
-
let addressTo = undefined;
|
|
2360
|
-
let network = undefined;
|
|
2361
|
-
let comment = undefined;
|
|
2362
|
-
if (transactionLength === 8) {
|
|
2363
|
-
const data = this.safeValue(transaction, 4, []);
|
|
2364
|
-
timestamp = this.safeInteger(transaction, 0);
|
|
2365
|
-
if (currency !== undefined) {
|
|
2366
|
-
code = currency['code'];
|
|
2367
|
-
}
|
|
2368
|
-
feeCost = this.safeString(data, 8);
|
|
2369
|
-
if (feeCost !== undefined) {
|
|
2370
|
-
feeCost = Precise.stringAbs(feeCost);
|
|
2371
|
-
}
|
|
2372
|
-
amount = this.safeNumber(data, 5);
|
|
2373
|
-
id = this.safeInteger(data, 0);
|
|
2374
|
-
status = 'ok';
|
|
2375
|
-
if (id === 0) {
|
|
2376
|
-
id = undefined;
|
|
2377
|
-
status = 'failed';
|
|
2378
|
-
}
|
|
2379
|
-
tag = this.safeString(data, 3);
|
|
2380
|
-
type = 'withdrawal';
|
|
2381
|
-
const networkId = this.safeString(data, 2);
|
|
2382
|
-
network = this.networkIdToCode(networkId.toUpperCase()); // withdraw returns in lowercase
|
|
2383
|
-
}
|
|
2384
|
-
else if (transactionLength === 22) {
|
|
2385
|
-
id = this.safeString(transaction, 0);
|
|
2386
|
-
const currencyId = this.safeString(transaction, 1);
|
|
2387
|
-
code = this.safeCurrencyCode(currencyId, currency);
|
|
2388
|
-
const networkId = this.safeString(transaction, 2);
|
|
2389
|
-
network = this.networkIdToCode(networkId);
|
|
2390
|
-
timestamp = this.safeInteger(transaction, 5);
|
|
2391
|
-
updated = this.safeInteger(transaction, 6);
|
|
2392
|
-
status = this.parseTransactionStatus(this.safeString(transaction, 9));
|
|
2393
|
-
const signedAmount = this.safeString(transaction, 12);
|
|
2394
|
-
amount = Precise.stringAbs(signedAmount);
|
|
2395
|
-
if (signedAmount !== undefined) {
|
|
2396
|
-
if (Precise.stringLt(signedAmount, '0')) {
|
|
2397
|
-
type = 'withdrawal';
|
|
2398
|
-
}
|
|
2399
|
-
else {
|
|
2400
|
-
type = 'deposit';
|
|
2401
|
-
}
|
|
2402
|
-
}
|
|
2403
|
-
feeCost = this.safeString(transaction, 13);
|
|
2404
|
-
if (feeCost !== undefined) {
|
|
2405
|
-
feeCost = Precise.stringAbs(feeCost);
|
|
2406
|
-
}
|
|
2407
|
-
addressTo = this.safeString(transaction, 16);
|
|
2408
|
-
txid = this.safeString(transaction, 20);
|
|
2409
|
-
comment = this.safeString(transaction, 21);
|
|
2410
|
-
}
|
|
2411
|
-
return {
|
|
2412
|
-
'info': transaction,
|
|
2413
|
-
'id': id,
|
|
2414
|
-
'txid': txid,
|
|
2415
|
-
'type': type,
|
|
2416
|
-
'currency': code,
|
|
2417
|
-
'network': network,
|
|
2418
|
-
'amount': this.parseNumber(amount),
|
|
2419
|
-
'status': status,
|
|
2420
|
-
'timestamp': timestamp,
|
|
2421
|
-
'datetime': this.iso8601(timestamp),
|
|
2422
|
-
'address': addressTo,
|
|
2423
|
-
'addressFrom': undefined,
|
|
2424
|
-
'addressTo': addressTo,
|
|
2425
|
-
'tag': tag,
|
|
2426
|
-
'tagFrom': undefined,
|
|
2427
|
-
'tagTo': tag,
|
|
2428
|
-
'updated': updated,
|
|
2429
|
-
'comment': comment,
|
|
2430
|
-
'internal': undefined,
|
|
2431
|
-
'fee': {
|
|
2432
|
-
'currency': code,
|
|
2433
|
-
'cost': this.parseNumber(feeCost),
|
|
2434
|
-
'rate': undefined,
|
|
2435
|
-
},
|
|
2436
|
-
};
|
|
2437
|
-
}
|
|
2438
|
-
/**
|
|
2439
|
-
* @method
|
|
2440
|
-
* @name bitfinex2#fetchTradingFees
|
|
2441
|
-
* @description fetch the trading fees for multiple markets
|
|
2442
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-summary
|
|
2443
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2444
|
-
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
|
|
2445
|
-
*/
|
|
2446
|
-
async fetchTradingFees(params = {}) {
|
|
2447
|
-
await this.loadMarkets();
|
|
2448
|
-
const response = await this.privatePostAuthRSummary(params);
|
|
2449
|
-
//
|
|
2450
|
-
// Response Spec:
|
|
2451
|
-
// [
|
|
2452
|
-
// PLACEHOLDER,
|
|
2453
|
-
// PLACEHOLDER,
|
|
2454
|
-
// PLACEHOLDER,
|
|
2455
|
-
// PLACEHOLDER,
|
|
2456
|
-
// [
|
|
2457
|
-
// [
|
|
2458
|
-
// MAKER_FEE,
|
|
2459
|
-
// MAKER_FEE,
|
|
2460
|
-
// MAKER_FEE,
|
|
2461
|
-
// PLACEHOLDER,
|
|
2462
|
-
// PLACEHOLDER,
|
|
2463
|
-
// DERIV_REBATE
|
|
2464
|
-
// ],
|
|
2465
|
-
// [
|
|
2466
|
-
// TAKER_FEE_TO_CRYPTO,
|
|
2467
|
-
// TAKER_FEE_TO_STABLE,
|
|
2468
|
-
// TAKER_FEE_TO_FIAT,
|
|
2469
|
-
// PLACEHOLDER,
|
|
2470
|
-
// PLACEHOLDER,
|
|
2471
|
-
// DERIV_TAKER_FEE
|
|
2472
|
-
// ]
|
|
2473
|
-
// ],
|
|
2474
|
-
// PLACEHOLDER,
|
|
2475
|
-
// PLACEHOLDER,
|
|
2476
|
-
// PLACEHOLDER,
|
|
2477
|
-
// PLACEHOLDER,
|
|
2478
|
-
// {
|
|
2479
|
-
// LEO_LEV,
|
|
2480
|
-
// LEO_AMOUNT_AVG
|
|
2481
|
-
// }
|
|
2482
|
-
// ]
|
|
2483
|
-
//
|
|
2484
|
-
// Example response:
|
|
2485
|
-
//
|
|
2486
|
-
// [
|
|
2487
|
-
// null,
|
|
2488
|
-
// null,
|
|
2489
|
-
// null,
|
|
2490
|
-
// null,
|
|
2491
|
-
// [
|
|
2492
|
-
// [ 0.001, 0.001, 0.001, null, null, 0.0002 ],
|
|
2493
|
-
// [ 0.002, 0.002, 0.002, null, null, 0.00065 ]
|
|
2494
|
-
// ],
|
|
2495
|
-
// [
|
|
2496
|
-
// [
|
|
2497
|
-
// {
|
|
2498
|
-
// "curr": "Total (USD)",
|
|
2499
|
-
// "vol": "0",
|
|
2500
|
-
// "vol_safe": "0",
|
|
2501
|
-
// "vol_maker": "0",
|
|
2502
|
-
// "vol_BFX": "0",
|
|
2503
|
-
// "vol_BFX_safe": "0",
|
|
2504
|
-
// "vol_BFX_maker": "0"
|
|
2505
|
-
// }
|
|
2506
|
-
// ],
|
|
2507
|
-
// {},
|
|
2508
|
-
// 0
|
|
2509
|
-
// ],
|
|
2510
|
-
// [ null, {}, 0 ],
|
|
2511
|
-
// null,
|
|
2512
|
-
// null,
|
|
2513
|
-
// { leo_lev: "0", leo_amount_avg: "0" }
|
|
2514
|
-
// ]
|
|
2515
|
-
//
|
|
2516
|
-
const result = {};
|
|
2517
|
-
const fiat = this.safeValue(this.options, 'fiat', {});
|
|
2518
|
-
const feeData = this.safeValue(response, 4, []);
|
|
2519
|
-
const makerData = this.safeValue(feeData, 0, []);
|
|
2520
|
-
const takerData = this.safeValue(feeData, 1, []);
|
|
2521
|
-
const makerFee = this.safeNumber(makerData, 0);
|
|
2522
|
-
const makerFeeFiat = this.safeNumber(makerData, 2);
|
|
2523
|
-
const makerFeeDeriv = this.safeNumber(makerData, 5);
|
|
2524
|
-
const takerFee = this.safeNumber(takerData, 0);
|
|
2525
|
-
const takerFeeFiat = this.safeNumber(takerData, 2);
|
|
2526
|
-
const takerFeeDeriv = this.safeNumber(takerData, 5);
|
|
2527
|
-
for (let i = 0; i < this.symbols.length; i++) {
|
|
2528
|
-
const symbol = this.symbols[i];
|
|
2529
|
-
const market = this.market(symbol);
|
|
2530
|
-
const fee = {
|
|
2531
|
-
'info': response,
|
|
2532
|
-
'symbol': symbol,
|
|
2533
|
-
'percentage': true,
|
|
2534
|
-
'tierBased': true,
|
|
2535
|
-
};
|
|
2536
|
-
if (market['quote'] in fiat) {
|
|
2537
|
-
fee['maker'] = makerFeeFiat;
|
|
2538
|
-
fee['taker'] = takerFeeFiat;
|
|
2539
|
-
}
|
|
2540
|
-
else if (market['contract']) {
|
|
2541
|
-
fee['maker'] = makerFeeDeriv;
|
|
2542
|
-
fee['taker'] = takerFeeDeriv;
|
|
2543
|
-
}
|
|
2544
|
-
else { // TODO check if stable coin
|
|
2545
|
-
fee['maker'] = makerFee;
|
|
2546
|
-
fee['taker'] = takerFee;
|
|
2547
|
-
}
|
|
2548
|
-
result[symbol] = fee;
|
|
2549
|
-
}
|
|
2550
|
-
return result;
|
|
2551
|
-
}
|
|
2552
|
-
/**
|
|
2553
|
-
* @method
|
|
2554
|
-
* @name bitfinex2#fetchDepositsWithdrawals
|
|
2555
|
-
* @description fetch history of deposits and withdrawals
|
|
2556
|
-
* @see https://docs.bitfinex.com/reference/movement-info
|
|
2557
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-movements
|
|
2558
|
-
* @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
|
|
2559
|
-
* @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
|
|
2560
|
-
* @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
|
|
2561
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2562
|
-
* @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
2563
|
-
*/
|
|
2564
|
-
async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2565
|
-
await this.loadMarkets();
|
|
2566
|
-
let currency = undefined;
|
|
2567
|
-
const request = {};
|
|
2568
|
-
if (since !== undefined) {
|
|
2569
|
-
request['start'] = since;
|
|
2570
|
-
}
|
|
2571
|
-
if (limit !== undefined) {
|
|
2572
|
-
request['limit'] = limit; // max 1000
|
|
2573
|
-
}
|
|
2574
|
-
let response = undefined;
|
|
2575
|
-
if (code !== undefined) {
|
|
2576
|
-
currency = this.currency(code);
|
|
2577
|
-
request['currency'] = currency['uppercaseId'];
|
|
2578
|
-
response = await this.privatePostAuthRMovementsCurrencyHist(this.extend(request, params));
|
|
2579
|
-
}
|
|
2580
|
-
else {
|
|
2581
|
-
response = await this.privatePostAuthRMovementsHist(this.extend(request, params));
|
|
2582
|
-
}
|
|
2583
|
-
//
|
|
2584
|
-
// [
|
|
2585
|
-
// [
|
|
2586
|
-
// 13293039, // ID
|
|
2587
|
-
// "ETH", // CURRENCY
|
|
2588
|
-
// "ETHEREUM", // CURRENCY_NAME
|
|
2589
|
-
// null,
|
|
2590
|
-
// null,
|
|
2591
|
-
// 1574175052000, // MTS_STARTED
|
|
2592
|
-
// 1574181326000, // MTS_UPDATED
|
|
2593
|
-
// null,
|
|
2594
|
-
// null,
|
|
2595
|
-
// "CANCELED", // STATUS
|
|
2596
|
-
// null,
|
|
2597
|
-
// null,
|
|
2598
|
-
// -0.24, // AMOUNT, negative for withdrawals
|
|
2599
|
-
// -0.00135, // FEES
|
|
2600
|
-
// null,
|
|
2601
|
-
// null,
|
|
2602
|
-
// "0x38110e0Fc932CB2BE...........", // DESTINATION_ADDRESS
|
|
2603
|
-
// null,
|
|
2604
|
-
// null,
|
|
2605
|
-
// null,
|
|
2606
|
-
// "0x523ec8945500.....................................", // TRANSACTION_ID
|
|
2607
|
-
// "Purchase of 100 pizzas", // WITHDRAW_TRANSACTION_NOTE, might also be: null
|
|
2608
|
-
// ]
|
|
2609
|
-
// ]
|
|
2610
|
-
//
|
|
2611
|
-
return this.parseTransactions(response, currency, since, limit);
|
|
2612
|
-
}
|
|
2613
|
-
/**
|
|
2614
|
-
* @method
|
|
2615
|
-
* @name bitfinex2#withdraw
|
|
2616
|
-
* @description make a withdrawal
|
|
2617
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-withdraw
|
|
2618
|
-
* @param {string} code unified currency code
|
|
2619
|
-
* @param {float} amount the amount to withdraw
|
|
2620
|
-
* @param {string} address the address to withdraw to
|
|
2621
|
-
* @param {string} tag
|
|
2622
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2623
|
-
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
2624
|
-
*/
|
|
2625
|
-
async withdraw(code, amount, address, tag = undefined, params = {}) {
|
|
2626
|
-
this.checkAddress(address);
|
|
2627
|
-
await this.loadMarkets();
|
|
2628
|
-
const currency = this.currency(code);
|
|
2629
|
-
// if not provided explicitly we will try to match using the currency name
|
|
2630
|
-
const network = this.safeString(params, 'network', code);
|
|
2631
|
-
params = this.omit(params, 'network');
|
|
2632
|
-
const currencyNetworks = this.safeValue(currency, 'networks', {});
|
|
2633
|
-
const currencyNetwork = this.safeValue(currencyNetworks, network);
|
|
2634
|
-
const networkId = this.safeString(currencyNetwork, 'id');
|
|
2635
|
-
if (networkId === undefined) {
|
|
2636
|
-
throw new ArgumentsRequired(this.id + " withdraw() could not find a network for '" + code + "'. You can specify it by providing the 'network' value inside params");
|
|
2637
|
-
}
|
|
2638
|
-
const wallet = this.safeString(params, 'wallet', 'exchange'); // 'exchange', 'margin', 'funding' and also old labels 'exchange', 'trading', 'deposit', respectively
|
|
2639
|
-
params = this.omit(params, 'network', 'wallet');
|
|
2640
|
-
const request = {
|
|
2641
|
-
'method': networkId,
|
|
2642
|
-
'wallet': wallet,
|
|
2643
|
-
'amount': this.numberToString(amount),
|
|
2644
|
-
'address': address,
|
|
2645
|
-
};
|
|
2646
|
-
if (tag !== undefined) {
|
|
2647
|
-
request['payment_id'] = tag;
|
|
2648
|
-
}
|
|
2649
|
-
const withdrawOptions = this.safeValue(this.options, 'withdraw', {});
|
|
2650
|
-
const includeFee = this.safeBool(withdrawOptions, 'includeFee', false);
|
|
2651
|
-
if (includeFee) {
|
|
2652
|
-
request['fee_deduct'] = 1;
|
|
2653
|
-
}
|
|
2654
|
-
const response = await this.privatePostAuthWWithdraw(this.extend(request, params));
|
|
2655
|
-
//
|
|
2656
|
-
// [
|
|
2657
|
-
// 1582271520931, // MTS Millisecond Time Stamp of the update
|
|
2658
|
-
// "acc_wd-req", // TYPE Purpose of notification "acc_wd-req" account withdrawal request
|
|
2659
|
-
// null, // MESSAGE_ID unique ID of the message
|
|
2660
|
-
// null, // not documented
|
|
2661
|
-
// [
|
|
2662
|
-
// 0, // WITHDRAWAL_ID Unique Withdrawal ID
|
|
2663
|
-
// null, // PLACEHOLDER
|
|
2664
|
-
// "bitcoin", // METHOD Method of withdrawal
|
|
2665
|
-
// null, // PAYMENT_ID Payment ID if relevant
|
|
2666
|
-
// "exchange", // WALLET Sending wallet
|
|
2667
|
-
// 1, // AMOUNT Amount of Withdrawal less fee
|
|
2668
|
-
// null, // PLACEHOLDER
|
|
2669
|
-
// null, // PLACEHOLDER
|
|
2670
|
-
// 0.0004, // WITHDRAWAL_FEE Fee on withdrawal
|
|
2671
|
-
// ],
|
|
2672
|
-
// null, // CODE null or integer Work in progress
|
|
2673
|
-
// "SUCCESS", // STATUS Status of the notification, it may vary over time SUCCESS, ERROR, FAILURE
|
|
2674
|
-
// "Invalid bitcoin address (abcdef)", // TEXT Text of the notification
|
|
2675
|
-
// ]
|
|
2676
|
-
//
|
|
2677
|
-
// in case of failure:
|
|
2678
|
-
//
|
|
2679
|
-
// [
|
|
2680
|
-
// "error",
|
|
2681
|
-
// 10001,
|
|
2682
|
-
// "Momentary balance check. Please wait few seconds and try the transfer again."
|
|
2683
|
-
// ]
|
|
2684
|
-
//
|
|
2685
|
-
const statusMessage = this.safeString(response, 0);
|
|
2686
|
-
if (statusMessage === 'error') {
|
|
2687
|
-
const feedback = this.id + ' ' + response;
|
|
2688
|
-
const message = this.safeString(response, 2, '');
|
|
2689
|
-
// same message as in v1
|
|
2690
|
-
this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
|
|
2691
|
-
this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
|
|
2692
|
-
throw new ExchangeError(feedback); // unknown message
|
|
2693
|
-
}
|
|
2694
|
-
const text = this.safeString(response, 7);
|
|
2695
|
-
if (text !== 'success') {
|
|
2696
|
-
this.throwBroadlyMatchedException(this.exceptions['broad'], text, text);
|
|
2697
|
-
}
|
|
2698
|
-
return this.parseTransaction(response, currency);
|
|
2699
|
-
}
|
|
2700
|
-
/**
|
|
2701
|
-
* @method
|
|
2702
|
-
* @name bitfinex2#fetchPositions
|
|
2703
|
-
* @description fetch all open positions
|
|
2704
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-positions
|
|
2705
|
-
* @param {string[]|undefined} symbols list of unified market symbols
|
|
2706
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2707
|
-
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
2708
|
-
*/
|
|
2709
|
-
async fetchPositions(symbols = undefined, params = {}) {
|
|
2710
|
-
await this.loadMarkets();
|
|
2711
|
-
symbols = this.marketSymbols(symbols);
|
|
2712
|
-
const response = await this.privatePostAuthRPositions(params);
|
|
2713
|
-
//
|
|
2714
|
-
// [
|
|
2715
|
-
// [
|
|
2716
|
-
// "tBTCUSD", // SYMBOL
|
|
2717
|
-
// "ACTIVE", // STATUS
|
|
2718
|
-
// 0.0195, // AMOUNT
|
|
2719
|
-
// 8565.0267019, // BASE_PRICE
|
|
2720
|
-
// 0, // MARGIN_FUNDING
|
|
2721
|
-
// 0, // MARGIN_FUNDING_TYPE
|
|
2722
|
-
// -0.33455568705000516, // PL
|
|
2723
|
-
// -0.0003117550117425625, // PL_PERC
|
|
2724
|
-
// 7045.876419249083, // PRICE_LIQ
|
|
2725
|
-
// 3.0673001895895604, // LEVERAGE
|
|
2726
|
-
// null, // _PLACEHOLDER
|
|
2727
|
-
// 142355652, // POSITION_ID
|
|
2728
|
-
// 1574002216000, // MTS_CREATE
|
|
2729
|
-
// 1574002216000, // MTS_UPDATE
|
|
2730
|
-
// null, // _PLACEHOLDER
|
|
2731
|
-
// 0, // TYPE
|
|
2732
|
-
// null, // _PLACEHOLDER
|
|
2733
|
-
// 0, // COLLATERAL
|
|
2734
|
-
// 0, // COLLATERAL_MIN
|
|
2735
|
-
// // META
|
|
2736
|
-
// {
|
|
2737
|
-
// "reason":"TRADE",
|
|
2738
|
-
// "order_id":34271018124,
|
|
2739
|
-
// "liq_stage":null,
|
|
2740
|
-
// "trade_price":"8565.0267019",
|
|
2741
|
-
// "trade_amount":"0.0195",
|
|
2742
|
-
// "order_id_oppo":34277498022
|
|
2743
|
-
// }
|
|
2744
|
-
// ]
|
|
2745
|
-
// ]
|
|
2746
|
-
//
|
|
2747
|
-
const positionsList = [];
|
|
2748
|
-
for (let i = 0; i < response.length; i++) {
|
|
2749
|
-
positionsList.push({ 'result': response[i] });
|
|
2750
|
-
}
|
|
2751
|
-
return this.parsePositions(positionsList, symbols);
|
|
2752
|
-
}
|
|
2753
|
-
parsePosition(position, market = undefined) {
|
|
2754
|
-
//
|
|
2755
|
-
// [
|
|
2756
|
-
// "tBTCUSD", // SYMBOL
|
|
2757
|
-
// "ACTIVE", // STATUS
|
|
2758
|
-
// 0.0195, // AMOUNT
|
|
2759
|
-
// 8565.0267019, // BASE_PRICE
|
|
2760
|
-
// 0, // MARGIN_FUNDING
|
|
2761
|
-
// 0, // MARGIN_FUNDING_TYPE
|
|
2762
|
-
// -0.33455568705000516, // PL
|
|
2763
|
-
// -0.0003117550117425625, // PL_PERC
|
|
2764
|
-
// 7045.876419249083, // PRICE_LIQ
|
|
2765
|
-
// 3.0673001895895604, // LEVERAGE
|
|
2766
|
-
// null, // _PLACEHOLDER
|
|
2767
|
-
// 142355652, // POSITION_ID
|
|
2768
|
-
// 1574002216000, // MTS_CREATE
|
|
2769
|
-
// 1574002216000, // MTS_UPDATE
|
|
2770
|
-
// null, // _PLACEHOLDER
|
|
2771
|
-
// 0, // TYPE
|
|
2772
|
-
// null, // _PLACEHOLDER
|
|
2773
|
-
// 0, // COLLATERAL
|
|
2774
|
-
// 0, // COLLATERAL_MIN
|
|
2775
|
-
// // META
|
|
2776
|
-
// {
|
|
2777
|
-
// "reason": "TRADE",
|
|
2778
|
-
// "order_id": 34271018124,
|
|
2779
|
-
// "liq_stage": null,
|
|
2780
|
-
// "trade_price": "8565.0267019",
|
|
2781
|
-
// "trade_amount": "0.0195",
|
|
2782
|
-
// "order_id_oppo": 34277498022
|
|
2783
|
-
// }
|
|
2784
|
-
// ]
|
|
2785
|
-
//
|
|
2786
|
-
const positionList = this.safeList(position, 'result');
|
|
2787
|
-
const marketId = this.safeString(positionList, 0);
|
|
2788
|
-
const amount = this.safeString(positionList, 2);
|
|
2789
|
-
const timestamp = this.safeInteger(positionList, 12);
|
|
2790
|
-
const meta = this.safeString(positionList, 19);
|
|
2791
|
-
const tradePrice = this.safeString(meta, 'trade_price');
|
|
2792
|
-
const tradeAmount = this.safeString(meta, 'trade_amount');
|
|
2793
|
-
return this.safePosition({
|
|
2794
|
-
'info': positionList,
|
|
2795
|
-
'id': this.safeString(positionList, 11),
|
|
2796
|
-
'symbol': this.safeSymbol(marketId, market),
|
|
2797
|
-
'notional': this.parseNumber(amount),
|
|
2798
|
-
'marginMode': 'isolated',
|
|
2799
|
-
'liquidationPrice': this.safeNumber(positionList, 8),
|
|
2800
|
-
'entryPrice': this.safeNumber(positionList, 3),
|
|
2801
|
-
'unrealizedPnl': this.safeNumber(positionList, 6),
|
|
2802
|
-
'percentage': this.safeNumber(positionList, 7),
|
|
2803
|
-
'contracts': undefined,
|
|
2804
|
-
'contractSize': undefined,
|
|
2805
|
-
'markPrice': undefined,
|
|
2806
|
-
'lastPrice': undefined,
|
|
2807
|
-
'side': Precise.stringGt(amount, '0') ? 'long' : 'short',
|
|
2808
|
-
'hedged': undefined,
|
|
2809
|
-
'timestamp': timestamp,
|
|
2810
|
-
'datetime': this.iso8601(timestamp),
|
|
2811
|
-
'lastUpdateTimestamp': this.safeInteger(positionList, 13),
|
|
2812
|
-
'maintenanceMargin': this.safeNumber(positionList, 18),
|
|
2813
|
-
'maintenanceMarginPercentage': undefined,
|
|
2814
|
-
'collateral': this.safeNumber(positionList, 17),
|
|
2815
|
-
'initialMargin': this.parseNumber(Precise.stringMul(tradeAmount, tradePrice)),
|
|
2816
|
-
'initialMarginPercentage': undefined,
|
|
2817
|
-
'leverage': this.safeNumber(positionList, 9),
|
|
2818
|
-
'marginRatio': undefined,
|
|
2819
|
-
'stopLossPrice': undefined,
|
|
2820
|
-
'takeProfitPrice': undefined,
|
|
2821
|
-
});
|
|
2822
|
-
}
|
|
2823
|
-
nonce() {
|
|
2824
|
-
return this.milliseconds();
|
|
2825
|
-
}
|
|
2826
|
-
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
2827
|
-
let request = '/' + this.implodeParams(path, params);
|
|
2828
|
-
const query = this.omit(params, this.extractParams(path));
|
|
2829
|
-
if (api === 'v1') {
|
|
2830
|
-
request = api + request;
|
|
2831
|
-
}
|
|
2832
|
-
else {
|
|
2833
|
-
request = this.version + request;
|
|
2834
|
-
}
|
|
2835
|
-
let url = this.urls['api'][api] + '/' + request;
|
|
2836
|
-
if (api === 'public') {
|
|
2837
|
-
if (Object.keys(query).length) {
|
|
2838
|
-
url += '?' + this.urlencode(query);
|
|
2839
|
-
}
|
|
2840
|
-
}
|
|
2841
|
-
if (api === 'private') {
|
|
2842
|
-
this.checkRequiredCredentials();
|
|
2843
|
-
const nonce = this.nonce().toString();
|
|
2844
|
-
body = this.json(query);
|
|
2845
|
-
const auth = '/api/' + request + nonce + body;
|
|
2846
|
-
const signature = this.hmac(this.encode(auth), this.encode(this.secret), sha384);
|
|
2847
|
-
headers = {
|
|
2848
|
-
'bfx-nonce': nonce,
|
|
2849
|
-
'bfx-apikey': this.apiKey,
|
|
2850
|
-
'bfx-signature': signature,
|
|
2851
|
-
'Content-Type': 'application/json',
|
|
2852
|
-
};
|
|
2853
|
-
}
|
|
2854
|
-
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
2855
|
-
}
|
|
2856
|
-
handleErrors(statusCode, statusText, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
2857
|
-
// ["error", 11010, "ratelimit: error"]
|
|
2858
|
-
if (response !== undefined) {
|
|
2859
|
-
if (!Array.isArray(response)) {
|
|
2860
|
-
const message = this.safeString2(response, 'message', 'error');
|
|
2861
|
-
const feedback = this.id + ' ' + body;
|
|
2862
|
-
this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
|
|
2863
|
-
this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
|
|
2864
|
-
throw new ExchangeError(this.id + ' ' + body);
|
|
2865
|
-
}
|
|
2866
|
-
}
|
|
2867
|
-
else if (response === '') {
|
|
2868
|
-
throw new ExchangeError(this.id + ' returned empty response');
|
|
2869
|
-
}
|
|
2870
|
-
if (statusCode === 429) {
|
|
2871
|
-
throw new RateLimitExceeded(this.id + ' ' + body);
|
|
2872
|
-
}
|
|
2873
|
-
if (statusCode === 500) {
|
|
2874
|
-
// See https://docs.bitfinex.com/docs/abbreviations-glossary#section-errorinfo-codes
|
|
2875
|
-
const errorCode = this.safeString(response, 1, '');
|
|
2876
|
-
const errorText = this.safeString(response, 2, '');
|
|
2877
|
-
const feedback = this.id + ' ' + errorText;
|
|
2878
|
-
this.throwBroadlyMatchedException(this.exceptions['broad'], errorText, feedback);
|
|
2879
|
-
this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
|
|
2880
|
-
this.throwExactlyMatchedException(this.exceptions['exact'], errorText, feedback);
|
|
2881
|
-
throw new ExchangeError(this.id + ' ' + errorText + ' (#' + errorCode + ')');
|
|
2882
|
-
}
|
|
2883
|
-
return response;
|
|
2884
|
-
}
|
|
2885
|
-
parseLedgerEntryType(type) {
|
|
2886
|
-
if (type === undefined) {
|
|
2887
|
-
return undefined;
|
|
2888
|
-
}
|
|
2889
|
-
else if (type.indexOf('fee') >= 0 || type.indexOf('charged') >= 0) {
|
|
2890
|
-
return 'fee';
|
|
2891
|
-
}
|
|
2892
|
-
else if (type.indexOf('rebate') >= 0) {
|
|
2893
|
-
return 'rebate';
|
|
2894
|
-
}
|
|
2895
|
-
else if (type.indexOf('deposit') >= 0 || type.indexOf('withdrawal') >= 0) {
|
|
2896
|
-
return 'transaction';
|
|
2897
|
-
}
|
|
2898
|
-
else if (type.indexOf('transfer') >= 0) {
|
|
2899
|
-
return 'transfer';
|
|
2900
|
-
}
|
|
2901
|
-
else if (type.indexOf('payment') >= 0) {
|
|
2902
|
-
return 'payout';
|
|
2903
|
-
}
|
|
2904
|
-
else if (type.indexOf('exchange') >= 0 || type.indexOf('position') >= 0) {
|
|
2905
|
-
return 'trade';
|
|
2906
|
-
}
|
|
2907
|
-
else {
|
|
2908
|
-
return type;
|
|
2909
|
-
}
|
|
2910
|
-
}
|
|
2911
|
-
parseLedgerEntry(item, currency = undefined) {
|
|
2912
|
-
//
|
|
2913
|
-
// [
|
|
2914
|
-
// [
|
|
2915
|
-
// 2531822314, // ID: Ledger identifier
|
|
2916
|
-
// "USD", // CURRENCY: The symbol of the currency (ex. "BTC")
|
|
2917
|
-
// null, // PLACEHOLDER
|
|
2918
|
-
// 1573521810000, // MTS: Timestamp in milliseconds
|
|
2919
|
-
// null, // PLACEHOLDER
|
|
2920
|
-
// 0.01644445, // AMOUNT: Amount of funds moved
|
|
2921
|
-
// 0, // BALANCE: New balance
|
|
2922
|
-
// null, // PLACEHOLDER
|
|
2923
|
-
// "Settlement @ 185.79 on wallet margin" // DESCRIPTION: Description of ledger transaction
|
|
2924
|
-
// ]
|
|
2925
|
-
// ]
|
|
2926
|
-
//
|
|
2927
|
-
const itemList = this.safeList(item, 'result', []);
|
|
2928
|
-
let type = undefined;
|
|
2929
|
-
const id = this.safeString(itemList, 0);
|
|
2930
|
-
const currencyId = this.safeString(itemList, 1);
|
|
2931
|
-
const code = this.safeCurrencyCode(currencyId, currency);
|
|
2932
|
-
currency = this.safeCurrency(currencyId, currency);
|
|
2933
|
-
const timestamp = this.safeInteger(itemList, 3);
|
|
2934
|
-
const amount = this.safeNumber(itemList, 5);
|
|
2935
|
-
const after = this.safeNumber(itemList, 6);
|
|
2936
|
-
const description = this.safeString(itemList, 8);
|
|
2937
|
-
if (description !== undefined) {
|
|
2938
|
-
const parts = description.split(' @ ');
|
|
2939
|
-
const first = this.safeStringLower(parts, 0);
|
|
2940
|
-
type = this.parseLedgerEntryType(first);
|
|
2941
|
-
}
|
|
2942
|
-
return this.safeLedgerEntry({
|
|
2943
|
-
'info': item,
|
|
2944
|
-
'id': id,
|
|
2945
|
-
'direction': undefined,
|
|
2946
|
-
'account': undefined,
|
|
2947
|
-
'referenceId': id,
|
|
2948
|
-
'referenceAccount': undefined,
|
|
2949
|
-
'type': type,
|
|
2950
|
-
'currency': code,
|
|
2951
|
-
'amount': amount,
|
|
2952
|
-
'timestamp': timestamp,
|
|
2953
|
-
'datetime': this.iso8601(timestamp),
|
|
2954
|
-
'before': undefined,
|
|
2955
|
-
'after': after,
|
|
2956
|
-
'status': undefined,
|
|
2957
|
-
'fee': undefined,
|
|
2958
|
-
}, currency);
|
|
2959
|
-
}
|
|
2960
|
-
/**
|
|
2961
|
-
* @method
|
|
2962
|
-
* @name bitfinex2#fetchLedger
|
|
2963
|
-
* @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
|
2964
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-ledgers
|
|
2965
|
-
* @param {string} [code] unified currency code, default is undefined
|
|
2966
|
-
* @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
|
|
2967
|
-
* @param {int} [limit] max number of ledger entries to return, default is undefined, max is 2500
|
|
2968
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2969
|
-
* @param {int} [params.until] timestamp in ms of the latest ledger entry
|
|
2970
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
2971
|
-
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
|
|
2972
|
-
*/
|
|
2973
|
-
async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
2974
|
-
await this.loadMarkets();
|
|
2975
|
-
let paginate = false;
|
|
2976
|
-
[paginate, params] = this.handleOptionAndParams(params, 'fetchLedger', 'paginate');
|
|
2977
|
-
if (paginate) {
|
|
2978
|
-
return await this.fetchPaginatedCallDynamic('fetchLedger', code, since, limit, params, 2500);
|
|
2979
|
-
}
|
|
2980
|
-
let currency = undefined;
|
|
2981
|
-
let request = {};
|
|
2982
|
-
if (since !== undefined) {
|
|
2983
|
-
request['start'] = since;
|
|
2984
|
-
}
|
|
2985
|
-
if (limit !== undefined) {
|
|
2986
|
-
request['limit'] = limit;
|
|
2987
|
-
}
|
|
2988
|
-
[request, params] = this.handleUntilOption('end', request, params);
|
|
2989
|
-
let response = undefined;
|
|
2990
|
-
if (code !== undefined) {
|
|
2991
|
-
currency = this.currency(code);
|
|
2992
|
-
request['currency'] = currency['uppercaseId'];
|
|
2993
|
-
response = await this.privatePostAuthRLedgersCurrencyHist(this.extend(request, params));
|
|
2994
|
-
}
|
|
2995
|
-
else {
|
|
2996
|
-
response = await this.privatePostAuthRLedgersHist(this.extend(request, params));
|
|
2997
|
-
}
|
|
2998
|
-
//
|
|
2999
|
-
// [
|
|
3000
|
-
// [
|
|
3001
|
-
// 2531822314, // ID: Ledger identifier
|
|
3002
|
-
// "USD", // CURRENCY: The symbol of the currency (ex. "BTC")
|
|
3003
|
-
// null, // PLACEHOLDER
|
|
3004
|
-
// 1573521810000, // MTS: Timestamp in milliseconds
|
|
3005
|
-
// null, // PLACEHOLDER
|
|
3006
|
-
// 0.01644445, // AMOUNT: Amount of funds moved
|
|
3007
|
-
// 0, // BALANCE: New balance
|
|
3008
|
-
// null, // PLACEHOLDER
|
|
3009
|
-
// "Settlement @ 185.79 on wallet margin" // DESCRIPTION: Description of ledger transaction
|
|
3010
|
-
// ]
|
|
3011
|
-
// ]
|
|
3012
|
-
//
|
|
3013
|
-
const ledgerObjects = [];
|
|
3014
|
-
for (let i = 0; i < response.length; i++) {
|
|
3015
|
-
const item = response[i];
|
|
3016
|
-
ledgerObjects.push({ 'result': item });
|
|
3017
|
-
}
|
|
3018
|
-
return this.parseLedger(ledgerObjects, currency, since, limit);
|
|
3019
|
-
}
|
|
3020
|
-
/**
|
|
3021
|
-
* @method
|
|
3022
|
-
* @name bitfinex2#fetchFundingRates
|
|
3023
|
-
* @description fetch the current funding rate for multiple symbols
|
|
3024
|
-
* @see https://docs.bitfinex.com/reference/rest-public-derivatives-status
|
|
3025
|
-
* @param {string[]} symbols list of unified market symbols
|
|
3026
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3027
|
-
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
|
3028
|
-
*/
|
|
3029
|
-
async fetchFundingRates(symbols = undefined, params = {}) {
|
|
3030
|
-
if (symbols === undefined) {
|
|
3031
|
-
throw new ArgumentsRequired(this.id + ' fetchFundingRates() requires a symbols argument');
|
|
3032
|
-
}
|
|
3033
|
-
await this.loadMarkets();
|
|
3034
|
-
const marketIds = this.marketIds(symbols);
|
|
3035
|
-
const request = {
|
|
3036
|
-
'keys': marketIds.join(','),
|
|
3037
|
-
};
|
|
3038
|
-
const response = await this.publicGetStatusDeriv(this.extend(request, params));
|
|
3039
|
-
//
|
|
3040
|
-
// [
|
|
3041
|
-
// [
|
|
3042
|
-
// "tBTCF0:USTF0",
|
|
3043
|
-
// 1691165059000,
|
|
3044
|
-
// null,
|
|
3045
|
-
// 29297.851276225,
|
|
3046
|
-
// 29277.5,
|
|
3047
|
-
// null,
|
|
3048
|
-
// 36950860.76010306,
|
|
3049
|
-
// null,
|
|
3050
|
-
// 1691193600000,
|
|
3051
|
-
// 0.00000527,
|
|
3052
|
-
// 82,
|
|
3053
|
-
// null,
|
|
3054
|
-
// 0.00014548,
|
|
3055
|
-
// null,
|
|
3056
|
-
// null,
|
|
3057
|
-
// 29278.8925,
|
|
3058
|
-
// null,
|
|
3059
|
-
// null,
|
|
3060
|
-
// 9636.07644994,
|
|
3061
|
-
// null,
|
|
3062
|
-
// null,
|
|
3063
|
-
// null,
|
|
3064
|
-
// 0.0005,
|
|
3065
|
-
// 0.0025
|
|
3066
|
-
// ]
|
|
3067
|
-
// ]
|
|
3068
|
-
//
|
|
3069
|
-
return this.parseFundingRates(response);
|
|
3070
|
-
}
|
|
3071
|
-
/**
|
|
3072
|
-
* @method
|
|
3073
|
-
* @name bitfinex2#fetchFundingRateHistory
|
|
3074
|
-
* @description fetches historical funding rate prices
|
|
3075
|
-
* @see https://docs.bitfinex.com/reference/rest-public-derivatives-status-history
|
|
3076
|
-
* @param {string} symbol unified market symbol
|
|
3077
|
-
* @param {int} [since] timestamp in ms of the earliest funding rate entry
|
|
3078
|
-
* @param {int} [limit] max number of funding rate entrys to return
|
|
3079
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3080
|
-
* @param {int} [params.until] timestamp in ms of the latest funding rate
|
|
3081
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
3082
|
-
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
|
3083
|
-
*/
|
|
3084
|
-
async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3085
|
-
if (symbol === undefined) {
|
|
3086
|
-
throw new ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
|
|
3087
|
-
}
|
|
3088
|
-
await this.loadMarkets();
|
|
3089
|
-
let paginate = false;
|
|
3090
|
-
[paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
|
|
3091
|
-
if (paginate) {
|
|
3092
|
-
return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 5000);
|
|
3093
|
-
}
|
|
3094
|
-
const market = this.market(symbol);
|
|
3095
|
-
let request = {
|
|
3096
|
-
'symbol': market['id'],
|
|
3097
|
-
};
|
|
3098
|
-
if (since !== undefined) {
|
|
3099
|
-
request['start'] = since;
|
|
3100
|
-
}
|
|
3101
|
-
[request, params] = this.handleUntilOption('end', request, params);
|
|
3102
|
-
const response = await this.publicGetStatusDerivSymbolHist(this.extend(request, params));
|
|
3103
|
-
//
|
|
3104
|
-
// [
|
|
3105
|
-
// [
|
|
3106
|
-
// "tBTCF0:USTF0",
|
|
3107
|
-
// 1691165059000,
|
|
3108
|
-
// null,
|
|
3109
|
-
// 29297.851276225,
|
|
3110
|
-
// 29277.5,
|
|
3111
|
-
// null,
|
|
3112
|
-
// 36950860.76010306,
|
|
3113
|
-
// null,
|
|
3114
|
-
// 1691193600000,
|
|
3115
|
-
// 0.00000527,
|
|
3116
|
-
// 82,
|
|
3117
|
-
// null,
|
|
3118
|
-
// 0.00014548,
|
|
3119
|
-
// null,
|
|
3120
|
-
// null,
|
|
3121
|
-
// 29278.8925,
|
|
3122
|
-
// null,
|
|
3123
|
-
// null,
|
|
3124
|
-
// 9636.07644994,
|
|
3125
|
-
// null,
|
|
3126
|
-
// null,
|
|
3127
|
-
// null,
|
|
3128
|
-
// 0.0005,
|
|
3129
|
-
// 0.0025
|
|
3130
|
-
// ]
|
|
3131
|
-
// ]
|
|
3132
|
-
//
|
|
3133
|
-
const rates = [];
|
|
3134
|
-
for (let i = 0; i < response.length; i++) {
|
|
3135
|
-
const fr = response[i];
|
|
3136
|
-
const rate = this.parseFundingRateHistory(fr, market);
|
|
3137
|
-
rates.push(rate);
|
|
3138
|
-
}
|
|
3139
|
-
const reversedArray = [];
|
|
3140
|
-
const rawRates = this.filterBySymbolSinceLimit(rates, symbol, since, limit);
|
|
3141
|
-
const ratesLength = rawRates.length;
|
|
3142
|
-
for (let i = 0; i < ratesLength; i++) {
|
|
3143
|
-
const index = ratesLength - i - 1;
|
|
3144
|
-
const valueAtIndex = rawRates[index];
|
|
3145
|
-
reversedArray.push(valueAtIndex);
|
|
3146
|
-
}
|
|
3147
|
-
return reversedArray;
|
|
3148
|
-
}
|
|
3149
|
-
parseFundingRate(contract, market = undefined) {
|
|
3150
|
-
//
|
|
3151
|
-
// [
|
|
3152
|
-
// "tBTCF0:USTF0",
|
|
3153
|
-
// 1691165059000,
|
|
3154
|
-
// null,
|
|
3155
|
-
// 29297.851276225,
|
|
3156
|
-
// 29277.5,
|
|
3157
|
-
// null,
|
|
3158
|
-
// 36950860.76010306,
|
|
3159
|
-
// null,
|
|
3160
|
-
// 1691193600000,
|
|
3161
|
-
// 0.00000527,
|
|
3162
|
-
// 82,
|
|
3163
|
-
// null,
|
|
3164
|
-
// 0.00014548,
|
|
3165
|
-
// null,
|
|
3166
|
-
// null,
|
|
3167
|
-
// 29278.8925,
|
|
3168
|
-
// null,
|
|
3169
|
-
// null,
|
|
3170
|
-
// 9636.07644994,
|
|
3171
|
-
// null,
|
|
3172
|
-
// null,
|
|
3173
|
-
// null,
|
|
3174
|
-
// 0.0005,
|
|
3175
|
-
// 0.0025
|
|
3176
|
-
// ]
|
|
3177
|
-
//
|
|
3178
|
-
const marketId = this.safeString(contract, 0);
|
|
3179
|
-
const timestamp = this.safeInteger(contract, 1);
|
|
3180
|
-
const nextFundingTimestamp = this.safeInteger(contract, 8);
|
|
3181
|
-
return {
|
|
3182
|
-
'info': contract,
|
|
3183
|
-
'symbol': this.safeSymbol(marketId, market),
|
|
3184
|
-
'markPrice': this.safeNumber(contract, 15),
|
|
3185
|
-
'indexPrice': this.safeNumber(contract, 3),
|
|
3186
|
-
'interestRate': undefined,
|
|
3187
|
-
'estimatedSettlePrice': undefined,
|
|
3188
|
-
'timestamp': timestamp,
|
|
3189
|
-
'datetime': this.iso8601(timestamp),
|
|
3190
|
-
'fundingRate': this.safeNumber(contract, 12),
|
|
3191
|
-
'fundingTimestamp': undefined,
|
|
3192
|
-
'fundingDatetime': undefined,
|
|
3193
|
-
'nextFundingRate': this.safeNumber(contract, 9),
|
|
3194
|
-
'nextFundingTimestamp': nextFundingTimestamp,
|
|
3195
|
-
'nextFundingDatetime': this.iso8601(nextFundingTimestamp),
|
|
3196
|
-
'previousFundingRate': undefined,
|
|
3197
|
-
'previousFundingTimestamp': undefined,
|
|
3198
|
-
'previousFundingDatetime': undefined,
|
|
3199
|
-
'interval': undefined,
|
|
3200
|
-
};
|
|
3201
|
-
}
|
|
3202
|
-
parseFundingRateHistory(contract, market = undefined) {
|
|
3203
|
-
//
|
|
3204
|
-
// [
|
|
3205
|
-
// 1691165494000,
|
|
3206
|
-
// null,
|
|
3207
|
-
// 29278.95838065,
|
|
3208
|
-
// 29260.5,
|
|
3209
|
-
// null,
|
|
3210
|
-
// 36950860.76010305,
|
|
3211
|
-
// null,
|
|
3212
|
-
// 1691193600000,
|
|
3213
|
-
// 0.00001449,
|
|
3214
|
-
// 222,
|
|
3215
|
-
// null,
|
|
3216
|
-
// 0.00014548,
|
|
3217
|
-
// null,
|
|
3218
|
-
// null,
|
|
3219
|
-
// 29260.005,
|
|
3220
|
-
// null,
|
|
3221
|
-
// null,
|
|
3222
|
-
// 9635.86484562,
|
|
3223
|
-
// null,
|
|
3224
|
-
// null,
|
|
3225
|
-
// null,
|
|
3226
|
-
// 0.0005,
|
|
3227
|
-
// 0.0025
|
|
3228
|
-
// ]
|
|
3229
|
-
//
|
|
3230
|
-
const timestamp = this.safeInteger(contract, 0);
|
|
3231
|
-
const nextFundingTimestamp = this.safeInteger(contract, 7);
|
|
3232
|
-
return {
|
|
3233
|
-
'info': contract,
|
|
3234
|
-
'symbol': this.safeSymbol(undefined, market),
|
|
3235
|
-
'markPrice': this.safeNumber(contract, 14),
|
|
3236
|
-
'indexPrice': this.safeNumber(contract, 2),
|
|
3237
|
-
'interestRate': undefined,
|
|
3238
|
-
'estimatedSettlePrice': undefined,
|
|
3239
|
-
'timestamp': timestamp,
|
|
3240
|
-
'datetime': this.iso8601(timestamp),
|
|
3241
|
-
'fundingRate': this.safeNumber(contract, 11),
|
|
3242
|
-
'fundingTimestamp': undefined,
|
|
3243
|
-
'fundingDatetime': undefined,
|
|
3244
|
-
'nextFundingRate': this.safeNumber(contract, 8),
|
|
3245
|
-
'nextFundingTimestamp': nextFundingTimestamp,
|
|
3246
|
-
'nextFundingDatetime': this.iso8601(nextFundingTimestamp),
|
|
3247
|
-
'previousFundingRate': undefined,
|
|
3248
|
-
'previousFundingTimestamp': undefined,
|
|
3249
|
-
'previousFundingDatetime': undefined,
|
|
3250
|
-
};
|
|
3251
|
-
}
|
|
3252
|
-
/**
|
|
3253
|
-
* @method
|
|
3254
|
-
* @name bitfinex2#fetchOpenInterest
|
|
3255
|
-
* @description retrieves the open interest of a contract trading pair
|
|
3256
|
-
* @see https://docs.bitfinex.com/reference/rest-public-derivatives-status
|
|
3257
|
-
* @param {string} symbol unified CCXT market symbol
|
|
3258
|
-
* @param {object} [params] exchange specific parameters
|
|
3259
|
-
* @returns {object} an [open interest structure]{@link https://docs.ccxt.com/#/?id=open-interest-structure}
|
|
3260
|
-
*/
|
|
3261
|
-
async fetchOpenInterest(symbol, params = {}) {
|
|
3262
|
-
await this.loadMarkets();
|
|
3263
|
-
const market = this.market(symbol);
|
|
3264
|
-
const request = {
|
|
3265
|
-
'keys': market['id'],
|
|
3266
|
-
};
|
|
3267
|
-
const response = await this.publicGetStatusDeriv(this.extend(request, params));
|
|
3268
|
-
//
|
|
3269
|
-
// [
|
|
3270
|
-
// [
|
|
3271
|
-
// "tXRPF0:USTF0", // market id
|
|
3272
|
-
// 1706256986000, // millisecond timestamp
|
|
3273
|
-
// null,
|
|
3274
|
-
// 0.512705, // derivative mid price
|
|
3275
|
-
// 0.512395, // underlying spot mid price
|
|
3276
|
-
// null,
|
|
3277
|
-
// 37671483.04, // insurance fund balance
|
|
3278
|
-
// null,
|
|
3279
|
-
// 1706284800000, // timestamp of next funding
|
|
3280
|
-
// 0.00002353, // accrued funding for next period
|
|
3281
|
-
// 317, // next funding step
|
|
3282
|
-
// null,
|
|
3283
|
-
// 0, // current funding
|
|
3284
|
-
// null,
|
|
3285
|
-
// null,
|
|
3286
|
-
// 0.5123016, // mark price
|
|
3287
|
-
// null,
|
|
3288
|
-
// null,
|
|
3289
|
-
// 2233562.03115, // open interest in contracts
|
|
3290
|
-
// null,
|
|
3291
|
-
// null,
|
|
3292
|
-
// null,
|
|
3293
|
-
// 0.0005, // average spread without funding payment
|
|
3294
|
-
// 0.0025 // funding payment cap
|
|
3295
|
-
// ]
|
|
3296
|
-
// ]
|
|
3297
|
-
//
|
|
3298
|
-
const oi = this.safeList(response, 0);
|
|
3299
|
-
return this.parseOpenInterest(oi, market);
|
|
3300
|
-
}
|
|
3301
|
-
/**
|
|
3302
|
-
* @method
|
|
3303
|
-
* @name bitfinex2#fetchOpenInterestHistory
|
|
3304
|
-
* @description retrieves the open interest history of a currency
|
|
3305
|
-
* @see https://docs.bitfinex.com/reference/rest-public-derivatives-status-history
|
|
3306
|
-
* @param {string} symbol unified CCXT market symbol
|
|
3307
|
-
* @param {string} timeframe the time period of each row of data, not used by bitfinex2
|
|
3308
|
-
* @param {int} [since] the time in ms of the earliest record to retrieve as a unix timestamp
|
|
3309
|
-
* @param {int} [limit] the number of records in the response
|
|
3310
|
-
* @param {object} [params] exchange specific parameters
|
|
3311
|
-
* @param {int} [params.until] the time in ms of the latest record to retrieve as a unix timestamp
|
|
3312
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
3313
|
-
* @returns An array of [open interest structures]{@link https://docs.ccxt.com/#/?id=open-interest-structure}
|
|
3314
|
-
*/
|
|
3315
|
-
async fetchOpenInterestHistory(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
3316
|
-
await this.loadMarkets();
|
|
3317
|
-
let paginate = false;
|
|
3318
|
-
[paginate, params] = this.handleOptionAndParams(params, 'fetchOpenInterestHistory', 'paginate');
|
|
3319
|
-
if (paginate) {
|
|
3320
|
-
return await this.fetchPaginatedCallDeterministic('fetchOpenInterestHistory', symbol, since, limit, '8h', params, 5000);
|
|
3321
|
-
}
|
|
3322
|
-
const market = this.market(symbol);
|
|
3323
|
-
let request = {
|
|
3324
|
-
'symbol': market['id'],
|
|
3325
|
-
};
|
|
3326
|
-
if (since !== undefined) {
|
|
3327
|
-
request['start'] = since;
|
|
3328
|
-
}
|
|
3329
|
-
if (limit !== undefined) {
|
|
3330
|
-
request['limit'] = limit;
|
|
3331
|
-
}
|
|
3332
|
-
[request, params] = this.handleUntilOption('end', request, params);
|
|
3333
|
-
const response = await this.publicGetStatusDerivSymbolHist(this.extend(request, params));
|
|
3334
|
-
//
|
|
3335
|
-
// [
|
|
3336
|
-
// [
|
|
3337
|
-
// 1706295191000, // timestamp
|
|
3338
|
-
// null,
|
|
3339
|
-
// 42152.425382, // derivative mid price
|
|
3340
|
-
// 42133, // spot mid price
|
|
3341
|
-
// null,
|
|
3342
|
-
// 37671589.7853521, // insurance fund balance
|
|
3343
|
-
// null,
|
|
3344
|
-
// 1706313600000, // timestamp of next funding
|
|
3345
|
-
// 0.00018734, // accrued funding for next period
|
|
3346
|
-
// 3343, // next funding step
|
|
3347
|
-
// null,
|
|
3348
|
-
// 0.00007587, // current funding
|
|
3349
|
-
// null,
|
|
3350
|
-
// null,
|
|
3351
|
-
// 42134.1, // mark price
|
|
3352
|
-
// null,
|
|
3353
|
-
// null,
|
|
3354
|
-
// 5775.20348804, // open interest number of contracts
|
|
3355
|
-
// null,
|
|
3356
|
-
// null,
|
|
3357
|
-
// null,
|
|
3358
|
-
// 0.0005, // average spread without funding payment
|
|
3359
|
-
// 0.0025 // funding payment cap
|
|
3360
|
-
// ],
|
|
3361
|
-
// ]
|
|
3362
|
-
//
|
|
3363
|
-
return this.parseOpenInterests(response, market, since, limit);
|
|
3364
|
-
}
|
|
3365
|
-
parseOpenInterest(interest, market = undefined) {
|
|
3366
|
-
//
|
|
3367
|
-
// fetchOpenInterest:
|
|
3368
|
-
//
|
|
3369
|
-
// [
|
|
3370
|
-
// "tXRPF0:USTF0", // market id
|
|
3371
|
-
// 1706256986000, // millisecond timestamp
|
|
3372
|
-
// null,
|
|
3373
|
-
// 0.512705, // derivative mid price
|
|
3374
|
-
// 0.512395, // underlying spot mid price
|
|
3375
|
-
// null,
|
|
3376
|
-
// 37671483.04, // insurance fund balance
|
|
3377
|
-
// null,
|
|
3378
|
-
// 1706284800000, // timestamp of next funding
|
|
3379
|
-
// 0.00002353, // accrued funding for next period
|
|
3380
|
-
// 317, // next funding step
|
|
3381
|
-
// null,
|
|
3382
|
-
// 0, // current funding
|
|
3383
|
-
// null,
|
|
3384
|
-
// null,
|
|
3385
|
-
// 0.5123016, // mark price
|
|
3386
|
-
// null,
|
|
3387
|
-
// null,
|
|
3388
|
-
// 2233562.03115, // open interest in contracts
|
|
3389
|
-
// null,
|
|
3390
|
-
// null,
|
|
3391
|
-
// null,
|
|
3392
|
-
// 0.0005, // average spread without funding payment
|
|
3393
|
-
// 0.0025 // funding payment cap
|
|
3394
|
-
// ]
|
|
3395
|
-
//
|
|
3396
|
-
// fetchOpenInterestHistory:
|
|
3397
|
-
//
|
|
3398
|
-
// [
|
|
3399
|
-
// 1706295191000, // timestamp
|
|
3400
|
-
// null,
|
|
3401
|
-
// 42152.425382, // derivative mid price
|
|
3402
|
-
// 42133, // spot mid price
|
|
3403
|
-
// null,
|
|
3404
|
-
// 37671589.7853521, // insurance fund balance
|
|
3405
|
-
// null,
|
|
3406
|
-
// 1706313600000, // timestamp of next funding
|
|
3407
|
-
// 0.00018734, // accrued funding for next period
|
|
3408
|
-
// 3343, // next funding step
|
|
3409
|
-
// null,
|
|
3410
|
-
// 0.00007587, // current funding
|
|
3411
|
-
// null,
|
|
3412
|
-
// null,
|
|
3413
|
-
// 42134.1, // mark price
|
|
3414
|
-
// null,
|
|
3415
|
-
// null,
|
|
3416
|
-
// 5775.20348804, // open interest number of contracts
|
|
3417
|
-
// null,
|
|
3418
|
-
// null,
|
|
3419
|
-
// null,
|
|
3420
|
-
// 0.0005, // average spread without funding payment
|
|
3421
|
-
// 0.0025 // funding payment cap
|
|
3422
|
-
// ]
|
|
3423
|
-
//
|
|
3424
|
-
const interestLength = interest.length;
|
|
3425
|
-
const openInterestIndex = (interestLength === 23) ? 17 : 18;
|
|
3426
|
-
const timestamp = this.safeInteger(interest, 1);
|
|
3427
|
-
const marketId = this.safeString(interest, 0);
|
|
3428
|
-
return this.safeOpenInterest({
|
|
3429
|
-
'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
|
|
3430
|
-
'openInterestAmount': this.safeNumber(interest, openInterestIndex),
|
|
3431
|
-
'openInterestValue': undefined,
|
|
3432
|
-
'timestamp': timestamp,
|
|
3433
|
-
'datetime': this.iso8601(timestamp),
|
|
3434
|
-
'info': interest,
|
|
3435
|
-
}, market);
|
|
3436
|
-
}
|
|
3437
|
-
/**
|
|
3438
|
-
* @method
|
|
3439
|
-
* @name bitfinex2#fetchLiquidations
|
|
3440
|
-
* @description retrieves the public liquidations of a trading pair
|
|
3441
|
-
* @see https://docs.bitfinex.com/reference/rest-public-liquidations
|
|
3442
|
-
* @param {string} symbol unified CCXT market symbol
|
|
3443
|
-
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
3444
|
-
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
3445
|
-
* @param {object} [params] exchange specific parameters
|
|
3446
|
-
* @param {int} [params.until] timestamp in ms of the latest liquidation
|
|
3447
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
3448
|
-
* @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
|
|
3449
|
-
*/
|
|
3450
|
-
async fetchLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
|
|
3451
|
-
await this.loadMarkets();
|
|
3452
|
-
let paginate = false;
|
|
3453
|
-
[paginate, params] = this.handleOptionAndParams(params, 'fetchLiquidations', 'paginate');
|
|
3454
|
-
if (paginate) {
|
|
3455
|
-
return await this.fetchPaginatedCallDeterministic('fetchLiquidations', symbol, since, limit, '8h', params, 500);
|
|
3456
|
-
}
|
|
3457
|
-
const market = this.market(symbol);
|
|
3458
|
-
let request = {};
|
|
3459
|
-
if (since !== undefined) {
|
|
3460
|
-
request['start'] = since;
|
|
3461
|
-
}
|
|
3462
|
-
if (limit !== undefined) {
|
|
3463
|
-
request['limit'] = limit;
|
|
3464
|
-
}
|
|
3465
|
-
[request, params] = this.handleUntilOption('end', request, params);
|
|
3466
|
-
const response = await this.publicGetLiquidationsHist(this.extend(request, params));
|
|
3467
|
-
//
|
|
3468
|
-
// [
|
|
3469
|
-
// [
|
|
3470
|
-
// [
|
|
3471
|
-
// "pos",
|
|
3472
|
-
// 171085137,
|
|
3473
|
-
// 1706395919788,
|
|
3474
|
-
// null,
|
|
3475
|
-
// "tAVAXF0:USTF0",
|
|
3476
|
-
// -8,
|
|
3477
|
-
// 32.868,
|
|
3478
|
-
// null,
|
|
3479
|
-
// 1,
|
|
3480
|
-
// 1,
|
|
3481
|
-
// null,
|
|
3482
|
-
// 33.255
|
|
3483
|
-
// ]
|
|
3484
|
-
// ],
|
|
3485
|
-
// ]
|
|
3486
|
-
//
|
|
3487
|
-
return this.parseLiquidations(response, market, since, limit);
|
|
3488
|
-
}
|
|
3489
|
-
parseLiquidation(liquidation, market = undefined) {
|
|
3490
|
-
//
|
|
3491
|
-
// [
|
|
3492
|
-
// [
|
|
3493
|
-
// "pos",
|
|
3494
|
-
// 171085137, // position id
|
|
3495
|
-
// 1706395919788, // timestamp
|
|
3496
|
-
// null,
|
|
3497
|
-
// "tAVAXF0:USTF0", // market id
|
|
3498
|
-
// -8, // amount in contracts
|
|
3499
|
-
// 32.868, // base price
|
|
3500
|
-
// null,
|
|
3501
|
-
// 1,
|
|
3502
|
-
// 1,
|
|
3503
|
-
// null,
|
|
3504
|
-
// 33.255 // acquired price
|
|
3505
|
-
// ]
|
|
3506
|
-
// ]
|
|
3507
|
-
//
|
|
3508
|
-
const entry = liquidation[0];
|
|
3509
|
-
const timestamp = this.safeInteger(entry, 2);
|
|
3510
|
-
const marketId = this.safeString(entry, 4);
|
|
3511
|
-
const contracts = Precise.stringAbs(this.safeString(entry, 5));
|
|
3512
|
-
const contractSize = this.safeString(market, 'contractSize');
|
|
3513
|
-
const baseValue = Precise.stringMul(contracts, contractSize);
|
|
3514
|
-
const price = this.safeString(entry, 11);
|
|
3515
|
-
return this.safeLiquidation({
|
|
3516
|
-
'info': entry,
|
|
3517
|
-
'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
|
|
3518
|
-
'contracts': this.parseNumber(contracts),
|
|
3519
|
-
'contractSize': this.parseNumber(contractSize),
|
|
3520
|
-
'price': this.parseNumber(price),
|
|
3521
|
-
'baseValue': this.parseNumber(baseValue),
|
|
3522
|
-
'quoteValue': this.parseNumber(Precise.stringMul(baseValue, price)),
|
|
3523
|
-
'timestamp': timestamp,
|
|
3524
|
-
'datetime': this.iso8601(timestamp),
|
|
3525
|
-
});
|
|
3526
|
-
}
|
|
3527
|
-
/**
|
|
3528
|
-
* @method
|
|
3529
|
-
* @name bitfinex2#setMargin
|
|
3530
|
-
* @description either adds or reduces margin in a swap position in order to set the margin to a specific value
|
|
3531
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-deriv-pos-collateral-set
|
|
3532
|
-
* @param {string} symbol unified market symbol of the market to set margin in
|
|
3533
|
-
* @param {float} amount the amount to set the margin to
|
|
3534
|
-
* @param {object} [params] parameters specific to the exchange API endpoint
|
|
3535
|
-
* @returns {object} A [margin structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#add-margin-structure}
|
|
3536
|
-
*/
|
|
3537
|
-
async setMargin(symbol, amount, params = {}) {
|
|
3538
|
-
await this.loadMarkets();
|
|
3539
|
-
const market = this.market(symbol);
|
|
3540
|
-
if (!market['swap']) {
|
|
3541
|
-
throw new NotSupported(this.id + ' setMargin() only support swap markets');
|
|
3542
|
-
}
|
|
3543
|
-
const request = {
|
|
3544
|
-
'symbol': market['id'],
|
|
3545
|
-
'collateral': this.parseToNumeric(amount),
|
|
3546
|
-
};
|
|
3547
|
-
const response = await this.privatePostAuthWDerivCollateralSet(this.extend(request, params));
|
|
3548
|
-
//
|
|
3549
|
-
// [
|
|
3550
|
-
// [
|
|
3551
|
-
// 1
|
|
3552
|
-
// ]
|
|
3553
|
-
// ]
|
|
3554
|
-
//
|
|
3555
|
-
const data = this.safeValue(response, 0);
|
|
3556
|
-
return this.parseMarginModification(data, market);
|
|
3557
|
-
}
|
|
3558
|
-
parseMarginModification(data, market = undefined) {
|
|
3559
|
-
//
|
|
3560
|
-
// setMargin
|
|
3561
|
-
//
|
|
3562
|
-
// [
|
|
3563
|
-
// [
|
|
3564
|
-
// 1
|
|
3565
|
-
// ]
|
|
3566
|
-
// ]
|
|
3567
|
-
//
|
|
3568
|
-
const marginStatusRaw = data[0];
|
|
3569
|
-
const marginStatus = (marginStatusRaw === 1) ? 'ok' : 'failed';
|
|
3570
|
-
return {
|
|
3571
|
-
'info': data,
|
|
3572
|
-
'symbol': market['symbol'],
|
|
3573
|
-
'type': undefined,
|
|
3574
|
-
'marginMode': 'isolated',
|
|
3575
|
-
'amount': undefined,
|
|
3576
|
-
'total': undefined,
|
|
3577
|
-
'code': undefined,
|
|
3578
|
-
'status': marginStatus,
|
|
3579
|
-
'timestamp': undefined,
|
|
3580
|
-
'datetime': undefined,
|
|
3581
|
-
};
|
|
3582
|
-
}
|
|
3583
|
-
/**
|
|
3584
|
-
* @method
|
|
3585
|
-
* @name bitfinex2#fetchOrder
|
|
3586
|
-
* @description fetches information on an order made by the user
|
|
3587
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-retrieve-orders
|
|
3588
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-retrieve-orders-by-symbol
|
|
3589
|
-
* @param {string} id the order id
|
|
3590
|
-
* @param {string} [symbol] unified symbol of the market the order was made in
|
|
3591
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3592
|
-
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3593
|
-
*/
|
|
3594
|
-
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
3595
|
-
await this.loadMarkets();
|
|
3596
|
-
const request = {
|
|
3597
|
-
'id': [this.parseToNumeric(id)],
|
|
3598
|
-
};
|
|
3599
|
-
let market = undefined;
|
|
3600
|
-
let response = undefined;
|
|
3601
|
-
if (symbol === undefined) {
|
|
3602
|
-
response = await this.privatePostAuthROrders(this.extend(request, params));
|
|
3603
|
-
}
|
|
3604
|
-
else {
|
|
3605
|
-
market = this.market(symbol);
|
|
3606
|
-
request['symbol'] = market['id'];
|
|
3607
|
-
response = await this.privatePostAuthROrdersSymbol(this.extend(request, params));
|
|
3608
|
-
}
|
|
3609
|
-
//
|
|
3610
|
-
// [
|
|
3611
|
-
// [
|
|
3612
|
-
// 139658969116,
|
|
3613
|
-
// null,
|
|
3614
|
-
// 1706843908637,
|
|
3615
|
-
// "tBTCUST",
|
|
3616
|
-
// 1706843908637,
|
|
3617
|
-
// 1706843908638,
|
|
3618
|
-
// 0.0001,
|
|
3619
|
-
// 0.0001,
|
|
3620
|
-
// "EXCHANGE LIMIT",
|
|
3621
|
-
// null,
|
|
3622
|
-
// null,
|
|
3623
|
-
// null,
|
|
3624
|
-
// 0,
|
|
3625
|
-
// "ACTIVE",
|
|
3626
|
-
// null,
|
|
3627
|
-
// null,
|
|
3628
|
-
// 35000,
|
|
3629
|
-
// 0,
|
|
3630
|
-
// 0,
|
|
3631
|
-
// 0,
|
|
3632
|
-
// null,
|
|
3633
|
-
// null,
|
|
3634
|
-
// null,
|
|
3635
|
-
// 0,
|
|
3636
|
-
// 0,
|
|
3637
|
-
// null,
|
|
3638
|
-
// null,
|
|
3639
|
-
// null,
|
|
3640
|
-
// "API>BFX",
|
|
3641
|
-
// null,
|
|
3642
|
-
// null,
|
|
3643
|
-
// {}
|
|
3644
|
-
// ]
|
|
3645
|
-
// ]
|
|
3646
|
-
//
|
|
3647
|
-
const order = this.safeList(response, 0);
|
|
3648
|
-
const newOrder = { 'result': order };
|
|
3649
|
-
return this.parseOrder(newOrder, market);
|
|
3650
|
-
}
|
|
3651
|
-
/**
|
|
3652
|
-
* @method
|
|
3653
|
-
* @name bitfinex2#editOrder
|
|
3654
|
-
* @description edit a trade order
|
|
3655
|
-
* @see https://docs.bitfinex.com/reference/rest-auth-update-order
|
|
3656
|
-
* @param {string} id edit order id
|
|
3657
|
-
* @param {string} symbol unified symbol of the market to edit an order in
|
|
3658
|
-
* @param {string} type 'market' or 'limit'
|
|
3659
|
-
* @param {string} side 'buy' or 'sell'
|
|
3660
|
-
* @param {float} amount how much you want to trade in units of the base currency
|
|
3661
|
-
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
3662
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3663
|
-
* @param {float} [params.stopPrice] the price that triggers a trigger order
|
|
3664
|
-
* @param {boolean} [params.postOnly] set to true if you want to make a post only order
|
|
3665
|
-
* @param {boolean} [params.reduceOnly] indicates that the order is to reduce the size of a position
|
|
3666
|
-
* @param {int} [params.flags] additional order parameters: 4096 (Post Only), 1024 (Reduce Only), 16384 (OCO), 64 (Hidden), 512 (Close), 524288 (No Var Rates)
|
|
3667
|
-
* @param {int} [params.leverage] leverage for a derivative order, supported by derivative symbol orders only, the value should be between 1 and 100 inclusive
|
|
3668
|
-
* @param {int} [params.clientOrderId] a unique client order id for the order
|
|
3669
|
-
* @param {float} [params.trailingAmount] *swap only* the quote amount to trail away from the current market price
|
|
3670
|
-
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3671
|
-
*/
|
|
3672
|
-
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
3673
|
-
await this.loadMarkets();
|
|
3674
|
-
const market = this.market(symbol);
|
|
3675
|
-
const request = {
|
|
3676
|
-
'id': this.parseToNumeric(id),
|
|
3677
|
-
};
|
|
3678
|
-
if (amount !== undefined) {
|
|
3679
|
-
let amountString = this.amountToPrecision(symbol, amount);
|
|
3680
|
-
amountString = (side === 'buy') ? amountString : Precise.stringNeg(amountString);
|
|
3681
|
-
request['amount'] = amountString;
|
|
3682
|
-
}
|
|
3683
|
-
const stopPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
|
|
3684
|
-
const trailingAmount = this.safeString(params, 'trailingAmount');
|
|
3685
|
-
const timeInForce = this.safeString(params, 'timeInForce');
|
|
3686
|
-
const postOnlyParam = this.safeBool(params, 'postOnly', false);
|
|
3687
|
-
const reduceOnly = this.safeBool(params, 'reduceOnly', false);
|
|
3688
|
-
const clientOrderId = this.safeInteger2(params, 'cid', 'clientOrderId');
|
|
3689
|
-
if (trailingAmount !== undefined) {
|
|
3690
|
-
request['price_trailing'] = trailingAmount;
|
|
3691
|
-
}
|
|
3692
|
-
else if (stopPrice !== undefined) {
|
|
3693
|
-
// request['price'] is taken as stopPrice for stop orders
|
|
3694
|
-
request['price'] = this.priceToPrecision(symbol, stopPrice);
|
|
3695
|
-
if (type === 'limit') {
|
|
3696
|
-
request['price_aux_limit'] = this.priceToPrecision(symbol, price);
|
|
3697
|
-
}
|
|
3698
|
-
}
|
|
3699
|
-
const postOnly = (postOnlyParam || (timeInForce === 'PO'));
|
|
3700
|
-
if ((type !== 'market') && (stopPrice === undefined)) {
|
|
3701
|
-
request['price'] = this.priceToPrecision(symbol, price);
|
|
3702
|
-
}
|
|
3703
|
-
// flag values may be summed to combine flags
|
|
3704
|
-
let flags = 0;
|
|
3705
|
-
if (postOnly) {
|
|
3706
|
-
flags = this.sum(flags, 4096);
|
|
3707
|
-
}
|
|
3708
|
-
if (reduceOnly) {
|
|
3709
|
-
flags = this.sum(flags, 1024);
|
|
3710
|
-
}
|
|
3711
|
-
if (flags !== 0) {
|
|
3712
|
-
request['flags'] = flags;
|
|
3713
|
-
}
|
|
3714
|
-
if (clientOrderId !== undefined) {
|
|
3715
|
-
request['cid'] = clientOrderId;
|
|
3716
|
-
}
|
|
3717
|
-
const leverage = this.safeInteger2(params, 'leverage', 'lev');
|
|
3718
|
-
if (leverage !== undefined) {
|
|
3719
|
-
request['lev'] = leverage;
|
|
3720
|
-
}
|
|
3721
|
-
params = this.omit(params, ['triggerPrice', 'stopPrice', 'timeInForce', 'postOnly', 'reduceOnly', 'trailingAmount', 'clientOrderId', 'leverage']);
|
|
3722
|
-
const response = await this.privatePostAuthWOrderUpdate(this.extend(request, params));
|
|
3723
|
-
//
|
|
3724
|
-
// [
|
|
3725
|
-
// 1706845376402,
|
|
3726
|
-
// "ou-req",
|
|
3727
|
-
// null,
|
|
3728
|
-
// null,
|
|
3729
|
-
// [
|
|
3730
|
-
// 139658969116,
|
|
3731
|
-
// null,
|
|
3732
|
-
// 1706843908637,
|
|
3733
|
-
// "tBTCUST",
|
|
3734
|
-
// 1706843908637,
|
|
3735
|
-
// 1706843908638,
|
|
3736
|
-
// 0.0002,
|
|
3737
|
-
// 0.0002,
|
|
3738
|
-
// "EXCHANGE LIMIT",
|
|
3739
|
-
// null,
|
|
3740
|
-
// null,
|
|
3741
|
-
// null,
|
|
3742
|
-
// 0,
|
|
3743
|
-
// "ACTIVE",
|
|
3744
|
-
// null,
|
|
3745
|
-
// null,
|
|
3746
|
-
// 35000,
|
|
3747
|
-
// 0,
|
|
3748
|
-
// 0,
|
|
3749
|
-
// 0,
|
|
3750
|
-
// null,
|
|
3751
|
-
// null,
|
|
3752
|
-
// null,
|
|
3753
|
-
// 0,
|
|
3754
|
-
// 0,
|
|
3755
|
-
// null,
|
|
3756
|
-
// null,
|
|
3757
|
-
// null,
|
|
3758
|
-
// "API>BFX",
|
|
3759
|
-
// null,
|
|
3760
|
-
// null,
|
|
3761
|
-
// {}
|
|
3762
|
-
// ],
|
|
3763
|
-
// null,
|
|
3764
|
-
// "SUCCESS",
|
|
3765
|
-
// "Submitting update to exchange limit buy order for 0.0002 BTC."
|
|
3766
|
-
// ]
|
|
3767
|
-
//
|
|
3768
|
-
const status = this.safeString(response, 6);
|
|
3769
|
-
if (status !== 'SUCCESS') {
|
|
3770
|
-
const errorCode = response[5];
|
|
3771
|
-
const errorText = response[7];
|
|
3772
|
-
throw new ExchangeError(this.id + ' ' + response[6] + ': ' + errorText + ' (#' + errorCode + ')');
|
|
3773
|
-
}
|
|
3774
|
-
const order = this.safeList(response, 4, []);
|
|
3775
|
-
const newOrder = { 'result': order };
|
|
3776
|
-
return this.parseOrder(newOrder, market);
|
|
3777
|
-
}
|
|
3778
|
-
}
|