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

Commit

Permalink
Fix training start and simulation start/end (#1119)
Browse files Browse the repository at this point in the history
* Respect buy_max_amt also in paper mode

buy_max_amt was working only on live, now it works also on paper mode

* Fix node-telegram-bot-api deprecated warning

Get rid of that annoying message. Telegram tested and working fine.

* Fix training start and simulation start/end

Previously the training was starting too early if --days_test was
specified. According to the parameter description, --days_test is a
parameter to specify when the simulation should stop (days after
training). The simulator wants the start and end date in this format:
YYYYMMDDhhmm, which was not the case, thus the simulator wasn't
running properly. Now if the user specifies dates it works properly.

Example: ./zenbot.sh train binance.ETH-BTC --start_training 2018-01-01
--end_training 2018-01-03 --days_test 3

In this example, the training stops on Jan 2nd (midnight).
The simulation test runs after the period used in the training, thus
begins on on Jan 3rd and stops 3 days later, on Jan 5th (midnight).

* Ignore models in models/subdirectories
  • Loading branch information
firepol authored and DeviaVir committed Jan 13, 2018
1 parent 409ef61 commit 04e976c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ trade_result*
*_test
backtesting_*
generation_data_*
models/*.json
models/*.html
models/**/*.json
models/**/*.html
*.pyc
*.swp
temp.html
Expand Down
23 changes: 11 additions & 12 deletions commands/train.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,7 @@ module.exports = function container (get, set, clear) {
}
if (!so.start_training && so.days_training) {
var d = tb('1d')
so.start_training = d.subtract(so.days_test).subtract(so.days_training).toMilliseconds()
}
if (so.days_test > 0) {
var d = tb('1d')
so.end_training = d.subtract(so.days_test).toMilliseconds()
so.start_training = d.subtract(so.days_training).toMilliseconds()
}
so.selector = get('lib.objectify-selector')(selector || c.selector)
so.mode = 'train'
Expand Down Expand Up @@ -232,8 +228,8 @@ module.exports = function container (get, set, clear) {
'--strategy', 'forex_analytics',
'--disable_options',
'--modelfile', path.resolve(__dirname, '..', tempModelFile),
'--start', so.start_training,
'--end', so.end_training,
'--start', moment(so.start_training).format('YYYYMMDDHHmm'),
'--end', moment(so.end_training).format('YYYYMMDDHHmm'),
'--period', so.period_length,
'--filename', path.resolve(__dirname, '..', tempModelFile) + '-simTrainingResult.html'
]
Expand All @@ -248,18 +244,21 @@ module.exports = function container (get, set, clear) {
var trainingResult = parseSimulation(path.resolve(__dirname, '..', tempModelFile) + '-simTrainingResult.html')

if (so.days_test > 0) {
console.log(
"\nRunning simulation on test data from "
+ moment(so.end_training).format('YYYY-MM-DD HH:mm:ss ZZ') + " onwards.\n"
var endTest = moment(so.end_training).add(so.days_test, 'days')

console.log("\nRunning simulation on test data from "
+ moment(so.end_training).format('YYYY-MM-DD HH:mm:ss ZZ') + " to "
+ moment(endTest).format('YYYY-MM-DD HH:mm:ss ZZ') + " (" + so.days_test + " days).\n"
)

var testArgs = [
'sim',
so.selector.normalized,
'--strategy', 'forex_analytics',
'--disable_options',
'--modelfile', path.resolve(__dirname, '..', tempModelFile),
'--start', so.end_training,
'--start', moment(so.end_training).format('YYYYMMDDHHmm'),
'--end', moment(endTest).format('YYYYMMDDHHmm'),
'--period', so.period_length,
'--filename', path.resolve(__dirname, '..', tempModelFile) + '-simTestResult.html',
]
Expand Down

0 comments on commit 04e976c

Please sign in to comment.