我尝试进行投资组合优化,但随后TypeError: minimize_sharpe() missing 1 required positional argument: 'log_returns'
出现:请在下面找到摘录。
import scipy.optimize as optimize
optimal_sharpe=optimize.minimize(minimize_sharpe,
initializer,
method = 'SLSQP',
bounds = bounds,
constraints = constraints)
print(optimal_sharpe)
“minimize_sharpe”的定义自带如下代码
def minimize_sharpe(weights, log_returns):
return -portfolio_stats(weights)['Sharpe']