How far is the index below its all-time high, and how does
that compare with its earlier falls? See drawdown_episodes() for how
the falls are found.
Now: the last close against the all-time high, the lowest close since that high, the rise the price needs to get back to it, and the earlier falls that went at least as deep as the current one has so far: how many days they took to get back to their high.
The history: the falls of at least min_depth percent, the deepest
first, the share of days that closed that far below the high, and the
days that closed at a new all-time high.
Arguments
- history
Price history of one index from
get_history(), with all of it: the highs are those of the history given.- min_depth
Smallest fall of the history to list, in percent below the high.
Value
NULL when there are fewer than 2 prices, or a list with:
- index, first_date, last_date, min_depth
What was analysed.
- now
dateandcloseof the last day,drawdown_pct,high_dateandhigh_priceof the all-time high,days_since_high, andrise_needed_pctto get back to it. While the price is below the high alsolow_dateandlow_price, the lowest close since the high,deepest_pcthow far that is below it,rankof the current fall among all the falls of the history by that depth, 1 for the deepest, andearlier, the earlier falls at least as deep, as rows ofdrawdown_episodes(). At the high,previousholds the last fall of at leastmin_depthpercent, or no rows.- episodes
The falls of at least
min_depthpercent fromdrawdown_episodes(), with theirrankin front, 1 for the deepest.- series
A row per day:
date,close,high(the all-time high so far) anddrawdown_pct(seedrawdown()).- share_under
Percent of the days that closed at least
min_depthpercent below the high.- new_highs
Days that closed at a new all-time high, the first day of the history left out.
Examples
if (FALSE) { # interactive()
spx <- get_history("S&P 500", as.Date("1950-01-01"))
analysis <- drawdown_analysis(spx)
analysis$now$drawdown_pct
analysis$episodes
drawdown_text(analysis)
}