Пример #1
0
        public void clearPositions()
        {
            //Clear Virtual positions
            m_site.clearVirtualPositions(m_sSymbol);

            //Clear Real positions
            double dLots = m_site.getPosLots_Total_real(m_sSymbol);

            if (Math.Abs(dLots) < CFATCommon.ESP)
            {
                return;
            }

            ETRADER_OP nCmd = ETRADER_OP.NONE;

            if (dLots > 0) // Buy
            {
                nCmd = ETRADER_OP.BUY_CLOSE;
            }
            else // Sell
            {
                nCmd = ETRADER_OP.SELL_CLOSE;
            }

            double dReqLots  = Math.Abs(dLots);
            double dReqPrice = 0;

            if (nCmd == ETRADER_OP.BUY_CLOSE) //Sell
            {
                dReqPrice = getTick(0).dBid;
            }

            if (nCmd == ETRADER_OP.SELL_CLOSE) //Buy
            {
                dReqPrice = getTick(0).dAsk;
            }

            reqOrder(nCmd, ref dReqLots, ref dReqPrice, EORDER_TYPE.MARKET);
        }