internal double BetIt(Solution solution, double bankroll, double minPercentAdvantage, ref int numberOfBetsFound) { double totalWeight = 0; foreach (var horse in _horse) { horse.AssignWeight(solution.Weights); totalWeight += horse.Weight; } double bettingResult = 0.0; foreach (var horse in _horse) { horse.ProbabilityToWin = horse.Weight/totalWeight; if(horse.IsOverlayByThisMargin(minPercentAdvantage)) { double amountToBet = bankroll*minPercentAdvantage; amountToBet = 10; bettingResult = horse.IsWinner ? amountToBet : (-1.0)*amountToBet; if (horse.IsWinner) { ++numberOfBetsFound; } break; } } return bettingResult; }
public BackTester(Solution s, double bankroll, int numberOfRaces, int minAdvantage) { _solution = s; _bankroll = bankroll; _numberOfRaces = numberOfRaces; _minAdvantage = minAdvantage; }
public void UpdatePartitions(Solution solution) { AssignProbabilities(solution); _horse.ForEach(h => { if (h.IsWinner) solution.Partitions[h.Weight].IncreaseWinners(); else solution.Partitions[h.Weight].IncreaseCount(); } ); }
private Solution(Solution s1, Solution s2) { _weights = new List<double>(); int crossOverPoint = Randomizer.GetNextInteger(0, s1._weights.Count); for (int i = 0; i < s1._weights.Count; ++i) { List<double> l = i <= crossOverPoint ? s1._weights : s2._weights; _weights.Add(l[i]); } }
internal double CalculateReturn(Solution solution) { double bankroll = _horse.Count * (1.0); double totalWeight = 0.0; foreach (var horse in _horse) { horse.AssignWeight(solution.Weights); totalWeight += horse.Weight; } foreach (var horse in _horse) { if (horse.IsWinner) { bankroll = totalWeight / horse.Weight - bankroll; } } return bankroll; }
private void AssignProbabilities(Solution solution) { _horse.ForEach(horse => horse.AssignWeight(solution.Weights)); double totalWeight = 0; _horse.ForEach(horse => totalWeight += horse.Weight); _horse.ForEach(horse=>horse.ProbabilityToWin = horse.Weight / totalWeight); }
public BackTestForm(Solution s) { _solution = s; InitializeComponent(); }
internal static Solution CrossOver(Solution s1, Solution s2) { return new Solution(s1,s2); }