def process_orderbook(self, data):
        """订单簿推送"""
        symbol = data['code']

        tick = self._tick_dict.get(symbol, None)
        if not tick:
            tick = TinyQuoteData()
            tick.symbol = symbol
            self._tick_dict[symbol] = tick

        d = tick.__dict__
        for i in range(5):
            bid_data = data['Bid'][i]
            ask_data = data['Ask'][i]
            n = i + 1

            d['bidPrice%s' % n] = bid_data[0]
            d['bidVolume%s' % n] = bid_data[1]
            d['askPrice%s' % n] = ask_data[0]
            d['askVolume%s' % n] = ask_data[1]

            new_tick = copy(tick)
        self._notify_new_tick_event(new_tick)
def process_orderbook ( self , data ) : symbol = data [ 'code' ] tick = self . _tick_dict . get ( symbol , None ) if not tick : tick = TinyQuoteData ( ) tick . symbol = symbol self . _tick_dict [ symbol ] = tick d = tick . __dict__ for i in range ( 5 ) : bid_data = data [ 'Bid' ] [ i ] ask_data = data [ 'Ask' ] [ i ] n = i + 1 d [ 'bidPrice%s' % n ] = bid_data [ 0 ] d [ 'bidVolume%s' % n ] = bid_data [ 1 ] d [ 'askPrice%s' % n ] = ask_data [ 0 ] d [ 'askVolume%s' % n ] = ask_data [ 1 ] new_tick = copy ( tick ) self . _notify_new_tick_event ( new_tick )
订单簿推送