-
Notifications
You must be signed in to change notification settings - Fork 52
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
b7a6c60
commit 0b727ee
Showing
3 changed files
with
12,536 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
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,47 @@ | ||
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 Tokpie extends Driver { | ||
/** | ||
* @augments Driver.fetchTickers | ||
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers. | ||
*/ | ||
async fetchTickers() { | ||
const markets = await request('https://tokpie.com/api_ticker/'); | ||
|
||
return Object.keys(markets).flatMap((market) => { | ||
const ticker = markets[market]; | ||
if (ticker.isFrozen) return []; | ||
|
||
const [base, quote] = ticker.pair.split('@'); | ||
|
||
const close = parseToFloat(ticker.last); | ||
const baseVolume = parseToFloat(ticker.baseVolume); | ||
const quoteVolume = parseToFloat(ticker.quoteVolume); | ||
|
||
if (!close) return []; | ||
if (!baseVolume && !quoteVolume) return []; | ||
|
||
return new Ticker({ | ||
base, | ||
quote, | ||
open: parseToFloat(ticker.at_first24), | ||
high: parseToFloat(ticker.high24hr), | ||
low: parseToFloat(ticker.low24hr), | ||
close, | ||
bid: parseToFloat(ticker.highestBid), | ||
ask: parseToFloat(ticker.lowestAsk), | ||
baseVolume, | ||
quoteVolume, | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = Tokpie; |
Oops, something went wrong.