開始使用免費開始

相關性的效果量

資產的波動度大致上定義為價格變動的幅度。在本練習中,你將以每日為單位量測波動度,定義為(最高價 − 最低價)/收盤價。

哪些因素可以解釋 Bitcoin 的波動度?S&P 500 的波動度與其是否密切相關?當價格上漲時,波動度會上升還是下降?換句話說,這些不同因素之間的相關性,其效果量有多大?你將在本練習中計算這兩種效果量。

一個包含 S&P 500 與 Bitcoin 價格的 DataFrame(btc_sp_df)已為你載入,同時也載入了 pandas(作為 pd)、NumPy(作為 np)、Matplotlib(作為 plt),以及 SciPy 中的 stats。

本練習屬於課程

Python 推論基礎

檢視課程

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Compute the volatility of Bitcoin
btc_sp_df['Volatility_BTC'] = ____

# Compute the volatility of the S&P500
btc_sp_df['Volatility_SP500'] = ____

# Compute and print R^2 between the volatility of BTC and SP500
r_volatility, p_value_volatility = ____
print('R^2 between volatility of the assets:', ____)

# Compute and print R^2 between the volatility of BTC and the closing price of BTC
r_closing, p_value_closing = ____
print('R^2 between closing price and volatility of BTC:', ____)
編輯並執行程式碼