exotx provides a simple and user-friendly interface for pricing and analyzing financial derivatives using QuantLib's advanced numerical methods.
exotx
exotx is a Python wrapper for the QuantLib library, a powerful open-source library for quantitative finance. exotx provides a simple and user-friendly interface for pricing and analyzing financial derivatives using QuantLib's advanced numerical methods.
Installation
To install exotx, simply use pip:
pip install exotx
Usage
Define the product
Vanilla Option
import exotx
from exotx.instruments import OptionType
strike = 90 option_maturity = '2016-05-04' myvanillaoption = exotx.VanillaOption(strike, option_maturity, OptionType.CALL)
Auto-Callable
notional = 100
strike = 100.0
autocallbarrierlevel = 1.0 # 100%
annualcouponvalue = 0.03 # 3.00%
couponbarrierlevel = 0.75 # 75%
protectionbarrierlevel = 0.75 # 75%
myautocallable = exotx.Autocallable(notional, strike, autocallbarrierlevel, annualcouponvalue, couponbarrierlevel, protectionbarrier_level)
Define the static data
The object that represents static data such as the calendar, the day counter or the business day convention used.
From the constructor
mystaticdata = exotx.StaticData(daycounter='Actual360', businessday_c)
From JSON
my_json = {
'day_counter': 'Actual360',
'businessdayconvention': 'ModifiedFollowing'
}
mystaticdata = exotx.StaticData.fromjson(myjson)
Define the market data
From the constructor
reference_date = '2015-11-06'
spot = 100.0
riskfreerate = 0.01
dividend_rate = 0.0
blackscholesvolatility = 0.2
mymarketdata = exotx.MarketData(referencedate, spot, riskfreerate, dividendrate, blackscholesvolatility=blackscholesvolatility)
From JSON
my_json = {
'reference_date': '2015-11-06',
'spot': 100,
'riskfreerate': 0.01,
'dividend_rate': 0,
'blackscholesvolatility': 0.2
}
mymarketdata = exotx.MarketData.fromjson(myjson)
Price the product
Vanilla Option
from exotx.enums import PricingModel, NumericalMethod
mypricingconfig = exotx.PricingConfiguration(PricingModel.BLACKSCHOLES, NumericalMethod.ANALYTIC, computegreeks=True) exotx.price(myvanillaoption, mymarketdata, mystaticdata, mypricingconfig)
>>> { 'price': 13.83328710, 'delta': 0.77183751, 'gamma': 0.01609460, 'theta': -7.01024983 }
Auto-Callable
exotx.price(myautocallable, mymarketdata, mystatic_data, model='black-scholes')
>>> 96.08517973497098
Contributing
We welcome contributions to exotx! If you find a bug or would like to request a new feature, please open an issue on the Github repository. If you would like to contribute code, please submit a pull request.
License
exotx is released under the MIT License.