Skip to content

Commit

Permalink
BUG: fixed issue scrtlabs#216 with bad candle data
Browse files Browse the repository at this point in the history
  • Loading branch information
fredfortier committed Feb 8, 2018
1 parent 97afbf7 commit 82d318a
Show file tree
Hide file tree
Showing 3 changed files with 392 additions and 13 deletions.
20 changes: 10 additions & 10 deletions catalyst/exchange/ccxt/ccxt_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,26 +425,26 @@ def get_candles(self, freq, assets, bar_count=1, start_dt=None,
'Please provide either start_dt or end_dt, not both.'
)

elif end_dt is not None:
# Make sure that end_dt really wants data in the past
# if it's close to now, we skip the 'since' parameters to
# lower the probability of error
bars_to_now = pd.date_range(
end_dt, pd.Timestamp.utcnow(), freq=freq
)
# See: https://github.com/ccxt/ccxt/issues/1360
if len(bars_to_now) > 1 or self.name in ['poloniex']:
if start_dt is None:
# TODO: determine why binance is failing
if end_dt is None and self.name not in ['binance']:
end_dt = pd.Timestamp.utcnow()

if end_dt is not None:
dt_range = get_periods_range(
end_dt=end_dt,
periods=bar_count,
freq=freq,
)
start_dt = dt_range[0]

since = None
if start_dt is not None:
# Convert out start date to a UNIX timestamp, then translate to
# milliseconds
delta = start_dt - get_epoch()
since = int(delta.total_seconds()) * 1000
else:
since = None

candles = dict()
for index, asset in enumerate(assets):
Expand Down
Loading

0 comments on commit 82d318a

Please sign in to comment.