Skip to content

Latest commit

 

History

History
10 lines (8 loc) · 345 Bytes

File metadata and controls

10 lines (8 loc) · 345 Bytes
# Convert pandas Dataframe to Numpy and calculate
def negativeSharpeRatio(weights, returns, covariance, rate):
      portfolio_return = np.dot(weights, returns)
      portfolio_std = np.sqrt(np.dot(weights.T, np.dot(covariance, weights)))
      sharpe_ratio = (portfolio_return - rate) / portfolio_std
      return -sharpe_ratio