Simulating stock market returns using Monte Carlo › 1. Setting Up The Environment

Michael BrenndoerferJuly 19, 20251 min read
Simulating stock market returns using Monte Carlo › 1. Setting Up The EnvironmentOne section · Sections in this article2 / 8 ↓
Reading tools Definitions & inline links

Toggle tooltip visibility. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

First, let's import the essential libraries we'll need for our simulation and visualization:

In[1]:
Code
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

# Modern, clean styling
plt.style.use('default')
plt.rcParams.update({
    'figure.facecolor': 'white',
    'axes.facecolor': 'white',
    'axes.edgecolor': '#CCCCCC',
    'axes.linewidth': 0.8,
    'axes.spines.left': True,
    'axes.spines.bottom': True,
    'axes.spines.top': False,
    'axes.spines.right': False,
    'xtick.bottom': True,
    'xtick.top': False,
    'ytick.left': True,
    'ytick.right': False,
    'axes.grid': True,
    'grid.color': '#E5E5E5',
    'grid.linewidth': 0.5,
    'font.size': 11,
    'axes.titlesize': 14,
    'axes.labelsize': 12,
    'figure.dpi': 100
})