Skip to content

Instantly share code, notes, and snippets.

@kakopappa
Created January 5, 2018 05:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kakopappa/e4b5fce3de4285eaaaa523a186a1c964 to your computer and use it in GitHub Desktop.
Save kakopappa/e4b5fce3de4285eaaaa523a186a1c964 to your computer and use it in GitHub Desktop.
Scan coinmarketcap and find good coins to buy
// Scan coinmarketcap and find good coins to buy
const CoinMarketCap = require('coinmarketcap-api')
const client = new CoinMarketCap()
client.getTicker({limit: 1000}).then( pairs => {
let filteredResult = pairs.filter(function(key) {
return (key.available_supply < 1500000);
});
var fr = filteredResult.reduce(function (r, a) {
//r.push({symbol: a.symbol, rank: a.rank, supply: a.available_supply, price: a.price_usd});
r.push({symbol: a.symbol, price: a.price_usd});
return r;
}, []);
var sorted = fr.sort(function(a, b) {
return (a.rank > b.rank) ? 1 : ((b.rank > a.rank) ? -1 : 0)
//return (a.price > b.price) ? 1 : ((b.price > a.price) ? -1 : 0)
});
console.log(sorted);
}).catch(console.error)
//client.getGlobal().then(console.log).catch(console.error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment