Skip to content
This repository has been archived by the owner on Nov 26, 2022. It is now read-only.

Pandas Error on small Timeframes #276

Closed
avolution opened this issue Mar 16, 2018 · 2 comments
Closed

Pandas Error on small Timeframes #276

avolution opened this issue Mar 16, 2018 · 2 comments

Comments

@avolution
Copy link

avolution commented Mar 16, 2018

Hey guys,

I found a problem by running backtests with small timeframes

For example:
2017-12-01 10:00:00 to 2017-12-01 15:00:00

Here is the run_algorithm call:

run_algorithm(
exchange_name='bitfinex',
capital_base=10000,
data_frequency='minute',
initialize=initialize,
handle_data=handle_data,
analyze=analyze,
algo_namespace=NAMESPACE,
base_currency='usd',
start = pd.to_datetime('2017-12-01 10:00:00', utc=True),
end = pd.to_datetime('2017-12-01 15:00:00', utc=True),
output=out
)

Catalyst version 0.5.3

This error will occur:

File "../catalyst/lib/python3.6/site-packages/catalyst/utils/run_algo.py", line 549, in run_algorithm
stats_output=stats_output
File "../catalyst/lib/python3.6/site-packages/catalyst/utils/run_algo.py", line 269, in _run
last_available_session=end
File ".../catalyst/lib/python3.6/site-packages/catalyst/exchange/exchange_data_portal.py", line 250, in init
super(DataPortalExchangeBacktest, self).init(*args, **kwargs)
File ".../catalyst/lib/python3.6/site-packages/catalyst/exchange/exchange_data_portal.py", line 28, in init
super(DataPortalExchangeBase, self).init(*args, **kwargs)
File ".../catalyst/lib/python3.6/site-packages/catalyst/data/data_portal.py", line 301, in init
if self._first_trading_day is not None else (None, None)
File ".../catalyst/lib/python3.6/site-packages/catalyst/utils/calendars/trading_calendar.py", line 647, in open_and_close_for_session
sched.at[session_label, 'market_open'].tz_localize('UTC'),
File ".../catalyst/lib/python3.6/site-packages/pandas/core/indexing.py", line 1665, in getitem
return self.obj.get_value(*key, takeable=self._takeable)
File ".../catalyst/lib/python3.6/site-packages/pandas/core/frame.py", line 1900, in get_value
return engine.get_value(series.get_values(), index)
File "pandas/index.pyx", line 98, in pandas.index.IndexEngine.get_value (pandas/index.c:3557)
File "pandas/index.pyx", line 106, in pandas.index.IndexEngine.get_value (pandas/index.c:3240)
File "pandas/index.pyx", line 583, in pandas.index.DatetimeEngine.get_loc (pandas/index.c:11566)
KeyError: Timestamp('2017-12-01 10:00:00+0000', tz='UTC')


The timeframe setting 2017-12-01 00:00:00 to 2017-12-01 23:59:00 for example is working without any problems.

Would be nice to be able to backtest on that smaller frames to test algos on special market situations.

@AvishaiW
Copy link
Contributor

AvishaiW commented Mar 18, 2018

I think this error is identical to #268

@lenak25
Copy link
Contributor

lenak25 commented Mar 21, 2018

@avolution we are closing this as this issue is already discussed on another thread, like @AvishaiW mentioned.
Please feel free to add more information to issue #268 or reopen this if you feel otherwise.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants