Skip to content
Analyzing Stock Exchange Data
  • AI Chat
  • Code
  • Report
  • Stock Exchange Data

    This dataset consists of stock exchange data since 1965 for several indexes. It contains the daily stock prices along with the volume traded each day.

    Data Dictionary

    ColumnExplanation
    IndexTicker symbol for indexes
    DateData of observation
    OpenOpening price
    HighHighest price during trading day
    LowLowest price during trading day
    CloseClose price
    Adj CloseClose price adjusted for stock splits and dividends
    VolumeNumber of shares traded during trading day
    CloseUSDClose price in terms of USD
    import pandas as pd
    
    stock_df = pd.read_csv("stock_data.csv", index_col=None, parse_dates=['Date'])
    stock_df
    #import modules
    
    import numpy as np
    import matplotlib.pyplot as plt
    import seaborn as sns
    import plotly.express as px
    import plotly.graph_objects as go
    from datetime import date

    Motivation

    The stock Exchange dataset contains several different indexes showing thier prices traded for each day from year 1965 to 2021. If we can forecast promising indexes it will help investing companies to make decision on the right indexes to invest on. This therefore is the key factor motivating me in exploring this data and creating valid insights for investors to use .

    Data Cleaning

    Due to Large range of period in years I will be:

    -limiting my data to 10 years only ie from 2011 to 2021.

    -The dataset contains nil missing values

    -The date column will be casted to a datetime object.

    stock_df.info()
    Hidden output
    #subseting rows where date is greater than 2010-12-31
    
    stock = stock_df[stock_df['Date'] > '2010-12-31']
    stock.reset_index(drop=True)
    #converting Date column to datetime type
    stock['Date'] = pd.to_datetime(stock['Date'],format='ISO8601')
    stock
    stock.info()
    Hidden output
    #describing the numrical columns
    stock.describe()

    The data which was initially 104224 rows and 9 columns was reduced to 33333 rows and 9 columns after limiting the data to years from 2011 - 2021.

    From the describe table we see that Over the past 10 years(2011 - 2021):

    -the minimum opening price was 523.809998 while the maximum opening price was at 68775.0625. On average the opening prices for these years was 13189.7426(ronded to 4 decimal places) while 50% of the prices where either above or below 10004.7998(rounded to 4 decimal places).

    -the minimum high price was 536.9899 while the maximum open price was at 69403.75. On average the open prices for these years was 13265.8998(ronded to 4 decimal places) while 50% of the prices where either above or below 10075.25(rounded to 4 decimal places).

    -the minimum low price was 514.109985 while the maximum low price was at 68516.9921. On average the low prices for these years was 13107.5053(ronded to 4 decimal places) while 50% of the prices where either above or below 9937.9902(rounded to 4 decimal places).

    -the minimum closing price was 529.5 while the maximum closing price was at 6877.0625. On average the closing prices for these years was 13189.4298(ronded to 4 decimal places) while 50% of the prices where either above or below 10009.82031(rounded to 4 decimal places).

    -the minimum Volume of shares traded was 0 while the maximum volume of shares traded was 94403740000. On average the volume of shares traded a day was 2269236352.291783 while 50% of the volume of daily trade were between 82312000

    -In USD the minimum closing price was 45.4420 while the maximum closing price was at 18934.3762. On average the closing prices for these years was 4780.4562(ronded to 4 decimal places) while 50% of the prices where either above or below 2877.2288(rounded to 4 decimal places).

    Next,I'll plot a small multiple charts to have a glimpse of how various indices have performed over the years.

    sns.set(style='whitegrid',font_scale=1.25)
    sns.set_palette('husl',3)
    sns.relplot(x='Date',y='Close', kind ='line',data=stock,col='Index',col_wrap=3)
    plt.show()

    Closing prices are useful markers for investors to use to assess changes in stock prices over time.The closing price is considered the most accurate valuation of a stock or other security until trading resumes on the next trading day.

    The graph above showing the various stock indexes shows that Index J203.JO has the highest closing index over the years, graph with index HSI and N225 also show increase in closing prices over the years.

    The other stock index where mostly flat or only slight increase where noticed.

    Task 1:

    Index with the highest average annual return