Python: zipline calendar / history issue

I have an erratic / strange result with the Zipline trading calendar. On the same machine as Python 3.4.2x64 and Zipline 0.7.42, I can run the following code:

trading.environment = TradingEnvironment(bm_symbol='^FTSE', exchange_tz='Europe/London') Holidays = list(set(tradingcalendar_lse.non_trading_days)-set(data.index)) trading.environment.trading_days = pd.date_range(start=trading.environment.trading_days[0], end=trading.environment.trading_days[-1], freq=pd.tseries.offsets.CDay(holidays=Holidays)) freq = trading.environment.trading_days.freq trading.environment.trading_days = trading.environment.trading_days + data.index trading.environment.trading_days.freq = freq trading.environment.open_and_closes = pd.DataFrame(index=trading.environment.trading_days + data.index,columns=["market_open","market_close"]) trading.environment.open_and_closes.market_open = (trading.environment.open_and_closes.index + pd.to_timedelta(60*7,unit="T")).to_pydatetime() trading.environment.open_and_closes.market_close = (trading.environment.open_and_closes.index + pd.to_timedelta(60*15+30,unit="T")).to_pydatetime() 

This comes from: zipline backtesting using non-US (European) intraday data

This is probably a little redundant, but allows me to have a history with all the dates of my data (on the same machine).

I try to run the same code on another computer that should have the same configuration and get an error:

 AttributeError: can't set attribute 

1) Can anyone think of the difference in my configurations that leads to this error?

2) Does anyone have a more robust calendar setting solution so that all my dates are in history at the end?

Thank you very much

+1
source share
1 answer

I spent a little more time on this. trading.environment.trading_days is actually a DatetimeIndex that should be unchanged, so trying to set a frequency is not a good approach. DatetimeIndex has methods that are more suitable for doing what I want. However, I cannot reproduce my first output using methods ...

0
source

Source: https://habr.com/ru/post/973446/


All Articles