--- tags: computer science, finance --- <center> <!-- # **<font style="background-color:black;color:orange;">Financial Computing Labs: Futures & Options</font>** --> # **Financial Computing Lab**<br><font size = 5>Futures & Options</font> :::info Location: Room 108 Time: 1630 ~ 1830 ::: </center> <p style="text-align:right;background-color:#D5D8DC;font-family:Comic Sans MS;font-size:110%;"> "Δ + Γ + Θ = r"<br>-- The Black-Scholes hedging formula </p> <img src = "https://hackmd.io/_uploads/S1xxivDw9.jpg" height = 300px style="float:right"/> ## **Class Information** ### Instructor - Name: 盧政良 (Zheng-Liang Lu, Arthur) - Email address: arthurzllu@gmail.com ### Objectives > I will introduce the pricing theory of futures and options and also the hedging techniques with Python and Excel sample programs. After completing this course, you will primarily understand futures and options, and conduct quantitative analysis of options, such as calculating implied volatility and delta. These concepts are central to the financial risk management. This course is suitable for financial practitioners or students interested in financial engineering or quantitative research. Note that the pricing theory of derivatives will involve some mathematics, where I will do my best to make it clear. > 本課程將介紹期貨與選擇權的定價理論,並提供學員 Python 與 Excel 的範例程式參考與修改,最後說明如何透過複製資產來達到避險效果。學員完成本課程後將可以了解期貨與選擇權的基本功能,並可以自行計算選擇權的重要參數,例如隱含波動率 (implied volatility) 與 delta 等,進而在操作期貨與選擇權時有客觀量化的數據利於調整投資組合。本課程適合金融從業人員或是對於衍生性金融商品有興趣的學員。注意,選擇權的定價理論將會牽涉到些許數學,我將會逐一帶領學員了解其意義,無須擔心數學推導的過程。 ### Prerequisites - Basic knowledge about financial markets <font color = "gray" size = -1>...for example, what is stock/equity?</font> - Python programming <font color = "gray" size = -1></font> - Statistics <font color = "gray" size = -1>...for example, what is a normal distribution?</font> ### Working Environment - [Google Colab](https://colab.research.google.com/) with Python 3.6 or later - You need a Google account before using Colab. - [JupyterLab](https://jupyter.org/) - You can run the JupyterLab server on your host machine. - In this way, you don't need to share your ideas with Google. :::warning Recording of classroom lectures is <font color="red">**prohibited**</font> unless advance written permission is obtained from the class instructor and any guest presenter(s). ::: ## **Syllabus** | Session Name | Summary | Files | | ------------ | ---------- | :----:| | **Quant Research Basics** | ◍ Python basics<br> ◍ Useful packages: datetime, yfinance, pandas, matplotlib<br> ◍ TXF/TXO data<br> ◍ Backtesting<br> | [python](https://www.csie.ntu.edu.tw/~d00922011/python/notebooks/fcl_0_python.ipynb)<br>[ta](https://www.csie.ntu.edu.tw/~d00922011/python/notebooks/fcl_1_ta.ipynb)<br>[backtesting.py](https://www.csie.ntu.edu.tw/~d00922011/python/notebooks/fcl_1_backtesting.ipynb) | | **Futures & Options: Pricing** | ◍ Fundamental theorems of asset pricing: arbitrage-free principle<br> ◍ Option pricing: binomial option pricing model (BOPM)<br> ◍ Risk-neutral valuation<br> ◍ Monte Carlo simulation<br> ◍ Black-Scholes formula for European options<br>◍ Implied volatility<br> ◍ Volatility index<br> ◍ QuantLib tutorial<br> <font color = "gray">◍ Financial mathematics</font> | [option_pdf](https://www.csie.ntu.edu.tw/~d00922011/python/slides/options.pdf)<br>[code]( https://www.csie.ntu.edu.tw/~d00922011/python/notebooks/pyf_6_options.ipynb)<br>[vix_pdf](https://www.csie.ntu.edu.tw/~d00922011/finmath/VIX.pdf)<br>[quantlib_code](https://www.csie.ntu.edu.tw/~d00922011/python/notebooks/pyf_x_quantlib_tutorial.ipynb)<br>[math](https://www.csie.ntu.edu.tw/~d00922011/finmath/Ito_calculus.pdf) | | **Sensitivity Analysis: Greeks** | ◍ Delta & dynamic delta hedging<br> ◍ Gamma<br> ◍ Theta<br> ◍ Vega<br> ◍ Rho<br> | [pdf](https://www.csie.ntu.edu.tw/~d00922011/python/slides/greeks.pdf)<br>[code](https://www.csie.ntu.edu.tw/~d00922011/python/notebooks/pyf_7_greeks.ipynb) | | **Option Trading** | ◍ Option combinations<br> ◍ Portfolio Profiler by Python & Excel<br> | [link](https://www.optioncombo.com/)<br>[profiler_code]( https://www.csie.ntu.edu.tw/~d00922011/python/notebooks/pyf_x_option_profiler.ipynb)<br>[excel-dashboard](https://www.csie.ntu.edu.tw/~d00922011/python/data/excel-dashboard.jpg)<br> [xlwings]( https://www.csie.ntu.edu.tw/~d00922011/python/notebooks/pyf_x_xlwings.ipynb) | | **Financial Machine Learning** | ◍ Orc wing model for volatility smile<br>◍ PCA of implied volatility surface<br>◍ ARCH model<br>◍ Long-Short Term Memory (LSTM) | [orc wing](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwih2eaGjM2CAxWFfvUHHSmAA2AQFnoECA0QAQ&url=https%3A%2F%2Fsourceforge.net%2Fp%2Fquantlib%2Fmailman%2Fattachment%2FSNT147-DS14C62FD328A11C206965D6AED90%40phx.gbl%2F1%2F&usg=AOvVaw1kjbChVOOa3kH5q6V07UVM&opi=89978449)<br>[paper](http://rama.cont.perso.math.cnrs.fr/pdf/ImpliedVolDynamics.pdf)<br>[PCA_demo](https://setosa.io/ev/principal-component-analysis/)<br>[vol_modeling](http://www.fhi.sk/files/katedry/kove/predmety/Prognosticke_modely/Univariate-Volatility-Modeling.pdf)<br>[LSTM](https://www.csie.ntu.edu.tw/~d00922011/python/program/翻轉科技工作坊-第8回.zip)<br>[paper](https://link.springer.com/article/10.1007/s00521-020-05377-6) | ## Supplementary Materials - **Quantitative Research Basics** - For Python beginners, you can find my Python programming courses for further details: - [Python 101](https://hackmd.io/@arthurzllu/HJNXq84SO) - [Python Programming in Finance](/RjzdJKGGSDGTozfU_W_hlQ) - Data sources - TXF (台指期): https://www.taifex.com.tw/cht/3/dlFutPrevious30DaysSalesData - TXO (台指選擇權): https://www.taifex.com.tw/cht/3/dlOptPrevious30DaysSalesData - Technical indicators - See also https://www.axi.com/int/blog/education/technical-indicators. - **Futures & Options: Pricing** - Case study: https://en.wikipedia.org/wiki/Bachelier_model - Case study: Ai Jun Hou, Weining Wang, Cathy Y H Chen, Wolfgang Karl Härdle, [Pricing Cryptocurrency Options](https://academic.oup.com/jfec/article/18/2/250/5837734), 2020 - [CBOE VIX](https://www.cboe.com/tradable_products/vix/)<img src = "https://hackmd.io/_uploads/SkUUnen2j.png" height = 150px style="float:right"/> - [臺指選擇權波動率指數](https://mis.taifex.com.tw/futures/VolatilityQuotes/) or [here](https://histock.tw/index/VIX) - VIX term structure: http://vixcentral.com/ - [CBOE VVIX](https://tw.tradingview.com/symbols/CBOE-VVIX/) - Volatility modeling - Time series models: GARCH model and its variants - Stochastic volatility (SV) models: Heston model, SABR model - Local volatility (LV) models - Stochastic local volatility (SLV) models - Empirical models: Orc wing model - https://www.taifex.com.tw/cht/4/contractAdj - **Sensitivity Analysis: Greeks** - **Option Trading** - **MISC** - Monetary policy - The Fed - Federal Open Market Committee (FOMC): https://www.cmegroup.com/cn-t/trading/interest-rates/countdown-to-fomc.html - Convertible Bonds (CB) & Convertible Bond Asset Swap (CBAS): [sinopac](https://www.sinotrade.com.tw/newweb/financial-product/CBAS/?category=%E8%A1%8D%E7%94%9F%E6%80%A7%E5%95%86%E5%93%81&categoryCode=derivative) - Asset swap option (ASO): American style. - 台灣可轉債商品一覽:https://pchome.megatime.com.tw/group/mkt1/cid55_3.html - Warrants - https://www.buywarrant.com.tw/ - https://www.hkex.com.hk/Products/Securities/Structured-Products/Derivative-Warrants-Pricing-Calculation?sc_lang=en - Structured notes - https://www.bis.org/statistics/ - https://xueqiu.com/ - https://www.jin10.com/ - https://www.dailyfxasia.com/cn/calendar <!-- ## Programming Labs ### ++Lab 1 TXF/TXO Crawler/Loader++ ### ++Lab 2 European Option Pricer++ ### ++Lab 3 Option Profiler++ --> ## **References** ### ++General Introduction++ - John C. Hull, [Options, Futures, and Other Derivatives](https://www.amazon.com/Options-Futures-Other-Derivatives-10th/dp/013447208X), 11/e, 2021 ![](https://hackmd.io/_uploads/HyQM8bhhs.png =100x) ### ++Programming Techniques/Framework for Financial Engineering++ - [pandas](https://pandas.pydata.org/) - [Matplotlib: Visualization with Python](https://matplotlib.org/) - [TA-Lib](https://github.com/mrjbq7/ta-lib) - [Backtesting.py](https://kernc.github.io/backtesting.py/)<img src = "https://hackmd.io/_uploads/B1Sn98Xy3.png" height = 150px style="float:right"/> - [QuantLib](https://www.quantlib.org/) - [QuantLib-Python](https://quantlib-python-docs.readthedocs.io/en/latest/) - [Python for Excel and Google Sheets](https://www.xlwings.org/) ### ++Volatility++ - Emanuel Derman, Michael B. Miller, and David Park, [The Volatility Smile](https://www.amazon.com/Volatility-Smile-Wiley-Finance/dp/1118959167), 2016 ![](https://i.imgur.com/OsigTVf.png =100x) - Jim Gatheral, Nassim Nicholas Taleb, [The Volatility Surface: A Practitioner's Guide](https://www.wiley.com/en-us/The+Volatility+Surface%3A+A+Practitioner%27s+Guide-p-9780471792512), 2012 ![](https://hackmd.io/_uploads/Skxm4DFL9.png =100x) - Colin Bennett, [Trading Volatility: Trading Volatility, Correlation, Term Structure and Skew](https://www.amazon.com/Trading-Volatility-Correlation-Term-Structure/dp/1499206070), 2014 ![](https://i.imgur.com/kFuLglh.png =100x) - Dan Passarelli, [Trading Option Greeks: How Time, Volatility, and Other Pricing Factors Drive Profits](https://onlinelibrary.wiley.com/doi/book/10.1002/9781118531846), 2/e, 2012 ![](https://i.imgur.com/dlGi0qa.png =100x) - Alireza Javaheri, [Inside Volatility Filtering: Secrets of the Skew](https://www.wiley.com/en-us/Inside+Volatility+Filtering:+Secrets+of+the+Skew,+2nd+Edition-p-9781118943977), 2/e, 2015 ![](https://hackmd.io/_uploads/SyNNlIIIc.png =100x) - Adam S. Iqbal, [Volatility: Practical Options Theory](https://www.wiley.com/en-us/Volatility%3A+Practical+Options+Theory-p-9781119501688), 2018 ![](https://hackmd.io/_uploads/HkYzWuvD5.png =100x) - Riccardo Rebonato, [Volatility and Correlation: The Perfect Hedger and the Fox](https://onlinelibrary.wiley.com/doi/book/10.1002/9781118673539), 2/e, 2004 ![](https://hackmd.io/_uploads/BkJaZdvP9.png =100x) - Dinabandhu Bag, [Valuation and Volatility: Stakeholder's Perspective](https://link.springer.com/book/10.1007/978-981-16-1135-3), 2022 ![](https://hackmd.io/_uploads/Hypg1L889.png =100x) ### ++Financial Mathematics++ - Tomas Björk, [Arbitrage Theory in Continuous Time](https://www.amazon.com/Arbitrage-Theory-Continuous-Oxford-Finance/dp/019957474X), 3/e, 2009 ![](https://i.imgur.com/883OCn4.png =100x) - Steven Shreve, [Stochastic Calculus for Finance I: The Binomial Asset Pricing Model](https://www.springer.com/gp/book/9780387401003), 2004 ![](https://i.imgur.com/wDR0bLU.png =100x) - Steven Shreve, [Stochastic Calculus for Finance II: Continuous-Time Models](https://www.springer.com/gp/book/9780387401010), 2004 ![](https://i.imgur.com/P64Gat4.png =100x) ### ++More Derivative Pricing++ - Damiano Brigo and Fabio Mercurio, [Interest Rate Models - Theory and Practice With Smile, Inflation and Credit](https://link.springer.com/book/10.1007/978-3-540-34604-3), 2006 ![](https://hackmd.io/_uploads/SJfSu7gyn.png =100x) - Ingo Beyna, [Interest Rate Derivatives: Valuation, Calibration and Sensitivity Analysis](https://link.springer.com/book/10.1007/978-3-642-34925-6), 2013 ![](https://hackmd.io/_uploads/S1_4_me1n.png =100x) - Andreas Bluemke, [How to Invest in Structured Products: A Guide for Investors and Asset Managers](https://www.wiley.com/en-sg/How+to+Invest+in+Structured+Products:+A+Guide+for+Investors+and+Asset+Managers-p-9780470746790), 2009 ![](https://hackmd.io/_uploads/r15BF7gy2.png =100x) - Janet M. Tavakoli, [Structured Finance and Collateralized Debt Obligations: New Developments in Cash and Synthetic Securitization](https://onlinelibrary.wiley.com/doi/book/10.1002/9781118268230), 2/e, 2008 ![](https://hackmd.io/_uploads/H107YXlyn.png =100x) - Maxime de Bellefroid, [The Derivatives Academy](https://bookdown.org/maxime_debellefroid/MyBook/), 2022 ### ++Financial Machine Learning++ - Marcos M. López de Prado, [Machine Learning for Asset Managers](https://www.cambridge.org/core/books/machine-learning-for-asset-managers/6D9211305EA2E425D33A9F38D0AE3545), 2020 ![image](https://hackmd.io/_uploads/Bk4I18746.png =100x) ### ++MISC++ - https://blog.csdn.net/hzk427/category_9701535.html - Global Association of Risk Professionals, [Financial Risk Manager (FRM®)](https://www.garp.org/frm) - [2021 FRM Study Guide](https://www.csie.ntu.edu.tw/~d00922011/python/misc/FRM-StudyGuide-092520_annotated.pdf)