Programming for Finance with Python and Quantopian and Zipline Part 1



What is going on welcome to a python for finance tutorial video. Just to clarify right out of the gate, a lot of people envision programming as being used solely for high frequency trading, since computers can execute trades faster than people. While that is true, and computers are used for High Frequency Trading (HFT), they are also used for a whole lot more in finance. We're going to show the use of programming for things like simple algorithmic trades like moving average crossovers, all the way to utilizing things like machine learning. Computers can be used for really anything from high frequency trading to long term investing. Computers allow you to test all of your ideas through what is called back-testing. Back testing is where we take our trading strategies and apply them to historical data to see how they would have done if we had employed them. Back testing comes with some inherent flaws. First off, the usual warning about historical results are not indicative of future ones, and back testing also tends to ignore things like execution time, or how long it takes to actually make a trade. Depending on execution time and the order size, you're almost certainly to experience what is called skid / slippage. Skid/slip is the change in price during an order, from the point of execution initialization to when you actually complete the order. All that said, back testing is still a must, and you will find as we go through this series that back testing can become a reliable method for looking into the future, and we can also add risk metrics on top of it. So, this series is going to go through automated trading with python for finance. It would be helpful to have at least some background in Python, though I will do my best to make it not necessary. I will explain the code each step of the way, and, should you have any questions or confusions, I am always happy to help. So let's get started. To do this series, we're going to build everything on top of a service called Quantopian. Quantopian is a web app that allows us to write pure python code, it's not a rendition of python, it is python, in their web based IDE, which is the editor we write code into. They have a ton of batteries included so to speak, which means they have a lot of the modules that we're going to be using. Modules are pre-written code that we can import and use so we don't have to write a hundred thousand lines of code to do machine learning, for example. For the newcomer to Python, modules can be a bit of a pain to acquire. Using Quantopian eliminates this pain completely. We also want to use Quantopian because their back-testing simulation is very noob friendly. Quantopian is built on top of python, a bunch of other modules, and a module called Zipline, which is a back-testing module for Python. Zipline can be used outside of Quantopian, so you can learn with Quantopian and then protect your algorithm if you wanted to by moving off their website, but, for now, it will make things extremely simple. Quantopian also has a ton of high quality data that we can use. Normally, you will need to go and acquire this data somehow. There are some really great data resources out there, but Quantopian makes this super easy too. sample code: http://pythonprogramming.net http://hkinsley.com https://twitter.com/sentdex http://sentdex.com http://seaofbtc.com

Comments

  1. HOW does this guy learn all this stuff??
    Seriously i mean he said in one of his Q&A that he did so by just using google :-
    I tried that -first, read the module doc and try understand something with the help of good old google but nothing really makes sense to me that way
  2. Dude, people like you make the internet great
  3. Just use Anaconda to get all scientific Python packages to play nice.
  4. I have a 64 bit Windows with Python 3 and Anaconda installed. However, I am unable to install zipline. Any suggestions would be of great help.
  5. this is really cool. I like to watch your videos
  6. man you are doing a very very good job :-) God bless you
  7. Thank you !
  8. Hello! is this playlist still applicable to the syntax used now in quantopian?
  9. I love you dude !
  10. Your videos are awesome, down to earth, to the point and very interesting. Thanks heaps for sharing!
  11. how would I use the algo with real money?
  12. Skeptical about the safety of your algorithms - what's stopping quantopian from identifying and 'stealing' your algo?
  13. Hi there, is it possible to trade in quantopian? I mean to use it as a broker and what about commision of quantopian for one transaction of stocks?
  14. I don't get the same algorithms you do on Quantopian, what do I do?
  15. Sentdex, which version of python are you using for this series?
  16. I am just getting into Python and Raspberry Pi. Do you think that a Raspberry Pi cluster would be a option for running finance code with Robinhood?
  17. Have you used Zipline outside of Quantopian? if yes, what IDE did you use? is it easier or better? I like the autocomplete that PTVS provides, but so far I have struggle a little to make sense of it all..
  18. i love u. i had been finding this kind of help for over a year. god bless u my man. if i can make profit out of this. i promise i will do the same that u do to me to other.
  19. Do you think you could make a Python video series which shows how to access real-time data, for example through IB, without Quantopian? With Quantopian you have to place your code on their website. Plus, they place limits on what Python code you can execute.

    I would like to see a video series where you are not dependent on Quantopian to access real-time data. I would like to see a video series where you can write Python code in a native Python IDE such as Spyder, PyCharm, etc.
  20. Much respect to you my man! I truly appreciate these tutorials.


Additional Information:

Visibility: 84952

Duration: 13m 41s

Rating: 917