Skip to content

Mmadrb/femelli-monte-carlo-simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monte Carlo Simulation for National Iranian Copper Industries Company (NICICO) - فملی

Project Overview

This project implements a Monte Carlo simulation using the Geometric Brownian Motion (GBM) model to forecast future stock prices and assess potential risks and returns for the National Iranian Copper Industries Company (NICICO). The simulation provides a probabilistic outlook on NICICO's stock performance over a specified future period, offering insights into its price distribution, key statistical metrics, and risk measures.

Features

  • Historical Data Acquisition: Fetches historical stock price data using yfinance (currently configured for AAPL, but intended for NICICO).
  • Parameter Estimation: Calculates daily and annualized log returns, drift (arithmetic and log), and volatility from historical data.
  • Geometric Brownian Motion (GBM): Models stock price movements based on GBM, a widely used model for financial assets.
  • Antithetic Variates: Enhances the efficiency and reduces the variance of the Monte Carlo simulation by pairing each random path with its antithetic counterpart.
  • Comprehensive Statistical Analysis: Provides detailed statistical insights into simulated final prices, including mean, median, standard deviation, skewness, kurtosis, and various percentiles.
  • Risk Metrics: Calculates Value at Risk (VaR), Conditional Value at Risk (CVaR), and average/worst-case maximum drawdowns.
  • Probability Analysis: Estimates probabilities of profit, loss, and specific gain/loss thresholds.
  • Sharpe Ratio Calculation: Assesses the risk-adjusted return of the simulated paths.
  • Visualizations: Generates informative charts, including simulated price paths, final price distribution (highlighting profit/loss), return distribution, and a fan chart illustrating confidence intervals over time.
  • Scenario Table: Presents a clear summary of potential price and return scenarios at different percentile levels.

Methodology

The simulation is based on the Geometric Brownian Motion (GBM) model, which assumes that stock prices follow a random walk with a constant drift and volatility. The formula for GBM is:

dS = μS dt + σS dW

Where:

  • dS is the change in stock price.
  • S is the current stock price.
  • μ (mu) is the annualized arithmetic drift (expected return).
  • σ (sigma) is the annualized volatility.
  • dt is a small-time increment.
  • dW is a Wiener process (random shock).

The simulation estimates the drift and volatility parameters from the historical daily log returns of the stock. To improve the accuracy and convergence of the Monte Carlo simulation, Antithetic Variates are employed. This technique involves generating pairs of random numbers (Z and -Z) for the Wiener process, ensuring that for every simulated path, a mirrored path is also considered. This significantly reduces the variance of the simulation results.

Data Source

The simulation now uses historical stock data provided in FEMELLI.csv. This CSV file contains historical price data for NICICO (فملی) from the Tehran Stock Exchange (TSE). Users can replace this file with updated data or data for other tickers, ensuring the format matches the expected columns (Date and Close price).

Installation

To run this simulation, you need Python 3.x and the following libraries:

pip install numpy matplotlib pandas

Usage

  1. Clone the repository:
    git clone <repository_url>
    cd nicico-monte-carlo
  2. Update the ticker: Open monte_carlo.py and change the ticker variable from AAPL to MSMI1 (or the appropriate ticker for NICICO on your data source).
  3. Run the simulation:
    python monte_carlo.py

Output

The script will print statistical analysis to the console and generate a plot named monte_carlo_AAPL.png (which will be renamed to monte_carlo_NICICO.png after updating the ticker) showing the simulated price paths, final price distribution, return distribution, and confidence intervals.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Hashtags

#MonteCarloSimulation #FinancialModeling #StockMarket #NICICO #فملی #TehranStockExchange #Python #QuantitativeFinance

Disclaimer

This simulation is for educational and illustrative purposes only and should not be considered investment advice. The Geometric Brownian Motion model relies on certain assumptions (log-normal returns, constant volatility, no jumps, no regime changes) that may not hold true in real-world market conditions. Past performance is not indicative of future results.

References

[1] Morningstar. "Iran National Copper Industries Co (MSMI1)." Morningstar.com, https://www.morningstar.com/stocks/xteh/msmi1/quote.

About

Monte Carlo simulation for FEMELLI (Foulad Mobarakeh Esfahan Steel Company) on the Tehran Stock Exchange (TSE). This project provides tools and models for simulating market scenarios, assessing risk, and forecasting outcomes for investment strategies involving FEMELLI stocks.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages