Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"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 ()
"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")
"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',
"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) {
"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)
}) ()
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) {
/**
* 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,
, 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')
"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) {
"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) => {