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

fix phenotype win loss ratio weighting #1251

Merged
merged 1 commit into from Jan 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions scripts/genetic_backtester/phenotype.js
Expand Up @@ -70,9 +70,11 @@ module.exports = {
if (typeof phenotype.sim === 'undefined') return 0

var vsBuyHoldRate = (phenotype.sim.vsBuyHold / 50)
var wlRatio = phenotype.sim.wins - phenotype.sim.losses
// 2.71828 is https://en.wikipedia.org/wiki/E_(mathematical_constant)
var wlRatioRate = 1.0 / (1.0 + Math.pow(2.71828, wlRatio < 0 ? wlRatio:-(wlRatio)))
var wlRatio = phenotype.sim.wins / phenotype.sim.losses
if(isNaN(wlRatio)) { // zero trades will result in 0/0 which is NaN
wlRatio = 1
}
var wlRatioRate = 1.0 / (1.0 + Math.pow(Math.E, -wlRatio))
var rate = vsBuyHoldRate * (wlRatioRate)
return rate
},
Expand Down