arch.univariate.traffic_light¶
-
arch.univariate.traffic_light(returns: ndarray[tuple[int], dtype[float64]] | Series | list[float], var: ndarray[tuple[int], dtype[float64]] | Series | list[float], p: float =
0.01, window: int =250) TrafficLightResult[source]¶ Basel traffic light zone of the exceptions of VaR.
- Parameters:¶
- returns: ndarray[tuple[int], dtype[float64]] | Series | list[float]¶
Realized returns, a 1-d array of finite numbers with at least
windowobservations.- var: ndarray[tuple[int], dtype[float64]] | Series | list[float]¶
VaR forecasts as positive losses, a 1-d array of finite numbers. See var_exceptions for the sign convention and for how the inputs are aligned.
- p: float =
0.01¶ The probability of an exception that the VaR is designed for, which is the size of the tail, in the interval (0, 0.5]. It is 0.05 for a 95% VaR and 0.01 for a 99% VaR. The default is 0.01, the 99% VaR of the Basel framework.
- window: int =
250¶ The number of the most recent observations that are counted. It must be positive and no larger than the number of observations. The default is 250, about one year of daily data.
- Returns:¶
The zone, the number of exceptions in the window, the cumulative binomial probability of that number of exceptions or fewer, the probability of that number or more (the type 1 error), the number of observations in the window and
p.- Return type:¶
- Raises:¶
TypeError – If
returnsorvarcannot be converted to numbers,pis not a real number orwindowis not an integer.ValueError – If
returnsorvaris not valid, as in var_exceptions,pis not in (0, 0.5],windowis not positive, or there are fewer thanwindowobservations.
See also
kupiec_pofTest of the proportion of exceptions.
Notes
The framework of the Basel Committee on Banking Supervision (1996) [1] counts the exceptions in the last 250 days. If the probability of an exception is
p, the number of exceptions has a binomial distribution, and the cumulative probability \(P(X\leq x)\) of the observed number \(x\) sets the zone. The zone is green if the probability is below 95%, yellow if it is at least 95% and below 99.99%, and red if it is at least 99.99%, since the framework says that the yellow and the red zone begin where the probability equals or exceeds 95% and 99.99%. For 250 observations andp=0.01, green is 0 to 4 exceptions, yellow is 5 to 9 and red is 10 or more, which are the boundaries of Table 2 of the framework. The framework deduces the boundaries for other sample sizes from the binomial distribution in the same way, as this function does.type1_erroris \(P(X\geq x)\), the probability that an accurate model has \(x\) or more exceptions. The two probabilities add up to more than 1 by the probability of exactly \(x\) exceptions.A series with no exception is always green. Its cumulative probability is the probability of the smallest number of exceptions, which is above 95% when
window * pis small, but no exception is never a sign of understated risk.A series with fewer than
windowobservations raises an error rather than being tested with the observations that there are, because the zones of the framework are defined for a sample of the specified size. Setwindowto the number of observations to test a shorter series.References