Skip to content

Commit

Permalink
Version 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
quantsbin committed Jul 5, 2018
1 parent 8ade757 commit 7ab2b71
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 29 deletions.
10 changes: 5 additions & 5 deletions Quantsbin.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: Quantsbin
Version: 1.0
Version: 1.0a0
Summary: Quantitative Finance Tools
Home-page: https://github.com/quantsbin/Quantsbin
Author: Quantsbin
Expand All @@ -10,11 +10,11 @@ Description: # Quantsbin

Open source library for finance.

Quantsbin 1.0, which started as a weekend project is currently in its initial phase and
Quantsbin 1.0.a, 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 includes
## Quantsbin 1.0.a 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
Expand Down Expand Up @@ -53,10 +53,10 @@ Description: # Quantsbin
For collaboration and suggestion reach us at [Quantsbin](http://www.quantsbin.com/)

## Tutorial
Refer to our [Tutorial](http://www.quantsbin.com/tutorial/) page
Refer to our [Tutorial](https://quantsbin.wordpress.com/2018/07/05/introduction-to-options-and-option-pricing-using-python-open-source-library-quantsbin/) page

## Note
For Quantsbin 0.0.0 testing and documentation are still WIP.
For Quantsbin 1.0.a testing and documentation are still WIP.

Platform: UNKNOWN
Description-Content-Type: text/markdown
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

Open source library for finance.

Quantsbin 1.0, which started as a weekend project is currently in its initial phase and
Quantsbin 1.0.a, 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 includes
## Quantsbin 1.0.a 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
Expand Down Expand Up @@ -45,7 +45,7 @@ Refer to our [Documentation](http://www.quantsbin.com/documentation/) page
For collaboration and suggestion reach us at [Quantsbin](http://www.quantsbin.com/)

## Tutorial
Refer to our [Tutorial](http://www.quantsbin.com/tutorial/) page
Refer to our [Tutorial](https://quantsbin.wordpress.com/2018/07/05/introduction-to-options-and-option-pricing-using-python-open-source-library-quantsbin/) page

## Note
For Quantsbin 1.0 testing and documentation are still WIP.
For Quantsbin 1.0.a testing and documentation are still WIP.
16 changes: 8 additions & 8 deletions build/lib/quantsbin/derivativepricing/namesnmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ class UnderlyingParameters(Enum):


class RiskParameter(Enum):
DELTA = 'Delta'
GAMMA = 'Gamma'
THETA = 'Theta'
VEGA = 'Vega'
RHO = 'Rho'
PHI = 'Phi'
RHO_FOREIGN = 'Rho_foreign'
RHO_CONV = 'Rho_conv_yield'
DELTA = 'delta'
GAMMA = 'gamma'
THETA = 'theta'
VEGA = 'vega'
RHO = 'rho'
PHI = 'phi'
RHO_FOREIGN = 'rho_foreign'
RHO_CONV = 'rho_conv_yield'


class VanillaOptionType(Enum):
Expand Down
1 change: 1 addition & 0 deletions build/lib/quantsbin/derivativepricing/optionstrategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
UdlType.COMMODITY.value: inst.ComOption
}


def p_map(func, parameter):
if platform.system() == "Windows":
return map(func, parameter)
Expand Down
22 changes: 11 additions & 11 deletions build/lib/quantsbin/derivativepricing/pricingmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ def risk_parameters(self):
pass

@property
def cnv_yield(self):
def _cnv_yield(self):
if self.instrument.undl == UdlType.FUTURES.value:
return self.rf_rate
else:
return self._cnv_yield
return self.cnv_yield

@property
def pricing_date(self):
Expand Down Expand Up @@ -76,7 +76,7 @@ def __init__(self, instrument, spot0=None, rf_rate=0, cnv_yield=0, cost_yield=0,
self.instrument = instrument
self.spot0 = spot0 or .00001
self.rf_rate = rf_rate or 0
self._cnv_yield = cnv_yield or 0
self.cnv_yield = cnv_yield or 0
self.cost_yield = cost_yield or 0
self.pv_cnv = pv_cnv or 0
self.pv_cost = pv_cost or 0
Expand All @@ -90,7 +90,7 @@ def adj_spot0(self):
@property
def d1(self):
return (log(self.adj_spot0 / self.instrument.strike) + (
self.rf_rate - self.cnv_yield + self.cost_yield + 0.5 * (self.volatility ** 2)) * self.maturity) \
self.rf_rate - self._cnv_yield + self.cost_yield + 0.5 * (self.volatility ** 2)) * self.maturity) \
/ (self.volatility * sqrt(self.maturity))

@property
Expand All @@ -103,7 +103,7 @@ def discount_factor(self):

@property
def adj_discount_factor(self):
return e ** (-1 * (self.cnv_yield - self.cost_yield) * self.maturity)
return e ** (-1 * (self._cnv_yield - self.cost_yield) * self.maturity)

@property
def option_flag(self):
Expand Down Expand Up @@ -143,7 +143,7 @@ def rho_fut(self):
def theta(self):
return ((-1 * norm.pdf(self.d1) * self.volatility * self.adj_discount_factor * self.adj_spot0 / (
2 * sqrt(self.maturity))) +
(self.option_flag * (self.cnv_yield - self.cost_yield) * self.adj_spot0
(self.option_flag * (self._cnv_yield - self.cost_yield) * self.adj_spot0
* norm.cdf(self.option_flag * self.d1) * self.adj_discount_factor) -
(self.option_flag * self.rf_rate * self.instrument.strike * self.discount_factor
* norm.cdf(self.option_flag * self.d2))) / 365
Expand All @@ -167,7 +167,7 @@ def objective_func(vol_guess):
return val - premium

try:
return optimize.bisect(objective_func, 0.5, xtol=0.00005)
return optimize.bisect(objective_func, a=0.001, b=0.999, xtol=0.00005)
except ValueError:
raise ValueError("Unable to converge to implied volatility")

Expand Down Expand Up @@ -284,7 +284,7 @@ def __init__(self, instrument, spot0=None, rf_rate=0, cnv_yield=0, cost_yield=0,
self.instrument = instrument
self.spot0 = spot0 or .0001
self.rf_rate = rf_rate or 0
self._cnv_yield = cnv_yield or 0
self.cnv_yield = cnv_yield or 0
self.cost_yield = cost_yield or 0
self.volatility = volatility or 0.10
self._pricing_date = dt.strptime(pricing_date, '%Y%m%d')
Expand All @@ -301,7 +301,7 @@ def div_processed(self):

@property
def drift(self):
return self.rf_rate + self.cost_yield - self.cnv_yield
return self.rf_rate + self.cost_yield - self._cnv_yield

@property
def no_of_path(self):
Expand Down Expand Up @@ -399,7 +399,7 @@ def __init__(self, instrument, spot0=None, rf_rate=0, cnv_yield=0, cost_yield=0,
self.instrument = instrument
self.spot0 = spot0 or 0.0001
self.rf_rate = rf_rate or 0
self._cnv_yield = cnv_yield or 0
self.cnv_yield = cnv_yield or 0
self.cost_yield = cost_yield or 0
self.volatility = volatility or 0.10
self._pricing_date = dt.strptime(pricing_date, '%Y%m%d')
Expand All @@ -409,7 +409,7 @@ def __init__(self, instrument, spot0=None, rf_rate=0, cnv_yield=0, cost_yield=0,

@property
def drift(self):
return self.rf_rate + self.cost_yield - self.cnv_yield
return self.rf_rate + self.cost_yield - self._cnv_yield

@property
def div_processed(self):
Expand Down
1 change: 1 addition & 0 deletions quantsbin/derivativepricing/optionstrategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
UdlType.COMMODITY.value: inst.ComOption
}


def p_map(func, parameter):
if platform.system() == "Windows":
return map(func, parameter)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

setup(
name='Quantsbin',
version='1.0',
version='1.0.a',
description='Quantitative Finance Tools',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 7ab2b71

Please sign in to comment.