Beispiel #1
0
        public void publish_tick()
        {
            m_product_A.publish_tick();
            m_product_B.publish_tick();
            if (m_nType_price != EPRODUCT_TYPE_PRICE.A_B)
            {
                m_product_C.publish_tick();
            }

            //Publish self data
            string    sTxt       = "";
            TRatesMin ratesMin   = m_rates.getMin(0);
            DateTime  dtTime_cur = ratesMin.m_dtTime;

            if (m_dBid != m_dBid_published_tick || m_dAsk != m_dAsk_published_tick)
            {
                sTxt = string.Format("{0},{1},{2},{3},{4}", "CFD", m_sSymbolCFD, ratesMin.m_dtTime, m_dBid, m_dAsk);
                CMQClient.publish_msg(sTxt, CFATCommon.MQ_TOPIC_PRICE_TICK);
                m_dBid_published_tick = m_dBid;
                m_dAsk_published_tick = m_dAsk;
            }
            //-----------------------
        }
Beispiel #2
0
        public double getPrice(CCacheData cacheData, int nPos, ETIME_FRAME nTimeFrame = ETIME_FRAME.MIN1, EPRICE_MODE nPriceMode = EPRICE_MODE.BID, EPRICE_VAL nPriceVal = EPRICE_VAL.CLOSE)
        {
            double dRet = 0;

            if (nTimeFrame == ETIME_FRAME.MIN1)
            {
                if (nPriceMode == EPRICE_MODE.ASK)
                {
                    if (nPriceVal == EPRICE_VAL.OPEN)
                    {
                        return(cacheData.getMin(nPos).dAsk_open);
                    }
                    if (nPriceVal == EPRICE_VAL.HIGH)
                    {
                        return(cacheData.getMin(nPos).dAsk_high);
                    }
                    if (nPriceVal == EPRICE_VAL.LOW)
                    {
                        return(cacheData.getMin(nPos).dAsk_low);
                    }
                    if (nPriceVal == EPRICE_VAL.CLOSE)
                    {
                        return(cacheData.getMin(nPos).dAsk_close);
                    }
                }

                if (nPriceMode == EPRICE_MODE.BID)
                {
                    if (nPriceVal == EPRICE_VAL.OPEN)
                    {
                        return(cacheData.getMin(nPos).dBid_open);
                    }
                    if (nPriceVal == EPRICE_VAL.HIGH)
                    {
                        return(cacheData.getMin(nPos).dBid_high);
                    }
                    if (nPriceVal == EPRICE_VAL.LOW)
                    {
                        return(cacheData.getMin(nPos).dBid_low);
                    }
                    if (nPriceVal == EPRICE_VAL.CLOSE)
                    {
                        return(cacheData.getMin(nPos).dBid_close);
                    }
                }
            }

            if (nTimeFrame == ETIME_FRAME.TICK)
            {
                if (nPriceMode == EPRICE_MODE.ASK)
                {
                    return(cacheData.getTick(nPos).dAsk);
                }
                if (nPriceMode == EPRICE_MODE.BID)
                {
                    return(cacheData.getTick(nPos).dBid);
                }
            }

            return(dRet);
        }