Constarium
← Search

Data · dataset · 2024

Moving Average charts for ONGC Stock

Listed in Teesside University Research Data Repository

The provided code performs analysis and visualization of daily returns and moving averages for the historical stock price data of Oil and Natural Gas Corporation (ONGC) from a CSV file.

Description

The analysis is conducted using the pandas library for data manipulation, numpy for numerical computations, and matplotlib.pyplot for generating plots. Loading Data: The code imports the pandas library as pd, numpy as np, and matplotlib.pyplot as plt.

It specifies the file path of the CSV file containing ONGC stock price data. The data is loaded into a DataFrame named df using the read_csv() function from pandas. Extracting Required Columns: The code extracts the required columns from the DataFrame, including 'Open', 'High', 'Low', 'Close', and 'Adj Close' prices, and assigns them to separate variables.

Read the rest (3 more)

Calculating Daily Returns: Daily returns are calculated for each price metric ('Open', 'High', 'Low', 'Close', 'Adj Close') using the pct_change() function, which computes the percentage change between consecutive values. Calculating Moving Averages: Moving averages are computed for each daily return series using the rolling() function with a specified window size. The window size for the moving averages is set to 20 days.

Plotting Daily Returns and Moving Averages: Subplots are created for each price metric ('Open', 'High', 'Low', 'Close', 'Adj Close') along with their corresponding moving averages. Each subplot displays the daily returns and the moving average curve. Titles and legends are added to each subplot for clarity.

Displaying Plots: The plt.tight_layout() function adjusts the spacing between subplots to prevent overlapping. Finally, the plt.show() function is called to display the plots. Overall, the code provides a comprehensive analysis of daily returns and moving averages for ONGC stock prices, allowing for insights into the trend and volatility of the stock over time.

Links

Where it is published

Catalogue records · 1

Topics

Provenance · 1 source records, 12 field assertions
SourceKeyLast seenRaw
Teesside University Research Data Repositoryoai:data.mendeley.com/mh7h4thwp9.110 d agoJSON v1
FieldAssertionExtractorEvidence
access_levelsource · researchdata tees ac ukconnector:researchdata_tees_ac_uk@1.0.0
concepts[field].anzsrc:group:4905mapping · researchdata tees ac ukvocabulary-mapper@1.0.0keywords['Statistics']
concepts[field].local:field:earth-environmentalmapping · researchdata tees ac ukconnector:researchdata_tees_ac_uk@1.0.0
concepts[field].local:field:engineeringmapping · researchdata tees ac ukconnector:researchdata_tees_ac_uk@1.0.0
concepts[field].local:field:humanitiesmapping · researchdata tees ac ukconnector:researchdata_tees_ac_uk@1.0.0
concepts[field].local:field:life-sciencesmapping · researchdata tees ac ukconnector:researchdata_tees_ac_uk@1.0.0
concepts[field].local:field:mathematics-statisticsmapping · researchdata tees ac ukconnector:researchdata_tees_ac_uk@1.0.0
concepts[field].local:field:social-sciencemapping · researchdata tees ac ukconnector:researchdata_tees_ac_uk@1.0.0
descriptionsource · researchdata tees ac ukconnector:researchdata_tees_ac_uk@1.0.0/metadata/dc/description
licensesource · researchdata tees ac ukconnector:researchdata_tees_ac_uk@1.0.0/metadata/dc/rights
publication_datesource · researchdata tees ac ukconnector:researchdata_tees_ac_uk@1.0.0
titlesource · researchdata tees ac ukconnector:researchdata_tees_ac_uk@1.0.0/metadata/dc/title