예제 #1
0
        // ---

        public int reqOrder_async(ETRADER_OP nCmd, double dLots, double dPrice, EORDER_TYPE nOrderType, int nPriority, string sComment = "")
        {
            m_reqOrder_async.m_bProcessed = false;

            m_reqOrder_async.setProduct(m_sSymbol, m_site, m_sLogicID, m_dContractSize);
            m_reqOrder_async.setVal(nCmd, dLots, dPrice, nOrderType, nPriority, m_sLogicID, sComment);

            return(CSiteMng.registerOrder(m_reqOrder_async));
        }
예제 #2
0
        /// <summary>
        /// Merge reqOrders by product code ( defined by site & symbol)
        /// There is some problems.
        /// 1. IF different to request price on each logic
        /// 2. IF different to order type on each logic
        /// 3. IF different to priority on each logic
        /// </summary>
        /// <param name="nProductCode"></param>
        /// <returns></returns>
        private bool merge_reqOrders(int nPriority)
        {
            double dMergeLots = 0;
            int    nMergeCnt  = 0;

            m_reqMergeOrder.m_lstSubReqOrders.Clear();
            m_reqMergeOrder.m_product = null;

            foreach (TReqOrder reqOrder in m_lstReqOrders)
            {
                if (reqOrder.m_nPriority != nPriority)
                {
                    continue;
                }

                nMergeCnt++;
                if (m_reqMergeOrder.m_product == null)
                {
                    m_reqMergeOrder.setProduct(reqOrder.m_product.m_sSymbol, reqOrder.m_product.m_site, "REQ_MERGE", reqOrder.m_product.m_dContractSize);
                }

                m_reqMergeOrder.setVal(ETRADER_OP.NONE, 0, reqOrder.m_dPrice_req,
                                       reqOrder.m_nOrderType, reqOrder.m_nPriority, "REQ_MERGE", "");

                if (reqOrder.m_nCmd == ETRADER_OP.BUY || reqOrder.m_nCmd == ETRADER_OP.SELL_CLOSE)
                {
                    dMergeLots += reqOrder.m_dLots_req;
                }
                if (reqOrder.m_nCmd == ETRADER_OP.SELL || reqOrder.m_nCmd == ETRADER_OP.BUY_CLOSE)
                {
                    dMergeLots -= reqOrder.m_dLots_req;
                }
                m_reqMergeOrder.m_lstSubReqOrders.Add(reqOrder);// register sub req orders...
            }

            if (nMergeCnt == 0)
            {
                return(false);
            }

            if (Math.Abs(dMergeLots) < CFATCommon.ESP)
            {
                m_reqMergeOrder.m_dLots_exc = 0;
                m_reqMergeOrder.m_dLots_req = 0;
                return(true);
            }

            if (dMergeLots > CFATCommon.ESP)
            {
                m_reqMergeOrder.m_nCmd = ETRADER_OP.BUY;
            }

            if (dMergeLots < 0)
            {
                m_reqMergeOrder.m_nCmd = ETRADER_OP.SELL;
            }

            m_reqMergeOrder.m_dLots_req = Math.Abs(dMergeLots);

            return(true);
        }