Beispiel #1
0
        public override void onMessage(QuickFix44.NewOrderSingle order, SessionID sessionID)
        {
            Symbol   symbol   = new Symbol();
            Side     side     = new Side();
            OrdType  ordType  = new OrdType();
            OrderQty orderQty = new OrderQty();
            Price    price    = new Price();
            ClOrdID  clOrdID  = new ClOrdID();

            order.get(ordType);

            if (ordType.getValue() != OrdType.LIMIT)
            {
                throw new IncorrectTagValue(ordType.getField());
            }

            order.get(symbol);
            order.get(side);
            order.get(orderQty);
            order.get(price);
            order.get(clOrdID);

            QuickFix44.ExecutionReport executionReport = new QuickFix44.ExecutionReport
                                                             (genOrderID(),
                                                             genExecID(),
                                                             new ExecType(ExecType.FILL),
                                                             new OrdStatus(OrdStatus.FILLED),
                                                             side,
                                                             new LeavesQty(0),
                                                             new CumQty(orderQty.getValue()),
                                                             new AvgPx(price.getValue()));

            executionReport.set(clOrdID);
            executionReport.set(symbol);
            executionReport.set(orderQty);
            executionReport.set(new LastQty(orderQty.getValue()));
            executionReport.set(new LastPx(price.getValue()));

            if (order.isSetAccount())
            {
                executionReport.setField(order.getAccount());
            }

            try
            {
                Session.sendToTarget(executionReport, sessionID);
            }
            catch (SessionNotFound) {}
        }
Beispiel #2
0
 public void exampleTrading(AccountsWindow accounts, RatesWindow rates, char direction)
 {
     exampleRunning = true;
     if (instruments == null)
     {
         instruments = rates.symbols();
     }
     foreach (QuickFix.Symbol instrument in rates.symbols())
     {
         // place a market order on each available account
         foreach (QuickFix.Account account in accounts.accounts())
         {
             // create a NewOrderSingle Market
             QuickFix44.NewOrderSingle order = new QuickFix44.NewOrderSingle(
                 new QuickFix.ClOrdID(sessionID + "-" + DateTime.Now.Ticks + "-" + nextID().ToString()),
                 new QuickFix.Side(direction),
                 new QuickFix.TransactTime(),
                 new QuickFix.OrdType(QuickFix.OrdType.MARKET)
                 );
             order.set(account);
             order.set(instrument);
             // get the minimum quantity from the RatesWindow
             order.set(new QuickFix.OrderQty(rates.minQty(instrument)));
             order.set(new QuickFix.TimeInForce(QuickFix.TimeInForce.GOOD_TILL_CANCEL));
             order.set(new QuickFix.SecondaryClOrdID("fix_example_test"));
             // sent the order to the API
             send(order, sessionID);
             // write note to the log
             Console.WriteLine(
                 "An order for {0:N0} {1} on {2} placed on {3}",
                 order.getOrderQty().getValue(),
                 ((order.getSide().getValue() == 2) ? "Sell" : "Buy"),
                 order.getSymbol().getValue(),
                 order.getAccount().getValue()
                 );
         }
     }
 }