mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-02 19:54:45 +08:00
Bug fixes
This commit is contained in:
@@ -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'])
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user