Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async printPerformance() {
if (this.strategies.length == 0) return;
console.log('\x1Bc');
var date = "";
if (this.exchange.isBacktesting()) {
let dateStart = colors.magenta(dateFormat(config.scenario.start, "mmm d, h:MM:ssTT"));
let dateEnd = colors.magenta(dateFormat(config.scenario.end, "mmm d, h:MM:ssTT"));
date = colors.magenta(dateFormat(Math.min(this.exchange.time, config.scenario.end), "mmm d, h:MM:ssTT"));
console.log(` | Backtesting from ${dateStart} to ${dateEnd}\n`);
}
let columns = [];
for (var i = 0; i < this.strategies.length; i++) {
let strategy = this.strategies[i];
try {
let value = await strategy.portfolio.value("USDT");
if(!strategy.originalValue) strategy.originalValue = value;
let valstr = colors.green("$" + value.total.toFixed(2));
let ovalstr = colors.green("$" + strategy.originalValue.total.toFixed(2));
columns.push({strategy: colors.blue(strategy.title), value: valstr, "original value": ovalstr});
// console.log(" |=> " + strategy.prettyTitle(), valstr + ", original value:", ovalstr);
} catch(err) {
throw err;
console.log("Error calculating value");
if (!npm.config.get('global')) {
dir = path.relative(process.cwd(), dir)
}
var columns = [ depname,
has || 'MISSING',
want,
latest,
deppath
]
if (long) columns[5] = type
if (npm.color) {
columns[0] = color[has === want ? 'yellow' : 'red'](columns[0]) // dep
columns[2] = color.green(columns[2]) // want
columns[3] = color.magenta(columns[3]) // latest
columns[4] = color.brightBlack(columns[4]) // dir
if (long) columns[5] = color.brightBlack(columns[5]) // type
}
return columns
}
async printPerformance() {
if (this.strategies.length == 0)
return;
let scenario = types_1.Scenario.getInstance();
let out = "\x1Bc\n";
var date;
if (scenario.mode == types_1.ScenarioMode.PLAYBACK) {
let dateStart = colors.magenta(dateFormat(scenario.start, "mmm d, h:MM:ssTT"));
let dateEnd = colors.magenta(dateFormat(scenario.end, "mmm d, h:MM:ssTT"));
date = colors.magenta(dateFormat(Math.min(scenario.time, scenario.end), "mmm d, h:MM:ssTT"));
out += ` | Backtesting from ${dateStart} to ${dateEnd}\n\n`;
}
let columns = [];
for (var i = 0; i < this.strategies.length; i++) {
let strategy = this.strategies[i];
try {
let value = await strategy.portfolio.value(this.params.quote, this.exchange.price.bind(this.exchange));
if (!strategy.originalValue)
strategy.originalValue = value;
let total = types_1.BN(value.all.free).plus(value.all.reserved).toFixed(2);
let originalTotal = types_1.BN(strategy.originalValue.all.free).plus(strategy.originalValue.all.reserved).toFixed(2);
let valstr = colors.green("$" + total);
let ovalstr = colors.green("$" + originalTotal);
columns.push({ strategy: colors.blue(strategy.title), value: valstr, "original value": ovalstr });
}
catch (err) {
protected async printPerformance() {
if (this.strategies.length == 0) return;
let scenario = Scenario.getInstance();
let out = "\x1Bc\n";
var date;
if (scenario.mode == ScenarioMode.PLAYBACK) {
let dateStart = colors.magenta(dateFormat(scenario.start, "mmm d, h:MM:ssTT"));
let dateEnd = colors.magenta(dateFormat(scenario.end, "mmm d, h:MM:ssTT"));
date = colors.magenta(dateFormat(Math.min(scenario.time, scenario.end), "mmm d, h:MM:ssTT"));
out += ` | Backtesting from ${dateStart} to ${dateEnd}\n\n`;
}
let columns = [];
for (var i = 0; i < this.strategies.length; i++) {
let strategy = this.strategies[i];
try {
let value = await strategy.portfolio.value(this.params.quote, this.exchange.price.bind(this.exchange));
if(!strategy.originalValue) strategy.originalValue = value;
let total:string = BN(value.all.free).plus(value.all.reserved).toFixed(2);
let originalTotal:string = BN(strategy.originalValue.all.free).plus(strategy.originalValue.all.reserved).toFixed(2);
let valstr = colors.green("$" + total);
let ovalstr = colors.green("$" + originalTotal);
columns.push({strategy: colors.blue(strategy.title), value: valstr, "original value": ovalstr});
} catch(err) {
throw err;
function handle(server, req, resp, parsed) {
if(!(parsed.pathname in entries) && !('browserify' in parsed.query)) {
return nextHandler(server, req, resp, parsed)
}
var entryPath = entries[parsed.pathname]
, args = bundlerOpts.flags.slice()
, bundler
, output
if(entryPath) {
args.unshift(entryPath)
}
args.unshift(bundlerOpts.command)
parsed.loggedPathname = ansicolors.magenta(
parsed.pathname + ' -> ' + args.map(toLocal).join(' ')
)
args.shift()
bundler = spawn(bundlerOpts.command, args)
bundler.stderr.pipe(accumError(io.error, resp))
resp.setHeader('content-type', 'text/javascript')
bundler.stdout.pipe(resp)
}
protected async printPerformance() {
if (this.strategies.length == 0) return;
let scenario = Scenario.getInstance();
let out = "\x1Bc\n";
var date;
if (scenario.mode == ScenarioMode.PLAYBACK) {
let dateStart = colors.magenta(dateFormat(scenario.start, "mmm d, h:MM:ssTT"));
let dateEnd = colors.magenta(dateFormat(scenario.end, "mmm d, h:MM:ssTT"));
date = colors.magenta(dateFormat(Math.min(scenario.time, scenario.end), "mmm d, h:MM:ssTT"));
out += ` | Backtesting from ${dateStart} to ${dateEnd}\n\n`;
}
let columns = [];
for (var i = 0; i < this.strategies.length; i++) {
let strategy = this.strategies[i];
try {
let value = await strategy.portfolio.value(this.params.quote, this.exchange.price.bind(this.exchange));
if(!strategy.originalValue) strategy.originalValue = value;
let total:string = BN(value.all.free).plus(value.all.reserved).toFixed(2);
let originalTotal:string = BN(strategy.originalValue.all.free).plus(strategy.originalValue.all.reserved).toFixed(2);
let valstr = colors.green("$" + total);
let ovalstr = colors.green("$" + originalTotal);
columns.push({strategy: colors.blue(strategy.title), value: valstr, "original value": ovalstr});
} catch(err) {
throw err;
}
function handle(server, req, resp, parsed) {
if(!(parsed.pathname in entries) && !('browserify' in parsed.query)) {
return nextHandler(server, req, resp, parsed)
}
var entryPath = entries[parsed.pathname]
, args = bundlerOpts.flags.slice()
, bundler
, output
if(entryPath) {
args.unshift(entryPath)
}
args.unshift(bundlerOpts.command)
parsed.loggedPathname = ansicolors.magenta(
parsed.pathname + ' -> ' + args.map(toLocal).join(' ')
)
args.shift()
bundler = spawn(bundlerOpts.command, args)
bundler.stderr.pipe(accumError(io.error, resp))
resp.setHeader('content-type', 'text/javascript')
bundler.stdout.pipe(resp)
}
function handle(server, req, resp, parsed) {
if(!(parsed.pathname in entries) && !('browserify' in parsed.query)) {
return nextHandler(server, req, resp, parsed)
}
var entryPath = entries[parsed.pathname]
, args = bundlerOpts.flags.slice()
, bundler
, output
args.unshift(bundlerOpts.command.bundler, entryPath)
parsed.loggedPathname = ansicolors.magenta(
parsed.pathname + ' ➞ ' + args.map(toLocal).join(' ')
)
args.shift()
args.shift()
bundler = bundlerOpts.command(entryPath)
bundler.stderr.pipe(accumError(io.error, resp))
resp.setHeader('content-type', 'text/javascript')
bundler.stdout.pipe(resp)
}
async printPerformance() {
if (this.strategies.length == 0)
return;
let scenario = types_1.Scenario.getInstance();
let out = "\x1Bc\n";
var date;
if (scenario.mode == types_1.ScenarioMode.PLAYBACK) {
let dateStart = colors.magenta(dateFormat(scenario.start, "mmm d, h:MM:ssTT"));
let dateEnd = colors.magenta(dateFormat(scenario.end, "mmm d, h:MM:ssTT"));
date = colors.magenta(dateFormat(Math.min(scenario.time, scenario.end), "mmm d, h:MM:ssTT"));
out += ` | Backtesting from ${dateStart} to ${dateEnd}\n\n`;
}
let columns = [];
for (var i = 0; i < this.strategies.length; i++) {
let strategy = this.strategies[i];
try {
let value = await strategy.portfolio.value(this.params.quote, this.exchange.price.bind(this.exchange));
if (!strategy.originalValue)
strategy.originalValue = value;
let total = types_1.BN(value.all.free).plus(value.all.reserved).toFixed(2);
let originalTotal = types_1.BN(strategy.originalValue.all.free).plus(strategy.originalValue.all.reserved).toFixed(2);
let valstr = colors.green("$" + total);
let ovalstr = colors.green("$" + originalTotal);
columns.push({ strategy: colors.blue(strategy.title), value: valstr, "original value": ovalstr });
}