第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

高效前沿不好看

高效前沿不好看

明月笑刀無情 2021-11-16 14:30:27
我正在嘗試?yán)L制一個有效的邊界。下面是我用的?;貓髤?shù)由投資組合的 9 列回報組成。我選擇了 10,000 個投資組合,這就是我的有效邊界的樣子。這不是我們熟悉的通常的邊界形狀。有人可以向我解釋這個問題。def monteCarlo_Simulation(returns):    #returns=returns.drop("Date")    returns=returns/100    stocks=list(returns)    stocks1=list(returns)    stocks1.insert(0,"ret")    stocks1.insert(1,"stdev")    stocks1.insert(2,"sharpe")    print (stocks)    #calculate mean daily return and covariance of daily returns    mean_daily_returns = returns.mean()    #print (mean_daily_returns)    cov_matrix = returns.cov()    #set number of runs of random portfolio weights    num_portfolios = 10000    #set up array to hold results    #We have increased the size of the array to hold the weight values for each stock    results = np.zeros((4+len(stocks)-1,num_portfolios))    for i in range(num_portfolios):        #select random weights for portfolio holdings        weights = np.array(np.random.random(len(stocks)))        #rebalance weights to sum to 1        weights /= np.sum(weights)        #calculate portfolio return and volatility        portfolio_return = np.sum(mean_daily_returns * weights) * 252        portfolio_std_dev = np.sqrt(np.dot(weights.T,np.dot(cov_matrix, weights))) * np.sqrt(252)        #store results in results array        results[0,i] = portfolio_return        results[1,i] = portfolio_std_dev        #store Sharpe Ratio (return / volatility) - risk free rate element excluded for simplicity        results[2,i] = results[0,i] / results[1,i]        #iterate through the weight vector and add data to results array        for j in range(len(weights)):            results[j+3,i] = weights[j]
查看完整描述

2 回答

?
開心每一天1111

TA貢獻1836條經(jīng)驗 獲得超13個贊

很可能不是圖形或代碼搞砸了 - 而是您的輸入。嘗試使用資產(chǎn)。可能是您包含在優(yōu)化算法中的資產(chǎn)高度正相關(guān) - 導(dǎo)致多樣化的影響可以忽略不計。反過來,這會影響您的有效邊界的形狀。


編輯:


如果這不是問題的根源。也許使用以下代碼行重試該程序:


def monteCarlo_Simulation(returns):

    noa = len(tickers)

    random_returns = []

    random_volatility = []


    for i in range (10000):

        weights = np.random.random(noa)

        weights = weights / np.sum(weights)

        random_returns.append(np.sum(returns.mean()*weights)*252)

        random_volatility.append(np.sqrt(np.dot(weights.T, np.dot(returns.cov()*252, weights))))


    random_returns = np.array(random_returns)

    random_volatility = np.array(random_volatility)


    fig_random = plt.figure(figsize = [6,4])

    plt.scatter(random_volatility, random_returns,

                c= random_returns / random_volatility, marker = '.')

    plt.grid(True)

    plt.xlabel('Expected volatility')

    plt.ylabel('Expected return')

    plt.colorbar(label='Sharpe ratio')

    plt.title('Mean Variance Analysis Plot')

    plt.show()


查看完整回答
反對 回復(fù) 2021-11-16
?
楊__羊羊

TA貢獻1943條經(jīng)驗 獲得超7個贊

我遇到了類似的問題,我通過查看 NaN 值解決了這個問題,有些公司的 IPO 很晚,有些是在同一年。因此,您需要收集與您的股票投資組合中最新 IPO 相同的數(shù)據(jù)?;蛘咛蕹谀鷻z索數(shù)據(jù)之日之前未 IPO 的所有股票。


查看完整回答
反對 回復(fù) 2021-11-16
  • 2 回答
  • 0 關(guān)注
  • 233 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號