コード例 #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
        private static Order Convert(MessageType commandType,
                                     Symbol symbol,
                                     Side side,
                                     OrdType ordType,
                                     OrderQty orderQty,
                                     Price price,
                                     ClOrdID clOrdId,
                                     Account account)
        {
            switch (ordType.getValue())
            {
            case OrdType.LIMIT:
                if (price.Obj == 0)
                {
                    throw new IncorrectTagValue(price.Tag);
                }

                break;

            //case OrdType.MARKET: break;

            default:
                throw new IncorrectTagValue(ordType.Tag);
            }
            var orderId = DIContainer.ResolveByName <IdGenerator>("OrderIdGenerator").GenerateId();

            return(new Order
            {
                CommandType = commandType,
                OrderId = orderId,
                OrderSide = FixFieldsConverter.Convert(side),
                Asset = new Asset(symbol.getValue()),
                OrderType = FixFieldsConverter.Convert(ordType),
                Quantity = orderQty.getValue(),
                Price = price.getValue(),
                ClOrdId = clOrdId.getValue(),
                Account =
                    account == null
                            ? TradingAccount.None
                            : new TradingAccount(account.getValue())
            });
        }