Exemplo n.º 1
0
        /// <summary>
        /// Pulls order specified
        /// </summary>
        /// <param name="order">order info object</param>
        /// <returns></returns>
        public bool PullOrder(OrderInfo order)
        {
            if (order.Instrument == null)
            {
                LogFileWriter.TraceEvent(TraceEventType.Error, "Attempt to pull an order {0} with no structure defined", order.ToString());
                return false;
            }

            //MESSAGEFIX3Lib.FIXMsgConstants.esFIXMsgNewOrderSingle
            FIXMessage message = order.CreateFixMessage(MESSAGEFIX3Lib.FIXMsgConstants.esFIXMsgNewOrderSingle);

            Account account = m_AccountManagement.FindAccount(order.AccountID, message);

            if (account != null)
            {
                account.ApplyDefaults(order.Instrument.SecurityExchange, message);
                message.MsgType = MESSAGEFIX3Lib.FIXMsgConstants.esFIXMsgOrderCancelRequest;
                message.set_AsNumber(MESSAGEFIX3Lib.FIXTagConstants.esFIXTagESVAOState, 0);
                m_Router.SendMsg((EASYROUTERCOMCLIENTLib.IFIXMessage)message);
                return true;
            }
            return false;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Submit new order
        /// </summary>
        /// <param name="newOrder">Deatils fo teh order to be placed</param>
        /// <returns></returns>
        public bool SubmitNewOrder(OrderInfo newOrder,Hashtable table)
        {
            //add defaults
            MESSAGEFIX3Lib.FIXMsgConstants MsgType = MESSAGEFIX3Lib.FIXMsgConstants.esFIXMsgNewOrderSingle;
            FIXMessage message = newOrder.CreateFixMessage(MsgType);

            if (message == null)
                return false;

            Account account = m_AccountManagement.FindAccount(newOrder.AccountID, message);

            if (account != null)
            {
                account.ApplyDefaults(newOrder.Instrument.SecurityExchange, message);
                if(table.Count > 0)
                    account.ApplyDefaults(newOrder.Instrument.SecurityExchange, message,table);

                return m_Router.SendMsg((EASYROUTERCOMCLIENTLib.IFIXMessage)message);
            }
            return false;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Pass in the order information to be modified 
        /// </summary>
        /// <param name="order">order info object</param>
        /// <param name="dPrice">new price - enter old price if unchanged</param>
        /// <param name="nVolume">new volume - enter old volume if unchanged</param>
        /// <returns></returns>
        public bool EditOrder(OrderInfo order, double? dPrice, int nVolume)
        {
            bool bRetVal = true;

            switch (order.ExecutionReportStatus)
            {
                case Status.PendingNew:
                case Status.PendingReplace:
                case Status.PendingActivate:
                case Status.PendingCancel:
                case Status.Cancelled:
                case Status.Fill:
                    LogFileWriter.TraceEvent(TraceEventType.Error, "Attempt to edit an order {0} with invalid execution report status {1}", order.ToString(), order.ExecutionReportStatus.ToString());
                    return false;
            }

            if (order.Instrument == null)
            {
                LogFileWriter.TraceEvent(TraceEventType.Error, "Attempt to edit an order {0} with no structure defined", order.ToString());
                return false;
            }

            FIXMessage message = order.CreateFixMessage(MESSAGEFIX3Lib.FIXMsgConstants.esFIXMsgOrderModifyRequest);

            Account account = m_AccountManagement.FindAccount(order.AccountID, message);

            if (account != null)
            {
                account.ApplyDefaults(order.Instrument.SecurityExchange, message);

                message.RemoveGroup(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagOrderQty);

                message.RemoveGroup(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagLeavesQty);

                int nDelta = nVolume - order.LeavesQty;
                int nOrderQty = order.OrderQty + nDelta;

                message.set_AsNumber(MESSAGEFIX3Lib.FIXTagConstants.esFIXTagOrderQty, nOrderQty);
                message.set_AsNumber(MESSAGEFIX3Lib.FIXTagConstants.esFIXTagLeavesQty, nVolume);
                message.set_AsNumber(MESSAGEFIX3Lib.FIXTagConstants.esFIXTagESOrderDeltaQty, nDelta);

                message.RemoveGroup(EASYROUTERCOMCLIENTLib.FIXTagConstants.esFIXTagPrice);
                if (dPrice.HasValue)
                    message.set_AsDouble(MESSAGEFIX3Lib.FIXTagConstants.esFIXTagPrice, dPrice.Value);

                bRetVal = m_Router.SendMsg((EASYROUTERCOMCLIENTLib.IFIXMessage)message);
            }
            else
            {
                bRetVal = false;
            }
            return bRetVal;
        }