Drawdown

การเทรดทางการเงินด้วย Python

Chelsea Yang

Data Science Instructor

Drawdown คืออะไร?

Drawdown คือการลดลงจากจุดสูงสุดไปยังจุดต่ำสุดในช่วงเวลาหนึ่งของสินทรัพย์หรือบัญชีซื้อขาย

กราฟ Drawdown

การเทรดทางการเงินด้วย Python

Max drawdown

$\text{Max Drawdown} = (V_p - V_l)/ V_l $

$V_p$: มูลค่าสูงสุดก่อนการลดลงครั้งใหญ่ที่สุด

$V_l$: มูลค่าต่ำสุดก่อนที่จะแตะระดับสูงใหม่

ตัวอย่าง Max Drawdown

Max drawdown

= (มูลค่าจุด A - มูลค่าจุด D)/มูลค่าจุด A = (1700 - 800)/1700 = 53%

การเทรดทางการเงินด้วย Python

ดึงข้อมูล Drawdown จากสถิติ Backtest

resInfo = bt_result.stats

# Get the max drawdown max_drawdown = resInfo.loc['max_drawdown'] print('Maximum drawdown: %.2f'% max_drawdown)
# Get the average drawdown avg_drawdown = resInfo.loc['avg_drawdown'] print('Average drawdown: %.2f'% avg_drawdown)
# Get the average drawdown days avg_drawdown_days = resInfo.loc['avg_drawdown_days'] print('Average drawdown days: %.0f'% avg_drawdown_days)
Maximum drawdown: -0.59
Average drawdown: -0.11
Average drawdown days: 22
การเทรดทางการเงินด้วย Python

Calmar ratio

CALMAR: CALifornia Managed Accounts Report

 

$ Calmar = CAGR / \text{Max Drawdown} $

  • Calmar ratio ยิ่งสูง แสดงว่ากลยุทธ์ให้ผลตอบแทนดีขึ้นเมื่อปรับด้วยความเสี่ยง
  • โดยทั่วไป Calmar ratio ที่สูงกว่า 3 ถือว่าอยู่ในระดับดีเยี่ยม
การเทรดทางการเงินด้วย Python

คำนวณ Calmar ratio ด้วยตัวเอง

resInfo = bt_result.stats
# Get the CAGR
cagr = resInfo.loc['cagr']
# Get the max drawdown
max_drawdown = resInfo.loc['max_drawdown']

# Calculate Calmar ratio mannually calmar_calc = cagr / max_drawdown * (-1) print('Calmar Ratio calculated: %.2f'% calmar_calc)
Calmar Ratio calculated: 4.14
การเทรดทางการเงินด้วย Python

ดึงค่า Calmar ratio จากสถิติ Backtest

resInfo = bt_result.stats

# Get the Calmar ratio
calmar = resInfo.loc['calmar']
print('Calmar Ratio: %.2f'% calmar)
Calmar Ratio: 4.14
การเทรดทางการเงินด้วย Python

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

การเทรดทางการเงินด้วย Python

Preparing Video For Download...