How to use the ccxt.exchanges function in ccxt

To help you get started, we’ve selected a few ccxt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github atanasster / crypto-grommet / server / models / exchanges.js View on Github external
import ccxt from 'ccxt';
import { sleep } from '../api/utils';

export const exchanges = ccxt.exchanges.map((exchangeId) => {
  const exchange = new ccxt[exchangeId]();
  exchange.loadMarkets()
  // eslint-disable-next-line no-unused-vars
    .then((markets) => {
      // console.log(markets);
    })
    .catch(() => {
      console.log('ERROR : loadMarkets', exchangeId);
      return sleep();
    });
  return exchange;
});

const baseExchangeInfo = (exchange) => {
  const countries = typeof exchange.countries === 'string' ? [exchange.countries] : exchange.countries;
  return {
github atanasster / grommet-nextjs / server / graphql / crypto / models / exchanges.js View on Github external
id: exchange.id,
      name: exchange.name,
      logo: exchange.urls ? exchange.urls.logo : null,
      url,
      hasOrderBook: exchange.has.fetchOrderBook,
      countries: countries.map(c => (c === 'UK' ? 'GB' : c)),
      fees,
      currencies: exchange.currencies ? Object.keys(exchange.currencies).map(key =>
        (exchange.currencies[key])) : [],
      markets: exchange.markets ?
        Object.keys(exchange.markets).map(key => (exchange.markets[key])) : [],
    };
  };

  const exchanges = [];
  ccxt.exchanges.forEach((exchangeId) => {
    const exchange = new ccxt[exchangeId]();
    exchange.loadMarkets()
    // eslint-disable-next-line no-unused-vars
      .then((markets) => {
        exchanges.push(baseExchangeInfo(exchange));
      })
      .catch(() => {
        console.log('ERROR : loadMarkets', exchangeId);
        return sleep();
      });
  });
  exchanges.push({ id: 'CCCAGG', name: 'CCCAGG', countries: [] });
  module.exports.exchangeObj = (exchange) => {
    const exch = exchanges.find(item => item.name === exchange);
    if (exch) {
      return new ccxt[exch.id]();
github pRoy24 / tokencaps / models / APIStorage / Exchange / ExchangeList.js View on Github external
getMarketExchangeByToken() {
    let exchangeNormalizedArray = [];

    function marketCallback(responseData) {
      return responseData;
    }

    ccxt.exchanges.forEach(function (exchangeName, exIdx, exchangeArr) {
      try {
        let currentExchange = markets.getExchangeInstance(exchangeName);
        currentExchange.fetchMarkets().then(function (exchangeMarket) {
          let exchangeRows = [];
          let timeStamp = Date.now();
          Object.keys(exchangeMarket).forEach(function (marketKey) {
            exchangeRows.push({
              "base": exchangeMarket[marketKey].base, "quote": exchangeMarket[marketKey].quote,
              "symbol": exchangeMarket[marketKey].symbol, "market": exchangeName,
              "timestamp": timeStamp
            })
          });
          exchangeNormalizedArray = exchangeNormalizedArray.concat(MarketUtils.mergeQuotesForBaseInExchange(exchangeRows));
          // console.log(exchangeNormalizedArray.length);
          if (exIdx === exchangeArr.length - 1) {
            marketCallback(MarketUtils.groupCoinByMarketMaps(exchangeNormalizedArray));
github pRoy24 / tokencaps / models / ExchangeModels.js View on Github external
listExchangeMetadata: function() {
    var actions = ccxt.exchanges.map(getExchangeMetadata);
    var results = Promise.all(actions); // pass array of promises
    return results.then(function(response){
      return response;
    }).catch(function(err){
      return err;
    });
  },
github mxaddict / mmaker / src / engine.js View on Github external
async start () {
    // Check exchange
    if (!ccxt.exchanges.includes(this.exchange)) {
      log.bright.red.error(`Exchange "${this.exchange}" is not supported YET`)
      return false
    }

    // Load the exchange
    log.cyan(`Using Exchange "${this.exchange}"`)
    this.exchange = new ccxt[this.exchange](config.get(this.exchange))

    // Save the markets and marketsInfo
    this.marketsInfo = await this.exchange.loadMarkets()
    this.markets = Object.keys(this.marketsInfo)

    // Check if we selected a market/pair that is valid
    if (!this.markets.includes(this.market)) {
      log.bright.red.error(`Market "${this.market}" is not supported YET`)
      return false
github pRoy24 / tokencaps / models / ExchangeModels.js View on Github external
getExchangeDetailsList: function() {
    var actions = ccxt.exchanges.map(getExchangeDetails);
    var results = Promise.all(actions); // pass array of promises
    return results.then(function(response){
      return response;
    });
  },
github ccxt-rest / ccxt-rest / test / api / controllers / exchanges.js View on Github external
.end(function(err, res) {
            should.not.exist(err);

            res.body.should.eql(ccxt.exchanges.map(i => '' + i));

            done();
          });
      });
github kupi-network / kupi-terminal / server / core_components / initCCXT.js View on Github external
const initCCXT = async function(privateKeys) {
  var stocks = _.clone(ccxt.exchanges)
  for (let stock of stocks) {
    if (global.CCXT[`${stock}--public`] === undefined) {
      try {
        global.CCXT[`${stock}--public`] = new ccxt[stock] ({
          'enableRateLimit': true
        })
      } catch(err) {
        console.log(`Can't create ${stock} instance`)
      }
    }
  }

  for (let key of privateKeys) {
    global.ACCOUNTS[key.id] = {
      id: key.id,
      name: key.name,
github ccxt-rest / ccxt-rest / api / config / exchange.js View on Github external
}
    }
};

Object.keys(UNSUPPORTED_EXCHANGES).forEach(exchangeName => {
    exchangeConfigs[exchangeName] = {
        override : (functionName, req, res, defaultBehaviour) => {
            const details = UNSUPPORTED_EXCHANGES[exchangeName]
            const message = `[${exchangeName}] is currently ${details.status} and not supported right now (${details.moreInfo}).`
            throw new ccxtRestErrors.BrokenExchangeError(message)
        }
    }
})

module.exports = Object.assign(exchangeConfigs, {
    exchanges: ccxt.exchanges.filter(exchangeName => !UNSUPPORTED_EXCHANGES.hasOwnProperty(exchangeName)),
})
github ccxt-rest / ccxt-rest / src / routes / exchanges.js View on Github external
router.get('/', function(req, res, next) {
    res.send(CircularJSON.stringify(ccxt.exchanges));
  });