public void UpdateGainLoss(Double purchaseValue, Double openValue, Double currentValue) { //update Portfolio Daily and Inception Gain/Loss values and percentages ProfitLoss dpl = EquityCalculator.GetProfitLoss(openValue, currentValue); ProfitLoss ipl = EquityCalculator.GetProfitLoss(purchaseValue, currentValue); _portfolioDayGainLoss = dpl.ValueChange; _portfolioDayGainLossPercent = dpl.PercentChange; _portfolioInceptionGainLoss = ipl.ValueChange; _portfolioInceptionGainLossPercent = ipl.PercentChange; }
private Decision MakeCallDecision(RiverDecisionContext context) { int chipsToCall = context.RiverRaiser.RiverBet - context.Hero.RiverBet; double potOdds = (double)chipsToCall / (context.CurrentPotSize + chipsToCall); var raiserRange = context.RiverRaiser.RiverRange; var equityCalculator = new EquityCalculator(new RiverFiveCardsEnumerator(context.RiverBoard)); var equity = equityCalculator.CalculateEquity(context.HeroHoles, raiserRange); Logger.Instance.Log($"Pot odds is {potOdds}, hero's equity is {equity} against raiser {context.RiverRaiser.Position}-{context.RiverRaiserName}'s range: {raiserRange.ToString()}"); if (equity <= potOdds) { Logger.Instance.Log($"Fold"); return(new Decision(DecisionType.Fold, 0)); } Logger.Instance.Log($"Call {chipsToCall} chips"); return(new Decision(DecisionType.Call, chipsToCall)); //todo: implement the reraise logic }
public void UpdateValues(Double openPrice, Double currentPrice) { //cacluate individual position daily and inception Gain/Loss values and percentages //keep track of direction of last trade for formatting purposes on UI ProfitLoss dpl = EquityCalculator.GetProfitLoss(openPrice, currentPrice); ProfitLoss ipl = EquityCalculator.GetProfitLoss(_purchasePrice, currentPrice); if (_dataLoaded) { if (_currentPrice < currentPrice) { _direction = 1; } else if (_currentPrice > currentPrice) { _direction = -1; } else { _direction = 0; } } _openPrice = openPrice; _currentPrice = currentPrice; _dayGainLoss = dpl.ValueChange; _dayGainLossPercentage = dpl.PercentChange; _dayGainLossTotal = _dayGainLoss * _quantity; _inceptionGainLoss = ipl.ValueChange; _inceptionGainLossPercentage = ipl.PercentChange; _inceptionGainLossTotal = _inceptionGainLoss * _quantity; _dataLoaded = true; }