public void OnBarOpen(Bar bar)
{
if (this.ordersByInstrumentId[bar.InstrumentId] == null)
{
return;
}
if (FillOnBarOpen)
{
if (BarFilter.Count != 0 && !BarFilter.Contains(bar.Type, bar.Size))
{
return;
}
int i = 0;
while (i < this.ordersByInstrumentId[bar.InstrumentId].Count)
{
Order order = this.ordersByInstrumentId[bar.InstrumentId][i];
while (true)
{
switch (order.Type)
{
case OrderType.Market:
case OrderType.Pegged:
goto IL_215;
case OrderType.Stop:
switch (order.Side)
{
case OrderSide.Buy:
if (bar.Open >= order.StopPx)
{
if (!FillAtStopPrice)
{
order.Type = OrderType.Market;
continue;
}
goto IL_142;
}
break;
case OrderSide.Sell:
if (bar.Open <= order.StopPx)
{
if (!FillAtStopPrice)
{
order.Type = OrderType.Market;
continue;
}
goto IL_15B;
}
break;
}
break;
case OrderType.Limit:
goto IL_174;
case OrderType.StopLimit:
switch (order.Side)
{
case OrderSide.Buy:
if (bar.Open >= order.StopPx)
{
order.Type = OrderType.Limit;
continue;
}
break;
case OrderSide.Sell:
if (bar.Open <= order.StopPx)
{
order.Type = OrderType.Limit;
continue;
}
break;
}
break;
}
break;
}
IL_229:
i++;
continue;
goto IL_229;
IL_142:
this.Fill(order, order.StopPx, (int)bar.Volume);
goto IL_229;
IL_15B:
this.Fill(order, order.StopPx, (int)bar.Volume);
goto IL_229;
IL_174:
switch (order.Side)
{
case OrderSide.Buy:
if (bar.Open > order.Price)
{
goto IL_229;
}
if (FillAtLimitPrice)
{
this.Fill(order, order.Price, (int)bar.Volume);
goto IL_229;
}
this.Fill(order, bar.Open, (int)bar.Volume);
goto IL_229;
case OrderSide.Sell:
if (bar.Open < order.Price)
{
goto IL_229;
}
if (FillAtLimitPrice)
{
this.Fill(order, order.Price, (int)bar.Volume);
goto IL_229;
}
this.Fill(order, bar.Open, (int)bar.Volume);
goto IL_229;
default:
goto IL_229;
}
IL_215:
this.Fill(order, bar.Open, (int)bar.Volume);
goto IL_229;
}
this.ClearOrders();
}
}