private void OnOrderFilled(SmartQuant.Order order) { int index = order.Reports.Count - 1; double LastQty = order.Reports[index].LastQty; double LastPrice = order.Reports[index].LastPx; bool IsDone = order.IsDone; OpenCloseType OpenClose = OpenCloseHelper.GetOpenClose(order); MonoPositionRecord record = GetPositionRecord(order.Side, OpenClose); switch (OpenClose) { case OpenCloseType.Open: record.FilledOpen(LastQty, LastPrice); break; case OpenCloseType.Close: record.FilledClose(LastQty, LastPrice); break; case OpenCloseType.CloseToday: record.FilledCloseToday(LastQty, LastPrice); break; default: MessageBox.Show("Filled"); break; } }
public Order(Order order) : base() { this.id = -1; this.oCA = ""; this.text = ""; this.id = order.id; this.providerId = order.providerId; this.portfolioId = order.portfolioId; this.transactTime = order.transactTime; this.dateTime = order.dateTime; this.instrument = order.instrument; this.provider = order.provider; this.portfolio = order.portfolio; this.status = order.status; this.side = order.side; this.type = order.type; this.timeInForce = order.timeInForce; this.price = order.price; this.stopPx = order.stopPx; this.avgPx = order.avgPx; this.qty = order.qty; this.cumQty = order.cumQty; this.text = order.text; this.commands = order.commands; this.reports = order.reports; this.messages = order.messages; }
public Order OnExecutionCommand(ExecutionCommand command) { Order order = this.orders[command.Id]; if (order == null) { order = new Order(); this.orders[command.Id] = order; order.dateTime = command.dateTime; order.id = command.id; order.providerId = command.providerId; order.portfolioId = command.portfolioId; order.transactTime = command.transactTime; order.instrument = command.instrument; order.provider = command.provider; order.portfolio = command.portfolio; order.side = command.side; order.type = command.orderType; order.timeInForce = command.timeInForce; order.price = command.price; order.stopPx = command.stopPx; order.qty = command.qty; order.oCA = command.oCA; order.text = command.text; } command.order = order; order.OnExecutionCommand(command); return order; }
public void DoOrderSend(ref OrderField[] ordersArray, Order order) { if (Convert.ToInt32(order.Qty) == int.MaxValue) { SetExternalOrder(order, ref ordersArray[0]); } else { DoOrderSend(ref ordersArray, new List<Order>() { order }); } }
public void Init(Order order) { int digits = GetDigits(order.Instrument); if (order.Instrument.TickSize != 0.0) { this.nudLimitPrice.Increment = (Decimal)order.Instrument.TickSize; this.nudStopPrice.Increment = (Decimal)order.Instrument.TickSize; } else { Decimal num = (Decimal)Math.Pow(0.1, digits); this.nudLimitPrice.Increment = num; this.nudStopPrice.Increment = num; } int num1 = this.calculateDecimals(this.nudLimitPrice.Increment); if (num1 > digits) { this.nudLimitPrice.DecimalPlaces = num1; this.nudStopPrice.DecimalPlaces = num1; } else { this.nudLimitPrice.DecimalPlaces = digits; this.nudStopPrice.DecimalPlaces = digits; } this.nudLimitPrice.Enabled = false; this.nudStopPrice.Enabled = false; switch (order.Type) { case OrderType.Market: this.nudLimitPrice.Value = (Decimal)order.Price; this.nudStopPrice.Value = (Decimal)order.StopPx; this.nudQty.Value = (Decimal)order.Qty; this.Text = $"{order.Instrument.Symbol} - {order.Side} {order.Type} [Modify]"; break; case OrderType.Stop: this.nudStopPrice.Enabled = true; goto case OrderType.Market; case OrderType.Limit: this.nudLimitPrice.Enabled = true; goto case OrderType.Market; case OrderType.StopLimit: this.nudLimitPrice.Enabled = true; this.nudStopPrice.Enabled = true; goto case OrderType.Market; default: throw new NotSupportedException("Not supported order type - {order.Type}"); } }
public void Cancel(Order order) { ExecutionCommand executionCommand = new ExecutionCommand(ExecutionCommandType.Cancel, order); executionCommand.dateTime = this.framework.Clock.DateTime; executionCommand.providerId = order.providerId; executionCommand.portfolioId = order.portfolioId; executionCommand.transactTime = order.transactTime; executionCommand.instrument = order.instrument; executionCommand.provider = order.provider; executionCommand.portfolio = order.portfolio; executionCommand.side = order.side; executionCommand.orderType = order.Type; executionCommand.timeInForce = order.timeInForce; executionCommand.price = order.price; executionCommand.stopPx = order.stopPx; executionCommand.qty = order.qty; executionCommand.oCA = order.oCA; executionCommand.text = order.text; order.OnExecutionCommand(executionCommand); this.framework.eventServer.OnExecutionCommand(executionCommand); order.Provider.Send(executionCommand); }
private void SetExternalOrder(Order order, ref OrderField field) { var orderRecord = new OrderRecord(order); ExternalOrderRecord record = new ExternalOrderRecord(); record = externalOrders.GetOrAdd(order.Instrument.Symbol, record); if (field.OpenClose == OpenCloseType.Open) { if (field.Side == XAPI.OrderSide.Buy) { record.BuyOpen = orderRecord; } else { record.SellOpen = orderRecord; } } else { if (field.Side == XAPI.OrderSide.Buy) { record.BuyClose = orderRecord; } else { record.SellClose = orderRecord; } } }
protected internal virtual void OnOrderFilled(Order order) { }
public OnOrderStatusChanged(Order order) { this.order = order; }
public OnOrderCancelled(Order order) { this.order = order; }
internal override void OnOrderPartiallyFilled_(Order order) { this.strategyById[order.strategyId].OnOrderPartiallyFilled_(order); base.OnOrderPartiallyFilled_(order); }
internal void OnOrderDone(Order order) { this.OnEvent(new OnOrderDone(order)); }
private void Cancel(Order order) { this.orders[order.instrument.Id].Remove(order); base.EmitExecutionReport(new ExecutionReport { dateTime = this.framework.Clock.DateTime, order = order, commandID = order.id, instrument = order.instrument, ordQty = order.qty, timeInForce = order.timeInForce, execType = ExecType.ExecCancelled, ordStatus = OrderStatus.Cancelled, currencyId = order.instrument.currencyId, ordType = order.type, side = order.side, cumQty = order.cumQty, lastQty = 0.0, leavesQty = order.leavesQty, lastPx = 0.0, avgPx = 0.0, text = order.text }); }
internal void OnOrderStatusChanged(Order order) { this.OnEvent(new OnOrderStatusChanged(order)); }
internal void OnOrderCancelled(Order order) { this.OnEvent(new OnOrderCancelled(order)); }
protected internal virtual void OnOrderDone(Order order) { }
protected internal virtual void OnOrderCancelled(Order order) { }
public void Send(Order order) { this.framework.OrderManager.Send(order); }
public Order SellStopOrder(Instrument instrument, double qty, double stopPx, string text = "") { Order order = new Order(this.GetExecutionProvider(instrument), this.portfolio, instrument, OrderType.Stop, OrderSide.Sell, qty, 0.0, 0.0, TimeInForce.Day, 0, ""); order.strategyId = (int)this.id; order.text = text; order.stopPx = stopPx; this.framework.OrderManager.Register(order); return order; }
public Order SellLimit(Instrument instrument, double qty, double price, string text = "") { Order order = new Order(this.GetExecutionProvider(instrument), this.portfolio, instrument, OrderType.Limit, OrderSide.Sell, qty, 0.0, 0.0, TimeInForce.Day, 0, ""); order.strategyId = (int)this.id; order.text = text; order.price = price; this.framework.OrderManager.Send(order); return order; }
internal void OnOrderPartiallyFilled(Order order) { this.OnEvent(new OnOrderPartiallyFilled(order)); }
protected internal virtual void OnOrderPartiallyFilled(Order order) { }
internal void OnOrderReplaced(Order order) { this.OnEvent(new OnOrderReplaced(order)); }
internal virtual void OnOrderPartiallyFilled_(Order order) { if (this.raiseEvents) { this.OnOrderPartiallyFilled(order); } Strategy strategy = this.strategyByOrderId[order.strategyId]; if (strategy != null) { strategy.OnOrderPartiallyFilled_(order); } }
private void Send(Order order) { base.EmitExecutionReport(new ExecutionReport { dateTime = this.framework.Clock.DateTime, order = order, commandID = order.id, instrument = order.instrument, ordQty = order.qty, timeInForce = order.timeInForce, execType = ExecType.ExecNew, ordStatus = OrderStatus.New, currencyId = order.instrument.currencyId, ordType = order.type, side = order.side, cumQty = 0.0, lastQty = 0.0, leavesQty = 0.0, lastPx = 0.0, avgPx = 0.0, text = order.text }); int id = order.instrument.Id; if (this.orders[id] == null) { this.orders[id] = new List<Order>(); } this.orders[id].Add(order); switch (order.type) { case OrderType.Market: if (!this.fillMarketOnNext) { Instrument instrument = order.instrument; if (this.fillOnQuote) { switch (order.side) { case OrderSide.Buy: { Ask ask = this.framework.DataManager.GetAsk(instrument); if (ask != null) { this.Fill(order, ask.Price, ask.Size); return; } break; } case OrderSide.Sell: { Bid bid = this.framework.DataManager.GetBid(instrument); if (bid != null) { this.Fill(order, bid.Price, bid.Size); return; } break; } } } if (this.fillOnTrade) { Trade trade = this.framework.DataManager.GetTrade(instrument); if (trade != null) { this.Fill(order, trade.Price, trade.Size); } } } break; case OrderType.Stop: case OrderType.Limit: break; default: return; } }
protected internal virtual void OnOrderReplaced(Order order) { }
public void Fill(Order order, double price, int size) { this.orders[order.instrument.Id].Remove(order); ExecutionReport executionReport = new ExecutionReport(); executionReport.dateTime = this.framework.Clock.DateTime; executionReport.order = order; executionReport.ordType = order.type; executionReport.side = order.side; executionReport.instrument = order.instrument; executionReport.ordQty = order.qty; executionReport.commandID = order.id; executionReport.timeInForce = order.timeInForce; executionReport.execType = ExecType.ExecTrade; executionReport.ordStatus = OrderStatus.Filled; executionReport.currencyId = order.instrument.currencyId; executionReport.cumQty = order.qty; executionReport.lastQty = order.qty; executionReport.leavesQty = 0.0; executionReport.lastPx = price; executionReport.avgPx = price; executionReport.text = order.Text; executionReport.commission = this.commissionProvider.GetCommission(executionReport); executionReport.avgPx = this.slippageProvider.GetPrice(executionReport); base.EmitExecutionReport(executionReport); }
protected internal virtual void OnOrderStatusChanged(Order order) { }
internal override void OnOrderStatusChanged_(Order order) { this.strategyById[order.strategyId].OnOrderStatusChanged_(order); base.OnOrderStatusChanged_(order); }
internal virtual void OnOrderStatusChanged_(Order order) { if (this.raiseEvents) { this.OnOrderStatusChanged(order); } Strategy strategy = this.strategyByOrderId[order.strategyId]; if (strategy != null) { strategy.OnOrderStatusChanged_(order); } }
internal override void OnOrderReplaced_(Order order) { this.strategyById[order.strategyId].OnOrderReplaced_(order); base.OnOrderReplaced_(order); }