public static void PlaceNewSingleOrder()
        {
            QuickFix44.NewOrderSingle order = new QuickFix44.NewOrderSingle();

            #region Order Details

            QuickFix.OrderQty   orderQty = new QuickFix.OrderQty(10); order.setField(orderQty);
            QuickFix.Symbol     symbol   = new QuickFix.Symbol("EGS48031C016"); order.setField(symbol);
            QuickFix.SecurityID secID    = new QuickFix.SecurityID("EGS48031C016"); order.setField(secID);
            QuickFix.Side       side     = new QuickFix.Side(Side.SELL); order.setField(side);
            QuickFix.OrdType    ordType  = new QuickFix.OrdType(OrdType.LIMIT); order.setField(ordType);
            QuickFix.Price      price    = new QuickFix.Price(10); order.setField(price);
            Currency            currency = new Currency("EGP"); order.setField(currency);
            Account             acc      = new Account("1003"); order.setField(acc);
            QuickFix.PartyID    custody  = new PartyID("5004"); order.setField(custody);
            TimeInForce         tif      = new TimeInForce(TimeInForce.DAY); order.setField(tif);
            IDSource            ids      = new IDSource("4"); order.setField(ids);
            TransactTime        tt       = new TransactTime(DateTime.Now); order.setField(tt);
            //SenderSubID ss = new SenderSubID("05095a"); order.setField(ss);
            #endregion Order Details

            #region Fix Order Message IDs

            QuickFix.ClOrdID clOrdID = new ClOrdID(Guid.NewGuid().ToString());
            order.setField(clOrdID);

            #endregion Fix Order Message IDs

            #region Exchange
            ExDestination    exd         = new ExDestination("CA"); order.setField(exd);
            TradingSessionID tradSession = new TradingSessionID("NOPL"); order.setField(tradSession);
            #endregion Exchange

            Session.sendToTarget(order, _app.SessionID);
        }
示例#2
0
        //[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.Synchronized)]
        public static void PlaceNewSingleOrder(string _clOrderID, string _clientID, string _securityCode, int _quantity, double _price, string _custodyCode,
                                               char _orderSide, char _orderType, string currencyCode, string exDestination, char _timeInForce, string groupID,
                                               char handleInst, DateTime expiration, bool hasAON, int minQty)
        {
            QuickFix44.NewOrderSingle order = new QuickFix44.NewOrderSingle();

            #region Order Details

            QuickFix.OrderQty   orderQty = new QuickFix.OrderQty(_quantity); order.setField(orderQty);
            QuickFix.Symbol     symbol   = new QuickFix.Symbol(_securityCode); order.setField(symbol);
            QuickFix.SecurityID secID    = new QuickFix.SecurityID(_securityCode); order.setField(secID);
            QuickFix.Side       side     = new QuickFix.Side(_orderSide); order.setField(side);
            QuickFix.OrdType    ordType  = new QuickFix.OrdType(_orderType); order.setField(ordType);
            QuickFix.Price      price    = new QuickFix.Price(_price); order.setField(price);
            Currency            currency = new Currency(currencyCode); order.setField(currency);
            Account             acc      = new Account(_clientID); order.setField(acc);
            //QuickFix.ClearingFirm custody = new ClearingFirm(_custodyCode);order.setField(custody);
            QuickFix.PartyID custody = new PartyID(_custodyCode); order.setField(custody);
            //QuickFix.PartyRole pr = new PartyRole(PartyRole.CUSTODIAN); order.setField(pr);
            //QuickFix.NoPartyIDs npid = new NoPartyIDs(1); order.setField(npid);
            //QuickFix.PartyIDSource pid = new PartyIDSource(PartyIDSource.PROPRIETARY); order.setField(pid);
            TimeInForce  tif = new TimeInForce(_timeInForce); order.setField(tif);
            IDSource     ids = new IDSource("4"); order.setField(ids);
            TransactTime tt  = new TransactTime(DateTime.Now); order.setField(tt);
            //SenderSubID ss = new SenderSubID("05095a"); order.setField(ss);
            if (_timeInForce == QuickFix.TimeInForce.GOOD_TILL_DATE)
            {
                ExpireDate ed = new ExpireDate(expiration.ToString("yyyyMMdd")); order.setField(ed);
                //ExpireTime et = new ExpireTime(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour + 4, 0, 0)); order.setField(et);
                ExpireTime et = new ExpireTime(expiration); order.setField(et);
            }
            if (hasAON)
            {
                order.setField(new ExecInst(ExecInst.ALL_OR_NONE.ToString()));
                order.setField(new MinQty(minQty));
            }
            #endregion Order Details

            #region Fix Order Message IDs

            QuickFix.ClOrdID clOrdID = new QuickFix.ClOrdID(string.Format("{0}{1}", _wcfMsgPrefix, _clOrderID));
            order.setField(clOrdID);

            #endregion Fix Order Message IDs

            #region Reporting

            //QuickFix.HandlInst handlInst = new QuickFix.HandlInst(QuickFix.HandlInst.AUTOMATED_EXECUTION_ORDER_PRIVATE_NO_BROKER_INTERVENTION); order.setField(handlInst);
            QuickFix.HandlInst handlInst = new QuickFix.HandlInst(handleInst); order.setField(handlInst);

            #endregion Reporting

            #region Exchange

            ExDestination    exd         = new ExDestination(exDestination); order.setField(exd);
            TradingSessionID tradSession = new TradingSessionID(groupID); order.setField(tradSession);
            #endregion Exchange

            Session.sendToTarget(order, _sessionID);
        }
        /// <summary>
        /// genera un mensaje especifico para Dukascopy
        /// </summary>
        /// <param name="clOrdID"></param>
        /// <param name="price"></param>
        /// <param name="ordType"></param>
        /// <param name="timeInForce"></param>
        /// <param name="symbol"></param>
        /// <param name="orderQty"></param>
        /// <param name="side"></param>
        /// <param name="expireTime"></param>
        /// <param name="account"></param>
        /// <param name="slippage"></param>
        public static void SubmitOrder(ClOrdID clOrdID, decimal?price, OrdType ordType, TimeInForce timeInForce, Symbol symbol, OrderQty orderQty, Side side, ExpireTime expireTime, Account account, decimal?slippage)
        {
            QuickFix44.NewOrderSingle message = new QuickFix44.NewOrderSingle(
                clOrdID,
                side,
                new TransactTime(DateTime.UtcNow),
                ordType);

            if (price.HasValue)
            {
                message.set(new Price((double)price.Value));
            }
            message.set(timeInForce);
            message.set(symbol);
            message.set(orderQty);
            if (expireTime != null)
            {
                message.set(expireTime);
            }
            if (account != null)
            {
                message.set(account);
            }
            if (slippage.HasValue)
            {
                message.setDouble(7011, (double)slippage.Value);
            }

            Credential dukascopyCredential = CredentialFactory.GetCredential(Counterpart.Dukascopy);

            Session.sendToTarget(message, dukascopyCredential.TradingSenderCompID, dukascopyCredential.TradingTargetCompID);
        }
示例#4
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) {}
        }
示例#5
0
        protected void ProcesssNewOrderSingleThread(object param)
        {
            QuickFix44.NewOrderSingle order = (QuickFix44.NewOrderSingle)param;
            while (true)
            {
                string clOrdId = order.getString(ClOrdID.FIELD);
                string account = order.getString(Account.FIELD);
                string symbol  = order.getString(Symbol.FIELD);
                double lvsQty  = order.getDouble(OrderQty.FIELD);
                char   ordType = order.getChar(OrdType.FIELD);
                char   side    = order.getChar(Side.FIELD);

                QuickFix44.ExecutionReport exReport = new QuickFix44.ExecutionReport();

                int i = 0;

                exReport.setField(new ExecID(i.ToString()));
                exReport.setField(new ExecTransType(ExecTransType.NEW));
                exReport.setField(new ClOrdID(clOrdId));
                exReport.setField(new OrderID(Guid.NewGuid().ToString()));
                exReport.setField(new ExecType(ExecType.NEW));
                exReport.setField(new OrdStatus(OrdStatus.NEW));
                exReport.setField(new TransactTime(DateTime.Now));
                exReport.setField(new LeavesQty(lvsQty));
                exReport.setField(new CumQty(0));
                exReport.setField(new AvgPx(0));
                exReport.setField(new MultiLegReportingType(MultiLegReportingType.SINGLE));
                exReport.setField(new Symbol(symbol));
                exReport.setField(new Account(account));
                //exReport.setField(new OrderCapacity(OrderCapacity.PRINCIPAL));
                //exReport.setField(new CustOrderCapacity(CustOrderCapacity.MEMBER_TRADING_FOR_THEIR_OWN_ACCOUNT));
                exReport.setField(new Side(side));
                exReport.setField(new OrdType(ordType));
                exReport.setField(new OpenClose(OpenClose.OPEN));
                exReport.setField(new TimeInForce(TimeInForce.GOOD_TILL_CANCEL));

                Session.sendToTarget(exReport, SessionID);
                Thread.Sleep(1000);
            }
        }
示例#6
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()
                 );
         }
     }
 }
 public override void onMessage(QuickFix44.NewOrderSingle message, SessionID sessionID)
 {
     process(message, sessionID);
 }