Skip to content

Commit

Permalink
Merge pull request #245 from coinranking/feat/bitfxt
Browse files Browse the repository at this point in the history
feat: bitfxt driver
  • Loading branch information
nickpater authored Jul 30, 2020
2 parents 94de356 + b4705c0 commit b7a1547
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 0 deletions.
33 changes: 33 additions & 0 deletions drivers/bitfxt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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 Bitfxt extends Driver {
/**
* @augments Driver.fetchTickers
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers.
*/
async fetchTickers() {
const pairs = await request('https://bitfxt.com/api/v1/ticker');

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

return new Ticker({
base,
quote,
close: parseToFloat(ticker.last_price),
baseVolume: parseToFloat(ticker.base_volume),
quoteVolume: parseToFloat(ticker.quote_volume),
});
});
}
}

module.exports = Bitfxt;
1 change: 1 addition & 0 deletions drivers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ exports.Bitfex = require('./bitfex');
exports.Bitfinex = require('./bitfinex');
exports.Bitflyer = require('./bitflyer');
exports.Bitforex = require('./bitforex');
exports.Bitfxt = require('./bitfxt');
exports.Bithumb = require('./bithumb');
exports.Bithumbglobal = require('./Bithumbglobal');
exports.Bitinfi = require('./bitinfi');
Expand Down
149 changes: 149 additions & 0 deletions tests/fixtures/bitfxt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
[
{
"scope": "https://bitfxt.com:443",
"method": "GET",
"path": "/api/v1/ticker",
"body": "",
"status": 200,
"response": {
"BTC_NGN": {
"last_price": "4311157.44000000",
"quote_volume": "12933472.32000000",
"base_volume": "0.00255532"
},
"BMCT_BTC": {
"last_price": "0.00059000",
"quote_volume": 0,
"base_volume": 0
},
"BMCT_NGN": {
"last_price": "4000.00000000",
"quote_volume": 0,
"base_volume": 0
},
"BKY_NGN": {
"last_price": "0.01000000",
"quote_volume": 0,
"base_volume": 0
},
"ETH_BTC": {
"last_price": "0.02765600",
"quote_volume": "0.12873026",
"base_volume": "-0.00800000"
},
"DASH_BTC": {
"last_price": "0.00760600",
"quote_volume": 0,
"base_volume": 0
},
"EOS_BTC": {
"last_price": "0.00027570",
"quote_volume": 0,
"base_volume": 0
},
"FLASH_BTC": {
"last_price": "0.00000040",
"quote_volume": "0.00000319",
"base_volume": "57756.00000000"
},
"BXT_NGN": {
"last_price": "5.69000000",
"quote_volume": "18.37000000",
"base_volume": "131.89915053"
},
"ARDOR_BTC": {
"last_price": "0.00000647",
"quote_volume": 0,
"base_volume": 0
},
"BMT_BTC": {
"last_price": "0.00065000",
"quote_volume": 0,
"base_volume": 0
},
"BMT_NGN": {
"last_price": "2499.00000000",
"quote_volume": 0,
"base_volume": 0
},
"BPY_NGN": {
"last_price": "458.78000000",
"quote_volume": 0,
"base_volume": 0
},
"TAT_BTC": {
"last_price": "0.00000160",
"quote_volume": "0.00005386",
"base_volume": "41122.29964181"
},
"TAT_ETH": {
"last_price": "0.00000800",
"quote_volume": "0.00018100",
"base_volume": "769.66920797"
},
"TAT_NGN": {
"last_price": "0.30000000",
"quote_volume": "1851.91000000",
"base_volume": "196567.22564375"
},
"TAT_BPY": {
"last_price": "0.02000000",
"quote_volume": 0,
"base_volume": 0
},
"BNB_NGN": {
"last_price": false,
"quote_volume": 0,
"base_volume": 0
},
"DGB_BTC": {
"last_price": "0.00000222",
"quote_volume": 0,
"base_volume": 0
},
"DGB_NGN": {
"last_price": "9.61000000",
"quote_volume": 0,
"base_volume": 0
},
"DGB_BPY": {
"last_price": false,
"quote_volume": 0,
"base_volume": 0
}
},
"rawHeaders": [
"Date",
"Thu, 23 Jul 2020 11:46:30 GMT",
"Content-Type",
"text/html; charset=UTF-8",
"Transfer-Encoding",
"chunked",
"Connection",
"keep-alive",
"Set-Cookie",
"__cfduid=df035614b094c9a1ad9fc9107a703faff1595504790; expires=Sat, 22-Aug-20 11:46:30 GMT; path=/; domain=.bitfxt.com; HttpOnly; SameSite=Lax",
"Set-Cookie",
"csrf_bvue_cfd=71fbdd0c6efaf7aeb068928f713eab6a; expires=Thu, 23-Jul-2020 13:46:30 GMT; Max-Age=7200; path=/",
"Set-Cookie",
"ci_session=30c8c39415b4a2fe2cd5b4c0d9f8713af943052c; expires=Thu, 23-Jul-2020 13:46:30 GMT; Max-Age=7200; path=/; 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",
"Vary",
"Accept-Encoding",
"CF-Cache-Status",
"DYNAMIC",
"cf-request-id",
"041d18232b00009139ff207200000001",
"Expect-CT",
"max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"",
"Server",
"cloudflare"
],
"responseIsBinary": false
}
]

0 comments on commit b7a1547

Please sign in to comment.