diff --git a/drivers/extstock.js b/drivers/extstock.js new file mode 100644 index 00000000..65e95979 --- /dev/null +++ b/drivers/extstock.js @@ -0,0 +1,22 @@ +const request = require('../lib/request'); +const Ticker = require('../models/ticker'); +const { parseToFloat } = require('../lib/utils.js'); + +module.exports = async () => { + const { data: markets } = await request('https://extstock.com/api/v2/ticker'); + + return Object.keys(markets).map((market) => { + const [base, quote] = market.split('_'); + const ticker = markets[market]; + + return new Ticker({ + base, + quote, + close: parseToFloat(ticker.last_price), + ask: parseToFloat(ticker.high), + bid: parseToFloat(ticker.low), + baseVolume: parseToFloat(ticker.base_volume), + quoteVolume: parseToFloat(ticker.quote_volume), + }); + }); +}; diff --git a/drivers/index.js b/drivers/index.js index 6be2e6ba..f3d04d1d 100644 --- a/drivers/index.js +++ b/drivers/index.js @@ -130,6 +130,7 @@ exports.exmarkets = require('./exmarkets'); exports.exmo = require('./exmo'); exports.exnce = require('./exnce'); exports.exrates = require('./exrates'); +exports.extstock = require('./extstock'); exports.exx = require('./exx'); exports.fatbtc = require('./fatbtc'); exports.fcexchange = require('./fcexchange'); diff --git a/tests/fixtures/extstock.json b/tests/fixtures/extstock.json new file mode 100644 index 00000000..78d86c23 --- /dev/null +++ b/tests/fixtures/extstock.json @@ -0,0 +1,41 @@ +[ + { + "scope": "https://extstock.com:443", + "method": "GET", + "path": "/api/v2/ticker", + "body": "", + "status": 200, + "response": [ + "8300090044f365e557fdab37a3b13d786510f7a474f94078b5c63224f148b2a49d2cdac435dddfa3268ba82751afed87749f133ac4492e62c156768ff9f71c8f3a37efb388ba9c77b63c776efe3d77aff73edcbebb0f744f421fbefe2c0997a3456a4a7900fd57fb823e3c9a67cfcd69262cbb7d27e55c4ec608fe70cfbf9e9b73c76d6384e49ecb6d63c5943b37074ebc630d9f65e5b93bbfcb7cdb81d036adbdb2e0b7f2c6d7bf7ef8e2971ffff9fc87e379814707e80ab5356be57a3489dffdf8e739b25130c646fd7f21aa770f6edfd6a85298ef74055e6e4ccb3d9989826c35a46a46ec961714e30604d02d915cbd6d906823eb8dca75033753389e6bbe7bbd278f0361c6b09b7b9154cebc038ba1124d02e9dd691eca8dc0f485d5189852dd42d7e8510f03b3f0e5864eae15e8666c400f550e4f37d266764de7658ae5d34e889e53b0f0e9584cd9be119ddb5642b39ce0b86817c2cb3191a7d34bd037bb87add29cab9bc0bca634020974a6a7b93ca64179acd59a86ad4a740e4a4486d2b01e066089851f5c1f6fb60367cf4f8d62f71af0042b852708b4d0b201e9ca20f877d02e23b9a41a8e51d9e2d4c60cd3871b08109d596f59a84d2a5566327b421d0081adceb1dd58913eac8f5292ed86dd2b034b12e9aa8f1e0c1ebe8b2aeb99ee1489c279b3bb70b90cabe86802d3d289dc0880b9ec008deb19ab0864f54cd74ab6cc1aa5cbd5c8b59adc5ad44ed86e85934e76f79e31753342000749bb72f7ce7193303454014f7d46c494ed76076a670336d3bb262c94c9da90e3b065c1b2a51053f328071c88103a4391d2b73be19da0892c51e58c340085c2463be24ed056411884ab641654426aaaabaaad74b58b1beca3ddb51f9738c5dc2172e1acc14606848642dded2de672bc8bede3816cab54736304b9e34431784e30019388952b5ff3f5fb0f0fae8f891ad286e3c0843bef91ee69ab53f4f34c04b0ec7836c4b0e3b2eb9d75bf4bb6037d32c220f768e9456ceae58c4786aacd5c0b4e5e82b815cac6516e2ab38d844ff34e6a7d7d79353596b201dba52af260e63d0320b1cae55a46fbcc5250320877c7f61451532bd8a8956045f6248faf5643b1d803d04b770c3b", + "1d51f9a9083831c99b5b83e184d103b4fe198fad03bbf7f8c1bb77ebaeb4ba22932ddecdb2678b01e65951169d8142d0735d408311ae0801846d09a7778feebef6e11ca631e88dad6cf6166a2e9eac2471b6c4613d3b200956a54557992a949b72301e9d19ebb35b261cec394fe5f0145536e5939bc03c337ac7291311533e9fcc7303c90cd228a3b6e856e34e2332e4a88aafce4e4d90e478d504b52841741b994aeb627e29c38237aa2a3a87918a32f9848de8ad82e76f303bab6d8a41e5c9aa08371ff4f668d7a2ecd0938006ccb3bb188ef76bb8699a4f0b2830122e03bad068f12fa07a26d376", + "85500a0044572352aaee104202c8fbdfd6990ecea99d9eac9c9cbd70f7c06881d29e29bf22779640819af4981e901490960555eb2ea7aeaac31a1e04c79e096964a571e2e4141be9a8a43ab3cb8d4b4fe5f40c9e4962ecdc87efab774773c71c2bbca70e3a45b25d1a11cf83d93f5f86f2af4bc0f8c7070917c671726334c661274bcb611d9adacef01192b9930998d2bd3e6498b5045e159e08016770a06b5e2ebe1faee2c840988d476f29d7c3b6b7fd5bcb191b67c435835b7d15c6879e890186e4b074f04e4aa8b2fc5282fd7bb9bca27236a054afe45129572e8fe1bdd21b69b193084629fb78fbfccf3e17c38bf9152647b8b5150051f89f87710826ac123a507bc64e4c2f36f395c40301616100fd1a19a8b4744e1aeff2c2c0087b3b1d5b633f0b862adcbfae15251da16a7aff38ce618f7204af2746ac46b6b59832ec369f37ef8820a2aa9cafabd909c09e15b5436a79b090414515899d991198996af668dcbd396d406a5fbe0b37e2cc6aebafef277904bdcc080e4519316b1c67aa4b6d0e8ba4d5c489de29f4521b83e3cc2e1cd022546d0b997df4f3cdebf5b4ed4126aff028aa8a65565678fd312cd752fbb86ea65cc980199538483b39ae311548e52614db88c01176c4c35b0c51f896ed0439c49c3bb0ce3130b27c47da91cf78787dbdbc7a66eaffd993687b38509649d543593c7ee8b7af976752bd65958b09123bfaeef9ed52344e88a2fdb7d985f4844860a10c3abf28d66ed7d9c5d19d4334ab2591b653a1fc01662119b82b8ca708605ba145030a905a760079ea06e26dd61394a3eceb12705ebe0f1b3c3a3780cb12f447e0f400601810467af1a6339e50866f6f4a93deab915346ae9223dc760da03c2534fafef69d08e949a9aa870d357a869ec621f7c7a6193ec579bc0e88ffffa959ce25166a760a491ff3fcf0fa347311dc16688fe2af8cb3e179ee98a5f04b51e1835a3033ee34db404739cb7131b43bd26d00b3d06fd5262a8c9b894b38bba962a5ebc03c1d137358fd238d8dfd1dc22717c5f4b263f2e0157b7b99886dddd595f627f6ab9be7cf3de080c25420ec837ff2e819dba5467884268a960da7d1b252b951168ea9d6f1d62be61b6162ac88a63026f7fa261d5b88113e8aa1a6e54f24b578e56afca63032d173bad4cbeed61833f71e2dcc8ae635dfdbf616eff36bfe02631d66f7bea9cf0c6529aae38ab399edc6a8e35abbdeb2a9273b38351df172ae8cc9351d60a59f17af019d7891da9d4e67f92cc83b51f984b9d91703da5faaa9d9a03613a07c7292d1554ff01457282aab3003a1e89382ffffff1f" + ], + "rawHeaders": [ + "Date", + "Thu, 09 Apr 2020 20:04:09 GMT", + "Content-Type", + "application/json", + "Transfer-Encoding", + "chunked", + "Connection", + "keep-alive", + "Set-Cookie", + "__cfduid=d87a516449f393d843c352572ae23565b1586462649; expires=Sat, 09-May-20 20:04:09 GMT; path=/; domain=.extstock.com; HttpOnly; SameSite=Lax; Secure", + "Vary", + "Accept-Encoding", + "Cache-Control", + "no-cache, private", + "CF-Cache-Status", + "DYNAMIC", + "Expect-CT", + "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"", + "Server", + "cloudflare", + "CF-RAY", + "5816d5e55ebdd423-BUD", + "Content-Encoding", + "br" + ], + "responseIsBinary": false + } +] \ No newline at end of file