Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let ccxt = require ('ccxt')
// all examples are here: https://github.com/ccxt/ccxt/tree/master/examples
// this is for the runkit: https://npm.runkit.com/ccxt
let exchange = new ccxt.bitfinex ({
apiKey: '4FlEDtxDl35gdEiobnfZ72vJeZteE4Bb7JdvqzjIjHq',
secret: 'D4DXM8DZdHuAq9YptUsb42aWT1XBnGlIJgLi8a7tzFH',
})
await exchange.loadMarkets ()
console.log (exchange.symbols)
let symbol = exchange.symbols[0]
console.log (symbol)
let ticker = await exchange.fetchTicker (symbol)
console.log (ticker)
let orderbook = await exchange.fetchOrderBook (symbol)
console.log (orderbook)
async function findPriceUSD(exchange, coinName){
//Preset the Bitfinex access
let bitfinexExchange = new ccxt ['bitfinex'] ({
apiKey: eval(`process.env.` + 'bitfinex' + `_apiKey`),
secret: eval(`process.env.` + 'bitfinex' + `_secret`)
});
path = [];
symbol = coinName + '/USD';
allSymbols = await findSymbols(exchange);
found = false;
// If the asset is USD (Should check if in other currency as well)
if(coinName === 'USD'){ // Should not be necessary
path.push('USD');
return await findBalance(exchange, 'USD');
}
//Checks if there is a connection straight to USD