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.4.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: ameriopt-0.1.4.tar.gz
  • Upload date:
  • Size: 6.0 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.4.tar.gz
Algorithm Hash digest
SHA256 2cce3752dcf496fe0f6b45d223a70306202a4e6933047c9cc529aef60a405922
MD5 39f42313fd046be7b2814404c3649a10
BLAKE2b-256 efa5754b6d02f591a16e679ebf895bc2bc89a2288d7131bd19d73beea014253c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ameriopt-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 908afde99c60f789080105c812432aeba3198bf81cb7e10eaebc2e07b4b106df
MD5 b2120281703626db1c2fe7daf642a73b
BLAKE2b-256 ad5ab89306f61e64cdeb405d2eaaa3571e922b8f94a300782401f4d2f151c789

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