Skip to main content

library T-28h

Project description

American Options Library

The Library that is using various methods to price the variety of options of american type.

Installation


pip install american_options

Get started

How to obtain option price with this library:

from american_options import Option, Underlying



#Set up your parameters

n_sims = 10000   

T = 1

sigma1 = 0.4

sigma2 = 0.8

r = 0.06

N = 255

spot1 = 100

spot2 = 120

K1 = 100

K2 = 110

First you need to create assets you want to write options on. You can do this in following way:

# Instantiate an Underlying object

asset1 = Underlying(spot_price=100, r=0.07)

asset2 = Underlying(spot_price=120, r=0.07)

Next step is to calibrate assets for the use of different models.

# Calibrate created assets

asset1.calibrate_GBM(sigma=0.4, values_per_year_GBM=N)

asset1.calibrate_JD(sigma=0.4, jump_intensity=1/3)

asset2.calibrate_GBM(sigma=0.4, values_per_year_GBM=N)

asset2.calibrate_JD(sigma=0.2, jump_intensity=1/2)

Now create options, for that we need payoff functions as well. You can import some of them from payoffs module:

from american_options.payoffs import *



option1 = Option(underlyings=asset1, payoff_func=lambda trajectory: payoff_creator_1d(trajectory, Call_Payoff, K=100, barrier=True, barrier_level=140), T=1)

option2 = Option(underlyings=(asset1, asset2), payoff_func=lambda trajectories: double_max_put(trajectories, 100), T=1)

And finally obtaining a price!

# Pricing with state space partitioning method

option1.ssp(n_sims=10000, mode='JD')

option2.ssp(n_sims=10000, mode='GBM')



# pPricing with Longstaff-Schwartz method

option1.LS(n_sims=10000, mode='JD')

option2.ssp(n_sims=10000, mode='GBM')

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

american_options-0.1.1.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

american_options-0.1.1-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file american_options-0.1.1.tar.gz.

File metadata

  • Download URL: american_options-0.1.1.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.4

File hashes

Hashes for american_options-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5d9409cfe7da270d0c0be5a3843754a7448a0e2f8dc44f609299229c371bb028
MD5 ef1bc1a7cda666100e4152234c2ea728
BLAKE2b-256 63700cd1b3f2fa21f510db0a9fc2654ae51aafdec69a148a4ed011f71d191d28

See more details on using hashes here.

File details

Details for the file american_options-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for american_options-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 403b9d3902dcc7fa74a821826bc97da2135f2d24d4b82f70507c259c3fd17a03
MD5 1cc0bba84c5558edc9c3a36a84f70ad6
BLAKE2b-256 eaffd04045e5e4ab930e6ba116cfc303b2feb6ce32e455247fada4f480ce0793

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