FastQuant.ExecutionSimulator.FillWithBar C# (CSharp) Méthode

FillWithBar() private méthode

private FillWithBar ( Order order, Bar bar ) : bool
order Order
bar Bar
Résultat bool
        private bool FillWithBar(Order order, Bar bar)
        {
            while (true)
            {
                switch (order.Type)
                {
                    case OrderType.Market:
                    case OrderType.Pegged:
                        goto IL_1A6;
                    case OrderType.Stop:
                        switch (order.Side)
                        {
                            case OrderSide.Buy:
                                if (bar.High >= order.StopPx)
                                {
                                    if (!FillAtStopPrice)
                                    {
                                        order.Type = OrderType.Market;
                                        continue;
                                    }
                                    goto IL_DA;
                                }
                                break;
                            case OrderSide.Sell:
                                if (bar.Low <= order.StopPx)
                                {
                                    if (!FillAtStopPrice)
                                    {
                                        order.Type = OrderType.Market;
                                        continue;
                                    }
                                    goto IL_F0;
                                }
                                break;
                        }
                        break;
                    case OrderType.Limit:
                        goto IL_106;
                    case OrderType.StopLimit:
                        switch (order.Side)
                        {
                            case OrderSide.Buy:
                                if (bar.High >= order.StopPx)
                                {
                                    order.Type = OrderType.Limit;
                                    continue;
                                }
                                break;
                            case OrderSide.Sell:
                                if (bar.Low <= order.StopPx)
                                {
                                    order.Type = OrderType.Limit;
                                    continue;
                                }
                                break;
                        }
                        break;
                }
                break;
            }
            return false;
            IL_DA:
            this.Fill(order, order.StopPx, (int)bar.Volume);
            return true;
            IL_F0:
            this.Fill(order, order.StopPx, (int)bar.Volume);
            return true;
            IL_106:
            switch (order.Side)
            {
                case OrderSide.Buy:
                    if (bar.Low <= order.Price)
                    {
                        Fill(order, FillAtLimitPrice ? order.Price : bar.Close, (int) bar.Volume);
                        return true;
                    }
                    break;
                case OrderSide.Sell:
                    if (bar.High >= order.Price)
                    {
                        Fill(order, FillAtLimitPrice ? order.Price : bar.Close, (int) bar.Volume);
                        return true;
                    }
                    break;
            }
            return false;
            IL_1A6:
            this.Fill(order, bar.Close, (int)bar.Volume);
            return true;
        }