Skip to content

Commit

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

/**
* @memberof Driver
* @augments Driver
*/
class Floatsv extends Driver {
/**
* @augments Driver.fetchTickers
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers.
*/
async fetchTickers() {
const tickers = await request('https://www.floatsv.com/api/spot/v3/instruments/ticker');

return tickers.map((ticker) => {
const [base, quote] = ticker.instrument_id.split('-');

return new Ticker({
base,
quote,
high: parseToFloat(ticker.high_24hr),
low: parseToFloat(ticker.low_24hr),
close: parseToFloat(ticker.last),
baseVolume: parseToFloat(ticker.base_volume_24h),
quoteVolume: parseToFloat(ticker.quote_volume_24h),
});
});
}
}

module.exports = Floatsv;
1 change: 1 addition & 0 deletions drivers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ exports.Fcoin = require('./fcoin');
exports.Felixo = require('./felixo');
exports.Finexbox = require('./finexbox');
exports.Fivestar = require('./fivestar');
exports.Floatsv = require('./floatsv');
exports.Forkdelta = require('./forkdelta');
exports.Ftx = require('./ftx');
exports.Gateio = require('./gateio');
Expand Down
65 changes: 65 additions & 0 deletions tests/fixtures/floatsv.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[
{
"scope": "https://www.floatsv.com:443",
"method": "GET",
"path": "/api/spot/v3/instruments/ticker",
"body": "",
"status": 200,
"response": [
"03631800c40a5b66946f2c754df7b0326bcdf77e3c1390ff68fbf62de21d15454d4945cbdb1944a4dc0aab979b4982b87550f9bd277996191e2b3a8b0e6a5fa5fd6db5df4c96d68590e940eec7a9a56e842c09ee3bfceebf87d4fffef0e35fbf3dee0e83b15573dcb48cfbe4ebcf9ecae3e6f84f07aadf19b4e5c3d6f1ef9fbd717b7f3db574f84e9f09eb659beffd870f7ffeedefe3ee10d8b187f89b3efef5db0f7ffdfa9fcf9f7b7aabd48854327a9a275f267ad40b7d96173e547cf511bb5833f1235ab6a40a7dbefbf1cf75ac4513b95b3f7ccdf41326a006ee467b74917e379aecd6ead6ed78fb77d79d1cee7ce7b8390c0e74f4f3826cf6f8ff86f9af60368677dadf99daf599af3f7bfebae836bd5137ed743ee63118902d1e3b8670ab0b5ebfc250a95de82342f9f8228bc8b91f6416d2fd718d27b1f9929581e6243a7d00336b03d356f36a2c7de06bb8f480c65c4f8789b3363dadd6d285b5ef4030c711835e24a40ba4",
"9b6c33108f2d6b92006756defb19d678ad0d734fc6f2205b14b18246eed71b4ca1701e2b55c8677ebe6c9b18742f6e769164bebd39850cbfa1fbc27847632d9662853bf21575dba37025956579089788b5bd4d22e2a6f667e1eaf614ac4d4375131006716403d9d282c719ddaa0391e32882df2609792b901af79d123a4ebe7f7f13889a7113cd112c39809c35a1e97c5b0dc2cc56ed4f0b902b70932d1a8d4fa68e32a53903d19ceabb238b68dba0db6a04f1759d6608f717ea43020dda1fa05fa6677a70fefb922c30abdc46e79c5fa8a797b39ebd46cda6ebe286681498b2b387b45aa40ce49bc67a07d7ca574384d66d7c92ddadc32f2f115698171a721b95fd3f7eeead1b6f136b13b56786369768c1ed756185b5a803680409fe55b98229d798a32aa0a50afcae3774a806704b2facd36463bd14f192328e6c0b17ab132b7320718c2e70fdfa5da2aa86baa2dd7660839dd3ed63544b246cdfb6f4852750fb9dd05158966b74567a4dba1120bb3962c350d7a981f0c0bd90325adb23c42f0ba433d91cefbe7a198588d542b9b56015cad1df27cc643b1e782da9d0ee03b8505499edb25fe8a05bf41645f2eec86de6cfde504d16491f6e631622514451b753d20d44e12065c841a51d56076ecbbacb4aae6318d9946db823b5a89945f33867c9f95c8e16ad40b070bb399809d366665e6488740f47c5ed96831451fb79a4669e5a85016dc958ea2d39882197524e95b2fb24ca71ce9273d07ac6095230c8de78866175714c0bc8ae0e98113053c44ef6a955c012a1a2706270f7a195e22c27749b41e70a91ae14288db597cfa6c3a9c627e23291248b0dc8b3ea9d953dee93ecac41130f502d2565cdd3c38f26887329b96cad128d0f846089f9abdaed4c5bb0c5533689053644094848d0ba55018fca22e382faa98a2458c446c7b9945ec25db1d98040576da275d54cd3b11a52cac17207962141942fa8c059ca2eb706f9c8aa63c89a897a1699712e259762429cfb3266dc62d201cddcbd5a851ce8c0585b888aa48424b74448a54df8c1062cf062a8a03e9050fb7daa09e957864563ed77d982df0c4473a8bc8a05b4561d887e18992b7430997c4d6f73d6b073706076bfef4c0c554504bf30f6eb33d19bc3f4bd1de357bf2f3c7a16bbb2268b3de676e9c1add3601b750c5b5604282c6ab1624d765736ef6a64146e8b04cfb18be62c43a333ebe26d1aa617e460d511eb12cda7c30ca54227ca03a643c8eed7b90b9951edca133c1bc815c2053c0e7804ade463ba49356f4d9724b135fd0f44275eb8d66c799bc5d62cc972d4cab30ac1a0b0f55adb16a303ab0f0424768f6a38949e75458bed3d4259d681efd789a2d5e9b3554ad0fe8fa63b943b0c5f9bc72e4f70046c3b83642ffcada78f799b86eac62f3b9072859ffd1c1989ae18c1aa03f18bb5e68669879bcfeea4b688bd814fc48e3d22b14a0d656fb5aa5892a92195db2c3c788d7db3a07e90cfddc22a9f5bbaac7e3ddd12cef16895207eb957ae63dafdf1d64a7cc1965fedcbab28dff11a2fcdc1267bc5ac500c2efcfaf42ddec6a0fbe17843a1cc53c24805e140686caf47a9d1740ae7dd1ed7e924e92ba07cc52ca95d56ade695188b11dae61e5c2a846798498c276566a7ef708511ac890157c839805c9904b7a90ecf744f105f1dc8cce61797c6992a825edd6f4573e221de4dcaf3c188d70cc798e78cca66707d992e08f08d76ab3a59111c4cac85dd5d5928faba8de306c059111f0ec9a1bac09a8449c6ce54cb168e3370cabc2274dafea0254664d5a6c64506d6c5dd8d7ca60bacc922f39ea44132c58045178834b00835fdc9cdea20d22e23b8a29c0eb1067928501404ab05fd07714231cb838b679a7e401dfbb12aa5f2075dfec356a308a4b588d096608a820833",
"dd1cc7b79c8d5a5588ad1aa4b35e1484c3ab661e408ad3053a19c8722609725ac540b9100c4a2fbd143ecc5b6db0b96ec689a4d00c44d47707cb54015dfdd5826d7ea5484507a2a13d47240a6f022498225f675eb0f047977bdea6a1632611b25a76a550be7ece6360d38b5105ae415de8b5395f16402bd5a6414ebb392f5cac063e5660764895a79737a099015fc639273dbd6c554a14c7ffe6cdea6bf28b56036273d403428a44d1f10f8efd8a0f4c63dcba4b63990b6c577a575cb3bce0489b7e8172ce8c24934be5f82c1d5c1a667a975a0b6960d069644adbd46a70247bab91a2f6a467212b26e39ca567b6c8ffbd6a58748ab4768a2c5a137cacef1d24baa07a852f8b5b01c2a227e0a0e8690e79e7b32b395a1576869357de56fb5d51c56b0272f9f47a121e0194d10533bb2d5f00584e898888be3f49ee238c9e243fca67d13dced9d4d94927c152b6aca5bc1942efa23582b82a5be2a4014eeea336df792cf74b363c8be59bdf1f"
],
"rawHeaders": [
"Date",
"Tue, 30 Jun 2020 19:32:31 GMT",
"Content-Type",
"text/html; charset=UTF-8",
"Transfer-Encoding",
"chunked",
"Connection",
"keep-alive",
"Set-Cookie",
"__cfduid=d77837f6bf68b021764cc5bb338821b721593545550; expires=Thu, 30-Jul-20 19:32:30 GMT; path=/; domain=.floatsv.com; HttpOnly; SameSite=Lax",
"Vary",
"Accept-Encoding",
"Set-Cookie",
"locale=en_US; Max-Age=604800; Expires=Tue, 07-Jul-2020 19:32:31 GMT; Path=/",
"X-Content-Type-Options",
"nosniff",
"X-XSS-Protection",
"1; mode=block",
"Cache-Control",
"no-cache, no-store, max-age=0, must-revalidate",
"Pragma",
"no-cache",
"Expires",
"0",
"X-Frame-Options",
"DENY",
"X-BrokerID",
"153",
"X-Kong-Upstream-Latency",
"2",
"X-Kong-Proxy-Latency",
"0",
"Via",
"kong/1.4.3",
"Strict-Transport-Security",
"max-age=63072000; includeSubdomains; preload",
"CF-Cache-Status",
"DYNAMIC",
"cf-request-id",
"03a85083190000911bd5187200000001",
"Expect-CT",
"max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"",
"Server",
"cloudflare",
"CF-RAY",
"5aba504b58db911b-ZAG",
"Content-Encoding",
"br"
],
"responseIsBinary": false
}
]

0 comments on commit 16cbd10

Please sign in to comment.