Ejemplo n.º 1
0
        def run(self):
            while True:
                import time
                from random import uniform, randint

                time.sleep(2)

                which = randint(1, 3)

                data1 = dict()
                data1["InstrumentID"] = "au1606"
                data1["UpdateTime"] = utcnow().strftime("%H:%M:%S")
                price = uniform(9, 10)
                data1["LastPrice"] = price
                data1["Volume"] = randint(100, 200)
                data1["Turnover"] = uniform(200, 300)
                data1["PreClosePrice"] = price - 0.1

                data2 = dict()
                data2["InstrumentID"] = "IF1505"
                data2["UpdateTime"] = utcnow().strftime("%H:%M:%S")
                price = uniform(9, 10)
                data2["LastPrice"] = price
                data2["Volume"] = randint(100, 200)
                data2["Turnover"] = uniform(200, 300)
                data2["PreClosePrice"] = price - 0.1

                if which == 1:
                    print data1
                    self._api.onRtnDepthMarketData(data1)
                elif which == 2:
                    print data2
                    self._api.onRtnDepthMarketData(data2)
                else:  # both
                    print data1
                    print data2
                    self._api.onRtnDepthMarketData(data1)
                    self._api.onRtnDepthMarketData(data2)
Ejemplo n.º 2
0
        def run(self):
            while True:
                import time
                from random import uniform, randint
                time.sleep(2)

                which = randint(1, 3)

                data1 = dict()
                data1['InstrumentID'] = 'au1606'
                data1['UpdateTime'] = utcnow().strftime("%H:%M:%S")
                price = uniform(9, 10)
                data1['LastPrice'] = price
                data1['Volume'] = randint(100, 200)
                data1['Turnover'] = uniform(200, 300)
                data1['PreClosePrice'] = price - 0.1

                data2 = dict()
                data2['InstrumentID'] = 'IF1505'
                data2['UpdateTime'] = utcnow().strftime("%H:%M:%S")
                price = uniform(9, 10)
                data2['LastPrice'] = price
                data2['Volume'] = randint(100, 200)
                data2['Turnover'] = uniform(200, 300)
                data2['PreClosePrice'] = price - 0.1

                if which == 1:
                    print data1
                    self._api.onRtnDepthMarketData(data1)
                elif which == 2:
                    print data2
                    self._api.onRtnDepthMarketData(data2)
                else:  # both
                    print data1
                    print data2
                    self._api.onRtnDepthMarketData(data1)
                    self._api.onRtnDepthMarketData(data2)
Ejemplo n.º 3
0
    def __wait(self):
        # first reset ticks info in one cycle, maybe we need save it if NO quotation in this period
        for identifier in self._identifiers:
            self._tickDSDict[identifier].reset()

        nextCall = self.getNextCallDateTime()

        while not self.__stopped and utcnow() < nextCall:
            start_time = datetime.datetime.now()

            self.get_tushare_tick_data()

            end_time = datetime.datetime.now()
            time_diff = (end_time - start_time).seconds

            if time_diff < TuSharePollingThread.TUSHARE_INQUERY_PERIOD:
                time.sleep(TuSharePollingThread.TUSHARE_INQUERY_PERIOD - time_diff)
Ejemplo n.º 4
0
    def __wait(self):
        # first reset ticks info in one cycle, maybe we need save it if NO quotation in this period
        for identifier in self._identifiers:
            self._tickDSDict[identifier].reset()

        nextCall = self.getNextCallDateTime()

        while not self.__stopped and utcnow() < nextCall:
            start_time = datetime.datetime.now()

            self.get_tushare_tick_data()

            end_time = datetime.datetime.now()
            time_diff = (end_time - start_time).seconds

            if time_diff < TuSharePollingThread.TUSHARE_INQUERY_PERIOD:
                time.sleep(TuSharePollingThread.TUSHARE_INQUERY_PERIOD -
                           time_diff)
Ejemplo n.º 5
0
 def getCurrentDateTime(self):
     return utcnow()
Ejemplo n.º 6
0
 def __updateNextBarClose(self):
     self.__nextBarClose = resamplebase.build_range(
         utcnow(), self.__frequency).getEnding()
Ejemplo n.º 7
0
 def getCurrentDateTime(self):
     return utcnow()
Ejemplo n.º 8
0
 def __updateNextBarClose(self):
     self.__nextBarClose = resamplebase.build_range(utcnow(), self.__frequency).getEnding()