General improvements

This commit is contained in:
Conner Fromknecht
2017-07-01 18:26:57 -07:00
parent db9ab0075b
commit 2d26758fba
16 changed files with 291 additions and 40 deletions
+11 -8
View File
@@ -115,12 +115,13 @@ def poloniex_cryptoassets(symbols, start=None, end=None):
day_data.volume.sum(), # sum of all volumes
)
# scale to allow trading 100-ths of a coin
daily_bars.loc[:, 'open'] /= 100.0
daily_bars.loc[:, 'high'] /= 100.0
daily_bars.loc[:, 'low'] /= 100.0
daily_bars.loc[:, 'close'] /= 100.0
daily_bars.loc[:, 'volume'] *= 100.0
# scale to allow trading 10-ths of a coin
scale = 10.0
daily_bars.loc[:, 'open'] /= scale
daily_bars.loc[:, 'high'] /= scale
daily_bars.loc[:, 'low'] /= scale
daily_bars.loc[:, 'close'] /= scale
daily_bars.loc[:, 'volume'] *= scale
return daily_bars
@@ -171,8 +172,10 @@ def poloniex_cryptoassets(symbols, start=None, end=None):
yield sid, daily_bars
sid += 1
daily_bar_writer.write(_pricing_iter())
daily_bar_writer.write(
_pricing_iter(),
assets=metadata.symbol.index,
)
symbol_map = pd.Series(metadata.symbol.index, metadata.symbol)
+13
View File
@@ -5,6 +5,7 @@ from io import BytesIO
from itertools import count
import tarfile
from time import time, sleep
from datetime import datetime
from click import progressbar
from logbook import Logger
@@ -36,10 +37,17 @@ def _fetch_raw_metadata(api_key, cache, retries, environ):
try:
raw = pd.read_csv(
format_metadata_url(api_key, page_number),
date_parser=pd.tseries.tools.to_datetime,
parse_dates=[
'oldest_available_date',
'newest_available_date',
],
dtypes={
'dataset_code': 'int',
'name': 'str',
'oldest_available_date': 'str',
'newest_available_date': 'str',
},
usecols=[
'dataset_code',
'name',
@@ -126,6 +134,10 @@ def fetch_symbol_metadata_frame(api_key,
# we need to escape the paren because it is actually splitting on a regex
data.asset_name = data.asset_name.str.split(r' \(', 1).str.get(0)
data['exchange'] = 'QUANDL'
data['start_date'] = data['start_date'].astype(datetime)
data['end_date'] = data['end_date'].astype(datetime)
data['auto_close_date'] = data['end_date'] + pd.Timedelta(days=1)
return data
@@ -313,6 +325,7 @@ def quandl_bundle(environ,
dividends,
environ.get('QUANDL_DOWNLOAD_ATTEMPTS', 5),
),
assets=metadata.index,
show_progress=show_progress,
)
adjustment_writer.write(
+7 -6
View File
@@ -300,12 +300,13 @@ def ensure_crypto_benchmark_data(symbol, first_date, last_date, now,
day_data.volume.sum(), # sum of all volumes
)
# scale to allow trading 100-ths of a coin
daily_bars.loc[:, 'open'] /= 100.0
daily_bars.loc[:, 'high'] /= 100.0
daily_bars.loc[:, 'low'] /= 100.0
daily_bars.loc[:, 'close'] /= 100.0
daily_bars.loc[:, 'volume'] *= 100.0
# scale to allow trading 10-ths of a coin
scale = 10.0
daily_bars.loc[:, 'open'] /= scale
daily_bars.loc[:, 'high'] /= scale
daily_bars.loc[:, 'low'] /= scale
daily_bars.loc[:, 'close'] /= scale
daily_bars.loc[:, 'volume'] *= scale
return daily_bars