refactor: Capitalize column names in MonteCarloSimulator to ensure consistent data access
This commit is contained in:
parent
87287574b2
commit
9b3b1f27ac
@ -19,11 +19,14 @@ class MonteCarloSimulator:
|
|||||||
num_simulations (int): Number of simulation paths
|
num_simulations (int): Number of simulation paths
|
||||||
time_horizon (int): Number of days to simulate
|
time_horizon (int): Number of days to simulate
|
||||||
"""
|
"""
|
||||||
self.data = data
|
# Make a copy and standardize column names
|
||||||
|
self.data = data.copy()
|
||||||
|
self.data.columns = [col.capitalize() for col in self.data.columns]
|
||||||
|
|
||||||
self.num_simulations = num_simulations
|
self.num_simulations = num_simulations
|
||||||
self.time_horizon = time_horizon
|
self.time_horizon = time_horizon
|
||||||
self.returns = np.log(data['Close'] / data['Close'].shift(1)).dropna()
|
self.returns = np.log(self.data['Close'] / self.data['Close'].shift(1)).dropna()
|
||||||
self.last_price = data['Close'].iloc[-1]
|
self.last_price = self.data['Close'].iloc[-1]
|
||||||
self.drift = self.returns.mean()
|
self.drift = self.returns.mean()
|
||||||
self.volatility = self.returns.std()
|
self.volatility = self.returns.std()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user