For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Custom live data feed not calling _load

  • Hi. First off, thanks so much for writing this library.

    I've been working on implementing a live feed for use with Intrinio's IEX socket data. I'm trying to get just a hacky implementation up using Intrinio's python client before I start really integrating the 2 together.

    class MetaIntrinioData(DataBase.__class__):
        def __init__(cls, name, bases, dct):
            '''Class has already been created ... register'''
            # Initialize the class
            super(MetaIntrinioData, cls).__init__(name, bases, dct)
    class IntrinioData(with_metaclass(MetaIntrinioData, DataBase)):
            def __init__(self):
        options = {
            'username': 'afc02b9ad3eb215c40fe1d2b0117fda0',
            'password': '3fc9c2dc9db2288887a68c0a8d89965c',
            'provider': 'iex',
            'on_quote': self.on_quote
        self.client = IntrinioRealtimeClient(options)
        self.queue = Queue(25000)
        super(IntrinioFeed, self).__init__()
        def on_quote(self, quote, backlog):
        # print("QUOTE: ", quote, "BACKLOG LENGTH: ", backlog)
        def islive(self):
        '''Returns ``True`` to notify ``Cerebro`` that preloading and runonce
        should be deactivated'''
        return True
        def start(self):
        #listen to stocks (eventually set by user)
        self.client.join(['AAPL', 'GE', 'MSFT'])
        super(IntrinioFeed, self).start()
        def haslivedata(self):
            return bool(self.backlog)
        def stop(self):
        def _load(self):
            while True:
                if self.islive() == True:
                        #get message, put in queuee
                    except queue.Empty:
                        if True:
                            return None
                    ret = self._load_tick(self.msg)
                    if ret:
                        return True
        def _load_tick(self, msg):
            dtobj = datetime.utcfromtimestamp(msg['timestamp'])
            dt = date2num(dtobj)
            if dt <= self.lines.datetime[-1]:
                return False  # time already seen
            # Common fields
            self.lines.datetime[0] = dt
            self.lines.volume[0] = msg['volume']
            # Put the prices into the bar
            tick = msg['price']
  [0] = tick
            self.lines.high[0] = tick
            self.lines.low[0] = tick
            self.lines.close[0] = tick
            return True

    This code is still quite hacky, but when I try to test using a dummy strategy, nothing is called. The client connects to the server, and starts filling the queue, but _load and start is not called at all. What am I missing/doing incorrectly?

  • administrators

    As you also mention, the code seems too hacky to make any real assertion.

Log in to reply