Stock Market Trading with ML & AI Series - Tools of the Trade III (Python Modules)

in Project HOPE4 years ago

For those that have been following my series on building an automated stock trading application, I want to say thank you! It's amazing that we are now in the fourth article in this series and can't wait for us to start some coding. However, before we can get to where we can begin to get our hands dirty with python programming, there are still a few housekeeping we need to do. One of such is to continue building our toolbox for the task at hand. Last week, we looked at the anaconda and IDE tools. This week, we will be looking at the python modules we need and how to install them. It might help to think of anaconda and the IDE of choice as the building frame while the python modules as components of the building such as windows, roof etc. The python modules need to fit nicely to the anaconda and IDE frame or you get a very awkward looking building - sorry, I meant application.

There are 7 python modules we'll generally need and they are pandas, numpy, yfinance, matplotlib, scipy, scikit-learn and requests. I will try explain each of these libraries next stating what they are and why we use them.

Pandas

This is a python module that allows for intelligent handling of data. I find the easiest way to think about the need and versatility of pandas is by using a simple thought experiment. Consider for example, that you want to interact with data that has 3 dimensions using Microsoft Excel. You quickly realize this is an arduous task and easily prone to errors. Now consider that the data dimension is now 5 or 10 and you quickly realize this is an impossible task for MS Excel or any other ordinary data handler. It is especially in the multidimensional data scenario that pandas shine and prove their worth. There are other amazing things you can do with pandas such as automatic anchoring of data across dimensions that we'll find very useful as we go along.

Numpy

This is another data handler and infact very related to pandas. I generally consider a numpy array as a subset of a panda data frame (but that's me as some might disagree). Numpy shines where you'll need to do matrix type manipulations on your data which will be more often than you'll like when working with ML/AI. There are alternatives to using numpy arrays, like explicit for loops but those can be very slow and I'll save you the pain right now by teaching you the numpy way.

yfinance

This is the API module that will allow us to download stock data from yahoo finance. We are using ML/AI to trade and you can't do that without data. Using yahoo finance (with some restrictions) allows us to get this data for free. I'll talk about these restrictions in a separate post and also give links to paid subscription services for those who prefer not to have those restrictions.

Matplotlib

This is python's main plotting module. There is the popular adage that says a picture is worth a thousand lines of code - sorry, you know I meant to say words - and I find there is no substitution for being able to plot your data and analysis when it comes to understanding your trading algorithm.

Scipy

Python's statistics library. Statistics is the backbone of ML/AI and we'll be using statistics a lot to analyze our algorithms.

Scikit-learn

This is the main ML/AI module. I am sure you will not like me and my blog if I make you write all the ML/AI algorithms we'll be needing from scratch before you can use them to trade. Luckily, you don't have to because of scikit-learn. All ML/AI algorithms we'll need will come from here.

Requests

We'll be downloading data from the web and requests allows you to do this quite easily.

So that is it for this week. I've linked the documentation for all the modules above, so spend sometime going through them before next week. Next week, I'll be showing you how to install each of these modules.

DISCLAIMER
Trading is very risky and you should only risk funds you are willing to loose in trading either humanly or via ML/AI. This blog content does not constitute investment advise nor is it a substitute for expert opinion. When in doubt, please consult your financial adviser

Yours in learning,

AIPLUSFINANCE.png

Sort:  

Have a witness !BEER

As a follower of @followforupvotes this post has been randomly selected and upvoted! Enjoy your upvote and have a great day!

Coin Marketplace

STEEM 0.19
TRX 0.16
JST 0.033
BTC 64192.94
ETH 2764.54
USDT 1.00
SBD 2.65