'XNYSExchangeCalendar' object has no attribute 'session_in_range'

53 vues
Accéder directement au premier message non lu

Tob Ias

non lue,
3 mai 2020, 07:58:5403/05/2020
à Zipline Python Opensource Backtester
Hey everyone, I started with Andreas Clenow's book "Trading Evolved" and I'm stuck with my first zipline backtest. Whenever I want to run the code

results = run_algorithm(
    start
=start_date,
   
end=end_date,
    initialize
=initialize,
    capital_base
=10000)

I get this error message:
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-7b18cedc222a> in <module>()
     68     end=end_date,
     69     initialize=initialize,
---> 70     capital_base=10000)

~\Anaconda3\envs\env_zipline\lib\site-packages\zipline\utils\run_algo.py in run_algorithm(start, end, initialize, capital_base, handle_data, before_trading_start, analyze, data_frequency, data, bundle, bundle_timestamp, trading_calendar, metrics_set, default_extension, extensions, strict_extensions, environ, blotter)
    428         local_namespace=False,
    429         environ=environ,
--> 430         blotter=blotter,
    431     )

~\Anaconda3\envs\env_zipline\lib\site-packages\zipline\utils\run_algo.py in _run(handle_data, initialize, before_trading_start, analyze, algofile, algotext, defines, data_frequency, capital_base, data, bundle, bundle_timestamp, start, end, output, trading_calendar, print_algo, metrics_set, local_namespace, environ, blotter)
    157             trading_calendar=trading_calendar,
    158             trading_day=trading_calendar.day,
--> 159             trading_days=trading_calendar.schedule[start:end].index,
    160         )
    161         first_trading_day =\

~\Anaconda3\envs\env_zipline\lib\site-packages\zipline\finance\trading.py in __init__(self, load, bm_symbol, exchange_tz, trading_calendar, trading_day, trading_days, asset_db_path, future_chain_predicates, environ)
    101             trading_day,
    102             trading_days,
--> 103             self.bm_symbol,
    104         )
    105

~\Anaconda3\envs\env_zipline\lib\site-packages\zipline\data\loader.py in load_market_data(trading_day, trading_days, bm_symbol, environ)
    147         # date so that we can compute returns for the first date.
    148         trading_day,
--> 149         environ,
    150     )
    151     tc = ensure_treasury_data(

~\Anaconda3\envs\env_zipline\lib\site-packages\zipline\data\loader.py in ensure_benchmark_data(symbol, first_date, last_date, now, trading_day, environ)
    214
    215     try:
--> 216         data = get_benchmark_returns(symbol)
    217         data.to_csv(get_data_filepath(filename, environ))
    218     except (OSError, IOError, HTTPError):

~\Anaconda3\envs\env_zipline\lib\site-packages\zipline\data\benchmarks.py in get_benchmark_returns(symbol)
     21     first_date = datetime(1930,1,1)
     22     last_date = datetime(2030,1,1)
---> 23     dates = cal.session_in_range(firs_date, last_date)
     24     data = pd.DataFrame(0.0, index=dates, columns=["close"])
     25     data = data["close"]

AttributeError: 'XNYSExchangeCalendar' object has no attribute 'session_in_range'

Does anyone have a clue how to fix this error? Tank you!

Ayoub Ennassiri

non lue,
3 mai 2020, 13:29:3403/05/2020
à Zipline Python Opensource Backtester
Hi Tobias, 

I think that session_in_range should be sessions_in_range in the benchmarks.py that you amended. 

On a side note, I would recommend using the latest build version while waiting for a new Zipline release:

Thanks
Ayoub

Tob Ias

non lue,
3 mai 2020, 14:20:2103/05/2020
à Zipline Python Opensource Backtester
Hi Ayoub, thank you very much!!! 
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message