Merge branch 'master' into develop

This commit is contained in:
Victor Grau Serrat
2017-10-20 12:09:51 -06:00
5 changed files with 13 additions and 16 deletions
+1 -3
View File
@@ -215,13 +215,11 @@ cpdef _read_bcolz_data(ctable_t table,
else:
continue
if column_name in ['open', 'high', 'low', 'close']:
if column_name in ['open', 'high', 'low', 'close', 'volume']:
where_nan = (outbuf == 0)
outbuf_as_float = outbuf.astype(float64) * .000000001
outbuf_as_float[where_nan] = NAN
results.append(outbuf_as_float)
elif column_name != 'volume':
results.append(outbuf.astype(uint32))
else:
results.append(outbuf)
return results
+4 -1
View File
@@ -18,6 +18,7 @@ from numpy import (
full,
nan,
int64,
float64,
zeros
)
from six import iteritems, with_metaclass
@@ -70,7 +71,9 @@ class AssetDispatchBarReader(with_metaclass(ABCMeta)):
return self._dt_window_size(start_dt, end_dt), num_sids
def _make_raw_array_out(self, field, shape):
if field != 'volume' and field != 'sid':
if field == 'volume':
out = zeros(shape, dtype=float64)
elif field != 'sid':
out = full(shape, nan)
else:
out = zeros(shape, dtype=int64)
+1 -1
View File
@@ -1248,7 +1248,7 @@ class BcolzMinuteBarReader(MinuteBarReader):
if field != 'volume':
out = np.full(shape, np.nan)
else:
out = np.zeros(shape, dtype=np.uint64)
out = np.zeros(shape, dtype=np.float64)
for i, sid in enumerate(sids):
carray = self._open_minute_file(field, sid)
+6 -10
View File
@@ -441,7 +441,7 @@ class BcolzDailyBarWriter(object):
dates = raw_data.index.values.astype('datetime64[s]')
check_uint32_safe(dates.max().view(np.int64), 'day')
processed['day'] = dates.astype('uint32')
processed['volume'] = raw_data.volume.astype('uint64')
processed['volume'] = (raw_data.volume * PRICE_ADJUSTMENT_FACTOR).astype('uint64')
return ctable.fromdataframe(processed)
@@ -494,9 +494,8 @@ class BcolzDailyBarReader(SessionBarReader):
The data in these columns is interpreted as follows:
- Price columns ('open', 'high', 'low', 'close') are interpreted as 1000 *
as-traded dollar value.
- Volume is interpreted as as-traded volume.
- Price columns ('open', 'high', 'low', 'close') and Volume are interpreted
as 10^9 * as-traded dollar value.
- Day is interpreted as seconds since midnight UTC, Jan 1, 1970.
- Id is the asset id of the row.
@@ -762,13 +761,10 @@ class BcolzDailyBarReader(SessionBarReader):
"""
ix = self.sid_day_index(sid, dt)
price = self._spot_col(field)[ix]
if field != 'volume':
if price == 0:
return nan
else:
return price / PRICE_ADJUSTMENT_FACTOR
if field != 'volume' and price == 0:
return nan
else:
return price
return price / PRICE_ADJUSTMENT_FACTOR
class PanelBarReader(SessionBarReader):
+1 -1
View File
@@ -1,7 +1,7 @@
# Incompatible with earlier PIP versions
pip>=7.1.0
# bcolz fails to install if this is not in the build_requires.
setuptools>18.0
setuptools>36.0
# Logging
Logbook==0.12.5