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

FillWithTrade() private méthode

private FillWithTrade ( Order order, Trade trade ) : bool
order Order
trade Trade
Résultat bool
        private bool FillWithTrade(Order order, Trade trade)
        {
            while (true)
            {
                switch (order.Type)
                {
                    case OrderType.Market:
                    case OrderType.Pegged:
                        this.Fill(order, trade.Price, trade.Size);
                        return true;
                    case OrderType.Stop:
                        switch (order.Side)
                        {
                            case OrderSide.Buy:
                                if (trade.Price >= order.StopPx)
                                {
                                    if (!FillAtStopPrice)
                                    {
                                        order.Type = OrderType.Market;
                                        continue;
                                    }
                                    goto IL_DA;
                                }
                                break;
                            case OrderSide.Sell:
                                if (trade.Price <= order.StopPx)
                                {
                                    if (!FillAtStopPrice)
                                    {
                                        order.Type = OrderType.Market;
                                        continue;
                                    }
                                    goto IL_EF;
                                }
                                break;
                        }
                        break;
                    case OrderType.Limit:
                        goto IL_104;
                    case OrderType.StopLimit:
                        switch (order.Side)
                        {
                            case OrderSide.Buy:
                                if (trade.Price >= order.StopPx)
                                {
                                    order.Type = OrderType.Limit;
                                    continue;
                                }
                                break;
                            case OrderSide.Sell:
                                if (trade.Price <= order.StopPx)
                                {
                                    order.Type = OrderType.Limit;
                                    continue;
                                }
                                break;
                        }
                        break;
                }
                break;
            }
            return false;
            IL_DA:
            this.Fill(order, order.StopPx, trade.Size);
            return true;
            IL_EF:
            this.Fill(order, order.StopPx, trade.Size);
            return true;
            IL_104:
            switch (order.Side)
            {
                case OrderSide.Buy:
                    if (trade.Price <= order.Price)
                    {
                        Fill(order, FillAtLimitPrice ? order.Price : trade.Price, trade.Size);
                        return true;
                    }
                    break;
                case OrderSide.Sell:
                    if (trade.Price >= order.Price)
                    {
                        Fill(order, FillAtLimitPrice ? order.Price : trade.Price, trade.Size);
                        return true;
                    }
                    break;
            }
            return false;
            IL_1A0:
            this.Fill(order, trade.Price, trade.Size);
            return true;
        }