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

Cci backtest support #377

Merged
merged 2 commits into from
Jul 10, 2017
Merged
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
30 changes: 29 additions & 1 deletion scripts/auto_backtester/backtester.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* EMA Parameters: "trend_ema", "neutral_rate"
* RSI Parameters: "oversold_rsi", "oversold_rsi_periods"
*
* Example: ./backtester.js gdax.ETH-USD --days=10 --currency_capital=5 --period=1m
* Example: ./backtester.js gdax.ETH-USD --days=10 --currency_capital=5
*/

let shell = require('shelljs');
Expand Down Expand Up @@ -72,6 +72,7 @@ let objectProduct = obj => {
let runCommand = (strategy, cb) => {
countArr.push(1);
let strategyArgs = {
cci_srsi: `--cci_periods=${strategy.rsi_periods} --rsi_periods=${strategy.srsi_periods} --srsi_periods=${strategy.srsi_periods} --srsi_k=${strategy.srsi_k} --srsi_d=${strategy.srsi_d} --oversold_rsi=${strategy.oversold_rsi} --overbought_rsi=${strategy.overbought_rsi} --oversold_cci=${strategy.oversold_cci} --overbought_cci=${strategy.overbought_cci} --constant=${strategy.constant}`,
srsi_macd: `--rsi_periods=${strategy.rsi_periods} --srsi_periods=${strategy.srsi_periods} --srsi_k=${strategy.srsi_k} --srsi_d=${strategy.srsi_d} --oversold_rsi=${strategy.oversold_rsi} --overbought_rsi=${strategy.overbought_rsi} --ema_short_period=${strategy.ema_short_period} --ema_long_period=${strategy.ema_long_period} --signal_period=${strategy.signal_period} --up_trend_threshold=${strategy.up_trend_threshold} --down_trend_threshold=${strategy.down_trend_threshold}`,
macd: `--ema_short_period=${strategy.ema_short_period} --ema_long_period=${strategy.ema_long_period} --signal_period=${strategy.signal_period} --up_trend_threshold=${strategy.up_trend_threshold} --down_trend_threshold=${strategy.down_trend_threshold} --overbought_rsi_periods=${strategy.overbought_rsi_periods} --overbought_rsi=${strategy.overbought_rsi}`,
rsi: `--rsi_periods=${strategy.rsi_periods} --oversold_rsi=${strategy.oversold_rsi} --overbought_rsi=${strategy.overbought_rsi} --rsi_recover=${strategy.rsi_recover} --rsi_drop=${strategy.rsi_drop} --rsi_divisor=${strategy.rsi_divisor}`,
Expand Down Expand Up @@ -127,6 +128,18 @@ let processOutput = output => {
losses: losses,
errorRate: parseFloat(errorRate),

// cci_srsi
cciPeriods: params.cci_periods,
rsiPeriods: params.rsi_periods,
srsiPeriods: params.srsi_periods,
srsiK: params.srsi_k,
srsiD: params.srsi_d,
oversoldRsi: params.oversold_rsi,
overboughtRsi: params.overbought_rsi,
oversoldCci: params.oversold_cci,
overboughtCci: params.overbought_cci,
constant: params.consant,

// srsi_macd
rsiPeriods: params.rsi_periods,
srsiPeriods: params.srsi_periods,
Expand Down Expand Up @@ -181,6 +194,19 @@ let processOutput = output => {
};

let strategies = {
cci_srsi: objectProduct({
period: ['20m'],
min_periods: [52, 200],
rsi_periods: [14, 20],
srsi_periods: [14, 20],
srsi_k: [3, 9],
srsi_d: [3, 9],
oversold_rsi: [22],
overbought_rsi: [85],
oversold_cci: [-90],
overbought_cci: [140],
constant: [0.015]
}),
srsi_macd: objectProduct({
period: ['30m'],
min_periods: [52, 200],
Expand Down Expand Up @@ -269,6 +295,7 @@ parallel(tasks, PARALLEL_LIMIT, (err, results) => {
let filedsGeneral = ['roi', 'vsBuyHold', 'errorRate', 'wlRatio', 'frequency', 'endBalance', 'buyHold', 'wins', 'losses', 'period', 'min_periods', 'days'];
let filedNamesGeneral = ['ROI (%)', 'VS Buy Hold (%)', 'Error Rate (%)', 'Win/Loss Ratio', '# Trades/Day', 'Ending Balance ($)', 'Buy Hold ($)', '# Wins', '# Losses', 'Period', 'Min Periods', '# Days'];
let fields = {
cci_srsi: filedsGeneral.concat(['cciPeriods', 'rsiPeriods', 'srsiPeriods', 'srsiK', 'srsiD', 'oversoldRsi', 'overboughtRsi', 'oversoldCci', 'overboughtCci', 'Constant', 'params']),
srsi_macd: filedsGeneral.concat(['rsiPeriods', 'srsiPeriods', 'srsiK', 'srsiD', 'oversoldRsi', 'overboughtRsi', 'emaShortPeriod', 'emaLongPeriod', 'signalPeriod', 'upTrendThreshold', 'downTrendThreshold', 'params']),
macd: filedsGeneral.concat([ 'emaShortPeriod', 'emaLongPeriod', 'signalPeriod', 'upTrendThreshold', 'downTrendThreshold', 'overboughtRsiPeriods', 'overboughtRsi', 'params']),
rsi: filedsGeneral.concat(['rsiPeriods', 'oversoldRsi', 'overboughtRsi', 'rsiRecover', 'rsiDrop', 'rsiDivsor', 'params']),
Expand All @@ -277,6 +304,7 @@ parallel(tasks, PARALLEL_LIMIT, (err, results) => {
trend_ema: filedsGeneral.concat(['trendEma', 'neutralRate', 'oversoldRsiPeriods', 'oversoldRsi', 'params'])
};
let fieldNames = {
cci_srsi: filedNamesGeneral.concat(['CCI Periods', 'RSI Periods', 'SRSI Periods', 'SRSI K', 'SRSI D', 'Oversold RSI', 'Overbought RSI', 'Oversold CCI', 'Overbought CCI', 'Constant', 'Full Parameters']),
srsi_macd: filedNamesGeneral.concat(['RSI Periods', 'SRSI Periods', 'SRSI K', 'SRSI D', 'Oversold RSI', 'Overbought RSI', 'EMA Short Period', 'EMA Long Period', 'Signal Period', 'Up Trend Threshold', 'Down Trend Threshold', 'Full Parameters']),
macd: filedNamesGeneral.concat(['EMA Short Period', 'EMA Long Period', 'Signal Period', 'Up Trend Threshold', 'Down Trend Threshold', 'Overbought Rsi Periods', 'Overbought Rsi', 'Full Parameters']),
rsi: filedNamesGeneral.concat(['RSI Periods', 'Oversold RSI', 'Overbought RSI', 'RSI Recover', 'RSI Drop', 'RSI Divisor', 'Full Parameters']),
Expand Down