Esempio n. 1
0
        SKSTOCK GetSKSTOCKByCode(string code)
        {
            SKSTOCK pSKStock = new SKSTOCK();
            int     nCode    = m_SKQuoteLib.SKQuoteLib_GetStockByNo(code, ref pSKStock);

            return(pSKStock);
        }
Esempio n. 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());
        }
Esempio n. 3
0
        void m_SKQuoteLib_OnNotifyBest5(short sMarketNo, short sStockIdx, int nBestBid1, int nBestBidQty1, int nBestBid2, int nBestBidQty2, int nBestBid3, int nBestBidQty3, int nBestBid4, int nBestBidQty4, int nBestBid5, int nBestBidQty5, int nExtendBid, int nExtendBidQty, int nBestAsk1, int nBestAskQty1, int nBestAsk2, int nBestAskQty2, int nBestAsk3, int nBestAskQty3, int nBestAsk4, int nBestAskQty4, int nBestAsk5, int nBestAskQty5, int nExtendAsk, int nExtendAskQty, int nSimulate)
        {
            //0:一般;1:試算揭示
            if (nSimulate == 0)
            {
                GridBest5Ask.ForeColor = Color.Black;
                GridBest5Bid.ForeColor = Color.Black;
            }
            else
            {
                GridBest5Ask.ForeColor = Color.Gray;
                GridBest5Bid.ForeColor = Color.Gray;
            }

            SKSTOCK pSKStock       = new SKSTOCK();
            double  dDigitNum      = 0.000;
            string  strStockNoTick = txtTick.Text.Trim();
            int     nCode          = SKQuoteLib.SKQuoteLib_GetStockByNo(strStockNoTick, ref pSKStock);

            //[-1022-a-]
            if (nCode == 0)
            {
                dDigitNum = (Math.Pow(10, pSKStock.sDecimal));
            }
            else
            {
                dDigitNum = 100.00;//default value
            }
            if (m_dtBest5Ask.Rows.Count == 0 && m_dtBest5Bid.Rows.Count == 0)
            {
                DataRow myDataRow;

                myDataRow = m_dtBest5Ask.NewRow();
                myDataRow["m_nAskQty"] = nBestAskQty1;
                myDataRow["m_nAsk"]    = nBestAsk1 / dDigitNum;///100.00;
                m_dtBest5Ask.Rows.Add(myDataRow);

                myDataRow = m_dtBest5Ask.NewRow();
                myDataRow["m_nAskQty"] = nBestAskQty2;
                myDataRow["m_nAsk"]    = nBestAsk2 / dDigitNum;//100.00;
                m_dtBest5Ask.Rows.Add(myDataRow);

                myDataRow = m_dtBest5Ask.NewRow();
                myDataRow["m_nAskQty"] = nBestAskQty3;
                myDataRow["m_nAsk"]    = nBestAsk3 / dDigitNum;//100.00;
                m_dtBest5Ask.Rows.Add(myDataRow);

                myDataRow = m_dtBest5Ask.NewRow();
                myDataRow["m_nAskQty"] = nBestAskQty4;
                myDataRow["m_nAsk"]    = nBestAsk4 / dDigitNum;// 100.00;
                m_dtBest5Ask.Rows.Add(myDataRow);

                myDataRow = m_dtBest5Ask.NewRow();
                myDataRow["m_nAskQty"] = nBestAskQty5;
                myDataRow["m_nAsk"]    = nBestAsk5 / dDigitNum;// 100.00;
                m_dtBest5Ask.Rows.Add(myDataRow);

                myDataRow = m_dtBest5Bid.NewRow();
                myDataRow["m_nAskQty"] = nBestBidQty1;
                myDataRow["m_nAsk"]    = nBestBid1 / dDigitNum;
                m_dtBest5Bid.Rows.Add(myDataRow);

                myDataRow = m_dtBest5Bid.NewRow();
                myDataRow["m_nAskQty"] = nBestBidQty2;
                myDataRow["m_nAsk"]    = nBestBid2 / dDigitNum;
                m_dtBest5Bid.Rows.Add(myDataRow);

                myDataRow = m_dtBest5Bid.NewRow();
                myDataRow["m_nAskQty"] = nBestBidQty3;
                myDataRow["m_nAsk"]    = nBestBid3 / dDigitNum;
                m_dtBest5Bid.Rows.Add(myDataRow);

                myDataRow = m_dtBest5Bid.NewRow();
                myDataRow["m_nAskQty"] = nBestBidQty4;
                myDataRow["m_nAsk"]    = nBestBid4 / dDigitNum;
                m_dtBest5Bid.Rows.Add(myDataRow);

                myDataRow = m_dtBest5Bid.NewRow();
                myDataRow["m_nAskQty"] = nBestBidQty5;
                myDataRow["m_nAsk"]    = nBestBid5 / dDigitNum;
                m_dtBest5Bid.Rows.Add(myDataRow);
            }
            else
            {
                m_dtBest5Ask.Rows[0]["m_nAskQty"] = nBestAskQty1;
                m_dtBest5Ask.Rows[0]["m_nAsk"]    = nBestAsk1 / dDigitNum;

                m_dtBest5Ask.Rows[1]["m_nAskQty"] = nBestAskQty2;
                m_dtBest5Ask.Rows[1]["m_nAsk"]    = nBestAsk2 / dDigitNum;

                m_dtBest5Ask.Rows[2]["m_nAskQty"] = nBestAskQty3;
                m_dtBest5Ask.Rows[2]["m_nAsk"]    = nBestAsk3 / dDigitNum;

                m_dtBest5Ask.Rows[3]["m_nAskQty"] = nBestAskQty4;
                m_dtBest5Ask.Rows[3]["m_nAsk"]    = nBestAsk4 / dDigitNum;

                m_dtBest5Ask.Rows[4]["m_nAskQty"] = nBestAskQty5;
                m_dtBest5Ask.Rows[4]["m_nAsk"]    = nBestAsk5 / dDigitNum;

                m_dtBest5Bid.Rows[0]["m_nAskQty"] = nBestBidQty1;
                m_dtBest5Bid.Rows[0]["m_nAsk"]    = nBestBid1 / dDigitNum;

                m_dtBest5Bid.Rows[1]["m_nAskQty"] = nBestBidQty2;
                m_dtBest5Bid.Rows[1]["m_nAsk"]    = nBestBid2 / dDigitNum;

                m_dtBest5Bid.Rows[2]["m_nAskQty"] = nBestBidQty3;
                m_dtBest5Bid.Rows[2]["m_nAsk"]    = nBestBid3 / dDigitNum;

                m_dtBest5Bid.Rows[3]["m_nAskQty"] = nBestBidQty4;
                m_dtBest5Bid.Rows[3]["m_nAsk"]    = nBestBid4 / dDigitNum;

                m_dtBest5Bid.Rows[4]["m_nAskQty"] = nBestBidQty5;
                m_dtBest5Bid.Rows[4]["m_nAsk"]    = nBestBid5 / dDigitNum;
            }
        }
Esempio n. 4
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");
        }