diff --git a/README.md b/README.md index 045d1319d5..dcc0bdfa9d 100644 --- a/README.md +++ b/README.md @@ -259,6 +259,16 @@ and also: ``` zenbot list-strategies +crossover_vwap + description: + Estimate trends by comparing "Volume Weighted Average Price" to the "Exponential Moving Average". + options: + --emalen1= Length of EMA 1 (default: 30) + --smalen1= Length of SMA 1 (default: 108) + --smalen2= Length of SMA 2 (default: 60) + --vwap_length= Min periods for vwap to start (default: 10) + --vwap_max= Max history for vwap. Increasing this makes it more sensitive to short-term changes (default: 8000) + forex_analytics description: Apply the trained forex analytics model. diff --git a/extensions/strategies/crossover_vwap/example_sims/index.html b/extensions/strategies/crossover_vwap/example_sims/index.html new file mode 100644 index 0000000000..888afde8bd --- /dev/null +++ b/extensions/strategies/crossover_vwap/example_sims/index.html @@ -0,0 +1,19 @@ + + + + +

VWAP Max (--vwap_max)

+ + + + + diff --git a/extensions/strategies/crossover_vwap/example_sims/main.css b/extensions/strategies/crossover_vwap/example_sims/main.css new file mode 100644 index 0000000000..d09f26f72b --- /dev/null +++ b/extensions/strategies/crossover_vwap/example_sims/main.css @@ -0,0 +1,284 @@ +html { + height: 100%; +} + +body { + font: 10px sans-serif; + background-color: #000000; + color: #fff; + position: relative; +} + +svg { + margin: 50px 0 0 0; + width: 100%; + height: auto; + z-index: 2; +} + +.axis path, +.axis line { + fill: none; + stroke: #444; + shape-rendering: crispEdges; +} + +.axis.x path { + stroke: none; +} + +text { + fill: #fff; +} + +text.symbol { + fill: #BBBBBB; +} + +path { + fill: none; + stroke-width: 1; +} + +path.candle { + stroke: #888; +} + +path.candle.up { + stroke: rgb(85, 255, 14); +} + +path.candle.down { + fill: rgb(232, 87, 35); + stroke: #944329; +} + +.close.annotation.up path { + stroke: #8ff; + stroke-width: 1; + fill: #8ff; +} + +.close.annotation.up text { + fill: #000; +} + +path.volume { + fill: #588bbd; +} + +.indicator-plot path.line { + fill: none; + stroke-width: 1; +} + +.ma-0 path.line { + stroke: #1f77b4; + stroke-width: 2; +} + +.ma-1 path.line { + stroke: #aec7e8; + stroke-width: 2; +} + +.ma-2 path.line { + stroke: #00ff65; + stroke-width: 2; +} + +.sma-0 path.line { + stroke: #ff0d6d; + stroke-width: 2; +} + +.sma-1 path.line { + stroke: #910eff; + stroke-width: 2; +} + +.indicator4 path.line { + stroke: gold; + stroke-width: 3; +} + +path.adx{ + stroke: #ff7f0e; +} + +button { + position: absolute; + right: 110px; + top: 25px; +} + +path.macd { + stroke: #a0f; +} + +path.signal { + stroke: #0f0; +} + +path.difference { + fill: #35474c; +} + +path.rsi { + stroke: #09d; +} + +path.overbought { + stroke: #9f9; + stroke-dasharray: 1, 5; +} + +path.oversold { + stroke: #f99; + stroke-dasharray: 1, 5; +} + +path.middle, path.zero { + stroke: #888; + stroke-opacity: 0.5; + stroke-dasharray: 1, 5; +} + +.analysis path, .analysis circle { + stroke: blue; + stroke-width: 0.8; +} + +.trendline circle { + stroke-width: 0; + display: none; +} + +.mouseover .trendline path { + stroke-width: 1.2; +} + +.mouseover .trendline circle { + stroke-width: 1; + display: inline; +} + +.dragging .trendline path, .dragging .trendline circle { + stroke: darkblue; +} + +.interaction path, .interaction circle { + pointer-events: all; +} + +.interaction .body { + cursor: move; +} + +.trendlines .interaction .start, .trendlines .interaction .end { + cursor: nwse-resize; +} + +.supstance path { + stroke-dasharray: 2, 2; +} + +.supstances .interaction path { + pointer-events: all; + cursor: ns-resize; +} + +.mouseover .supstance path { + stroke-width: 1.5; +} + +.dragging .supstance path { + stroke: darkblue; +} + +.crosshair { + cursor: crosshair; +} + +.crosshair path.wire { + stroke: #fff; + stroke-opacity: 0.5; + stroke-dasharray: 1, 5; +} + +.crosshair .axisannotation path { + fill: #000; + stroke: #fff; +} + +.axisannotation.y path { + stroke: #fff; +} + +.tradearrow path.tradearrow { + stroke: none; +} + +.tradearrow path.buy { + fill: #00ff87; +} + +.tradearrow path.sell { + fill: #ff0000; +} + +.tradearrow path.highlight { + fill: none; + stroke-width: 2; +} + +.tradearrow path.highlight.buy { + stroke: #0000FF; +} + +.tradearrow path.highlight.sell { + stroke: #9900FF; +} + +.loading { + width: 50%; + height: 50%; + overflow: auto; + margin: auto; + position: absolute; + top: 0; left: 0; bottom: 0; right: 0; + text-align: center; + font-size: 80px; + z-index: 1; + color: #888; +} + +.no-data { + display: none; + color: #888; + font-size: 80px; + text-align: center; +} + +.options { + position: absolute; + top: 20px; + left: 20px; + z-index: 3; +} + +.footer { + position: fixed; + right: 20px; + bottom: 20px; + color: #aac; + font-size: 1.2em; +} + +.footer a { + color: cyan; + text-decoration: none; +} +pre { + font-size: 2em; +} \ No newline at end of file diff --git a/extensions/strategies/crossover_vwap/example_sims/vwapmax0.html b/extensions/strategies/crossover_vwap/example_sims/vwapmax0.html new file mode 100644 index 0000000000..6f5c6aea93 --- /dev/null +++ b/extensions/strategies/crossover_vwap/example_sims/vwapmax0.html @@ -0,0 +1,394 @@ + + + + + kraken.XXRP-ZEUR - zenbot 4.0.5 sim result + + + +
+ + + + + +
{
+  "asset_capital": 0,
+  "avg_slippage_pct": 0.045,
+  "buy_pct": 99,
+  "buy_stop_pct": 0,
+  "currency_capital": 700,
+  "days": 60,
+  "emalen1": 30,
+  "filename": "simulations/vwapmax0.html",
+  "markdown_buy_pct": 0.5,
+  "markup_sell_pct": 0.5,
+  "max_sell_loss_pct": 25,
+  "max_slippage_pct": "100",
+  "min_periods": 1,
+  "mode": "sim",
+  "order_adjust_time": 5000,
+  "order_type": "maker",
+  "period": "120m",
+  "profit_stop_enable_pct": 0,
+  "profit_stop_pct": 1,
+  "rsi_periods": 14,
+  "selector": "kraken.XXRP-ZEUR",
+  "sell_pct": 99,
+  "sell_stop_pct": 0,
+  "show_options": true,
+  "smalen1": 108,
+  "smalen2": 60,
+  "start": 1507939200000,
+  "stats": false,
+  "strategy": "crossover_vwap",
+  "verbose": false,
+  "vwap_length": 10,
+  "vwap_max": 0
+}
+end balance: 1006.01715054 (43.72%)
+buy hold: 1261.79569400 (80.26%)
+vs. buy hold: -20.27%
+5 trades over 62 days (avg 0.08 trades/day)
+win/loss: 3/0
+error rate: 0.00%
+ + \ No newline at end of file diff --git a/extensions/strategies/crossover_vwap/example_sims/vwapmax10.html b/extensions/strategies/crossover_vwap/example_sims/vwapmax10.html new file mode 100644 index 0000000000..cd7586c644 --- /dev/null +++ b/extensions/strategies/crossover_vwap/example_sims/vwapmax10.html @@ -0,0 +1,394 @@ + + + + + kraken.XXRP-ZEUR - zenbot 4.0.5 sim result + + + +
+ + + + + +
{
+  "asset_capital": 0,
+  "avg_slippage_pct": 0.045,
+  "buy_pct": 99,
+  "buy_stop_pct": 0,
+  "currency_capital": 700,
+  "days": 60,
+  "emalen1": 30,
+  "filename": "simulations/vwapmax10.html",
+  "markdown_buy_pct": 0.5,
+  "markup_sell_pct": 0.5,
+  "max_sell_loss_pct": 25,
+  "max_slippage_pct": "100",
+  "min_periods": 1,
+  "mode": "sim",
+  "order_adjust_time": 5000,
+  "order_type": "maker",
+  "period": "120m",
+  "profit_stop_enable_pct": 0,
+  "profit_stop_pct": 1,
+  "rsi_periods": 14,
+  "selector": "kraken.XXRP-ZEUR",
+  "sell_pct": 99,
+  "sell_stop_pct": 0,
+  "show_options": true,
+  "smalen1": 108,
+  "smalen2": 60,
+  "start": 1507939200000,
+  "stats": false,
+  "strategy": "crossover_vwap",
+  "verbose": false,
+  "vwap_length": 10,
+  "vwap_max": 10
+}
+end balance: 1525.92919381 (117.99%)
+buy hold: 1261.79569400 (80.26%)
+vs. buy hold: 20.93%
+51 trades over 62 days (avg 0.82 trades/day)
+win/loss: 20/6
+error rate: 23.08%
+ + \ No newline at end of file diff --git a/extensions/strategies/crossover_vwap/example_sims/vwapmax100.html b/extensions/strategies/crossover_vwap/example_sims/vwapmax100.html new file mode 100644 index 0000000000..652f4dc1b8 --- /dev/null +++ b/extensions/strategies/crossover_vwap/example_sims/vwapmax100.html @@ -0,0 +1,394 @@ + + + + + kraken.XXRP-ZEUR - zenbot 4.0.5 sim result + + + +
+ + + + + +
{
+  "asset_capital": 0,
+  "avg_slippage_pct": 0.045,
+  "buy_pct": 99,
+  "buy_stop_pct": 0,
+  "currency_capital": 700,
+  "days": 60,
+  "emalen1": 30,
+  "filename": "simulations/vwapmax100.html",
+  "markdown_buy_pct": 0.5,
+  "markup_sell_pct": 0.5,
+  "max_sell_loss_pct": 25,
+  "max_slippage_pct": "100",
+  "min_periods": 1,
+  "mode": "sim",
+  "order_adjust_time": 5000,
+  "order_type": "maker",
+  "period": "120m",
+  "profit_stop_enable_pct": 0,
+  "profit_stop_pct": 1,
+  "rsi_periods": 14,
+  "selector": "kraken.XXRP-ZEUR",
+  "sell_pct": 99,
+  "sell_stop_pct": 0,
+  "show_options": true,
+  "smalen1": 108,
+  "smalen2": 60,
+  "start": 1507939200000,
+  "stats": false,
+  "strategy": "crossover_vwap",
+  "verbose": false,
+  "vwap_length": 10,
+  "vwap_max": 100
+}
+end balance: 1331.33355047 (90.19%)
+buy hold: 1261.79569400 (80.26%)
+vs. buy hold: 5.51%
+56 trades over 62 days (avg 0.90 trades/day)
+win/loss: 19/9
+error rate: 32.14%
+ + \ No newline at end of file diff --git a/extensions/strategies/crossover_vwap/example_sims/vwapmax1000.html b/extensions/strategies/crossover_vwap/example_sims/vwapmax1000.html new file mode 100644 index 0000000000..face6532ef --- /dev/null +++ b/extensions/strategies/crossover_vwap/example_sims/vwapmax1000.html @@ -0,0 +1,394 @@ + + + + + kraken.XXRP-ZEUR - zenbot 4.0.5 sim result + + + +
+ + + + + +
{
+  "asset_capital": 0,
+  "avg_slippage_pct": 0.045,
+  "buy_pct": 99,
+  "buy_stop_pct": 0,
+  "currency_capital": 700,
+  "days": 60,
+  "emalen1": 30,
+  "filename": "simulations/vwapmax1000.html",
+  "markdown_buy_pct": 0.5,
+  "markup_sell_pct": 0.5,
+  "max_sell_loss_pct": 25,
+  "max_slippage_pct": "100",
+  "min_periods": 1,
+  "mode": "sim",
+  "order_adjust_time": 5000,
+  "order_type": "maker",
+  "period": "120m",
+  "profit_stop_enable_pct": 0,
+  "profit_stop_pct": 1,
+  "rsi_periods": 14,
+  "selector": "kraken.XXRP-ZEUR",
+  "sell_pct": 99,
+  "sell_stop_pct": 0,
+  "show_options": true,
+  "smalen1": 108,
+  "smalen2": 60,
+  "start": 1507939200000,
+  "stats": false,
+  "strategy": "crossover_vwap",
+  "verbose": false,
+  "vwap_length": 10,
+  "vwap_max": 1000
+}
+end balance: 1602.20161795 (128.89%)
+buy hold: 1261.79569400 (80.26%)
+vs. buy hold: 26.98%
+36 trades over 62 days (avg 0.58 trades/day)
+win/loss: 12/6
+error rate: 33.33%
+ + \ No newline at end of file diff --git a/extensions/strategies/crossover_vwap/example_sims/vwapmax10000.html b/extensions/strategies/crossover_vwap/example_sims/vwapmax10000.html new file mode 100644 index 0000000000..4a5e5a5556 --- /dev/null +++ b/extensions/strategies/crossover_vwap/example_sims/vwapmax10000.html @@ -0,0 +1,394 @@ + + + + + kraken.XXRP-ZEUR - zenbot 4.0.5 sim result + + + +
+ + + + + +
{
+  "asset_capital": 0,
+  "avg_slippage_pct": 0.045,
+  "buy_pct": 99,
+  "buy_stop_pct": 0,
+  "currency_capital": 700,
+  "days": 60,
+  "emalen1": 30,
+  "filename": "simulations/vwapmax10000.html",
+  "markdown_buy_pct": 0.5,
+  "markup_sell_pct": 0.5,
+  "max_sell_loss_pct": 25,
+  "max_slippage_pct": "100",
+  "min_periods": 1,
+  "mode": "sim",
+  "order_adjust_time": 5000,
+  "order_type": "maker",
+  "period": "120m",
+  "profit_stop_enable_pct": 0,
+  "profit_stop_pct": 1,
+  "rsi_periods": 14,
+  "selector": "kraken.XXRP-ZEUR",
+  "sell_pct": 99,
+  "sell_stop_pct": 0,
+  "show_options": true,
+  "smalen1": 108,
+  "smalen2": 60,
+  "start": 1507939200000,
+  "stats": false,
+  "strategy": "crossover_vwap",
+  "verbose": false,
+  "vwap_length": 10,
+  "vwap_max": 10000
+}
+end balance: 1469.07665511 (109.87%)
+buy hold: 1261.79569400 (80.26%)
+vs. buy hold: 16.43%
+19 trades over 62 days (avg 0.31 trades/day)
+win/loss: 3/6
+error rate: 66.67%
+ + \ No newline at end of file diff --git a/extensions/strategies/crossover_vwap/example_sims/vwapmax20000.html b/extensions/strategies/crossover_vwap/example_sims/vwapmax20000.html new file mode 100644 index 0000000000..d5a7412f7f --- /dev/null +++ b/extensions/strategies/crossover_vwap/example_sims/vwapmax20000.html @@ -0,0 +1,394 @@ + + + + + kraken.XXRP-ZEUR - zenbot 4.0.5 sim result + + + +
+ + + + + +
{
+  "asset_capital": 0,
+  "avg_slippage_pct": 0.045,
+  "buy_pct": 99,
+  "buy_stop_pct": 0,
+  "currency_capital": 700,
+  "days": 60,
+  "emalen1": 30,
+  "filename": "simulations/vwapmax20000.html",
+  "markdown_buy_pct": 0.5,
+  "markup_sell_pct": 0.5,
+  "max_sell_loss_pct": 25,
+  "max_slippage_pct": "100",
+  "min_periods": 1,
+  "mode": "sim",
+  "order_adjust_time": 5000,
+  "order_type": "maker",
+  "period": "120m",
+  "profit_stop_enable_pct": 0,
+  "profit_stop_pct": 1,
+  "rsi_periods": 14,
+  "selector": "kraken.XXRP-ZEUR",
+  "sell_pct": 99,
+  "sell_stop_pct": 0,
+  "show_options": true,
+  "smalen1": 108,
+  "smalen2": 60,
+  "start": 1507939200000,
+  "stats": false,
+  "strategy": "crossover_vwap",
+  "verbose": false,
+  "vwap_length": 10,
+  "vwap_max": 20000
+}
+end balance: 1164.18233610 (66.31%)
+buy hold: 1261.79569400 (80.26%)
+vs. buy hold: -7.74%
+20 trades over 62 days (avg 0.32 trades/day)
+win/loss: 2/7
+error rate: 77.78%
+ + \ No newline at end of file diff --git a/extensions/strategies/crossover_vwap/example_sims/vwapmax500.html b/extensions/strategies/crossover_vwap/example_sims/vwapmax500.html new file mode 100644 index 0000000000..174f987f86 --- /dev/null +++ b/extensions/strategies/crossover_vwap/example_sims/vwapmax500.html @@ -0,0 +1,394 @@ + + + + + kraken.XXRP-ZEUR - zenbot 4.0.5 sim result + + + +
+ + + + + +
{
+  "asset_capital": 0,
+  "avg_slippage_pct": 0.045,
+  "buy_pct": 99,
+  "buy_stop_pct": 0,
+  "currency_capital": 700,
+  "days": 60,
+  "emalen1": 30,
+  "filename": "simulations/vwapmax500.html",
+  "markdown_buy_pct": 0.5,
+  "markup_sell_pct": 0.5,
+  "max_sell_loss_pct": 25,
+  "max_slippage_pct": "100",
+  "min_periods": 1,
+  "mode": "sim",
+  "order_adjust_time": 5000,
+  "order_type": "maker",
+  "period": "120m",
+  "profit_stop_enable_pct": 0,
+  "profit_stop_pct": 1,
+  "rsi_periods": 14,
+  "selector": "kraken.XXRP-ZEUR",
+  "sell_pct": 99,
+  "sell_stop_pct": 0,
+  "show_options": true,
+  "smalen1": 108,
+  "smalen2": 60,
+  "start": 1507939200000,
+  "stats": false,
+  "strategy": "crossover_vwap",
+  "verbose": false,
+  "vwap_length": 10,
+  "vwap_max": 500
+}
+end balance: 1285.43743401 (83.63%)
+buy hold: 1261.79569400 (80.26%)
+vs. buy hold: 1.87%
+45 trades over 62 days (avg 0.73 trades/day)
+win/loss: 16/7
+error rate: 30.43%
+ + \ No newline at end of file diff --git a/extensions/strategies/crossover_vwap/example_sims/vwapmax5000.html b/extensions/strategies/crossover_vwap/example_sims/vwapmax5000.html new file mode 100644 index 0000000000..b69f585ea2 --- /dev/null +++ b/extensions/strategies/crossover_vwap/example_sims/vwapmax5000.html @@ -0,0 +1,394 @@ + + + + + kraken.XXRP-ZEUR - zenbot 4.0.5 sim result + + + +
+ + + + + +
{
+  "asset_capital": 0,
+  "avg_slippage_pct": 0.045,
+  "buy_pct": 99,
+  "buy_stop_pct": 0,
+  "currency_capital": 700,
+  "days": 60,
+  "emalen1": 30,
+  "filename": "simulations/vwapmax5000.html",
+  "markdown_buy_pct": 0.5,
+  "markup_sell_pct": 0.5,
+  "max_sell_loss_pct": 25,
+  "max_slippage_pct": "100",
+  "min_periods": 1,
+  "mode": "sim",
+  "order_adjust_time": 5000,
+  "order_type": "maker",
+  "period": "120m",
+  "profit_stop_enable_pct": 0,
+  "profit_stop_pct": 1,
+  "rsi_periods": 14,
+  "selector": "kraken.XXRP-ZEUR",
+  "sell_pct": 99,
+  "sell_stop_pct": 0,
+  "show_options": true,
+  "smalen1": 108,
+  "smalen2": 60,
+  "start": 1507939200000,
+  "stats": false,
+  "strategy": "crossover_vwap",
+  "verbose": false,
+  "vwap_length": 10,
+  "vwap_max": 5000
+}
+end balance: 1539.27499850 (119.90%)
+buy hold: 1261.79569400 (80.26%)
+vs. buy hold: 21.99%
+22 trades over 62 days (avg 0.35 trades/day)
+win/loss: 7/4
+error rate: 36.36%
+ + \ No newline at end of file diff --git a/extensions/strategies/crossover_vwap/strategy.js b/extensions/strategies/crossover_vwap/strategy.js index 7a8f128a2a..a3a11d223d 100644 --- a/extensions/strategies/crossover_vwap/strategy.js +++ b/extensions/strategies/crossover_vwap/strategy.js @@ -1,24 +1,24 @@ var z = require('zero-fill') , n = require('numbro') - //, fs = require('fs'), fs_started = false ; var data = ""; -/* -if(!fs_started) { - fs.appendFile('log.csv', 'pid'+','+'pOpen'+','+'pClose'+','+'emagreen'+','+'smapurple'+','+'smared'+'\n', (err)=>{}); - fs_started = true; -}//*/ module.exports = function container (get, set, clear) { return { name: 'crossover_vwap', - description: 'Testing indicator with vwap', + description: 'Estimate trends by comparing "Volume Weighted Average Price" to the "Exponential Moving Average".', - getOptions: function () { - // these are relative to period length. Good tests so far: period=5m or 90m - + getOptions: function () { // default start is 30, 108, 60. + // these are relative to period length. + + /* + Positive simulations during testing: + + zenbot sim kraken.XXRP-ZEUR --period="120m" --strategy=crossover_vwap --currency_capital=700 --asset_capital=0 --max_slippage_pct=100 --days=60 --avg_slippage_pct=0.045 --vwap_max=8000 --markup_sell_pct=0.5 --markdown_buy_pct=0.5 --emalen1=50 + zenbot sim kraken.XXRP-ZEUR --period="120m" --strategy=crossover_vwap --currency_capital=700 --asset_capital=0 --max_slippage_pct=100 --days=60 --avg_slippage_pct=0.045 --vwap_max=8000 --markup_sell_pct=0.5 --markdown_buy_pct=0.5 --emalen1=30 + */ this.option('emalen1', 'Length of EMA 1', Number, 30 )//green this.option('smalen1', 'Length of SMA 1', Number, 108 )//red this.option('smalen2', 'Length of SMA 2', Number, 60 )//purple @@ -26,13 +26,8 @@ module.exports = function container (get, set, clear) { this.option('vwap_max', 'Max history for vwap. Increasing this makes it more sensitive to short-term changes', Number, 8000)//gold }, - /* - zenbot sim kraken.XXRP-ZEUR --period="120m" --strategy=crossover_vwap --currency_capital=700 --asset_capital=0 --max_slippage_pct=100 --days=60 --avg_slippage_pct=0.045 --vwap_max=8000 --markup_sell_pct=0.5 --markdown_buy_pct=0.5 --emalen1=50 - zenbot sim kraken.XXRP-ZEUR --period="120m" --strategy=crossover_vwap --currency_capital=700 --asset_capital=0 --max_slippage_pct=100 --days=60 --avg_slippage_pct=0.045 --vwap_max=8000 --markup_sell_pct=0.5 --markdown_buy_pct=0.5 --emalen1=30 - */ + calculate: function (s) { - // compute MACD - //get('lib.ti_vwap')(s, 'vwap', s.options.vwap_len)//gold get('lib.vwap')(s, 'vwap', s.options.vwap_length, s.options.vwap_max)//gold get('lib.ema')(s, 'ema1', s.options.emalen1)//green diff --git a/scripts/genetic_backtester/darwin.js b/scripts/genetic_backtester/darwin.js index 39d420961f..a352eeff1e 100755 --- a/scripts/genetic_backtester/darwin.js +++ b/scripts/genetic_backtester/darwin.js @@ -40,6 +40,7 @@ let iterationCount = 0; let runCommand = (taskStrategyName, phenotype, cb) => { let commonArgs = `--strategy=${taskStrategyName} --period=${phenotype.period} --min_periods=${phenotype.min_periods} --markup_pct=${phenotype.markup_pct} --order_type=${phenotype.order_type} --sell_stop_pct=${phenotype.sell_stop_pct} --buy_stop_pct=${phenotype.buy_stop_pct} --profit_stop_enable_pct=${phenotype.profit_stop_enable_pct} --profit_stop_pct=${phenotype.profit_stop_pct}`; let strategyArgs = { + crossover_vwap: `--emalen1=${phenotype.emalen1} --vwap_length=${phenotype.vwap_length} --vwap_max=${phenotype.vwap_max}`, cci_srsi: `--cci_periods=${phenotype.rsi_periods} --rsi_periods=${phenotype.srsi_periods} --srsi_periods=${phenotype.srsi_periods} --srsi_k=${phenotype.srsi_k} --srsi_d=${phenotype.srsi_d} --oversold_rsi=${phenotype.oversold_rsi} --overbought_rsi=${phenotype.overbought_rsi} --oversold_cci=${phenotype.oversold_cci} --overbought_cci=${phenotype.overbought_cci} --constant=${phenotype.constant}`, srsi_macd: `--rsi_periods=${phenotype.rsi_periods} --srsi_periods=${phenotype.srsi_periods} --srsi_k=${phenotype.srsi_k} --srsi_d=${phenotype.srsi_d} --oversold_rsi=${phenotype.oversold_rsi} --overbought_rsi=${phenotype.overbought_rsi} --ema_short_period=${phenotype.ema_short_period} --ema_long_period=${phenotype.ema_long_period} --signal_period=${phenotype.signal_period} --up_trend_threshold=${phenotype.up_trend_threshold} --down_trend_threshold=${phenotype.down_trend_threshold}`, macd: `--ema_short_period=${phenotype.ema_short_period} --ema_long_period=${phenotype.ema_long_period} --signal_period=${phenotype.signal_period} --up_trend_threshold=${phenotype.up_trend_threshold} --down_trend_threshold=${phenotype.down_trend_threshold} --overbought_rsi_periods=${phenotype.overbought_rsi_periods} --overbought_rsi=${phenotype.overbought_rsi}`, @@ -176,6 +177,17 @@ let Range0 = (min, max) => { return r; }; +let RangeFactor = (min, max, factor) => { + var r = { + type: 'intfactor', + min: min, + max: max, + factor: factor + }; + return r; +}; + + let RangeFloat = (min, max) => { var r = { type: 'float', @@ -210,6 +222,22 @@ let RangeNeuralActivation = () => { }; let strategies = { + crossover_vwap: { + // -- common + period: RangePeriod(1, 200, 'm'), + min_periods: Range(1, 200), + markup_pct: RangeFloat(0, 5), + order_type: RangeMakerTaker(), + sell_stop_pct: Range0(1, 50), + buy_stop_pct: Range0(1, 50), + profit_stop_enable_pct: Range0(1, 20), + profit_stop_pct: Range(1,20), + + // -- strategy + emalen1: Range(1, 300), + vwap_length: Range(1, 200), + vwap_max: RangeFactor(0, 10000, 10)//0 disables this max cap. Test in increments of 10 + }, cci_srsi: { // -- common period: RangePeriod(1, 120, 'm'), diff --git a/scripts/genetic_backtester/phenotype.js b/scripts/genetic_backtester/phenotype.js index 699e2ac4f3..2eeff4629e 100644 --- a/scripts/genetic_backtester/phenotype.js +++ b/scripts/genetic_backtester/phenotype.js @@ -15,10 +15,14 @@ module.exports = { if (v.type === 'int') { r[k] = Math.floor((Math.random() * (v.max - v.min + 1)) + v.min); } else if (v.type === 'int0') { - r[k] = 0; - if (Math.random() >= 0.5) { - r[k] = Math.floor((Math.random() * (v.max - v.min + 1)) + v.min); - } + r[k] = 0; + if (Math.random() >= 0.5) { + r[k] = Math.floor((Math.random() * (v.max - v.min + 1)) + v.min); + } + } else if (v.type === 'intfactor') { + // possible 0 value by providing min 0 + if (v.min == 0 && Math.random() <= 0.5) r[k] = 0; + else r[k] = Math.round((Math.random() * (v.max - v.min + 1)/v.factor)*v.factor); } else if (v.type === 'float') { r[k] = (Math.random() * (v.max - v.min)) + v.min; } else if (v.type === 'makertaker') {