Programming for Finance Part 2 - Creating an automated trading strategy



In this tutorial, we break down the major elements to creating and testing an automated trading strategy, using Quantopian, which is mainly the pairing of Python with Zipline. The basic required elements to all trading strategies through Python's zipline module are initialize and handle_data methods. The initialize method is used for setting any global parameters (stored in the context variable), and is run once at the very beginning of the algorithm. The handle_data method is run once per time series window, which is either one day, or one minute with Quantopian. OOP Crash course: http://pythonprogramming.net/object-oriented-programming-crash-course-tkinter/ Python Dictionaries: http://pythonprogramming.net/dictionaries-tutorial-python-3/ Pandas with Python tutorials: http://pythonprogramming.net/dashboard/#tab_dataanalysis sample code: http://pythonprogramming.net http://hkinsley.com https://twitter.com/sentdex http://sentdex.com http://seaofbtc.com

Comments

  1. congrats! we made it, yeah!!
  2. Hi, Here you have shown the backtesting on daily data, is it possible to do the same backtest on 5min or 15min data?
  3. Can you program candlestick analysis into this? like Hammers and Shooters?
  4. well, these series are simply awesome. thanks bud!
  5. is this still relevant?
  6. It take a lojng time for backtesting in Quantopian 2 , even more so,when I change the handle_data to schedule_data,it would not run the algorithm. Help!! Please
  7. I really like these videos, although I would not recommend it to someone with no Python coding experience.
    They really need to learn the basics before really taking advantage of these videos. Anyhow, great videos man.
  8. Hi I'm trying to replicate what you're doing here but Quantopian doesnt have the Daily/Minute option. It seems to be running by the minute Minute by default and taking forever. do you know how to set it back to daily? thanks
  9. i would like to know if the libraries available in quantopian are downloadable. can you use them in your own algorithm and if not are there any libraries on the internet about trading?
  10. Hey so this was posted roughly a year ago and I was wondering if it will still be applied today? I went to new algorithm and it had a lot more different "methods" to it. Looking at them it doesn't seem to complicated, but I was wondering if you had maybe a video or a link that would explain it better. Thank you for these videos though very helpful.
  11. Can you do a video on how to install all the python software like zipline and everything so you could make an algo outside of quantopian?
  12. start a python for finance coding bootcamp
  13. Thank you for sharing,

    How to use minutes or bars instead of days in moving average calculations?
  14. Great video. If I were to instead of moving average say buy if SPY raises 1% and sells when it reaches 1.5%, how would that look like?
  15. BRILLIANT!!!
  16. " Congratulations on making it to the second tutorial. This is the video where we're gonna lose the most viewers, so if you've made it this far, CONGRATULATIONS! "

    LOL
  17. hello sentdex,
    where would I be able to find the docs that show all of the data and methods behind the hidden classes?
  18. Thanks Sentdex!

    When you are establishing variables(MA1, current_price etc) what is the difference when you are using brackets to call upon something vs parenthesis vs periods?

    For example, why would context[portfolio.positions.symbol.spy].amount not work? What is going on when using each different callout(not sure what the right word is for those)?

    Thanks!
  19. Thanks for the video! A few questions:
    1. In the initialize method, will you ever pass in more arguments than "context"?
    2. What does it mean when you continue referencing "context", are you calling a specific input?


Additional Information:

Visibility: 38986

Duration: 10m 55s

Rating: 319