Mirai RiskMetrics (MiRiM) is a Shiny app based on the RiskMetrics methodology enhanced to analyze the market risk of a portfolio.
MiRiM is freely available on our Website Gallery and is designed for desktop view.
In the first release, MiRiM was mainly a PoC serving as an example for the application of the J.P.Morgan/Reuters RiskMetrics methodology to a portfolio of commodities to be provided as a
CSV input, where a default portfolio of commodities from LME was initiated at the start of the app. RiskMetrics is a set of tools that enables participants in the financial markets to estimate their exposure to market risk, under what has been called the ‘Value-at-Risk framework’, in portfolios of foreign exchange, fixed income, equity and commodity products.
V.1.1 is a release with extensive changes and comes with the following enhancements:
quantmodis introduced to read share prices from Yahoo Finance
CSVfile of historical closing prices of a given asset is still available
The core methodology and the model parameters were not changed.
In order to operate with the MiRiM application, a user must first select a portfolio of assets in the ‘Input’ page, either from the provided list of Swiss assets on Nasdaq or by uploading a
CSV file of prices with a ‘Date’ column in the specified format.
Once the portfolio is selected move to the ‘Parameters and Model’ page, visualize how the assets’ prices and your overall portfolio perform over time, check its value and composition. By assumption, a portfolio (PF) is composed of 5 shares per asset.
Select the time window to be considered and the other parameters for the RiskMetrics model, e.g. the simulation size (small for this prototype).
Run the simulation to estimate what your worst case loss at each time point would be, e.g. with
The output table contains the results at the last time point.
On the R/Shiny side the main updates are related to the introduction of new packages:
quantmod is the standard tool for supporting quantitative traders in their analysis. Simply using the
getSymbols function we can read prices from sources like Yahoo Finance, Google, MySQL, FRED, and Oanda (our choice is for Yahoo Finance). The package contains also functionalities for drawing static financial plots like candlestick charts and line plots.
To make the plots interactive and dynamic on the Shiny app, we have used dygraphs for R, an interface to the dygraphs
dygraph plots react much faster than
plotly on the Shiny app when the graphs contain many points and
dygraph range selector allows fast zooming on a given time window.
The code below shows how to read a symbol from Yahoo Finance (
quantmod) and how to create a candlestick chart with a range selector (
quantmod::getSymbols("AAPL", src = "yahoo") ##  "AAPL" dat <- AAPL %>% setNames(gsub("AAPL.", "", names(AAPL))) datewindow <- c(tail(as.POSIXct(zoo::index(dat)), 365), max(as.POSIXct(zoo::index(dat)))) dygraphs::dygraph(dat[, 1:4], main = "Apple share price over time") %>% dygraphs::dyCandlestick() %>% dygraphs::dyOptions() %>% dygraphs::dyRangeSelector(height = 40, dateWindow = datewindow)
DT package provides convenient features to make static html tables look nicer.
Check the MiRiM app on our website to see the dynamic graphs, which can’t be displayed on this article, and to play with a portfolio of assets of your choice.
Do you have any suggestion for further improvement? Or if you have questions about the implementation, or about the approach of the RiskMetrics model, do not hesitate to contact us. We will be happy to hear from you and to take into consideration the relevant remarks for follow up releases.