-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87ad1e4
commit f6a4d13
Showing
3 changed files
with
424 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
|
||
/** | ||
* @memberof Driver | ||
* @augments Driver | ||
*/ | ||
class Exolo extends Driver { | ||
/** | ||
* @augments Driver.fetchTickers | ||
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers. | ||
*/ | ||
async fetchTickers() { | ||
const markets = await request('https://openapi.exolo.org/open/v2/pub/ticker'); | ||
|
||
return Object.keys(markets).map((market) => { | ||
const ticker = markets[market]; | ||
const [base, quote] = market.split('_'); | ||
|
||
return new Ticker({ | ||
base, | ||
quote, | ||
close: parseToFloat(ticker.last_price), | ||
baseVolume: parseToFloat(ticker['24_base_volume']), | ||
quoteVolume: parseToFloat(ticker['24_quote_volume']), | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = Exolo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.