Skip to content

Commit

Permalink
Merge 98a4e6c into 20a54a7
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbywater committed Apr 10, 2017
2 parents 20a54a7 + 98a4e6c commit be8e3b7
Show file tree
Hide file tree
Showing 95 changed files with 5,414 additions and 1,507 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
source = quantdsl
omit =
*/python?.?/*
*/test_?.py
*/tests/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.README.py
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
36 changes: 18 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@ language: python

sudo: false

matrix:
include:
- python: 2.7
env: NUMPY=1.9 SCIPY=0.15
- python: 3.4
env: NUMPY=1.9 SCIPY=0.15
services:
- rabbitmq

python:
- "2.7"
- "3.3"
- "3.4"

before_install:
# - wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
- travis_retry wget http://repo.continuum.io/miniconda/Miniconda-3.8.3-Linux-x86_64.sh -O miniconda.sh
- chmod +x miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH=/home/travis/miniconda/bin:$PATH
- conda update --yes conda
- travis_retry wget http://repo.continuum.io/miniconda/Miniconda-3.8.3-Linux-x86_64.sh -O miniconda.sh
- chmod +x miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH=/home/travis/miniconda/bin:$PATH
- conda update --yes conda
- conda install --yes atlas numpy scipy matplotlib

install:
- conda install --yes numpy=$NUMPY scipy=$SCIPY matplotlib pip
- conda install --yes -c dan_blanchard python-coveralls
- pip install setuptools
- pip install .
- pip install -U pip
- pip install -r requirements.txt
- pip install python-coveralls

script:
- coverage run --source quantdsl -m unittest discover quantdsl
- coverage run -m unittest discover quantdsl -v

after_success:
- coveralls --config_file .coveragerc
- coveralls
130 changes: 130 additions & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source

.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest

help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"

clean:
-rm -rf $(BUILDDIR)/*

html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."

singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."

pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."

json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."

htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."

qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Quant.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Quant.qhc"

devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/Quant"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Quant"
@echo "# devhelp"

epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."

latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."

latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
make -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."

man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."

changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."

linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."

doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
137 changes: 137 additions & 0 deletions doc/quant-domain-analysis.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
Domain Analysis for Quantative Analysis
=======================================

Motivation for analysis project
-------------------------------

Generate analysis of support provided by quantative analysis.

The following process are supported by quantative analysis:

1. Selling derivatives contracts.
2. Buying derivatives contracts.
3. Statistical arbitrage.


Scope of the Work
-----------------

"Productive business activities."

Event: Somebody wants to trade a derivative contract.
Response: Calculate a price for a derivative contract.
Outcome: Price of the derivative contract.

Event: Somebody signs a derivative contract.
Response: Book the derivative.
Outcome: New derivative contract registered on the book.

Event: New derivative contract on the book.
Response: Set initial hedges.
Outcome: Derivative contracts are hedged correctly.

Event: At frequency of book monitoring.
Response: Send request to monitor the book.
Outcome: Request to monitor the book.

Event: Receive request to monitor value of book.
Response: Calculate the value and greeks of the book.
Outcome: Send alert about value of the book.

Event: Receive alert about value of book.
Response: Send request to flatten the book.
Outcome: Request to flatten the book.

Event: At frequency of re-hedging.
Response: Send request to flatten the book.
Outcome: Request to flatten the book.

Event: Derivative contract is cancelled.
Response: Take derivative contract off the book.
Outcome: Derivative not registered on the book.

Event: Derivative contract expires.
Response: Take derivative contract off the book.
Outcome: Derivative not registered on the book.

Event: Old derivative contract removed from the book.
Response: Send request to flatten the book.
Outcome: Request to flatten the book.

Event: Receive request to flatten book.
Response: Make trades according to value and greeks of the book.
Outcome: Book is (sufficiently) flat.


Scope of the System
-------------------

"Interactions with a software service."

Calculate the price of a derivatives contract
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Product Use Case: Create software model for a derivatives contract.
Requirement: The system shall support creating software models for a forward contract.
Requirement: The system shall support creating software models for a european option (on forward contract).
Requirement: The system shall support creating software models for a american option (on forward contract).
Requirement: The system shall support creating software models for a swing option (on set of forward contracts).
Requirement: The system shall support creating software models for a european option (on european option).
Requirement: The system shall support creating software models for a general state machine contract.

Product Use Case: Select market model for a derivatives contract.
Requirement: The system shall support adding market models.
Requirement: The system shall support updating market models.
Requirement: The system shall support selecting a market model.
Requirement: The system shall support selecting a black scholes price process.
Requirement: The system shall support selecting a local volatility price process.

Product Use Case: Read software model for a derivatives contract.
Requirement: The system shall support reading software models of a derivatives contract.

Product Use Case: Update software model for a derivatives contract.
Requirement: The system shall support updating software models for a forward contract.
Requirement: The system shall support updating software models for a european option (on forward contract).
Requirement: The system shall support updating software models for a american option (on forward contract).
Requirement: The system shall support updating software models for a swing option (on set of forward contracts).
Requirement: The system shall support updating software models for a european option (on european option).
Requirement: The system shall support updating software models for a general state machine contract.

Product Use Case: List software model for a derivatives contract.
Requirement: The system shall support listing software models of a derivatives contract.

Product Use Case: Delete software model for a derivatives contract.
Requirement: The system shall support deleting software models of a derivatives contract.

Product Use Case: Execute software model for a derivatives contract.
Requirement: The system shall support executing black scholes solution for european contract model with black scholes price process.
Requirement: The system shall support executing binomial solution for european contract model with local volatility price process.
Requirement: The system shall support executing black scholes solution for binary contract model with black scholes price process.
Requirement: The system shall support executing binomial solution for binary contract model with local volatility price process.
Requirement: The system shall support executing binomial solution for american contract model with black scholes price process.
Requirement: The system shall support executing binomial solution for american contract model with local volatility price process.
Requirement: The system shall support executing binomial solution for swing contract model with black scholes price process.
Requirement: The system shall support executing binomial solution for swing contract model with local volatility price process.
Requirement: The system shall support executing monte carlo solution for general statement machine contract model.

Product Use Case: Save results of executing software model for a derivatives contract.
Requirement: The system shall support saving results of executing software model for a derivatives contract.


#Product Use Case: Read latest value and hedges of the entire book.
#Requirement: The system shall support calculating the total value of all contracts and hedges.
#
#Product Use Case: Read a booked contract.
#Requirement: The system shall support reading details of a given booked derivatives contract.
#
#Product Use Case: Register a new derivatives contract.
#Requirement: The system shall support registering a new derivatives contract.
#
#Product Use Case: List the booked contracts.
#Requirement: The system shall support list all booked derivatives contracts.


Waiting Room
------------


26 changes: 26 additions & 0 deletions doc/quant-dsl-definition-and-proof.bbl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
\begin{thebibliography}{1}

\bibitem{Longstaff}
Francis~A. Longstaff and Eduardo~S. Schwartz.
\newblock Valuing american options by simulation: A simple least-squares
approach.
\newblock {\em Review of Financial Studies}, pages 113--147, 2001.

\bibitem{Quant}
Appropriate~Software Foundation.
\newblock Quant.
\newblock {\em Python Package Index}, (http://pypi.python.org/pypi/quant),
2011.

\bibitem{SciPy}
The~SciPy Community.
\newblock Scipy.
\newblock {\em SciPy Website}, (http://www.scipy.org), 2011.

\bibitem{DomainModel}
Appropriate~Software Foundation.
\newblock Domain model.
\newblock {\em Python Package Index},
(http://pypi.python.org/pypi/domainmodel), 2011.

\end{thebibliography}
31 changes: 31 additions & 0 deletions doc/quant-dsl-definition-and-proof.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@ARTICLE{Longstaff,
author = {Francis A. Longstaff and Eduardo S. Schwartz},
title = {Valuing American options by simulation: A simple least-squares approach},
journal = {Review of Financial Studies},
year = {2001},
pages = {113--147},
}

@ARTICLE{Quant,
author = {Appropriate Software Foundation},
title = {Quant},
journal = {Python Package Index},
year = {2011},
number = {http://pypi.python.org/pypi/quant}
}

@ARTICLE{DomainModel,
author = {Appropriate Software Foundation},
title = {Domain Model},
journal = {Python Package Index},
year = {2011},
number = {http://pypi.python.org/pypi/domainmodel}
}

@ARTICLE{SciPy,
author = {The SciPy Community},
title = {SciPy},
journal = {SciPy Website},
year = {2011},
number = {http://www.scipy.org}
}
Binary file added doc/quant-dsl-definition-and-proof.pdf
Binary file not shown.
Loading

0 comments on commit be8e3b7

Please sign in to comment.