REST API web application for option pricing and market data storage
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Mark Veidemanis 97cdf54caa
Fix business day bug
2 months ago
app Setup media root 2 months ago
core Fix business day bug 2 months ago
docker Initial commit 3 months ago
.gitignore Add boilerplate files 2 months ago
.pre-commit-config.yaml Add boilerplate files 2 months ago
CombinedEnergyFutures.csv Add example market data 2 months ago
Dockerfile Initial commit 3 months ago
Makefile Initial commit 3 months ago
README.md Write README 2 months ago
docker-compose.yml Initial commit 3 months ago
manage.py Initial commit 3 months ago
requirements.txt Add boilerplate files 2 months ago
stack.env.example Setup media root 2 months ago

README.md

Option Pricing

Option pricing web application and API. Taking algorithmic implementation details from https://github.com/pauldepstein/Option_Pricing, but heavily rewritten, documented, and added error handling.

Features

  • Upload and download market data via easy file interface
  • Annotated option form for easy filling
  • Persistent options per-user stored in the database
  • Data is uneditable when the calculate button is clickable
  • Single page application - once loaded, refreshing is not needed
  • QR-code based two-factor authentication
  • API endpoint for calculation
  • Click to copy option price
  • Follows PEP8 snake_case style convention: https://peps.python.org/pep-0008/

To run

  • Ensure an empty file called db.sqlite3 exists in the same directory. Otherwise, Docker may helpfully create it as a folder

  • Copy the example environment file to stack.env and modify if you wish: cp stack.env.example stack.env

  • To start the application: make run

The docker-compose configuration will automatically download the dependencies.

Note for newer Docker versions

If you are using docker compose (no space) you will need to manually run this:

docker compose --env-file=stack.env up -d

To use

  • Run the migrations with make migrate
  • Create a user with make auth
  • Log in at the default URL (if you have not changed it) of http://127.0.0.1:5005/
  • Click Update/download market data and select CombinedEnergyFutures.csv in the root of this repo
  • Click update options and follow the prompts - everything is annotated
  • If you just want to see it work, select the following:
Upload: yes
Call: Call
Ticker: HH
Strike: 2.47
  • Click Submit
  • Click Calculate"

API

There is a API endpoint at http://127.0.0.1:5005/api/v1/options/calculate/ The market data needs to be uploaded and the market options set.

Note for newer docker versions

make migrate:

docker compose --env-file=stack.env run --rm app sh -c ". /venv/bin/activate && python manage.py migrate"

make auth:

docker compose --env-file=stack.env run --rm app sh -c ". /venv/bin/activate && python manage.py createsuperuser"

Note for 2-factor

If your superuser has the username m, you can use make token to generate a backup code. Otherwise, you can do this:

docker-compose --env-file=stack.env run --rm app sh -c ". /venv/bin/activate && python manage.py addstatictoken <USERNAME HERE>"

(as before, remove the hyphen if you have a newer Docker version)