public ExecutionReport CreateReport( OrderRecord record, SQ.ExecType? execType, SQ.OrderStatus? orderStatus) { ExecutionReport report = new ExecutionReport(); report.DateTime = framework.Clock.DateTime; report.Order = record.Order; report.Instrument = record.Order.Instrument; report.Side = record.Order.Side; report.OrdType = record.Order.Type; report.TimeInForce = record.Order.TimeInForce; report.OrdQty = record.Order.Qty; report.Price = record.Order.Price; report.StopPx = record.Order.StopPx; report.AvgPx = record.AvgPx; report.CumQty = record.CumQty; report.LeavesQty = record.LeavesQty; if (execType != null) report.ExecType = execType.Value; if (orderStatus != null) report.OrdStatus = orderStatus.Value; return report; }
public Order OnExecutionReport(ExecutionReport report) { Order order = this.orders[report.CommandId]; if (order == null) { return null; } report.order = order; order.OnExecutionReport(report); return order; }
public virtual double GetPrice(ExecutionReport report) { double num = report.AvgPx; switch (report.side) { case OrderSide.Buy: num += num * this.slippage; break; case OrderSide.Sell: num -= num * this.slippage; break; } return num; }
public virtual double GetCommission(ExecutionReport report) { double num; switch (this.type) { case CommissionType.PerShare: num = this.commission * report.cumQty; break; case CommissionType.Percent: num = this.commission * report.cumQty * report.avgPx; break; case CommissionType.Absolute: num = this.commission; break; default: throw new NotSupportedException("Unknown commission type " + this.type); } if (num < this.minCommission) { return this.minCommission; } return num; }
public Fill(ExecutionReport report) { this.dateTime = report.dateTime; this.order = report.order; this.instrument = report.instrument; this.currencyId = report.currencyId; this.side = report.side; this.qty = report.lastQty; this.price = report.avgPx; this.commission = report.commission; this.text = report.text; }
protected virtual void OnExecutionReport(ExecutionReport report) { }
internal void OnExecutionReport(ExecutionReport report) { if (this.strategy != null && this.strategy.status == StrategyStatus.Running) { this.strategy.OnExecutionReport_(report); } }
private void EmitExecutionReport(ExecutionReport report) { if (ExecutionReport != null) { ExecutionReport(this, new ExecutionReportEventArgs(report)); } }
internal override void OnExecutionReport_(ExecutionReport report) { this.strategyById[report.Order.strategyId].OnExecutionReport_(report); base.OnExecutionReport_(report); }
public ExecutionReport(ExecutionReport report) { this.dateTime = report.dateTime; this.instrument = report.instrument; this.currencyId = report.currencyId; this.execType = report.execType; this.ordType = report.ordType; this.side = report.side; this.timeInForce = report.timeInForce; this.ordStatus = report.ordStatus; this.order = report.order; this.commandID = report.commandID; this.lastPx = report.lastPx; this.avgPx = report.avgPx; this.ordQty = report.ordQty; this.cumQty = report.cumQty; this.lastQty = report.lastQty; this.leavesQty = report.leavesQty; this.price = report.price; this.stopPx = report.stopPx; this.commission = report.commission; }
public virtual void OnExecutionReport(ExecutionReport report) { }
public void OnExecutionReport(ExecutionReport report) { this.status = report.ordStatus; this.cumQty = report.cumQty; this.leavesQty = report.leavesQty; this.avgPx = report.avgPx; if (report.execType == ExecType.ExecReplace) { this.type = report.ordType; this.price = report.price; this.stopPx = report.stopPx; this.qty = report.ordQty; } this.reports.Add(report); this.messages.Add(report); }
public void EmitExecutionReport(ExecutionReport report) { this.framework.eventManager.OnEvent(report); }
internal void OnExecutionReport(ExecutionReport report) { this.OnEvent(report); }
protected internal void EmitExecutionReport(ExecutionReport report) { this.executionQueue.Enqueue(report); }
protected internal virtual void OnExecutionReport(ExecutionReport report) { }
protected internal override void OnExecutionReport(ExecutionReport report) { this.executionComponent.OnExecutionReport(report); }
internal virtual void OnExecutionReport_(ExecutionReport report) { if (this.raiseEvents) { this.OnExecutionReport(report); } Strategy strategy = this.strategyByOrderId[report.order.strategyId]; if (strategy != null) { strategy.OnExecutionReport_(report); } }
public override void onMessage(QuickFix42.ExecutionReport report, QuickFix.SessionID sessionID) { if (report.getExecType().getValue() == QuickFix.ExecType.PENDING_CANCEL || report.getExecType().getValue() == QuickFix.ExecType.CANCELED || report.getExecType().getValue() == QuickFix.ExecType.PENDING_REPLACE || report.getExecType().getValue() == QuickFix.ExecType.REPLACE) { object request = cancelRequests[report.getClOrdID().getValue()]; if (request == null) report.set(new OrigClOrdID(report.getClOrdID().getValue())); else { if (request is FIXOrderCancelRequest) report.set(new OrigClOrdID((request as FIXOrderCancelRequest).OrigClOrdID)); if (request is FIXOrderCancelReplaceRequest) report.set(new OrigClOrdID((request as FIXOrderCancelReplaceRequest).OrigClOrdID)); } } ExecutionReport Report = new ExecutionReport(); if (report.isSetOrderID()) Report.OrderID = report.getOrderID().getValue(); ////if (report.isSetSecondaryOrderID()) Report.SecondaryOrderID = report.getSecondaryOrderID().getValue(); if (report.isSetClOrdID()) Report.ClOrdID = report.getClOrdID().getValue(); if (report.isSetOrigClOrdID()) Report.OrigClOrdID = report.getOrigClOrdID().getValue(); ////if (report.isSetListID()) Report.ListID = report.getListID().getValue(); if (report.isSetExecID()) Report.ExecID = report.getExecID().getValue(); ////if (report.isSetExecRefID()) Report.ExecRefID = report.getExecRefID().getValue(); if (report.isSetExecType()) (Report as FIXExecutionReport).ExecType = report.getExecType().getValue(); if (report.isSetOrdStatus()) (Report as FIXExecutionReport).OrdStatus = report.getOrdStatus().getValue(); if (report.isSetOrdRejReason()) Report.OrdRejReason = report.getOrdRejReason().getValue(); ////if (report.isSetExecRestatementReason()) Report.ExecRestatementReason = report.getExecRestatementReason().getValue(); ////if (report.isSetAccount()) Report.Account = report.getAccount().getValue(); ////if (report.isSetSettlmntTyp()) Report.SettlType = report.getSettlmntTyp().getValue(); //if (report.isSetFutSettDate ()) Report.FutSettDate = report.getFutSettDate ().getValue(); if (report.isSetSymbol()) Report.Symbol = report.getSymbol().getValue(); ////if (report.isSetSymbolSfx()) Report.SymbolSfx = report.getSymbolSfx().getValue(); ////if (report.isSetSecurityID()) Report.SecurityID = report.getSecurityID().getValue(); //if (report.isSetIDSource ()) Report.IDSource = report.getIDSource ().getValue(); ////if (report.isSetSecurityType()) Report.SecurityType = report.getSecurityType().getValue(); ////if (report.isSetMaturityMonthYear()) Report.MaturityMonthYear = report.getMaturityMonthYear().getValue(); //if (report.isSetMaturityDay ()) Report.MaturityDate = DateTime.Parse(report.getMaturityDay ().getValue()); //if (report.isSetPutOrCall ()) Report.PutOrCall = report.getPutOrCall ().getValue(); ////if (report.isSetStrikePrice()) Report.StrikePrice = report.getStrikePrice().getValue(); ////if (report.isSetOptAttribute()) Report.OptAttribute = report.getOptAttribute().getValue(); ////if (report.isSetContractMultiplier()) Report.ContractMultiplier = report.getContractMultiplier().getValue(); ////if (report.isSetCouponRate()) Report.CouponRate = report.getCouponRate().getValue(); ////if (report.isSetSecurityExchange()) Report.SecurityExchange = report.getSecurityExchange().getValue(); ////if (report.isSetIssuer()) Report.Issuer = report.getIssuer().getValue(); ////if (report.isSetEncodedIssuerLen()) Report.EncodedIssuerLen = report.getEncodedIssuerLen().getValue(); ////if (report.isSetEncodedIssuer()) Report.EncodedIssuer = report.getEncodedIssuer().getValue(); ////if (report.isSetSecurityDesc()) Report.SecurityDesc = report.getSecurityDesc().getValue(); ////if (report.isSetEncodedSecurityDescLen()) Report.EncodedSecurityDescLen = report.getEncodedSecurityDescLen().getValue(); ////if (report.isSetEncodedSecurityDesc()) Report.EncodedSecurityDesc = report.getEncodedSecurityDesc().getValue(); if (report.isSetSide()) (Report as FIXExecutionReport).Side = report.getSide().getValue(); if (report.isSetOrderQty()) Report.OrderQty = report.getOrderQty().getValue(); ////if (report.isSetCashOrderQty()) Report.CashOrderQty = report.getCashOrderQty().getValue(); if (report.isSetOrdType()) (Report as FIXExecutionReport).OrdType = report.getOrdType().getValue(); if (report.isSetPrice()) Report.Price = report.getPrice().getValue(); ////if (report.isSetStopPx()) Report.StopPx = report.getStopPx().getValue(); //if (report.isSetPegDifference ()) Report.PegDifference = report.getPegDifference ().getValue(); ////if (report.isSetDiscretionInst()) Report.DiscretionInst = report.getDiscretionInst().getValue(); ////if (report.isSetDiscretionOffset()) Report.DiscretionOffsetValue = report.getDiscretionOffset().getValue(); ////if (report.isSetCurrency()) Report.Currency = report.getCurrency().getValue(); ////if (report.isSetComplianceID()) Report.ComplianceID = report.getComplianceID().getValue(); //if (report.isSetSolicitedFlag ()) Report.SolicitedFlag = report.getSolicitedFlag ().getValue(); ////if (report.isSetTimeInForce()) (Report as FIXExecutionReport).TimeInForce = report.getTimeInForce().getValue(); ////if (report.isSetEffectiveTime()) Report.EffectiveTime = report.getEffectiveTime().getValue(); ////if (report.isSetExpireDate()) Report.ExpireDate = DateTime.Parse(report.getExpireDate().getValue()); ////if (report.isSetExpireTime()) Report.ExpireTime = report.getExpireTime().getValue(); ////if (report.isSetExecInst()) Report.ExecInst = report.getExecInst().getValue(); //if (report.isSetRule80A ()) Report.Rule80A = report.getRule80A ().getValue(); if (report.isSetLastShares()) Report.LastQty = report.getLastShares().getValue(); if (report.isSetLastPx()) Report.LastPx = report.getLastPx().getValue(); ////if (report.isSetLastSpotRate()) Report.LastSpotRate = report.getLastSpotRate().getValue(); ////if (report.isSetLastForwardPoints()) Report.LastForwardPoints = report.getLastForwardPoints().getValue(); ////if (report.isSetLastMkt()) Report.LastMkt = report.getLastMkt().getValue(); ////if (report.isSetTradingSessionID()) Report.TradingSessionID = report.getTradingSessionID().getValue(); ////if (report.isSetLastCapacity()) Report.LastCapacity = report.getLastCapacity().getValue(); if (report.isSetLeavesQty()) Report.LeavesQty = report.getLeavesQty().getValue(); if (report.isSetCumQty()) Report.CumQty = report.getCumQty().getValue(); if (report.isSetAvgPx()) Report.AvgPx = report.getAvgPx().getValue(); ////if (report.isSetDayOrderQty()) Report.DayOrderQty = report.getDayOrderQty().getValue(); ////if (report.isSetDayCumQty()) Report.DayCumQty = report.getDayCumQty().getValue(); ////if (report.isSetDayAvgPx()) Report.DayAvgPx = report.getDayAvgPx().getValue(); ////if (report.isSetGTBookingInst()) Report.GTBookingInst = report.getGTBookingInst().getValue(); ////if (report.isSetTradeDate()) Report.TradeDate = DateTime.Parse(report.getTradeDate().getValue()); if (report.isSetTransactTime()) Report.TransactTime = report.getTransactTime().getValue(); //if (report.isSetReportToExch ()) Report.ReportToExch = report.getReportToExch ().getValue(); ////if (report.isSetCommission()) Report.Commission = report.getCommission().getValue(); ////if (report.isSetCommType()) (Report as FIXExecutionReport).CommType = report.getCommType().getValue(); ////if (report.isSetGrossTradeAmt()) Report.GrossTradeAmt = report.getGrossTradeAmt().getValue(); ////if (report.isSetSettlCurrAmt()) Report.SettlCurrAmt = report.getSettlCurrAmt().getValue(); ////if (report.isSetSettlCurrency()) Report.SettlCurrency = report.getSettlCurrency().getValue(); ////if (report.isSetHandlInst()) Report.HandlInst = report.getHandlInst().getValue(); ////if (report.isSetMinQty()) Report.MinQty = report.getMinQty().getValue(); ////if (report.isSetMaxFloor()) Report.MaxFloor = report.getMaxFloor().getValue(); //if (report.isSetOpenClose ()) Report.OpenClose = report.getOpenClose ().getValue(); ////if (report.isSetMaxShow()) Report.MaxShow = report.getMaxShow().getValue(); if (report.isSetText()) Report.Text = report.getText().getValue(); ////if (report.isSetEncodedTextLen()) Report.EncodedTextLen = report.getEncodedTextLen().getValue(); ////if (report.isSetEncodedText()) Report.EncodedText = report.getEncodedText().getValue(); //if (report.isSetFutSettDate2 ()) Report.FutSettDate2 = report.getFutSettDate2 ().getValue(); ////if (report.isSetOrderQty2()) Report.OrderQty2 = report.getOrderQty2().getValue(); //if (report.isSetClearingFirm ()) Report.ClearingFirm = report.getClearingFirm ().getValue(); //if (report.isSetClearingAccount ()) Report.ClearingAccount = report.getClearingAccount ().getValue(); ////if (report.isSetMultiLegReportingType()) Report.MultiLegReportingType = report.getMultiLegReportingType().getValue(); // SingleOrder order; if (Report.ExecType == SmartQuant.FIX.ExecType.PendingCancel || Report.ExecType == SmartQuant.FIX.ExecType.Cancelled || Report.ExecType == SmartQuant.FIX.ExecType.PendingReplace || Report.ExecType == SmartQuant.FIX.ExecType.Replace) order = OrderManager.Orders.All[Report.OrigClOrdID] as SingleOrder; else order = OrderManager.Orders.All[Report.ClOrdID] as SingleOrder; Instrument instrument = order.Instrument; Report.Symbol = instrument.Symbol; Report.TransactTime = Clock.Now; // emit execution report EmitExecutionReport(Report); }
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); }
internal void OnExecutionReport(ExecutionReport report) { if (report.execType == ExecType.ExecTrade) { Fill fill = new Fill(report); report.order.portfolio.Add(fill); } }
public OnExecutionReport(ExecutionReport report) { this.report = report; }
internal void OnExecutionReport(ExecutionReport report) { Order order = report.order; OrderStatus status = order.status; order.OnExecutionReport(report); if (status != order.status) { this.framework.eventServer.OnOrderStatusChanged(order); } ExecType execType = report.ExecType; switch (execType) { case ExecType.ExecTrade: if (order.status == OrderStatus.PartiallyFilled) { this.framework.eventServer.OnOrderPartiallyFilled(order); return; } this.framework.eventServer.OnOrderFilled(order); this.framework.eventServer.OnOrderDone(order); this.ProcessOCA(order); return; case ExecType.ExecPendingCancel: break; case ExecType.ExecCancelled: this.framework.eventServer.OnOrderCancelled(order); this.framework.eventServer.OnOrderDone(order); this.ProcessOCA(order); return; default: if (execType != ExecType.ExecReplace) { return; } this.framework.eventServer.OnOrderReplaced(order); break; } }
private void EmitExecutionReport(OrderRecord record, OrdStatus ordStatus, double lastPx, int lastQty, string text, CommType commType, double commission) { ExecutionReport report = new ExecutionReport { TransactTime = Clock.Now, ClOrdID = record.Order.ClOrdID, OrigClOrdID = record.Order.ClOrdID, OrderID = record.Order.OrderID, Symbol = record.Order.Symbol, SecurityType = record.Order.SecurityType, SecurityExchange = record.Order.SecurityExchange, Currency = record.Order.Currency, CommType = commType, Commission = commission, Side = record.Order.Side, OrdType = record.Order.OrdType, TimeInForce = record.Order.TimeInForce, OrderQty = record.Order.OrderQty, Price = record.Order.Price, StopPx = record.Order.StopPx, LastPx = lastPx, LastQty = lastQty }; if (ordStatus == OrdStatus.Replaced) { report.OrdType = record.Order.ReplaceOrder.ContainsField(EFIXField.OrdType) ? record.Order.ReplaceOrder.OrdType : record.Order.OrdType; report.TimeInForce = record.Order.ReplaceOrder.ContainsField(EFIXField.TimeInForce) ? record.Order.ReplaceOrder.TimeInForce : record.Order.TimeInForce; report.OrderQty = record.Order.ReplaceOrder.ContainsField(EFIXField.OrderQty) ? record.Order.ReplaceOrder.OrderQty : record.Order.OrderQty; report.Price = record.Order.ReplaceOrder.ContainsField(EFIXField.Price) ? record.Order.ReplaceOrder.Price : record.Order.Price; report.StopPx = record.Order.ReplaceOrder.ContainsField(EFIXField.StopPx) ? record.Order.ReplaceOrder.StopPx : record.Order.StopPx; record.LeavesQty = ((int)report.OrderQty) - record.CumQty; } else { report.OrdType = record.Order.OrdType; report.TimeInForce = record.Order.TimeInForce; report.OrderQty = record.Order.OrderQty; report.Price = record.Order.Price; report.StopPx = record.Order.StopPx; } if (ordStatus == OrdStatus.Undefined) { record.AddFill(lastPx, lastQty); if (record.LeavesQty > 0) { ordStatus = OrdStatus.PartiallyFilled; } else { ordStatus = OrdStatus.Filled; } } report.AvgPx = record.AvgPx; report.CumQty = record.CumQty; report.LeavesQty = record.LeavesQty; report.ExecType = CTPZQProvider.GetExecType(ordStatus); report.OrdStatus = ordStatus; report.Text = text; EmitExecutionReport(report); }
private void EmitExecutionReport(OrderRecord record, OrdStatus ordStatus, double lastPx, int lastQty, string text) { ExecutionReport report = new ExecutionReport { TransactTime = Clock.Now, ClOrdID = record.Order.ClOrdID, OrigClOrdID = record.Order.ClOrdID, OrderID = record.Order.OrderID, Symbol = record.Order.Symbol, SecurityType = record.Order.SecurityType, SecurityExchange = record.Order.SecurityExchange, Currency = record.Order.Currency, Side = record.Order.Side, OrdType = record.Order.OrdType, TimeInForce = record.Order.TimeInForce, OrderQty = record.Order.OrderQty, Price = record.Order.Price, StopPx = record.Order.StopPx, LastPx = lastPx, LastQty = lastQty }; if (ordStatus == OrdStatus.Undefined) { record.AddFill(lastPx, lastQty); if (record.LeavesQty > 0) { ordStatus = OrdStatus.PartiallyFilled; } else { ordStatus = OrdStatus.Filled; } } report.AvgPx = record.AvgPx; report.CumQty = record.CumQty; report.LeavesQty = record.LeavesQty; report.ExecType = this.GetExecType(ordStatus); report.OrdStatus = ordStatus; report.Text = text; EmitExecutionReport(report); }