FastQuant.Position.method_0 C# (CSharp) Method

method_0() private method

private method_0 ( FastQuant.Fill fill_1 ) : void
fill_1 FastQuant.Fill
return void
        private void method_0(Fill fill_1)
        {
            if (Amount == 0)
            {
                this.double_3 = fill_1.Value;
                AvgPx = fill_1.Price;
                return;
            }
            if ((Side == PositionSide.Long && fill_1.Side == OrderSide.Buy) || (this.Side == PositionSide.Short && fill_1.Side == OrderSide.Sell))
            {
                this.double_3 += fill_1.Value;
                if (Instrument.Factor != 0)
                {
                    AvgPx = this.double_3 / (this.Qty + fill_1.Qty) / Instrument.Factor;
                    return;
                }
                AvgPx = this.double_3 / (this.Qty + fill_1.Qty);
                return;
            }
            else
            {
                if (this.Qty == fill_1.Qty)
                {
                    PnL += this.method_2(fill_1.Price, fill_1.Qty);
                    this.double_3 = 0.0;
                    this.AvgPx = 0.0;
                    return;
                }
                if (this.Qty > fill_1.Qty)
                {
                    PnL += this.method_2(fill_1.Price, fill_1.Qty);
                    this.double_3 -= this.method_1(fill_1.Qty * this.AvgPx);
                    return;
                }
                PnL += this.method_2(fill_1.Price, this.Qty);
                double num = fill_1.Qty - this.Qty;
                this.double_3 = this.method_1(num * fill_1.Price);
                if (Instrument.Factor != 0)
                {
                    this.AvgPx = this.double_3 / num / Instrument.Factor;
                    return;
                }
                this.AvgPx = this.double_3 / num;
                return;
            }
        }