Math-Business-BlackScholes
view release on metacpan or search on metacpan
BlackScholes.pm view on Meta::CPAN
than calling call_price() and put_price() sequentially with the same arguments.
Each of these routines accepts the same set of parameters:
C<$current_market_price> is the price for which the underlying security is
currently trading.
C<$volatility> is the standard deviation of the probability distribution of
the natural logarithm of the stock price one year in the future.
C<$strike_price> is the strike price of the option.
C<$remaining_term> is the time remaining until the option expires, in years.
C<$interest_rate> is the risk-free interest rate (per year) as a fraction.
C<$fractional_yield> is the fraction of the stock price that the stock
yields in dividends per year; it is assumed to be zero if unspecified.
=head2 Discrete Dividends
If C<$fractional_yield> is specified as a number, then the actual timing of
the ex-dividend dates relative to the current time and the option expiration
time can affect the option price by as much as the value of a single dividend.
C<$fractional_yield> may instead be specified as a hashref, each key of which
is the remaining amount of time before the dividend is paid, in years,
and each value of which is the dividend amount.
This produces more accurate results when the dividends that will be assigned
during the term of the option are reliably predictable.
The ex-dividend date of each dividend so represented is assumed to occur
within the I<remaining> term of the option, even if the dividend is paid
after the term expires.
=head2 Determining Parameter Values
C<$volatility> and C<$fractional_yield> are traditionally estimated based on
historical data.
C<$interest_rate> is traditionally equal to the current T-bill rate.
The model assumes that these parameters are stable over the term of the
option.
C<$volatility> (a.k.a. I<sigma>) is sometimes expressed as a percentage,
which is misleading because it's not a ratio.
If you have it as a percentage, then you'll need to divide it by 100 before
passing it to this module.
Ditto for C<$interest_rate> and C<$fractional_yield>.
Two ways to estimate C<$volatility> are provided.
historical_volatility() takes an arrayref of at least 10 (preferably 100 or
more) consecutive daily closing prices of the underlying security, in either
chronological or reverse chronological order.
It then multiplies the variance of the log of day-to-day returns by the number
of trading days per year specified by the second argument (or 250 by default).
The square-root of this yearly variance is returned.
implied_volatility_call() computes the implied volatility based on the known
trading price of a "reference" call option on the same underlying security with
a different strike price and/or term, using the Newton-Raphson method, or the
bisection method if it fails to converge otherwise.
It's invoked like call_price(), except that the second argument is taken as
the price of the call option, and the volatility is returned.
You can override the default option price tolerance of 1e-4 by passing an
additional argument beyond C<$fractional_yield>.
If called in an array context, the second element of the return value is an
estimate of the error magnitude, and the third element is the number of
iterations required to obtain the result.
The error magnitude may be quite large unless you use a
reference option whose price exceeds its intrinsic value by an amount larger
than or comparable to the absolute difference of the market price and the
strike price, and it is undefined if the price of the reference option is
less than what would be calculated with zero volatility.
If the price of the reference option is greater than what would be calculated
with infinite volatility, then both the result and the error estimate are
undefined.
An exception is thrown if it fails to converge within
C<$Math::Business::BlackScholes::max_iter> (100 by default) iterations.
An analogous implied_volatility_put() is also available.
=head2 American Options
Whereas a European stock option may be exercised only when it expires,
an American option may be exercised any time prior to its expiration.
The price of an American option can be approximated as the maximum price
of similar European options over all possible remaining terms not greater
than the remaining term of the American option.
This maximum usually occurs at the end of the remaining term, or just before
or just after the final ex-dividend date within the remaining term.
=head2 Negative Market Value
An underlying security with a negative market value is assumed to be a short.
Buying a short is equivalent to selling the security, so a call option on
a short is equivalent to a put option.
This is somewhat confusing, and arguably a warning ought to be generated if
it gets invoked.
=head1 DIAGNOSTICS
Attempting to evaluate an option with a negative term will result in a croak(),
because that's meaningless.
Passing suspicious arguments (I<e.g.> a negative interest rate) will result
in descriptive warning messages.
To disable such messages, try this:
{
local($SIG{__WARN__})=sub{};
$value=call_price( ... );
}
=head1 CAVEATS
=over 2
=item *
This module requires C<Math::CDF>.
=item *
The fractional computational error of call_price() and put_price() is
usually negligible.
However, while the computational error of second result of call_put_prices()
is typically small in comparison to the current market price, it might be
significant in comparison to the result itself.
That's probably unimportant for most purposes.
=item *
historical_volatility() tends to produce misleading results because the
behavior of the underlying security is most likely not truly log-normal.
In particular, the price varies predictably after a dividend is distributed,
and the daily variance is expected to be greater after financial announcements
are made.
Also, a large number of data points are required to obtain statistically
meaningful results, but having a large number of data points implies that the
results are outdated.
( run in 3.833 seconds using v1.01-cache-2.11-cpan-b301d465b3d )