ccxt 4.2.17 → 4.2.19
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 +9 -9
- package/dist/ccxt.browser.js +48992 -47725
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +12 -1
- package/dist/cjs/src/alpaca.js +18 -18
- package/dist/cjs/src/ascendex.js +13 -6
- package/dist/cjs/src/base/Exchange.js +266 -27
- package/dist/cjs/src/bigone.js +434 -168
- package/dist/cjs/src/binance.js +163 -34
- package/dist/cjs/src/binanceus.js +8 -0
- package/dist/cjs/src/bingx.js +183 -41
- package/dist/cjs/src/bitfinex.js +2 -3
- package/dist/cjs/src/bitget.js +59 -16
- package/dist/cjs/src/bitmart.js +5 -5
- package/dist/cjs/src/bitmex.js +4 -6
- package/dist/cjs/src/bitpanda.js +5 -1991
- package/dist/cjs/src/bitstamp.js +8 -0
- package/dist/cjs/src/bybit.js +27 -47
- package/dist/cjs/src/coinbase.js +176 -26
- package/dist/cjs/src/coincheck.js +1 -0
- package/dist/cjs/src/coinex.js +3 -0
- package/dist/cjs/src/coinlist.js +13 -6
- package/dist/cjs/src/coinone.js +2 -2
- package/dist/cjs/src/coinsph.js +4 -5
- package/dist/cjs/src/delta.js +7 -1
- package/dist/cjs/src/deribit.js +17 -4
- package/dist/cjs/src/gate.js +151 -169
- package/dist/cjs/src/gemini.js +1 -1
- package/dist/cjs/src/hitbtc.js +2 -3
- package/dist/cjs/src/htx.js +157 -7
- package/dist/cjs/src/huobijp.js +2 -3
- package/dist/cjs/src/independentreserve.js +7 -5
- package/dist/cjs/src/kraken.js +86 -54
- package/dist/cjs/src/kucoin.js +5 -0
- package/dist/cjs/src/kucoinfutures.js +131 -77
- package/dist/cjs/src/lbank.js +60 -33
- package/dist/cjs/src/luno.js +84 -2
- package/dist/cjs/src/mexc.js +3 -3
- package/dist/cjs/src/oceanex.js +1 -1
- package/dist/cjs/src/okx.js +23 -11
- package/dist/cjs/{js/src/bitpanda.js → src/onetrading.js} +39 -39
- package/dist/cjs/src/phemex.js +37 -27
- package/dist/cjs/src/poloniexfutures.js +1 -0
- package/dist/cjs/src/pro/binance.js +66 -25
- package/dist/cjs/src/pro/bitget.js +1 -1
- package/dist/cjs/src/pro/bitpanda.js +5 -1330
- package/dist/cjs/src/pro/coinbase.js +4 -1
- package/dist/cjs/src/pro/coincheck.js +208 -0
- package/dist/cjs/src/pro/hitbtc.js +5 -4
- package/dist/cjs/src/pro/htx.js +6 -1
- package/dist/cjs/src/pro/kraken.js +1 -1
- package/dist/cjs/src/pro/krakenfutures.js +7 -1
- package/dist/cjs/src/pro/kucoin.js +46 -36
- package/dist/cjs/src/pro/kucoinfutures.js +45 -37
- package/dist/cjs/src/pro/lbank.js +881 -0
- package/dist/cjs/src/pro/okx.js +52 -2
- package/dist/cjs/{js/src/pro/bitpanda.js → src/pro/onetrading.js} +4 -7
- package/dist/cjs/src/pro/poloniex.js +2 -2
- package/dist/cjs/src/pro/poloniexfutures.js +43 -35
- package/dist/cjs/src/pro/woo.js +126 -0
- package/dist/cjs/src/probit.js +4 -2
- package/dist/cjs/src/upbit.js +12 -12
- package/dist/cjs/src/wavesexchange.js +1 -1
- package/dist/cjs/src/whitebit.js +1 -0
- package/dist/cjs/src/woo.js +56 -0
- package/js/ccxt.d.ts +14 -2
- package/js/ccxt.js +10 -2
- package/js/src/abstract/bitpanda.d.ts +4 -4
- package/js/src/abstract/bitstamp.d.ts +8 -0
- package/js/src/abstract/gate.d.ts +1 -0
- package/js/src/abstract/gateio.d.ts +1 -0
- package/js/src/abstract/htx.d.ts +3 -0
- package/js/src/abstract/huobi.d.ts +3 -0
- package/js/src/abstract/luno.d.ts +1 -0
- package/js/src/abstract/onetrading.d.ts +38 -0
- package/js/src/ascendex.js +2 -0
- package/js/src/base/Exchange.d.ts +2 -3
- package/js/src/base/Exchange.js +5 -2
- package/js/src/binance.js +7 -1
- package/js/src/bingx.d.ts +1 -0
- package/js/src/bingx.js +26 -0
- package/js/src/bitget.js +22 -3
- package/js/src/bitpanda.d.ts +2 -72
- package/js/src/bitpanda.js +5 -1991
- package/js/src/bitstamp.js +8 -0
- package/js/src/bybit.js +21 -47
- package/js/src/coincheck.js +1 -0
- package/js/src/deribit.js +16 -4
- package/js/src/gate.d.ts +1 -0
- package/js/src/gate.js +50 -110
- package/js/src/htx.js +3 -0
- package/js/src/kraken.d.ts +1 -0
- package/js/src/kraken.js +40 -39
- package/js/src/lbank.js +1 -0
- package/js/src/luno.d.ts +3 -1
- package/js/src/luno.js +84 -2
- package/js/src/mexc.js +1 -2
- package/js/src/onetrading.d.ts +74 -0
- package/js/src/onetrading.js +2003 -0
- package/js/src/poloniexfutures.js +1 -0
- package/js/src/pro/binance.js +7 -2
- package/js/src/pro/bitget.js +1 -1
- package/js/src/pro/bitpanda.d.ts +2 -34
- package/js/src/pro/bitpanda.js +5 -1330
- package/js/src/pro/coincheck.d.ts +12 -0
- package/js/src/pro/coincheck.js +209 -0
- package/js/src/pro/kucoin.js +43 -35
- package/js/src/pro/kucoinfutures.js +45 -37
- package/js/src/pro/lbank.d.ts +29 -0
- package/js/src/pro/lbank.js +882 -0
- package/js/src/pro/onetrading.d.ts +36 -0
- package/js/src/pro/onetrading.js +1339 -0
- package/js/src/pro/poloniexfutures.js +43 -35
- package/js/src/whitebit.js +1 -0
- package/package.json +2 -2
- package/rollup.config.js +2 -0
- package/skip-tests.json +14 -2
- package/test-commonjs.cjs +25 -1
- package/dist/cjs/js/ccxt.js +0 -476
- package/dist/cjs/js/src/abstract/alpaca.js +0 -9
- package/dist/cjs/js/src/abstract/ascendex.js +0 -9
- package/dist/cjs/js/src/abstract/bigone.js +0 -9
- package/dist/cjs/js/src/abstract/binance.js +0 -9
- package/dist/cjs/js/src/abstract/bingx.js +0 -9
- package/dist/cjs/js/src/abstract/bit2c.js +0 -9
- package/dist/cjs/js/src/abstract/bitbank.js +0 -9
- package/dist/cjs/js/src/abstract/bitbns.js +0 -9
- package/dist/cjs/js/src/abstract/bitfinex.js +0 -9
- package/dist/cjs/js/src/abstract/bitfinex2.js +0 -9
- package/dist/cjs/js/src/abstract/bitflyer.js +0 -9
- package/dist/cjs/js/src/abstract/bitforex.js +0 -9
- package/dist/cjs/js/src/abstract/bitget.js +0 -9
- package/dist/cjs/js/src/abstract/bithumb.js +0 -9
- package/dist/cjs/js/src/abstract/bitmart.js +0 -9
- package/dist/cjs/js/src/abstract/bitmex.js +0 -9
- package/dist/cjs/js/src/abstract/bitopro.js +0 -9
- package/dist/cjs/js/src/abstract/bitpanda.js +0 -9
- package/dist/cjs/js/src/abstract/bitrue.js +0 -9
- package/dist/cjs/js/src/abstract/bitso.js +0 -9
- package/dist/cjs/js/src/abstract/bitstamp.js +0 -9
- package/dist/cjs/js/src/abstract/bitteam.js +0 -9
- package/dist/cjs/js/src/abstract/bitvavo.js +0 -9
- package/dist/cjs/js/src/abstract/bl3p.js +0 -9
- package/dist/cjs/js/src/abstract/blockchaincom.js +0 -9
- package/dist/cjs/js/src/abstract/btcalpha.js +0 -9
- package/dist/cjs/js/src/abstract/btcbox.js +0 -9
- package/dist/cjs/js/src/abstract/btcmarkets.js +0 -9
- package/dist/cjs/js/src/abstract/btcturk.js +0 -9
- package/dist/cjs/js/src/abstract/bybit.js +0 -9
- package/dist/cjs/js/src/abstract/cex.js +0 -9
- package/dist/cjs/js/src/abstract/coinbase.js +0 -9
- package/dist/cjs/js/src/abstract/coinbasepro.js +0 -9
- package/dist/cjs/js/src/abstract/coincheck.js +0 -9
- package/dist/cjs/js/src/abstract/coinex.js +0 -9
- package/dist/cjs/js/src/abstract/coinlist.js +0 -9
- package/dist/cjs/js/src/abstract/coinmate.js +0 -9
- package/dist/cjs/js/src/abstract/coinone.js +0 -9
- package/dist/cjs/js/src/abstract/coinsph.js +0 -9
- package/dist/cjs/js/src/abstract/coinspot.js +0 -9
- package/dist/cjs/js/src/abstract/cryptocom.js +0 -9
- package/dist/cjs/js/src/abstract/currencycom.js +0 -9
- package/dist/cjs/js/src/abstract/delta.js +0 -9
- package/dist/cjs/js/src/abstract/deribit.js +0 -9
- package/dist/cjs/js/src/abstract/digifinex.js +0 -9
- package/dist/cjs/js/src/abstract/exmo.js +0 -9
- package/dist/cjs/js/src/abstract/gate.js +0 -9
- package/dist/cjs/js/src/abstract/gemini.js +0 -9
- package/dist/cjs/js/src/abstract/hitbtc.js +0 -9
- package/dist/cjs/js/src/abstract/hollaex.js +0 -9
- package/dist/cjs/js/src/abstract/htx.js +0 -9
- package/dist/cjs/js/src/abstract/huobijp.js +0 -9
- package/dist/cjs/js/src/abstract/idex.js +0 -9
- package/dist/cjs/js/src/abstract/independentreserve.js +0 -9
- package/dist/cjs/js/src/abstract/indodax.js +0 -9
- package/dist/cjs/js/src/abstract/kraken.js +0 -9
- package/dist/cjs/js/src/abstract/krakenfutures.js +0 -9
- package/dist/cjs/js/src/abstract/kucoin.js +0 -9
- package/dist/cjs/js/src/abstract/kucoinfutures.js +0 -9
- package/dist/cjs/js/src/abstract/kuna.js +0 -9
- package/dist/cjs/js/src/abstract/latoken.js +0 -9
- package/dist/cjs/js/src/abstract/lbank.js +0 -9
- package/dist/cjs/js/src/abstract/luno.js +0 -9
- package/dist/cjs/js/src/abstract/lykke.js +0 -9
- package/dist/cjs/js/src/abstract/mercado.js +0 -9
- package/dist/cjs/js/src/abstract/mexc.js +0 -9
- package/dist/cjs/js/src/abstract/ndax.js +0 -9
- package/dist/cjs/js/src/abstract/novadax.js +0 -9
- package/dist/cjs/js/src/abstract/oceanex.js +0 -9
- package/dist/cjs/js/src/abstract/okcoin.js +0 -9
- package/dist/cjs/js/src/abstract/okx.js +0 -9
- package/dist/cjs/js/src/abstract/p2b.js +0 -9
- package/dist/cjs/js/src/abstract/paymium.js +0 -9
- package/dist/cjs/js/src/abstract/phemex.js +0 -9
- package/dist/cjs/js/src/abstract/poloniex.js +0 -9
- package/dist/cjs/js/src/abstract/poloniexfutures.js +0 -9
- package/dist/cjs/js/src/abstract/probit.js +0 -9
- package/dist/cjs/js/src/abstract/timex.js +0 -9
- package/dist/cjs/js/src/abstract/tokocrypto.js +0 -9
- package/dist/cjs/js/src/abstract/upbit.js +0 -9
- package/dist/cjs/js/src/abstract/wavesexchange.js +0 -9
- package/dist/cjs/js/src/abstract/wazirx.js +0 -9
- package/dist/cjs/js/src/abstract/whitebit.js +0 -9
- package/dist/cjs/js/src/abstract/woo.js +0 -9
- package/dist/cjs/js/src/abstract/yobit.js +0 -9
- package/dist/cjs/js/src/abstract/zaif.js +0 -9
- package/dist/cjs/js/src/abstract/zonda.js +0 -9
- package/dist/cjs/js/src/ace.js +0 -1058
- package/dist/cjs/js/src/alpaca.js +0 -1125
- package/dist/cjs/js/src/ascendex.js +0 -3365
- package/dist/cjs/js/src/base/Exchange.js +0 -5257
- package/dist/cjs/js/src/base/Precise.js +0 -263
- package/dist/cjs/js/src/base/errors.js +0 -299
- package/dist/cjs/js/src/base/functions/crypto.js +0 -78
- package/dist/cjs/js/src/base/functions/encode.js +0 -44
- package/dist/cjs/js/src/base/functions/generic.js +0 -193
- package/dist/cjs/js/src/base/functions/misc.js +0 -96
- package/dist/cjs/js/src/base/functions/number.js +0 -297
- package/dist/cjs/js/src/base/functions/platform.js +0 -28
- package/dist/cjs/js/src/base/functions/rsa.js +0 -34
- package/dist/cjs/js/src/base/functions/string.js +0 -48
- package/dist/cjs/js/src/base/functions/throttle.js +0 -66
- package/dist/cjs/js/src/base/functions/time.js +0 -187
- package/dist/cjs/js/src/base/functions/totp.js +0 -24
- package/dist/cjs/js/src/base/functions/type.js +0 -162
- package/dist/cjs/js/src/base/functions.js +0 -157
- package/dist/cjs/js/src/base/ws/Cache.js +0 -254
- package/dist/cjs/js/src/base/ws/Client.js +0 -299
- package/dist/cjs/js/src/base/ws/Future.js +0 -34
- package/dist/cjs/js/src/base/ws/OrderBook.js +0 -107
- package/dist/cjs/js/src/base/ws/OrderBookSide.js +0 -281
- package/dist/cjs/js/src/base/ws/WsClient.js +0 -69
- package/dist/cjs/js/src/bequant.js +0 -33
- package/dist/cjs/js/src/bigone.js +0 -2213
- package/dist/cjs/js/src/binance.js +0 -9845
- package/dist/cjs/js/src/binancecoinm.js +0 -45
- package/dist/cjs/js/src/binanceus.js +0 -92
- package/dist/cjs/js/src/binanceusdm.js +0 -58
- package/dist/cjs/js/src/bingx.js +0 -3846
- package/dist/cjs/js/src/bit2c.js +0 -916
- package/dist/cjs/js/src/bitbank.js +0 -1000
- package/dist/cjs/js/src/bitbay.js +0 -17
- package/dist/cjs/js/src/bitbns.js +0 -1220
- package/dist/cjs/js/src/bitcoincom.js +0 -17
- package/dist/cjs/js/src/bitfinex.js +0 -1670
- package/dist/cjs/js/src/bitfinex2.js +0 -2990
- package/dist/cjs/js/src/bitflyer.js +0 -1045
- package/dist/cjs/js/src/bitforex.js +0 -852
- package/dist/cjs/js/src/bitget.js +0 -8295
- package/dist/cjs/js/src/bithumb.js +0 -1090
- package/dist/cjs/js/src/bitmart.js +0 -4454
- package/dist/cjs/js/src/bitmex.js +0 -2881
- package/dist/cjs/js/src/bitopro.js +0 -1724
- package/dist/cjs/js/src/bitrue.js +0 -3253
- package/dist/cjs/js/src/bitso.js +0 -1753
- package/dist/cjs/js/src/bitstamp.js +0 -2188
- package/dist/cjs/js/src/bitteam.js +0 -2309
- package/dist/cjs/js/src/bitvavo.js +0 -1968
- package/dist/cjs/js/src/bl3p.js +0 -447
- package/dist/cjs/js/src/blockchaincom.js +0 -1160
- package/dist/cjs/js/src/btcalpha.js +0 -929
- package/dist/cjs/js/src/btcbox.js +0 -565
- package/dist/cjs/js/src/btcmarkets.js +0 -1237
- package/dist/cjs/js/src/btcturk.js +0 -929
- package/dist/cjs/js/src/bybit.js +0 -7650
- package/dist/cjs/js/src/cex.js +0 -1693
- package/dist/cjs/js/src/coinbase.js +0 -3424
- package/dist/cjs/js/src/coinbasepro.js +0 -1866
- package/dist/cjs/js/src/coincheck.js +0 -843
- package/dist/cjs/js/src/coinex.js +0 -5417
- package/dist/cjs/js/src/coinlist.js +0 -2337
- package/dist/cjs/js/src/coinmate.js +0 -989
- package/dist/cjs/js/src/coinone.js +0 -1185
- package/dist/cjs/js/src/coinsph.js +0 -1933
- package/dist/cjs/js/src/coinspot.js +0 -548
- package/dist/cjs/js/src/cryptocom.js +0 -3007
- package/dist/cjs/js/src/currencycom.js +0 -2015
- package/dist/cjs/js/src/delta.js +0 -3262
- package/dist/cjs/js/src/deribit.js +0 -3306
- package/dist/cjs/js/src/digifinex.js +0 -4307
- package/dist/cjs/js/src/exmo.js +0 -2645
- package/dist/cjs/js/src/fmfwio.js +0 -34
- package/dist/cjs/js/src/gate.js +0 -7077
- package/dist/cjs/js/src/gateio.js +0 -16
- package/dist/cjs/js/src/gemini.js +0 -1801
- package/dist/cjs/js/src/hitbtc.js +0 -3660
- package/dist/cjs/js/src/hitbtc3.js +0 -19
- package/dist/cjs/js/src/hollaex.js +0 -1882
- package/dist/cjs/js/src/htx.js +0 -9174
- package/dist/cjs/js/src/huobi.js +0 -16
- package/dist/cjs/js/src/huobijp.js +0 -1918
- package/dist/cjs/js/src/idex.js +0 -1770
- package/dist/cjs/js/src/independentreserve.js +0 -761
- package/dist/cjs/js/src/indodax.js +0 -1069
- package/dist/cjs/js/src/kraken.js +0 -2891
- package/dist/cjs/js/src/krakenfutures.js +0 -2407
- package/dist/cjs/js/src/kucoin.js +0 -4494
- package/dist/cjs/js/src/kucoinfutures.js +0 -2529
- package/dist/cjs/js/src/kuna.js +0 -1949
- package/dist/cjs/js/src/latoken.js +0 -1729
- package/dist/cjs/js/src/lbank.js +0 -2851
- package/dist/cjs/js/src/luno.js +0 -1044
- package/dist/cjs/js/src/lykke.js +0 -1303
- package/dist/cjs/js/src/mercado.js +0 -897
- package/dist/cjs/js/src/mexc.js +0 -5407
- package/dist/cjs/js/src/ndax.js +0 -2450
- package/dist/cjs/js/src/novadax.js +0 -1556
- package/dist/cjs/js/src/oceanex.js +0 -964
- package/dist/cjs/js/src/okcoin.js +0 -3115
- package/dist/cjs/js/src/okx.js +0 -7331
- package/dist/cjs/js/src/p2b.js +0 -1243
- package/dist/cjs/js/src/paymium.js +0 -597
- package/dist/cjs/js/src/phemex.js +0 -4725
- package/dist/cjs/js/src/poloniex.js +0 -2356
- package/dist/cjs/js/src/poloniexfutures.js +0 -1794
- package/dist/cjs/js/src/pro/alpaca.js +0 -714
- package/dist/cjs/js/src/pro/ascendex.js +0 -957
- package/dist/cjs/js/src/pro/bequant.js +0 -33
- package/dist/cjs/js/src/pro/binance.js +0 -2796
- package/dist/cjs/js/src/pro/binancecoinm.js +0 -23
- package/dist/cjs/js/src/pro/binanceus.js +0 -51
- package/dist/cjs/js/src/pro/binanceusdm.js +0 -32
- package/dist/cjs/js/src/pro/bingx.js +0 -944
- package/dist/cjs/js/src/pro/bitcoincom.js +0 -29
- package/dist/cjs/js/src/pro/bitfinex.js +0 -672
- package/dist/cjs/js/src/pro/bitfinex2.js +0 -1159
- package/dist/cjs/js/src/pro/bitget.js +0 -1733
- package/dist/cjs/js/src/pro/bitmart.js +0 -1486
- package/dist/cjs/js/src/pro/bitmex.js +0 -1576
- package/dist/cjs/js/src/pro/bitopro.js +0 -327
- package/dist/cjs/js/src/pro/bitrue.js +0 -462
- package/dist/cjs/js/src/pro/bitstamp.js +0 -547
- package/dist/cjs/js/src/pro/bitvavo.js +0 -704
- package/dist/cjs/js/src/pro/blockchaincom.js +0 -794
- package/dist/cjs/js/src/pro/bybit.js +0 -1843
- package/dist/cjs/js/src/pro/cex.js +0 -1510
- package/dist/cjs/js/src/pro/coinbase.js +0 -561
- package/dist/cjs/js/src/pro/coinbasepro.js +0 -968
- package/dist/cjs/js/src/pro/coinex.js +0 -1095
- package/dist/cjs/js/src/pro/cryptocom.js +0 -1020
- package/dist/cjs/js/src/pro/currencycom.js +0 -563
- package/dist/cjs/js/src/pro/deribit.js +0 -825
- package/dist/cjs/js/src/pro/exmo.js +0 -658
- package/dist/cjs/js/src/pro/gate.js +0 -1316
- package/dist/cjs/js/src/pro/gateio.js +0 -16
- package/dist/cjs/js/src/pro/gemini.js +0 -649
- package/dist/cjs/js/src/pro/hitbtc.js +0 -1294
- package/dist/cjs/js/src/pro/hollaex.js +0 -597
- package/dist/cjs/js/src/pro/htx.js +0 -2388
- package/dist/cjs/js/src/pro/huobi.js +0 -16
- package/dist/cjs/js/src/pro/huobijp.js +0 -606
- package/dist/cjs/js/src/pro/idex.js +0 -714
- package/dist/cjs/js/src/pro/independentreserve.js +0 -280
- package/dist/cjs/js/src/pro/kraken.js +0 -1364
- package/dist/cjs/js/src/pro/krakenfutures.js +0 -1506
- package/dist/cjs/js/src/pro/kucoin.js +0 -1054
- package/dist/cjs/js/src/pro/kucoinfutures.js +0 -981
- package/dist/cjs/js/src/pro/luno.js +0 -322
- package/dist/cjs/js/src/pro/mexc.js +0 -1170
- package/dist/cjs/js/src/pro/ndax.js +0 -545
- package/dist/cjs/js/src/pro/okcoin.js +0 -760
- package/dist/cjs/js/src/pro/okx.js +0 -1608
- package/dist/cjs/js/src/pro/phemex.js +0 -1511
- package/dist/cjs/js/src/pro/poloniex.js +0 -1253
- package/dist/cjs/js/src/pro/poloniexfutures.js +0 -1014
- package/dist/cjs/js/src/pro/probit.js +0 -586
- package/dist/cjs/js/src/pro/upbit.js +0 -234
- package/dist/cjs/js/src/pro/wazirx.js +0 -776
- package/dist/cjs/js/src/pro/whitebit.js +0 -927
- package/dist/cjs/js/src/pro/woo.js +0 -895
- package/dist/cjs/js/src/probit.js +0 -1867
- package/dist/cjs/js/src/static_dependencies/fflake/browser.js +0 -401
- package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncrypt.js +0 -195
- package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +0 -308
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +0 -554
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +0 -94
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +0 -70
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +0 -91
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +0 -16
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +0 -1760
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +0 -52
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +0 -81
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +0 -376
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +0 -70
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +0 -1580
- package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +0 -74
- package/dist/cjs/js/src/static_dependencies/noble-curves/_shortw_utils.js +0 -24
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/curve.js +0 -158
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/edwards.js +0 -429
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +0 -176
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/modular.js +0 -324
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/montgomery.js +0 -163
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/utils.js +0 -245
- package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +0 -1018
- package/dist/cjs/js/src/static_dependencies/noble-curves/ed25519.js +0 -383
- package/dist/cjs/js/src/static_dependencies/noble-curves/secp256k1.js +0 -258
- package/dist/cjs/js/src/static_dependencies/noble-hashes/_assert.js +0 -53
- package/dist/cjs/js/src/static_dependencies/noble-hashes/_sha2.js +0 -120
- package/dist/cjs/js/src/static_dependencies/noble-hashes/_u64.js +0 -69
- package/dist/cjs/js/src/static_dependencies/noble-hashes/crypto.js +0 -7
- package/dist/cjs/js/src/static_dependencies/noble-hashes/hmac.js +0 -83
- package/dist/cjs/js/src/static_dependencies/noble-hashes/md5.js +0 -240
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha1.js +0 -91
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha256.js +0 -130
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha3.js +0 -214
- package/dist/cjs/js/src/static_dependencies/noble-hashes/sha512.js +0 -239
- package/dist/cjs/js/src/static_dependencies/noble-hashes/utils.js +0 -93
- package/dist/cjs/js/src/static_dependencies/node-fetch/body.js +0 -354
- package/dist/cjs/js/src/static_dependencies/node-fetch/errors/abort-error.js +0 -16
- package/dist/cjs/js/src/static_dependencies/node-fetch/errors/base.js +0 -20
- package/dist/cjs/js/src/static_dependencies/node-fetch/errors/fetch-error.js +0 -30
- package/dist/cjs/js/src/static_dependencies/node-fetch/headers.js +0 -239
- package/dist/cjs/js/src/static_dependencies/node-fetch/index.js +0 -372
- package/dist/cjs/js/src/static_dependencies/node-fetch/request.js +0 -273
- package/dist/cjs/js/src/static_dependencies/node-fetch/response.js +0 -139
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/get-search.js +0 -14
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is-redirect.js +0 -16
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is.js +0 -81
- package/dist/cjs/js/src/static_dependencies/node-fetch/utils/referrer.js +0 -292
- package/dist/cjs/js/src/static_dependencies/proxies/agent-base/index.js +0 -103
- package/dist/cjs/js/src/static_dependencies/proxies/http-proxy-agent/index.js +0 -140
- package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/index.js +0 -175
- package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +0 -95
- package/dist/cjs/js/src/static_dependencies/qs/index.cjs.js +0 -7
- package/dist/cjs/js/src/static_dependencies/scure-base/index.js +0 -383
- package/dist/cjs/js/src/timex.js +0 -1562
- package/dist/cjs/js/src/tokocrypto.js +0 -2542
- package/dist/cjs/js/src/upbit.js +0 -1844
- package/dist/cjs/js/src/wavesexchange.js +0 -2607
- package/dist/cjs/js/src/wazirx.js +0 -953
- package/dist/cjs/js/src/whitebit.js +0 -2309
- package/dist/cjs/js/src/woo.js +0 -2769
- package/dist/cjs/js/src/yobit.js +0 -1314
- package/dist/cjs/js/src/zaif.js +0 -736
- package/dist/cjs/js/src/zonda.js +0 -1883
- package/dist/cjs/src/abstract/bitpanda.js +0 -9
- package/test.ts +0 -0
- /package/dist/cjs/{js/src/abstract/ace.js → src/abstract/onetrading.js} +0 -0
- /package/dist/cjs/{js/src → src}/pro/coinone.js +0 -0
- /package/js/src/abstract/{bitpanda.js → onetrading.js} +0 -0
package/dist/cjs/js/src/cex.js
DELETED
|
@@ -1,1693 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var cex$1 = require('./abstract/cex.js');
|
|
4
|
-
var errors = require('./base/errors.js');
|
|
5
|
-
var Precise = require('./base/Precise.js');
|
|
6
|
-
var number = require('./base/functions/number.js');
|
|
7
|
-
var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
|
|
8
|
-
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
// ---------------------------------------------------------------------------
|
|
11
|
-
/**
|
|
12
|
-
* @class cex
|
|
13
|
-
* @augments Exchange
|
|
14
|
-
*/
|
|
15
|
-
class cex extends cex$1 {
|
|
16
|
-
describe() {
|
|
17
|
-
return this.deepExtend(super.describe(), {
|
|
18
|
-
'id': 'cex',
|
|
19
|
-
'name': 'CEX.IO',
|
|
20
|
-
'countries': ['GB', 'EU', 'CY', 'RU'],
|
|
21
|
-
'rateLimit': 1500,
|
|
22
|
-
'pro': true,
|
|
23
|
-
'has': {
|
|
24
|
-
'CORS': undefined,
|
|
25
|
-
'spot': true,
|
|
26
|
-
'margin': false,
|
|
27
|
-
'swap': false,
|
|
28
|
-
'future': false,
|
|
29
|
-
'option': false,
|
|
30
|
-
'addMargin': false,
|
|
31
|
-
'cancelAllOrders': true,
|
|
32
|
-
'cancelOrder': true,
|
|
33
|
-
'cancelOrders': false,
|
|
34
|
-
'createDepositAddress': false,
|
|
35
|
-
'createMarketBuyOrderWithCost': true,
|
|
36
|
-
'createMarketOrderWithCost': false,
|
|
37
|
-
'createMarketSellOrderWithCost': false,
|
|
38
|
-
'createOrder': true,
|
|
39
|
-
'createStopLimitOrder': false,
|
|
40
|
-
'createStopMarketOrder': false,
|
|
41
|
-
'createStopOrder': false,
|
|
42
|
-
'editOrder': true,
|
|
43
|
-
'fetchBalance': true,
|
|
44
|
-
'fetchClosedOrders': true,
|
|
45
|
-
'fetchCurrencies': true,
|
|
46
|
-
'fetchDeposit': false,
|
|
47
|
-
'fetchDepositAddress': true,
|
|
48
|
-
'fetchDepositAddresses': false,
|
|
49
|
-
'fetchDeposits': false,
|
|
50
|
-
'fetchDepositsWithdrawals': false,
|
|
51
|
-
'fetchFundingHistory': false,
|
|
52
|
-
'fetchFundingRate': false,
|
|
53
|
-
'fetchFundingRateHistory': false,
|
|
54
|
-
'fetchFundingRates': false,
|
|
55
|
-
'fetchIndexOHLCV': false,
|
|
56
|
-
'fetchMarginMode': false,
|
|
57
|
-
'fetchMarkets': true,
|
|
58
|
-
'fetchMarkOHLCV': false,
|
|
59
|
-
'fetchOHLCV': true,
|
|
60
|
-
'fetchOpenInterestHistory': false,
|
|
61
|
-
'fetchOpenOrders': true,
|
|
62
|
-
'fetchOrder': true,
|
|
63
|
-
'fetchOrderBook': true,
|
|
64
|
-
'fetchOrders': true,
|
|
65
|
-
'fetchPositionMode': false,
|
|
66
|
-
'fetchPremiumIndexOHLCV': false,
|
|
67
|
-
'fetchTicker': true,
|
|
68
|
-
'fetchTickers': true,
|
|
69
|
-
'fetchTrades': true,
|
|
70
|
-
'fetchTradingFee': false,
|
|
71
|
-
'fetchTradingFees': true,
|
|
72
|
-
'fetchTransactions': false,
|
|
73
|
-
'fetchTransfer': false,
|
|
74
|
-
'fetchTransfers': false,
|
|
75
|
-
'fetchWithdrawal': false,
|
|
76
|
-
'fetchWithdrawals': false,
|
|
77
|
-
'fetchWithdrawalWhitelist': false,
|
|
78
|
-
'reduceMargin': false,
|
|
79
|
-
'setLeverage': false,
|
|
80
|
-
'setMargin': false,
|
|
81
|
-
'setMarginMode': false,
|
|
82
|
-
'transfer': false,
|
|
83
|
-
'withdraw': false,
|
|
84
|
-
},
|
|
85
|
-
'timeframes': {
|
|
86
|
-
'1m': '1m',
|
|
87
|
-
'1h': '1h',
|
|
88
|
-
'1d': '1d',
|
|
89
|
-
},
|
|
90
|
-
'urls': {
|
|
91
|
-
'logo': 'https://user-images.githubusercontent.com/1294454/27766442-8ddc33b0-5ed8-11e7-8b98-f786aef0f3c9.jpg',
|
|
92
|
-
'api': {
|
|
93
|
-
'rest': 'https://cex.io/api',
|
|
94
|
-
},
|
|
95
|
-
'www': 'https://cex.io',
|
|
96
|
-
'doc': 'https://cex.io/cex-api',
|
|
97
|
-
'fees': [
|
|
98
|
-
'https://cex.io/fee-schedule',
|
|
99
|
-
'https://cex.io/limits-commissions',
|
|
100
|
-
],
|
|
101
|
-
'referral': 'https://cex.io/r/0/up105393824/0/',
|
|
102
|
-
},
|
|
103
|
-
'requiredCredentials': {
|
|
104
|
-
'apiKey': true,
|
|
105
|
-
'secret': true,
|
|
106
|
-
'uid': true,
|
|
107
|
-
},
|
|
108
|
-
'api': {
|
|
109
|
-
'public': {
|
|
110
|
-
'get': [
|
|
111
|
-
'currency_profile',
|
|
112
|
-
'currency_limits/',
|
|
113
|
-
'last_price/{pair}/',
|
|
114
|
-
'last_prices/{currencies}/',
|
|
115
|
-
'ohlcv/hd/{yyyymmdd}/{pair}',
|
|
116
|
-
'order_book/{pair}/',
|
|
117
|
-
'ticker/{pair}/',
|
|
118
|
-
'tickers/{currencies}/',
|
|
119
|
-
'trade_history/{pair}/',
|
|
120
|
-
],
|
|
121
|
-
'post': [
|
|
122
|
-
'convert/{pair}',
|
|
123
|
-
'price_stats/{pair}',
|
|
124
|
-
],
|
|
125
|
-
},
|
|
126
|
-
'private': {
|
|
127
|
-
'post': [
|
|
128
|
-
'active_orders_status/',
|
|
129
|
-
'archived_orders/{pair}/',
|
|
130
|
-
'balance/',
|
|
131
|
-
'cancel_order/',
|
|
132
|
-
'cancel_orders/{pair}/',
|
|
133
|
-
'cancel_replace_order/{pair}/',
|
|
134
|
-
'close_position/{pair}/',
|
|
135
|
-
'get_address/',
|
|
136
|
-
'get_crypto_address',
|
|
137
|
-
'get_myfee/',
|
|
138
|
-
'get_order/',
|
|
139
|
-
'get_order_tx/',
|
|
140
|
-
'open_orders/{pair}/',
|
|
141
|
-
'open_orders/',
|
|
142
|
-
'open_position/{pair}/',
|
|
143
|
-
'open_positions/{pair}/',
|
|
144
|
-
'place_order/{pair}/',
|
|
145
|
-
'raw_tx_history',
|
|
146
|
-
],
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
'fees': {
|
|
150
|
-
'trading': {
|
|
151
|
-
'maker': this.parseNumber('0.0016'),
|
|
152
|
-
'taker': this.parseNumber('0.0025'),
|
|
153
|
-
},
|
|
154
|
-
'funding': {
|
|
155
|
-
'withdraw': {},
|
|
156
|
-
'deposit': {
|
|
157
|
-
// 'USD': amount => amount * 0.035 + 0.25,
|
|
158
|
-
// 'EUR': amount => amount * 0.035 + 0.24,
|
|
159
|
-
// 'RUB': amount => amount * 0.05 + 15.57,
|
|
160
|
-
// 'GBP': amount => amount * 0.035 + 0.2,
|
|
161
|
-
'BTC': 0.0,
|
|
162
|
-
'ETH': 0.0,
|
|
163
|
-
'BCH': 0.0,
|
|
164
|
-
'DASH': 0.0,
|
|
165
|
-
'BTG': 0.0,
|
|
166
|
-
'ZEC': 0.0,
|
|
167
|
-
'XRP': 0.0,
|
|
168
|
-
'XLM': 0.0,
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
'precisionMode': number.TICK_SIZE,
|
|
173
|
-
'exceptions': {
|
|
174
|
-
'exact': {},
|
|
175
|
-
'broad': {
|
|
176
|
-
'Insufficient funds': errors.InsufficientFunds,
|
|
177
|
-
'Nonce must be incremented': errors.InvalidNonce,
|
|
178
|
-
'Invalid Order': errors.InvalidOrder,
|
|
179
|
-
'Order not found': errors.OrderNotFound,
|
|
180
|
-
'limit exceeded': errors.RateLimitExceeded,
|
|
181
|
-
'Invalid API key': errors.AuthenticationError,
|
|
182
|
-
'There was an error while placing your order': errors.InvalidOrder,
|
|
183
|
-
'Sorry, too many clients already': errors.DDoSProtection,
|
|
184
|
-
'Invalid Symbols Pair': errors.BadSymbol,
|
|
185
|
-
'Wrong currency pair': errors.BadSymbol, // {"error":"There was an error while placing your order: Wrong currency pair.","safe":true}
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
'options': {
|
|
189
|
-
'fetchOHLCVWarning': true,
|
|
190
|
-
'createMarketBuyOrderRequiresPrice': true,
|
|
191
|
-
'order': {
|
|
192
|
-
'status': {
|
|
193
|
-
'c': 'canceled',
|
|
194
|
-
'd': 'closed',
|
|
195
|
-
'cd': 'canceled',
|
|
196
|
-
'a': 'open',
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
'defaultNetwork': 'ERC20',
|
|
200
|
-
'defaultNetworks': {
|
|
201
|
-
'USDT': 'TRC20',
|
|
202
|
-
},
|
|
203
|
-
'networks': {
|
|
204
|
-
'ERC20': 'Ethereum',
|
|
205
|
-
'BTC': 'BTC',
|
|
206
|
-
'BEP20': 'Binance Smart Chain',
|
|
207
|
-
'TRC20': 'Tron',
|
|
208
|
-
},
|
|
209
|
-
},
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
async fetchCurrenciesFromCache(params = {}) {
|
|
213
|
-
// this method is now redundant
|
|
214
|
-
// currencies are now fetched before markets
|
|
215
|
-
const options = this.safeValue(this.options, 'fetchCurrencies', {});
|
|
216
|
-
const timestamp = this.safeInteger(options, 'timestamp');
|
|
217
|
-
const expires = this.safeInteger(options, 'expires', 1000);
|
|
218
|
-
const now = this.milliseconds();
|
|
219
|
-
if ((timestamp === undefined) || ((now - timestamp) > expires)) {
|
|
220
|
-
const response = await this.publicGetCurrencyProfile(params);
|
|
221
|
-
this.options['fetchCurrencies'] = this.extend(options, {
|
|
222
|
-
'response': response,
|
|
223
|
-
'timestamp': now,
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
return this.safeValue(this.options['fetchCurrencies'], 'response');
|
|
227
|
-
}
|
|
228
|
-
async fetchCurrencies(params = {}) {
|
|
229
|
-
/**
|
|
230
|
-
* @method
|
|
231
|
-
* @name cex#fetchCurrencies
|
|
232
|
-
* @description fetches all available currencies on an exchange
|
|
233
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
234
|
-
* @returns {object} an associative dictionary of currencies
|
|
235
|
-
*/
|
|
236
|
-
const response = await this.fetchCurrenciesFromCache(params);
|
|
237
|
-
this.options['currencies'] = {
|
|
238
|
-
'timestamp': this.milliseconds(),
|
|
239
|
-
'response': response,
|
|
240
|
-
};
|
|
241
|
-
//
|
|
242
|
-
// {
|
|
243
|
-
// "e":"currency_profile",
|
|
244
|
-
// "ok":"ok",
|
|
245
|
-
// "data":{
|
|
246
|
-
// "symbols":[
|
|
247
|
-
// {
|
|
248
|
-
// "code":"GHS",
|
|
249
|
-
// "contract":true,
|
|
250
|
-
// "commodity":true,
|
|
251
|
-
// "fiat":false,
|
|
252
|
-
// "description":"CEX.IO doesn't provide cloud mining services anymore.",
|
|
253
|
-
// "precision":8,
|
|
254
|
-
// "scale":0,
|
|
255
|
-
// "minimumCurrencyAmount":"0.00000001",
|
|
256
|
-
// "minimalWithdrawalAmount":-1
|
|
257
|
-
// },
|
|
258
|
-
// {
|
|
259
|
-
// "code":"BTC",
|
|
260
|
-
// "contract":false,
|
|
261
|
-
// "commodity":false,
|
|
262
|
-
// "fiat":false,
|
|
263
|
-
// "description":"",
|
|
264
|
-
// "precision":8,
|
|
265
|
-
// "scale":0,
|
|
266
|
-
// "minimumCurrencyAmount":"0.00000001",
|
|
267
|
-
// "minimalWithdrawalAmount":0.002
|
|
268
|
-
// },
|
|
269
|
-
// {
|
|
270
|
-
// "code":"ETH",
|
|
271
|
-
// "contract":false,
|
|
272
|
-
// "commodity":false,
|
|
273
|
-
// "fiat":false,
|
|
274
|
-
// "description":"",
|
|
275
|
-
// "precision":8,
|
|
276
|
-
// "scale":2,
|
|
277
|
-
// "minimumCurrencyAmount":"0.00000100",
|
|
278
|
-
// "minimalWithdrawalAmount":0.01
|
|
279
|
-
// }
|
|
280
|
-
// ],
|
|
281
|
-
// "pairs":[
|
|
282
|
-
// {
|
|
283
|
-
// "symbol1":"BTC",
|
|
284
|
-
// "symbol2":"USD",
|
|
285
|
-
// "pricePrecision":1,
|
|
286
|
-
// "priceScale":"/1000000",
|
|
287
|
-
// "minLotSize":0.002,
|
|
288
|
-
// "minLotSizeS2":20
|
|
289
|
-
// },
|
|
290
|
-
// {
|
|
291
|
-
// "symbol1":"ETH",
|
|
292
|
-
// "symbol2":"USD",
|
|
293
|
-
// "pricePrecision":2,
|
|
294
|
-
// "priceScale":"/10000",
|
|
295
|
-
// "minLotSize":0.1,
|
|
296
|
-
// "minLotSizeS2":20
|
|
297
|
-
// }
|
|
298
|
-
// ]
|
|
299
|
-
// }
|
|
300
|
-
// }
|
|
301
|
-
//
|
|
302
|
-
const data = this.safeValue(response, 'data', []);
|
|
303
|
-
const currencies = this.safeValue(data, 'symbols', []);
|
|
304
|
-
const result = {};
|
|
305
|
-
for (let i = 0; i < currencies.length; i++) {
|
|
306
|
-
const currency = currencies[i];
|
|
307
|
-
const id = this.safeString(currency, 'code');
|
|
308
|
-
const code = this.safeCurrencyCode(id);
|
|
309
|
-
const active = true;
|
|
310
|
-
result[code] = {
|
|
311
|
-
'id': id,
|
|
312
|
-
'code': code,
|
|
313
|
-
'name': id,
|
|
314
|
-
'active': active,
|
|
315
|
-
'deposit': undefined,
|
|
316
|
-
'withdraw': undefined,
|
|
317
|
-
'precision': this.parseNumber(this.parsePrecision(this.safeString(currency, 'precision'))),
|
|
318
|
-
'fee': undefined,
|
|
319
|
-
'limits': {
|
|
320
|
-
'amount': {
|
|
321
|
-
'min': this.safeNumber(currency, 'minimumCurrencyAmount'),
|
|
322
|
-
'max': undefined,
|
|
323
|
-
},
|
|
324
|
-
'withdraw': {
|
|
325
|
-
'min': this.safeNumber(currency, 'minimalWithdrawalAmount'),
|
|
326
|
-
'max': undefined,
|
|
327
|
-
},
|
|
328
|
-
},
|
|
329
|
-
'info': currency,
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
return result;
|
|
333
|
-
}
|
|
334
|
-
async fetchMarkets(params = {}) {
|
|
335
|
-
/**
|
|
336
|
-
* @method
|
|
337
|
-
* @name cex#fetchMarkets
|
|
338
|
-
* @description retrieves data on all markets for cex
|
|
339
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
340
|
-
* @returns {object[]} an array of objects representing market data
|
|
341
|
-
*/
|
|
342
|
-
const currenciesResponse = await this.fetchCurrenciesFromCache(params);
|
|
343
|
-
const currenciesData = this.safeValue(currenciesResponse, 'data', {});
|
|
344
|
-
const currencies = this.safeValue(currenciesData, 'symbols', []);
|
|
345
|
-
const currenciesById = this.indexBy(currencies, 'code');
|
|
346
|
-
const pairs = this.safeValue(currenciesData, 'pairs', []);
|
|
347
|
-
const response = await this.publicGetCurrencyLimits(params);
|
|
348
|
-
//
|
|
349
|
-
// {
|
|
350
|
-
// "e":"currency_limits",
|
|
351
|
-
// "ok":"ok",
|
|
352
|
-
// "data": {
|
|
353
|
-
// "pairs":[
|
|
354
|
-
// {
|
|
355
|
-
// "symbol1":"BTC",
|
|
356
|
-
// "symbol2":"USD",
|
|
357
|
-
// "minLotSize":0.002,
|
|
358
|
-
// "minLotSizeS2":20,
|
|
359
|
-
// "maxLotSize":30,
|
|
360
|
-
// "minPrice":"1500",
|
|
361
|
-
// "maxPrice":"35000"
|
|
362
|
-
// },
|
|
363
|
-
// {
|
|
364
|
-
// "symbol1":"BCH",
|
|
365
|
-
// "symbol2":"EUR",
|
|
366
|
-
// "minLotSize":0.1,
|
|
367
|
-
// "minLotSizeS2":20,
|
|
368
|
-
// "maxLotSize":null,
|
|
369
|
-
// "minPrice":"25",
|
|
370
|
-
// "maxPrice":"8192"
|
|
371
|
-
// }
|
|
372
|
-
// ]
|
|
373
|
-
// }
|
|
374
|
-
// }
|
|
375
|
-
//
|
|
376
|
-
const result = [];
|
|
377
|
-
const markets = this.safeValue(response['data'], 'pairs');
|
|
378
|
-
for (let i = 0; i < markets.length; i++) {
|
|
379
|
-
const market = markets[i];
|
|
380
|
-
const baseId = this.safeString(market, 'symbol1');
|
|
381
|
-
const quoteId = this.safeString(market, 'symbol2');
|
|
382
|
-
const base = this.safeCurrencyCode(baseId);
|
|
383
|
-
const quote = this.safeCurrencyCode(quoteId);
|
|
384
|
-
const baseCurrency = this.safeValue(currenciesById, baseId, {});
|
|
385
|
-
const quoteCurrency = this.safeValue(currenciesById, quoteId, {});
|
|
386
|
-
let pricePrecisionString = this.safeString(quoteCurrency, 'precision', '8');
|
|
387
|
-
for (let j = 0; j < pairs.length; j++) {
|
|
388
|
-
const pair = pairs[j];
|
|
389
|
-
if ((pair['symbol1'] === baseId) && (pair['symbol2'] === quoteId)) {
|
|
390
|
-
// we might need to account for `priceScale` here
|
|
391
|
-
pricePrecisionString = this.safeString(pair, 'pricePrecision', pricePrecisionString);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
const baseCurrencyPrecision = this.safeString(baseCurrency, 'precision', '8');
|
|
395
|
-
const baseCurrencyScale = this.safeString(baseCurrency, 'scale', '0');
|
|
396
|
-
const amountPrecisionString = Precise["default"].stringSub(baseCurrencyPrecision, baseCurrencyScale);
|
|
397
|
-
result.push({
|
|
398
|
-
'id': baseId + '/' + quoteId,
|
|
399
|
-
'symbol': base + '/' + quote,
|
|
400
|
-
'base': base,
|
|
401
|
-
'quote': quote,
|
|
402
|
-
'settle': undefined,
|
|
403
|
-
'baseId': baseId,
|
|
404
|
-
'quoteId': quoteId,
|
|
405
|
-
'settleId': undefined,
|
|
406
|
-
'type': 'spot',
|
|
407
|
-
'spot': true,
|
|
408
|
-
'margin': undefined,
|
|
409
|
-
'swap': false,
|
|
410
|
-
'future': false,
|
|
411
|
-
'option': false,
|
|
412
|
-
'active': undefined,
|
|
413
|
-
'contract': false,
|
|
414
|
-
'linear': undefined,
|
|
415
|
-
'inverse': undefined,
|
|
416
|
-
'contractSize': undefined,
|
|
417
|
-
'expiry': undefined,
|
|
418
|
-
'expiryDatetime': undefined,
|
|
419
|
-
'strike': undefined,
|
|
420
|
-
'optionType': undefined,
|
|
421
|
-
'precision': {
|
|
422
|
-
'amount': this.parseNumber(this.parsePrecision(amountPrecisionString)),
|
|
423
|
-
'price': this.parseNumber(this.parsePrecision(pricePrecisionString)),
|
|
424
|
-
},
|
|
425
|
-
'limits': {
|
|
426
|
-
'leverage': {
|
|
427
|
-
'min': undefined,
|
|
428
|
-
'max': undefined,
|
|
429
|
-
},
|
|
430
|
-
'amount': {
|
|
431
|
-
'min': this.safeNumber(market, 'minLotSize'),
|
|
432
|
-
'max': this.safeNumber(market, 'maxLotSize'),
|
|
433
|
-
},
|
|
434
|
-
'price': {
|
|
435
|
-
'min': this.safeNumber(market, 'minPrice'),
|
|
436
|
-
'max': this.safeNumber(market, 'maxPrice'),
|
|
437
|
-
},
|
|
438
|
-
'cost': {
|
|
439
|
-
'min': this.safeNumber(market, 'minLotSizeS2'),
|
|
440
|
-
'max': undefined,
|
|
441
|
-
},
|
|
442
|
-
},
|
|
443
|
-
'created': undefined,
|
|
444
|
-
'info': market,
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
return result;
|
|
448
|
-
}
|
|
449
|
-
parseBalance(response) {
|
|
450
|
-
const result = { 'info': response };
|
|
451
|
-
const ommited = ['username', 'timestamp'];
|
|
452
|
-
const balances = this.omit(response, ommited);
|
|
453
|
-
const currencyIds = Object.keys(balances);
|
|
454
|
-
for (let i = 0; i < currencyIds.length; i++) {
|
|
455
|
-
const currencyId = currencyIds[i];
|
|
456
|
-
const balance = this.safeValue(balances, currencyId, {});
|
|
457
|
-
const account = this.account();
|
|
458
|
-
account['free'] = this.safeString(balance, 'available');
|
|
459
|
-
// https://github.com/ccxt/ccxt/issues/5484
|
|
460
|
-
account['used'] = this.safeString(balance, 'orders', '0');
|
|
461
|
-
const code = this.safeCurrencyCode(currencyId);
|
|
462
|
-
result[code] = account;
|
|
463
|
-
}
|
|
464
|
-
return this.safeBalance(result);
|
|
465
|
-
}
|
|
466
|
-
async fetchBalance(params = {}) {
|
|
467
|
-
/**
|
|
468
|
-
* @method
|
|
469
|
-
* @name cex#fetchBalance
|
|
470
|
-
* @see https://docs.cex.io/#account-balance
|
|
471
|
-
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
472
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
473
|
-
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
474
|
-
*/
|
|
475
|
-
await this.loadMarkets();
|
|
476
|
-
const response = await this.privatePostBalance(params);
|
|
477
|
-
return this.parseBalance(response);
|
|
478
|
-
}
|
|
479
|
-
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
480
|
-
/**
|
|
481
|
-
* @method
|
|
482
|
-
* @name cex#fetchOrderBook
|
|
483
|
-
* @see https://docs.cex.io/#orderbook
|
|
484
|
-
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
485
|
-
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
486
|
-
* @param {int} [limit] the maximum amount of order book entries to return
|
|
487
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
488
|
-
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
489
|
-
*/
|
|
490
|
-
await this.loadMarkets();
|
|
491
|
-
const market = this.market(symbol);
|
|
492
|
-
const request = {
|
|
493
|
-
'pair': market['id'],
|
|
494
|
-
};
|
|
495
|
-
if (limit !== undefined) {
|
|
496
|
-
request['depth'] = limit;
|
|
497
|
-
}
|
|
498
|
-
const response = await this.publicGetOrderBookPair(this.extend(request, params));
|
|
499
|
-
const timestamp = this.safeTimestamp(response, 'timestamp');
|
|
500
|
-
return this.parseOrderBook(response, market['symbol'], timestamp);
|
|
501
|
-
}
|
|
502
|
-
parseOHLCV(ohlcv, market = undefined) {
|
|
503
|
-
//
|
|
504
|
-
// [
|
|
505
|
-
// 1591403940,
|
|
506
|
-
// 0.024972,
|
|
507
|
-
// 0.024972,
|
|
508
|
-
// 0.024969,
|
|
509
|
-
// 0.024969,
|
|
510
|
-
// 0.49999900
|
|
511
|
-
// ]
|
|
512
|
-
//
|
|
513
|
-
return [
|
|
514
|
-
this.safeTimestamp(ohlcv, 0),
|
|
515
|
-
this.safeNumber(ohlcv, 1),
|
|
516
|
-
this.safeNumber(ohlcv, 2),
|
|
517
|
-
this.safeNumber(ohlcv, 3),
|
|
518
|
-
this.safeNumber(ohlcv, 4),
|
|
519
|
-
this.safeNumber(ohlcv, 5),
|
|
520
|
-
];
|
|
521
|
-
}
|
|
522
|
-
async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
523
|
-
/**
|
|
524
|
-
* @method
|
|
525
|
-
* @name cex#fetchOHLCV
|
|
526
|
-
* @see https://docs.cex.io/#historical-ohlcv-chart
|
|
527
|
-
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
528
|
-
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
529
|
-
* @param {string} timeframe the length of time each candle represents
|
|
530
|
-
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
531
|
-
* @param {int} [limit] the maximum amount of candles to fetch
|
|
532
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
533
|
-
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
534
|
-
*/
|
|
535
|
-
await this.loadMarkets();
|
|
536
|
-
const market = this.market(symbol);
|
|
537
|
-
if (since === undefined) {
|
|
538
|
-
since = this.milliseconds() - 86400000; // yesterday
|
|
539
|
-
}
|
|
540
|
-
else {
|
|
541
|
-
if (this.options['fetchOHLCVWarning']) {
|
|
542
|
-
throw new errors.ExchangeError(this.id + " fetchOHLCV warning: CEX can return historical candles for a certain date only, this might produce an empty or null reply. Set exchange.options['fetchOHLCVWarning'] = false or add ({ 'options': { 'fetchOHLCVWarning': false }}) to constructor params to suppress this warning message.");
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
const request = {
|
|
546
|
-
'pair': market['id'],
|
|
547
|
-
'yyyymmdd': this.yyyymmdd(since, ''),
|
|
548
|
-
};
|
|
549
|
-
try {
|
|
550
|
-
const response = await this.publicGetOhlcvHdYyyymmddPair(this.extend(request, params));
|
|
551
|
-
//
|
|
552
|
-
// {
|
|
553
|
-
// "time":20200606,
|
|
554
|
-
// "data1m":"[[1591403940,0.024972,0.024972,0.024969,0.024969,0.49999900]]",
|
|
555
|
-
// }
|
|
556
|
-
//
|
|
557
|
-
const key = 'data' + this.safeString(this.timeframes, timeframe, timeframe);
|
|
558
|
-
const data = this.safeString(response, key);
|
|
559
|
-
const ohlcvs = JSON.parse(data);
|
|
560
|
-
return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
|
|
561
|
-
}
|
|
562
|
-
catch (e) {
|
|
563
|
-
if (e instanceof errors.NullResponse) {
|
|
564
|
-
return [];
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
return undefined;
|
|
568
|
-
}
|
|
569
|
-
parseTicker(ticker, market = undefined) {
|
|
570
|
-
const timestamp = this.safeTimestamp(ticker, 'timestamp');
|
|
571
|
-
const volume = this.safeString(ticker, 'volume');
|
|
572
|
-
const high = this.safeString(ticker, 'high');
|
|
573
|
-
const low = this.safeString(ticker, 'low');
|
|
574
|
-
const bid = this.safeString(ticker, 'bid');
|
|
575
|
-
const ask = this.safeString(ticker, 'ask');
|
|
576
|
-
const last = this.safeString(ticker, 'last');
|
|
577
|
-
const symbol = this.safeSymbol(undefined, market);
|
|
578
|
-
return this.safeTicker({
|
|
579
|
-
'symbol': symbol,
|
|
580
|
-
'timestamp': timestamp,
|
|
581
|
-
'datetime': this.iso8601(timestamp),
|
|
582
|
-
'high': high,
|
|
583
|
-
'low': low,
|
|
584
|
-
'bid': bid,
|
|
585
|
-
'bidVolume': undefined,
|
|
586
|
-
'ask': ask,
|
|
587
|
-
'askVolume': undefined,
|
|
588
|
-
'vwap': undefined,
|
|
589
|
-
'open': undefined,
|
|
590
|
-
'close': last,
|
|
591
|
-
'last': last,
|
|
592
|
-
'previousClose': undefined,
|
|
593
|
-
'change': undefined,
|
|
594
|
-
'percentage': undefined,
|
|
595
|
-
'average': undefined,
|
|
596
|
-
'baseVolume': volume,
|
|
597
|
-
'quoteVolume': undefined,
|
|
598
|
-
'info': ticker,
|
|
599
|
-
}, market);
|
|
600
|
-
}
|
|
601
|
-
async fetchTickers(symbols = undefined, params = {}) {
|
|
602
|
-
/**
|
|
603
|
-
* @method
|
|
604
|
-
* @name cex#fetchTickers
|
|
605
|
-
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
606
|
-
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
607
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
608
|
-
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
609
|
-
*/
|
|
610
|
-
await this.loadMarkets();
|
|
611
|
-
symbols = this.marketSymbols(symbols);
|
|
612
|
-
const currencies = Object.keys(this.currencies);
|
|
613
|
-
const request = {
|
|
614
|
-
'currencies': currencies.join('/'),
|
|
615
|
-
};
|
|
616
|
-
const response = await this.publicGetTickersCurrencies(this.extend(request, params));
|
|
617
|
-
const tickers = this.safeValue(response, 'data', []);
|
|
618
|
-
const result = {};
|
|
619
|
-
for (let t = 0; t < tickers.length; t++) {
|
|
620
|
-
const ticker = tickers[t];
|
|
621
|
-
const marketId = this.safeString(ticker, 'pair');
|
|
622
|
-
const market = this.safeMarket(marketId, undefined, ':');
|
|
623
|
-
const symbol = market['symbol'];
|
|
624
|
-
result[symbol] = this.parseTicker(ticker, market);
|
|
625
|
-
}
|
|
626
|
-
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
627
|
-
}
|
|
628
|
-
async fetchTicker(symbol, params = {}) {
|
|
629
|
-
/**
|
|
630
|
-
* @method
|
|
631
|
-
* @name cex#fetchTicker
|
|
632
|
-
* @see https://docs.cex.io/#ticker
|
|
633
|
-
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
634
|
-
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
635
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
636
|
-
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
637
|
-
*/
|
|
638
|
-
await this.loadMarkets();
|
|
639
|
-
const market = this.market(symbol);
|
|
640
|
-
const request = {
|
|
641
|
-
'pair': market['id'],
|
|
642
|
-
};
|
|
643
|
-
const ticker = await this.publicGetTickerPair(this.extend(request, params));
|
|
644
|
-
return this.parseTicker(ticker, market);
|
|
645
|
-
}
|
|
646
|
-
parseTrade(trade, market = undefined) {
|
|
647
|
-
//
|
|
648
|
-
// fetchTrades (public)
|
|
649
|
-
//
|
|
650
|
-
// {
|
|
651
|
-
// "type": "sell",
|
|
652
|
-
// "date": "1638401878",
|
|
653
|
-
// "amount": "0.401000",
|
|
654
|
-
// "price": "249",
|
|
655
|
-
// "tid": "11922"
|
|
656
|
-
// }
|
|
657
|
-
//
|
|
658
|
-
const timestamp = this.safeTimestamp(trade, 'date');
|
|
659
|
-
const id = this.safeString(trade, 'tid');
|
|
660
|
-
const type = undefined;
|
|
661
|
-
const side = this.safeString(trade, 'type');
|
|
662
|
-
const priceString = this.safeString(trade, 'price');
|
|
663
|
-
const amountString = this.safeString(trade, 'amount');
|
|
664
|
-
market = this.safeMarket(undefined, market);
|
|
665
|
-
return this.safeTrade({
|
|
666
|
-
'info': trade,
|
|
667
|
-
'id': id,
|
|
668
|
-
'timestamp': timestamp,
|
|
669
|
-
'datetime': this.iso8601(timestamp),
|
|
670
|
-
'symbol': market['symbol'],
|
|
671
|
-
'type': type,
|
|
672
|
-
'side': side,
|
|
673
|
-
'order': undefined,
|
|
674
|
-
'takerOrMaker': undefined,
|
|
675
|
-
'price': priceString,
|
|
676
|
-
'amount': amountString,
|
|
677
|
-
'cost': undefined,
|
|
678
|
-
'fee': undefined,
|
|
679
|
-
}, market);
|
|
680
|
-
}
|
|
681
|
-
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
682
|
-
/**
|
|
683
|
-
* @method
|
|
684
|
-
* @name cex#fetchTrades
|
|
685
|
-
* @see https://docs.cex.io/#trade-history
|
|
686
|
-
* @description get the list of most recent trades for a particular symbol
|
|
687
|
-
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
688
|
-
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
689
|
-
* @param {int} [limit] the maximum amount of trades to fetch
|
|
690
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
691
|
-
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
692
|
-
*/
|
|
693
|
-
await this.loadMarkets();
|
|
694
|
-
const market = this.market(symbol);
|
|
695
|
-
const request = {
|
|
696
|
-
'pair': market['id'],
|
|
697
|
-
};
|
|
698
|
-
const response = await this.publicGetTradeHistoryPair(this.extend(request, params));
|
|
699
|
-
return this.parseTrades(response, market, since, limit);
|
|
700
|
-
}
|
|
701
|
-
async fetchTradingFees(params = {}) {
|
|
702
|
-
/**
|
|
703
|
-
* @method
|
|
704
|
-
* @name cex#fetchTradingFees
|
|
705
|
-
* @see https://docs.cex.io/#get-my-fee
|
|
706
|
-
* @description fetch the trading fees for multiple markets
|
|
707
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
708
|
-
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
|
|
709
|
-
*/
|
|
710
|
-
await this.loadMarkets();
|
|
711
|
-
const response = await this.privatePostGetMyfee(params);
|
|
712
|
-
//
|
|
713
|
-
// {
|
|
714
|
-
// "e": "get_myfee",
|
|
715
|
-
// "ok": "ok",
|
|
716
|
-
// "data": {
|
|
717
|
-
// 'BTC:USD': { buy: '0.25', sell: '0.25', buyMaker: '0.15', sellMaker: "0.15" },
|
|
718
|
-
// 'ETH:USD': { buy: '0.25', sell: '0.25', buyMaker: '0.15', sellMaker: "0.15" },
|
|
719
|
-
// ..
|
|
720
|
-
// }
|
|
721
|
-
// }
|
|
722
|
-
//
|
|
723
|
-
const data = this.safeValue(response, 'data', {});
|
|
724
|
-
const result = {};
|
|
725
|
-
for (let i = 0; i < this.symbols.length; i++) {
|
|
726
|
-
const symbol = this.symbols[i];
|
|
727
|
-
const market = this.market(symbol);
|
|
728
|
-
const fee = this.safeValue(data, market['id'], {});
|
|
729
|
-
const makerString = this.safeString(fee, 'buyMaker');
|
|
730
|
-
const takerString = this.safeString(fee, 'buy');
|
|
731
|
-
const maker = this.parseNumber(Precise["default"].stringDiv(makerString, '100'));
|
|
732
|
-
const taker = this.parseNumber(Precise["default"].stringDiv(takerString, '100'));
|
|
733
|
-
result[symbol] = {
|
|
734
|
-
'info': fee,
|
|
735
|
-
'symbol': symbol,
|
|
736
|
-
'maker': maker,
|
|
737
|
-
'taker': taker,
|
|
738
|
-
'percentage': true,
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
return result;
|
|
742
|
-
}
|
|
743
|
-
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
744
|
-
/**
|
|
745
|
-
* @method
|
|
746
|
-
* @name cex#createOrder
|
|
747
|
-
* @see https://docs.cex.io/#place-order
|
|
748
|
-
* @description create a trade order
|
|
749
|
-
* @see https://cex.io/rest-api#place-order
|
|
750
|
-
* @param {string} symbol unified symbol of the market to create an order in
|
|
751
|
-
* @param {string} type 'market' or 'limit'
|
|
752
|
-
* @param {string} side 'buy' or 'sell'
|
|
753
|
-
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
754
|
-
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
755
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
756
|
-
* @param {float} [params.cost] the quote quantity that can be used as an alternative for the amount for market buy orders
|
|
757
|
-
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
758
|
-
*/
|
|
759
|
-
await this.loadMarkets();
|
|
760
|
-
const market = this.market(symbol);
|
|
761
|
-
const request = {
|
|
762
|
-
'pair': market['id'],
|
|
763
|
-
'type': side,
|
|
764
|
-
};
|
|
765
|
-
// for market buy it requires the amount of quote currency to spend
|
|
766
|
-
if ((type === 'market') && (side === 'buy')) {
|
|
767
|
-
let quoteAmount = undefined;
|
|
768
|
-
let createMarketBuyOrderRequiresPrice = true;
|
|
769
|
-
[createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
|
|
770
|
-
const cost = this.safeString(params, 'cost');
|
|
771
|
-
params = this.omit(params, 'cost');
|
|
772
|
-
if (cost !== undefined) {
|
|
773
|
-
quoteAmount = this.costToPrecision(symbol, cost);
|
|
774
|
-
}
|
|
775
|
-
else if (createMarketBuyOrderRequiresPrice) {
|
|
776
|
-
if (price === undefined) {
|
|
777
|
-
throw new errors.InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend in the amount argument');
|
|
778
|
-
}
|
|
779
|
-
else {
|
|
780
|
-
const amountString = this.numberToString(amount);
|
|
781
|
-
const priceString = this.numberToString(price);
|
|
782
|
-
const costRequest = Precise["default"].stringMul(amountString, priceString);
|
|
783
|
-
quoteAmount = this.costToPrecision(symbol, costRequest);
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
else {
|
|
787
|
-
quoteAmount = this.costToPrecision(symbol, amount);
|
|
788
|
-
}
|
|
789
|
-
request['amount'] = quoteAmount;
|
|
790
|
-
}
|
|
791
|
-
else {
|
|
792
|
-
request['amount'] = this.amountToPrecision(symbol, amount);
|
|
793
|
-
}
|
|
794
|
-
if (type === 'limit') {
|
|
795
|
-
request['price'] = this.numberToString(price);
|
|
796
|
-
}
|
|
797
|
-
else {
|
|
798
|
-
request['order_type'] = type;
|
|
799
|
-
}
|
|
800
|
-
const response = await this.privatePostPlaceOrderPair(this.extend(request, params));
|
|
801
|
-
//
|
|
802
|
-
// {
|
|
803
|
-
// "id": "12978363524",
|
|
804
|
-
// "time": 1586610022259,
|
|
805
|
-
// "type": "buy",
|
|
806
|
-
// "price": "0.033934",
|
|
807
|
-
// "amount": "0.10722802",
|
|
808
|
-
// "pending": "0.10722802",
|
|
809
|
-
// "complete": false
|
|
810
|
-
// }
|
|
811
|
-
//
|
|
812
|
-
const placedAmount = this.safeString(response, 'amount');
|
|
813
|
-
const remaining = this.safeString(response, 'pending');
|
|
814
|
-
const timestamp = this.safeValue(response, 'time');
|
|
815
|
-
const complete = this.safeValue(response, 'complete');
|
|
816
|
-
const status = complete ? 'closed' : 'open';
|
|
817
|
-
let filled = undefined;
|
|
818
|
-
if ((placedAmount !== undefined) && (remaining !== undefined)) {
|
|
819
|
-
filled = Precise["default"].stringMax(Precise["default"].stringSub(placedAmount, remaining), '0');
|
|
820
|
-
}
|
|
821
|
-
return this.safeOrder({
|
|
822
|
-
'id': this.safeString(response, 'id'),
|
|
823
|
-
'info': response,
|
|
824
|
-
'clientOrderId': undefined,
|
|
825
|
-
'timestamp': timestamp,
|
|
826
|
-
'datetime': this.iso8601(timestamp),
|
|
827
|
-
'lastTradeTimestamp': undefined,
|
|
828
|
-
'type': type,
|
|
829
|
-
'side': this.safeString(response, 'type'),
|
|
830
|
-
'symbol': market['symbol'],
|
|
831
|
-
'status': status,
|
|
832
|
-
'price': this.safeString(response, 'price'),
|
|
833
|
-
'amount': placedAmount,
|
|
834
|
-
'cost': undefined,
|
|
835
|
-
'average': undefined,
|
|
836
|
-
'remaining': remaining,
|
|
837
|
-
'filled': filled,
|
|
838
|
-
'fee': undefined,
|
|
839
|
-
'trades': undefined,
|
|
840
|
-
});
|
|
841
|
-
}
|
|
842
|
-
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
843
|
-
/**
|
|
844
|
-
* @method
|
|
845
|
-
* @name cex#cancelOrder
|
|
846
|
-
* @see https://docs.cex.io/#cancel-order
|
|
847
|
-
* @description cancels an open order
|
|
848
|
-
* @param {string} id order id
|
|
849
|
-
* @param {string} symbol not used by cex cancelOrder ()
|
|
850
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
851
|
-
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
852
|
-
*/
|
|
853
|
-
await this.loadMarkets();
|
|
854
|
-
const request = {
|
|
855
|
-
'id': id,
|
|
856
|
-
};
|
|
857
|
-
const response = await this.privatePostCancelOrder(this.extend(request, params));
|
|
858
|
-
// 'true'
|
|
859
|
-
return this.extend(this.parseOrder({}), { 'info': response, 'type': undefined, 'id': id, 'status': 'canceled' });
|
|
860
|
-
}
|
|
861
|
-
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
862
|
-
/**
|
|
863
|
-
* @method
|
|
864
|
-
* @name cex#cancelAllOrders
|
|
865
|
-
* @see https://docs.cex.io/#cancel-all-orders-for-given-pair
|
|
866
|
-
* @description cancel all open orders in a market
|
|
867
|
-
* @param {string} symbol unified market symbol of the market to cancel orders in
|
|
868
|
-
* @param {object} [params] extra parameters specific to the cex api endpoint
|
|
869
|
-
* @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
|
|
870
|
-
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
871
|
-
*/
|
|
872
|
-
if (symbol === undefined) {
|
|
873
|
-
throw new errors.ArgumentsRequired(this.id + ' cancelAllOrders requires a symbol.');
|
|
874
|
-
}
|
|
875
|
-
await this.loadMarkets();
|
|
876
|
-
const market = this.market(symbol);
|
|
877
|
-
const request = {
|
|
878
|
-
'pair': market['id'],
|
|
879
|
-
};
|
|
880
|
-
const orders = await this.privatePostCancelOrdersPair(this.extend(request, params));
|
|
881
|
-
//
|
|
882
|
-
// {
|
|
883
|
-
// "e":"cancel_orders",
|
|
884
|
-
// "ok":"ok",
|
|
885
|
-
// "data":[
|
|
886
|
-
// ]
|
|
887
|
-
// }
|
|
888
|
-
//
|
|
889
|
-
return orders;
|
|
890
|
-
}
|
|
891
|
-
parseOrder(order, market = undefined) {
|
|
892
|
-
// Depending on the call, 'time' can be a unix int, unix string or ISO string
|
|
893
|
-
// Yes, really
|
|
894
|
-
let timestamp = this.safeValue(order, 'time');
|
|
895
|
-
if (typeof timestamp === 'string' && timestamp.indexOf('T') >= 0) {
|
|
896
|
-
// ISO8601 string
|
|
897
|
-
timestamp = this.parse8601(timestamp);
|
|
898
|
-
}
|
|
899
|
-
else if (timestamp !== undefined) {
|
|
900
|
-
// either integer or string integer
|
|
901
|
-
timestamp = parseInt(timestamp);
|
|
902
|
-
}
|
|
903
|
-
let symbol = undefined;
|
|
904
|
-
const baseId = this.safeString(order, 'symbol1');
|
|
905
|
-
const quoteId = this.safeString(order, 'symbol2');
|
|
906
|
-
if (market === undefined && baseId !== undefined && quoteId !== undefined) {
|
|
907
|
-
const base = this.safeCurrencyCode(baseId);
|
|
908
|
-
const quote = this.safeCurrencyCode(quoteId);
|
|
909
|
-
if ((base !== undefined) && (quote !== undefined)) {
|
|
910
|
-
symbol = base + '/' + quote;
|
|
911
|
-
}
|
|
912
|
-
if (symbol in this.markets) {
|
|
913
|
-
market = this.market(symbol);
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
const status = this.parseOrderStatus(this.safeString(order, 'status'));
|
|
917
|
-
const price = this.safeString(order, 'price');
|
|
918
|
-
let amount = this.omitZero(this.safeString(order, 'amount'));
|
|
919
|
-
// sell orders can have a negative amount
|
|
920
|
-
// https://github.com/ccxt/ccxt/issues/5338
|
|
921
|
-
if (amount !== undefined) {
|
|
922
|
-
amount = Precise["default"].stringAbs(amount);
|
|
923
|
-
}
|
|
924
|
-
else if (market !== undefined) {
|
|
925
|
-
const amountKey = 'a:' + market['base'] + 'cds:';
|
|
926
|
-
amount = Precise["default"].stringAbs(this.safeString(order, amountKey));
|
|
927
|
-
}
|
|
928
|
-
const remaining = this.safeString2(order, 'pending', 'remains');
|
|
929
|
-
const filled = Precise["default"].stringSub(amount, remaining);
|
|
930
|
-
let fee = undefined;
|
|
931
|
-
let cost = undefined;
|
|
932
|
-
if (market !== undefined) {
|
|
933
|
-
symbol = market['symbol'];
|
|
934
|
-
const taCost = this.safeString(order, 'ta:' + market['quote']);
|
|
935
|
-
const ttaCost = this.safeString(order, 'tta:' + market['quote']);
|
|
936
|
-
cost = Precise["default"].stringAdd(taCost, ttaCost);
|
|
937
|
-
const baseFee = 'fa:' + market['base'];
|
|
938
|
-
const baseTakerFee = 'tfa:' + market['base'];
|
|
939
|
-
const quoteFee = 'fa:' + market['quote'];
|
|
940
|
-
const quoteTakerFee = 'tfa:' + market['quote'];
|
|
941
|
-
let feeRate = this.safeString(order, 'tradingFeeMaker');
|
|
942
|
-
if (!feeRate) {
|
|
943
|
-
feeRate = this.safeString(order, 'tradingFeeTaker', feeRate);
|
|
944
|
-
}
|
|
945
|
-
if (feeRate) {
|
|
946
|
-
feeRate = Precise["default"].stringDiv(feeRate, '100'); // convert to mathematically-correct percentage coefficients: 1.0 = 100%
|
|
947
|
-
}
|
|
948
|
-
if ((baseFee in order) || (baseTakerFee in order)) {
|
|
949
|
-
const baseFeeCost = this.safeNumber2(order, baseFee, baseTakerFee);
|
|
950
|
-
fee = {
|
|
951
|
-
'currency': market['base'],
|
|
952
|
-
'rate': this.parseNumber(feeRate),
|
|
953
|
-
'cost': baseFeeCost,
|
|
954
|
-
};
|
|
955
|
-
}
|
|
956
|
-
else if ((quoteFee in order) || (quoteTakerFee in order)) {
|
|
957
|
-
const quoteFeeCost = this.safeNumber2(order, quoteFee, quoteTakerFee);
|
|
958
|
-
fee = {
|
|
959
|
-
'currency': market['quote'],
|
|
960
|
-
'rate': this.parseNumber(feeRate),
|
|
961
|
-
'cost': quoteFeeCost,
|
|
962
|
-
};
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
if (!cost) {
|
|
966
|
-
cost = Precise["default"].stringMul(price, filled);
|
|
967
|
-
}
|
|
968
|
-
const side = this.safeString(order, 'type');
|
|
969
|
-
let trades = undefined;
|
|
970
|
-
const orderId = this.safeString(order, 'id');
|
|
971
|
-
if ('vtx' in order) {
|
|
972
|
-
trades = [];
|
|
973
|
-
for (let i = 0; i < order['vtx'].length; i++) {
|
|
974
|
-
const item = order['vtx'][i];
|
|
975
|
-
const tradeSide = this.safeString(item, 'type');
|
|
976
|
-
if (tradeSide === 'cancel') {
|
|
977
|
-
// looks like this might represent the cancelled part of an order
|
|
978
|
-
// { "id": "4426729543",
|
|
979
|
-
// "type": "cancel",
|
|
980
|
-
// "time": "2017-09-22T00:24:30.476Z",
|
|
981
|
-
// "user": "up106404164",
|
|
982
|
-
// "c": "user:up106404164:a:BCH",
|
|
983
|
-
// "d": "order:4426728375:a:BCH",
|
|
984
|
-
// "a": "0.09935956",
|
|
985
|
-
// "amount": "0.09935956",
|
|
986
|
-
// "balance": "0.42580261",
|
|
987
|
-
// "symbol": "BCH",
|
|
988
|
-
// "order": "4426728375",
|
|
989
|
-
// "buy": null,
|
|
990
|
-
// "sell": null,
|
|
991
|
-
// "pair": null,
|
|
992
|
-
// "pos": null,
|
|
993
|
-
// "cs": "0.42580261",
|
|
994
|
-
// "ds": 0 }
|
|
995
|
-
continue;
|
|
996
|
-
}
|
|
997
|
-
const tradePrice = this.safeString(item, 'price');
|
|
998
|
-
if (tradePrice === undefined) {
|
|
999
|
-
// this represents the order
|
|
1000
|
-
// {
|
|
1001
|
-
// "a": "0.47000000",
|
|
1002
|
-
// "c": "user:up106404164:a:EUR",
|
|
1003
|
-
// "d": "order:6065499239:a:EUR",
|
|
1004
|
-
// "cs": "1432.93",
|
|
1005
|
-
// "ds": "476.72",
|
|
1006
|
-
// "id": "6065499249",
|
|
1007
|
-
// "buy": null,
|
|
1008
|
-
// "pos": null,
|
|
1009
|
-
// "pair": null,
|
|
1010
|
-
// "sell": null,
|
|
1011
|
-
// "time": "2018-04-22T13:07:22.152Z",
|
|
1012
|
-
// "type": "buy",
|
|
1013
|
-
// "user": "up106404164",
|
|
1014
|
-
// "order": "6065499239",
|
|
1015
|
-
// "amount": "-715.97000000",
|
|
1016
|
-
// "symbol": "EUR",
|
|
1017
|
-
// "balance": "1432.93000000" }
|
|
1018
|
-
continue;
|
|
1019
|
-
}
|
|
1020
|
-
// todo: deal with these
|
|
1021
|
-
if (tradeSide === 'costsNothing') {
|
|
1022
|
-
continue;
|
|
1023
|
-
}
|
|
1024
|
-
// --
|
|
1025
|
-
// if (side !== tradeSide)
|
|
1026
|
-
// throw new Error (JSON.stringify (order, null, 2));
|
|
1027
|
-
// if (orderId !== item['order'])
|
|
1028
|
-
// throw new Error (JSON.stringify (order, null, 2));
|
|
1029
|
-
// --
|
|
1030
|
-
// partial buy trade
|
|
1031
|
-
// {
|
|
1032
|
-
// "a": "0.01589885",
|
|
1033
|
-
// "c": "user:up106404164:a:BTC",
|
|
1034
|
-
// "d": "order:6065499239:a:BTC",
|
|
1035
|
-
// "cs": "0.36300000",
|
|
1036
|
-
// "ds": 0,
|
|
1037
|
-
// "id": "6067991213",
|
|
1038
|
-
// "buy": "6065499239",
|
|
1039
|
-
// "pos": null,
|
|
1040
|
-
// "pair": null,
|
|
1041
|
-
// "sell": "6067991206",
|
|
1042
|
-
// "time": "2018-04-22T23:09:11.773Z",
|
|
1043
|
-
// "type": "buy",
|
|
1044
|
-
// "user": "up106404164",
|
|
1045
|
-
// "order": "6065499239",
|
|
1046
|
-
// "price": 7146.5,
|
|
1047
|
-
// "amount": "0.01589885",
|
|
1048
|
-
// "symbol": "BTC",
|
|
1049
|
-
// "balance": "0.36300000",
|
|
1050
|
-
// "symbol2": "EUR",
|
|
1051
|
-
// "fee_amount": "0.19" }
|
|
1052
|
-
// --
|
|
1053
|
-
// trade with zero amount, but non-zero fee
|
|
1054
|
-
// {
|
|
1055
|
-
// "a": "0.00000000",
|
|
1056
|
-
// "c": "user:up106404164:a:EUR",
|
|
1057
|
-
// "d": "order:5840654423:a:EUR",
|
|
1058
|
-
// "cs": 559744,
|
|
1059
|
-
// "ds": 0,
|
|
1060
|
-
// "id": "5840654429",
|
|
1061
|
-
// "buy": "5807238573",
|
|
1062
|
-
// "pos": null,
|
|
1063
|
-
// "pair": null,
|
|
1064
|
-
// "sell": "5840654423",
|
|
1065
|
-
// "time": "2018-03-15T03:20:14.010Z",
|
|
1066
|
-
// "type": "sell",
|
|
1067
|
-
// "user": "up106404164",
|
|
1068
|
-
// "order": "5840654423",
|
|
1069
|
-
// "price": 730,
|
|
1070
|
-
// "amount": "0.00000000",
|
|
1071
|
-
// "symbol": "EUR",
|
|
1072
|
-
// "balance": "5597.44000000",
|
|
1073
|
-
// "symbol2": "BCH",
|
|
1074
|
-
// "fee_amount": "0.01" }
|
|
1075
|
-
// --
|
|
1076
|
-
// trade which should have an amount of exactly 0.002BTC
|
|
1077
|
-
// {
|
|
1078
|
-
// "a": "16.70000000",
|
|
1079
|
-
// "c": "user:up106404164:a:GBP",
|
|
1080
|
-
// "d": "order:9927386681:a:GBP",
|
|
1081
|
-
// "cs": "86.90",
|
|
1082
|
-
// "ds": 0,
|
|
1083
|
-
// "id": "9927401610",
|
|
1084
|
-
// "buy": "9927401601",
|
|
1085
|
-
// "pos": null,
|
|
1086
|
-
// "pair": null,
|
|
1087
|
-
// "sell": "9927386681",
|
|
1088
|
-
// "time": "2019-08-21T15:25:37.777Z",
|
|
1089
|
-
// "type": "sell",
|
|
1090
|
-
// "user": "up106404164",
|
|
1091
|
-
// "order": "9927386681",
|
|
1092
|
-
// "price": 8365,
|
|
1093
|
-
// "amount": "16.70000000",
|
|
1094
|
-
// "office": "UK",
|
|
1095
|
-
// "symbol": "GBP",
|
|
1096
|
-
// "balance": "86.90000000",
|
|
1097
|
-
// "symbol2": "BTC",
|
|
1098
|
-
// "fee_amount": "0.03"
|
|
1099
|
-
// }
|
|
1100
|
-
const tradeTimestamp = this.parse8601(this.safeString(item, 'time'));
|
|
1101
|
-
const tradeAmount = this.safeString(item, 'amount');
|
|
1102
|
-
const feeCost = this.safeString(item, 'fee_amount');
|
|
1103
|
-
let absTradeAmount = Precise["default"].stringAbs(tradeAmount);
|
|
1104
|
-
let tradeCost = undefined;
|
|
1105
|
-
if (tradeSide === 'sell') {
|
|
1106
|
-
tradeCost = absTradeAmount;
|
|
1107
|
-
absTradeAmount = Precise["default"].stringDiv(Precise["default"].stringAdd(feeCost, tradeCost), tradePrice);
|
|
1108
|
-
}
|
|
1109
|
-
else {
|
|
1110
|
-
tradeCost = Precise["default"].stringMul(absTradeAmount, tradePrice);
|
|
1111
|
-
}
|
|
1112
|
-
trades.push({
|
|
1113
|
-
'id': this.safeString(item, 'id'),
|
|
1114
|
-
'timestamp': tradeTimestamp,
|
|
1115
|
-
'datetime': this.iso8601(tradeTimestamp),
|
|
1116
|
-
'order': orderId,
|
|
1117
|
-
'symbol': symbol,
|
|
1118
|
-
'price': this.parseNumber(tradePrice),
|
|
1119
|
-
'amount': this.parseNumber(absTradeAmount),
|
|
1120
|
-
'cost': this.parseNumber(tradeCost),
|
|
1121
|
-
'side': tradeSide,
|
|
1122
|
-
'fee': {
|
|
1123
|
-
'cost': this.parseNumber(feeCost),
|
|
1124
|
-
'currency': market['quote'],
|
|
1125
|
-
},
|
|
1126
|
-
'info': item,
|
|
1127
|
-
'type': undefined,
|
|
1128
|
-
'takerOrMaker': undefined,
|
|
1129
|
-
});
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
return this.safeOrder({
|
|
1133
|
-
'info': order,
|
|
1134
|
-
'id': orderId,
|
|
1135
|
-
'clientOrderId': undefined,
|
|
1136
|
-
'datetime': this.iso8601(timestamp),
|
|
1137
|
-
'timestamp': timestamp,
|
|
1138
|
-
'lastTradeTimestamp': undefined,
|
|
1139
|
-
'status': status,
|
|
1140
|
-
'symbol': symbol,
|
|
1141
|
-
'type': (price === undefined) ? 'market' : 'limit',
|
|
1142
|
-
'timeInForce': undefined,
|
|
1143
|
-
'postOnly': undefined,
|
|
1144
|
-
'side': side,
|
|
1145
|
-
'price': price,
|
|
1146
|
-
'stopPrice': undefined,
|
|
1147
|
-
'triggerPrice': undefined,
|
|
1148
|
-
'cost': cost,
|
|
1149
|
-
'amount': amount,
|
|
1150
|
-
'filled': filled,
|
|
1151
|
-
'remaining': remaining,
|
|
1152
|
-
'trades': trades,
|
|
1153
|
-
'fee': fee,
|
|
1154
|
-
'average': undefined,
|
|
1155
|
-
});
|
|
1156
|
-
}
|
|
1157
|
-
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1158
|
-
/**
|
|
1159
|
-
* @method
|
|
1160
|
-
* @name cex#fetchOpenOrders
|
|
1161
|
-
* @see https://docs.cex.io/#open-orders
|
|
1162
|
-
* @description fetch all unfilled currently open orders
|
|
1163
|
-
* @param {string} symbol unified market symbol
|
|
1164
|
-
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
1165
|
-
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
1166
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1167
|
-
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1168
|
-
*/
|
|
1169
|
-
await this.loadMarkets();
|
|
1170
|
-
const request = {};
|
|
1171
|
-
let market = undefined;
|
|
1172
|
-
let orders = undefined;
|
|
1173
|
-
if (symbol !== undefined) {
|
|
1174
|
-
market = this.market(symbol);
|
|
1175
|
-
request['pair'] = market['id'];
|
|
1176
|
-
orders = await this.privatePostOpenOrdersPair(this.extend(request, params));
|
|
1177
|
-
}
|
|
1178
|
-
else {
|
|
1179
|
-
orders = await this.privatePostOpenOrders(this.extend(request, params));
|
|
1180
|
-
}
|
|
1181
|
-
for (let i = 0; i < orders.length; i++) {
|
|
1182
|
-
orders[i] = this.extend(orders[i], { 'status': 'open' });
|
|
1183
|
-
}
|
|
1184
|
-
return this.parseOrders(orders, market, since, limit);
|
|
1185
|
-
}
|
|
1186
|
-
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1187
|
-
/**
|
|
1188
|
-
* @method
|
|
1189
|
-
* @name cex#fetchClosedOrders
|
|
1190
|
-
* @see https://docs.cex.io/#archived-orders
|
|
1191
|
-
* @description fetches information on multiple closed orders made by the user
|
|
1192
|
-
* @param {string} symbol unified market symbol of the market orders were made in
|
|
1193
|
-
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
1194
|
-
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
1195
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1196
|
-
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1197
|
-
*/
|
|
1198
|
-
if (symbol === undefined) {
|
|
1199
|
-
throw new errors.ArgumentsRequired(this.id + ' fetchClosedOrders() requires a symbol argument');
|
|
1200
|
-
}
|
|
1201
|
-
await this.loadMarkets();
|
|
1202
|
-
const market = this.market(symbol);
|
|
1203
|
-
const request = { 'pair': market['id'] };
|
|
1204
|
-
const response = await this.privatePostArchivedOrdersPair(this.extend(request, params));
|
|
1205
|
-
return this.parseOrders(response, market, since, limit);
|
|
1206
|
-
}
|
|
1207
|
-
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
1208
|
-
/**
|
|
1209
|
-
* @method
|
|
1210
|
-
* @name cex#fetchOrder
|
|
1211
|
-
* @see https://docs.cex.io/?python#get-order-details
|
|
1212
|
-
* @description fetches information on an order made by the user
|
|
1213
|
-
* @param {string} symbol not used by cex fetchOrder
|
|
1214
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1215
|
-
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1216
|
-
*/
|
|
1217
|
-
await this.loadMarkets();
|
|
1218
|
-
const request = {
|
|
1219
|
-
'id': id.toString(),
|
|
1220
|
-
};
|
|
1221
|
-
const response = await this.privatePostGetOrderTx(this.extend(request, params));
|
|
1222
|
-
const data = this.safeValue(response, 'data', {});
|
|
1223
|
-
//
|
|
1224
|
-
// {
|
|
1225
|
-
// "id": "5442731603",
|
|
1226
|
-
// "type": "sell",
|
|
1227
|
-
// "time": 1516132358071,
|
|
1228
|
-
// "lastTxTime": 1516132378452,
|
|
1229
|
-
// "lastTx": "5442734452",
|
|
1230
|
-
// "pos": null,
|
|
1231
|
-
// "user": "up106404164",
|
|
1232
|
-
// "status": "d",
|
|
1233
|
-
// "symbol1": "ETH",
|
|
1234
|
-
// "symbol2": "EUR",
|
|
1235
|
-
// "amount": "0.50000000",
|
|
1236
|
-
// "kind": "api",
|
|
1237
|
-
// "price": "923.3386",
|
|
1238
|
-
// "tfacf": "1",
|
|
1239
|
-
// "fa:EUR": "0.55",
|
|
1240
|
-
// "ta:EUR": "369.77",
|
|
1241
|
-
// "remains": "0.00000000",
|
|
1242
|
-
// "tfa:EUR": "0.22",
|
|
1243
|
-
// "tta:EUR": "91.95",
|
|
1244
|
-
// "a:ETH:cds": "0.50000000",
|
|
1245
|
-
// "a:EUR:cds": "461.72",
|
|
1246
|
-
// "f:EUR:cds": "0.77",
|
|
1247
|
-
// "tradingFeeMaker": "0.15",
|
|
1248
|
-
// "tradingFeeTaker": "0.23",
|
|
1249
|
-
// "tradingFeeStrategy": "userVolumeAmount",
|
|
1250
|
-
// "tradingFeeUserVolumeAmount": "2896912572",
|
|
1251
|
-
// "orderId": "5442731603",
|
|
1252
|
-
// "next": false,
|
|
1253
|
-
// "vtx": [
|
|
1254
|
-
// {
|
|
1255
|
-
// "id": "5442734452",
|
|
1256
|
-
// "type": "sell",
|
|
1257
|
-
// "time": "2018-01-16T19:52:58.452Z",
|
|
1258
|
-
// "user": "up106404164",
|
|
1259
|
-
// "c": "user:up106404164:a:EUR",
|
|
1260
|
-
// "d": "order:5442731603:a:EUR",
|
|
1261
|
-
// "a": "104.53000000",
|
|
1262
|
-
// "amount": "104.53000000",
|
|
1263
|
-
// "balance": "932.71000000",
|
|
1264
|
-
// "symbol": "EUR",
|
|
1265
|
-
// "order": "5442731603",
|
|
1266
|
-
// "buy": "5442734443",
|
|
1267
|
-
// "sell": "5442731603",
|
|
1268
|
-
// "pair": null,
|
|
1269
|
-
// "pos": null,
|
|
1270
|
-
// "office": null,
|
|
1271
|
-
// "cs": "932.71",
|
|
1272
|
-
// "ds": 0,
|
|
1273
|
-
// "price": 923.3386,
|
|
1274
|
-
// "symbol2": "ETH",
|
|
1275
|
-
// "fee_amount": "0.16"
|
|
1276
|
-
// },
|
|
1277
|
-
// {
|
|
1278
|
-
// "id": "5442731609",
|
|
1279
|
-
// "type": "sell",
|
|
1280
|
-
// "time": "2018-01-16T19:52:38.071Z",
|
|
1281
|
-
// "user": "up106404164",
|
|
1282
|
-
// "c": "user:up106404164:a:EUR",
|
|
1283
|
-
// "d": "order:5442731603:a:EUR",
|
|
1284
|
-
// "a": "91.73000000",
|
|
1285
|
-
// "amount": "91.73000000",
|
|
1286
|
-
// "balance": "563.49000000",
|
|
1287
|
-
// "symbol": "EUR",
|
|
1288
|
-
// "order": "5442731603",
|
|
1289
|
-
// "buy": "5442618127",
|
|
1290
|
-
// "sell": "5442731603",
|
|
1291
|
-
// "pair": null,
|
|
1292
|
-
// "pos": null,
|
|
1293
|
-
// "office": null,
|
|
1294
|
-
// "cs": "563.49",
|
|
1295
|
-
// "ds": 0,
|
|
1296
|
-
// "price": 924.0092,
|
|
1297
|
-
// "symbol2": "ETH",
|
|
1298
|
-
// "fee_amount": "0.22"
|
|
1299
|
-
// },
|
|
1300
|
-
// {
|
|
1301
|
-
// "id": "5442731604",
|
|
1302
|
-
// "type": "sell",
|
|
1303
|
-
// "time": "2018-01-16T19:52:38.071Z",
|
|
1304
|
-
// "user": "up106404164",
|
|
1305
|
-
// "c": "order:5442731603:a:ETH",
|
|
1306
|
-
// "d": "user:up106404164:a:ETH",
|
|
1307
|
-
// "a": "0.50000000",
|
|
1308
|
-
// "amount": "-0.50000000",
|
|
1309
|
-
// "balance": "15.80995000",
|
|
1310
|
-
// "symbol": "ETH",
|
|
1311
|
-
// "order": "5442731603",
|
|
1312
|
-
// "buy": null,
|
|
1313
|
-
// "sell": null,
|
|
1314
|
-
// "pair": null,
|
|
1315
|
-
// "pos": null,
|
|
1316
|
-
// "office": null,
|
|
1317
|
-
// "cs": "0.50000000",
|
|
1318
|
-
// "ds": "15.80995000"
|
|
1319
|
-
// }
|
|
1320
|
-
// ]
|
|
1321
|
-
// }
|
|
1322
|
-
//
|
|
1323
|
-
return this.parseOrder(data);
|
|
1324
|
-
}
|
|
1325
|
-
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1326
|
-
/**
|
|
1327
|
-
* @method
|
|
1328
|
-
* @name cex#fetchOrders
|
|
1329
|
-
* @see https://docs.cex.io/#archived-orders
|
|
1330
|
-
* @description fetches information on multiple orders made by the user
|
|
1331
|
-
* @param {string} symbol unified market symbol of the market orders were made in
|
|
1332
|
-
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
1333
|
-
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
1334
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1335
|
-
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1336
|
-
*/
|
|
1337
|
-
await this.loadMarkets();
|
|
1338
|
-
const market = this.market(symbol);
|
|
1339
|
-
const request = {
|
|
1340
|
-
'limit': limit,
|
|
1341
|
-
'pair': market['id'],
|
|
1342
|
-
'dateFrom': since,
|
|
1343
|
-
};
|
|
1344
|
-
const response = await this.privatePostArchivedOrdersPair(this.extend(request, params));
|
|
1345
|
-
const results = [];
|
|
1346
|
-
for (let i = 0; i < response.length; i++) {
|
|
1347
|
-
// cancelled (unfilled):
|
|
1348
|
-
// { "id": "4005785516",
|
|
1349
|
-
// "type": "sell",
|
|
1350
|
-
// "time": "2017-07-18T19:08:34.223Z",
|
|
1351
|
-
// "lastTxTime": "2017-07-18T19:08:34.396Z",
|
|
1352
|
-
// "lastTx": "4005785522",
|
|
1353
|
-
// "pos": null,
|
|
1354
|
-
// "status": "c",
|
|
1355
|
-
// "symbol1": "ETH",
|
|
1356
|
-
// "symbol2": "GBP",
|
|
1357
|
-
// "amount": "0.20000000",
|
|
1358
|
-
// "price": "200.5625",
|
|
1359
|
-
// "remains": "0.20000000",
|
|
1360
|
-
// 'a:ETH:cds': "0.20000000",
|
|
1361
|
-
// "tradingFeeMaker": "0",
|
|
1362
|
-
// "tradingFeeTaker": "0.16",
|
|
1363
|
-
// "tradingFeeUserVolumeAmount": "10155061217",
|
|
1364
|
-
// "orderId": "4005785516" }
|
|
1365
|
-
// --
|
|
1366
|
-
// cancelled (partially filled buy):
|
|
1367
|
-
// { "id": "4084911657",
|
|
1368
|
-
// "type": "buy",
|
|
1369
|
-
// "time": "2017-08-05T03:18:39.596Z",
|
|
1370
|
-
// "lastTxTime": "2019-03-19T17:37:46.404Z",
|
|
1371
|
-
// "lastTx": "8459265833",
|
|
1372
|
-
// "pos": null,
|
|
1373
|
-
// "status": "cd",
|
|
1374
|
-
// "symbol1": "BTC",
|
|
1375
|
-
// "symbol2": "GBP",
|
|
1376
|
-
// "amount": "0.05000000",
|
|
1377
|
-
// "price": "2241.4692",
|
|
1378
|
-
// "tfacf": "1",
|
|
1379
|
-
// "remains": "0.03910535",
|
|
1380
|
-
// 'tfa:GBP': "0.04",
|
|
1381
|
-
// 'tta:GBP': "24.39",
|
|
1382
|
-
// 'a:BTC:cds': "0.01089465",
|
|
1383
|
-
// 'a:GBP:cds': "112.26",
|
|
1384
|
-
// 'f:GBP:cds': "0.04",
|
|
1385
|
-
// "tradingFeeMaker": "0",
|
|
1386
|
-
// "tradingFeeTaker": "0.16",
|
|
1387
|
-
// "tradingFeeUserVolumeAmount": "13336396963",
|
|
1388
|
-
// "orderId": "4084911657" }
|
|
1389
|
-
// --
|
|
1390
|
-
// cancelled (partially filled sell):
|
|
1391
|
-
// { "id": "4426728375",
|
|
1392
|
-
// "type": "sell",
|
|
1393
|
-
// "time": "2017-09-22T00:24:20.126Z",
|
|
1394
|
-
// "lastTxTime": "2017-09-22T00:24:30.476Z",
|
|
1395
|
-
// "lastTx": "4426729543",
|
|
1396
|
-
// "pos": null,
|
|
1397
|
-
// "status": "cd",
|
|
1398
|
-
// "symbol1": "BCH",
|
|
1399
|
-
// "symbol2": "BTC",
|
|
1400
|
-
// "amount": "0.10000000",
|
|
1401
|
-
// "price": "0.11757182",
|
|
1402
|
-
// "tfacf": "1",
|
|
1403
|
-
// "remains": "0.09935956",
|
|
1404
|
-
// 'tfa:BTC': "0.00000014",
|
|
1405
|
-
// 'tta:BTC': "0.00007537",
|
|
1406
|
-
// 'a:BCH:cds': "0.10000000",
|
|
1407
|
-
// 'a:BTC:cds': "0.00007537",
|
|
1408
|
-
// 'f:BTC:cds': "0.00000014",
|
|
1409
|
-
// "tradingFeeMaker": "0",
|
|
1410
|
-
// "tradingFeeTaker": "0.18",
|
|
1411
|
-
// "tradingFeeUserVolumeAmount": "3466715450",
|
|
1412
|
-
// "orderId": "4426728375" }
|
|
1413
|
-
// --
|
|
1414
|
-
// filled:
|
|
1415
|
-
// { "id": "5342275378",
|
|
1416
|
-
// "type": "sell",
|
|
1417
|
-
// "time": "2018-01-04T00:28:12.992Z",
|
|
1418
|
-
// "lastTxTime": "2018-01-04T00:28:12.992Z",
|
|
1419
|
-
// "lastTx": "5342275393",
|
|
1420
|
-
// "pos": null,
|
|
1421
|
-
// "status": "d",
|
|
1422
|
-
// "symbol1": "BCH",
|
|
1423
|
-
// "symbol2": "BTC",
|
|
1424
|
-
// "amount": "0.10000000",
|
|
1425
|
-
// "kind": "api",
|
|
1426
|
-
// "price": "0.17",
|
|
1427
|
-
// "remains": "0.00000000",
|
|
1428
|
-
// 'tfa:BTC': "0.00003902",
|
|
1429
|
-
// 'tta:BTC': "0.01699999",
|
|
1430
|
-
// 'a:BCH:cds': "0.10000000",
|
|
1431
|
-
// 'a:BTC:cds': "0.01699999",
|
|
1432
|
-
// 'f:BTC:cds': "0.00003902",
|
|
1433
|
-
// "tradingFeeMaker": "0.15",
|
|
1434
|
-
// "tradingFeeTaker": "0.23",
|
|
1435
|
-
// "tradingFeeUserVolumeAmount": "1525951128",
|
|
1436
|
-
// "orderId": "5342275378" }
|
|
1437
|
-
// --
|
|
1438
|
-
// market order (buy):
|
|
1439
|
-
// { "id": "6281946200",
|
|
1440
|
-
// "pos": null,
|
|
1441
|
-
// "time": "2018-05-23T11:55:43.467Z",
|
|
1442
|
-
// "type": "buy",
|
|
1443
|
-
// "amount": "0.00000000",
|
|
1444
|
-
// "lastTx": "6281946210",
|
|
1445
|
-
// "status": "d",
|
|
1446
|
-
// "amount2": "20.00",
|
|
1447
|
-
// "orderId": "6281946200",
|
|
1448
|
-
// "remains": "0.00000000",
|
|
1449
|
-
// "symbol1": "ETH",
|
|
1450
|
-
// "symbol2": "EUR",
|
|
1451
|
-
// "tfa:EUR": "0.05",
|
|
1452
|
-
// "tta:EUR": "19.94",
|
|
1453
|
-
// "a:ETH:cds": "0.03764100",
|
|
1454
|
-
// "a:EUR:cds": "20.00",
|
|
1455
|
-
// "f:EUR:cds": "0.05",
|
|
1456
|
-
// "lastTxTime": "2018-05-23T11:55:43.467Z",
|
|
1457
|
-
// "tradingFeeTaker": "0.25",
|
|
1458
|
-
// "tradingFeeUserVolumeAmount": "55998097" }
|
|
1459
|
-
// --
|
|
1460
|
-
// market order (sell):
|
|
1461
|
-
// { "id": "6282200948",
|
|
1462
|
-
// "pos": null,
|
|
1463
|
-
// "time": "2018-05-23T12:42:58.315Z",
|
|
1464
|
-
// "type": "sell",
|
|
1465
|
-
// "amount": "-0.05000000",
|
|
1466
|
-
// "lastTx": "6282200958",
|
|
1467
|
-
// "status": "d",
|
|
1468
|
-
// "orderId": "6282200948",
|
|
1469
|
-
// "remains": "0.00000000",
|
|
1470
|
-
// "symbol1": "ETH",
|
|
1471
|
-
// "symbol2": "EUR",
|
|
1472
|
-
// "tfa:EUR": "0.07",
|
|
1473
|
-
// "tta:EUR": "26.49",
|
|
1474
|
-
// "a:ETH:cds": "0.05000000",
|
|
1475
|
-
// "a:EUR:cds": "26.49",
|
|
1476
|
-
// "f:EUR:cds": "0.07",
|
|
1477
|
-
// "lastTxTime": "2018-05-23T12:42:58.315Z",
|
|
1478
|
-
// "tradingFeeTaker": "0.25",
|
|
1479
|
-
// "tradingFeeUserVolumeAmount": "56294576" }
|
|
1480
|
-
const order = response[i];
|
|
1481
|
-
const status = this.parseOrderStatus(this.safeString(order, 'status'));
|
|
1482
|
-
const baseId = this.safeString(order, 'symbol1');
|
|
1483
|
-
const quoteId = this.safeString(order, 'symbol2');
|
|
1484
|
-
const base = this.safeCurrencyCode(baseId);
|
|
1485
|
-
const quote = this.safeCurrencyCode(quoteId);
|
|
1486
|
-
const symbolInner = base + '/' + quote;
|
|
1487
|
-
const side = this.safeString(order, 'type');
|
|
1488
|
-
const baseAmount = this.safeNumber(order, 'a:' + baseId + ':cds');
|
|
1489
|
-
const quoteAmount = this.safeNumber(order, 'a:' + quoteId + ':cds');
|
|
1490
|
-
const fee = this.safeNumber(order, 'f:' + quoteId + ':cds');
|
|
1491
|
-
const amount = this.safeString(order, 'amount');
|
|
1492
|
-
const price = this.safeString(order, 'price');
|
|
1493
|
-
const remaining = this.safeString(order, 'remains');
|
|
1494
|
-
const filled = Precise["default"].stringSub(amount, remaining);
|
|
1495
|
-
let orderAmount = undefined;
|
|
1496
|
-
let cost = undefined;
|
|
1497
|
-
let average = undefined;
|
|
1498
|
-
let type = undefined;
|
|
1499
|
-
if (!price) {
|
|
1500
|
-
type = 'market';
|
|
1501
|
-
orderAmount = baseAmount;
|
|
1502
|
-
cost = quoteAmount;
|
|
1503
|
-
average = Precise["default"].stringDiv(orderAmount, cost);
|
|
1504
|
-
}
|
|
1505
|
-
else {
|
|
1506
|
-
const ta = this.safeString(order, 'ta:' + quoteId, '0');
|
|
1507
|
-
const tta = this.safeString(order, 'tta:' + quoteId, '0');
|
|
1508
|
-
const fa = this.safeString(order, 'fa:' + quoteId, '0');
|
|
1509
|
-
const tfa = this.safeString(order, 'tfa:' + quoteId, '0');
|
|
1510
|
-
if (side === 'sell') {
|
|
1511
|
-
cost = Precise["default"].stringAdd(Precise["default"].stringAdd(ta, tta), Precise["default"].stringAdd(fa, tfa));
|
|
1512
|
-
}
|
|
1513
|
-
else {
|
|
1514
|
-
cost = Precise["default"].stringSub(Precise["default"].stringAdd(ta, tta), Precise["default"].stringAdd(fa, tfa));
|
|
1515
|
-
}
|
|
1516
|
-
type = 'limit';
|
|
1517
|
-
orderAmount = amount;
|
|
1518
|
-
average = Precise["default"].stringDiv(cost, filled);
|
|
1519
|
-
}
|
|
1520
|
-
const time = this.safeString(order, 'time');
|
|
1521
|
-
const lastTxTime = this.safeString(order, 'lastTxTime');
|
|
1522
|
-
const timestamp = this.parse8601(time);
|
|
1523
|
-
const safeOrder = this.safeOrder({
|
|
1524
|
-
'info': order,
|
|
1525
|
-
'id': this.safeString(order, 'id'),
|
|
1526
|
-
'timestamp': timestamp,
|
|
1527
|
-
'datetime': this.iso8601(timestamp),
|
|
1528
|
-
'lastUpdated': this.parse8601(lastTxTime),
|
|
1529
|
-
'status': status,
|
|
1530
|
-
'symbol': symbolInner,
|
|
1531
|
-
'side': side,
|
|
1532
|
-
'price': price,
|
|
1533
|
-
'amount': orderAmount,
|
|
1534
|
-
'average': average,
|
|
1535
|
-
'type': type,
|
|
1536
|
-
'filled': filled,
|
|
1537
|
-
'cost': cost,
|
|
1538
|
-
'remaining': remaining,
|
|
1539
|
-
'fee': {
|
|
1540
|
-
'cost': fee,
|
|
1541
|
-
'currency': quote,
|
|
1542
|
-
},
|
|
1543
|
-
});
|
|
1544
|
-
results.push(safeOrder);
|
|
1545
|
-
}
|
|
1546
|
-
return results;
|
|
1547
|
-
}
|
|
1548
|
-
parseOrderStatus(status) {
|
|
1549
|
-
return this.safeString(this.options['order']['status'], status, status);
|
|
1550
|
-
}
|
|
1551
|
-
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
1552
|
-
/**
|
|
1553
|
-
* @method
|
|
1554
|
-
* @name cex#editOrderWs
|
|
1555
|
-
* @description edit a trade order
|
|
1556
|
-
* @see https://docs.cex.io/#cancel-replace-order
|
|
1557
|
-
* @param {string} id order id
|
|
1558
|
-
* @param {string} symbol unified symbol of the market to create an order in
|
|
1559
|
-
* @param {string} type 'market' or 'limit'
|
|
1560
|
-
* @param {string} side 'buy' or 'sell'
|
|
1561
|
-
* @param {float} amount how much of the currency you want to trade in units of the base currency
|
|
1562
|
-
* @param {float|undefined} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
1563
|
-
* @param {object} [params] extra parameters specific to the cex api endpoint
|
|
1564
|
-
* @returns {object} an [order structure]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure}
|
|
1565
|
-
*/
|
|
1566
|
-
if (amount === undefined) {
|
|
1567
|
-
throw new errors.ArgumentsRequired(this.id + ' editOrder() requires a amount argument');
|
|
1568
|
-
}
|
|
1569
|
-
if (price === undefined) {
|
|
1570
|
-
throw new errors.ArgumentsRequired(this.id + ' editOrder() requires a price argument');
|
|
1571
|
-
}
|
|
1572
|
-
await this.loadMarkets();
|
|
1573
|
-
const market = this.market(symbol);
|
|
1574
|
-
// see: https://cex.io/rest-api#/definitions/CancelReplaceOrderRequest
|
|
1575
|
-
const request = {
|
|
1576
|
-
'pair': market['id'],
|
|
1577
|
-
'type': side,
|
|
1578
|
-
'amount': amount,
|
|
1579
|
-
'price': price,
|
|
1580
|
-
'order_id': id,
|
|
1581
|
-
};
|
|
1582
|
-
const response = await this.privatePostCancelReplaceOrderPair(this.extend(request, params));
|
|
1583
|
-
return this.parseOrder(response, market);
|
|
1584
|
-
}
|
|
1585
|
-
async fetchDepositAddress(code, params = {}) {
|
|
1586
|
-
/**
|
|
1587
|
-
* @method
|
|
1588
|
-
* @name cex#fetchDepositAddress
|
|
1589
|
-
* @see https://docs.cex.io/#get-crypto-address
|
|
1590
|
-
* @description fetch the deposit address for a currency associated with this account
|
|
1591
|
-
* @param {string} code unified currency code
|
|
1592
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1593
|
-
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
1594
|
-
*/
|
|
1595
|
-
await this.loadMarkets();
|
|
1596
|
-
const currency = this.currency(code);
|
|
1597
|
-
const request = {
|
|
1598
|
-
'currency': currency['id'],
|
|
1599
|
-
};
|
|
1600
|
-
const [networkCode, query] = this.handleNetworkCodeAndParams(params);
|
|
1601
|
-
// atm, cex doesn't support network in the request
|
|
1602
|
-
const response = await this.privatePostGetCryptoAddress(this.extend(request, query));
|
|
1603
|
-
//
|
|
1604
|
-
// {
|
|
1605
|
-
// "e": "get_crypto_address",
|
|
1606
|
-
// "ok": "ok",
|
|
1607
|
-
// "data": {
|
|
1608
|
-
// "name": "BTC",
|
|
1609
|
-
// "addresses": [
|
|
1610
|
-
// {
|
|
1611
|
-
// "blockchain": "Bitcoin",
|
|
1612
|
-
// "address": "2BvKwe1UwrdTjq2nzhscFYXwqCjCaaHCeq"
|
|
1613
|
-
//
|
|
1614
|
-
// // for others coins (i.e. XRP, XLM) other keys are present:
|
|
1615
|
-
// // "destination": "rF1sdh25BJX3qFwneeTBwaq3zPEWYcwjp2",
|
|
1616
|
-
// // "destinationTag": "7519113655",
|
|
1617
|
-
// // "memo": "XLM-memo12345",
|
|
1618
|
-
// }
|
|
1619
|
-
// ]
|
|
1620
|
-
// }
|
|
1621
|
-
// }
|
|
1622
|
-
//
|
|
1623
|
-
const data = this.safeValue(response, 'data', {});
|
|
1624
|
-
const addresses = this.safeValue(data, 'addresses', []);
|
|
1625
|
-
const chainsIndexedById = this.indexBy(addresses, 'blockchain');
|
|
1626
|
-
const selectedNetworkId = this.selectNetworkIdFromRawNetworks(code, networkCode, chainsIndexedById);
|
|
1627
|
-
const addressObject = this.safeValue(chainsIndexedById, selectedNetworkId, {});
|
|
1628
|
-
const address = this.safeString2(addressObject, 'address', 'destination');
|
|
1629
|
-
this.checkAddress(address);
|
|
1630
|
-
return {
|
|
1631
|
-
'currency': code,
|
|
1632
|
-
'address': address,
|
|
1633
|
-
'tag': this.safeString2(addressObject, 'destinationTag', 'memo'),
|
|
1634
|
-
'network': this.networkIdToCode(selectedNetworkId),
|
|
1635
|
-
'info': data,
|
|
1636
|
-
};
|
|
1637
|
-
}
|
|
1638
|
-
nonce() {
|
|
1639
|
-
return this.milliseconds();
|
|
1640
|
-
}
|
|
1641
|
-
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
1642
|
-
let url = this.urls['api']['rest'] + '/' + this.implodeParams(path, params);
|
|
1643
|
-
const query = this.omit(params, this.extractParams(path));
|
|
1644
|
-
if (api === 'public') {
|
|
1645
|
-
if (Object.keys(query).length) {
|
|
1646
|
-
url += '?' + this.urlencode(query);
|
|
1647
|
-
}
|
|
1648
|
-
}
|
|
1649
|
-
else {
|
|
1650
|
-
this.checkRequiredCredentials();
|
|
1651
|
-
const nonce = this.nonce().toString();
|
|
1652
|
-
const auth = nonce + this.uid + this.apiKey;
|
|
1653
|
-
const signature = this.hmac(this.encode(auth), this.encode(this.secret), sha256.sha256);
|
|
1654
|
-
body = this.json(this.extend({
|
|
1655
|
-
'key': this.apiKey,
|
|
1656
|
-
'signature': signature.toUpperCase(),
|
|
1657
|
-
'nonce': nonce,
|
|
1658
|
-
}, query));
|
|
1659
|
-
headers = {
|
|
1660
|
-
'Content-Type': 'application/json',
|
|
1661
|
-
};
|
|
1662
|
-
}
|
|
1663
|
-
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
1664
|
-
}
|
|
1665
|
-
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
1666
|
-
if (Array.isArray(response)) {
|
|
1667
|
-
return response; // public endpoints may return []-arrays
|
|
1668
|
-
}
|
|
1669
|
-
if (body === 'true') {
|
|
1670
|
-
return undefined;
|
|
1671
|
-
}
|
|
1672
|
-
if (response === undefined) {
|
|
1673
|
-
throw new errors.NullResponse(this.id + ' returned ' + this.json(response));
|
|
1674
|
-
}
|
|
1675
|
-
if ('e' in response) {
|
|
1676
|
-
if ('ok' in response) {
|
|
1677
|
-
if (response['ok'] === 'ok') {
|
|
1678
|
-
return undefined;
|
|
1679
|
-
}
|
|
1680
|
-
}
|
|
1681
|
-
}
|
|
1682
|
-
if ('error' in response) {
|
|
1683
|
-
const message = this.safeString(response, 'error');
|
|
1684
|
-
const feedback = this.id + ' ' + body;
|
|
1685
|
-
this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
|
|
1686
|
-
this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
|
|
1687
|
-
throw new errors.ExchangeError(feedback);
|
|
1688
|
-
}
|
|
1689
|
-
return undefined;
|
|
1690
|
-
}
|
|
1691
|
-
}
|
|
1692
|
-
|
|
1693
|
-
module.exports = cex;
|