|
2 months ago | |
---|---|---|
app | 2 months ago | |
core | 2 months ago | |
docker | 3 months ago | |
.gitignore | 2 months ago | |
.pre-commit-config.yaml | 2 months ago | |
CombinedEnergyFutures.csv | 2 months ago | |
Dockerfile | 3 months ago | |
Makefile | 3 months ago | |
README.md | 2 months ago | |
docker-compose.yml | 3 months ago | |
manage.py | 3 months ago | |
requirements.txt | 2 months ago | |
stack.env.example | 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)