{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "Value at Risk (VaR) Evaluation",
"data": {
"sequence": {
"start": -0.1,
"stop": 0.1,
"step": 0.001,
"as": "x"
}
},
"transform": [
{
"calculate": "densityNormal(datum.x, 0.001, 0.02)",
"as": "pdf"
},
{
"calculate": "cumulativeNormal(datum.x, 0.001, 0.02)",
"as": "cdf"
}
],
"hconcat": [
{
"width": 300,
"height": 200,
"mark": "area",
"encoding": {
"x": {
"field": "x",
"type": "quantitative",
"title": "Daily Return"
},
"y": {
"field": "pdf",
"type": "quantitative",
"title": "Density"
},
"color": {
"value": "skyblue"
}
},
"title": "Distribution of Daily Returns"
},
{
"width": 300,
"height": 200,
"layer": [
{
"mark": {
"type": "line",
"color": "red"
},
"encoding": {
"x": {
"field": "x",
"type": "quantitative",
"title": "Daily Return"
},
"y": {
"field": "cdf",
"type": "quantitative",
"title": "Cumulative Probability"
}
}
},
{
"mark": {
"type": "rule",
"color": "green"
},
"encoding": {
"x": {
"datum": -0.0328,
"type": "quantitative"
},
"y": {
"datum": 0.05,
"type": "quantitative"
},
"y2": {
"datum": 0
}
}
},
{
"mark": {
"type": "rule",
"color": "green",
"strokeDash": [
4,
4
]
},
"encoding": {
"y": {
"datum": 0.05,
"type": "quantitative"
},
"x": {
"datum": -0.1
},
"x2": {
"datum": -0.0328
}
}
},
{
"mark": {
"type": "text",
"align": "right",
"dx": -5,
"dy": -5
},
"encoding": {
"x": {
"datum": -0.1
},
"y": {
"datum": 0.05
},
"text": {
"value": "5%-tile"
}
}
},
{
"mark": {
"type": "text",
"align": "left",
"dx": 5
},
"encoding": {
"x": {
"datum": -0.0328
},
"y": {
"datum": 0
},
"text": {
"value": "95% VaR"
}
}
}
],
"title": "Cumulative Distribution Function with 95% VaR"
}
],
"config": {
"view": {
"stroke": null
}
}
}