Lionel Fotso Kamga
2 min readApr 19, 2019

Practice of Machine Learning in Finance — An attempt at fetching data

Python has become a popular tool to extract and analyze stock price data. Many different APIs (Application in Program Interface) have been set up to that effect . The most popular APIs were the google, Yahoo finance ones, but they have been recently discarded because of the volume of requests they had to sustain. Fortunately, We were able to find a reliable one (Investor Exchange (IEX)). The IEX is a transparent and easily accessible stock exchange , founded by a famous financier Brad Katsuyama as an alternative to the more conventional options , that , to his opinion, were crippled with frauds, and dangerous practices such as high frequency trading.

We used the web.DataReader feature of the Pandas library to download the information necessary to our endeavor. With the dataReader, we can specify specific dates such that we can receive stock prices data from a certain period of time. The resulting data is stored into a dataframe. For this spring challenge, we will focus on the companies TESLA (Code TSLA), Ford (F) and General Motors (GM)

df = web.DataReader("TSLA", 'iex', start, end)

Here is an example of the of the sort of dataframe we obtain through this process:

             open     high      low     close    volume
date
2018-01-02 312.00 322.1099 311.00 320.53 4352241
2018-01-03 321.00 325.2500 315.55 317.25 4521527
2018-01-04 312.87 318.5500 305.68 314.62 9946304
2018-01-05 316.62 317.2400 312.00 316.58 4591180
2018-01-08 316.00 337.0199 315.50 336.41 9859435

Here is what this information means:

Open — Price of a share at opening

Low- Lowest share price of the day

High- Highest share price of the day

Volume — Number of shares traded during the day

I proceeded to graph the TSLA share price.

Graph depicting the evolution of the TSLA share price

Then, the GM share price

Graph depicting the evolution of the GM share price

and , finally, the Ford share price

Graph depicting the evolution of the Ford share price

I finished by graphing all of them together.

Graph depicting the evolution of the GM-Ford-Tesla share price