Bug fixes

This commit is contained in:
fredfortier
2017-10-11 22:05:29 -04:00
parent c33bab673f
commit c24918e2c8
5 changed files with 13 additions and 10 deletions
+2 -1
View File
@@ -7,6 +7,7 @@ import pandas as pd
import pytz
from catalyst.data.bundles import from_bundle_ingest_dirname
from catalyst.exchange.exchange_errors import ApiCandlesError
from catalyst.utils.deprecate import deprecated
from catalyst.utils.paths import data_path
@@ -96,7 +97,7 @@ def get_history(exchange_name, data_frequency, symbol, start=None, end=None):
data = response.json()
if 'error' in data:
raise ValueError(data['error'])
raise ApiCandlesError(error=data['error'])
for candle in data:
last_traded = pd.Timestamp.utcfromtimestamp(candle['ts'])
+1 -1
View File
@@ -489,7 +489,7 @@ class Exchange:
candles = bundle_utils.get_history(
exchange_name=self.name,
data_frequency=data_frequency,
symbol=asset.exchange_symbol, # TODO: use Catalyst symbol
symbol=asset.symbol, # TODO: use Catalyst symbol
start=catalyst_start,
end=catalyst_end
)
+2 -6
View File
@@ -131,18 +131,14 @@ class ExchangeBundle:
write_metadata = False
if start_dt < metadata.start_session:
write_metadata = True
start_session = start_dt.floor('1d')
start_session = start_dt
else:
start_session = metadata.start_session
if end_dt > metadata.end_session:
write_metadata = True
# TODO: workaround, improve the calendar logic?
if end_dt == start_dt:
end_dt += timedelta(days=1)
end_session = end_dt.floor('1d')
end_session = end_dt
else:
end_session = metadata.end_session
+4
View File
@@ -167,3 +167,7 @@ class PricingDataNotLoadedError(ZiplineError):
'Please ingest data using the command '
'`catalyst ingest -b exchange_{exchange}`. '
'See catalyst documentation for details.').strip()
class ApiCandlesError(ZiplineError):
msg = ('Unable to fetch candles from the remote API: {error}.').strip()
+4 -2
View File
@@ -1,3 +1,4 @@
from datetime import timedelta
from logging import Logger
import pandas as pd
@@ -12,8 +13,9 @@ class ExchangeBundleTestCase:
def test_ingest_minute(self):
exchange_name = 'bitfinex'
start = pd.to_datetime('2017-09-01', utc=True)
end = pd.Timestamp.utcnow()
# start = pd.to_datetime('2017-09-01', utc=True)
end = pd.Timestamp.utcnow() - timedelta(minutes=5)
start = end - timedelta(minutes=30)
exchange_bundle = ExchangeBundle(get_exchange(exchange_name))