コード例 #1
0
    def OnNotifyTicks(self, sMarketNo, sStockidx, nPtr, nDate, nTimehms, nTimemillis, nBid, nAsk, nClose, nQty, nSimulate):
        pStock = sk.SKSTOCK()
        self.skQ.SKQuoteLib_GetStockByIndex(sMarketNo, sStockidx, pStock)
        self.stock_state[pStock.bstrStockNo] = pStock
        ppow = math.pow(10, pStock.sDecimal)

        # 14:30:00 的紀錄不處理
        if nTimehms > 133000:
            return

        # 時間字串化
        s = nTimehms % 100
        nTimehms /= 100
        m = nTimehms % 100
        nTimehms /= 100
        h = nTimehms
        timestr = '%02d:%02d:%02d.%03d' % (h, m, s, nTimemillis//1000)

        entry = {
            'id': pStock.bstrStockNo,
            'name': pStock.bstrStockName,
            'time': timestr,
            'ask': nAsk / ppow,
            'bid': nBid / ppow,
            'close': nClose / ppow,
            'qty': nQty,
            'volume': pStock.nTQty
        }
        self.ticks_hook(entry)
コード例 #2
0
 def OnNotifyQuote(self, sMarketNo, sStockidx):
     pStock = sk.SKSTOCK()
     skQ.SKQuoteLib_GetStockByIndex(sMarketNo, sStockidx, pStock)
     strMsg = pStock.bstrStockNo, pStock.bstrStockName, pStock.nOpen / math.pow(
         10, pStock.sDecimal), pStock.nHigh / math.pow(
             10, pStock.sDecimal), pStock.nLow / math.pow(
                 10, pStock.sDecimal), pStock.nClose / math.pow(
                     10, pStock.sDecimal), pStock.nTQty
     self.StockPrice.append(strMsg)
コード例 #3
0
 def OnNotifyQuote(self, sMarketNo, sStockidx):
     pStock = sk.SKSTOCK()
     skQ.SKQuoteLib_GetStockByIndex(sMarketNo, sStockidx, pStock)
     strMsg = '代碼:', pStock.bstrStockNo, '--名稱:', pStock.bstrStockName, '--開盤價:', pStock.nOpen / math.pow(
         10, pStock.sDecimal), '--最高:', pStock.nHigh / math.pow(
             10, pStock.sDecimal), '--最低:', pStock.nLow / math.pow(
                 10, pStock.sDecimal), '--成交價:', pStock.nClose / math.pow(
                     10, pStock.sDecimal), '--總量:', pStock.nTQty
     WriteMessage(strMsg, Gobal_Quote_ListInformation)
コード例 #4
0
 def OnNotifyQuote(self, sMarketNo, sStockidx):
     self.parent.watchdog = 0
     pStock = sk.SKSTOCK()
     self.parent.skQ.SKQuoteLib_GetStockByIndex(sMarketNo, sStockidx,
                                                pStock)
     self.parent.get_price(
         self, pStock.bstrStockNo,
         pStock.nOpen / math.pow(10, pStock.sDecimal),
         pStock.nHigh / math.pow(10, pStock.sDecimal),
         pStock.nLow / math.pow(10, pStock.sDecimal),
         pStock.nClose / math.pow(10, pStock.sDecimal), pStock.nTQty)
コード例 #5
0
    def get_best5(self, sMarketNo, sStockIdx, nBestBid1, nBestBidQty1,
                  nBestBid2, nBestBidQty2, nBestBid3, nBestBidQty3, nBestBid4,
                  nBestBidQty4, nBestBid5, nBestBidQty5, nExtendBid,
                  nExtendBidQty, nBestAsk1, nBestAskQty1, nBestAsk2,
                  nBestAskQty2, nBestAsk3, nBestAskQty3, nBestAsk4,
                  nBestAskQty4, nBestAsk5, nBestAskQty5, nExtendAsk,
                  nExtendAskQty, nSimulate):
        '''
		sMarketNo,	市埸代碼
		sStockidx,	系統編碼後的特殊商品代號
		nBestBid1,nBestBidQty1,  買價1, 買量1
		nBestBid2,nBestBidQty2,  買價2, 買量2
		nBestBid3,nBestBidQty3,  買價3, 買量3
		nBestBid4,nBestBidQty4,  買價4, 買量4
		nBestBid5,nBestBidQty5,  買價5, 買量5
		nExtendBid,nExtendBidQty,延伸買價,延伸買量		
		nBestAsk1,nBestAskQty1,  買價1, 買量1
		nBestAsk2,nBestAskQty2,  買價2, 買量2
		nBestAsk3,nBestAskQty3,  買價3, 買量3
		nBestAsk4,nBestAskQty4,  買價4, 買量4
		nBestAsk5,nBestAskQty5,  買價5, 買量5
		nExtendAsk,nExtendAskQty,延伸賣價,延伸賣量		
		nSimulate 0:一般揭示 1:試算揭示
		'''
        #for debug only #
        if SHOW_DETAIL == True:
            print(sMarketNo, sStockIdx, nBestBid1, nBestBidQty1, nBestBid2,
                  nBestBidQty2, nBestBid3, nBestBidQty3, nBestBid4,
                  nBestBidQty4, nBestBid5, nBestBidQty5, nExtendBid,
                  nExtendBidQty, nBestAsk1, nBestAskQty1, nBestAsk2,
                  nBestAskQty2, nBestAsk3, nBestAskQty3, nBestAsk4,
                  nBestAskQty4, nBestAsk5, nBestAskQty5, nExtendAsk,
                  nExtendAskQty, nSimulate)
        #################
        if sStockIdx in self.best5_id_dict:
            pStock = sk.SKSTOCK()
            self.skQ.SKQuoteLib_GetStockByIndex(sMarketNo, sStockIdx, pStock)
            df = math.pow(10, pStock.sDecimal)
            bstrStockName = self.best5_id_dict[sStockIdx]
            self.best5_dict[bstrStockName] = (
                self.timestr, nBestBid1 / df, nBestBidQty1, nBestBid2 / df,
                nBestBidQty2, nBestBid3 / df, nBestBidQty3, nBestBid4 / df,
                nBestBidQty4, nBestBid5 / df, nBestBidQty5, nExtendBid / df,
                nExtendBidQty, nBestAsk1 / df, nBestAskQty1, nBestAsk2 / df,
                nBestAskQty2, nBestAsk3 / df, nBestAskQty3, nBestAsk4 / df,
                nBestAskQty4, nBestAsk5 / df, nBestAskQty5, nExtendAsk / df,
                nExtendAskQty, nSimulate)
コード例 #6
0
ファイル: Test.py プロジェクト: xTobu/CapitalAPI
    def OnNotifyQuote(self, sMarketNo, sStockidx):
        pStock = sk.SKSTOCK()
        skQ.SKQuoteLib_GetStockByIndex(sMarketNo, sStockidx, pStock)

        Open = pStock.nOpen/math.pow(10, pStock.sDecimal)
        High = pStock.nHigh/math.pow(10, pStock.sDecimal)
        Low = pStock.nLow/math.pow(10, pStock.sDecimal)
        Close = pStock.nClose/math.pow(10, pStock.sDecimal)
        Qty = pStock.nTQty
        a = datetime.datetime.now()

        try:
            # modelSql.s_insert(a, pStock.bstrStockNo, pStock.bstrStockName, Open, High, Low, Close, Qty)
            # testdb.commit()
            strMsg = '代碼:', pStock.bstrStockNo, '--名稱:', pStock.bstrStockName, '--開盤價:', pStock.nOpen/math.pow(10, pStock.sDecimal), '--最高:', pStock.nHigh/math.pow(
                10, pStock.sDecimal), '--最低:', pStock.nLow/math.pow(10, pStock.sDecimal), '--成交價:', pStock.nClose/math.pow(10, pStock.sDecimal), '--總量:', pStock.nTQty
            print('OnNotifyQuote: ', a)
            print(strMsg)

        except mysql.connector.Error as error:
            print("Failed to update record to database rollback: {}".format(error))
コード例 #7
0
 def OnNotifyQuote(self, sMarketNo, sStockidx):
     pStock = sk.SKSTOCK()
     self.skQ.SKQuoteLib_GetStockByIndex(sMarketNo, sStockidx, pStock)
     if pStock.bstrStockNo not in self.stock_state:
         self.stock_state[pStock.bstrStockNo] = pStock