This is an example Python script using Quantlib in order to calculate American Option prices. This is provided purely as an example and is not intended to be used as-is for financial pricing.
There is a provided Dockerfile and a setup script to configure a virtual environment and generate protobuf code.
You can run setup.sh
locally for development purposes and it can also be used
in the Dockerfile
.
Run setup.sh:
./setup.sh
Generate 1000 example tasks:
.venv/bin/python3 main.py gentasks --count 1000 tasks.jsonl
Directly run pricer with the test data:
.venv/bin/python3 main.py load tasks.jsonl
Run the pricing engine locally on the default port 2002:
.venv/bin/python3 main.py serve
In a separate command prompt, grpcurl with the test data to try it out: to generate JSON test data for the pricing library. This will only send in the first request.
head -n 1 tasks.jsonl | grpcurl -d @ -plaintext localhost:2002 main.PricingService/CalcPrices
docker build -t pricer .
Generate 1000 example tasks:
docker run pricer gentasks --count 1000 - > tasks.jsonl
Directly run pricer with the test data:
docker run -v $PWD:/data pricer load /data/tasks.jsonl
Run the pricing engine locally on the default port 2002:
docker run -p 2002:2002 pricer serve
In a separate command prompt, grpcurl with the test data to try it out: to generate JSON test data for the pricing library. This will only send in the first request.
head -n 1 tasks.jsonl | grpcurl -d @ -plaintext localhost:2002 main.PricingService/CalcPrices