scrtlabs / catalyst

An Algorithmic Trading Library for Crypto-Assets in Python
http://enigma.co
Apache License 2.0
2.49k stars 725 forks source link

catalyst run fails on first run #18

Closed lacabra closed 7 years ago

lacabra commented 7 years ago

Dear Catalyst Maintainers,

Before I tell you about my issue, let me describe my environment:

Environment

Now that you know a little about me, let me tell you about the issue I am having:

Catalyst fails when running an algo (starting with the buy_and_hodl.py suggested in the tutorial).

Trading algorithm should have run with no errors.

Catalyst throws the following error:

$ catalyst run -f buy_and_hodl.py --start 2015-3-1 --end 2017-6-28 --capital-base 100000 -o bah.pickle
[2017-07-30 08:20:48.089358] INFO: Loader: Loading benchmark data for 'USDT_BTC' from 1989-12-31 00:00:00+00:00 to 2017-07-28 00:00:00+00:00
[2017-07-30 08:20:48.089732] INFO: Loader: Cache at /Users/marta/.catalyst/data/USDT_BTC_benchmark.csv does not have data from 1990-01-01 00:00:00+00:00 to 2017-07-28 00:00:00+00:00.

[2017-07-30 08:20:48.090117] INFO: Loader: Downloading benchmark data for 'USDT_BTC' from 1989-12-31 00:00:00+00:00 to 2017-07-28 00:00:00+00:00
[2017-07-30 08:20:48.093315] DEBUG: catalyst.curate.poloniex: Getting data for USDT_BTC
Traceback (most recent call last):
  File "/Users/marta/Victor/env-c/bin/catalyst", line 11, in <module>
    sys.exit(main())
  File "/Users/marta/Victor/env-c/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/marta/Victor/env-c/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/marta/Victor/env-c/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/marta/Victor/env-c/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/marta/Victor/env-c/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/marta/Victor/env-c/lib/python2.7/site-packages/catalyst/__main__.py", line 97, in _
    return f(*args, **kwargs)
  File "/Users/marta/Victor/env-c/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/marta/Victor/env-c/lib/python2.7/site-packages/catalyst/__main__.py", line 240, in run
    environ=os.environ,
  File "/Users/marta/Victor/env-c/lib/python2.7/site-packages/catalyst/utils/run_algo.py", line 196, in _run
    env, data = get_trading_env_and_data(bundles)
  File "/Users/marta/Victor/env-c/lib/python2.7/site-packages/catalyst/utils/run_algo.py", line 156, in get_trading_env_and_data
    environ=environ,
  File "/Users/marta/Victor/env-c/lib/python2.7/site-packages/catalyst/finance/trading.py", line 99, in __init__
    self.bm_symbol,
  File "/Users/marta/Victor/env-c/lib/python2.7/site-packages/catalyst/data/loader.py", line 135, in load_crypto_market_data
    environ,
  File "/Users/marta/Victor/env-c/lib/python2.7/site-packages/catalyst/data/loader.py", line 367, in ensure_crypto_benchmark_data
    if not has_data_for_dates(daily_close, first_date, last_date):
  File "/Users/marta/Victor/env-c/lib/python2.7/site-packages/catalyst/data/loader.py", line 97, in has_data_for_dates
    return (first <= first_date) and (last >= last_date)
  File "pandas/tslib.pyx", line 1106, in pandas.tslib._Timestamp.__richcmp__ (pandas/tslib.c:20503)
  File "pandas/tslib.pyx", line 1167, in pandas.tslib._Timestamp._assert_tzawareness_compat (pandas/tslib.c:21519)
TypeError: Cannot compare tz-naive and tz-aware timestamps

Here is how you can reproduce this issue on your machine:

Reproduction Steps

First time you run: catalyst run -f buy_and_hodl.py --start 2015-3-1 --end 2017-6-28 --capital-base 100000 -o bah.pickle

What steps have you taken to resolve this already?

If you run the same command a second time, the error disappears.

Anything else?

No

Sincerely, Victor

rterbush commented 7 years ago

This may be fixed by https://github.com/enigmampc/catalyst/pull/20

lacabra commented 7 years ago

Addressed in commit 13d405b2b2593465c1d60a4dcf3a934a928b9666, which is part of 0.1.dev7 release: 20a98a32ca8ba60f295b05423e2afb93812e84bc in the master branch.