ccxt-look 1.81.50
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/.cache/eslintcache +1 -0
- package/.dockerignore +6 -0
- package/.eslintignore +1 -0
- package/.gitattributes +5 -0
- package/.readthedocs.yaml +16 -0
- package/CONTRIBUTING.md +1049 -0
- package/LICENSE.txt +21 -0
- package/README.md +537 -0
- package/SECURITY.md +5 -0
- package/build/cleanup-old-tags.js +94 -0
- package/build/countries.js +256 -0
- package/build/export-exchanges.js +520 -0
- package/build/fs.js +51 -0
- package/build/transpile.js +1772 -0
- package/build/vss.js +78 -0
- package/ccxt.browser.js +7 -0
- package/ccxt.d.ts +692 -0
- package/ccxt.js +171 -0
- package/cleanup.sh +2 -0
- package/composer-install.sh +20 -0
- package/dist/ccxt.browser.js +208383 -0
- package/gource.sh +3 -0
- package/index.html +7 -0
- package/js/.eslintrc +87 -0
- package/js/aax.js +2686 -0
- package/js/ascendex.js +2584 -0
- package/js/base/.eslintrc.js +43 -0
- package/js/base/Exchange.js +2371 -0
- package/js/base/Precise.js +283 -0
- package/js/base/errorHierarchy.js +47 -0
- package/js/base/errors.js +55 -0
- package/js/base/functions/crypto.js +158 -0
- package/js/base/functions/encode.js +118 -0
- package/js/base/functions/generic.js +270 -0
- package/js/base/functions/misc.js +138 -0
- package/js/base/functions/number.js +329 -0
- package/js/base/functions/platform.js +38 -0
- package/js/base/functions/string.js +21 -0
- package/js/base/functions/throttle.js +79 -0
- package/js/base/functions/time.js +210 -0
- package/js/base/functions/type.js +66 -0
- package/js/base/functions.js +28 -0
- package/js/bequant.js +32 -0
- package/js/bibox.js +1407 -0
- package/js/bigone.js +1366 -0
- package/js/binance.js +5652 -0
- package/js/binancecoinm.js +46 -0
- package/js/binanceus.js +46 -0
- package/js/binanceusdm.js +49 -0
- package/js/bit2c.js +535 -0
- package/js/bitbank.js +842 -0
- package/js/bitbay.js +16 -0
- package/js/bitbns.js +1073 -0
- package/js/bitcoincom.js +15 -0
- package/js/bitfinex.js +1433 -0
- package/js/bitfinex2.js +2025 -0
- package/js/bitflyer.js +840 -0
- package/js/bitforex.js +614 -0
- package/js/bitget.js +2397 -0
- package/js/bithumb.js +980 -0
- package/js/bitmart.js +2516 -0
- package/js/bitmex.js +1809 -0
- package/js/bitopro.js +1443 -0
- package/js/bitpanda.js +1782 -0
- package/js/bitrue.js +1747 -0
- package/js/bitso.js +1062 -0
- package/js/bitstamp.js +1757 -0
- package/js/bitstamp1.js +343 -0
- package/js/bittrex.js +1876 -0
- package/js/bitvavo.js +1579 -0
- package/js/bkex.js +1233 -0
- package/js/bl3p.js +346 -0
- package/js/blockchaincom.js +969 -0
- package/js/btcalpha.js +680 -0
- package/js/btcbox.js +477 -0
- package/js/btcmarkets.js +1022 -0
- package/js/btctradeua.js +466 -0
- package/js/btcturk.js +734 -0
- package/js/buda.js +946 -0
- package/js/bw.js +1265 -0
- package/js/bybit.js +3372 -0
- package/js/bytetrade.js +1336 -0
- package/js/cdax.js +1646 -0
- package/js/cex.js +1410 -0
- package/js/coinbase.js +1342 -0
- package/js/coinbaseprime.js +31 -0
- package/js/coinbasepro.js +1466 -0
- package/js/coincheck.js +755 -0
- package/js/coinex.js +3400 -0
- package/js/coinfalcon.js +880 -0
- package/js/coinmate.js +794 -0
- package/js/coinone.js +816 -0
- package/js/coinspot.js +345 -0
- package/js/crex24.js +1636 -0
- package/js/cryptocom.js +1832 -0
- package/js/currencycom.js +1748 -0
- package/js/delta.js +1547 -0
- package/js/deribit.js +2148 -0
- package/js/digifinex.js +1585 -0
- package/js/eqonex.js +1660 -0
- package/js/exmo.js +1670 -0
- package/js/fairdesk.js +1231 -0
- package/js/flowbtc.js +35 -0
- package/js/fmfwio.js +34 -0
- package/js/ftx.js +2751 -0
- package/js/ftxus.js +38 -0
- package/js/gateio.js +4174 -0
- package/js/gemini.js +1397 -0
- package/js/hitbtc.js +1343 -0
- package/js/hitbtc3.js +2329 -0
- package/js/hollaex.js +1486 -0
- package/js/huobi.js +5706 -0
- package/js/huobijp.js +1710 -0
- package/js/huobipro.js +18 -0
- package/js/idex.js +1439 -0
- package/js/independentreserve.js +649 -0
- package/js/indodax.js +742 -0
- package/js/itbit.js +722 -0
- package/js/kraken.js +2179 -0
- package/js/kucoin.js +2571 -0
- package/js/kucoinfutures.js +1771 -0
- package/js/kuna.js +809 -0
- package/js/latoken.js +1445 -0
- package/js/lbank.js +760 -0
- package/js/liquid.js +1432 -0
- package/js/luno.js +873 -0
- package/js/lykke.js +1147 -0
- package/js/mercado.js +771 -0
- package/js/mexc.js +3151 -0
- package/js/ndax.js +2233 -0
- package/js/novadax.js +1318 -0
- package/js/oceanex.js +816 -0
- package/js/okcoin.js +3841 -0
- package/js/okex.js +16 -0
- package/js/okex5.js +16 -0
- package/js/okx.js +4795 -0
- package/js/paymium.js +498 -0
- package/js/phemex.js +2957 -0
- package/js/poloniex.js +1674 -0
- package/js/probit.js +1346 -0
- package/js/qtrade.js +1588 -0
- package/js/ripio.js +1061 -0
- package/js/static_dependencies/BN/bn.js +3526 -0
- package/js/static_dependencies/README.md +1 -0
- package/js/static_dependencies/crypto-js/crypto-js.js +5988 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/base.js +375 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/edwards.js +433 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/index.js +8 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/mont.js +180 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/short.js +938 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curves.js +204 -0
- package/js/static_dependencies/elliptic/lib/elliptic/ec/index.js +240 -0
- package/js/static_dependencies/elliptic/lib/elliptic/ec/key.js +119 -0
- package/js/static_dependencies/elliptic/lib/elliptic/ec/signature.js +24 -0
- package/js/static_dependencies/elliptic/lib/elliptic/eddsa/index.js +145 -0
- package/js/static_dependencies/elliptic/lib/elliptic/eddsa/key.js +100 -0
- package/js/static_dependencies/elliptic/lib/elliptic/eddsa/signature.js +65 -0
- package/js/static_dependencies/elliptic/lib/elliptic/precomputed/secp256k1.js +780 -0
- package/js/static_dependencies/elliptic/lib/elliptic/utils.js +214 -0
- package/js/static_dependencies/elliptic/lib/elliptic.js +22 -0
- package/js/static_dependencies/elliptic/lib/hmac-drbg/hmac-drbg.js +114 -0
- package/js/static_dependencies/fetch-ponyfill/fetch-node.js +39 -0
- package/js/static_dependencies/node-fetch/index.js +1564 -0
- package/js/static_dependencies/node-rsa/NodeRSA.js +223 -0
- package/js/static_dependencies/node-rsa/asn1/ber/errors.js +13 -0
- package/js/static_dependencies/node-rsa/asn1/ber/index.js +21 -0
- package/js/static_dependencies/node-rsa/asn1/ber/reader.js +262 -0
- package/js/static_dependencies/node-rsa/asn1/ber/types.js +36 -0
- package/js/static_dependencies/node-rsa/asn1/index.js +17 -0
- package/js/static_dependencies/node-rsa/encryptEngines/js.js +34 -0
- package/js/static_dependencies/node-rsa/formats/components.js +71 -0
- package/js/static_dependencies/node-rsa/formats/formats.js +31 -0
- package/js/static_dependencies/node-rsa/formats/pkcs1.js +148 -0
- package/js/static_dependencies/node-rsa/formats/pkcs8.js +187 -0
- package/js/static_dependencies/node-rsa/libs/jsbn.js +1252 -0
- package/js/static_dependencies/node-rsa/libs/rsa.js +147 -0
- package/js/static_dependencies/node-rsa/schemes/pkcs1.js +176 -0
- package/js/static_dependencies/node-rsa/schemes/schemes.js +21 -0
- package/js/static_dependencies/node-rsa/utils.js +98 -0
- package/js/static_dependencies/qs/formats.js +18 -0
- package/js/static_dependencies/qs/index.js +11 -0
- package/js/static_dependencies/qs/parse.js +242 -0
- package/js/static_dependencies/qs/stringify.js +269 -0
- package/js/static_dependencies/qs/utils.js +230 -0
- package/js/stex.js +1925 -0
- package/js/test/.eslintrc.js +42 -0
- package/js/test/Exchange/test.balance.js +61 -0
- package/js/test/Exchange/test.borrowRate.js +32 -0
- package/js/test/Exchange/test.currency.js +52 -0
- package/js/test/Exchange/test.fetchBalance.js +23 -0
- package/js/test/Exchange/test.fetchBorrowInterest.js +59 -0
- package/js/test/Exchange/test.fetchBorrowRate.js +32 -0
- package/js/test/Exchange/test.fetchBorrowRates.js +28 -0
- package/js/test/Exchange/test.fetchClosedOrders.js +32 -0
- package/js/test/Exchange/test.fetchCurrencies.js +35 -0
- package/js/test/Exchange/test.fetchDeposits.js +31 -0
- package/js/test/Exchange/test.fetchFundingFees.js +19 -0
- package/js/test/Exchange/test.fetchFundingRateHistory.js +40 -0
- package/js/test/Exchange/test.fetchL2OrderBook.js +23 -0
- package/js/test/Exchange/test.fetchLedger.js +42 -0
- package/js/test/Exchange/test.fetchLeverageTiers.js +33 -0
- package/js/test/Exchange/test.fetchMarketLeverageTiers.js +22 -0
- package/js/test/Exchange/test.fetchMarkets.js +33 -0
- package/js/test/Exchange/test.fetchMyTrades.js +42 -0
- package/js/test/Exchange/test.fetchOHLCV.js +46 -0
- package/js/test/Exchange/test.fetchOpenOrders.js +36 -0
- package/js/test/Exchange/test.fetchOrderBook.js +25 -0
- package/js/test/Exchange/test.fetchOrderBooks.js +35 -0
- package/js/test/Exchange/test.fetchOrders.js +41 -0
- package/js/test/Exchange/test.fetchPositions.js +47 -0
- package/js/test/Exchange/test.fetchStatus.js +35 -0
- package/js/test/Exchange/test.fetchTicker.js +38 -0
- package/js/test/Exchange/test.fetchTickers.js +49 -0
- package/js/test/Exchange/test.fetchTrades.js +39 -0
- package/js/test/Exchange/test.fetchTradingFee.js +18 -0
- package/js/test/Exchange/test.fetchTradingFees.js +22 -0
- package/js/test/Exchange/test.fetchTransactions.js +31 -0
- package/js/test/Exchange/test.fetchWithdrawals.js +31 -0
- package/js/test/Exchange/test.ledgerItem.js +46 -0
- package/js/test/Exchange/test.leverageTier.js +33 -0
- package/js/test/Exchange/test.loadMarkets.js +35 -0
- package/js/test/Exchange/test.market.js +129 -0
- package/js/test/Exchange/test.ohlcv.js +33 -0
- package/js/test/Exchange/test.order.js +62 -0
- package/js/test/Exchange/test.orderbook.js +61 -0
- package/js/test/Exchange/test.position.js +21 -0
- package/js/test/Exchange/test.throttle.js +94 -0
- package/js/test/Exchange/test.ticker.js +95 -0
- package/js/test/Exchange/test.trade.js +68 -0
- package/js/test/Exchange/test.tradingFee.js +34 -0
- package/js/test/Exchange/test.transaction.js +35 -0
- package/js/test/base/.eslintrc +38 -0
- package/js/test/base/functions/test.crypto.js +110 -0
- package/js/test/base/functions/test.datetime.js +62 -0
- package/js/test/base/functions/test.generic.js +152 -0
- package/js/test/base/functions/test.number.js +362 -0
- package/js/test/base/functions/test.time.js +56 -0
- package/js/test/base/functions/test.type.js +53 -0
- package/js/test/base/test.base.js +193 -0
- package/js/test/errors/test.InsufficientFunds.js +86 -0
- package/js/test/errors/test.InvalidNonce.js +64 -0
- package/js/test/errors/test.InvalidOrder.js +35 -0
- package/js/test/errors/test.OrderNotFound.js +39 -0
- package/js/test/test.js +426 -0
- package/js/test/test.timeout_hang.js +12 -0
- package/js/therock.js +1431 -0
- package/js/tidebit.js +632 -0
- package/js/tidex.js +939 -0
- package/js/timex.js +1283 -0
- package/js/upbit.js +1622 -0
- package/js/vcc.js +1353 -0
- package/js/wavesexchange.js +2185 -0
- package/js/wazirx.js +732 -0
- package/js/whitebit.js +1352 -0
- package/js/woo.js +1577 -0
- package/js/xena.js +1948 -0
- package/js/yobit.js +1129 -0
- package/js/zaif.js +647 -0
- package/js/zb.js +4088 -0
- package/js/zipmex.js +40 -0
- package/js/zonda.js +1497 -0
- package/multilang.sh +159 -0
- package/package.json +591 -0
- package/postinstall.js +103 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
// ----------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const assert = require ('assert')
|
6
|
+
, testTrade = require ('./test.trade.js')
|
7
|
+
|
8
|
+
// ----------------------------------------------------------------------------
|
9
|
+
|
10
|
+
module.exports = async (exchange, symbol) => {
|
11
|
+
|
12
|
+
const skippedExchanges = [
|
13
|
+
'bitso',
|
14
|
+
]
|
15
|
+
|
16
|
+
if (skippedExchanges.includes (exchange.id)) {
|
17
|
+
console.log (exchange.id, 'found in ignored exchanges, skipping fetchMyTrades...')
|
18
|
+
return
|
19
|
+
}
|
20
|
+
|
21
|
+
if (exchange.has.fetchMyTrades) {
|
22
|
+
|
23
|
+
const trades = await exchange.fetchMyTrades (symbol)
|
24
|
+
|
25
|
+
assert (trades instanceof Array)
|
26
|
+
|
27
|
+
console.log ('fetched', trades.length, 'trades')
|
28
|
+
|
29
|
+
const now = Date.now ()
|
30
|
+
|
31
|
+
for (let i = 0; i < trades.length; i++) {
|
32
|
+
testTrade (exchange, trades[i], symbol, now)
|
33
|
+
if (i > 0) {
|
34
|
+
assert (trades[i].timestamp >= trades[i - 1].timestamp)
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
} else {
|
39
|
+
|
40
|
+
console.log ('fetching my trades not supported')
|
41
|
+
}
|
42
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
// ----------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const testOHLCV = require ('./test.ohlcv.js')
|
6
|
+
|
7
|
+
// ----------------------------------------------------------------------------
|
8
|
+
|
9
|
+
module.exports = async (exchange, symbol) => {
|
10
|
+
|
11
|
+
const skippedExchanges = [
|
12
|
+
'btcalpha', // issue with 404 on a documented endpoint https://travis-ci.org/ccxt/ccxt/builds/643930431#L2213
|
13
|
+
'bitmex', // an issue with null values,to be resolved later
|
14
|
+
'cex',
|
15
|
+
]
|
16
|
+
|
17
|
+
if (skippedExchanges.includes (exchange.id)) {
|
18
|
+
console.log (exchange.id, 'found in ignored exchanges, skipping fetchOHLCV...')
|
19
|
+
return
|
20
|
+
}
|
21
|
+
|
22
|
+
if (exchange.has.fetchOHLCV) {
|
23
|
+
|
24
|
+
const timeframe = Object.keys (exchange.timeframes || { '1d': '1d' })[0]
|
25
|
+
const limit = 10
|
26
|
+
const duration = exchange.parseTimeframe (timeframe)
|
27
|
+
const since = exchange.milliseconds () - duration * limit * 1000 - 1000
|
28
|
+
|
29
|
+
const ohlcvs = await exchange.fetchOHLCV (symbol, timeframe, since, limit)
|
30
|
+
|
31
|
+
const now = Date.now ()
|
32
|
+
|
33
|
+
for (let i = 0; i < ohlcvs.length; i++) {
|
34
|
+
const ohlcv = ohlcvs[i]
|
35
|
+
testOHLCV (exchange, ohlcv, symbol, now)
|
36
|
+
}
|
37
|
+
|
38
|
+
console.log (symbol, 'fetched', Object.keys (ohlcvs).length, 'OHLCVs')
|
39
|
+
|
40
|
+
return ohlcvs
|
41
|
+
|
42
|
+
} else {
|
43
|
+
|
44
|
+
console.log ('fetching OHLCV not supported')
|
45
|
+
}
|
46
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
// ----------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const assert = require ('assert')
|
6
|
+
, testOrder = require ('./test.order.js')
|
7
|
+
|
8
|
+
// ----------------------------------------------------------------------------
|
9
|
+
|
10
|
+
module.exports = async (exchange, symbol) => {
|
11
|
+
|
12
|
+
if (exchange.has.fetchOpenOrders) {
|
13
|
+
|
14
|
+
// log ('fetching open orders...')
|
15
|
+
|
16
|
+
const orders = await exchange.fetchOpenOrders (symbol)
|
17
|
+
|
18
|
+
assert (orders instanceof Array)
|
19
|
+
|
20
|
+
console.log ('fetched', orders.length, 'open orders')
|
21
|
+
|
22
|
+
const now = Date.now ()
|
23
|
+
|
24
|
+
for (let i = 0; i < orders.length; i++) {
|
25
|
+
const order = orders[i]
|
26
|
+
testOrder (exchange, order, symbol, now)
|
27
|
+
assert (order.status === 'open')
|
28
|
+
}
|
29
|
+
|
30
|
+
// log (asTable (orders))
|
31
|
+
|
32
|
+
} else {
|
33
|
+
|
34
|
+
console.log ('fetching open orders not supported')
|
35
|
+
}
|
36
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
// ----------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const testOrderBook = require ('./test.orderbook.js')
|
6
|
+
|
7
|
+
// ----------------------------------------------------------------------------
|
8
|
+
|
9
|
+
module.exports = async (exchange, symbol) => {
|
10
|
+
|
11
|
+
const method = 'fetchOrderBook'
|
12
|
+
|
13
|
+
if (exchange.has[method]) {
|
14
|
+
|
15
|
+
const orderbook = await exchange[method] (symbol)
|
16
|
+
|
17
|
+
testOrderBook (exchange, orderbook, method, symbol)
|
18
|
+
|
19
|
+
return orderbook
|
20
|
+
|
21
|
+
} else {
|
22
|
+
|
23
|
+
console.log (method + '() not supported')
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
// ----------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const testOrderBook = require ('./test.orderbook.js')
|
6
|
+
|
7
|
+
// ----------------------------------------------------------------------------
|
8
|
+
|
9
|
+
module.exports = async (exchange) => {
|
10
|
+
|
11
|
+
const randomSymbols = exchange.symbols.slice ().sort (() => 0.5 - Math.random ()).slice (0, 2)
|
12
|
+
const customExchangeParams = ([
|
13
|
+
'yobit',
|
14
|
+
'tidex',
|
15
|
+
'ccex',
|
16
|
+
'liqui',
|
17
|
+
'dsx',
|
18
|
+
]).reduce ((params, id) => ({ ... params, [id]: [randomSymbols], }), {})
|
19
|
+
|
20
|
+
const args = (exchange.id in customExchangeParams) ? customExchangeParams[exchange.id] : []
|
21
|
+
const method = 'fetchOrderBooks'
|
22
|
+
|
23
|
+
if (exchange.has[method]) {
|
24
|
+
|
25
|
+
const orderbooks = await exchange[method] (... args)
|
26
|
+
|
27
|
+
Object.entries (orderbooks).forEach (([symbol, orderbook]) => {
|
28
|
+
testOrderBook (exchange, orderbook, method, symbol)
|
29
|
+
})
|
30
|
+
|
31
|
+
} else {
|
32
|
+
|
33
|
+
console.log (method + '() not supported')
|
34
|
+
}
|
35
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
// ----------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const assert = require ('assert')
|
6
|
+
, testOrder = require ('./test.order.js')
|
7
|
+
|
8
|
+
// ----------------------------------------------------------------------------
|
9
|
+
|
10
|
+
module.exports = async (exchange, symbol) => {
|
11
|
+
|
12
|
+
const skippedExchanges = [
|
13
|
+
'bitmart',
|
14
|
+
'rightbtc',
|
15
|
+
]
|
16
|
+
|
17
|
+
if (skippedExchanges.includes (exchange.id)) {
|
18
|
+
console.log (exchange.id, 'found in ignored exchanges, skipping fetchMyTrades...')
|
19
|
+
return
|
20
|
+
}
|
21
|
+
|
22
|
+
if (exchange.has.fetchOrders) {
|
23
|
+
|
24
|
+
const orders = await exchange.fetchOrders (symbol)
|
25
|
+
|
26
|
+
console.log ('fetched', orders.length, 'orders, asserting each...')
|
27
|
+
|
28
|
+
assert (orders instanceof Array)
|
29
|
+
|
30
|
+
const now = Date.now ()
|
31
|
+
|
32
|
+
for (let i = 0; i < orders.length; i++) {
|
33
|
+
const order = orders[i]
|
34
|
+
testOrder (exchange, order, symbol, now)
|
35
|
+
}
|
36
|
+
|
37
|
+
} else {
|
38
|
+
|
39
|
+
console.log ('fetching orders not supported')
|
40
|
+
}
|
41
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
// ----------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const assert = require ('assert')
|
6
|
+
, testPosition = require ('./test.position.js')
|
7
|
+
|
8
|
+
// ----------------------------------------------------------------------------
|
9
|
+
|
10
|
+
module.exports = async (exchange, symbol) => {
|
11
|
+
|
12
|
+
const skippedExchanges = [
|
13
|
+
'bitmart',
|
14
|
+
'rightbtc',
|
15
|
+
]
|
16
|
+
|
17
|
+
if (skippedExchanges.includes (exchange.id)) {
|
18
|
+
console.log (exchange.id, 'found in ignored exchanges, skipping fetchPositions...')
|
19
|
+
return
|
20
|
+
}
|
21
|
+
|
22
|
+
if (exchange.has['fetchPositions']) {
|
23
|
+
const now = Date.now ()
|
24
|
+
|
25
|
+
// without symbol
|
26
|
+
const positions = await exchange.fetchPositions ()
|
27
|
+
console.log ('fetched', positions.length, 'positions, asserting each...')
|
28
|
+
assert (positions instanceof Array)
|
29
|
+
for (let i = 0; i < positions.length; i++) {
|
30
|
+
const position = positions[i]
|
31
|
+
testPosition (exchange, position, undefined, now)
|
32
|
+
}
|
33
|
+
|
34
|
+
// with symbol
|
35
|
+
const positionsForSymbol = await exchange.fetchPositions ([ symbol ])
|
36
|
+
console.log ('fetched', positions.length, 'positions (' + symbol + '), asserting each...')
|
37
|
+
assert (positionsForSymbol instanceof Array)
|
38
|
+
for (let i = 0; i < positionsForSymbol.length; i++) {
|
39
|
+
const position = positionsForSymbol[i]
|
40
|
+
testPosition (exchange, position, symbol, now)
|
41
|
+
}
|
42
|
+
|
43
|
+
} else {
|
44
|
+
|
45
|
+
console.log ('fetching positions not supported')
|
46
|
+
}
|
47
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
// ----------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const assert = require ('assert')
|
6
|
+
|
7
|
+
// ----------------------------------------------------------------------------
|
8
|
+
|
9
|
+
module.exports = async (exchange) => {
|
10
|
+
|
11
|
+
if (exchange.has.fetchStatus) {
|
12
|
+
|
13
|
+
const method = 'fetchStatus'
|
14
|
+
const status = await exchange[method] ()
|
15
|
+
|
16
|
+
const sampleStatus = {
|
17
|
+
'status': 'ok', // 'ok', 'shutdown', 'error', 'maintenance'
|
18
|
+
'updated': undefined, // integer, last updated timestamp in milliseconds if updated via the API
|
19
|
+
'eta': undefined, // when the maintenance or outage is expected to end
|
20
|
+
'url': undefined, // a link to a GitHub issue or to an exchange post on the subject
|
21
|
+
}
|
22
|
+
|
23
|
+
const keys = Object.keys (sampleStatus)
|
24
|
+
for (let i = 0; i < keys.length; i++) {
|
25
|
+
const key = keys[i]
|
26
|
+
assert (key in status)
|
27
|
+
}
|
28
|
+
|
29
|
+
return status
|
30
|
+
|
31
|
+
} else {
|
32
|
+
|
33
|
+
console.log ('fetching status not supported')
|
34
|
+
}
|
35
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
// ----------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const testTicker = require ('./test.ticker.js')
|
6
|
+
|
7
|
+
// ----------------------------------------------------------------------------
|
8
|
+
|
9
|
+
module.exports = async (exchange, symbol) => {
|
10
|
+
|
11
|
+
const method = 'fetchTicker'
|
12
|
+
|
13
|
+
const skippedExchanges = [
|
14
|
+
'digifinex',
|
15
|
+
'currencycom'
|
16
|
+
]
|
17
|
+
|
18
|
+
if (skippedExchanges.includes (exchange.id)) {
|
19
|
+
console.log (exchange.id, 'found in ignored exchanges, skipping ' + method + '...')
|
20
|
+
return
|
21
|
+
}
|
22
|
+
|
23
|
+
if (exchange.has[method]) {
|
24
|
+
|
25
|
+
const ticker = await exchange.fetchTicker (symbol)
|
26
|
+
|
27
|
+
testTicker (exchange, ticker, method, symbol)
|
28
|
+
|
29
|
+
console.log (symbol, method, ticker['datetime'], 'bid:', ticker['bid'], 'ask:', ticker['ask'])
|
30
|
+
|
31
|
+
return ticker
|
32
|
+
|
33
|
+
} else {
|
34
|
+
|
35
|
+
console.log (symbol, 'fetchTicker () not supported')
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
// ----------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const testTicker = require ('./test.ticker.js')
|
6
|
+
|
7
|
+
// ----------------------------------------------------------------------------
|
8
|
+
|
9
|
+
module.exports = async (exchange, symbol) => {
|
10
|
+
|
11
|
+
const skippedExchanges = [
|
12
|
+
'binance',
|
13
|
+
'digifinex',
|
14
|
+
'currencycom',
|
15
|
+
]
|
16
|
+
|
17
|
+
if (skippedExchanges.includes (exchange.id)) {
|
18
|
+
console.log (exchange.id, 'found in ignored exchanges, skipping fetch all tickers...')
|
19
|
+
return
|
20
|
+
}
|
21
|
+
|
22
|
+
if (exchange.has.fetchTickers) {
|
23
|
+
|
24
|
+
// log ('fetching all tickers at once...')
|
25
|
+
|
26
|
+
const method = 'fetchTickers'
|
27
|
+
let tickers = undefined
|
28
|
+
|
29
|
+
try {
|
30
|
+
|
31
|
+
tickers = await exchange[method] ()
|
32
|
+
console.log ('fetched all', Object.keys (tickers).length, 'tickers')
|
33
|
+
|
34
|
+
} catch (e) {
|
35
|
+
|
36
|
+
console.log ('failed to fetch all tickers, fetching multiple tickers at once...')
|
37
|
+
tickers = await exchange[method] ([ symbol ])
|
38
|
+
console.log ('fetched', Object.keys (tickers).length, 'tickers')
|
39
|
+
}
|
40
|
+
|
41
|
+
Object.values (tickers).forEach ((ticker) => testTicker (exchange, ticker, undefined, symbol))
|
42
|
+
return tickers
|
43
|
+
|
44
|
+
} else {
|
45
|
+
|
46
|
+
console.log ('fetching all tickers at once not supported')
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
// ----------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const assert = require ('assert')
|
6
|
+
, testTrade = require ('./test.trade.js')
|
7
|
+
|
8
|
+
// ----------------------------------------------------------------------------
|
9
|
+
|
10
|
+
module.exports = async (exchange, symbol) => {
|
11
|
+
|
12
|
+
const skippedExchanges = []
|
13
|
+
|
14
|
+
if (skippedExchanges.includes (exchange.id)) {
|
15
|
+
console.log (exchange.id, 'found in ignored exchanges, skipping fetchTrades...')
|
16
|
+
return
|
17
|
+
}
|
18
|
+
|
19
|
+
if (exchange.has.fetchTrades) {
|
20
|
+
|
21
|
+
const trades = await exchange.fetchTrades (symbol)
|
22
|
+
assert (trades instanceof Array)
|
23
|
+
console.log (symbol, 'fetched', Object.values (trades).length, 'trades')
|
24
|
+
const now = Date.now ()
|
25
|
+
for (let i = 0; i < trades.length; i++) {
|
26
|
+
testTrade (exchange, trades[i], symbol, now)
|
27
|
+
if (i > 0) {
|
28
|
+
if (trades[i].timestamp && trades[i - 1].timestamp) {
|
29
|
+
assert (trades[i].timestamp >= trades[i - 1].timestamp)
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
}
|
34
|
+
|
35
|
+
} else {
|
36
|
+
|
37
|
+
console.log (symbol, 'fetchTrades () not supported')
|
38
|
+
}
|
39
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
const testTradingFee = require ('./test.tradingFee.js')
|
4
|
+
|
5
|
+
module.exports = async (exchange, symbol) => {
|
6
|
+
const skippedExchanges = []
|
7
|
+
if (skippedExchanges.includes (exchange.id)) {
|
8
|
+
console.log (exchange.id, 'found in ignored exchanges, skipping fetchTradingFee...')
|
9
|
+
return
|
10
|
+
}
|
11
|
+
if (exchange.has.fetchTradingFee) {
|
12
|
+
const fee = await exchange.fetchTradingFee (symbol)
|
13
|
+
testTradingFee (exchange, symbol, fee)
|
14
|
+
return fee
|
15
|
+
} else {
|
16
|
+
console.log ('fetching trading fees not supported')
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
const testTradingFee = require ("./test.tradingFee")
|
4
|
+
|
5
|
+
module.exports = async (exchange) => {
|
6
|
+
const skippedExchanges = []
|
7
|
+
if (skippedExchanges.includes (exchange.id)) {
|
8
|
+
console.log (exchange.id, 'found in ignored exchanges, skipping fetchTradingFees...')
|
9
|
+
return
|
10
|
+
}
|
11
|
+
if (exchange.has.fetchTradingFees) {
|
12
|
+
const fees = await exchange.fetchTradingFees ()
|
13
|
+
const symbols = Object.keys (fees)
|
14
|
+
for (let i = 0; i < symbols.length; i++) {
|
15
|
+
const symbol = symbols[i]
|
16
|
+
testTradingFee (exchange, symbol, fees[symbol])
|
17
|
+
}
|
18
|
+
return fees
|
19
|
+
} else {
|
20
|
+
console.log ('fetching trading fees not supported')
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
// ----------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const assert = require ('assert')
|
6
|
+
, testTransaction = require ('./test.transaction.js')
|
7
|
+
|
8
|
+
// ----------------------------------------------------------------------------
|
9
|
+
|
10
|
+
module.exports = async (exchange, code) => {
|
11
|
+
|
12
|
+
if (exchange.has.fetchTransactions) {
|
13
|
+
|
14
|
+
const transactions = await exchange.fetchTransactions (code)
|
15
|
+
|
16
|
+
console.log ('fetched', transactions.length, 'transactions, asserting each...')
|
17
|
+
|
18
|
+
assert (transactions instanceof Array)
|
19
|
+
|
20
|
+
const now = Date.now ()
|
21
|
+
|
22
|
+
for (let i = 0; i < transactions.length; i++) {
|
23
|
+
const transaction = transactions[i]
|
24
|
+
testTransaction (exchange, transaction, code, now)
|
25
|
+
}
|
26
|
+
|
27
|
+
} else {
|
28
|
+
|
29
|
+
console.log ('fetching transactions not supported')
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
// ----------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const assert = require ('assert')
|
6
|
+
, testTransaction = require ('./test.transaction.js')
|
7
|
+
|
8
|
+
// ----------------------------------------------------------------------------
|
9
|
+
|
10
|
+
module.exports = async (exchange, code) => {
|
11
|
+
|
12
|
+
if (exchange.has.fetchWithdrawals) {
|
13
|
+
|
14
|
+
const transactions = await exchange.fetchWithdrawals (code)
|
15
|
+
|
16
|
+
console.log ('fetched', transactions.length, 'withdrawals, asserting each...')
|
17
|
+
|
18
|
+
assert (transactions instanceof Array)
|
19
|
+
|
20
|
+
const now = Date.now ()
|
21
|
+
|
22
|
+
for (let i = 0; i < transactions.length; i++) {
|
23
|
+
const transaction = transactions[i]
|
24
|
+
testTransaction (exchange, transaction, code, now)
|
25
|
+
}
|
26
|
+
|
27
|
+
} else {
|
28
|
+
|
29
|
+
console.log ('fetching withdrawals not supported')
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
// ----------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const assert = require ('assert')
|
6
|
+
|
7
|
+
// ----------------------------------------------------------------------------
|
8
|
+
|
9
|
+
module.exports = (exchange, item, code, now) => {
|
10
|
+
assert (typeof item === 'object')
|
11
|
+
assert ('id' in item)
|
12
|
+
assert (item['id'] === undefined || typeof item['id'] === 'string')
|
13
|
+
assert ('direction' in item)
|
14
|
+
assert (item['direction'] === 'in' || item['direction'] === 'out')
|
15
|
+
assert ('account' in item)
|
16
|
+
assert (item['account'] === undefined || typeof item['account'] === 'string')
|
17
|
+
assert ('referenceId' in item)
|
18
|
+
assert (item['referenceId'] === undefined || typeof item['referenceId'] === 'string')
|
19
|
+
assert ('referenceAccount' in item)
|
20
|
+
assert (item['referenceAccount'] === undefined || typeof item['referenceAccount'] === 'string')
|
21
|
+
assert ('type' in item)
|
22
|
+
// expect (item.type).to.be.oneOf (['trade', 'transaction', 'margin', 'cashback', 'referral', 'transfer', 'fee', /* TODO: add more types here */ ])
|
23
|
+
assert ('currency' in item)
|
24
|
+
assert ((item['currency'] === undefined) || (item['currency'] in exchange.currencies))
|
25
|
+
assert ('amount' in item)
|
26
|
+
assert ((item['amount'] === undefined) || (typeof item['amount'] === 'number'))
|
27
|
+
assert ('before' in item)
|
28
|
+
assert ((item['before'] === undefined) || (typeof item['before'] === 'number'))
|
29
|
+
assert ('after' in item)
|
30
|
+
assert ((item['after'] === undefined) || (typeof item['after'] === 'number'))
|
31
|
+
assert ('timestamp' in item)
|
32
|
+
assert ((item['timestamp'] === undefined) || (typeof item['timestamp'] === 'number'))
|
33
|
+
assert (item['timestamp'] >= 1230940800000)
|
34
|
+
assert (item['timestamp'] <= now)
|
35
|
+
assert ('datetime' in item)
|
36
|
+
assert (item['datetime'] === exchange.iso8601 (item['timestamp']))
|
37
|
+
assert ('fee' in item)
|
38
|
+
if (item['fee'] !== undefined) {
|
39
|
+
assert (typeof item['fee'] === 'object')
|
40
|
+
assert ('cost' in item['fee'])
|
41
|
+
assert ((item['fee']['cost'] === undefined) || (typeof item['fee']['cost'] === 'number'))
|
42
|
+
assert ('currency' in item['fee'])
|
43
|
+
}
|
44
|
+
assert ('info' in item)
|
45
|
+
assert ((item['info'] === undefined) || (typeof item['info'] === 'object'))
|
46
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const assert = require ('assert');
|
4
|
+
|
5
|
+
function testLeverageTier (exchange, method, tier) {
|
6
|
+
const format = {
|
7
|
+
'tier': 1,
|
8
|
+
'minNotional': 0,
|
9
|
+
'maxNotional': 5000,
|
10
|
+
'maintenanceMarginRate': 0.01,
|
11
|
+
'maxLeverage': 25,
|
12
|
+
'info': {},
|
13
|
+
};
|
14
|
+
const keys = Object.keys (format);
|
15
|
+
for (let i = 0; i < keys.length; i++) {
|
16
|
+
const key = keys[i];
|
17
|
+
assert (key in tier);
|
18
|
+
}
|
19
|
+
assert (typeof tier['tier'] === 'number');
|
20
|
+
assert (typeof tier['minNotional'] === 'number');
|
21
|
+
assert (typeof tier['maxNotional'] === 'number');
|
22
|
+
assert (typeof tier['maintenanceMarginRate'] === 'number');
|
23
|
+
assert (typeof tier['maxLeverage'] === 'number');
|
24
|
+
assert (tier['tier'] >= 0);
|
25
|
+
assert (tier['minNotional'] >= 0);
|
26
|
+
assert (tier['notionalCap'] >= 0);
|
27
|
+
assert (tier['maintenanceMarginRate'] <= 1);
|
28
|
+
assert (tier['maxLeverage'] >= 1);
|
29
|
+
console.log (exchange.id, method, tier['tier'], tier['minNotional'], tier['maxNotional'], tier['maintenanceMarginRate'], tier['maxLeverage']);
|
30
|
+
return tier;
|
31
|
+
}
|
32
|
+
|
33
|
+
module.exports = testLeverageTier;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
// ----------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const testMarket = require ('./test.market.js')
|
6
|
+
|
7
|
+
// ----------------------------------------------------------------------------
|
8
|
+
|
9
|
+
module.exports = async (exchange) => {
|
10
|
+
|
11
|
+
const skippedExchanges = [
|
12
|
+
'bitforex',
|
13
|
+
]
|
14
|
+
|
15
|
+
if (skippedExchanges.includes (exchange.id)) {
|
16
|
+
console.log (exchange.id, 'found in ignored exchanges, skipping loadMarkets...')
|
17
|
+
return
|
18
|
+
}
|
19
|
+
|
20
|
+
if (exchange.has.loadMarkets) {
|
21
|
+
|
22
|
+
const method = 'loadMarkets'
|
23
|
+
const markets = await exchange[method] ()
|
24
|
+
const values = Object.values (markets)
|
25
|
+
for (let i = 0; i < values.length; i++) {
|
26
|
+
const market = values[i]
|
27
|
+
testMarket (exchange, market, method)
|
28
|
+
}
|
29
|
+
return markets
|
30
|
+
|
31
|
+
} else {
|
32
|
+
|
33
|
+
console.log ('loading markets not supported')
|
34
|
+
}
|
35
|
+
}
|