Trading Custom Markets (bitcoin example) – Zipline Tutorial finance with Python p.4

Hello and welcome to part 4 of the zipline local tutorial series. Up to this point, we’ve covered installing Zipline, using it locally, and even incorporating your own …


  1. is anyone else getting the following error: TypeError: 'datetime.time' object is not iterable when the code tries to run the zipline.run_algorithm. It's messing up right at trading_calendar=TwentyFourHR()

  2. can you explain how benchmark period returns are calculated and if that returns are cumulative returns , then by using the formula as cumulative_return(i) = product (1+ return(i)) -1 , not matching with benchmark period returns given in the output of zipline

  3. If it possible to backtest other parameters besides just price and volume? If I add another column without different days can I backtest against that data?

  4. Thank you for the 28 videos. They were amazing and helped me learn a lot about the automated trading / backtesting system I want to design. You are a great teacher.
    If you are thinking about uploading more content regarding finance is it possible for you to consider uploading a tutorial for creating a trading bot using 
    Zipline with ib_insync.

    Either ways grateful for all the help and keep up the good work.

  5. Solution for TypeError: Can't instantiate abstract class TwentyFourHR with abstract methods close_times, open_times.

    Replace code with the following code and restart Jupyter.
    from datetime import time

    from zipline.utils.memoize import lazyval

    from pandas.tseries.offsets import CustomBusinessDay

    from pytz import timezone

    from .trading_calendar import TradingCalendar

    class TwentyFourHR(TradingCalendar):


            Exchange calendar for 24/7 trading.


            Open Time: 12am, UTC

            Close Time: 11:59pm, UTC



        name = 'twentyfourhr'

        tz = timezone('UTC')

        open_times = (

                      (None, time(0, 0)),


        close_times = (

                         (None, time(23, 59)),



        def day(self):

            return CustomBusinessDay(

                                     weekmask='Mon Tue Wed Thu Fri Sat Sun',


  6. anyone else who is running this on Spyder get the error


    TypeError: Can't instantiate abstract class TwentyFourHR with abstract methods close_times, open_times

    I got this when running the perf function with the 24 hour calander. If you solved it let me know how please!

  7. Can anyone help?

    I encountered this error:

    TypeError: Can't instantiate abstract class TFSExchangeCalendar with abstract methods close_times, open_times

  8. What to do if I have one column of price data and one prediction column for the price of the assets(Derives from ML model). For commodity trading you also trade like 1 month into the future. Can I backtest that using zipline and notebook.

  9. Hi, when I search in ziplineutils for calendars there is no such folder. I followed your installation process but I cannot find it. I can only see python files called 'calendars' and 'tradingcalendars' any advise on this? thank you.

  10. Hi Harrison.First of all I would like to thank you for all the great content you share on youtube and on the internet.I have been a silent fan of you for a while now and I have learnt a lot from you.I will share my ideas and contributions as time goes on.Green pips to you good Sir.

  11. Hello! I'm just starting out and am following your tutorials! They're really useful. I tried testing your full script on your written tutorial, and i'm getting this error: TypeError: Already tz-aware, use tz_convert to convert.

Leave a Reply

Your email address will not be published.


65 + = 73