Alex大大
另外這幾天早上測試時,發現一個問題,就是您程式的單量顏色,有時候會有幾筆單量與嘉實資訊的單量顏色不同,我猜可能是因為您程式的判斷依據是根據報價中的買價,賣價,成交價與即時Tick事件的其他三個資料產生一些差異的關係而造成的;因此我就想說是否可能在報價表中,改用即時Tick事件的成交明細(也就是說show出買進,賣出,成交,單量,由內盤成交判斷單量為綠色,或外盤成交單量判斷為紅色,中間的顯示白色),但是寫出程式後,卻發現每一檔個股的即時Tick資料雖會更新,但有更新的資料又會將還沒更新的其他個股Tick資料覆蓋過去,可否幫忙看一下問題出在哪裡嗎?
謝謝您,感恩!
Dim sPage As Short
Dim intPage As Integer = -1
If Short.TryParse(txtPageNo.Text, sPage) = False Then Return
Dim Stocks As String() = txtStocks.Text.Trim().Split(New Char() {","c})
For Each s As String In Stocks
Dim nCode As Integer = skQ.SKQuoteLib_GetStockByNo(s.Trim(), pSKStock)
Dim mCode As Integer = skQ.SKQuoteLib_RequestTicks(intPage, s.Trim())
If nCode = 0 AndAlso mCode = 0 Then
OnUpDateDataRow(pSKStock, pSKTick)
End If
intPage = intPage + 1
Next
skQ.SKQuoteLib_RequestStocks(sPage, txtStocks.Text.Trim())
skQ.SKQuoteLib_RequestTicks(intPage, txtStocks.Text.Trim())
txtPageNo.Text = sPage.ToString()
End Sub
Private Sub skQ_OnNotifyQuote(sMarketNo As Short, sStockIdx As Short) Handles skQ.OnNotifyQuote
skQ.SKQuoteLib_GetStockByIndex(sMarketNo, sStockIdx, pSKStock)
OnUpDateDataRow(pSKStock, pSKTick)
End Sub
Private Sub skQ_OnNotifyTicks(sMarketNo As Short, sIndex As Short, nPtr As Integer, nTimehms As Integer, nTimemillismicros As Integer, nBid As Integer, nAsk As Integer, nClose As Integer, nQty As Integer, nSimulate As Integer) Handles skQ.OnNotifyTicks
skQ.SKQuoteLib_GetTick(sMarketNo, sIndex, nPtr, pSKTick)
End Sub
Private Sub OnUpDateDataRow(ByVal pStock As SKCOMLib.SKSTOCK, ByVal pTick As SKCOMLib.SKTICK)
Dim strStockNo As String = pStock.bstrStockNo
Dim drFind As DataRow = portfolioQuoteTable.Rows.Find(strStockNo)
If drFind Is Nothing Then
Try
Dim myDataRow As DataRow = portfolioQuoteTable.NewRow()
myDataRow("sStockidx") = pStock.sStockIdx
myDataRow("sDecimal") = pStock.sDecimal
myDataRow("sTypeNo") = pStock.sTypeNo
myDataRow("cMarketNo") = pStock.bstrMarketNo
myDataRow("caStockNo") = pStock.bstrStockNo
myDataRow("caName") = pStock.bstrStockName
myDataRow("nTickQty") = pStock.nTickQty
myDataRow("nCloseOpen") = (pStock.nClose - pSKStock.nOpen) / (Math.Pow(10, pStock.sDecimal))
myDataRow("nUpDown") = (pStock.nClose - pStock.nRef) / (Math.Pow(10, pStock.sDecimal))
myDataRow("nBid") = pStock.nBid / (Math.Pow(10, pStock.sDecimal))
myDataRow("nAsk") = pStock.nAsk / (Math.Pow(10, pStock.sDecimal))
myDataRow("nClose") = pStock.nClose / (Math.Pow(10, pStock.sDecimal))
myDataRow("nOpen") = pStock.nOpen / (Math.Pow(10, pStock.sDecimal))
myDataRow("nHigh") = pStock.nHigh / (Math.Pow(10, pStock.sDecimal))
myDataRow("nLow") = pStock.nLow / (Math.Pow(10, pStock.sDecimal))
myDataRow("nRef") = pStock.nRef / (Math.Pow(10, pStock.sDecimal))
myDataRow("nHigh_1K") = 0
myDataRow("nLow_1K") = 0
myDataRow("Long1") = 0
myDataRow("Short1") = 0
myDataRow("LongShort1") = 0
myDataRow("nHigh_5K") = 0
myDataRow("nLow_5K") = 0
myDataRow("Long5") = 0
myDataRow("Short5") = 0
myDataRow("LongShort5") = 0
myDataRow("nLastClose") = myDataRow("nClose")
myDataRow("nLastBid") = myDataRow("nBid")
myDataRow("nLastAsk") = myDataRow("nAsk")
myDataRow("nPtr") = pTick.nPtr
myDataRow("nTimehms") = pTick.nTimehms
m_nSimulateStock = pStock.nSimulate
portfolioQuoteTable.Rows.Add(myDataRow)
Catch ex As Exception
Dim msg As String = ex.Message
End Try
Else
drFind("nLastClose") = drFind("nClose")
drFind("nLastBid") = drFind("nBid")
drFind("nLastAsk") = drFind("nAsk")
'drFind("sStockidx") = pStock.sStockIdx
'drFind("sDecimal") = pStock.sDecimal
'drFind("sTypeNo") = pStock.sTypeNo
'drFind("cMarketNo") = pStock.bstrMarketNo
'drFind("caStockNo") = pStock.bstrStockNo
'drFind("caName") = pStock.bstrStockName
drFind("nTickQty") = pStock.nTickQty
drFind("nCloseOpen") = (pStock.nClose - pSKStock.nOpen) / (Math.Pow(10, pStock.sDecimal))
drFind("nUpDown") = (pStock.nClose - pStock.nRef) / (Math.Pow(10, pStock.sDecimal))
drFind("nBid") = pStock.nBid / (Math.Pow(10, pStock.sDecimal))
drFind("nAsk") = pStock.nAsk / (Math.Pow(10, pStock.sDecimal))
drFind("nClose") = pStock.nClose / (Math.Pow(10, pStock.sDecimal))
drFind("nOpen") = pStock.nOpen / (Math.Pow(10, pStock.sDecimal))
drFind("nHigh") = pStock.nHigh / (Math.Pow(10, pStock.sDecimal))
drFind("nLow") = pStock.nLow / (Math.Pow(10, pStock.sDecimal))
drFind("nRef") = pStock.nRef / (Math.Pow(10, pStock.sDecimal))
drFind("nPtr") = pTick.nPtr
drFind("nTimehms") = pTick.nTimehms
m_nSimulateStock = pStock.nSimulate
End If
End Sub
|