Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.3%) to scientific vocabulary
Keywords
actuarial
actuary
cache
finance
memoization
modeling
monte-carlo
python
quantitative-finance
recursion
risk-management
time-series
Last synced: 6 months ago
·
JSON representation
Repository
Use Python like a spreadsheet!
Basic Info
- Host: GitHub
- Owner: fumitoh
- License: lgpl-3.0
- Language: Python
- Default Branch: main
- Homepage: https://modelx.io
- Size: 4.18 MB
Statistics
- Stars: 108
- Watchers: 16
- Forks: 22
- Open Issues: 29
- Releases: 11
Topics
actuarial
actuary
cache
finance
memoization
modeling
monte-carlo
python
quantitative-finance
recursion
risk-management
time-series
Created over 8 years ago
· Last pushed 6 months ago
Metadata Files
Readme
Contributing
License
README.rst
modelx
======
*Use Python like a spreadsheet!*
.. image:: https://github.com/fumitoh/modelx/actions/workflows/python-package.yml/badge.svg
:target: https://github.com/fumitoh/modelx/actions/workflows/python-package.yml
.. image:: https://img.shields.io/pypi/pyversions/modelx
:target: https://pypi.org/project/modelx/
.. image:: https://img.shields.io/pypi/v/modelx
:target: https://pypi.org/project/modelx/
.. image:: https://img.shields.io/pypi/l/modelx
:target: https://github.com/fumitoh/modelx/blob/master/LICENSE.LESSER.txt
.. Overview Begin
What is modelx?
---------------
**modelx** is a numerical computing tool that enables you to
use Python like a spreadsheet by quickly defining cached functions.
modelx is best suited for implementing mathematical models expressed
in a large system of recursive formulas,
in such fields as actuarial science, quantitative finance and risk management.
Feature highlights
------------------
**modelx** enables you to interactively
develop, run and debug complex models in smart ways.
modelx allows you to:
- Define cached functions as *Cells* objects by writing Python functions
- Quickly build object-oriented models, utilizing prototype-based inheritance and composition
- Quickly parameterize a set of formulas and get results for different parameters
- Trace formula dependency
- Import and use any Python modules, such as `Numpy`_, `pandas`_, `SciPy`_, `scikit-learn`_, etc..
- See formula traceback upon error and inspect local variables
- Save models to text files and version-control with `Git`_
- Save data such as pandas DataFrames in Excel or CSV files within models
- Auto-document saved models by Python documentation generators, such as `Sphinx`_
- Use Spyder with a plugin for modelx (spyder-modelx) to interface with modelx through GUI
.. _Numpy: https://numpy.org/
.. _pandas: https://pandas.pydata.org/
.. _SciPy: https://scipy.org/
.. _scikit-learn: https://scikit-learn.org/
.. _Git: https://git-scm.com/
.. _Sphinx: https://www.sphinx-doc.org
modelx sites
-------------
========================== ===============================================
Home page https://modelx.io
Blog https://modelx.io/allposts
Documentation site https://docs.modelx.io
Development https://github.com/fumitoh/modelx
Discussion Forum https://github.com/fumitoh/modelx/discussions
modelx on PyPI https://pypi.org/project/modelx/
========================== ===============================================
Who is modelx for?
------------------
**modelx** is designed to be domain agnostic,
so it's useful for anyone in any field.
Especially, modelx is suited for modeling in such fields such as:
- Quantitative finance
- Risk management
- Actuarial science
**lifelib** (https://lifelib.io) is a library of actuarial and
financial models that are built on top of modelx.
How modelx works
----------------
Below is an example showing how to build a simple model using modelx.
The model performs a Monte Carlo simulation to generate 10,000
stochastic paths of a stock price that follow a geometric Brownian motion
and to price an European call option on the stock.
.. code-block:: python
import modelx as mx
import numpy as np
model = mx.new_model() # Create a new Model named "Model1"
space = model.new_space("MonteCarlo") # Create a UserSpace named "MonteCralo"
# Define names in MonteCarlo
space.np = np
space.M = 10000 # Number of scenarios
space.T = 3 # Time to maturity in years
space.N = 36 # Number of time steps
space.S0 = 100 # S(0): Stock price at t=0
space.r = 0.05 # Risk Free Rate
space.sigma = 0.2 # Volatility
space.K = 110 # Option Strike
# Define Cells objects in MonteCarlo from function definitions
@mx.defcells
def std_norm_rand():
gen = np.random.default_rng(1234)
return gen.standard_normal(size=(N, M))
@mx.defcells
def stock(i):
"""Stock price at time t_i"""
dt = T/N; t = dt * i
if i == 0:
return np.full(shape=M, fill_value=S0)
else:
epsilon = std_norm_rand()[i-1]
return stock(i-1) * np.exp((r - 0.5 * sigma**2) * dt + sigma * epsilon * dt**0.5)
@mx.defcells
def call_opt():
"""Call option price by Monte Carlo"""
return np.average(np.maximum(stock(N) - K, 0)) * np.exp(-r*T)
Running the model from IPython is as simple as calling a function:
.. code-block:: pycon
>>> stock(space.N) # Stock price at i=N i.e. t=T
array([ 78.58406132, 59.01504804, 115.148291 , ..., 155.39335662,
74.7907511 , 137.82730703])
>>> call_opt()
16.26919556999345
Changing a parameter is as simple as assigning a value to a name:
.. code-block:: pycon
>>> space.K = 100 # Cache is cleared by this assignment
>>> call_opt() # New option price for the updated strike
20.96156962064
You can even dynamically create multiple copies of *MonteCarlo*
with different combinations of ``r`` and ``sigma``,
by parameterizing *MonteCarlo* with ``r`` and ``sigma``:
.. code-block:: pycon
>>> space.parameters = ("r", "sigma") # Parameterize MonteCarlo with r and sigma
>>> space[0.03, 0.15].call_opt() # Dynamically create a copy of MonteCarlo with r=3% and sigma=15%
14.812014828333284
>>> space[0.06, 0.4].call_opt() # Dynamically create another copy with r=6% and sigma=40%
33.90481014639403
License
-------
Copyright 2017-2024, Fumito Hamamura
modelx is free software; you can redistribute it and/or
modify it under the terms of
`GNU Lesser General Public License v3 (LGPLv3)
`_.
Contributions, productive comments, requests and feedback from the community
are always welcome. Information on modelx development is found at Github
https://github.com/fumitoh/modelx
.. Overview End
Requirements
------------
* Python 3.7+
* NetwrkX 2.0+
* asttokens
* LibCST
* Pandas
* OpenPyXL
Owner
- Name: fumitoh
- Login: fumitoh
- Kind: user
- Location: Tokyo
- Repositories: 3
- Profile: https://github.com/fumitoh
GitHub Events
Total
- Create event: 5
- Release event: 2
- Issues event: 17
- Watch event: 8
- Delete event: 7
- Issue comment event: 12
- Push event: 19
- Pull request event: 8
- Fork event: 2
Last Year
- Create event: 5
- Release event: 2
- Issues event: 17
- Watch event: 8
- Delete event: 7
- Issue comment event: 12
- Push event: 19
- Pull request event: 8
- Fork event: 2
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Fumito Hamamura | f****m@g****m | 1,316 |
| Alexey Baran | a****n@a****m | 3 |
| Matthew Caseres | m****s@o****m | 1 |
Committer Domains (Top 20 + Academic)
athene.bm: 1
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 94
- Total pull requests: 40
- Average time to close issues: 5 months
- Average time to close pull requests: about 5 hours
- Total issue authors: 19
- Total pull request authors: 4
- Average comments per issue: 3.1
- Average comments per pull request: 0.08
- Merged pull requests: 35
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 15
- Pull requests: 8
- Average time to close issues: about 1 month
- Average time to close pull requests: about 10 hours
- Issue authors: 3
- Pull request authors: 3
- Average comments per issue: 0.47
- Average comments per pull request: 0.25
- Merged pull requests: 7
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- fumitoh (40)
- alebaran (18)
- alexeybaran (13)
- AB-Athene (4)
- AADYABAJAJ (3)
- defrule (2)
- mhumpher (2)
- kevinwong15 (1)
- Sheing (1)
- kaustavSen (1)
- HunterPxG (1)
- SunnyHillSpaces (1)
- bakj1979 (1)
- NGKEVEN (1)
- kinshulsharma (1)
Pull Request Authors
- fumitoh (33)
- AB-Athene (4)
- alexeybaran (2)
- MatthewCaseres (1)
Top Labels
Issue Labels
bug (23)
enhancement (14)
feature request (9)
question (6)
performance (3)
compat (3)
refactor (1)
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 796 last-month
- Total docker downloads: 127
-
Total dependent packages: 5
(may contain duplicates) -
Total dependent repositories: 2
(may contain duplicates) - Total versions: 65
- Total maintainers: 1
pypi.org: modelx
Build and run complex models composed of formulas and data
- Homepage: https://github.com/fumitoh/modelx
- Documentation: https://modelx.readthedocs.io/
- License: LGPLv3
-
Latest release: 0.28.1
published 7 months ago
Rankings
Dependent packages count: 2.4%
Docker downloads count: 2.9%
Average: 6.9%
Downloads: 7.1%
Stargazers count: 7.9%
Forks count: 9.6%
Dependent repos count: 11.5%
Maintainers (1)
Last synced:
6 months ago
conda-forge.org: modelx
- Homepage: https://github.com/fumitoh/modelx
- License: LGPL-3.0-only
-
Latest release: 0.21.0
published over 3 years ago
Rankings
Dependent packages count: 19.5%
Average: 32.0%
Dependent repos count: 34.0%
Stargazers count: 35.6%
Forks count: 39.0%
Last synced:
6 months ago
Dependencies
requirements-doc.txt
pypi
- networkx <2.8
- openpyxl *
- pandas *
- pydata_sphinx_theme *
- sphinxcontrib-blockdiag *
requirements-travis.txt
pypi
- asttokens *
- networkx ==
- numpy >=1.16.5
- openpyxl *
- pandas *
- psutil *
- pytest-benchmark *
setup.py
pypi
- asttokens *
- networkx >=2.0
.github/workflows/python-package.yml
actions
- actions/checkout v2 composite
- actions/setup-python v2 composite
.github/workflows/python-publish.yml
actions
- actions/checkout v3 composite
- actions/setup-python v3 composite
- pypa/gh-action-pypi-publish 27b31702a0e7fc50959f5ad993c78deac1bdfc29 composite