Skip to content

Commit

Permalink
0.2 release (docker version)
Browse files Browse the repository at this point in the history
  • Loading branch information
open-risk committed Oct 24, 2024
1 parent 802cef8 commit 55925ab
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 22 deletions.
71 changes: 71 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# This file is part of the tailRisk distribution (https://github.com/open-risk/tailRisk).
# Copyright (c) 2022 - 2024 Open Risk (https://www.openriskmanagement.com)+
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

FROM ubuntu:22.04

LABEL description="tailRisk: A library for computing risk measures"
LABEL maintainer="[email protected]"
LABEL version="0.2"
LABEL author="Open Risk <www.openriskmanagement.com>"

EXPOSE 8080

ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV DJANGO_SETTINGS_MODULE controller.settings
ENV DJANGO_ALLOWED_HOSTS localhost 127.0.0.1 [::1]

ENV CC=gcc-12
ENV CXX=gcc-12

# Prepare the environment (gcc, cmake, conan and other Python dependencies)
RUN apt update && apt upgrade -y && apt install python3-pip cmake build-essential -y
RUN apt install g++-12 -y
RUN apt install openssl libssl-dev -y
RUN apt install git -y
RUN apt install gpg wget -y
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
ENV CXX=/usr/bin/g++
ENV CC=/usr/bin/gcc

# Install and configure Conan
RUN pip3 install conan
RUN conan profile detect --force
ENV CONAN_SYSREQUIRES_SUDO 0
ENV CONAN_SYSREQUIRES_MODE enabled

# Copy required files, delete local pre-existing builds
RUN mkdir /tailRisk
COPY ./src/CMakeLists.txt /tailRisk/src/CMakeLists.txt
COPY ./src/conanfile.txt /tailRisk/src/conanfile.txt
COPY ./src/*.cpp /tailRisk/src/
COPY ./src/*.h /tailRisk/src/
COPY ./testing/ /tailRisk/testing

# Remove the build dir (just in case)
RUN rm -rf /tailRisk/src/cmake-build-debug
RUN mkdir /tailRisk/src/cmake-build-debug

# Install C++ dependencies
WORKDIR /tailRisk/src
RUN conan install . --output-folder=cmake-build-debug --build missing -s build_type=Debug

# Build tailRisk
WORKDIR /tailRisk/src/cmake-build-debug
RUN cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Debug
#RUN cmake --build .


# If all went well you now have a running instance of tailRisk in a Docker container
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
A C++ library for the calculation of various tail risk measures

## Documentation

**NB: Documentation still under development.**

* Implemented [Risk Measures](RiskMeasures.md)
* Mathematical Documentation available [here](https://www.openriskmanual.org/wiki/Category:Tail_Risk)
* [User Manual](https://www.openriskmanagement.com/documentation/tailrisk/)
* Mathematical Documentation is available int Open Risk Manual Tail Risk [category](https://www.openriskmanual.org/wiki/Category:Tail_Risk)

## Dependencies

Expand Down
7 changes: 0 additions & 7 deletions RandomVarRepresentations.md

This file was deleted.

7 changes: 0 additions & 7 deletions RiskMeasures.md

This file was deleted.

18 changes: 18 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Testing

### Additional Probability Distributions

* Gamma
* Generalized Inverse Gaussian
* Inverse Gamma
* Negative Binomial
* Pareto
* Stable

## Functionality

* Extreme Value Theory
* Mean Excess Plots / Hill Plots
* Python Bindings


9 changes: 6 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@
set(PROJECT_VENDOR "Open Risk")
set(PROJECT_CONTACT "[email protected]")
set(PROJECT_URL "https://github.com/open-risk/tailRisk")
set(PROJECT_DESCRIPTION "tailRisk is a library for computing tail risk measures")

cmake_minimum_required(VERSION 3.19)
project(tailRisk)
set(TAILRISK_VERSION_MAJOR 0)
set(TAILRISK_VERSION_MINOR 2)
set(TAILRISK_VERSION_PATCH 0)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS -std=c++17)
Expand All @@ -29,8 +33,7 @@ add_definitions("-std=c++17")
set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS_DEBUG)
#set(CONAN_DISABLE_CHECK_COMPILER ON)
set(CMAKE_PREFIX_PATH ../cmake-build-debug)
set(CMAKE_PREFIX_PATH cmake-build-debug)

include_directories(..)
include_directories(.)
Expand All @@ -52,7 +55,7 @@ set(TEST_FILES
../testing/rnd_statistics/test_random_var_lognormal.cpp
../testing/test_histogram.cpp)

find_package(Poco REQUIRED COMPONENTS Foundation Net Util Data)
find_package(Poco REQUIRED COMPONENTS Foundation Net NetSSL Util Data)
find_package(Catch2 REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(statslib REQUIRED)
Expand Down
2 changes: 2 additions & 0 deletions src/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ catch2/3.4.0
[options]
poco*:enable_data_odbc=False
poco*:enable_data_mysql=False
poco*:enable_data_postgresql=False
poco*:enable_mongodb=False
poco*:enable_data_sqlite=False
poco*:enable_redis=False

[generators]
Expand Down
8 changes: 7 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@

int main(int argc, char *argv[]) {

// Example 0
RandomVar X;
std::string filename = "../data/example0.json";
X.ReadFromJSON(filename);
X.Print();

// Example 1
int Grid = 1;
int DataType = 0;
RandomVar D(Grid, DataType);
std::string filename = "../data/example1.json";
filename = "../data/example1.json";
D.ReadFromJSON(filename);
D.Print();
D.Cumulative();
Expand Down
10 changes: 8 additions & 2 deletions src/random_var.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*################################################################################
/**
################################################################################
##
## Copyright (C) 2020-2024 Open Risk (www.openriskmanagement.com)
##
Expand All @@ -16,7 +17,8 @@
## See the License for the specific language governing permissions and
## limitations under the License.
##
################################################################################*/
################################################################################
*/

/**
* File: random_var.cpp
Expand Down Expand Up @@ -380,3 +382,7 @@ void RandomVar::Seed() {
}
}
}

RandomVar::RandomVar() {

}
3 changes: 3 additions & 0 deletions src/random_var.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class RandomVar {
// Type 0 -> Histogram type Storage
// Type 1 -> Sample type Storage

RandomVar();

RandomVar(size_t S, int type) {
if (type == 0) {
m_type = 0;
Expand Down Expand Up @@ -171,6 +173,7 @@ class RandomVar {

void Seed();


private:
// 0 Type: exact representation (discrete probabilities view)
// 1 Type: sampling representation (distribution sampling view)
Expand Down

0 comments on commit 55925ab

Please sign in to comment.