Esempio n. 1
0
    def get_realtime_quotes(self,
                            symbols=None,
                            dataframe=True,
                            loop=None,
                            split=False):
        self.quote = None
        if symbols is None:
            symbols = self.get_symbols()
        if loop is None:
            loop = asyncio.get_event_loop()
        else:
            asyncio.set_event_loop(loop)

        if isinstance(symbols, str):
            symbolList = symbols.split(',')
        else:
            symbolList = list(symbols)
        [symbols_sz, symbols_sh] = util.split_symbols(symbolList)
        symbolListSlice = util.slice_list(step=800, dataList=symbols_sz)
        symbolListSlice.extend(util.slice_list(step=800, dataList=symbols_sh))
        loop.run_until_complete(
            self.get_quote_task(symbolListSlice=symbolListSlice,
                                dataframe=dataframe))
        if dataframe:
            self.quote = self.quote.drop('ms', axis=1)
            self.quote.convert_objects(convert_dates=False,
                                       convert_numeric=True,
                                       convert_timedeltas=False)
        if split:
            quote_sz = self.quote[self.quote.symbol > 'sz']
            quote_sh = self.quote[self.quote.symbol < 'sz']
            return [quote_sz, quote_sh]
        return self.quote
Esempio n. 2
0
	def get_realtime_quotes(self, symbols = None, dataframe = True, loop = None, split = False):
		self.quote = None
		if symbols is None:
			symbols = self.symbols
		if loop is None:
			loop = asyncio.get_event_loop()
		else:
			asyncio.set_event_loop(loop)

		if isinstance(symbols, str):
			symbolList = symbols.split(',')
		else:
			symbolList = list(symbols)
		[ symbols_sz, symbols_sh ] = util.split_symbols(symbolList)
		symbolListSlice = util.slice_list(step = 800, data_list = symbols_sz)
		symbolListSlice.extend( util.slice_list(step = 800, data_list = symbols_sh) )
		loop.run_until_complete( self.get_quote_task(symbolListSlice=symbolListSlice, dataframe = dataframe) )
		if dataframe:
			self.quote = self.quote.drop( 'ms', axis = 1 )
			self.quote.convert_objects(convert_dates=False,convert_numeric=True,convert_timedeltas=False)
		if split:
			quote_sz = self.quote[ self.quote.symbol > 'sz' ]
			quote_sh = self.quote[ self.quote.symbol < 'sz' ]
			return [ quote_sz, quote_sh ]
		return self.quote
Esempio n. 3
0
 def __init__(self, name=None, symbols=None, **kwargs):
     super().__init__(name=name, **kwargs)
     self.sina = V('Sina')
     if symbols is None:
         self.symbols = self.sina.get_symbols()
     else:
         self.symbols = symbols
     [self.szSymbols, self.shSymbols] = util.split_symbols(self.symbols)
     self.szTime = datetime(1970, 1, 1)
     self.shTime = datetime(1970, 1, 1)
Esempio n. 4
0
	def __init__(self, name = None, symbols = None ,**kwargs):
		super().__init__( name=name, **kwargs )
		self.sina = V('Sina')
		if symbols is None:
			self.symbols = self.sina.get_symbols()
		else:
			self.symbols = symbols
		[self.szSymbols, self.shSymbols] = util.split_symbols(self.symbols)
		self.szTime = datetime(1970,1,1)
		self.shTime = datetime(1970,1,1)