private void dGEFgdOydF() { if (!(this.PYBF7sahqY is SingleOrder)) { return; } SingleOrder singleOrder = this.PYBF7sahqY as SingleOrder; if (singleOrder.ContainsField(11201)) { this.kUyFaL3cQu = (FillOnBarMode)singleOrder.FillOnBarMode; } Instrument instrument = singleOrder.Instrument; bool flag = !singleOrder.IsStopLimitReady && (singleOrder.OrdType == OrdType.TrailingStop || singleOrder.OrdType == OrdType.TrailingStopLimit || singleOrder.OrdType == OrdType.StopLimit); if (singleOrder.OrdType == OrdType.Market) { if ((this.A8bFJItyyx.FillOnQuote && !flag || this.A8bFJItyyx.TriggerOnQuote && flag) && this.A8bFJItyyx.FillOnQuoteMode == FillOnQuoteMode.LastQuote) { this.Y18FFPmDy5(instrument.Quote, (Trade)null, (Bar)null); } if ((this.A8bFJItyyx.FillOnTrade && !flag || this.A8bFJItyyx.TriggerOnTrade && flag) && this.A8bFJItyyx.FillOnTradeMode == FillOnTradeMode.LastTrade) { this.Y18FFPmDy5((Quote)null, instrument.Trade, (Bar)null); } if ((this.A8bFJItyyx.FillOnBar && !flag || this.A8bFJItyyx.TriggerOnBar && flag) && ((this.kUyFaL3cQu == FillOnBarMode.LastBarClose || singleOrder.ForceMarketOrder) && this.A8bFJItyyx.BarFilter.Contains(instrument.Bar.BarType, instrument.Bar.Size))) { this.Y18FFPmDy5((Quote)null, (Trade)null, instrument.Bar); } } else { if (instrument.Quote != null && (this.A8bFJItyyx.FillOnQuote && !flag || this.A8bFJItyyx.TriggerOnQuote && flag) && this.A8bFJItyyx.FillOnQuoteMode == FillOnQuoteMode.LastQuote) { this.Y18FFPmDy5(instrument.Quote, (Trade)null, (Bar)null); } if (instrument.Trade != null && (this.A8bFJItyyx.FillOnTrade && !flag || this.A8bFJItyyx.TriggerOnTrade && flag) && this.A8bFJItyyx.FillOnTradeMode == FillOnTradeMode.LastTrade) { this.Y18FFPmDy5((Quote)null, instrument.Trade, (Bar)null); } if (instrument.Bar != null && (this.A8bFJItyyx.FillOnBar && !flag || this.A8bFJItyyx.TriggerOnBar && flag) && (this.A8bFJItyyx.BarFilter.Contains(instrument.Bar.BarType, instrument.Bar.Size) && this.A8bFJItyyx.FillOnBarMode == FillOnBarMode.LastBarClose)) { double close = instrument.Bar.Close; if (close != 0.0) { this.wYBFLwFB4S(close, singleOrder.OrderQty); } } } if (this.aXtFGP76FH) { return; } if (this.A8bFJItyyx.FillOnQuote || this.A8bFJItyyx.TriggerOnQuote) { instrument.NewQuote += new QuoteEventHandler(this.PyJFklA8yp); } if (this.A8bFJItyyx.FillOnTrade || this.A8bFJItyyx.TriggerOnTrade) { instrument.NewTrade += new TradeEventHandler(this.YGKFrq1UXP); } this.smCF4MYTNu = instrument.Quote; if (this.A8bFJItyyx.FillOnBar || this.A8bFJItyyx.TriggerOnBar) { if (singleOrder.ForceMarketOrder) { instrument.NewBar += new BarEventHandler(this.YgkFRBfPV0); instrument.NewBarOpen += new BarEventHandler(this.OyPFEsHGL2); } else if (singleOrder.OrdType == OrdType.Market) { switch (this.kUyFaL3cQu) { case FillOnBarMode.LastBarClose: case FillOnBarMode.NextBarClose: instrument.NewBar += new BarEventHandler(this.YgkFRBfPV0); break; case FillOnBarMode.NextBarOpen: instrument.NewBarOpen += new BarEventHandler(this.OyPFEsHGL2); break; } } else { instrument.NewBar += new BarEventHandler(this.YgkFRBfPV0); instrument.NewBarOpen += new BarEventHandler(this.OyPFEsHGL2); } } if ((int)this.PYBF7sahqY.TimeInForce != 54) { return; } Clock.AddReminder(new ReminderEventHandler(this.xT1FyAqCPT), this.PYBF7sahqY.ExpireTime, (object)null); }
private void Init() { if (this.fOrder is SingleOrder) { SingleOrder singleOrder = this.fOrder as SingleOrder; if (singleOrder.ContainsField(11201)) { this.fFillOnBarMode = (FillOnBarMode)singleOrder.FillOnBarMode; } Instrument instrument = singleOrder.Instrument; if (singleOrder.OrdType == OrdType.Market) { if (this.fProvider.FillOnQuote && this.fProvider.FillOnQuoteMode == FillOnQuoteMode.LastQuote) { this.Process(instrument.Quote, null, null); } if (this.fProvider.FillOnTrade && this.fProvider.FillOnTradeMode == FillOnTradeMode.LastTrade) { this.Process(null, instrument.Trade, null); } if (this.fProvider.FillOnBar && (this.fFillOnBarMode == FillOnBarMode.LastBarClose || singleOrder.ForceMarketOrder) && this.fProvider.BarFilter.Contains(instrument.Bar.BarType, instrument.Bar.Size)) { this.Process(null, null, instrument.Bar); } } else { if (instrument.Quote != null && this.fProvider.FillOnQuote) { this.Process(instrument.Quote, null, null); } if (instrument.Trade != null && this.fProvider.FillOnTrade) { this.Process(null, instrument.Trade, null); } if (instrument.Bar != null && this.fProvider.FillOnBar && this.fProvider.BarFilter.Contains(instrument.Bar.BarType, instrument.Bar.Size)) { double close = instrument.Bar.Close; if (close != 0.0) { this.StopLimit(close, singleOrder.OrderQty); } } } if (!this.fExecuted) { if (this.fProvider.FillOnQuote) { instrument.NewQuote += new QuoteEventHandler(this.OnNewQuote); } if (this.fProvider.FillOnTrade) { instrument.NewTrade += new TradeEventHandler(this.OnNewTrade); } if (this.fProvider.FillOnBar) { if (singleOrder.ForceMarketOrder) { instrument.NewBar += new BarEventHandler(this.OnNewBar); instrument.NewBarOpen += new BarEventHandler(this.OnNewBarOpen); } else { if (singleOrder.OrdType == OrdType.Market) { switch (this.fFillOnBarMode) { case FillOnBarMode.LastBarClose: case FillOnBarMode.NextBarClose: instrument.NewBar += new BarEventHandler(this.OnNewBar); break; case FillOnBarMode.NextBarOpen: instrument.NewBarOpen += new BarEventHandler(this.OnNewBarOpen); break; } } else { instrument.NewBar += new BarEventHandler(this.OnNewBar); instrument.NewBarOpen += new BarEventHandler(this.OnNewBarOpen); } } } if (this.fOrder.TimeInForce == '6') { Clock.AddReminder(new ReminderEventHandler(this.Clock_Reminder), this.fOrder.ExpireTime, null); } } } }
private double CcXFPEywDQ(Quote obj0, Trade obj1, Bar obj2) { SingleOrder singleOrder = this.PYBF7sahqY as SingleOrder; if (singleOrder.ContainsField(11103) && singleOrder.StrategyFill) { return(singleOrder.StrategyPrice); } bool flag = !singleOrder.IsStopLimitReady && (singleOrder.OrdType == OrdType.TrailingStop || singleOrder.OrdType == OrdType.TrailingStopLimit || singleOrder.OrdType == OrdType.StopLimit); if (obj0 != null && (this.A8bFJItyyx.FillOnQuote && !flag || this.A8bFJItyyx.TriggerOnQuote && flag)) { if (!this.A8bFJItyyx.FillAtWorstQuoteRate || obj0.Bid <= obj0.Ask) { switch (singleOrder.Side) { case Side.Buy: case Side.BuyMinus: if (obj0.Ask != 0.0) { return(obj0.Ask); } else { break; } case Side.Sell: case Side.SellShort: if (obj0.Bid != 0.0) { return(obj0.Bid); } else { break; } default: throw new NotSupportedException("" + ((object)singleOrder.Side).ToString()); } } else { switch (singleOrder.Side) { case Side.Buy: case Side.BuyMinus: if (obj0.Bid != 0.0) { return(obj0.Bid); } else { break; } case Side.Sell: case Side.SellShort: if (obj0.Ask != 0.0) { return(obj0.Ask); } else { break; } default: throw new NotSupportedException("" + ((object)singleOrder.Side).ToString()); } } } if (obj1 != null && (this.A8bFJItyyx.FillOnTrade && !flag || this.A8bFJItyyx.TriggerOnTrade && flag) && obj1.Price != 0.0) { return(obj1.Price); } if (obj2 != null && (this.A8bFJItyyx.FillOnBar && !flag || this.A8bFJItyyx.TriggerOnBar && flag)) { if (singleOrder.StrategyComponent == "which") { return(singleOrder.StrategyPrice); } if (singleOrder.ForceMarketOrder) { if (obj2.Close != 0.0) { return(obj2.Close); } if (obj2.Open != 0.0) { return(obj2.Open); } } switch (this.kUyFaL3cQu) { case FillOnBarMode.LastBarClose: case FillOnBarMode.NextBarClose: return(obj2.Close); case FillOnBarMode.NextBarOpen: return(obj2.Open); } } return(0.0); }
private double GetPrice(Quote quote, Trade trade, Bar bar) { SingleOrder singleOrder = this.fOrder as SingleOrder; if (singleOrder.ContainsField(11103) && singleOrder.StrategyFill) { return(singleOrder.StrategyPrice); } if (quote != null && this.fProvider.FillOnQuote) { switch (singleOrder.Side) { case Side.Buy: case Side.BuyMinus: if (quote.Ask != 0.0) { return(quote.Ask); } goto IL_B0; case Side.Sell: case Side.SellShort: if (quote.Bid != 0.0) { return(quote.Bid); } goto IL_B0; } throw new NotSupportedException("Order side is not supported : " + singleOrder.Side.ToString()); } IL_B0: if (trade != null && this.fProvider.FillOnTrade && trade.Price != 0.0) { return(trade.Price); } if (bar != null && this.fProvider.FillOnBar) { if (singleOrder.StrategyComponent == "Stop") { return(singleOrder.StrategyPrice); } if (singleOrder.ForceMarketOrder) { if (bar.Close != 0.0) { return(bar.Close); } if (bar.Open != 0.0) { return(bar.Open); } } switch (this.fFillOnBarMode) { case FillOnBarMode.LastBarClose: case FillOnBarMode.NextBarClose: return(bar.Close); case FillOnBarMode.NextBarOpen: return(bar.Open); } } return(0.0); }