Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Add strategy: forex.analytics, an genetic optimization algorithm for TA-lib stats #389

Merged
merged 15 commits into from
Jul 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ conf_*
sim_result*
*_test
backtesting_*
models/*.json
models/*.html
2 changes: 2 additions & 0 deletions commands/_codemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
'list-strategies': require('./list-strategies'),
'backfill': require('./backfill'),
'sim': require('./sim'),
'train': require('./train'),
'balance': require('./balance'),
'trade': require('./trade'),
'buy': require('./buy'),
Expand All @@ -15,6 +16,7 @@ module.exports = {
'list[30]': '#commands.list-strategies',
'list[50]': '#commands.backfill',
'list[60]': '#commands.sim',
'list[62]': '#commands.train',
'list[65]': '#commands.balance',
'list[70]': '#commands.trade',
'list[80]': '#commands.buy',
Expand Down
18 changes: 12 additions & 6 deletions commands/sim.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function container (get, set, clear) {
.option('--conf <path>', 'path to optional conf overrides file')
.option('--strategy <name>', 'strategy to use', String, c.strategy)
.option('--order_type <type>', 'order type to use (maker/taker)', /^(maker|taker)$/i, c.order_type)
.option('--filename <filename>', 'filename for the result output (ex: result.html)', String, c.filename)
.option('--filename <filename>', 'filename for the result output (ex: result.html). "none" to disable', String, c.filename)
.option('--start <timestamp>', 'start at timestamp')
.option('--end <timestamp>', 'end at timestamp')
.option('--days <days>', 'set duration by day count', Number, c.days)
Expand All @@ -35,6 +35,7 @@ module.exports = function container (get, set, clear) {
.option('--max_slippage_pct <pct>', 'avoid selling at a slippage pct above this float', c.max_slippage_pct)
.option('--symmetrical', 'reverse time at the end of the graph, normalizing buy/hold to 0', Boolean, c.symmetrical)
.option('--rsi_periods <periods>', 'number of periods to calculate RSI at', Number, c.rsi_periods)
.option('--disable_options', 'disable printing of options')
.option('--enable_stats', 'enable printing order stats')
.option('--verbose', 'print status lines on every period')
.action(function (selector, cmd) {
Expand Down Expand Up @@ -63,6 +64,7 @@ module.exports = function container (get, set, clear) {
so.start = d.subtract(so.days).toMilliseconds()
}
so.stats = !!cmd.enable_stats
so.show_options = !cmd.disable_options
so.verbose = !!cmd.verbose
so.selector = get('lib.normalize-selector')(selector || c.selector)
so.mode = 'sim'
Expand Down Expand Up @@ -93,8 +95,10 @@ module.exports = function container (get, set, clear) {
option_keys.forEach(function (k) {
options[k] = so[k]
})
var options_json = JSON.stringify(options, null, 2)
output_lines.push(options_json)
if (so.show_options) {
var options_json = JSON.stringify(options, null, 2)
output_lines.push(options_json)
}
if (s.my_trades.length) {
s.my_trades.push({
price: s.period.close,
Expand Down Expand Up @@ -159,9 +163,11 @@ module.exports = function container (get, set, clear) {
.replace('{{output}}', html_output)
.replace(/\{\{symbol\}\}/g, so.selector + ' - zenbot ' + require('../package.json').version)

var out_target = so.filename || 'simulations/sim_result_' + so.selector +'_' + new Date().toISOString().replace(/T/, '_').replace(/\..+/, '').replace(/-/g, '').replace(/:/g, '').replace(/20/, '') + '_UTC.html'
fs.writeFileSync(out_target, out)
console.log('wrote', out_target)
if (so.filename !== 'none') {
var out_target = so.filename || 'simulations/sim_result_' + so.selector +'_' + new Date().toISOString().replace(/T/, '_').replace(/\..+/, '').replace(/-/g, '').replace(/:/g, '').replace(/20/, '') + '_UTC.html'
fs.writeFileSync(out_target, out)
console.log('wrote', out_target)
}
process.exit(0)
}

Expand Down
Loading