danielhstahl / black_scholes_rust

Rust for black scholes
https://danielhstahl.github.io/black_scholes_rust/dev/bench/
23 stars 8 forks source link

Maturity clarity #22

Closed brandonros closed 1 year ago

brandonros commented 1 year ago

https://github.com/ronniec95/black_scholes/blob/92b4f0a7543e5802c2645c7e2c19f1154815e892/src/bs_f32x8_.rs#L762

I'm not smart enough to understand if the math for maturity between this library and ronniec95/black_scholes are the same but, to clarify, this repo expects maturity as days_to_expiration / 365 days a year and not days_to_expiration / 252 trading days a year, right?

What about for example:

{
    "underlying": "SPY",
    "name": "16 DEC 22 100",
    "spc": 100.0,
    "multiplier": 100.0,
    "expirationStyle": "REGULAR",
    "isEuropean": false,
    "expiration": "2022-12-17T12:00:00Z",
    "lastTradeDate": "2022-12-16T21:00:00Z",
    "settlementType": "PM"
}

Is the expiration date expiration or lastTradeDate? Or does none of this really matter because they are American style options instead of European?

Option style / maturity?

Are SPX American or European? SPX options are European-style and can therefore only be exercised at the time of expiration. There is no risk of early exercise when using European-style options which is a nice advantage for option sellers.

SPY (ETF) options are American style, meaning the option owner may choose to exercise ahead of expiration.

Option style / dividend?

According to the Black-Scholes option pricing model (its Merton's extension that accounts for dividends), there are six parameters which affect option prices:

Dividend yield was only added by Merton in Theory of Rational Option Pricing, 1973.

Not sure if dividend matters only on a certain style of option (American vs European) / if it affects the greeks since it has to be priced in even if the option isn't close to the ex-dividend date expiration wise?

Just thinking outloud/being nitpicky in the quest of making the greeks more "accurate" to the real world (aka how TD Ameritrade/other platforms price options for trading basically)

danielhstahl commented 1 year ago

My library is agnostic to time. If vol and discount rate is calculated using 365 day convention then the time should use a 365 day convention.

My library, by itself, is intentionally un-opinionated on how to actually calculate the parameters used in the Black Scholes model. A substantial amount of scaffolding is needed to wrap my library into something useable "in production".

As an example, see https://github.com/lballabio/QuantLib. Quantlib provides the "base calculator" here: https://github.com/lballabio/QuantLib/blob/master/ql/pricingengines/blackcalculator.cpp. But they provide many options for the day conventions: https://github.com/lballabio/QuantLib/tree/f47242c966d191e1b542162b1f2d726615bdba89/ql/time/daycounters.

One of Quantlib's examples uses the 365 day convention (https://github.com/lballabio/QuantLib/blob/master/Examples/EquityOption/EquityOption.cpp), though they could have chosen a 252 day convention as well.

brandonros commented 1 year ago

Thanks.

// Black-Scholes for European
// semi-analytic Heston for European
// semi-analytic Bates for European
// Barone-Adesi and Whaley approximation for American
// Bjerksund and Stensland approximation for American
// QD+ fixed-point engine for American
// Integral
// Finite differences
// Binomial method: Jarrow-Rudd
// Binomial method: Additive equiprobabilities
// Binomial method: Binomial Trigeorgis
// Binomial method: Binomial Tian
// Binomial method: Binomial Leisen-Reimer
// Binomial method: Binomial Joshi
// Monte Carlo Method: MC (crude)
// Monte Carlo Method: QMC (Sobol)
// Monte Carlo Method: MC (Longstaff Schwartz)

Do we know what brokerages are using method calculation wise, or can we reverse engineer the two unknown variables (time to expire, risk free rate) from implied vol + the Greeks they provide?

A substantial amount of scaffolding is needed to wrap my library into something useable "in production".

Could you expand on this a bit? I looked at the EquityOption example (thanks for that) but I'm not quite sure what's missing from your repo other than maybe dividend yield?

danielhstahl commented 1 year ago

Most online calculators will be using straight Black Scholes, unless they say otherwise.

My library is very similar to the blackcalculator.cpp from Quantlib. By scaffolding I mean all the other things Quantlib has that I (intentionally) don't have: things like zero-rate curve construction, the date conventions, etc. Most online calculators do not document how they treat dates, weekends, holidays, etc.

danielhstahl commented 1 year ago

Not to mention how option or stock prices are calculated...eg last trade price, or mid point of bid and ask (which I assume is what most calculators use).

brandonros commented 1 year ago

zero-rate curve construction

can this be overly simplified by just using the 10y as the risk free rate?

I’m with you on last trade vs mark price but does that really make a difference during regular trading hours for something as liquid as SPY/SPX?

I’ll do a writeup on how far off some calculations are if that’s cool with you “expected vs actual” where actual is the # most people see online.

If none of this interests you by all means I’ll stop wasting your time. You’ve been very helpful and kind so far.

danielhstahl commented 1 year ago

There are many ways to define the input parameters. There are conventions for how to define them: eg midpoint of bid ask, or 252 days in a year. Consistency of convention is what is important. Again, that's outside the scope of this repo.

danielhstahl commented 1 year ago

What do you mean my "most people"? All the calculators online should be using the same mathematical logic; the difference is in the "conventions".