public QuickFix.FIX44.Message CreateFillReport(OrderMatchReport report)
        {
            var execId          = string.Format("{0}{1}", report.Asset.Symbol, DIContainer.ResolveByName <IdGenerator>("ExecIdGenerator").GenerateId());
            var symbol          = new Symbol(report.Asset.Symbol);
            var executionReport = new ExecutionReport(
                new OrderID(report.OrderId.ToString(CultureInfo.InvariantCulture)),
                new ExecID(execId),
                new ExecType(report.MatchType == OrderMatchType.Filled
                                 ? ExecType.FILL
                                 : ExecType.PARTIAL_FILL),
                new OrdStatus(report.MatchType == OrderMatchType.Filled
                                  ? OrdStatus.FILLED
                                  : OrdStatus.PARTIALLY_FILLED),
                symbol,
                FixFieldsConverter.Convert(report.OrderSide),
                new LeavesQty(report.RemainingQuantity),
                new CumQty(report.OriginalOrderQuantity - report.RemainingQuantity),
                new AvgPx(report.Price))
            {
                ClOrdID  = new ClOrdID(report.ClOrdId),
                Symbol   = symbol,
                OrderQty = new OrderQty(report.OriginalOrderQuantity),
                LastQty  = new LastQty(report.MatchedQuantity),
                LastPx   = new LastPx(report.Price)
            };

            if (TradingAccount.IsSet(report.Account))
            {
                executionReport.SetField(new Account(report.Account.Name));
            }

            return(executionReport);
        }
        public Message CreateNewOrderExecutionReport(IOrder o, string execID)
        {
            var symbol = new Symbol(o.Contract.Symbol);
            var exReport = new ExecutionReport(
                new OrderID(o.ID.ToString(CultureInfo.InvariantCulture)),
                new ExecID(execID),
                new ExecType(ExecType.NEW),
                new OrdStatus(OrdStatus.NEW),
                symbol,
                TranslateFixFields.Translate(o.MarketSide),
                new LeavesQty(o.Quantity),
                new CumQty(0m),
                new AvgPx(o.Price))
                {
                    ClOrdID = new ClOrdID(o.ClOrdID),
                    Symbol = symbol,
                    OrderQty = new OrderQty(o.Quantity),
                    LastQty = new LastQty(0m)
                };

            //exReport.Set(new LastPx(o.Price));

            if (TradingAccount.IsSet(o.Account))
                exReport.SetField(new Account(o.Account.Name));

            return exReport;
        }
Example #3
0
        public static ExecutionReport CreateRejectNewOrderExecutionReport(
            NewOrderSingle n,
            string execID,
            string rejectionReason,
            int?rejectionCode = null)
        {
            var exReport = new ExecutionReport(
                new OrderID("unknown orderID"),
                new ExecID(execID),
                new ExecTransType(ExecTransType.NEW),
                new ExecType(ExecType.REJECTED),
                new OrdStatus(OrdStatus.REJECTED),
                n.Symbol,
                n.Side,
                new LeavesQty(0m),
                new CumQty(0m),
                new AvgPx(0m));

            if (rejectionCode.HasValue)
            {
                exReport.OrdRejReason = new OrdRejReason(rejectionCode.Value);
            }

            exReport.Set(n.ClOrdID);
            exReport.Set(n.OrderQty);

            if (n.IsSetAccount())
            {
                exReport.SetField(n.Account);
            }

            return(exReport);
        }
        public Message CreateFillReport(OrderMatch match, string execID)
        {
            var symbol = new Symbol(match.Contract.Symbol);
            var exReport = new ExecutionReport(
                new OrderID(match.OrderID.ToString(CultureInfo.InvariantCulture)),
                new ExecID(execID),
                new ExecType(match.MatchType == MatchType.Full
                                 ? ExecType.FILL
                                 : ExecType.PARTIAL_FILL),
                new OrdStatus(match.MatchType == MatchType.Full
                                  ? OrdStatus.FILLED
                                  : OrdStatus.PARTIALLY_FILLED),
                symbol,
                TranslateFixFields.Translate(match.MarketSide),
                new LeavesQty(match.RemainingQuantity),
                new CumQty(match.OriginalOrderQuantity - match.RemainingQuantity),
                new AvgPx(match.Price))
            {
                ClOrdID = new ClOrdID(match.ClOrdID),
                Symbol = symbol,
                OrderQty = new OrderQty(match.OriginalOrderQuantity),
                LastQty = new LastQty(match.MatchedQuantity),
                LastPx = new LastPx(match.Price)
            };

            if (TradingAccount.IsSet(match.Account))
                exReport.SetField(new Account(match.Account.Name));

            return exReport;
        }
Example #5
0
        public static ExecutionReport CreateRejectNewOrderExecutionReport(
            NewOrderSingle n,
            string execID,
            string rejectionReason,
            int? rejectionCode = null)
        {
            var exReport = new ExecutionReport(
                new OrderID("unknown orderID"),
                new ExecID(execID),
                new ExecTransType(ExecTransType.NEW),
                new ExecType(ExecType.REJECTED),
                new OrdStatus(OrdStatus.REJECTED),
                n.Symbol,
                n.Side,
                new LeavesQty(0m),
                new CumQty(0m),
                new AvgPx(0m));

            if (rejectionCode.HasValue)
            {
                exReport.OrdRejReason = new OrdRejReason(rejectionCode.Value);
            }

            exReport.Set(n.ClOrdID);
            exReport.Set(n.OrderQty);

            if (n.IsSetAccount())
                exReport.SetField(n.Account);

            return exReport;
        }
Example #6
0
        public Message CreateNewOrderExecutionReport(IOrder o, string execID)
        {
            var exReport = new ExecutionReport(
                new OrderID(o.ID.ToString(CultureInfo.InvariantCulture)),
                new ExecID(execID),
                new ExecTransType(ExecType.NEW),
                new ExecType(ExecType.NEW),
                new OrdStatus(OrdStatus.NEW),
                new Symbol(o.Contract.Symbol),
                TranslateFixFields.Translate(o.MarketSide),
                new LeavesQty(o.Quantity),
                new CumQty(0m),
                new AvgPx(o.Price))
            {
                ClOrdID    = new ClOrdID(o.ClOrdID),
                OrderQty   = new OrderQty(o.Quantity),
                LastShares = new LastShares(0m)
            };

            //exReport.Set(new LastPx(o.Price));

            if (TradingAccount.IsSet(o.Account))
            {
                exReport.SetField(new Account(o.Account.Name));
            }

            return(exReport);
        }
Example #7
0
        // From fixprotocol.org:
        // CumQty: Currently executed shares for chain of orders.
        // LeavesQty: Amount of shares open for further execution. If the OrdStatus is Canceled,
        //            DoneForTheDay, Expired, Calculated, or Rejected (in which case the order
        //            is no longer active) then LeavesQty could be 0,
        //            otherwise LeavesQty = OrderQty - CumQty.
        // LastShares: Quantity of shares bought/sold on this (last) fill.
        //
        // Also see http://www.onixs.biz/fix-dictionary/4.2/msgType_8_8.html
        // The general rule is: OrderQty <38> = CumQty <14> + LeavesQty <151>.

        public Message CreateFillReport(OrderMatch match, string execID)
        {
            var exReport = new ExecutionReport(
                new OrderID(match.OrderID.ToString(CultureInfo.InvariantCulture)),
                new ExecID(execID),
                new ExecTransType(ExecTransType.NEW),
                new ExecType(match.MatchType == MatchType.Full
                                 ? ExecType.FILL
                                 : ExecType.PARTIAL_FILL),
                new OrdStatus(match.MatchType == MatchType.Full
                                  ? OrdStatus.FILLED
                                  : OrdStatus.PARTIALLY_FILLED),
                new Symbol(match.Contract.Symbol),
                TranslateFixFields.Translate(match.MarketSide),
                new LeavesQty(match.RemainingQuantity),
                new CumQty(match.OriginalOrderQuantity - match.RemainingQuantity),
                new AvgPx(match.Price))
            {
                ClOrdID    = new ClOrdID(match.ClOrdID),
                OrderQty   = new OrderQty(match.OriginalOrderQuantity),
                LastShares = new LastShares(match.MatchedQuantity),
                LastPx     = new LastPx(match.Price)
            };

            if (TradingAccount.IsSet(match.Account))
            {
                exReport.SetField(new Account(match.Account.Name));
            }

            return(exReport);
        }
Example #8
0
        internal static ExecutionReport CopyFromOrder(this ExecutionReport executionReport, NewOrderSingle newOrderSingle)
        {
            executionReport.Set(newOrderSingle.Symbol);
            executionReport.Set(newOrderSingle.Side);
            executionReport.Set(newOrderSingle.OrdType);
            executionReport.Set(newOrderSingle.ClOrdID);
            executionReport.Set(newOrderSingle.OrderQty);
            if (newOrderSingle.IsSetAccount())
            {
                executionReport.SetField(newOrderSingle.Account);
            }

            return(executionReport);
        }