Stock Market analysis practice

*This is not a tutorial post but just notes of practicing on following tech materials.

I have studied the python data visualization course performed by Jose Portlla. I highly recommend this course if you are interested in Python drills. At this post, I am writing my note while I practice stock market analysis.


import pandas as pd
from pandas import Series,DataFrame
import numpy as np

import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('whitegrid')

from pandas.io.data import DataReader

from datetime import datetime

from __future__ import division

I recall some libraries to generate graphs. In the tutorial operated by Jose, Yahoo data and pandas have been used to grab some data.

For more detail, probably you need to go to Udemy and see the lectures note. In this post, I am just writing what I’ve been practiced.

I want to see a historical view of the closing price.


AAPL['Adj Close'].plot(legend=True,figsize=(10,4))

axes_subplots

And let’s see the volumes of tradings

matplotlib_volumes

Still I am very on to sloppy understanding “Why the graph looks like this?” Perhaps, this is the point where I need to study on financial analysis.


AAPL[['Adj Close','MA for 10 days','MA for 20 days','MA for 50 days']].plot(subplots=False,figsize=(10,4))

I’ve got this moving average graph.

moving_axes_subplots

I want to compare the daily percentage return of two stocks to check how correlated. I expect that comparing Google to itself will show me a quite-matched linear relationship.


sns.jointplot('GOOG','GOOG',tech_rets,kind='scatter',color='seagreen')

sns.jointplot('GOOG','MSFT',tech_rets,kind='scatter')

seaborn.axisgrid.1

seaborn.joint.grid.2

Wow. two stocks are perfectly correlated with each other a linear relationship between its daily return values.

The blue one is a comparison between Google and Microsoft.

Seems like seaborn and pandas make all the data be represented on its comparison analysis. I couldn’t do this with Excel or other program.

seaborn.pairplot

I wonder if I can generate similar result in R. I am quite happy with python since I am subscribing some python course(but must of them are web development though.) Hopefully, I can catch some R codes later along with D3.

Advertisements