Ejemplo n.º 1
0
        public string getString()
        {
            string sRet = "";

            sRet = string.Format("{0},{1},{2},{3}," +                                   //request open time, excute open time, request close time, request close time
                                 "{4},{5:0.000},{6:0.000},{7}," +                       // symbol, request lots, excute lots, command
                                 "{8:0.00000},{9:0.00000},{10:0.00000},{11:0.00000}," + // request open price, excute open price, request close price, excute close price
                                 "{12:0.00},{13},{14}",                                 // profit, logic id, comment
                                 m_dtOpenTime_req.ToString("yyyy-MM-dd HH:mm:ss.fff"), m_dtOpenTime_exc.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                                 m_dtCloseTime_req.ToString("yyyy-MM-dd HH:mm:ss.fff"), m_dtCloseTime_exc.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                                 m_sSymbol, m_dLots_req, m_dLots_exc, TRADER.cmd2String(m_nCmd),
                                 m_dOpenPrice_req, m_dOpenPrice_exc, m_dClosePrice_req, m_dClosePrice_exc,
                                 m_dProfit_real, m_sLogicID, m_sComment);
            return(sRet);
        }
Ejemplo n.º 2
0
        public override EFILLED_STATE reqOrder(string sSymbol, ETRADER_OP nCmd, ref double dLots, ref double dPrice, EORDER_TYPE nOrderType, string sLogicID, string sComment = "",
                                               double dLots_exc = 0, double dPrice_exc = 0, DateTime dtTime_exc = default(DateTime))
        {
            if (CFATManager.m_nRunMode == ERUN_MODE.SIMULATION)
            {
                return(base.reqOrder(sSymbol, nCmd, ref dLots, ref dPrice, nOrderType, sLogicID, sComment, dLots, dPrice, DateTime.Now));
            }

            string sCmd       = TRADER.cmd2String(nCmd);
            double dLots_req  = dLots;
            double dPrice_req = dPrice;

            bool bRet = CSHGoldAPI.sg_newOrder(sSymbol, sCmd, ref dPrice, ref dLots);

            if (!bRet)
            {
                return(EFILLED_STATE.FAIL);
            }

            return(base.reqOrder(sSymbol, nCmd, ref dLots_req, ref dPrice_req, nOrderType, sLogicID, sComment, dLots, dPrice, DateTime.Now));
        }
Ejemplo n.º 3
0
        private void requestOrder(ETRADER_OP nCmd, string sComment = "")
        {
            double dLots     = ex_dLots;
            double dPrice    = 0;
            double dCurPrice = 0;

            if (nCmd == ETRADER_OP.BUY || nCmd == ETRADER_OP.SELL_CLOSE)
            {//Buy or SellClose
                dCurPrice = m_dAsk_Shanghai;
                dPrice    = m_dAsk_Shanghai + ex_dSlippage;
                if (nCmd == ETRADER_OP.BUY)
                {
                    m_dOpen_ld_midPrice = m_dMid_London;
                    m_dMaxProfit        = -100;
                    m_dMinProfit        = 100;
                }
                m_dOpen10TickSeconds = get10TickSecond();
            }
            else//Sell or BuyClose
            {
                dCurPrice = m_dBid_Shanghai;
                dPrice    = m_dBid_Shanghai - ex_dSlippage;
                if (nCmd == ETRADER_OP.SELL)
                {
                    m_dOpen_ld_midPrice = m_dMid_London;
                    m_dMaxProfit        = -100;
                    m_dMinProfit        = 100;
                }
                m_dOpen10TickSeconds = get10TickSecond();
            }



            //For BackTest
            if (!CFATManager.isOnlineMode())
            {
                m_products[ID_SHANGHAI].reqOrder(nCmd, ref dLots, ref dPrice, EORDER_TYPE.MARKET, sComment);
                double dLDPrice = m_dMid_London;
                m_products[ID_LONDON].reqOrder(nCmd, ref dLots, ref dLDPrice, EORDER_TYPE.MARKET, sComment);
                return;
            }

            //For RealTime
            if (nCmd == ETRADER_OP.BUY_CLOSE || nCmd == ETRADER_OP.SELL_CLOSE)
            {
                if (ex_nIsNewOrder <= 0)
                {
                    ex_nIsNewOrder = 1;
                }
            }

            if (ex_nIsNewOrder > 0)
            {
                CFATLogger.output_proc(string.Format("Request order, cmd = {0}, current price ={1}, request price = {2}, request lost = {3}", TRADER.cmd2String(nCmd), dCurPrice, dPrice, dLots));
                m_products[ID_SHANGHAI].reqOrder(nCmd, ref dLots, ref dPrice, EORDER_TYPE.MARKET, sComment);
                CFATLogger.output_proc(string.Format("Response order, response price = {0}, response lost = {1}", dPrice, dLots));
                ex_nIsNewOrder--;
                m_bIsNeedCheckPosition = true;
            }
            else
            {
                CFATLogger.output_proc(string.Format("new Signal = {0}, ex_nIsNewOrder = {1}", TRADER.cmd2String(nCmd), ex_nIsNewOrder));
            }
        }