Giter Club home page Giter Club logo

quantsbin's Introduction

PyPi version PyPi Status Github Stars Twitter follows

Quantsbin

Open source library for finance.

Quantsbin 1.0.3, which started as a weekend project is currently in its initial phase and incorporates tools for pricing and plotting of vanilla option prices, greeks and various other analysis around them. We are working on optimising calculations and expanding the scope of library in multiple directions for future releases.

Quantsbin 1.0.3 includes

  1. Option payoff, premium and greeks calculation for vanilla options on Equity, FX, Commodity and Futures.
  2. Capability to calculate greeks numerically for all models and also analytically for Black Scholes Model.
  3. Price vanilla options with European expiry using BSM, Binomial tree and MonteCarlo with option to incorporate continuous compounded dividend yield for Equity options, cost and convenience yield for Commodity options and local and foreign risk-free rate in case of FX options. It also allows option to give discrete dividends in cased of Equity options.
  4. Price vanilla options with American expiry using Binomial tree and MonteCarlo(Longstaff Schwartz) method. There is option to provide discrete dividends for Equity options for both the models.
  5. Implied volatility calculation under BSM framework model.
  6. Option to create user defined or standard strategies using multiple single underlying options and directly generate and plot valuation and greeks for these strategies.

License

MIT LICENCE

Dependencies and Installation details

  scipy==1.6.3
  pandas==1.2.4
  matplotlib==3.4.2
  numpy==1.18.0     

Install using setup.py:

>>> python setup.py install

Install using pip:

>>> pip install quantsbin

Detailed documentation

Refer to our Documentation page

Our Website

For collaboration and suggestion reach us at Quantsbin

Tutorial

Refer to our Tutorial page

Note

For Quantsbin 1.0.3 documentation are still WIP.

quantsbin's People

Contributors

deepsourcebot avatar quantsbin avatar richwu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quantsbin's Issues

Problem with binomial model when running example code

I ran this code from the example:
import quantsbin.derivativepricing as qbdp

equity_p1 = qbdp.EqOption(option_type='Put', strike=50, expiry_date='20190721', expiry_type='European')
equity_p2 = qbdp.EqOption(option_type='Put', strike=50, expiry_date='20190721', expiry_type='American')

market1_parameters = {'spot0': 45
, 'pricing_date':'20180121'
, 'volatility':.25
, 'rf_rate':.05
, 'yield_div':0.02}

eq1_BSM_market1 = equity_p1.engine(model="BSM", **market1_parameters)
eq1_market1 = equity_p1.engine(model="Binomial", **market1_parameters)
eq2_market1 = equity_p2.engine(model="Binomial", **market1_parameters)

print("Value of eq1 under market 1 with BSM model is {}".format(eq1_BSM_market1.valuation()))
print("Value of eq1 under market 1 with Binomial model is {}".format(eq1_market1.valuation()))
print("Value of eq2 under market 1 with Binomial model is {}".format(eq2_market1.valuation()))

print("parms of eq1 under market 1 with BSM model is {}".format(eq1_BSM_market1.risk_parameters()))
print("parms of eq1 under market 1 with Binomial model is {}".format(eq1_market1.risk_parameters()))
print("parms of eq2 under market 1 with Binomial model is {}".format(eq2_market1.risk_parameters()))

BSM works fine but binomial gives the error:

Traceback (most recent call last):
print("parms of eq1 under market 1 with Binomial model is {}".format(eq1_market1.risk_parameters()))
File "/anaconda3/envs/py37/lib/python3.7/site-packages/quantsbin/derivativepricing/engineconfig.py", line 66, in risk_parameters
, delta_rf_conv=delta_rf_conv, delta_cost_yield=delta_cost_yield, *kwargs)
File "/anaconda3/envs/py37/lib/python3.7/site-packages/quantsbin/derivativepricing/engineconfig.py", line 79, in risk_parameters_num
return ng.risk_parameters_num()
File "/anaconda3/envs/py37/lib/python3.7/site-packages/quantsbin/derivativepricing/numericalgreeks.py", line 70, in risk_parameters_num
return {RiskParameter.DELTA.value: self.delta()
File "/anaconda3/envs/py37/lib/python3.7/site-packages/quantsbin/derivativepricing/numericalgreeks.py", line 55, in delta
return self.degree_one(UnderlyingParameters.SPOT.value, self.delta_spot)
File "/anaconda3/envs/py37/lib/python3.7/site-packages/quantsbin/derivativepricing/numericalgreeks.py", line 44, in degree_one
return (up_model.valuation() - down_model.valuation())/(2
(getattr(self._model, var)*change))
ZeroDivisionError: float division by zero

spline method

Hi there,

its not a real issue I would say but if you use the current scipy package rather than 1.0 (as mentioned in the requirements) the spline method will not be found. It relates to the refactoring from spline to UnivariateSpline.

To solve this rename all occurences of 'spline' to 'UnivariateSpline'.

Disclaimer: I am not sure if all the functions will work with this change and whether the behaviour is as expected.

Happy coding
W

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.