r/algotrading • u/Quiet-Cup-1501 • 7h ago
Education I built a Python application to replicate arbitrary payoff curves using options
Enable HLS to view with audio, or disable this notification
The idea is pretty simple: you draw a payoff curve with your mouse, and the algorithm figures out an options portfolio that approximates it.
It uses a result from Peter Carr and Dilip Madan's work on volatility trading from the late 90s, where the first and second derivatives of a sufficiently smooth payoff function can be used to determine the underlying position, cash component, and option positions needed for static replication.
Of course, there are some limitations. It assumes European-style options, doesn't account for contract lot sizes, and the replication isn't exact when using real option chains with discrete strikes.
This is just one piece of the broader work developed by Carr and Madan. I thought it would be fun to turn this rather abstract result into something more tangible. The underlying method works with any twice-differentiable payoff function, so you could feed it a function directly instead of drawing one.
It works both with a numerical strike grid and with real option chains for indices like the S&P 500 and Nasdaq-100.
For anyone curious about the implementation: https://github.com/Serranegra/TooManyOptions
Would love to hear any thoughts or suggestions!
Reference:
Carr, P. and Madan, D. (1998). “Towards a Theory of Volatility Trading.” In Volatility: New Developments in Options and Derivatives, edited by R. Jarrow, pp. 417–427. Risk Books.







