Composable financial contracts with Monte Carlo valuation
Project description
Monte Carlo Contracts
Composable financial contracts with Monte Carlo valuation. This module employs ideas from How to Write a Financial Contract by S. L. Peyton Jones and J-M. Eber. However, the implementation is not based on functional programming but rather using an object oriented approach. Also, this implementation is tailored towards Monte Carlo based cashflow generation whereas the paper favours more general methods.
Features
- Composition of financial contracts using elementary contracts
Zero
,One
,Give
,Scale
,And
,When
,Cond
,Anytime
andUntil
- Boolean and real valued observables (stochastic processes) to be referenced by contracts
- Cashflow generation for composed contracts given simulation models on fixed dategrids
Examples
Install
You can install monte-carlo-contracts
using pip
with
pip3 install monte-carlo-contracts
or you can simply download mcc.py
and then run it using python3
with
python3 mcc.py
History
See HISTORY.md.
Credits
Main developer is luphord luphord@protonmail.com. cookiecutter-pyscript is used as project template.
History
0.7.0 (2022-03-13)
- BREAKING CHANGE:
ObservableFloat.simulate
andObservableBool.simulate
now accept aDateIndex
first_observation_idx
as first argument,Contract
classes will passacquisition_idx
; this allows observations to depend on the time of entering a contract, e.g. "maximum spot since acquisition" - BREAKING CHANGE:
FixedAfter
fixes composed observable after (including)first_observation_idx
, not from the beginning - Add operator overloading for
Contract
classes, i.e. you can now doOne("USD") - One("EUR") | 1.2 * One("GBP")
instead ofOr(And(One("USD"), Give(One("EUR"))), Scale(1.2, One("GBP")))
Maximum
andMinimum
observables to observe the larger and smaller value of two observables at the same time on the same pathRunningMax
andRunningMin
observables to observe running extreme values fromfirst_observation_idx
onwards- Support Python 3.10
- Make use of type annotations added to numpy
0.6.0 (2022-03-04)
- BREAKING CHANGE: Make
SimpleCashflows
apandas.DataFrame
- Run notebooks in automated tests using nbval
- Migrate from travis-ci to GitHub Actions
- Explicitly support Python 3.8 and 3.9
- Move history to HISTORY.md
0.5.0 (2020-11-08)
- BREAKING CHANGE: Add
simulated_rates
toModel
(included in constructor); pass an empty dict forsimulated_rates
to adapt your code - BREAKING CHANGE:
BrownianMotion
andGeometricBrownianMotion
generalized to dynamic mean/drift; passmu_t = lambda t: mu * t
to adapt your code LinearRate
observable supported byTermStructureModel
- First steps towards term structure models
FixedAfter
observable to keep an observable fixed after a condition is true- Observables support arithmetic operations (binary
+
,-
,*
,/
,**
and unary-
) with other observables as well as constants (also right operators work) - Working with Observables example notebook
0.4.0 (2020-11-04)
- Discounting (
Model.discount
) - Evaluation (
Model.evaluate
) - String representations for contracts and observables
0.3.0 (2020-10-23)
- Simulation of basic contract
Until
- Currency conversion of
IndexedCashflows
Or
contract supports multiple currenciesObservableFloat
supports<
,<=
,>
and>=
operators withfloat
or otherObservableFloat
instancesObservableBool
supports~
,&
and|
operators for combined conditions- Equity Options and FX Options examples
0.2.0 (2020-10-11)
- Simulation of basic contracts
Zero
,One
,Give
,Scale
,And
,When
andCond
- Partial simulation of
Or
contract - Float observables
Stock
andFX
- Boolean observables
At
SimulatedCashflows
and model-boundIndexedCashflows
to represent cashflows- Basic
Model
allowing the generation of cashflows for the contracts above
0.1.0 (2020-09-22)
- Created using cookiecutter-pyscript
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file monte-carlo-contracts-0.7.0.tar.gz
.
File metadata
- Download URL: monte-carlo-contracts-0.7.0.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/28.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.51.0 importlib-metadata/4.11.2 keyring/21.4.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0a6728623ca18ec545d3728fae8be14626c4d7aae0566894dacfa7200678226 |
|
MD5 | fd2fcbe2bd007eafdd6410d9a7a6d23d |
|
BLAKE2b-256 | 61ecced529d202b228ca9d40dc18c30530d6cec0f44fa389758f672ca44ca12d |
File details
Details for the file monte_carlo_contracts-0.7.0-py2.py3-none-any.whl
.
File metadata
- Download URL: monte_carlo_contracts-0.7.0-py2.py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/28.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.51.0 importlib-metadata/4.11.2 keyring/21.4.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70969c7607e9574d6e0525271315eae1d34f1b717a67e9da2c3fc82eae7d32e2 |
|
MD5 | 04a4a3feeb5dba8b39211852f2e874b8 |
|
BLAKE2b-256 | 2393164e2ee8b9723f0f3c02aba2a18012747e53a63bf8eab2e5005bb6071348 |