Skip to content

Commit

Permalink
fixing array definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
fmilthaler committed Jul 30, 2023
1 parent 56329f5 commit f32ebc8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions finquant/monte_carlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ def _random_weights(self) -> Tuple[np.ndarray[float, Any], np.ndarray[float, Any
list of [expected return, volatility, sharpe ratio].
"""
# select random weights for portfolio
weights = np.array(np.random.random(self.num_stocks))
weights = np.array(np.random.random(self.num_stocks), dtype=float)
# rebalance weights
weights = weights / np.sum(weights)
# compute portfolio return and volatility
portfolio_values = annualised_portfolio_quantities(
weights, self.return_means, self.cov_matrix, self.risk_free_rate, self.freq
)
return (weights, np.array(portfolio_values))
return (weights, np.array(portfolio_values, dtype=float))

def _random_portfolios(self) -> Tuple[pd.DataFrame, pd.DataFrame]:
"""Performs a Monte Carlo run and gets a list of random portfolios
Expand Down

0 comments on commit f32ebc8

Please sign in to comment.