<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Web based application for operational loss collection and value-at-risk and expected shortfall calculation</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Sergey G. Shorokhov</string-name>
          <email>shorokhov-sg@rudn.ru</email>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Victoria V. Khaptakhanova</string-name>
          <email>vkhaptakhanova@mail.ru</email>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Information Technology Peoples' Friendship University of Russia (RUDN University)</institution>
          <addr-line>6 Miklukho-Maklaya St, Moscow, 117198, Russian Federation</addr-line>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2019</year>
      </pub-date>
      <fpage>141</fpage>
      <lpage>148</lpage>
      <abstract>
        <p>We study some issues of operational risk information system design and implementation in compliance with new requirements of Basel Committee on Banking Supervision and Bank of Russia. To meet regulatory requirements, banks need to create and regularly update an analytical database on operational risk losses extending back for some years. We provide requirements to the form and contents of the information to be registered for operational risk events and losses and list mandatory classifiers for risk event database. The structure of tables in risk event database is presented on entity-relationship diagram. Operational risk information system can be rapidly developed as a distributed system using web-framework Django. Such Django features as MVC (Model-View-Controller) pattern and ORM (Object-Relational Mapping) speed up the development of web-based application for risk event database and allow to avoid manipulating sophisticated SQL expressions. We provide examples of Django classes in Python for model component of Django risk event database application. We also develop and present algorithm for Value-at-Risk and Expected Shortfall calculation using data in operational risk event database. The algorithm can be easily implemented in Python using Django database-abstraction API.</p>
      </abstract>
      <kwd-group>
        <kwd>and phrases</kwd>
        <kwd>operational risk</kwd>
        <kwd>Model-View-Controller</kwd>
        <kwd>Object-Relational Mapping</kwd>
        <kwd>Django framework</kwd>
        <kwd>Value-at-Risk</kwd>
        <kwd>Expected Shortfall</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>Copyright © 2019 for the individual papers by the papers’ authors. Copying permitted for private and
academic purposes. This volume is published and copyrighted by its editors.</p>
      <p>In: K. E. Samouylov, L. A. Sevastianov, D. S. Kulyabov (eds.): Selected Papers of the IX Conference
“Information and Telecommunication Technologies and Mathematical Modeling of High-Tech Systems”,
Moscow, Russia, 19-Apr-2019, published at http://ceur-ws.org</p>
    </sec>
    <sec id="sec-2">
      <title>1. Introduction</title>
      <p>Basically, operational risk is the risk of losses due to unreliability of the internal
management procedures, negligence of employees, failure of information systems or the
impact of external events [1]. Along with market and credit risks, operational risk is
regarded as one of the most material financial risks and credit institutions worldwide
are obliged to establish a risk and capital management system to detect, evaluate,
and aggregate operational risk and other most material risks and assess their capital
adequacy [2, 3].</p>
      <p>In 2017, Basel Committee on Banking Supervision (BCBS) finalized the Basel III
framework [4], updating minimum capital requirements for operational risk and criteria
for identification, collection and treatment of internal loss data. In 2018, Bank of Russia
released draft regulation [5] on the requirements to the operational risk management.</p>
      <p>We study some methodological and practical aspects of operational risk information
system design and implementation and subsequent calculation of operational risk
indicators Value-at-Risk and Expected Shortfall using available data on operational losses
occurred.</p>
      <p>2.</p>
    </sec>
    <sec id="sec-3">
      <title>Operational risk event database structure</title>
      <p>According to [1] each credit institution creates and maintains the analytical database
on losses incurred due to operational risk events (event database). The event database
shall contain information on the amount and type of losses, the dates of event occurrence,
recognition and completion, event circumstances and other relevant information [6].</p>
      <p>According to the requirements for maintaining the event database [5] (ch. 6), the
event database should contain, in particular, the following information:
– unique serial identification number of the event;
– identifier of the group of homogeneous events (if any);
– date and time of event occurrence;
– date and time of event identification;
– date and time of event completion;
– event status;
– business unit, associated with the event;
– detailed description of the event;
– loss event source (cause) codes, including the code of main source (cause);
– loss event type code;
– additional (level 2) loss event type code;
– operational risk type code;
– other banking risk type codes (if any);
– business line (or business process level 1) code;
– business process (level 2) code;
– code of the bank information system used when the event occurred;
– operational risk loss data.</p>
      <p>The following classifiers should be used when recording operational loss events:
– classifier of loss event sources (causes) [5] (clause 2.3);
– classifier of operational risk types [5] (clause 2.3.5);
– classifier of loss event types (level 1) [5] (clause 2.7);
– classifier of loss event types (level 2) [5] (addendum 1);
– classifier of business lines (level 1) [5] (clause 2.10);
– classifier of business lines (level 2) or business processes according to internal
documents of the credit institution or, for instance, [7];
– classifier of direct and indirect operational losses [5] (clause 2.11);
– classifier of business units of the credit institution [5] (clause 6.6);
– classifier of other types of banking risks [5] (clause 6.6);
– classifier of information systems of the credit institution [5] (clause 6.6).</p>
      <p>Thus, the event database should contain the main table with detailed information on
operational risk event and loss and classifiers for the event table fields (Fig. 1).</p>
    </sec>
    <sec id="sec-4">
      <title>3. Implementation of operational risk event database application</title>
      <p>Operational risk event database should embrace all divisions of the bank, including
geographically remote branches, and risk event collection application should be designed
and implemented as a distributed system.</p>
      <p>At present web development is essentially done in Python language [8] and Django
is the core Python framework for creating database-driven websites [9]. Some of the
well-known Django websites include Instagram, Pinterest, Dropbox, Spotify.</p>
      <p>Django framework is an example of Model–View–Controller (MVC) architecture,
ifrst introduced in Smalltalk programming environment [10], which allows developers
to change the visual part and the business logic of an application separately,
without afecting one another [11]. Actually, Django architecture is called sometimes as
Model–View–Template (MVT), because there are three independent layers (Model, View,
and Template) in Django, responsible for managing diferent parts of an application (Fig.
2). Communication between the layers is possible only via an application programming
interface (API).</p>
      <p>Model component is the single source of information about application data in Django.
It contains separate model (Python class) for each table (entity) of the application
database. Django oficially supports four application databases: PostgreSQL, MySQL,
SQLite, and Oracle.</p>
      <p>Model in Django is a special Python class and it holds business logic, properties,
specific methods, and other behavior of manipulated data. Models in Django allow
developers to create, read, update, and delete data in the original database without
using complicated SQL expressions. Django also automatically generates web pages for
maintaining model data on special administrative site of Django application [12].
HTTP request</p>
      <p>URLS
(urls.py)</p>
      <p>View
(views.py)</p>
      <p>HTML
HTTP response</p>
      <p>Forwarding request</p>
      <p>Model
(models.py)</p>
      <p>Data</p>
      <p>Page</p>
      <p>Template
(filenames.html)
class OR_Business_Process2(models.Model):</p>
      <p>OR_business_process2_ID = models.CharField(max_length=2, unique = True,
verbose_name = "Business Process Code")
OR_business_process_ID = models.ForeignKey(OR_Business_Process, on_delete=
models.DO_NOTHING, verbose_name = "Business Line Code")
OR_business_process2_name = models.CharField(max_length=50,</p>
      <p>verbose_name = "Business Process Name")
OR_business_process2_description = models.TextField(max_length=500,
verbose_name = "Business Process Description")
class Meta:
ordering = ["OR_business_process2_ID"]
verbose_name = "Business Process"
verbose_name_plural = "Business Processes"
def __str__(self):
"""String for representing the OR_Business_Process2 object"""
return ’%s) %s’ % (self.OR_business_process2_ID,</p>
      <p>self.OR_business_process2_name)
An example of model for business process (level 2) classifier is given in Fig. 3.</p>
      <p>The view component of Django executes three main tasks: it accepts HTTP requests
from users, applies business logic from Django models, and provides HTTP responses to
users’ requests.</p>
      <p>Django has a powerful template engine and its own markup language with many
tools. Templates in Django are HTML files used to present data.</p>
      <p>Django has built-in object-relational mapping (ORM) that helps developers interact
with databases. ORM is a mechanism that automatically transfers data stored in
application database into objects used in application code [13].</p>
      <p>Django ORM speeds up web application development and helps developers build
working prototypes in reduced time. Developers may not know the details of SQL
implementation for a specific database to manipulate data.</p>
      <p>The Django framework can be used for creating various applications, including client
relationship management (CRM) systems, communication platforms, booking engines,
machine learning systems and many other applications [14, 15].</p>
      <p>Due to advantages of Django architecture operational risk event database application
can be rapidly implemented in Django web framework.</p>
      <p>4.</p>
    </sec>
    <sec id="sec-5">
      <title>Value-at-Risk and Expected Shortfall Calculation</title>
      <p>Operational risk may be measured using various approaches and risk metrics, for
instance, Basel II approaches (basic indicator approach, standardized approach, advanced
measurement approaches), expected loss and unexpected loss, etc [16].</p>
      <p>Value-at-Risk (VaR) and Expected Shortfall (ES) are the most widely used financial
risk metrics [17, 18]. In market risk management Value-at-Risk is the worst loss of asset
portfolio over a given time interval that will not be exceeded with a given confidence
level. Expected Shortfall at a given confidence level  is the expected loss of asset
portfolio in the worst 1 −  percent of losses.</p>
      <p>Value-at-Risk and Expected Shortfall can be calculated for operational risk in a
number of ways [19]. If event database with losses incurred due to operational risk
events is available for certain time period, then the calculation of VaR and ES may be
based on data in risk event database [20].</p>
      <p>Assume that operational risk loss  per day is distributed discretely, i.e. operational
risk loss per day  for the period of  days takes some values 1, 2, ...,  with equal
probability  = 1 , i.e.</p>
      <p>P [ = ] =  =</p>
      <p>,  = 1, .
1</p>
      <p>Suppose for simplicity that  ̸=  ,  ̸=  and day losses  are sorted in ascending
order:</p>
      <p>0 &lt; 1 &lt; 2 &lt; ... &lt; .</p>
      <p>Due to property P [ 6 ] = 1 − P [ &gt; ] the definition of   ( ) takes the form
  ( ) = inf{ ∈ R : P [ 6 ] &gt;  } = inf{ ∈ R : P [ &gt; ] 6 1 −  }.</p>
      <p>If  ∈ [, +1) for some index  between 1 and  (1 6  &lt; ), then</p>
      <p>( ) = inf{ ∈ R : P [ &gt; ] 6 1 −  } = inf{ ∈ R :  &gt; } = .</p>
      <p>If for some  the confidence level  is equal to
then for any  ∈ R inequality
is equivalent to inequality  &gt; , therefore

∑︁
=+1


Algorithm: calculation of operational   and  on a given event database.</p>
    </sec>
    <sec id="sec-6">
      <title>Input:</title>
    </sec>
    <sec id="sec-7">
      <title>Method:</title>
      <p>
        1. start date 1 and end date 2 of time interval [1, 2]
2. event database with operational loss data for time interval [1, 2]
3. confidence level  ∈ (
        <xref ref-type="bibr" rid="ref1">0, 1</xref>
        )
Output: daily operational   and  with confidence level 
day
index starts from 1)
(
        <xref ref-type="bibr" rid="ref1">1</xref>
        ) calculate total number of days in time interval [1, 2]:  = 2− 1+1
(
        <xref ref-type="bibr" rid="ref2">2</xref>
        ) for each day of time interval [1, 2] sum operational losses incurred on that
365
(
        <xref ref-type="bibr" rid="ref3">3</xref>
        ) sort the losses received on previous step in descending order and store the
losses in array  (days with high losses at the beginning of array, array
(4) if (confidence level  is equal to  for some integer  between 1 and  ) {
(5)
(6)
(7) }
(9)
(10)
(11) }
  ( ) =  [ −
      </p>
      <p>1
 ( ) = − 
 + 1]
=1
∑︀−   []
  ( ) =  [ − ]
 ( ) = 1− 1
(8) else if (  &lt;  &lt;
+1 for some integer  between 1 and  − 1) {</p>
      <p>=1
︁( 1 ∑︀− − 1  [] +
︁( +1
 − 
︁)  [ − ]
︁)</p>
      <p>If for some  the confidence level  satisfies the double inequality
then for any  ∈ [, +1)
hence P [ &gt; ] &lt; 1 −  only when  &gt; +1 and


&lt;  &lt;
 + 1

percent of losses and calculate average value for these losses.</p>
      <p>For  =  , 1 6  &lt; ,  ∈ N we have 1 −  = −  , so worst 1 −  percent of losses
are the last  −  losses +1, ...,  and
 ( ) = E [ |  &gt; ] =
∑︀</p>
      <p>=+1  
∑︀
=+1 
=
1

∑︁ .
 −  =+1</p>
      <p>For  &lt;  &lt; +1 , 1 6  &lt; ,  ∈ N we have 1 −  = ~ + − − 1 for some ~ ∈ (︀ 0, 1 )︀ ,
~ = 1 −  − −  , so worst 1 −  percent of losses are the last  −  − 1 losses +2, ..., 
and a part of the loss +1 and
 ( ) =
So under made assumptions</p>
      <p>+1 ,
where 1 6  &lt; ,  ∈ N.</p>
      <p>From received formulae for   ( ) and  ( ) we receive the following algorithm
(Fig. 4) for the calculation of Value-at-Risk and Expected Shortfall under made
assumptions.</p>
      <p>Algorithm on Fig. 4 can be easily implemented in Python, using methods aggregate
and annotate of Django database API.</p>
      <p>5.</p>
    </sec>
    <sec id="sec-8">
      <title>Conclusion</title>
      <p>We presented some design and implementation considerations for a web based
application for operational loss collection. Using Django web framework significantly speeds
up and facilitates application development. Algorithm for calculation of operational
Value-at-Risk and Expected Shortfall using data in risk event database is also developed.</p>
    </sec>
    <sec id="sec-9">
      <title>Acknowledgments</title>
      <p>The publication has been prepared with the support of the «RUDN University
Program 5-100» (risk event database design and implementation). The reported study
was funded by RFBR, grant No 16-08-00558 (VaR and ES algorithm development).
4. BCBS, Basel III: Finalising post-crisis reforms, Publication, Basel Committee on
Banking Supervision, Basel (dec 2017).</p>
      <p>URL http://www.bis.org/bcbs/publ/d424.pdf
5. Bank of Russia, On the requirements to the operational risk management system of
credit institution and banking group (draft regulation), Draft regulation, Moscow
(September 2018).</p>
      <p>
        URL http://www.cbr.ru/StaticHtml/File/41186/180918-41_1.pdf
6. L. Wei, J. Li, X. Zhu, Operational loss data collection: A Literature Review, Annals
of Data Science 5 (
        <xref ref-type="bibr" rid="ref3">3</xref>
        ) (2018) 313–337. doi:10.1007/s40745-018-0139-2.
7. BCBS, The Quantitative Impact Study for Operational Risk: Overview of Individual
Loss Data and Lessons Learned, Working paper, Basel Committee on Banking
Supervision, Basel (jan 2002).
      </p>
      <p>URL https://www.bis.org/bcbs/qis/qisopriskresponse.pdf
8. D. Beazley, G. Van Rossum, Python: Essential Reference, New Riders Publishing,
1999.
9. A. Holovaty, J. Kaplan-Moss, The Definitive Guide to Django, Apress, 2009. doi:
10.1007/978-1-4302-1937-8.
10. A. Mével, T. Guéguen, M. Wolczko, Smalltalk-80, Macmillan Education UK, 1987.</p>
      <p>
        doi:10.1007/978-1-349-09653-4.
11. G. E. Krasner, S. T. Pope, A cookbook for using the model-view controller user
interface paradigm in smalltalk-80, Journal of Object-Oriented Programming 1 (
        <xref ref-type="bibr" rid="ref3">3</xref>
        )
(1988) 26–49.
      </p>
      <p>URL http://dl.acm.org/citation.cfm?id=50757.50759
12. M. Alchin, Pro Django, Apress, 2013. doi:10.1007/978-1-4302-5810-0.
13. M. Lorenz., G. Hesse., J. Rudolph., Object-relational mapping revised - a guideline
review and consolidation, in: Proceedings of the 11th International Joint Conference
on Software Technologies - Volume 1: ICSOFT-EA, (ICSOFT 2016), INSTICC,
SciTePress, 2016, pp. 157–168. doi:10.5220/0005974201570168.
14. K. Cao, F. Wang, J. G. Liu, Study and implementation of pm2.5 data download
service based on python, Applied Mechanics and Materials 411-414 (2013) 555–558.
doi:10.4028/www.scientific.net/amm.411-414.555.
15. Z. Li, Design and implementation of the software testing management system based
on django, Applied Mechanics and Materials 525 (2014) 707–710. doi:10.4028/www.
scientific.net/amm.525.707.
16. R. Coleman, A VaR too far? The pricing of operational risk, Journal of Financial
Transformation 28 (2010) 123–129.</p>
      <p>URL https://EconPapers.repec.org/RePEc:ris:jofitr:1420
17. P. Jorion, Value at Risk: The New Benchmark for Managing Financial Risk, 3rd</p>
      <p>
        Edition, Mcgraw-Hill Professional, 2006.
18. C. Acerbi, D. Tasche, Expected shortfall: A Natural Coherent Alternative to Value
at Risk, Economic Notes 31 (
        <xref ref-type="bibr" rid="ref2">2</xref>
        ) (2002) 379–388. doi:10.1111/1468-0300.00091.
19. A. S. Chernobai, S. T. Rachev, F. J. Fabozzi, Operational Risk: A Guide to Basel
II Capital Requirements, Models, and Analysis, John Wiley &amp; Sons, Inc., 2012.
doi:10.1002/9781119201922.
20. J. Esterhuysen, P. Styger, G. W. V. Vuuren, Calculating operational value-at-risk
(opvar) in a retail bank, South African Journal of Economic and Management
Sciences 11 (
        <xref ref-type="bibr" rid="ref1">1</xref>
        ) (2012) 1–16. doi:10.4102/sajems.v11i1.374.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1. Bank of Russia,
          <article-title>On the requirements to the risk and capital management system of credit institution and banking group (ordinance no. 3624-</article-title>
          u of april 15,
          <year>2015</year>
          ),
          <source>Vestnik Banka Rossii (51)</source>
          (
          <year>2015</year>
          )
          <fpage>15</fpage>
          -
          <lpage>35</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>A.</given-names>
            <surname>Aloqab</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Alobaidi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Raweh</surname>
          </string-name>
          ,
          <article-title>Operational risk management in financial institutions: An Overview</article-title>
          ,
          <source>Business and Economic Research</source>
          <volume>8</volume>
          (
          <issue>2</issue>
          ) (
          <year>2018</year>
          )
          <article-title>11</article-title>
          . doi:
          <volume>10</volume>
          .5296/ber.v8i2.
          <fpage>12681</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>S.</given-names>
            <surname>Pakhchanyan</surname>
          </string-name>
          ,
          <article-title>Operational risk management in financial institutions: A Literature Review</article-title>
          ,
          <source>International Journal of Financial Studies</source>
          <volume>4</volume>
          (
          <issue>4</issue>
          ) (
          <year>2016</year>
          )
          <article-title>20</article-title>
          . doi:
          <volume>10</volume>
          .3390/ ijfs4040020.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>