コード例 #1
0
        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);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
0
        public Message CreateRejectNewOrderExecutionReport(string symbol,
                                                           MarketSide marketSide,
                                                           string clOrdID,
                                                           decimal orderQuantity,
                                                           TradingAccount account,
                                                           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),
                new Symbol(symbol),
                TranslateFixFields.Translate(marketSide),
                new LeavesQty(0m),
                new CumQty(0m),
                new AvgPx(0m))
            {
                ClOrdID  = new ClOrdID(clOrdID),
                OrderQty = new OrderQty(orderQuantity)
            };

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

            if (TradingAccount.IsSet(account))
            {
                exReport.Account = new Account(account.Name);
            }

            return(exReport);
        }