Esempio n. 1
0
    def get_current_bar(self):
        '''
        Returns the current Bar as a Bar instance.  The cursor is advanced to 
        point to the next Bar.
        
        :returns Bar: Bar containing all standard fields plus a user-defined
                      field for each indicator in this feed.
        '''
        if self._cursor >= self._len:
            return None
        
        # because of how the code in the constructor above, we all of the 
        # standard bar fields exist at fixed offsets in self._values
        b = Bar(self._values[0][self._cursor],
                self._values[1][self._cursor],
                self._values[2][self._cursor],
                self._values[3][self._cursor],
                self._values[4][self._cursor],
                self._values[5][self._cursor])
        
        for ind in self._indictrs:
            b.set_user_defined(ind.name(), self._lkup[ind.name()][self._cursor])

        self._cursor += 1
        return b
Esempio n. 2
0
    def get_current_bar(self):
        '''
        Returns the current Bar as a Bar instance.  The cursor is advanced to 
        point to the next Bar.
        
        :returns Bar: Bar containing all standard fields plus a user-defined
                      field for each indicator in this feed.
        '''
        if self._cursor >= self._len:
            return None

        # because of how the code in the constructor above, we all of the
        # standard bar fields exist at fixed offsets in self._values
        b = Bar(self._values[0][self._cursor], self._values[1][self._cursor],
                self._values[2][self._cursor], self._values[3][self._cursor],
                self._values[4][self._cursor], self._values[5][self._cursor])

        for ind in self._indictrs:
            b.set_user_defined(ind.name(),
                               self._lkup[ind.name()][self._cursor])

        self._cursor += 1
        return b
Esempio n. 3
0
 def testUserDefined(self):
     b = Bar(datetime.datetime(2013,1,23),10.0, 40.0, 5.0, 25.0)
     b.set_user_defined('foo1', 42)
     b.set_user_defined('foo2', 99.36)
     self.assertEqual(b.foo1(), 42)
     self.assertEqual(b.foo2(), 99.36)
     with self.assertRaisesRegexp(Exception, 'Bar has no user-defined'):
         b.Close()
     self.assertFalse(b.has_nan())
     b.set_user_defined('foonan', numpy.nan)
     self.assertTrue(b.has_nan())
Esempio n. 4
0
 def testUserDefined(self):
     b = Bar(datetime.datetime(2013, 1, 23), 10.0, 40.0, 5.0, 25.0)
     b.set_user_defined('foo1', 42)
     b.set_user_defined('foo2', 99.36)
     self.assertEqual(b.foo1(), 42)
     self.assertEqual(b.foo2(), 99.36)
     with self.assertRaisesRegexp(Exception, 'Bar has no user-defined'):
         b.Close()
     self.assertFalse(b.has_nan())
     b.set_user_defined('foonan', numpy.nan)
     self.assertTrue(b.has_nan())