对数正常蒙特卡洛

Log Normal Montecarlo

提问人:THEOP TH 提问时间:9/27/2023 更新时间:9/27/2023 访问量:32

问:

我正在尝试使用对数正态分布拟合蒙特卡洛模拟,但我不明白为什么实际波动率(模拟后的波动率)如此之高,它应该对应于预期波动率的最小值。 (蒙特卡洛是模拟一个由2种资产组成的投资组合,这些资产是私人公司 - 这就是我选择季度的原因)。

实际上从这个: expected_volatilities = np.array([0.3, 0.4]) Companie 1 的预期波动率为 0.3 Companie 2 的预期挥发率为 0.4 在 MC 日志法线模拟之后,我有这个巨大的实际体积。 实际挥发率: [ 6.15159602 10.7589778 ]

任何帮助将不胜感激:)

下面是蒙特卡洛函数:

def monte_carlo_simulation_quarterly(expected_returns, expected_volatilities, correlation_matrix, initial_prices, quarters=4, sim_count=1000):
    asset_count = len(initial_prices)
    
    # Convert volatilities to variances
    expected_variances = expected_volatilities ** 2
    
    cholesky_decomp = np.linalg.cholesky(correlation_matrix)
    final_prices = []
    
    for _ in range(sim_count):
        rand_vals = np.random.normal(0, 1, (quarters, asset_count))
        correlated_rand_vals = np.dot(rand_vals, cholesky_decomp.T)

        # Calculate quarterly returns using variance
        quarterly_returns = np.exp((expected_returns - expected_variances / 2) / quarters + 
                                   (np.sqrt(expected_variances) / np.sqrt(quarters)) * correlated_rand_vals)
        
        price = initial_prices * np.prod(quarterly_returns, axis=0)
        final_prices.append(price)
    
    final_prices = np.array(final_prices)
    avg_final_prices = np.mean(final_prices, axis=0)
    actual_returns = (avg_final_prices / initial_prices) - 1
    
    # Calculate the actual variance and then convert to volatility
    actual_variances = np.var(final_prices, axis=0) / np.mean(final_prices, axis=0) * quarters
    actual_volatilities = np.sqrt(actual_variances)
    
    return actual_returns, actual_volatilities

这是使用随机选择的输入的调用

expected_returns = np.array([0.1, 0.12])  # Expected Returns for two assets
expected_volatilities = np.array([0.3, 0.4])  # Expected Volatilities for two assets
correlation_matrix = np.array([[1, 0.5], [0.5, 1]])  # Correlation Matrix
initial_prices = np.array([100, 150])  # Initial Prices for two assets

actual_returns, actual_volatilities = monte_carlo_simulation_quarterly(expected_returns, expected_volatilities, correlation_matrix, initial_prices)

print(f"Actual Returns: {actual_returns}")
print(f"Actual Volatilities: {actual_volatilities}")
Python 蒙特卡洛 量化金融

评论


答: 暂无答案