Skip to content

Commit

Permalink
feat: add jumpAuto config
Browse files Browse the repository at this point in the history
  • Loading branch information
Cedric-ruiu committed Sep 25, 2021
1 parent 80bf4f2 commit ee6319c
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 14 deletions.
33 changes: 19 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ If the backtest evaluation is not satisfactory, you can change parameter, indica
|------|------|---------|----------|-------------|
| `jumpTestAfterStart` | integer | `0` | cumulative | (1*) start backtests after a specific number of tests (useful if script has been stop and restart it) |
| `jumpParamNumber` | boolean/integer | `false` | cumulative | by default this is the last active parameter who have jump processed, provide a number to choose another parameter |
| `jumpTestsParamByTrade` | boolean / integer | `false` | 0 | (2*) if a test <= "x" trade, it **jump all following** cursor tests in the last parameter. (ex: set to 0 useful for Orderflow) |
| `jumpTestsParamByEarning` | boolean / integer | `false` | 1 | (2*) if a test <= "x" earning, it **jump all following** cursor tests in the last parameter. (ex: set to -1000 useful for bad series) |
| `jump3TestByEarning` | boolean / integer | `false` | 2 | (2*) if a test <= "x" earning, it **jump 3** next cursor tests in the last parameter |
| `jump2TestByEarning` | boolean / integer | `false` | 3 | (2*) if a test <= "x" earning, it **jump 2** next cursor tests in the last parameter |
| `jump1TestByEarning` | boolean / integer | `false` | 4 | (2*) if a test <= "x" earning, it **jump one** next cursor test in the last parameter |
| `jumpTestByTrade` | boolean / integer | `false` | 5 | (2*) if a test <= "x" trade, it **jump one** next cursor test in the last parameter |
| `jumpTestByWinrate` | boolean / integer | `false` | 6 | (2*) if a test <= "x" winrate, it **jump one** next cursor test in the last parameter |
| `jumpAutoSeries` | boolean | `false` | cumulative | load `jumpTestsParamByTrade` & `jumpTestsParamByEarning` with auto values optimized for current timeframe |
| `jumpTestsParamByTrade` | boolean / integer | `false` or `int` provided by `jumpAutoSeries` | 0 | (2*) if a test <= "x" trade, it **jump all following** cursor tests in the last parameter. (ex: set to 0 useful for Orderflow) |
| `jumpTestsParamByEarning` | boolean / integer | `false` or `int` provided by `jumpAutoSeries` | 1 | (2*) if a test <= "x" earning, it **jump all following** cursor tests in the last parameter. (ex: set to -1000 useful for bad series) |
| `jumpAuto` | boolean | `true` | cumulative | load `jump3TestByEarning`, `jump2TestByEarning`, `jump1TestByEarning`, `jumpTestByTrade` & `jumpTestByWinrate` with auto values optimized for current timeframe |
| `jump3TestByEarning` | boolean / integer | `false` or `int` provided by `jumpAuto` | 2 | (2*) if a test <= "x" earning, it **jump 3** next cursor tests in the last parameter |
| `jump2TestByEarning` | boolean / integer | `false` or `int` provided by `jumpAuto` | 3 | (2*) if a test <= "x" earning, it **jump 2** next cursor tests in the last parameter |
| `jump1TestByEarning` | boolean / integer | `false` or `int` provided by `jumpAuto` | 4 | (2*) if a test <= "x" earning, it **jump one** next cursor test in the last parameter |
| `jumpTestByTrade` | boolean / integer | `false` or `int` provided by `jumpAuto` | 5 | (2*) if a test <= "x" trade, it **jump one** next cursor test in the last parameter |
| `jumpTestByWinrate` | boolean / float | `false` or `float` provided by `jumpAuto` | 6 | (2*) if a test <= "x" winrate, it **jump one** next cursor test in the last parameter |
| `jumpTestByEarningMinus` | boolean / integer | `false` | 7 | (2*) if a test <= "x" earning and if it's smaller that the previous one, it **jump one** next cursor test in the last parameter |
| `debug` | boolean | `false` | cumulative | only to help debugging |

Expand All @@ -38,16 +40,19 @@ If the backtest evaluation is not satisfactory, you can change parameter, indica
(2*) : only work if the last non-ignored parameter is a slider or optionalSlider type. And non cumulative with other (2*).

```javascript
// Example with full global options
strat1.init({
jumpTestAfterStart: 2135,
jumpParamNumber: 4,
jumpTestsParamByTrade: 0,
jumpTestsParamByEarning: -1000,
jump3TestByEarning: -500,
jump2TestByEarning: -200,
jump1TestByEarning: -50,
jumpTestByTrade: 25,
jumpTestByWinrate: 50,
jumpAutoSeries: true, // override specific value you need
jumpTestsParamByTrade: 0, // override value from jumpAutoSeries
jumpTestsParamByEarning: -1000, // override value from jumpAutoSeries
// jumpAuto: true, // true by default, no need to fill it, override specific value you need
jump3TestByEarning: -500, // override value from jumpAuto
jump2TestByEarning: -200, // override value from jumpAuto
jump1TestByEarning: -50, // override value from jumpAuto
jumpTestByTrade: 25, // override value from jumpAuto
jumpTestByWinrate: 50, // override value from jumpAuto
jumpTestByEarningMinus: -200,
debug: true,
});
Expand Down
49 changes: 49 additions & 0 deletions src/Strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export class Strategy {
jumpParamNumber = false; // choose a specific param to jump, by default this is the last
jumpParamIndex = false; // save the parameter index who jump
jumpTestStack = 0; // current stacking jump test
jumpAuto = false;
jumpAutoSeries = false;
jumpTestsParamByTrade = false; // jump all following cursor test for last slider indic if trade === value
jumpTestsParamByEarning = false; // jump all following cursor test for last slider indic if earning smaller than value
jump3TestByEarning = false; // jump 3 tests by compare earning
Expand All @@ -39,6 +41,34 @@ export class Strategy {
dateEnd = 0;
started = false; // security check for a started BT

jumpAutoConfig = {
'5m': {
jump1TestByEarning: 0,
jump2TestByEarning: -1000,
jump3TestByEarning: -3500,
jumpTestByTrade: 20,
jumpTestByWinrate: 52,
},
'15m': {
jump1TestByEarning: 0,
jump2TestByEarning: -400,
jump3TestByEarning: -800,
jumpTestByTrade: 15,
jumpTestByWinrate: 52.5,
}
};

jumpAutoSeriesConfig = {
'5m': {
jumpTestsParamByTrade: 0,
jumpTestsParamByEarning: -5000,
},
'15m': {
jumpTestsParamByTrade: 0,
jumpTestsParamByEarning: -1200,
}
}

constructor(strategy = null) {
if (typeof strategy === 'number') {
this.strategy = document.querySelectorAll('.strategy')[strategy]
Expand Down Expand Up @@ -115,6 +145,14 @@ export class Strategy {
this.jumpTestStack += this.jumpTestAfterStart;
}

// auto jump series - disabled by default
if (typeof options.jumpAutoSeries !== 'undefined' && options.jumpAutoSeries) {
if (typeof this.jumpAutoSeriesConfig[this.infos.timeframe] !== 'undefined') {
options.jumpTestsParamByTrade = this.jumpAutoSeriesConfig[this.infos.timeframe].jumpTestsParamByTrade;
options.jumpTestsParamByEarning = this.jumpAutoSeriesConfig[this.infos.timeframe].jumpTestsParamByEarning;
}
}

if (typeof options.jumpTestsParamByTrade !== 'undefined') {
this.jumpTestsParamByTrade = options.jumpTestsParamByTrade;
this.jumpedTest.jumpTestsParamByTrade = 0;
Expand All @@ -125,6 +163,17 @@ export class Strategy {
this.jumpedTest.jumpTestsParamByEarning = 0;
}

// auto jump - enabled by default
if (typeof options.jumpAuto === 'undefined' || options.jumpAuto) {
if (typeof this.jumpAutoConfig[this.infos.timeframe] !== 'undefined') {
options.jump3TestByEarning = this.jumpAutoConfig[this.infos.timeframe].jump3TestByEarning;
options.jump2TestByEarning = this.jumpAutoConfig[this.infos.timeframe].jump2TestByEarning;
options.jump1TestByEarning = this.jumpAutoConfig[this.infos.timeframe].jump1TestByEarning;
options.jumpTestByTrade = this.jumpAutoConfig[this.infos.timeframe].jumpTestByTrade;
options.jumpTestByWinrate = this.jumpAutoConfig[this.infos.timeframe].jumpTestByWinrate;
}
}

if (typeof options.jump3TestByEarning !== 'undefined') {
this.jump3TestByEarning = options.jump3TestByEarning;
this.jumpedTest.jump3TestByEarning = 0;
Expand Down

0 comments on commit ee6319c

Please sign in to comment.