Getting started Problem

121 views
Skip to first unread message

Ahmad Hashemi

unread,
Nov 29, 2017, 2:46:58 PM11/29/17
to Zipline Python Opensource Backtester

Hi zipliners,


I need to run a loop of backtesting via Zipline, butI could not implement even a simple Algorithm as attachment (buy APPL and print 2 comments)

There isn’t unfortunately any Tutorial about it. The Link here seems to be deleted, which was a Notebook in folder “Tutorials and Documentation” of Quantopian account.
Thank you in advance!


from zipline.api import order
from zipline.api import history


def initialize(context):
    print('initialize ran')
    context.test = 'It is just a test. \n'


def handle_data(context,data):
    order('AAPL',10)
    print(context.test)

if __name__ == '__main__':
    algo = TradingAlgorithm(initialize=initialize, handle_data=handle_data)
    data = history('AAPL','price', 10, '1d')
    algo.run(data=data)

Ed Bartosh

unread,
Nov 29, 2017, 3:22:01 PM11/29/17
to Ahmad Hashemi, Zipline Python Opensource Backtester
Hi Ahmad,

I guess you're looking for this: http://www.zipline.io/beginner-tutorial.html

Regards,
Ed

--
You received this message because you are subscribed to the Google Groups "Zipline Python Opensource Backtester" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zipline+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
BR,
Ed

Ahmad Hashemi

unread,
Nov 29, 2017, 4:33:55 PM11/29/17
to Zipline Python Opensource Backtester

Hi Ed,


Thanks for the answer by return.

I want to run something as same as my first algorithm.

I would better ask, how I can run the algorithm in IPython Notebook, namely Research environment of Quantopian.


best regards

Ahmad

Ahmad Hashemi

unread,
Nov 29, 2017, 5:26:20 PM11/29/17
to Zipline Python Opensource Backtester
screenshot of error message is attached.


On Wednesday, November 29, 2017 at 8:46:58 PM UTC+1, Ahmad Hashemi wrote:
screenshot.JPG

Ed Bartosh

unread,
Nov 29, 2017, 6:12:12 PM11/29/17
to Ahmad Hashemi, Zipline Python Opensource Backtester
Hi Ahmad,

To run that zipline example you need to have Ipython notebook installed. You can do it following this guide: http://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/install.html

If you want to run your algo in Quantopian research platform that's different story. It's better to ask about it on Quantopian forum.

Regards,
Ed

--
You received this message because you are subscribed to the Google Groups "Zipline Python Opensource Backtester" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zipline+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
BR,
Ed

Ahmad Hashemi

unread,
Nov 30, 2017, 12:55:12 PM11/30/17
to Zipline Python Opensource Backtester
Thanks again for your support.
I have also asked my question over there yesterday, but so far has received no answer.


On Wednesday, November 29, 2017 at 8:46:58 PM UTC+1, Ahmad Hashemi wrote:

fva...@quantopian.com

unread,
Nov 30, 2017, 1:10:16 PM11/30/17
to Zipline Python Opensource Backtester
Hi Ahmad,

You can run backtests in the research environment, but you should use the run method (like you do in your notebook in this post (https://www.quantopian.com/posts/is-backtesting-in-research-notebooks-impossible). Using Zipline in Quantopian Research is different from running Zipline on your own machine, using IPython Notebook.

The error is coming from getting benchmark data it seems, in zipline.data.benchmarks. I've opened a PR that should hopefully fix that. 

If you want to use Zipline, I'd suggest either using Zipline in your own machine, in an IPython Notebook, or just use the backtester on quantopian.com/algorithms, if you're looking to use Pipeline, Optimize, or other Quantopian APIs.

Ahmad Hashemi

unread,
Nov 30, 2017, 2:46:33 PM11/30/17
to Zipline Python Opensource Backtester

Hi Freddie


As I said before I want to run a loop of backtests, something like the work of Justin Lent over here, in order to apply various optimization methods (Metaheuristics and Mathematical) based on various parameters (technical and fundamental Factors, Risk metrics as Scharpe, Alpha, Return). To implement my exposé, I found Research environment more compatible. Am I right?


About of the error I think it is coming from invocation and making an object of TradingAlgorithm, their Arguments (such as initialize, handle data, capital base, etc.) are all deleted from constructor. Cloned version of Justins work has the same problem.


I really appreciate any help you can provide


Regards

Ahmad



On Wednesday, November 29, 2017 at 8:46:58 PM UTC+1, Ahmad Hashemi wrote:

Ed Bartosh

unread,
Dec 1, 2017, 11:45:35 AM12/1/17
to Ahmad Hashemi, Zipline Python Opensource Backtester
HI Ahmad,

Hi Ahmad,

Can you explain why do you need that? You can run backtest in Quantopian and then analize it in Research.

Regards,
Ed

--
You received this message because you are subscribed to the Google Groups "Zipline Python Opensource Backtester" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zipline+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
BR,
Ed
Reply all
Reply to author
Forward
0 new messages