How to use the ansicolor.nice function in ansicolor

To help you get started, we’ve selected a few ansicolor 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 ccxt / ccxt / examples / js / bittrex-balance.js View on Github external
"use strict";

const ccxt      = require ('../../ccxt.js')
const asTable   = require ('as-table')
const log       = require ('ololog').configure ({ locate: false })

require ('ansicolor').nice

let sleep = (ms) => new Promise (resolve => setTimeout (resolve, ms))

;(async () => {

    // instantiate the exchange
    let exchange = new ccxt.bittrex  ({
        "apiKey": "471b47a06c384e81b24072e9a8739064",
        "secret": "694025686e9445589787e8ca212b4cff",
    })


    try {

        // fetch account balance from the exchange
        let balance = await exchange.fetchBalance ()
github ccxt / ccxt / examples / js / binance-fetch-ohlcv.js View on Github external
"use strict";

const ccxt       = require ('../../ccxt.js')
const asciichart = require ('asciichart')
const asTable    = require ('as-table')
const log        = require ('ololog').configure ({ locate: false })

require ('ansicolor').nice;

//-----------------------------------------------------------------------------

(async function main () {

    const index = 4 // [ timestamp, open, high, low, close, volume ]


    const ohlcv = await new ccxt.binance ().fetchOHLCV ('BTC/USDT', '1h')


    const lastPrice = ohlcv[ohlcv.length - 1][index] // closing price
    const series = ohlcv.slice (-80).map (x => x[index])         // closing price
    const bitcoinRate = ('₿ = $' + lastPrice).green
    const chart = asciichart.plot (series, { height: 15 })
    log.yellow ("\n" + chart, bitcoinRate, "\n")
github ccxt / ccxt / examples / js / exchange-capabilities.js View on Github external
"use strict";

/*  ------------------------------------------------------------------------ */

const ccxt        = require ('../../ccxt.js')
    , asTable     = require ('as-table') // .configure ({ print: require ('string.ify').noPretty })
    , log         = require ('ololog').noLocate
    , ansi        = require ('ansicolor').nice

;(async function test () {

    let total = 0
    let missing = 0
    let implemented = 0
    let emulated = 0

    log (asTable (ccxt.exchanges.map (id => new ccxt[id]()).map (exchange => {

        let result = {};

        [
            'publicAPI',
            'privateAPI',
            'CORS',
github ccxt / ccxt / examples / js / live-orderbook.js View on Github external
"use strict";

const asTable   = require ('as-table')
    , log       = require ('ololog').noLocate
    , ansi      = require ('ansicolor').nice
    , ccxt      = require ('../../ccxt.js')

let printSupportedExchanges = function () {
    log ('Supported exchanges:', ccxt.exchanges.join (', ').green)
}

let printUsage = function () {
    log ('Usage: node', process.argv[1], 'exchange'.green, 'symbol'.yellow, 'depth'.cyan)
    printSupportedExchanges ()
}

let printOrderBook = async (id, symbol, depth) => {

    // check if the exchange is supported by ccxt
    let exchangeFound = ccxt.exchanges.indexOf (id) > -1
    if (exchangeFound) {
github ccxt / ccxt / examples / js / order-book-extra-level-depth-param.js View on Github external
"use strict";

const ccxt = require ('../../ccxt')
const asTable = require ('as-table')
const log = require ('ololog')

require ('ansicolor').nice

;(async function test () {

    const exchange = new ccxt.bitfinex ()
    const orders = await exchange.fetchOrderBook ('BTC/USD', {
        'limit_bids': 5, // max = 50
        'limit_asks': 5, // may be 0 in which case the array is empty
        'group': 1, // 1 = orders are grouped by price, 0 = orders are separate
    })

    log (orders)
}) ()
github michnovka / ccxt-trading-cp / tradingcp.js View on Github external
terminal.nl();
    terminal.nl();
    terminal.showCentered(title, '-');
    terminal.showCentered(getYmdHisDate(timeStart)+' - '+ getYmdHisDate(timeEnd), '-');
    terminal.nl();

    if(!series)
        return;

    if(!precision)
        precision = 0;

    let asciichart = require ('asciichart');
    let log        = require ('ololog').configure ({ locate: false });

    require('ansicolor').nice;

    series = series.slice(-96);

    let firstPrice = series[0]; // closing price
    let lastPrice = series[series.length - 1]; // closing price
    let difference = (lastPrice/firstPrice -1)*100;

    if(difference < 0){
        difference = (terminal.number_format(difference,2)+'%').red;
    }else{
        difference = ('+'+terminal.number_format(difference,2)+'%').green;
    }
    let padding = '                ';

    let quoteRate = (symbol + ' = ' + quote + lastPrice).green;
    let chart = asciichart.plot(series, { height: 15, format: function (x) {
github ourarash / log-with-statusbar / examples / enable.js View on Github external
/**
 * Demonstrate how to use statusBarTextPush and statusBarTextPop 
 * functions to add/remove lines
 * To run:
 *  npm install progress-string
 * By: Ari Saif
 */
var log = require("../index.js")({
  ololog_configure: {
    locate: false,
    tag: true
  }
});
require("ansicolor").nice;

var progressString;
try {
  progressString = require("progress-string");
} catch (error) {
  console.log(
    `Please run "npm install progress-string" before running the demo.`
  );
  process.exit();
}

let i = 0;
let maxCount = 100;

var pBar = progressString({
  width: 40,
github ccxt / ccxt / examples / js / cli.js View on Github external
, cloudscrape = process.argv.includes ('--cloudscrape')
    , cfscrape = process.argv.includes ('--cfscrape')
    , poll = process.argv.includes ('--poll')
    , no_send = process.argv.includes ('--no-send')
    , no_load_markets = process.argv.includes ('--no-load-markets')
    , details = process.argv.includes ('--details')
    , no_table = process.argv.includes ('--no-table')
    , iso8601 = process.argv.includes ('--iso8601')
    , cors = process.argv.includes ('--cors')

//-----------------------------------------------------------------------------

const ccxt         = require ('../../ccxt.js')
    , fs           = require ('fs')
    , path         = require ('path')
    , ansi         = require ('ansicolor').nice
    , asTable      = require ('as-table').configure ({

        delimiter: ' | '.lightGray.dim,
        right: true,
        title: x => String (x).lightGray,
        dash: '-'.lightGray.dim,
        print: x => {
            if (typeof x === 'object') {
                const j = JSON.stringify (x).trim ()
                if (j.length < 100) return j
            }
            return String (x)
        }
    })
    , util         = require ('util')
    , { execSync } = require ('child_process')
github ccxt / ccxt / examples / js / load-all-tickers-at-once.js View on Github external
"use strict";

const ccxt      = require ('../../ccxt.js')
const asTable   = require ('as-table')
const log       = require ('ololog').configure ({ locate: false })

require ('ansicolor').nice

//-----------------------------------------------------------------------------

process.on ('uncaughtException',  e => { log.bright.red.error (e); process.exit (1) })
process.on ('unhandledRejection', e => { log.bright.red.error (e); process.exit (1) })

//-----------------------------------------------------------------------------

let human_value = function (price) {
    return price === undefined ? 'N/A' : price
}

//-----------------------------------------------------------------------------

let test = async function (exchange, symbol) {
github ccxt / ccxt / examples / js / arbitrage-pairs.js View on Github external
"use strict";

const ccxt      = require ('../../ccxt.js')
const asTable   = require ('as-table')
const log       = require ('ololog').configure ({ locate: false })

require ('ansicolor').nice;

let printSupportedExchanges = function () {
    log ('Supported exchanges:', ccxt.exchanges.join (', ').green)
}

let printUsage = function () {
    log ('Usage: node', process.argv[1], 'id1'.green, 'id2'.yellow, 'id3'.blue, '...')
    printSupportedExchanges ()
}

let printExchangeSymbolsAndMarkets = function (exchange) {
    log (getExchangeSymbols (exchange))
    log (getExchangeMarketsTable (exchange))
}

let getExchangeMarketsTable = (exchange) => {

ansicolor

A JavaScript ANSI color/style management. ANSI parsing. ANSI to CSS. Small, clean, no dependencies.

Unlicense
Latest version published 3 months ago

Package Health Score

76 / 100
Full package analysis