BUG: Fix volume value returned by daily spot price

Volumes were incorrectly having the thousands factor applied, however
the volume is written as is (without the factor, since it volume is an
int, not float value.)

Fix by adding a special case for volume which returns the price as is.
This commit is contained in:
Eddie Hebert
2015-11-25 10:16:19 -05:00
parent 0e246a2eee
commit 53dae6320c
2 changed files with 10 additions and 1 deletions
+5
View File
@@ -291,6 +291,11 @@ class BcolzDailyBarTestCase(TestCase):
'close')
self.assertEqual(235651.0, price)
# Ensure that volume does not have float adjustment applied.
volume = reader.spot_price(1, Timestamp('2015-06-02', tz='UTC'),
'volume')
self.assertEqual(145631, volume)
def test_unadjusted_spot_price_no_data(self):
table = self.writer.write(self.dest, self.trading_days, self.assets)
reader = BcolzDailyBarReader(table)
+5 -1
View File
@@ -498,7 +498,11 @@ class BcolzDailyBarReader(object):
raise NoDataOnDate(
"No data on or after day={0} for sid={1}".format(
day, sid))
return self._spot_col(colname)[ix] * 0.001
price = self._spot_col(colname)[ix]
if colname != 'volume':
return price * 0.001
else:
return price
class SQLiteAdjustmentWriter(object):