Skip to main content

This is a package for pricing American options using reinforcement learning

Project description

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

image info

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ameriopt-0.1.5.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

ameriopt-0.1.5-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file ameriopt-0.1.5.tar.gz.

File metadata

  • Download URL: ameriopt-0.1.5.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/5.15.0-119-generic

File hashes

Hashes for ameriopt-0.1.5.tar.gz
Algorithm Hash digest
SHA256 992c54315da4a16a394c700927f74dd0b05646b11e61d0f2a782894b832456e9
MD5 e8517fb9870c91be0aa2b29ac1b46985
BLAKE2b-256 f9909ab66d66c25b22c6f057b5c6a22795f81ff99f4f294bbf8e6a826232ac43

See more details on using hashes here.

File details

Details for the file ameriopt-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: ameriopt-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/5.15.0-119-generic

File hashes

Hashes for ameriopt-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e05bab4ec0a85b9c1215dbddbc9b838ccc09969db95d6251bd0ddc96efa29243
MD5 2ad09e5dcb2a077ab74edd07ca48b005
BLAKE2b-256 12395a3c5ca0814cf72088d7fde5879ec26ec64ce02d910b5f1a8e508d513030

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page