Skip to content

04-04: Stock Price Chart

Python: Data Analytics

View the live site — ijk37.com

Project 04

Home  |  All Projects  |  Notes  |  Exercises  |  Quiz Hub

Simulates 90-day stock price data for three companies using a random walk, then plots: all companies on one chart, a single company with 10-day moving average (high/low annotated), and a daily percentage-change bar chart. Saved as stock_chart.png.

Topics covered: np.cumprod() · np.convolve() · ax.plot() multiple lines · ax.annotate() · ax.scatter() · np.diff() · ax.bar() · plt.subplots(3,1)

Difficulty: ⭐⭐⭐ Intermediate


Requirements

pip install matplotlib numpy

How to Run

python main.py

Output: stock_chart.png


Key Concepts Practised

Concept Where used
np.random.normal(loc, scale) Simulated daily returns
np.cumprod(1 + returns) Cumulative price series
np.convolve(prices, kernel) Simple moving average
ax.annotate() High/low price labels
ax.scatter(..., marker="^") Triangle markers at extremes
np.diff(prices) / prices[:-1] Daily % change