Stock Exchange Data
  • AI Chat
  • Code
  • Report
  • Beta
    Spinner

    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.

    Not sure where to begin? Scroll to the bottom to find challenges!

    import pandas as pd
    
    stock_data = pd.read_csv("stock_data.csv", index_col=None)
    stock_data

    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

    Source of dataset.

    Don't know where to start?

    Challenges are brief tasks designed to help you practice specific skills:

    • πŸ—ΊοΈ Explore: Which index has produced the highest average annual return?
    • πŸ“Š Visualize: Create a plot visualizing a 30 day moving average for an index of your choosing.
    • πŸ”Ž Analyze: Compare the volatilities of the indexes included in the dataset.

    Scenarios are broader questions to help you develop an end-to-end project for your portfolio:

    You are working for an investment firm that is looking to invest in index funds. They have provided you with a dataset containing the returns of 13 different indexes. Your manager has asked you to make short-term forecasts for several of the most promising indexes to help them decide which would be a good fund to include. Your analysis should also include a discussion of the associated risks and volatility of each fund you focus on.

    You will need to prepare a report that is accessible to a broad audience. It should outline your motivation, steps, findings, and conclusions.

    Before we start exploring and analysing our data, let's explain the concept of stock data and Why did we neet to analyses. Stock data refers to the historical and real-time information about a company's stock, incloude its price trading volume and other relevant metrics. Analyzing stock data is crucial for making informed investment decisions. Investors and traders analyze this data to identify trends, patterns and potential opportunities or risks in the market. Not analyzing stock data could lead to uninformed decisions, increasing the likelihood of financial losses

    # Numbers of columns
    stock_data.shape
    # Check if the data is clean
    stock_data.isna().sum()
    # Data type
    stock_data.dtypes

    We can convert our object date to datatime once or or several times if we need it.

    # import pandas
    import pandas as pd
    # import date
    from datetime import datetime
    # Convert date object to datetime
    stock_data['Date'] = pd.to_datetime(stock_data['Date'])
    
    # Verify the changes
    stock_data.dtypes

    Use Histogram graphic to show the distribution of Close price date

    import matplotlib.pyplot as plt
    
    # Plot histogram of the "Close" column in stock_data
    plt.hist(stock_data["Close"], bins=20, color='skyblue')
    
    # Add labels and title
    plt.xlabel("Closing Price")
    plt.ylabel("Frequency")
    plt.title("Distribution of Stock Closing Prices")
    
    # Show the plot
    plt.show()

    Calculate the highest price and lowest price during the trading day

    To calculate highest orice we use 'High' column dot mex.

    To calculate lowest price we use 'Low' column dot min

    # Calculate the highest and lowest price during the trading day
    highest_price = stock_data['High'].max()
    lowest_price = stock_data['Low'].min()
    
    print('Highhest Price =', highest_price, 'Lowest Price =', lowest_price)
    β€Œ
    β€Œ
    β€Œ