mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-06 05:14:38 +08:00
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:
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user