Open gaacevedof opened 9 months ago
it seems to be an issue with pandas API DataFrame.append and Series.append are deprecated, the recommended way forward is to use pandas.concat
if you check your error trace it states ~\AppData\Local\Temp\tmp_tovme1s\ipykernel_4732\1025870542.py in ?(context, data)
meaning that the error is in your notebook. replace append by concat in your notebook code
Dear Zipline 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:
I was having some problems using the run_algorithm function of the Zipline library. It was giving me some errors so I did some changes in the library.
In algorithm file, line 2284 I add .tz_localize(None) because it was giving me the error KeyError: Timestamp('2017-11-30 00:00:00+0000', tz='UTC')
sim_end_session = self.sim_params.end_session.tz_localize(None)
but now I have a new error
AttributeError Traceback (most recent call last) ~\AppData\Local\Temp\tmp_tovme1s\ipykernel_4732\1562877378.py in ?() 1 start = time() ----> 2 results = run_algorithm(start=start_date, 3 end=end_date, 4 initialize=initialize, 5 before_trading_start=before_trading_start,
~\anaconda3\Lib\site-packages\zipline\utils\run_algo.py in ?(start, end, initialize, capital_base, handle_data, before_trading_start, analyze, data_frequency, bundle, bundle_timestamp, trading_calendar, metrics_set, benchmark_returns, default_extension, extensions, strict_extensions, environ, custom_loader, blotter) 393 load_extensions(default_extension, extensions, strict_extensions, environ) 394 395 benchmark_spec = BenchmarkSpec.from_returns(benchmark_returns) 396 --> 397 return _run( 398 handle_data=handle_data, 399 initialize=initialize, 400 before_trading_start=before_trading_start,
~\anaconda3\Lib\site-packages\zipline\utils\run_algo.py in ?(handle_data, initialize, before_trading_start, analyze, algofile, algotext, defines, data_frequency, capital_base, bundle, bundle_timestamp, start, end, output, trading_calendar, print_algo, metrics_set, local_namespace, environ, blotter, custom_loader, benchmark_spec) 224 "algo_filename": getattr(algofile, "name", ""),
225 "script": algotext,
226 },
227 ).run()
--> 228 except NoBenchmark:
229 raise _RunAlgoError(
230 (
231 "No
benchmark_spec
was provided, and"~\anaconda3\Lib\site-packages\zipline\algorithm.py in ?(self, data_portal) 630 631 self.analyze(daily_stats) 632 finally: 633 self.data_portal = None --> 634 self.metrics_tracker = None 635 636 return daily_stats
~\anaconda3\Lib\site-packages\zipline\gens\tradesimulation.py in ?(self) 239 yield self._get_daily_message(dt, algo, metrics_tracker) 240 elif action == BEFORE_TRADING_START_BAR: 241 self.simulation_dt = dt 242 algo.on_dt_changed(dt) --> 243 algo.before_trading_start(self.current_data) 244 elif action == MINUTE_END: 245 minute_msg = self._get_minute_message( 246 dt,
~\anaconda3\Lib\site-packages\zipline\algorithm.py in ?(self, data) 433 434 with handle_non_market_minutes( 435 data 436 ) if self.data_frequency == "minute" else ExitStack(): --> 437 self._before_trading_start(self, data) 438 439 self._in_before_trading_start = False
~\AppData\Local\Temp\tmp_tovme1s\ipykernel_4732\1025870542.py in ?(context, data) 3 Called every day before market open. 4 """ 5 output = pipeline_output('signals') 6 context.trades = (output['longs'].astype(int) ----> 7 .append(output['shorts'].astype(int).mul(-1)) 8 .reset_index() 9 .drop_duplicates() 10 .set_index('index')
~\anaconda3\Lib\site-packages\pandas\core\generic.py in ?(self, name) 5985 and name not in self._accessors 5986 and self._info_axis._can_hold_identifiers_and_holds_name(name) 5987 ): 5988 return self[name] -> 5989 return object.getattribute(self, name)
AttributeError: 'Series' object has no attribute 'append'
I don´t know what to do here to do it works.
...
Sincerely, Gabriel