Solid, up-to-date example that uses pandas panel data...

126 views
Skip to first unread message

Joël Hubert

unread,
Jul 13, 2016, 6:43:54 AM7/13/16
to Zipline Python Opensource Backtester
Hi!

This is the second time I'm doing a project with Zipline and the second time I'm REALLY struggling with the documentation. Everything seems outdated. I feel like a five-year old on a treasure hunt when I try to figure out zipline stuff. Anyway, simple request:

Could you please, please post a solid, up to date example of a super simple algo that uses panel data (custom csv import)? 

I've got a proper pandas panel waiting, but I have no clear idea of how to make it jive with initialize and handle_data

An example along the lines of the following would greatly help: 

from zipline.algorithm import TradingAlgorithm
from zipline.api import order, symbol

import matplotlib.pyplot as plt

panel = pd.Panel(data)

sim_params = factory.create_simulation_parameters(
start=pd.to_datetime("01-04-14").tz_localize("Europe/London").tz_convert("UTC"),
end=pd.to_datetime("11-06-16").tz_localize("Europe/London").tz_convert("UTC"),
data_frequency="daily",
emission_rate="daily")

def initialize(algo):


def handle_data(algo, data):


algo = TradingAlgorithm(initialize=initialize, handle_data=handle_data, sim_params=sim_params)
results = algo.run(data=panel, overwrite_sim_params=False)
results.portfolio_value.plot()




Reply all
Reply to author
Forward
0 new messages