UPDATED series: https://pythonprogramming.net/quantopian-trading-strategies-introduction-python-programming-for-finance/
This series has become outdated with Quantopian 2.0.
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