This project aims to perform a comprehensive Feature Engineering and Exploratory Data Analysis (EDA) on NVIDIA's stock data. By extracting key features and analyzing their behavior, we gain insights into stock performance, price trends, volatility, and market activity. The dataset is sourced from Yahoo Finance (yfinance) for a 1-year period.
- Data Collection: Historical stock data for NVIDIA was fetched using the
yfinanceAPI. - Data Preparation:
- Reset the index to use
Dateas a column. - Verified and converted
Datetodatetimeformat.
- Reset the index to use
- Feature Engineering: Derived various stock-related features for analysis.
- Visualization: Analyzed trends using matplotlib and seaborn.
-
Daily Returns: Calculated percentage change in daily closing prices.
-
Price Change: Difference in closing prices between consecutive days.
-
5-Day Moving Average: Average closing price over a rolling 5-day window.
-
High-Low Spread: Difference between daily high and low prices.
-
Volatility: Standard deviation of daily returns over a 20-day rolling window.
-
10-Day Simple Moving Average (SMA): Average closing price over a rolling 10-day window.
-
10-Day Exponential Moving Average (EMA): Weighted average of closing prices over 10 days, giving more weight to recent days.
-
Lagged Features:
- Lagged Closing Price: Previous day's closing price.
- Lagged Returns: Previous day's returns.
-
Temporal Features:
- Day of the Week: Weekday (0=Monday, ..., 6=Sunday).
- Month: Month of the year.
- Year: Extracted from the
Date.
-
Cumulative Returns: Total compounded return over the period.
-
Scaled Volume: Daily trading volume scaled for visualization (in millions).
-
Daily Closing Price with Moving Averages
- Plot: Line plot showing daily returns and 5-Day and 10-Day moving averages.
- Inference: The upward trend in the stock price is evident from the rising moving averages. The 5-day moving average crossing above the 10-day moving average suggests potential bullish momentum.
-
Daily Returns and Volatility
- Plot: This plot shows daily percentage returns alongside their rolling volatility.
- Inference: The plot shows the daily returns and volatility of a stock. The volatility fluctuates over time, with periods of higher and lower volatility. The daily returns exhibit significant variation, with both positive and negative returns. This suggests a volatile stock with potential for both going long and short.
-
Daily Returns and Cummulative Returns
- Plot: This visualization combines daily returns with cumulative returns to show the stock's overall growth trajectory.
- Inference: The plot shows the daily returns and cumulative returns of a stock. The daily returns fluctuate significantly, indicating high volatility. The cumulative returns show an overall upward trend, suggesting positive performance over the period.
-
Moving average and Daily Price Change
- Plot: This plot compares the stock's moving average (5-day and 10-day) with daily price changes to reveal how smoothed trends align with short-term price fluctuations.
- Inference: The plot shows the closing price of a stock along with its 5-day and 10-day moving averages and daily price change. The stock price shows an upward trend, with the moving averages confirming the overall direction. The daily price change indicates significant fluctuations, suggesting a high-risk stock.
- Daily Returns: Highlighted the variability in stock price movements.
- Volatility: Showed periods of high/low market activity.
- Moving Averages: Demonstrated short-term trends and price smoothness.
- Temporal Features: Identified trends based on the day of the week and month.
- Cumulative Returns: Illustrated the growth trajectory of the stock.
- Heatmap: Showed strong correlations between price features (e.g., Adj Close vs Close).
- Focused only on NVIDIA stock; results may not generalize to other securities.
- Temporal scope limited to 1 year.
- Does not include macroeconomic factors or market-wide trends.
- Expand analysis to multiple stocks and perform comparative analysis.
- Build predictive models using the engineered features:
- Predict future prices using regression models.
- Classify price movements using machine learning classifiers.
- Integrate sentiment analysis using news data.
- Use advanced techniques like GARCH for volatility modeling.
This project successfully performed a detailed feature engineering and EDA on NVIDIA's stock data. The engineered features provide a solid foundation for further analysis and predictive modeling. Insights into stock price trends, volatility, and trading activity are visually captured, offering valuable perspectives for trading strategies.





