-
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.
Merge branch 'master' into feat/amanpuri
- Loading branch information
Showing
16 changed files
with
11,803 additions
and
352 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,31 @@ | ||
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 Ankerswap extends Driver { | ||
/** | ||
* @augments Driver.fetchTickers | ||
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers. | ||
*/ | ||
async fetchTickers() { | ||
// get base and quote data for tickers | ||
const { data: tickers } = await request('https://api.ankerswap.com/api/v1/tickers'); | ||
|
||
return tickers.map((ticker) => new Ticker({ | ||
base: ticker.base_currency, | ||
quote: ticker.target_currency, | ||
high: parseToFloat(ticker.high), | ||
low: parseToFloat(ticker.low), | ||
close: parseToFloat(ticker.last_price), | ||
baseVolume: parseToFloat(ticker.base_volume), | ||
quoteVolume: parseToFloat(ticker.target_volume), | ||
})); | ||
} | ||
} | ||
|
||
module.exports = Ankerswap; |
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,37 @@ | ||
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 Bitcoiva extends Driver { | ||
/** | ||
* @augments Driver.fetchTickers | ||
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers. | ||
*/ | ||
async fetchTickers() { | ||
const { pairlist: markets } = await request('https://www.bitcoiva.com/api/tickers'); | ||
|
||
return Object.keys(markets).map((market) => { | ||
const ticker = markets[market]; | ||
// eslint-disable-next-line no-useless-escape | ||
const [base, quote] = market.split('\/'); | ||
|
||
return new Ticker({ | ||
base, | ||
baseName: ticker.base_full_name, | ||
quote, | ||
high: parseToFloat(ticker.high), | ||
low: parseToFloat(ticker.low), | ||
close: parseToFloat(ticker.current_price), | ||
open: parseToFloat(ticker.start_price), | ||
baseVolume: parseToFloat(ticker.volume), | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = Bitcoiva; |
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,37 @@ | ||
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 Bitcoiva extends Driver { | ||
/** | ||
* @augments Driver.fetchTickers | ||
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers. | ||
*/ | ||
async fetchTickers() { | ||
const { result: tickers } = await request('https://api.bololex.com/api/prices'); | ||
|
||
return tickers.map((ticker) => { | ||
const [base, quote] = ticker.symbol.split('/'); | ||
|
||
return new Ticker({ | ||
base, | ||
quote, | ||
high: parseToFloat(ticker.high), | ||
low: parseToFloat(ticker.low), | ||
close: parseToFloat(ticker.last), | ||
open: parseToFloat(ticker.open), | ||
bid: parseToFloat(ticker.bid), | ||
ask: parseToFloat(ticker.ask), | ||
baseVolume: parseToFloat(ticker.volume.base), | ||
quoteVolume: parseToFloat(ticker.volume.quote), | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = Bitcoiva; |
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,42 @@ | ||
const Driver = require('../models/driver'); | ||
const request = require('../lib/request'); | ||
const Ticker = require('../models/ticker'); | ||
const { throttleMap, parseToFloat } = require('../lib/utils'); | ||
/** | ||
* @memberof Driver | ||
* @augments Driver | ||
*/ | ||
class Flybit extends Driver { | ||
/** | ||
* @param {boolean} isMocked Set to true when stored tickers are used | ||
* @augments Driver.fetchTickers | ||
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers. | ||
*/ | ||
async fetchTickers(isMocked) { | ||
const markets = await request('https://api.flybit.com/v2/public/market/all'); | ||
|
||
const tickers = throttleMap(markets, async ({ MARKET: market }) => { | ||
const ticker = await request(`https://api.flybit.com/v2/public/ticker?market=${market}`); | ||
const [quote, base] = market.split('-'); | ||
|
||
if (!ticker) { | ||
return undefined; | ||
} | ||
|
||
return new Ticker({ | ||
base, | ||
quote, | ||
high: parseToFloat(ticker.MAX_PRICE), | ||
low: parseToFloat(ticker.MIN_PRICE), | ||
close: parseToFloat(ticker.CLOSING_PRICE), | ||
open: parseToFloat(ticker.OPENING_PRICE), | ||
baseVolume: parseToFloat(ticker.UNITS_TRADED_24H), | ||
quoteVolume: parseToFloat(ticker.ACC_TRADE_VALUE_24H), | ||
}); | ||
}, isMocked ? 0 : 50); // 20 requests per second | ||
|
||
return Promise.all(tickers); | ||
} | ||
} | ||
|
||
module.exports = Flybit; |
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,82 @@ | ||
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 Polarity extends Driver { | ||
/** | ||
* @augments Driver.fetchTickers | ||
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers. | ||
*/ | ||
async fetchTickers() { | ||
const { data: markets } = await request('https://data-service.polarity.exchange/pairs?limit=1000'); | ||
const { data: assets } = await request('https://data-service.polarity.exchange/assets?ticker=*'); | ||
|
||
const currencies = assets.map((asset) => ({ | ||
symbol: asset.data.ticker.trim(), | ||
name: asset.data.name, | ||
address: asset.data.id, | ||
})); | ||
|
||
// Add Tether manually because polarity.exchange | ||
// didn't include the quote currency in the assets list | ||
currencies.push({ | ||
address: '7RB3BWayeCVPq3kkpkeJZAFv2DYCB5gEwnutEpRofaw4', | ||
symbol: 'USDT', | ||
name: 'Tether', | ||
}); | ||
|
||
return markets.map((market) => { | ||
const baseCurrency = currencies.find((currency) => (market.amountAsset === currency.address)); | ||
const quoteCurrency = currencies.find((currency) => (market.priceAsset === currency.address)); | ||
|
||
let base; | ||
let baseName; | ||
let baseReference; | ||
if (baseCurrency) { | ||
base = baseCurrency.symbol; | ||
baseName = baseCurrency.name; | ||
baseReference = baseCurrency.address; | ||
} else { | ||
base = market.amountAsset; | ||
baseReference = market.amountAsset; | ||
} | ||
|
||
let quote; | ||
let quoteName; | ||
let quoteReference; | ||
if (quoteCurrency) { | ||
quote = quoteCurrency.symbol; | ||
quoteName = quoteCurrency.name; | ||
quoteReference = quoteCurrency.address; | ||
} else { | ||
quote = market.priceAsset; | ||
quoteReference = market.priceAsset; | ||
} | ||
|
||
const ticker = market.data; | ||
|
||
return new Ticker({ | ||
base, | ||
baseName, | ||
baseReference, | ||
quote, | ||
quoteName, | ||
quoteReference, | ||
open: parseToFloat(ticker.firstPrice), | ||
high: parseToFloat(ticker.high), | ||
low: parseToFloat(ticker.low), | ||
close: parseToFloat(ticker.lastPrice), | ||
vwap: parseToFloat(ticker.weightedAveragePrice), | ||
baseVolume: parseToFloat(ticker.volume), | ||
quoteVolume: parseToFloat(ticker.quoteVolume), | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = Polarity; |
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,50 @@ | ||
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 Wenxpro extends Driver { | ||
/** | ||
* @augments Driver.fetchTickers | ||
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers. | ||
*/ | ||
async fetchTickers() { | ||
const tickers = await request('https://api.wenxpro.com/openapi/quote/v1/ticker/24hr'); | ||
const { symbols } = await request('https://api.wenxpro.com/openapi/v1/brokerInfo'); | ||
const pairs = {}; | ||
|
||
symbols.forEach((el) => { | ||
pairs[el.symbolName] = { | ||
base: el.baseAsset, | ||
baseName: el.baseAssetName, | ||
quote: el.quoteAsset, | ||
quoteName: el.quoteAssetName, | ||
}; | ||
}); | ||
|
||
return tickers.map((ticker) => { | ||
const { | ||
base, quote, baseName, quoteName, | ||
} = pairs[ticker.symbol]; | ||
|
||
return new Ticker({ | ||
base, | ||
baseName, | ||
quote, | ||
quoteName, | ||
high: parseToFloat(ticker.highPrice), | ||
low: parseToFloat(ticker.lowPrice), | ||
close: parseToFloat(ticker.lastPrice), | ||
open: parseToFloat(ticker.openPrice), | ||
baseVolume: parseToFloat(ticker.volume), | ||
quoteVolume: parseToFloat(ticker.quoteVolume), | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = Wenxpro; |
Oops, something went wrong.