Skip to content

Dictionary Assembly of Stock Data, completed as personal project for CIS 9650: Programming for Analytics

Notifications You must be signed in to change notification settings

Oheb/Stock_Analysis_Report

Repository files navigation

CIS9650 Assignment 2 - Stock Analysis Report

Overview

Reads historical stock market data from a CSV file and calculates technical indicators including SMA(30), EMA(30), daily returns, and 20-period volatility for multiple stocks.

How to Run

Required Packages

import numpy as np
import pandas as pd

Execution

python danieloheb_assignment_2.py

The script reads the csv file stock_data_july_to_september.csv and outputs a JSON dictionary with analysis results based on the computational findings.

Data File Format

The CSV should contain the following columns for each row:

  • Date: Trading date (YYYY-MM-DD)
  • Symbol: Stock ticker (AAPL, MSFT, GOOGL, etc.)
  • Open, High, Low, Close: Price data (Price at Opening, Highest Daily Price, Lowest Daily Price, and Price at Closing)
  • Volume: Trading volume (Total Shares Moved During Period)

Example:

Date,Symbol,Open,High,Low,Close,Volume
2025-07-01,AAPL,150.5,152.3,150.0,151.8,1000000

Key Functions

  • read_and_parse_csv(filepath): Reads CSV and returns list of dictionaries
  • stock_summary(rows_for_symbol): Extracts and returns (symbol, highest_high, lowest_low) as tuple from CSV
  • technical_analysis(closes): Returns dict with sma_30, ema_30, three_month_return, average_vol (Rolling Average, Exponential Average, Last Daily Return, and Average Standard Deviation of Returns Over Last 20 periods)
  • main(path): Orchestrates full pipeline and outputs formatted JSON report for reader to analyze

Assumptions

  • CSV headers match exactly in syntax and spelling: Date, Symbol, Open, High, Low, Close, Volume
  • Data is in proper chronological order (oldest to newest)
  • Each stock has sufficient data (30+ daily closes for analysis in both SMA and EMA)
  • Incomplete rows are silently skipped for proper analysis
  • Numeric fields contain valid numeric values (Floats, Integers)

Output Example

{
  "AAPL": {
    "highest_high": 257.6,
    "lowest_low": 201.27,
    "tech": {
      "sma_30": 238.44,
      "ema_30": 240.11,
      "three_month_return": 0.0008,
      "average_vol": 0.0182
    }
  }
}

About

Dictionary Assembly of Stock Data, completed as personal project for CIS 9650: Programming for Analytics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published