我有这个代码:
from empyrical import max_drawdown
from pandas_datareader import data as pdr
myStartDate = "2017-01-01"
myEndDate = "2017-04-30"
myTicker = "SPY"
myData = pdr.get_data_yahoo(myTicker, myStartDate, myEndDate)
daily_close = myData[['Adj Close']]
returns = daily_close.pct_change()
mdd = max_drawdown(returns)
print("My max drawdown:", mdd)
输出是:
My max drawdown: 0 -0.026101
dtype: float64
我希望输出显示为小数点后 2 位的百分比。例如:
My max drawdown: -2.61%
我该怎么做呢?