Skip to content

Commit

Permalink
eslint fixes (DeviaVir#1298)
Browse files Browse the repository at this point in the history
  • Loading branch information
krystophv authored and DeviaVir committed Feb 7, 2018
1 parent 7139305 commit 2758400
Show file tree
Hide file tree
Showing 57 changed files with 714 additions and 738 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scripts/auto_backtester/node_modules/*
scripts/genetic_backtester/node_modules/*
scripts/genetic_algo/node_modules/*
dist
templates/dashboard_assets/js/*
9 changes: 8 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"env": {
"es6": true,
"node": true,
"jasmine": true
"jasmine": true,
"browser": true
},
"extends": "eslint:recommended",
"rules": {
Expand All @@ -23,5 +24,11 @@
"error",
"never"
]
},
"parserOptions": {
"sourceType": "module",
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
}
}
2 changes: 1 addition & 1 deletion boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function (cb) {
cb(null, zenbot)
}

var authStr = '', authMechanismStr, authMechanism
var authStr = '', authMechanism

if(c.mongo.username){
authStr = encodeURIComponent(c.mongo.username)
Expand Down
5 changes: 3 additions & 2 deletions commands/backfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,13 @@ module.exports = function (program, conf) {
marker.newest_time = other_marker.newest_time
}
})
var diff
if (oldest_time !== marker.oldest_time) {
var diff = tb(oldest_time - marker.oldest_time).resize('1h').value
diff = tb(oldest_time - marker.oldest_time).resize('1h').value
console.log('\nskipping ' + diff + ' hrs of previously collected data')
}
else if (newest_time !== marker.newest_time) {
var diff = tb(marker.newest_time - newest_time).resize('1h').value
diff = tb(marker.newest_time - newest_time).resize('1h').value
console.log('\nskipping ' + diff + ' hrs of previously collected data')
}
resume_markers.save(marker, function (err) {
Expand Down
2 changes: 1 addition & 1 deletion commands/backfill/backfill.function.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function container (conf) {
cpService.setOnProcessFunc(backfillProcessFunction(conf))
cpService.setAfterOnProcessFunc(backfillUpdateScreenFunction)

return new Promise((resolve, reject) => {
return new Promise((resolve/*, reject*/) => {
cpService.go(targetTimeInMillis).then((finalTrade) => {
resolve(finalTrade)
})
Expand Down
2 changes: 1 addition & 1 deletion commands/backfill/backfill.process.function.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = function (conf) {
if (skipToTradeId === curr.trade_id) {
let lastTrade = curr
let idx = {i: index}
collectionServiceInstance.getTrades().insert(curr).then((err, doc) => {
collectionServiceInstance.getTrades().insert(curr).then((/*err, doc*/) => {
if (idx.i === trades.length) {
cb(null, false, lastTrade.trade_id, lastTrade)
}
Expand Down
3 changes: 2 additions & 1 deletion commands/balance.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var minimist = require('minimist')
, n = require('numbro')
// eslint-disable-next-line no-unused-vars
, colors = require('colors')
, moment = require('moment')
, engineFactory = require('../lib/engine')
Expand Down Expand Up @@ -34,7 +35,7 @@ module.exports = function (program, conf) {
var engine = engineFactory(s, conf)
function balance () {
s.exchange.getBalance(s, function (err, balance) {
if (err) return cb(err)
if (err) throw err
s.exchange.getQuote(s, function (err, quote) {
if (err) throw err

Expand Down
1 change: 1 addition & 0 deletions commands/buy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var minimist = require('minimist')
, n = require('numbro')
// eslint-disable-next-line no-unused-vars
, colors = require('colors')
, objectifySelector = require('../lib/objectify-selector')
, engineFactory = require('../lib/engine')
Expand Down
3 changes: 2 additions & 1 deletion commands/list-selectors.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// eslint-disable-next-line no-unused-vars
var colors = require('colors'),
fs = require('fs')

module.exports = function (program) {
program
.command('list-selectors')
.description('list available selectors')
.action(function (cmd) {
.action(function (/*cmd*/) {
var exchanges = fs.readdirSync('./extensions/exchanges')
exchanges.forEach(function(exchange){
console.log(`${exchange}:`)
Expand Down
3 changes: 2 additions & 1 deletion commands/list-strategies.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
var fs = require('fs'),
// eslint-disable-next-line no-unused-vars
colors = require('colors')

module.exports = function (program, conf) {
program
.command('list-strategies')
.description('list available strategies')
.action(function (cmd) {
.action(function (/*cmd*/) {
var strategies = fs.readdirSync('./extensions/strategies')
strategies.forEach((strategy) => {
let strat = require(`../extensions/strategies/${strategy}/strategy`)
Expand Down
1 change: 1 addition & 0 deletions commands/sell.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var minimist = require('minimist')
, n = require('numbro')
// eslint-disable-next-line no-unused-vars
, colors = require('colors')
, objectifySelector = require('../lib/objectify-selector')
, engineFactory = require('../lib/engine')
Expand Down
91 changes: 45 additions & 46 deletions commands/sim.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ var tb = require('timebucket')
, objectifySelector = require('../lib/objectify-selector')
, engineFactory = require('../lib/engine')
, tradesCollection = require('../db/trades')
, _ = require('lodash')

module.exports = function (program, conf) {
program
Expand Down Expand Up @@ -89,7 +88,7 @@ module.exports = function (program, conf) {
var query_start = so.start ? tb(so.start).resize(so.period_length).subtract(so.min_periods + 2).toMilliseconds() : null

function exitSim () {
console.log()
console.log()
if (!s.period) {
console.error('no trades found! try running `zenbot backfill ' + so.selector.normalized + '` first')
process.exit(1)
Expand All @@ -105,8 +104,8 @@ module.exports = function (program, conf) {
options[k] = so[k]
})

let options_output = options
options_output.simresults = {}
let options_output = options
options_output.simresults = {}

if (s.my_trades.length) {
s.my_trades.push({
Expand Down Expand Up @@ -202,29 +201,29 @@ module.exports = function (program, conf) {
process.exit(0)
}

function getNext () {
var opts = {
query: {
selector: so.selector.normalized
},
sort: {time: 1},
limit: 1000
}
if (so.end) {
opts.query.time = {$lte: so.end}
}
if (cursor) {
if (reversing) {
opts.query.time = {}
opts.query.time['$lt'] = cursor
if (query_start) {
opts.query.time['$gte'] = query_start
}
opts.sort = {time: -1}
function getNext () {
var opts = {
query: {
selector: so.selector.normalized
},
sort: {time: 1},
limit: 1000
}
if (so.end) {
opts.query.time = {$lte: so.end}
}
if (cursor) {
if (reversing) {
opts.query.time = {}
opts.query.time['$lt'] = cursor
if (query_start) {
opts.query.time['$gte'] = query_start
}
else {
if (!opts.query.time) opts.query.time = {}
opts.query.time['$gt'] = cursor
opts.sort = {time: -1}
}
else {
if (!opts.query.time) opts.query.time = {}
opts.query.time['$gt'] = cursor
}
}
else if (query_start) {
Expand All @@ -240,26 +239,26 @@ module.exports = function (program, conf) {
return getNext()
}
engine.exit(exitSim)
}
if (so.symmetrical && reversing) {
trades.forEach(function (trade) {
trade.orig_time = trade.time
trade.time = reverse_point + (reverse_point - trade.time)
})
}
engine.update(trades, function (err) {
if (err) throw err
if (reversing) {
cursor = trades[trades.length - 1].orig_time
}
else {
cursor = trades[trades.length - 1].time
}
setImmediate(getNext)
}
if (so.symmetrical && reversing) {
trades.forEach(function (trade) {
trade.orig_time = trade.time
trade.time = reverse_point + (reverse_point - trade.time)
})
}
engine.update(trades, function (err) {
if (err) throw err
if (reversing) {
cursor = trades[trades.length - 1].orig_time
}
else {
cursor = trades[trades.length - 1].time
}
setImmediate(getNext)
})
}
getNext()
})
}
})
}
getNext()
})
}

9 changes: 4 additions & 5 deletions commands/train.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var tb = require('timebucket')
, minimist = require('minimist')
, n = require('numbro')
, fs = require('fs')
, path = require('path')
, spawn = require('child_process').spawn
, moment = require('moment')
// eslint-disable-next-line no-unused-vars
, colors = require('colors')
, analytics = require('forex.analytics')
, ProgressBar = require('progress')
Expand Down Expand Up @@ -86,7 +86,7 @@ module.exports = function (program, conf) {
if (!so.days_test) { so.days_test = 0 }
so.strategy = 'noop'

unknownIndicators = []
var unknownIndicators = []
if (so.indicators) {
so.indicators.split(',').forEach(function(indicator) {
if (!fa_availableIndicators.includes(indicator))
Expand Down Expand Up @@ -194,7 +194,7 @@ module.exports = function (program, conf) {
var simulationResult = fs.readFileSync(simulationResultFile).toString()
simulationResult = simulationResult.substr(simulationResult.length - 512)

result = {}
var result = {}
if (simulationResult.match(endBalance)) { result.endBalance = simulationResult.match(endBalance)[1] }
if (simulationResult.match(buyHold)) { result.buyHold = simulationResult.match(buyHold)[1] }
if (simulationResult.match(vsBuyHold)) { result.vsBuyHold = simulationResult.match(vsBuyHold)[1] }
Expand Down Expand Up @@ -300,7 +300,7 @@ module.exports = function (program, conf) {
}
)

return analytics.findStrategy(candlesticks, fa_getTrainOptions(so), function(strategy, fitness, generation) {
return analytics.findStrategy(candlesticks, fa_getTrainOptions(so), function(strategy, fitness/*, generation*/) {
bar.tick({
'fitness': fitness
})
Expand All @@ -316,7 +316,6 @@ module.exports = function (program, conf) {
}

var option_keys = Object.keys(so)
var output_lines = []
option_keys.sort(function (a, b) {
if (a < b) return -1
return 1
Expand Down
2 changes: 1 addition & 1 deletion conf-sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ c.notifiers.pushover.priority = '0' // choose a priority to send zenbot messages
// end pushover configs

// telegram configs
c.notifiers.telegram = {};
c.notifiers.telegram = {}
c.notifiers.telegram.on = false // false telegram disabled; true telegram enabled (key should be correct)
c.notifiers.telegram.bot_token = 'YOUR-BOT-TOKEN'
c.notifiers.telegram.chat_id = 'YOUR-CHAT-ID' // the id of the chat the messages should be send in
Expand Down
3 changes: 1 addition & 2 deletions extensions/exchanges/binance/exchange.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const ccxt = require('ccxt')
, path = require('path')
// eslint-disable-next-line no-unused-vars
, colors = require('colors')
, moment = require('moment')
, _ = require('lodash')
, n = require('numbro')

module.exports = function bittrex (conf) {
var public_client, authed_client
Expand Down
Loading

0 comments on commit 2758400

Please sign in to comment.