FastQuant.Statistics.Drawdown.OnEquity C# (CSharp) Method

OnEquity() protected method

protected OnEquity ( double equity ) : void
equity double
return void
        protected internal override void OnEquity(double equity)
        {
            if (this.longAccValue == 0 && this.shortAccValue == 0)
                this.longAccValue = this.shortAccValue = this.portfolio.AccountValue;

            var longValue = this.longAccValue;
            var shortValue = this.shortAccValue;
            foreach (var position in this.portfolio.Positions)
            {
                var value = position.Value;
                if (position.Side == PositionSide.Long)
                    longValue += value;
                else
                    shortValue -= value;
            }
            this.longEquityMax = Max(longValue, this.longEquityMax);
            this.shortEquityMax = Max(shortValue, this.shortEquityMax);
            this.totalEquityMax = Max(equity, this.totalEquityMax);
            this.longValue = longValue - this.longEquityMax;
            this.shortValue = shortValue - this.shortEquityMax;
            this.totalValue = equity - this.totalEquityMax;
            LongValues.Add(Clock.DateTime, this.longValue);
            ShortValues.Add(Clock.DateTime, this.shortValue);
            TotalValues.Add(Clock.DateTime, this.totalValue);
            Emit();
        }