From 53dae6320cde10e4283f81965f65ba5280553836 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Wed, 25 Nov 2015 10:16:19 -0500 Subject: [PATCH] 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. --- tests/data/test_us_equity_pricing.py | 5 +++++ zipline/data/us_equity_pricing.py | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/data/test_us_equity_pricing.py b/tests/data/test_us_equity_pricing.py index a6431875..35e329f4 100644 --- a/tests/data/test_us_equity_pricing.py +++ b/tests/data/test_us_equity_pricing.py @@ -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) diff --git a/zipline/data/us_equity_pricing.py b/zipline/data/us_equity_pricing.py index 0d308c75..121e56d5 100644 --- a/zipline/data/us_equity_pricing.py +++ b/zipline/data/us_equity_pricing.py @@ -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):