FastQuant.Statistics.ProfitFactor.OnStatistics C# (CSharp) Method

OnStatistics() protected method

protected OnStatistics ( PortfolioStatisticsItem statistics ) : void
statistics PortfolioStatisticsItem
return void
        protected internal override void OnStatistics(PortfolioStatisticsItem statistics)
        {
            bool changed = false;
            if (statistics.Type == PortfolioStatisticsType.GrossProfit)
            {
                this.grossProfit = statistics;
                changed = true;
            }
            if (statistics.Type == PortfolioStatisticsType.GrossLoss)
            {
                this.grossLoss = statistics;
                changed = true;
            }
            if (changed && this.grossProfit != null && this.grossLoss != null)
            {
                bool updated = false;
                if (this.grossLoss.LongValue != 0)
                {
                    this.longValue = this.grossProfit.LongValue / -this.grossLoss.LongValue;
                    LongValues.Add(base.Clock.DateTime, this.longValue);
                    updated = true;
                }
                if (this.grossLoss.ShortValue != 0)
                {
                    this.shortValue = this.grossProfit.ShortValue / -this.grossLoss.ShortValue;
                    ShortValues.Add(Clock.DateTime, this.shortValue);
                    updated = true;
                }
                if (this.grossLoss.TotalValue != 0.0)
                {
                    this.totalValue = this.grossProfit.TotalValue / -this.grossLoss.TotalValue;
                    TotalValues.Add(Clock.DateTime, this.totalValue);
                    updated = true;
                }
                if (updated)
                {
                    Emit();
                }
            }
        }