/// <summary>
 /// Constructor
 /// </summary>
 /// <param name="firstOrder"></param>
 public OrderHistory(OrderInfo firstOrder)
 {
     if (firstOrder != null)
     {
         m_OrderHistory.Add(firstOrder);
         m_CurrentOrder = new OrderInfo(firstOrder);
     }
 }
Пример #2
0
        /// <summary>
        /// Submit new order
        /// </summary>
        /// <param name="sTE">ES Ticker Mnemomic (internal ER symbol for instrument</param>
        /// <param name="bBuy">is it a buy or sell</param>
        /// <param name="dPrice">price of order</param>
        /// <param name="nVolume">volume of order</param>
        /// <returns></returns>
        public bool SubmitNewOrder(string sTE, bool bBuy, double? dPrice, int nVolume,  OrderType sOrderType, TimeInForce sTimeInForce)
        {
            /*
                BodyLength=232
                MsgType=NewOrderSingle<D>
                ESTickerMnemonic=3FX:EUR-GBP
                ESTickerSymbol=EUR-GBP
                ESExchange=F
                ESPriceFormatCode=0
                SecurityExchange=3
                PutOrCall=OptionTypePut<0>
                SecurityType=FOR
                Symbol=EUR
                CFICode=MRCXXX
                Currency=EUR
                ESDecimalPlaces=4
                ESUnitTickValue=0.000000
                ESCompositeDelta=0.000000
                ESShortOptAdjust=0.000000
                Side=SideSell<2>
                OpenClose=Open<O>
                ESAccountID=9
                ESAccountName=apj
                HandlInst=2
                ESDefaultFieldSanityCheck=True
                OrdType=OrderTypeLimit<2>
                TimeInForce=TimeInForceImmediateOrCancel<3>
                Price=0.67501
                StopPx=0
                TradingSessionID=2
                OrderQty=1
             */

            OrderInfo order = new OrderInfo(sTE);
            order.Price = dPrice;
            order.OrderQty = nVolume;

            if (bBuy == true)
            {
                order.Side = MESSAGEFIX3Lib.FIXSideConstants.esFIXSideBuy;
            }
            else
            {
                order.Side = MESSAGEFIX3Lib.FIXSideConstants.esFIXSideSell;
            }

            order.OrderType = sOrderType;
            order.TimeInForce = sTimeInForce;
            return SubmitNewOrder(order);
        }
 /// <summary>
 /// Update the current order with the FIX message trade or order update
 /// </summary>
 /// <param name="order"></param>
 public void UpdateOrder(OrderInfo order)
 {
     if (m_CurrentOrder != null)
     {
         if ((order.ExecutionReportStatus != Status.PendingCancel) &&
            (order.ExecutionReportStatus != Status.PendingReplace))
         {
             m_CurrentOrder.ApplyChanges(order);
         }
         else
         {
             if(order.TransactTime != null)
                 m_CurrentOrder.TransactTime = order.TransactTime;
         }
         m_OrderHistory.Add(order);
     }
 }
Пример #4
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;
        }
Пример #5
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;
        }
Пример #6
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;
        }
Пример #7
0
        /// <summary>
        /// Apply changes from another Order
        /// </summary>
        /// <param name="order"></param>
        public void ApplyChanges(OrderInfo order)
        {
            this.m_nLeavesQty = order.m_nLeavesQty;
            this.m_nOrderQty = order.m_nOrderQty;
            this.m_nCumQty = order.m_nCumQty;
            if (this.m_dTotalFilledPrice.HasValue)
                this.m_dTotalFilledPrice += order.m_dTotalFilledPrice;
            else
                this.m_dTotalFilledPrice = order.m_dTotalFilledPrice;

            if (order.m_dPrice.HasValue)
                this.m_dPrice = order.m_dPrice;
            else
                order.m_dPrice = this.Price;
            this.m_nSecondBOID = order.m_nSecondBOID;

            this.m_sExecutionReportStatus = order.m_sExecutionReportStatus;

            if (order.m_TransactTime != null)
                this.m_TransactTime = order.m_TransactTime;
            else
                order.m_TransactTime = this.m_TransactTime;
        }
Пример #8
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="order"></param>
 public OrderInfo(OrderInfo order)
 {
     this.m_nLeavesQty = order.m_nLeavesQty;
     this.m_nOrderQty = order.m_nOrderQty;
     this.m_dPrice = order.m_dPrice;
     this.m_nSecondBOID = order.m_nSecondBOID;
     this.m_sExecutionReportStatus = order.m_sExecutionReportStatus;
     this.m_TransactTime = order.m_TransactTime;
     this.m_instrument = order.m_instrument;
     this.m_nCumQty = order.m_nCumQty;
     this.m_sClOrdID = order.m_sClOrdID;
     this.m_sSide = order.m_sSide;
     this.m_sExecutionReportStatus = order.m_sExecutionReportStatus;
     this.m_sTickerMnemonic = order.m_sTickerMnemonic;
     this.m_sTimeInForce = order.m_sTimeInForce;
     this.m_sOrderType = order.m_sOrderType;
     this.PrimaryBOID = order.PrimaryBOID;
     this.m_iAccountID = order.m_iAccountID;
 }