I am attempting to calculate the expected one-day standard deviation of a portfolio in dollars. In other words, I am looking for the following: "I expect my portfolio to move _______ dollars on average each day."
I have historical price data for each asset in my portfolio for the previous 90 days, as well as my current position sizes for each asset. The portfolio includes both long & short positions.
One complicating factor is that not all assets have the same weighting. For example, 1 unit of asset XYZ has a scalar of 100, similar to options. In other words, if XYZ has a price of 3 dollars, owning 1 unit of asset XYZ is equivalent to owning $300 of XYZ.
My python code is below. What I am currently doing is multiplying my positions by their scalars and using this as weights_df. Then, I am calculating the covariance matrix of the assets from the historical prices (with no scaling). However, I am not positive that this is mathematically correct.
prices_df = pd.pivot_table(df, values='VALUE', index=['PUBLISH_DATE'], columns=['Product']).ffill(axis=0) cov_df = returns_df.cov() weights_df = pd.read_excel('posfrombook.xlsx', sheetname='Match') portfolio_weights = np.asarray(weights_df['Position Size']) portfolio_volatility = (np.dot(portfolio_weights.T, np.dot(cov_df, portfolio_weights))) print((portfolio_volatility**.5))
I was expecting a portfolio variance around $2000, yet the number I'm getting with the following method seems to be much too high (10-15x what I expected). Should I be using return data? If so, how do I deal with the short positions, as well as the scaling issues?