mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-12 11:50:11 +08:00
ENH: Return -1 for missing spot prices.
Return -1 when there is a zero value for a spot price. Intended for use by the incoming data portal changes. When the data portal will see a -1 value, the portal will seek back a trading day until a non-negative value is returned.
This commit is contained in:
@@ -306,3 +306,20 @@ class BcolzDailyBarTestCase(TestCase):
|
||||
# after
|
||||
with self.assertRaises(NoDataOnDate):
|
||||
reader.spot_price(4, Timestamp('2015-06-16', tz='UTC'), 'close')
|
||||
|
||||
def test_unadjusted_spot_price_empty_value(self):
|
||||
table = self.writer.write(self.dest, self.trading_days, self.assets)
|
||||
reader = BcolzDailyBarReader(table)
|
||||
|
||||
# A sid, day and corresponding index into which to overwrite a zero.
|
||||
zero_sid = 1
|
||||
zero_day = Timestamp('2015-06-02', tz='UTC')
|
||||
zero_ix = reader.sid_day_index(zero_sid, zero_day)
|
||||
|
||||
# Write a zero into the synthetic pricing data at the day and sid,
|
||||
# so that a read should now return -1.
|
||||
# This a little hacky, in lieu of changing the synthetic data set.
|
||||
reader._spot_col('close')[zero_ix] = 0
|
||||
|
||||
close = reader.spot_price(zero_sid, zero_day, 'close')
|
||||
self.assertEqual(-1, close)
|
||||
|
||||
Reference in New Issue
Block a user