AmeriOpt
A Python Package for Pricing American Option using Reinforcement Learning.
The full documentation of paper can be found in https://www.mdpi.com/1999-4893/17/9/400
To use package, you need to follwo the following steps:
Installation
pip install ameriopt
Import the package
from ameriopt.rl_policy import RLPolicy
Set the parameters of GBM model
- Number of Laguerre polynomials to be used in the RL model
NUM_LAGUERRE = 5
- Number of training iterations for the RL algorithm
TRAINING_ITERS = 3
- Small constant for numerical stability in the RL algorithm
EPSILON = 1e-5
- Strike price of the option
STRIKE_PRICE = 40
- Time to expiration (in years)
EXPIRY_TIME = 1.0
- Risk-free interest rate
INTEREST_RATE = 0.06
- Number of time intervals
NUM_INTERVALS = 50
- Number of simulations for generating training data
NUM_SIMULATIONS_TRAIN = 5000
- Number of simulations for testing the RL policy
NUM_SIMULATIONS_TEST = 10000
- Spot price of the underlying asset at the start of the simulation
SPOT_PRICE = 36.0
- Volatility of the underlying asset (annualized)
VOLATILITY = 0.2
Simulate Training Data using Geometric Brownian Motion (GBM)
training_data = simulate_GBM_training(
expiry_time=EXPIRY_TIME,
num_intervals=NUM_INTERVALS,
num_simulations=NUM_SIMULATIONS_TRAIN,
spot_price=SPOT_PRICE,
interest_rate=INTEREST_RATE,
volatility=VOLATILITY
)
Instantiate the RLPolicy model with defined parameter GBM Price Model
rl_policy = RLPolicy(
num_laguerre=NUM_LAGUERRE,
strike_price=STRIKE_PRICE,
expiry=EXPIRY_TIME,
interest_rate=INTEREST_RATE,
num_steps=NUM_INTERVALS,
training_iters=TRAINING_ITERS,
epsilon=EPSILON
)
Train the RL Model and Get Weights (Weight for the optimal policy)
weights = rl_policy.get_weights(training_data=training_data)
Generate test data (GBM paths) for option price scoring
paths_test = scoring_sim_data(
expiry_time=EXPIRY_TIME,
num_intervals=NUM_INTERVALS,
num_simulations_test=NUM_SIMULATIONS_TEST,
spot_price=SPOT_PRICE,
interest_rate=INTEREST_RATE,
volatility=VOLATILITY
)
Option price
option_price = rl_policy.calculate_option_price(stock_paths=paths_test)
Print the calculated option price
print("Option Price using RL Method:", option_price)
Metadata
Release files for ameriopt 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ameriopt-0.1.5.tar.gz | 6.1 kB | Without provenance | Details for ameriopt-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ameriopt-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for ameriopt-0.1.5-py3-none-any.whl |
Total release size: 13.5 kB
Release files / ameriopt-0.1.5.tar.gz
| Download URL | ameriopt-0.1.5.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
992c54315da4a16a394c700927f74dd0b05646b11e61d0f2a782894b832456e9
|
|
BLAKE2b-256 checksum How to use checksums |
f9909ab66d66c25b22c6f057b5c6a22795f81ff99f4f294bbf8e6a826232ac43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.14 Linux/5.15.0-119-generic
|
Release files / ameriopt-0.1.5-py3-none-any.whl
| Download URL | ameriopt-0.1.5-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e05bab4ec0a85b9c1215dbddbc9b838ccc09969db95d6251bd0ddc96efa29243
|
|
BLAKE2b-256 checksum How to use checksums |
12395a3c5ca0814cf72088d7fde5879ec26ec64ce02d910b5f1a8e508d513030
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.14 Linux/5.15.0-119-generic
|
Security for ameriopt 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.