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.

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

Uploaded Source

Built Distribution

ameriopt-0.1.3-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ameriopt-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 b1de44c1a058f41e7f0a356fae6b1c715fdbc7973ff4d5e4d0f174b6a170c429
MD5 d8a1d8b23ba05f1a0a7989119a8d1223
BLAKE2b-256 0ef52f00452fa2332ccca67005469c24d4589bb4e58cf9b472c5f2f365bf1f79

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ameriopt-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.3 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 42cf21e63c0c21f0c77d3b575bb968ea19d6615cbe743ff65d192cd8b15c47c6
MD5 1ff8beffb9bb9bd687e83ca2fe1e7331
BLAKE2b-256 eb1d6c2f1dbb09dce383801d20617e60c0f76ae17121dd80b3f5a26ca046bcdf

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