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

Allow making some darwin values be sticky and not mutate by passing them on the command line #1175

Merged
merged 2 commits into from
Jan 21, 2018

Conversation

glennfu
Copy link
Contributor

@glennfu glennfu commented Jan 19, 2018

I wanted to be able to pass in extra args the commands, but previously everything was hard-coded. Only stuff specifically defined in darwin.js phenotype definitions would be passed along, and could not be overridden from the initial command line call. Now those parameters are passed along dynamically, along with it being possible to override them if you choose to add them to your command. The ultimate goal here being to make it convenient to more tightly control what kind of experiment you intend to run without having to go and change the source code.

Now if you run: ./scripts/genetic_backtester/darwin.js --selector="gdax.BTC-USD" --currency_capital=1000 --asset_capital=0 --use_strategies=trend_ema --period=60m --days=1 --population=8 --markdown_buy_pct=4.1 --min_periods=2

You'll see:

=== Simulating generation 1 ===

Backfilling (might take some time) ...
./zenbot.sh backfill --days=1 gdax.BTC-USD
[ 1/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=22m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=1.5539857101908812 --order_type=maker --sell_stop_pct=39 --buy_stop_pct=19 --profit_stop_enable_pct=0 --profit_stop_pct=8 --trend_ema=20 --oversold_rsi_periods=20 --oversold_rsi=22 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 2/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=113m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=0.09676986513947083 --order_type=taker --sell_stop_pct=41 --buy_stop_pct=37 --profit_stop_enable_pct=3 --profit_stop_pct=13 --trend_ema=20 --oversold_rsi_periods=23 --oversold_rsi=34 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 3/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=97m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=3.6750922758126947 --order_type=maker --sell_stop_pct=2 --buy_stop_pct=0 --profit_stop_enable_pct=12 --profit_stop_pct=15 --trend_ema=20 --oversold_rsi_periods=19 --oversold_rsi=21 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 4/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=87m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=1.8329766431785508 --order_type=maker --sell_stop_pct=6 --buy_stop_pct=49 --profit_stop_enable_pct=0 --profit_stop_pct=3 --trend_ema=20 --oversold_rsi_periods=23 --oversold_rsi=31 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 5/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=9m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=0.3470441865160976 --order_type=taker --sell_stop_pct=0 --buy_stop_pct=0 --profit_stop_enable_pct=6 --profit_stop_pct=14 --trend_ema=20 --oversold_rsi_periods=18 --oversold_rsi=29 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 6/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=39m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=4.2701038389297015 --order_type=maker --sell_stop_pct=49 --buy_stop_pct=0 --profit_stop_enable_pct=0 --profit_stop_pct=17 --trend_ema=20 --oversold_rsi_periods=23 --oversold_rsi=24 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 7/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=20m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=3.260455882341361 --order_type=maker --sell_stop_pct=0 --buy_stop_pct=6 --profit_stop_enable_pct=19 --profit_stop_pct=8 --trend_ema=20 --oversold_rsi_periods=25 --oversold_rsi=33 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 8/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=18m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=0.2856642972225938 --order_type=maker --sell_stop_pct=45 --buy_stop_pct=0 --profit_stop_enable_pct=8 --profit_stop_pct=11 --trend_ema=20 --oversold_rsi_periods=21 --oversold_rsi=34 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none

Generation complete, saving results...
> Finished writing generation csv to simulations/backtesting_1516379625.csv
> Finished writing generation json to simulations/generation_data_1516379625_gen_1.json


Generation's Best Results
	(trend_ema) Sim Fitness -0.0406, VS Buy and Hold: -4.06 End Balance: 1000, Wins/Losses 0/0.
./zenbot.sh sim gdax.BTC-USD --avg_slippage_pct=0.045 --buy_stop_pct=19 --markdown_buy_pct=4.1 --markup_sell_pct=1.5539857101908812 --max_sell_loss_pct=25 --max_slippage_pct=5 --min_periods=2 --neutral_rate=auto --order_type=maker --oversold_rsi=22 --oversold_rsi_periods=20 --period=22m --period_length=22m --profit_stop_enable_pct=0 --profit_stop_pct=8 --rsi_periods=20 --sell_stop_pct=39 --strategy=trend_ema --trend_ema=20 --start=201801170700 --asset_capital=0 --currency_capital=1000



=== Simulating generation 2 ===

Backfilling (might take some time) ...
./zenbot.sh backfill --days=1 gdax.BTC-USD
[ 1/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=39m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=4.2701038389297015 --order_type=maker --sell_stop_pct=49 --buy_stop_pct=0 --profit_stop_enable_pct=0 --profit_stop_pct=17 --trend_ema=20 --oversold_rsi_periods=23 --oversold_rsi=24 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 2/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=39m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=4.2701038389297015 --order_type=maker --sell_stop_pct=49 --buy_stop_pct=0 --profit_stop_enable_pct=0 --profit_stop_pct=17 --trend_ema=20 --oversold_rsi_periods=23 --oversold_rsi=24 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 3/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=97m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=3.6750922758126947 --order_type=maker --sell_stop_pct=2 --buy_stop_pct=0 --profit_stop_enable_pct=12 --profit_stop_pct=15 --trend_ema=20 --oversold_rsi_periods=19 --oversold_rsi=21 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 4/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=97m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=3.6750922758126947 --order_type=maker --sell_stop_pct=2 --buy_stop_pct=0 --profit_stop_enable_pct=12 --profit_stop_pct=15 --trend_ema=20 --oversold_rsi_periods=19 --oversold_rsi=21 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 5/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=20m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=3.260455882341361 --order_type=maker --sell_stop_pct=0 --buy_stop_pct=6 --profit_stop_enable_pct=19 --profit_stop_pct=8 --trend_ema=20 --oversold_rsi_periods=25 --oversold_rsi=33 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 6/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=20m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=3.260455882341361 --order_type=maker --sell_stop_pct=4 --buy_stop_pct=11 --profit_stop_enable_pct=15 --profit_stop_pct=8 --trend_ema=20 --oversold_rsi_periods=25 --oversold_rsi=33 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 7/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=22m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=1.5539857101908812 --order_type=maker --sell_stop_pct=39 --buy_stop_pct=19 --profit_stop_enable_pct=0 --profit_stop_pct=8 --trend_ema=20 --oversold_rsi_periods=20 --oversold_rsi=22 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 8/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=22m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=1.5539857101908812 --order_type=maker --sell_stop_pct=49 --buy_stop_pct=19 --profit_stop_enable_pct=0 --profit_stop_pct=17 --trend_ema=20 --oversold_rsi_periods=20 --oversold_rsi=22 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none

Generation complete, saving results...
> Finished writing generation csv to simulations/backtesting_1516379665.csv
> Finished writing generation json to simulations/generation_data_1516379665_gen_2.json


Generation's Best Results
	(trend_ema) Sim Fitness -0.0404, VS Buy and Hold: -4.04 End Balance: 1000, Wins/Losses 0/0.
./zenbot.sh sim gdax.BTC-USD --avg_slippage_pct=0.045 --buy_stop_pct=0 --markdown_buy_pct=4.1 --markup_sell_pct=4.2701038389297015 --max_sell_loss_pct=25 --max_slippage_pct=5 --min_periods=2 --neutral_rate=auto --order_type=maker --oversold_rsi=24 --oversold_rsi_periods=23 --period=39m --period_length=39m --profit_stop_enable_pct=0 --profit_stop_pct=17 --rsi_periods=23 --sell_stop_pct=49 --strategy=trend_ema --trend_ema=20 --start=201801170700 --asset_capital=0 --currency_capital=1000



=== Simulating generation 3 ===

Backfilling (might take some time) ...
./zenbot.sh backfill --days=1 gdax.BTC-USD
[ 1/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=97m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=3.6750922758126947 --order_type=maker --sell_stop_pct=2 --buy_stop_pct=0 --profit_stop_enable_pct=12 --profit_stop_pct=15 --trend_ema=20 --oversold_rsi_periods=19 --oversold_rsi=21 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 2/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=97m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=3.9296683966154884 --order_type=maker --sell_stop_pct=2 --buy_stop_pct=5 --profit_stop_enable_pct=12 --profit_stop_pct=15 --trend_ema=20 --oversold_rsi_periods=20 --oversold_rsi=21 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 3/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=22m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=1.5539857101908812 --order_type=maker --sell_stop_pct=49 --buy_stop_pct=19 --profit_stop_enable_pct=0 --profit_stop_pct=17 --trend_ema=20 --oversold_rsi_periods=20 --oversold_rsi=22 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 4/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=22m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=1.5539857101908812 --order_type=maker --sell_stop_pct=49 --buy_stop_pct=19 --profit_stop_enable_pct=12 --profit_stop_pct=15 --trend_ema=20 --oversold_rsi_periods=19 --oversold_rsi=21 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 5/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=22m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=1.5539857101908812 --order_type=maker --sell_stop_pct=39 --buy_stop_pct=19 --profit_stop_enable_pct=0 --profit_stop_pct=8 --trend_ema=20 --oversold_rsi_periods=20 --oversold_rsi=22 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 6/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=20m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=3.260455882341361 --order_type=maker --sell_stop_pct=39 --buy_stop_pct=11 --profit_stop_enable_pct=15 --profit_stop_pct=8 --trend_ema=20 --oversold_rsi_periods=20 --oversold_rsi=33 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 7/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=20m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=3.260455882341361 --order_type=maker --sell_stop_pct=4 --buy_stop_pct=11 --profit_stop_enable_pct=15 --profit_stop_pct=8 --trend_ema=20 --oversold_rsi_periods=25 --oversold_rsi=33 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none
[ 8/8 ] ./zenbot.sh sim gdax.BTC-USD --period_length=20m --min_periods=2 --markdown_buy_pct=4.1 --markup_sell_pct=3.260455882341361 --order_type=maker --sell_stop_pct=2 --buy_stop_pct=0 --profit_stop_enable_pct=12 --profit_stop_pct=15 --trend_ema=20 --oversold_rsi_periods=19 --oversold_rsi=33 --strategy=trend_ema --currency_capital=1000 --asset_capital=0 --period=60m --days=1 --filename=none

Generation complete, saving results...
> Finished writing generation csv to simulations/backtesting_1516379704.csv
> Finished writing generation json to simulations/generation_data_1516379704_gen_3.json


Generation's Best Results
	(trend_ema) Sim Fitness -0.0404, VS Buy and Hold: -4.04 End Balance: 1000, Wins/Losses 0/0.
./zenbot.sh sim gdax.BTC-USD --avg_slippage_pct=0.045 --buy_stop_pct=0 --markdown_buy_pct=4.1 --markup_sell_pct=3.6750922758126947 --max_sell_loss_pct=25 --max_slippage_pct=5 --min_periods=2 --neutral_rate=auto --order_type=maker --oversold_rsi=21 --oversold_rsi_periods=19 --period=97m --period_length=97m --profit_stop_enable_pct=12 --profit_stop_pct=15 --rsi_periods=19 --sell_stop_pct=2 --strategy=trend_ema --trend_ema=20 --start=201801170700 --asset_capital=0 --currency_capital=1000

There you can see since I've passed --markdown_buy_pct=4.1 --min_periods=2 into the original command, those get passed along to the inner commands and they never evolve or mutate.

Also incidentally the change on line 613 fixes a bug in the current unstable branch where the "Best Results" would have an "undefined" in it:

Generation's Best Results
	(macd) Sim Fitness 1.234, VS Buy and Hold: 297.69 End Balance: 256.28946, Wins/Losses 2/1.
./zenbot.sh sim undefined --days=1...

Copy link
Owner

@DeviaVir DeviaVir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your changes make a lot of sense, I'll pull them in if I don't see negative comments.

@station384
Copy link
Contributor

station384 commented Jan 20, 2018

You beat me to the this 👍, I was in the process of doing something similar to this.

The only addition to this I was trying to add as well as it being sticky, was to allow passing in ranges, so for example

This would be a constant, like yours
--avg_slippage_pct=0.045

this would be dynamic allowing overriding of the constants in the code, but still participating in the mutations
--avg_slippage_pct=$RangeFloat(0,0.5)

@DeviaVir DeviaVir merged commit 3c9959d into DeviaVir:unstable Jan 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants