Esempio n. 1
0
 def derivatives_raw(self, symbol, from_date, to_date, expiry_date,
                     instrument_type, strike_price, option_type):
     date_ranges = ut.break_dates(from_date, to_date)
     params = [(symbol, x[0], x[1], expiry_date, instrument_type,
                strike_price, option_type) for x in reversed(date_ranges)]
     chunks = ut.pool(self._derivatives, params, max_workers=self.workers)
     return list(itertools.chain.from_iterable(chunks))
Esempio n. 2
0
def test_pool():
    for use_threads in [True, False]:
        params = [(0, 1), (1, 2), (2, 3)]
        expected = [1, 9, 25]
        actual = ut.pool(demo_for_pool, params, use_threads)
        assert expected == list(actual)
        d = DemoForPool()
        actual = d.pooled(params, use_threads)
        assert expected == list(actual)
Esempio n. 3
0
 def stock_raw(self, symbol, from_date, to_date, series="EQ"):
     date_ranges = ut.break_dates(from_date, to_date)
     params = [(symbol, x[0], x[1], series) for x in reversed(date_ranges)]
     chunks = ut.pool(self._stock, params)
         
     return list(itertools.chain.from_iterable(chunks))
Esempio n. 4
0
 def index_raw(self, symbol, from_date, to_date):
     date_ranges = ut.break_dates(from_date, to_date)
     params = [(symbol, x[0], x[1]) for x in reversed(date_ranges)]
     chunks = ut.pool(self._index, params)
     return list(itertools.chain.from_iterable(chunks))
Esempio n. 5
0
 def pooled(self, params, use_threds):
     return ut.pool(self.demo_for_pool, params, use_threds)