Skip to content

Commit

Permalink
feat: bitsten driver
Browse files Browse the repository at this point in the history
  • Loading branch information
sajcics authored and nickpater committed Mar 25, 2020
1 parent ed47ea0 commit 8c0731d
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
26 changes: 26 additions & 0 deletions drivers/bitsten.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const request = require('../lib/request');
const Ticker = require('../models/ticker');
const { parseToFloat } = require('../lib/utils');

module.exports = async () => {
const { result: markets } = await request(
'https://api.bitsten.com/api/v1/public/getticker/all',
);

return Object.keys(markets).map((market) => {
const ticker = markets[market];
const [base, quote] = market.split('_');

return new Ticker({
base,
quote,
high: parseToFloat(ticker.high),
low: parseToFloat(ticker.low),
close: parseToFloat(ticker.last),
bid: parseToFloat(ticker.bid),
ask: parseToFloat(ticker.ask),
baseVolume: parseToFloat(ticker.basevolume),
quoteVolume: parseToFloat(ticker.btcvolume),
});
});
};
1 change: 1 addition & 0 deletions drivers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ exports.bitrue = require('./bitrue');
exports.bitsdaq = require('./bitsdaq');
exports.bitso = require('./bitso');
exports.bitstamp = require('./bitstamp');
exports.bitsten = require('./bitsten');
exports.bittrex = require('./bittrex');
exports.bitubu = require('./bitubu');
exports.bitvast = require('./bitvast');
Expand Down
58 changes: 58 additions & 0 deletions tests/fixtures/bitsten.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[
{
"scope": "https://api.bitsten.com:443",
"method": "GET",
"path": "/api/v1/public/getticker/all",
"body": "",
"status": 200,
"response": [
"83ab010064754c7fa39afa2fa5a13b907f6e01e1ead61c51c08907961d8601ee4b6116057e937e2fbe146813801efceb999794088b81af92f6f673bf150000dcccf053a603169a1cb19193020bdcc5f9bfbb4d8793dbb492e3f236beddcdc55aa3df1bb41cc9c2bfe9f15b00c911851454a3ea3159cfccea9928185fb7315923c4444819c90793c7eef87cc7ca2a0a215312b3851020159460d07a36a72296926a397d9b1a250a7aa5ca4e0815b3bff8639c1d97f3d0c372541228da1be9e1a5410f559d1ea3418fd942881c1987e8a1a7b4063cdb63bc30bfad",
"0cb92700885b88d838c51310cb36255f4a3d9a3a5b89ac9028515cabe8bb3cf3e3be2e7503b80c865a4382323fd933617e987184b1bc23122b300e085bab6c707ce01cfb8a574008c1da429da44d3666e96ada0a4c4e7bb2bc3bc966670f1c4776cbb0a122365ccd1d35b2ee4d4551160246f1353dfff9e2f1ddcbef9acf831e5cfcf224b9783f0752068b2a613f2760af65af821c990557dbaad27ecea40c0a700a72680e6c5778aa9724a8957e8864e538b63611dc253554edb5d2091f1089d7e265585c616f892b0c9621598ebacba894a37aefd842dd322cb140ef5fc8b4ce95a199f15453b4c5abb6a2987ff0fcc7cfc603c542712275a2f84a2b2467d3118dad24ca509c40f1edfaeae75b0c4ae4146f17ea22046050077dac1648a5047c8688645ed92813ad35b44a6629092a765e9bffacbcc76037c1a8699ca5313689535338cefafac8815a55288a32907408e7fee5d373cd930f73c97b32f735ae65c8e716367a7256ebec15529734672b4b4994218ca3350f9dd3c55f316e2d13e2c12a52b61b01b2284216c59af7ff68a122ba109d8273fffaf18beef79cfac19ffd106daa6c2f226452026449846cfd6bba87ca7d9123f5dd29414659f13958decc1c2c5f2ffd0db5716e313103a5e8f4f665fca108e4560337858839cddffee7af7f7f94f7d5f29a786442027a598f91ed46c0bab24d950649006f332aba1d0cbfa69f2f1e7ffd78f93318eea4ef4c4ff966db9b72fe2fe4ce10fcccf66a56ff67b66da6e01772f78e28ec4465e13663f66c56ddf3d58cc2a0d05ddc1c8bdc45cc90544886efcabc344adeab0a627e76c09ed67221c88d142885bdfa699eb8e824aba6790ae1efd04c79acaa964baa5336eab68d7b8a07c5dd797efaf01dc76d476524ebee8a7dbae770ded5a11f476ddfa406eee136c07c7276a21ae7e713e368e6349b2063b5b91faba7249d51b8302f274c3a83b78c9f1274c6b454904c9ac1a21ea4890b05aba59b68c4cc593b329abba59d1ea1bbd697c142c0c0b4e78fbf5fc320a0bfc02f7a7d202914f8437b69bdabdf0faa95018a555ebfdf734fc1a2c2ab1fe6efba280eb8434d096b3097ab22b5c83d5d6a705de4e0d00684a546f9320ad8b67f45d0543d5729d7204aa20c260f1dd5069ff3ffef7f711420c851a4ab5795e4803a350f52122f291b1c4656a7ab80ec3e64a8115977d019ff4fb0b1bb2e0f062b8efc07cf5e7e9eb5fab951d24d698dd22ecd086de82681cb6d7d8c29979d8b16766d65fc1ffadb7f9a875190359b0882bdf536c45d6a095a183bd1a8652a10e586a630cea931ba0ea6d235d6dd33057c28033efc57bfcbfb2ebaf10b1e72e9ca46e99abc74b2c1eeb5a1d9fdae0bf15247cdd7901a5461c354d88379d8dfbf54edc913d5a37863b0047d62ced724aeb2860ba780e561e1390dc3f2c19311c4c26203533eabf76c9b3126a8b8f27ebb1fdf7dfea07b47b1ebe618d67e53041ee82b3b131ef793d5dd0cd0ed097bd9c08385eb3a4366a61944d9dedafd3b109e3b435dd832a6cefdf3abbf8ee3087376a6eda36dca8ce69af7ea61b7a32dcd714a77f6f7792ad8ac42563c313d72cdea3ef5eaadea56756df0e09cf78b7f1f3925adabe6184ea1314eb29eb120ddd12965e0385a61175f1321202313373735e29432935baedf933c20e38c99f67ef1fbc529101f7be058076a9a5e5685d5c6430d83a007128a035da93e43172e8f173b0dd5e33e6b46589b4d48f7bf592ffeb02079967a5f49973d92731f7dc0636b3a615d6dce7c82d1428127c4",
"80c50200c4690393ee5280d2d6c9b9b9259fbf3c75096842b95262afb5da5858a4bd34d6b1ad5ab7ea36199df247a052734d5b2f277be59715a2bca8ed5fcbbb840d1e951db1e08450f7095ee654789f16ce0d1931f055bfa5305942a320bcc546df009e069bff7f3f7f370d7bae86be130efa224e9f19593d2746c78f12ea62e0a02a5f8fa77413ce5826f2c2a1052a42ee7587666a32e4735a41f06b4f64dc35ec12f4400ace38568812c1af50b74d8deee96fc8cf8302f75446f544f0424475b7665ac55b2eec04f6f6102b73",
"582c0040dc6a516c8eb88810fbb57f0b4f45c330c02298745231489d83c6b6c307b162eb741b8e44b23d287b919b0be223f11d59e3d710507ba46ad724fc8acb5eb6024ffd1cceb45f9fd1ac7d726bb6977e5c5c54d68e060a89e8c51efda9fd712cf6488d7097c14b2de90ff4ea81c3557f7f5c72f990a149c07625109b179b43c8d5110a5d51e4cb288cbf40948ea851b65f365cac2266473f7f90f153b12ad74d705a06030704c1b7c4402e41701e9f01875fc55e987b483178",
"80dc02006293c1eab6c0e0ee80a3559dc9cd2f5ff5ebb75669d1148e3b7e491a12768e3b6a231a2dedbfd985bb41639b442dc15c1d93a6766ebcec297148aa6be98dc2695dddcdea0830f3fffd7d41c8b094c23dad8360633e85b05cbcd0921f2804f95218b36d401d936af3e41488d28135cd79e0cd2a2b322718a5a86926413a7063445ca255fab1ebc1511220e8b0b46518619267c8e0bd5040c970883f8f097a66147768404a4bc11500d046b115bf16e5c1358b7b511c5e5ecafe99270bbe0e0fc1d14c8477c618d613feab55202ce728d8226aa560423961dcfec30bb015bb6fe06da40ee36efbf2c46b8c4072c07ac514b259dab9b9b2e0221bf9fd8cbe67bac9675ad3f9a2814c843d8f99c69236fa1d5170f97adeaa178e2bd46500748a8db9cf151910e0ca368a348e5a630f24161eb51d2b32e7180d7faa549eaabb4206c1eb88c3e96332d26fccfcfb3cdbaf2e38b08f709d9e23dd43ae9c7aae260b27ee36cee49afadd3c7665550cd50be4308a85bae4c93bca7e8f",
"df"
],
"rawHeaders": [
"Date",
"Tue, 03 Mar 2020 18:45:13 GMT",
"Content-Type",
"application/json",
"Transfer-Encoding",
"chunked",
"Connection",
"keep-alive",
"Set-Cookie",
"__cfduid=d4e9ab63395f21e1ce1771d842f11c63e1583261112; expires=Thu, 02-Apr-20 18:45:12 GMT; path=/; domain=.bitsten.com; HttpOnly; SameSite=Lax; Secure",
"X-XSS-Protection",
"1; mode=block",
"Access-Control-Allow-Origin",
"*",
"Set-Cookie",
"__cfduidl_copy1=agtas5gbuj46avcukjftdgh8ggqh0akk; expires=Thu, 30-Apr-2020 15:38:33 GMT; Max-Age=5000000; path=/; secure; HttpOnly",
"Expires",
"Thu, 19 Nov 1981 08:52:00 GMT",
"Cache-Control",
"no-store, no-cache, must-revalidate, post-check=0, pre-check=0",
"Pragma",
"no-cache",
"X-Turbo-Charged-By",
"LiteSpeed",
"CF-Cache-Status",
"DYNAMIC",
"Expect-CT",
"max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"",
"Strict-Transport-Security",
"max-age=15552000; preload",
"X-Content-Type-Options",
"nosniff",
"Server",
"cloudflare",
"CF-RAY",
"56e5836118eb9103-ZAG",
"Content-Encoding",
"br"
],
"responseIsBinary": false
}
]

0 comments on commit 8c0731d

Please sign in to comment.