예제 #1
0
 public ExecutionReport(
     QuickFix.OrderID aOrderID,
     QuickFix.ExecID aExecID,
     QuickFix.ExecTransType aExecTransType,
     QuickFix.ExecType aExecType,
     QuickFix.OrdStatus aOrdStatus,
     QuickFix.Symbol aSymbol,
     QuickFix.Side aSide,
     QuickFix.OrderQty aOrderQty,
     QuickFix.LastShares aLastShares,
     QuickFix.LastPx aLastPx,
     QuickFix.LeavesQty aLeavesQty,
     QuickFix.CumQty aCumQty,
     QuickFix.AvgPx aAvgPx)
     : base(MsgType())
 {
     set(aOrderID);
     set(aExecID);
     set(aExecTransType);
     set(aExecType);
     set(aOrdStatus);
     set(aSymbol);
     set(aSide);
     set(aOrderQty);
     set(aLastShares);
     set(aLastPx);
     set(aLeavesQty);
     set(aCumQty);
     set(aAvgPx);
 }
예제 #2
0
 public OrderStatusRequest(
     QuickFix.ClOrdID aClOrdID,
     QuickFix.Side aSide)
     : base(MsgType())
 {
     set(aClOrdID);
     set(aSide);
 }
예제 #3
0
 public DontKnowTrade(
     QuickFix.DKReason aDKReason,
     QuickFix.Symbol aSymbol,
     QuickFix.Side aSide)
     : base(MsgType())
 {
     set(aDKReason);
     set(aSymbol);
     set(aSide);
 }
예제 #4
0
 public IOI(
     QuickFix.IOIid aIOIid,
     QuickFix.IOITransType aIOITransType,
     QuickFix.Side aSide,
     QuickFix.IOIQty aIOIQty)
     : base(MsgType())
 {
     set(aIOIid);
     set(aIOITransType);
     set(aSide);
     set(aIOIQty);
 }
예제 #5
0
 public OrderCancelRequest(
     QuickFix.OrigClOrdID aOrigClOrdID,
     QuickFix.ClOrdID aClOrdID,
     QuickFix.Symbol aSymbol,
     QuickFix.Side aSide)
     : base(MsgType())
 {
     set(aOrigClOrdID);
     set(aClOrdID);
     set(aSymbol);
     set(aSide);
 }
예제 #6
0
 public DontKnowTrade(
     QuickFix.OrderID aOrderID,
     QuickFix.ExecID aExecID,
     QuickFix.DKReason aDKReason,
     QuickFix.Side aSide)
     : base(MsgType())
 {
     set(aOrderID);
     set(aExecID);
     set(aDKReason);
     set(aSide);
 }
예제 #7
0
 public OrderCancelRequest(
     QuickFix.OrigClOrdID aOrigClOrdID,
     QuickFix.ClOrdID aClOrdID,
     QuickFix.Side aSide,
     QuickFix.TransactTime aTransactTime)
     : base(MsgType())
 {
     set(aOrigClOrdID);
     set(aClOrdID);
     set(aSide);
     set(aTransactTime);
 }
예제 #8
0
 public IndicationOfInterest(
     QuickFix.IOIid aIOIid,
     QuickFix.IOITransType aIOITransType,
     QuickFix.Side aSide,
     QuickFix.IOIQty aIOIQty)
     : base(MsgType())
 {
     set(aIOIid);
     set(aIOITransType);
     set(aSide);
     set(aIOIQty);
 }
예제 #9
0
 public IndicationofInterest(
     QuickFix.IOIid aIOIid,
     QuickFix.IOITransType aIOITransType,
     QuickFix.Symbol aSymbol,
     QuickFix.Side aSide,
     QuickFix.IOIShares aIOIShares)
     : base(MsgType())
 {
     set(aIOIid);
     set(aIOITransType);
     set(aSymbol);
     set(aSide);
     set(aIOIShares);
 }
예제 #10
0
 public NewOrderSingle(
     QuickFix.ClOrdID aClOrdID,
     QuickFix.HandlInst aHandlInst,
     QuickFix.Symbol aSymbol,
     QuickFix.Side aSide,
     QuickFix.OrdType aOrdType)
     : base(MsgType())
 {
     set(aClOrdID);
     set(aHandlInst);
     set(aSymbol);
     set(aSide);
     set(aOrdType);
 }
예제 #11
0
 public DontKnowTrade(
     QuickFix.DKReason aDKReason,
     QuickFix.Symbol aSymbol,
     QuickFix.Side aSide,
     QuickFix.OrderQty aOrderQty,
     QuickFix.LastShares aLastShares,
     QuickFix.LastPx aLastPx)
     : base(MsgType())
 {
     set(aDKReason);
     set(aSymbol);
     set(aSide);
     set(aOrderQty);
     set(aLastShares);
     set(aLastPx);
 }
예제 #12
0
 public OrderCancelReplaceRequest(
     QuickFix.OrigClOrdID aOrigClOrdID,
     QuickFix.ClOrdID aClOrdID,
     QuickFix.HandlInst aHandlInst,
     QuickFix.Symbol aSymbol,
     QuickFix.Side aSide,
     QuickFix.OrdType aOrdType)
     : base(MsgType())
 {
     set(aOrigClOrdID);
     set(aClOrdID);
     set(aHandlInst);
     set(aSymbol);
     set(aSide);
     set(aOrdType);
 }
예제 #13
0
 public Allocation(
     QuickFix.AllocID aAllocID,
     QuickFix.AllocTransType aAllocTransType,
     QuickFix.Side aSide,
     QuickFix.Symbol aSymbol,
     QuickFix.Shares aShares,
     QuickFix.AvgPx aAvgPx,
     QuickFix.TradeDate aTradeDate)
     : base(MsgType())
 {
     set(aAllocID);
     set(aAllocTransType);
     set(aSide);
     set(aSymbol);
     set(aShares);
     set(aAvgPx);
     set(aTradeDate);
 }
예제 #14
0
 public NewOrderList(
   QuickFix.ListID aListID,
   QuickFix.ListSeqNo aListSeqNo,
   QuickFix.ListNoOrds aListNoOrds,
   QuickFix.ClOrdID aClOrdID,
   QuickFix.HandlInst aHandlInst,
   QuickFix.Symbol aSymbol,
   QuickFix.Side aSide,
   QuickFix.OrderQty aOrderQty,
   QuickFix.OrdType aOrdType )
 : base(MsgType()) {
   set(aListID);
   set(aListSeqNo);
   set(aListNoOrds);
   set(aClOrdID);
   set(aHandlInst);
   set(aSymbol);
   set(aSide);
   set(aOrderQty);
   set(aOrdType);
 }
예제 #15
0
 public QuickFix.Side getSide()
 {
     QuickFix.Side value = new QuickFix.Side();
     getField(value); return value;
 }
예제 #16
0
 public bool isSet(QuickFix.Side field)
 {
     return(isSetField(field));
 }
예제 #17
0
 public QuickFix.Side getSide()
 {
     QuickFix.Side value = new QuickFix.Side();
     getField(value); return(value);
 }
예제 #18
0
 public QuickFix.Side get(QuickFix.Side value)
 {
     getField(value); return(value);
 }
예제 #19
0
 public void set(QuickFix.Side value)
 {
     setField(value);
 }
예제 #20
0
        /// <summary>
        /// submit an order to IB using a incomming FIX new order single
        /// </summary>
        /// <param name="myMsg"></param>
        private void submitOrder(KaiTrade.Interfaces.IMessage myMsg)
        {
            QuickFix.Message myQFOrder = null;
            try
            {
                // Extract the raw FIX Message from the inbound message
                string strOrder = myMsg.Data;

                // Use QuickFix to handle the message
                myQFOrder = new QuickFix.Message(strOrder);

                // Use product manager to validate the product specified on
                // the order exists for this adapter

                // Get the product associated with the FIX message

                //QuickFix.Symbol symbol = new QuickFix.Symbol();
                //myQFOrder.getField(symbol);

                QuickFix.Side mySide = new QuickFix.Side();
                QuickFix.OrdType myOrdType = new QuickFix.OrdType();
                QuickFix.OrderQty myOrderQty = new QuickFix.OrderQty();
                QuickFix.Price myPrice = new QuickFix.Price();
                QuickFix.StopPx myStopPx = new QuickFix.StopPx();
                QuickFix.Account myAccount = new QuickFix.Account();

                QuickFix.ClOrdID myClOrdID = new QuickFix.ClOrdID();
                QuickFix.TimeInForce myTimeInForce = new QuickFix.TimeInForce();

                // the account code is mandatory
                if (myQFOrder.isSetField(myAccount))
                {
                    myQFOrder.getField(myAccount);
                }
                else
                {
                    this.SendAdvisoryMessage("IB TWS: you need to provide a valid account");
                    throw new Exception("IB TWS: you need to provide a valid account");
                }

                myQFOrder.getField(myClOrdID);

                // Get the Order type
                myQFOrder.getField(myOrdType);

                // Get the QTY
                myQFOrder.getField(myOrderQty);

                // get the Side of the order
                myQFOrder.getField(mySide);

                // Set order duration
                myQFOrder.getField(myTimeInForce);

                // Prices
                if (myQFOrder.isSetField(myPrice))
                {
                    myQFOrder.getField(myPrice);
                }

                if (myQFOrder.isSetField(myStopPx))
                {
                    myQFOrder.getField(myStopPx);
                }

                // get the contract
                TWSLib.IContract myContract = getIBContract(myQFOrder);
                if (myContract == null)
                {
                    this.SendAdvisoryMessage("IB TWS: cannot find a valid contract");
                    throw new Exception("IB TWS: cannot find a valid contract");
                }

                // create an IB Order
                TWSLib.IOrder myIBOrder = m_Host.TWS.createOrder();

                myIBOrder.whatIf = 0;
                myIBOrder.account = myAccount.getValue();

                if(myOrdType.getValue() == QuickFix.OrdType.LIMIT)
                {
                    myIBOrder.orderType = "LMT";
                    myIBOrder.lmtPrice = myPrice.getValue();
                }
                else if(myOrdType.getValue() == QuickFix.OrdType.MARKET)
                {
                    myIBOrder.orderType = "MKT";
                }
                else if (myOrdType.getValue() == QuickFix.OrdType.STOP)
                {
                    myIBOrder.orderType = "STP";
                    myIBOrder.auxPrice = myStopPx.getValue();
                    if (myPrice.getValue() == -1)
                    {
                        myIBOrder.lmtPrice = myStopPx.getValue();
                    }
                    else
                    {
                        myIBOrder.lmtPrice = myPrice.getValue();
                    }
                }
                else if (myOrdType.getValue() == QuickFix.OrdType.STOP_LIMIT)
                {
                    myIBOrder.orderType = "STP";
                    myIBOrder.auxPrice = myStopPx.getValue();
                    if (myPrice.getValue() == -1)
                    {
                        myIBOrder.lmtPrice = myStopPx.getValue();
                    }
                    else
                    {
                        myIBOrder.lmtPrice = myPrice.getValue();
                    }
                }
                else
                {
                    this.SendAdvisoryMessage("IB TWS: order type not supported");
                    throw new Exception("IB TWS: order type not supported");
                }

                myIBOrder.totalQuantity = (int) myOrderQty.getValue();

                // Side
                string myAction = KaiUtil.QFUtils.DecodeSide(mySide).ToUpper();
                myIBOrder.action = myAction;

                // Time in force
                string myTIF = KaiUtil.QFUtils.DecodeTimeInForce(myTimeInForce).ToUpper();
                myIBOrder.timeInForce = myTIF;

                if (myOrdType.getValue() == QuickFix.OrdType.LIMIT)
                {
                    myIBOrder.lmtPrice = myPrice.getValue();
                }

                DriverBase.OrderContext myCntx = RecordOrderContext(myClOrdID.getValue(), myQFOrder, null, m_NextID.ToString());
                SetContextCommand(myCntx, DriverBase.ORCommand.Undefined, DriverBase.ORCommand.Submit);

                myCntx.OrderQty = myIBOrder.totalQuantity;
                myCntx.CumQty = 0;

                m_Host.TWS.placeOrderEx(m_NextID++, myContract, myIBOrder);

            }
            catch (Exception myE)
            {

                _log.Error("submitOrder", myE);
                // To provide the end user with more information
                // send an advisory message, again this is optional
                // and depends on the adpater
                this.SendAdvisoryMessage("IB TWS:submitOrder: problem submitting order:" + myE.ToString());

                QuickFix.OrdStatus myOrdStatus;
                QuickFix.ExecType myExecType = new QuickFix.ExecType(QuickFix.ExecType.REJECTED);

                myOrdStatus = new QuickFix.OrdStatus(QuickFix.OrdStatus.REJECTED);
                QuickFix.OrderQty orderQty = new QuickFix.OrderQty();
                if (myQFOrder != null)
                {
                    myQFOrder.getField(orderQty);
                    QuickFix.OrdRejReason myRejReason = new QuickFix.OrdRejReason(QuickFix.OrdRejReason.OTHER);
                    sendExecReport(myQFOrder, new QuickFix.OrderID("UNKNOWN"), myOrdStatus, myExecType, 0.0, (int)orderQty.getValue(), 0, 0, 0, myE.Message, myRejReason);
                }

            }
        }