มาตรวัดความเสี่ยงทางเลือก

การวิเคราะห์พอร์ตโฟลิโอด้วย Python

Charlotte Werger

Data Scientist

ความเสี่ยงด้านลบ

กราฟแสดงความเสี่ยงด้านบวกและด้านลบ

  • มาตรวัดความเสี่ยงที่ดีควรมุ่งเน้นที่การขาดทุนที่อาจเกิดขึ้น กล่าวคือ ความเสี่ยงด้านลบ
การวิเคราะห์พอร์ตโฟลิโอด้วย Python

Sortino ratio

$$

  • คล้ายกับ Sharpe ratio แต่ใช้ค่าเบี่ยงเบนมาตรฐานที่ต่างออกไป
  • $ Sortino \; Ratio = \frac{R_p - R_f}{\sigma_d}$
  • $\sigma_d$ คือค่าเบี่ยงเบนมาตรฐานของผลตอบแทนด้านลบ

$$

การคำนวณความเสี่ยงด้านลบ

การวิเคราะห์พอร์ตโฟลิโอด้วย Python

Sortino ratio ใน Python

# Define risk free rate and target return of 0
rfr = 0
target_return = 0
# Calcualte the daily returns from price data
apple_returns=pd.DataFrame(apple_price.pct_change())
# Select the negative returns only 
negative_returns = apple_returns.loc[apple_returns['AAPL'] < target]
การวิเคราะห์พอร์ตโฟลิโอด้วย Python
# Calculate expected return and std dev of downside returns
expected_return = apple_returns['AAPL'].mean()
down_stdev = negative_returns.std()
# Calculate the sortino ratio
sortino_ratio = (expected_return - rfr)/down_stdev
print(sortino_ratio)
0.07887683763760528
การวิเคราะห์พอร์ตโฟลิโอด้วย Python

Maximum draw-down

  • การสูญเสียเป็นเปอร์เซ็นต์ที่มากที่สุดจากจุดสูงสุดถึงจุดต่ำสุดของตลาด
  • ขึ้นอยู่กับช่วงเวลาที่เลือก
  • ระยะเวลาฟื้นตัว: เวลาที่ใช้ในการกลับมาสู่จุดคุ้มทุน

การ draw-down ของ S&P500 ตามช่วงเวลา

การวิเคราะห์พอร์ตโฟลิโอด้วย Python

Maximum daily draw-down ใน Python

# Calculate the maximum value of returns using rolling().max()
roll_max = apple_price.rolling(min_periods=1,window=250).max()

# Calculate daily draw-down from rolling max daily_drawdown = apple_price/roll_max - 1.0
# Calculate maximum daily draw-down max_daily_drawdown = daily_drawdown.rolling(min_periods=1,window=250).min()
# Plot the results daily_drawdown.plot() max_daily_drawdown.plot() plt.show()
การวิเคราะห์พอร์ตโฟลิโอด้วย Python

Maximum draw-down ของ Apple

กราฟ Maximum draw-down ของราคาหุ้น Apple

การวิเคราะห์พอร์ตโฟลิโอด้วย Python

มาฝึกกันเถอะ!

การวิเคราะห์พอร์ตโฟลิโอด้วย Python

Preparing Video For Download...