Example #1
0
 def test_write_day_and_id(self):
     result = self.bcolz_daily_bar_ctable
     idx = 0
     ids = result['id']
     days = result['day']
     for asset_id in self.assets:
         for date in self.dates_for_asset(asset_id):
             self.assertEqual(ids[idx], asset_id)
             self.assertEqual(date, seconds_to_timestamp(days[idx]))
             idx += 1
 def test_write_day_and_id(self):
     result = self.bcolz_daily_bar_ctable
     idx = 0
     ids = result['id']
     days = result['day']
     for asset_id in self.assets:
         for date in self.dates_for_asset(asset_id):
             self.assertEqual(ids[idx], asset_id)
             self.assertEqual(date, seconds_to_timestamp(days[idx]))
             idx += 1
 def test_write_day_and_id(self):
     result = self.bcolz_daily_bar_ctable
     idx = 0
     ids = result["id"]
     days = result["day"]
     for asset_id in self.assets:
         for date in self.dates_for_asset(asset_id):
             assert ids[idx] == asset_id
             assert date == seconds_to_timestamp(days[idx])
             idx += 1
 def test_write_day_and_id(self):
     result = self.writer.write(self.dest, self.trading_days, self.assets)
     idx = 0
     ids = result['id']
     days = result['day']
     for asset_id in self.assets:
         for date in self.dates_for_asset(asset_id):
             self.assertEqual(ids[idx], asset_id)
             self.assertEqual(date, seconds_to_timestamp(days[idx]))
             idx += 1
 def test_write_day_and_id(self):
     result = self.writer.write(self.dest, self.trading_days, self.assets)
     idx = 0
     ids = result['id']
     days = result['day']
     for asset_id in self.assets:
         for date in self.dates_for_asset(asset_id):
             self.assertEqual(ids[idx], asset_id)
             self.assertEqual(date, seconds_to_timestamp(days[idx]))
             idx += 1
 def apply_adjustments(self, dates, assets, baseline_values, adjustments):
     min_date, max_date = dates[[0, -1]]
     # HACK: Simulate the coercion to float64 we do in adjusted_array.  This
     # should be removed when AdjustedArray properly supports
     # non-floating-point types.
     orig_dtype = baseline_values.dtype
     values = baseline_values.astype(float64).copy()
     for eff_date_secs, ratio, sid in adjustments.itertuples(index=False):
         eff_date = seconds_to_timestamp(eff_date_secs)
         # Don't apply adjustments that aren't in the current date range.
         if eff_date not in dates:
             continue
         eff_date_loc = dates.get_loc(eff_date)
         asset_col = assets.get_loc(sid)
         # Apply ratio multiplicatively to the asset column on all rows less
         # than or equal adjustment effective date.
         values[:eff_date_loc + 1, asset_col] *= ratio
     return values.astype(orig_dtype)
 def apply_adjustments(self, dates, assets, baseline_values, adjustments):
     min_date, max_date = dates[[0, -1]]
     # HACK: Simulate the coercion to float64 we do in adjusted_array.  This
     # should be removed when AdjustedArray properly supports
     # non-floating-point types.
     orig_dtype = baseline_values.dtype
     values = baseline_values.astype(float64).copy()
     for eff_date_secs, ratio, sid in adjustments.itertuples(index=False):
         eff_date = seconds_to_timestamp(eff_date_secs)
         # Don't apply adjustments that aren't in the current date range.
         if eff_date not in dates:
             continue
         eff_date_loc = dates.get_loc(eff_date)
         asset_col = assets.get_loc(sid)
         # Apply ratio multiplicatively to the asset column on all rows less
         # than or equal adjustment effective date.
         values[:eff_date_loc + 1, asset_col] *= ratio
     return values.astype(orig_dtype)