diff --git a/.gitignore b/.gitignore index 77bee78..e0f61e6 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ share/python-wheels/ .installed.cfg *.egg MANIFEST +.idea/ # PyInstaller # Usually these files are written by a python script from a template diff --git a/README.md b/README.md index ba339b7..788ca7f 100644 --- a/README.md +++ b/README.md @@ -14,26 +14,27 @@ Some examples of arbitrage repair are shown as below: ![image](https://user-images.githubusercontent.com/32545513/83334755-9666ad80-a2a0-11ea-9910-34137539517b.png) ->An arbitrage-free normalised call price surface -> ->should satisfy some shape constraints. Assuming smooth surface function ->, ->then these shape constraints are ->- Positivity: ->- Monotonicity: , ->- Convexity: +An arbitrage-free normalised call price surface + +should satisfy some shape constraints. Assuming smooth surface function +, +then these shape constraints are +- Positivity: +- Monotonicity: , +- Convexity: ## Code -### Installation of pre-requisites +### Installation -It is recommended to create a new environment and install pre-requisite -packages. All packages in requirement.txt are compatible with Python 3.8.x. +It is recommended to create a new virtual environment and install from pypi. >``` ->pip install -r requirements.txt +>pip install arbitragerepair >``` +**Requirements:** ```Python >= 3.8``` and ```CVXOPT >= 1.3.0```. + ### Usage While an example can be found in [this jupyter notebook](notebook/example.ipynb), @@ -46,6 +47,10 @@ the usage of this code consists of the following steps. >``` **1.** Normalise strikes and call prices + +The inputs are four 1D ```numpy.array``` objects ```T, K, C, F```, which should be of the same length, representing +time-to-expiries, strike prices, option prices and forward prices. + >``` >normaliser = constraints.Normalise() >normaliser.fit(T, K, C, F) diff --git a/arbitragerepair/__init__.py b/arbitragerepair/__init__.py index e69de29..dbe2fa8 100644 --- a/arbitragerepair/__init__.py +++ b/arbitragerepair/__init__.py @@ -0,0 +1,2 @@ +from .constraints import * +from .repair import * diff --git a/arbitragerepair/repair.py b/arbitragerepair/repair.py index 2f65175..0aaf47c 100644 --- a/arbitragerepair/repair.py +++ b/arbitragerepair/repair.py @@ -141,10 +141,10 @@ def l1ba(mat_A, vec_b, C, spread=None, solver='glpk'): delta0 = 1./len(delta_ask) if delta0 > 1./len(delta_ask) else delta0 delta0 = 1e-8 if delta0 < 1e-8 else delta0 except ValueError: - raise ValueError('Please ensure that the spread input has legal ' - 'format! It should contain two arrays/lists, one ' - 'for bid-reference spread, one for ask-reference ' - 'spread.') + raise ValueError('Please ensure that the spread input has legal ' + 'format! It should contain two arrays/lists, one ' + 'for bid-reference spread, one for ask-reference ' + 'spread.') # Construct required quantities for the LP I = _np.eye(n_quote) diff --git a/requirements.txt b/requirements.txt index c0d0e41..feba0ed 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -cvxopt==1.3.0 -matplotlib==3.2.2 -numpy==1.19.0 -pandas==1.0.5 \ No newline at end of file +cvxopt>=1.3.0 +numpy>=1.19.0 +pandas>=1.0.5 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..0f94f37 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[metadata] +description_file = README.md \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..4223cc5 --- /dev/null +++ b/setup.py @@ -0,0 +1,30 @@ +import os +from setuptools import setup + +here = os.path.realpath(os.path.dirname(__file__)) +with open(os.path.join(here, 'README.md')) as f: + readme = f.read() + +setup( + name='arbitragerepair', + packages=['arbitragerepair'], + description='Model-free algorithms of detecting and repairing spread, butterfly and calendar arbitrages in European option prices.', + long_description=readme, + long_description_content_type="text/markdown", + install_requires=[ + 'cvxopt>=1.3.0', + 'numpy>=1.19.0', + 'pandas>=1.0.5' + ], + python_requies='>=3.8', + url='https://github.com/vicaws/arbitragerepair', + version='1.0.2', + license='MIT', + author='Victor Wang', + author_email='wangsheng.victor@gmail.com', + keywords=['option', 'arbitrage', 'quantitative finance', 'data cleansing', 'asset pricing'], + classifiers=[ + 'Programming Language :: Python :: 3', + 'License :: OSI Approved :: MIT License' + ] +)