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

Commit

Permalink
Fix bug where fitness function assigned higher fitness to worse resul…
Browse files Browse the repository at this point in the history
…ts. (#1043)

The fitness calculation does not appear to work correctly when win < loss AND buyvsHold value is negative. It results in a higher fitness value being assigned to worse results. In generation runs where ONLY negative results are returned, each subsequent generation gets progressively worse, not better. To test this I ran trend_ema, 60 days on cexio.ETH_USD and the results now assign the best fitness to the best result correctly, where it was incorrect before.
  • Loading branch information
ricktonoli authored and DeviaVir committed Jan 4, 2018
1 parent 7e40f02 commit fb8526b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/genetic_backtester/phenotype.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ module.exports = {
if (typeof phenotype.sim === 'undefined') return 0;

var vsBuyHoldRate = (phenotype.sim.vsBuyHold / 50);
var wlRatioRate = 1.0 / (1.0 + Math.pow(2.71828, -(phenotype.sim.wins - phenotype.sim.losses)));
var wlRatio = phenotype.sim.wins - phenotype.sim.losses
var wlRatioRate = 1.0 / (1.0 + Math.pow(2.71828, wlRatio < 0 ? wlRatio:-(wlRatio)));
var rate = vsBuyHoldRate * (wlRatioRate);
return rate;
},
Expand Down

0 comments on commit fb8526b

Please sign in to comment.