Beispiel #1
0
        public void InsertTick(TICK pTick, short sMarketNo, short sStockidx, int nPtr)
        {
            DataRow myDataRow = m_dtTick.NewRow();

            myDataRow["m_nPtr"]  = pTick.m_nPtr;
            myDataRow["m_nTime"] = pTick.m_nTime;

            if (pTick.m_nBid == -999999)
            {
                myDataRow["m_nBid"] = 0;
            }
            else
            {
                myDataRow["m_nBid"] = pTick.m_nBid / 100.00;
            }

            if (pTick.m_nAsk == -999999)
            {
                myDataRow["m_nAsk"] = 0;
            }
            else
            {
                myDataRow["m_nAsk"] = pTick.m_nAsk / 100.00;
            }

            if (pTick.m_nAsk == -999999)
            {
                myDataRow["m_nClose"] = 0;
            }
            else
            {
                myDataRow["m_nClose"] = pTick.m_nClose / 100.00;
            }

            myDataRow["m_nQty"] = pTick.m_nQty;

            m_dtTick.Rows.Add(myDataRow);


            String symbol = "";
            String key    = sMarketNo.ToString() + sStockidx.ToString();

            if (symbolNames.Contains(key))
            {
                symbol = System.Convert.ToString(symbolNames[key]);
            }
            else
            {
                STOCK pSTOCK;
                int   nCode = Functions.SKQuoteLib_GetStockByIndex(sMarketNo, sStockidx, out pSTOCK);
                if (nCode == 0)
                {
                    int nMarketNo = pSTOCK.m_cMarketNo;
                    //商品代碼
                    symbolNames.Add(key, pSTOCK.m_caStockNo);
                    symbol = pSTOCK.m_caStockNo;
                }
            }

            //insert db
            Tick newTick = new Tick();

            newTick.marketNo = sMarketNo;
            newTick.stockIdx = symbol;
            newTick.ptr      = nPtr;
            newTick.date     = DateTime.Today.ToString("yyyyMMdd");
            newTick.time     = Convert.ToString(pTick.m_nTime).PadLeft(6, '0');
            if (pTick.m_nBid == -999999)
            {
                newTick.bid = 0;
            }
            else
            {
                newTick.bid = Convert.ToInt32(pTick.m_nBid / 100.00);
            }

            if (pTick.m_nAsk == -999999)
            {
                newTick.ask = 0;
            }
            else
            {
                newTick.ask = Convert.ToInt32(pTick.m_nAsk / 100.00);
            }

            if (pTick.m_nAsk == -999999)
            {
                newTick.close = 0;
            }
            else
            {
                newTick.close = Convert.ToInt32(pTick.m_nClose / 100.00);
            }

            newTick.qty = pTick.m_nQty;

            insertTickToDB(newTick);

            //Message Consuming Queue
            tickQueue.Add(newTick);
        }
Beispiel #2
0
 public static extern int SKQuoteLib_GetTick(int sMarketNo, int sStockidx, int nPtr, out TICK Tick);