Example #1
0
 private void SKQuoteLib_OnConnection(int nKind, int nCode)
 {
     if (nKind == 3003 && nCode == 0)
     {
         short nPage = 0;
         m_pSKQuoteLib.SKQuoteLib_RequestStocks(ref nPage, strStocks);
     }
 }
Example #2
0
        static void Main(string[] args)
        {
            SKCenterLib m_pSKCenter = new SKCenterLib();
            SKReplyLib  m_pSKReply  = new SKReplyLib();
            //skReply1.SKReplyLib = m_pSKReply;

            SKQuoteLib m_SKQuoteLib = new SKQuoteLib();
            //skQuote1.SKQuoteLib = m_pSKQuote;

            SKOSQuoteLib m_pSKOSQuote = new SKOSQuoteLib();
            //skosQuote1.SKOSQuoteLib = m_pSKOSQuote;

            SKOOQuoteLib m_pSKOOQuote = new SKOOQuoteLib();

            int m_nCode = m_pSKCenter.SKCenterLib_Login("M121591178", "1q2w3e4r");

            if (m_nCode == 0)
            {
                Console.WriteLine("登入成功!!");
            }
            else
            {
                Console.WriteLine("登入失敗!!");
            }

            //connection
            m_SKQuoteLib.OnConnection            += new _ISKQuoteLibEvents_OnConnectionEventHandler(m_SKQuoteLib_OnConnection);
            m_SKQuoteLib.OnNotifyQuote           += new _ISKQuoteLibEvents_OnNotifyQuoteEventHandler(m_SKQuoteLib_OnNotifyQuote);
            m_SKQuoteLib.OnNotifyHistoryTicks    += new _ISKQuoteLibEvents_OnNotifyHistoryTicksEventHandler(m_SKQuoteLib_OnNotifyHistoryTicks);
            m_SKQuoteLib.OnNotifyTicks           += new _ISKQuoteLibEvents_OnNotifyTicksEventHandler(m_SKQuoteLib_OnNotifyTicks);
            m_SKQuoteLib.OnNotifyBest5           += new _ISKQuoteLibEvents_OnNotifyBest5EventHandler(m_SKQuoteLib_OnNotifyBest5);
            m_SKQuoteLib.OnNotifyKLineData       += new _ISKQuoteLibEvents_OnNotifyKLineDataEventHandler(m_SKQuoteLib_OnNotifyKLineData);
            m_SKQuoteLib.OnNotifyServerTime      += new _ISKQuoteLibEvents_OnNotifyServerTimeEventHandler(m_SKQuoteLib_OnNotifyServerTime);
            m_SKQuoteLib.OnNotifyMarketTot       += new _ISKQuoteLibEvents_OnNotifyMarketTotEventHandler(m_SKQuoteLib_OnNotifyMarketTot);
            m_SKQuoteLib.OnNotifyMarketBuySell   += new _ISKQuoteLibEvents_OnNotifyMarketBuySellEventHandler(m_SKQuoteLib_OnNotifyMarketBuySell);
            m_SKQuoteLib.OnNotifyMarketHighLow   += new _ISKQuoteLibEvents_OnNotifyMarketHighLowEventHandler(m_SKQuoteLib_OnNotifyMarketHighLow);
            m_SKQuoteLib.OnNotifyMACD            += new _ISKQuoteLibEvents_OnNotifyMACDEventHandler(m_SKQuoteLib_OnNotifyMACD);
            m_SKQuoteLib.OnNotifyBoolTunel       += new _ISKQuoteLibEvents_OnNotifyBoolTunelEventHandler(m_SKQuoteLib_OnNotifyBoolTunel);
            m_SKQuoteLib.OnNotifyFutureTradeInfo += new _ISKQuoteLibEvents_OnNotifyFutureTradeInfoEventHandler(m_SKQuoteLib_OnNotifyFutureTradeInfo);
            m_SKQuoteLib.OnNotifyStrikePrices    += new _ISKQuoteLibEvents_OnNotifyStrikePricesEventHandler(m_SKQuoteLib_OnNotifyStrikePrices);
            m_SKQuoteLib.OnNotifyStockList       += new _ISKQuoteLibEvents_OnNotifyStockListEventHandler(m_SKQuoteLib_OnNotifyStockList);


            string[] Stocks = txtStocks.Text.Trim().Split(new Char[] { ',' });

            foreach (string s in Stocks)
            {
                SKSTOCK pSKStock = new SKSTOCK();

                int nCode = m_SKQuoteLib.SKQuoteLib_GetStockByNo(s.Trim(), ref pSKStock);

                OnUpDateDataRow(pSKStock);

                if (nCode == 0)
                {
                    OnUpDateDataRow(pSKStock);
                }
            }

            m_nCode = m_SKQuoteLib.SKQuoteLib_RequestStocks(ref sPage, txtStocks.Text.Trim());
        }
Example #3
0
        private void btnQueryStocks_Click(object sender, EventArgs e)
        {
            short sPage;

            if (short.TryParse(txtPageNo.Text, out sPage) == false && searchtype.SelectedIndex == -1)
            {
                return;
            }

            m_dtStocks.Clear();
            gridStocks.ClearSelection();

            gridStocks.DataSource = m_dtStocks;

            gridStocks.Columns["m_sStockidx"].Visible    = false;
            gridStocks.Columns["m_sDecimal"].Visible     = false;
            gridStocks.Columns["m_sTypeNo"].Visible      = false;
            gridStocks.Columns["m_cMarketNo"].Visible    = false;
            gridStocks.Columns["m_caStockNo"].HeaderText = "代碼";
            gridStocks.Columns["m_caName"].HeaderText    = "名稱";
            gridStocks.Columns["m_nOpen"].HeaderText     = "開盤價";
            //gridStocks.Columns["m_nHigh"].Visible = false;
            gridStocks.Columns["m_nHigh"].HeaderText = "最高";
            //gridStocks.Columns["m_nLow"].Visible = false;
            gridStocks.Columns["m_nLow"].HeaderText     = "最低";
            gridStocks.Columns["m_nClose"].HeaderText   = "成交價";
            gridStocks.Columns["m_nTickQty"].HeaderText = "單量";
            gridStocks.Columns["m_nRef"].HeaderText     = "昨收價";
            gridStocks.Columns["m_nBid"].HeaderText     = "買價";
            //gridStocks.Columns["m_nBc"].Visible = false;
            gridStocks.Columns["m_nBc"].HeaderText  = "買量";
            gridStocks.Columns["m_nAsk"].HeaderText = "賣價";
            //gridStocks.Columns["m_nAc"].Visible = false;
            gridStocks.Columns["m_nAc"].HeaderText = "賣量";
            //gridStocks.Columns["m_nTBc"].Visible = false;
            gridStocks.Columns["m_nTBc"].HeaderText = "買盤量";
            //gridStocks.Columns["m_nTAc"].Visible = false;
            gridStocks.Columns["m_nTAc"].HeaderText   = "賣盤量";
            gridStocks.Columns["m_nFutureOI"].Visible = false;
            //gridStocks.Columns["m_nTQty"].Visible = false;
            gridStocks.Columns["m_nTQty"].HeaderText = "總量";
            //gridStocks.Columns["m_nYQty"].Visible = false;
            gridStocks.Columns["m_nYQty"].HeaderText = "昨量";
            //gridStocks.Columns["m_nUp"].Visible = false;
            gridStocks.Columns["m_nUp"].HeaderText = "漲停";
            //gridStocks.Columns["m_nDown"].Visible = false;
            gridStocks.Columns["m_nDown"].HeaderText = "跌停";
            string stockstr = "";

            string[] Stocks = { };
            if (searchtype.SelectedIndex == 1)
            {
                using (SqlConnection connection = new SqlConnection(connectionstr))
                {
                    string[]   bstrDataset = new string[5];
                    string     sqlwhere    = "";
                    SqlCommand sqlcmd      = new SqlCommand();
                    sqlwhere = " WHERE PageNo=" + UserPagetxt.Text.ToString();

                    connection.Open();

                    sqlcmd.CommandText = @"SELECT [StockNo] FROM [dbo].[StockList] " + sqlwhere;
                    sqlcmd.Connection  = connection;
                    sqlcmd.CommandType = CommandType.Text;

                    using (SqlDataReader reader = sqlcmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            stockstr = stockstr + "," + reader.GetValue(0).ToString();
                        }
                    }
                }
                Stocks = stockstr.Split(new Char[] { ',' });
                Stocks = Stocks.Where((source, index) => index != 0).ToArray();//remove the first element
            }
            if (searchtype.SelectedIndex == 0)
            {
                Stocks = txtStocks.Text.Trim().Split(new Char[] { ',' });
            }


            foreach (string s in Stocks)
            {
                SKSTOCK pSKStock = new SKSTOCK();

                int nCode = SKQuoteLib.SKQuoteLib_GetStockByNo(s.Trim(), ref pSKStock);

                OnUpDateDataRow(pSKStock);

                if (nCode == 0)
                {
                    OnUpDateDataRow(pSKStock);
                }
            }

            m_nCode = SKQuoteLib.SKQuoteLib_RequestStocks(ref sPage, stockstr);

            txtPageNo.Text = sPage.ToString();

            SendReturnMessage("Quote", m_nCode, "SKQuoteLib_RequestStocks");
        }