first commit
This commit is contained in:
commit
aa7869eb33
386 files changed
+69375
No files matched your search
@@ -0,0 +1,54 @@
|
||||
const _ = require('lodash');
|
||||
const fs = require('fs');
|
||||
const request = require('request-promise');
|
||||
const Promise = require('bluebird');
|
||||
|
||||
request({
|
||||
url: 'https://api.bitfinex.com/v1/symbols_details',
|
||||
headers: {
|
||||
Connection: 'keep-alive',
|
||||
'User-Agent': 'Request-Promise',
|
||||
},
|
||||
json: true,
|
||||
})
|
||||
.then(body => {
|
||||
if (!body) {
|
||||
throw new Error('Unable to fetch list of assets, response was empty');
|
||||
}
|
||||
|
||||
return body;
|
||||
})
|
||||
.then(results => {
|
||||
let assets = _.uniq(_.map(results, market => {
|
||||
return market.pair.substring(0, 3).toUpperCase();
|
||||
}));
|
||||
|
||||
let currencies = _.uniq(_.map(results, market => {
|
||||
return market.pair.substring(3, 6).toUpperCase();
|
||||
}));
|
||||
|
||||
let markets = _.map(results, market => {
|
||||
return {
|
||||
pair: [
|
||||
market.pair.substring(3, 6).toUpperCase(),
|
||||
market.pair.substring(0, 3).toUpperCase()
|
||||
],
|
||||
minimalOrder: {
|
||||
amount: market.minimum_order_size,
|
||||
unit: 'asset',
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
return { assets: assets, currencies: currencies, markets: markets };
|
||||
})
|
||||
.then(markets => {
|
||||
fs.writeFileSync('../../wrappers/bitfinex-markets.json', JSON.stringify(markets, null, 2));
|
||||
console.log(`Done writing Bitfinex market data`);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(`Couldn't import products from Bitfinex`);
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user