Black Scholes and Option Greeks in Python
文章推薦指數: 80 %
Implement Black-Scholes Model using Opstrat ... Opstrat is a python package which deals with options. This package can be used to determine option pricing as well ... SigninAboutSubmitDDIntelDDIChatDDImarioStartHereBlackScholesandOptionGreeksinPythonImplementingBlack-ScholesOptionPricingModelusingOpstratpackageinpythonAbhijithChandradasFollowJun30·4minreadWhatisBlack-ScholesModel?TheBlack-Scholesmodel,alsoknownastheBlack-Scholes-Merton(BSM)model,isamathematicalmodelusedtodeterminethefairpricesofoptionscontract.ThemodelowesitsnametoeconomistsFischerBlackandMyronScholes.RobertC.Mertonwasthefirsttopublishapaperexpandingthemathematicalunderstandingoftheoptionspricingmodel,andcoinedtheterm“Black–Scholesoptionspricingmodel”.ThemodelrevolutionizedfinanciallandscapeandearnedMertonandScholestheNobelMemorialPrizeinEconomicSciencesin1997.InputsrequiredforBSMThemodelutilizesthefollowingfiveinputstopredictthepriceofoption(C):i.Currentprice(Spotprice)oftheAsset(St)ii.Strike/Exerciseprice(K)iii.RiskFreeRate(r)iv.Timetoexpiration(t)v.Volatility(σ)Black-ScholesModelforEuropeanCall(ImagebyAuthor)Nintheaboveequationdenotesstandardnormaldistribution.Theaboveistheequationforcalloptionpricing,putoptionformulaisslightlydifferentfromtheabove.Black-ScholesModelforEuropeanPut(ImagebyAuthor)NotethatBlack-ScholesModelisonlyusedtopriceEuropeanoptionsasitdoesnottakeintoaccountthatU.S.optionscouldbeexercisedbeforetheexpirationdate.Themodelalsodoesnottakeintoaccounttheeffectofdividendonpricing.ImplementBlack-ScholesModelusingOpstratOpstratisapythonpackagewhichdealswithoptions.Thispackagecanbeusedtodetermineoptionpricingaswellasvisualizeoptionpayoffs.Ifyouarenewtooptions,visualizingoptionpayoffscanbeagoodstartingpoint.Youcancheckoutthebelowarticleonhowtovisualizeoptionpayoffsusingopstrat.VisualizingOptionTradingStrategiesinPythonAwalk-throughofhowtoplotoptionpayoffdiagramsusingopstratpackageinpythonmedium.datadriveninvestor.comOptionvaluescanbecalculatedbyusingtheblack_scholes()functionfromopstrat.Allinputsrequiredforthemodelhavetobepassedinasarguments.Inadditiontotheaboveinputs,typeofoptionhastobespecifiedusingtypeparameter-‘c’forcalloptionand‘p’forputoption.#ImportLibrariesimportopstratasop#DeclareparametersK=200#spotpriceSt=208#currentstockpricer=4#4%riskfreeratet=30#timetoexpiry,30daysv=20#volatilitytype='c'#Optiontypecall#BlackScholesModelbsm=op.black_scholes(K=K,St=St,r=r,t=t,v=v,type='c')Thefunctionreturnsadictionarywithvalueandgreeksaskeys.Optionvaluecanbeaccessedbyusingvalueaskey.bsm['value']Output:{'optionvalue':10.210518559926442,'intrinsicvalue':8,'timevalue':2.2105185599264416}Theoutputisadictionarycontainingoptionvalueanditscomponents-timevalueandintrinsicvalue.Therequiredvaluecanbeaccessedbyusingtherespectivekey.bsm['value']['optionvalue']Output:10.210518559926442WhatareOptionGreeks?OptionGreeksareasetofriskmeasuressonamedaftertheGreeklettersthatdenotethem.ThesefiveprimaryGreekriskmeasuresareknownasanoption’stheta,vega,delta,gammaandrho.Greeksindicatehowsensitiveanoptionistotime-valuedecay,changesinimpliedvolatility,riskfreerate,andmovementsinthepriceitsunderlyingsecurity.Delta:MeasuresImpactofaChangeinthePriceofUnderlyingGamma:MeasurestheRateofChangeofDeltaTheta:MeasuresImpactofaChangeinTimeRemainingVega:MeasuresImpactofaChangeinVolatilityRho:MeasurestheimpactofchangesinInterestratesGreekscanbeobtainedfromtheoutputofblack_scholesfunctionbyusing‘greeks’key.bsm['greeks']Output:{'delta':0.7793593241701937,'gamma':0.024868265088898882,'theta':-0.07559961986526405,'vega':0.17686037602292404,'rho':0.12484620893217029}Individualgreekcanbeobtainedbypassingthegreeknameaskeytotheabovedictionary.bsm['greeks']['theta']Output:-0.07559961986526405Resources:NotebookforthearticleandmoreexamplescanbeobtainedfrommyGitHubrepo.BecomeaMemberIhopeyoulikethearticle,IwouldhighlyrecommendsigningupforMediumMembershiptoreadmorearticlesbymeorstoriesbythousandsofotherauthorsonvarietyoftopics.Yourmembershipfeedirectlysupportsmeandotherwritersyouread.You’llalsogetfullaccesstoeverystoryonMedium.Otherarticlesbytheauthoryoumayfindinteresting:StockMarketDataVisualizationUsingMplfinanceHowtoobtainstockmarketdataandcreatevisualizations(candlestick,OHLC,PnFetc.)inPythonusingmplfinance…medium.comAllyouneedtoknowaboutyfinance:Yahoo!FinanceLibraryAcompletestep-by-steptutorialonhowtouseYahooFinancePackageforpython-yfinance,toobtainsharepriceand…medium.comPhotobyScottGrahamonUnsplashDataDrivenInvestorempowermentthroughdata,knowledge,andexpertise.Follow73ThankstoTDSEditors. BlackScholesPythonOptionsGreeksPricing73 claps73WrittenbyAbhijithChandradasFollowDataAnalyst|Hacker|FinancialAnalyst|Freelancer|IIMMBA|Opensource|DemocratizeKnowledge|https://www.youtube.com/channel/UCLpBd4gzfIBXm2BPpdHOWdQFollowDataDrivenInvestorFollowempowermentthroughdata,knowledge,andexpertise.subscribetoDDIntelathttps://ddintel.datadriveninvestor.comFollowWrittenbyAbhijithChandradasFollowDataAnalyst|Hacker|FinancialAnalyst|Freelancer|IIMMBA|Opensource|DemocratizeKnowledge|https://www.youtube.com/channel/UCLpBd4gzfIBXm2BPpdHOWdQDataDrivenInvestorFollowempowermentthroughdata,knowledge,andexpertise.subscribetoDDIntelathttps://ddintel.datadriveninvestor.comMoreFromMedium3.3LsmallformfactorcaseSFFMykolaLytvynchukPayFacasaService:13QuestionsYouMustHaveAnswersToWayneAkeyWhyCleanCodeisEmpatheticCodeKarenWhiteinBigCommerceDeveloperBlogGoogleHasaSecretHiringChallengeCalledFoobarFabianBoslerinBetterProgrammingLifeShatteredasCovidsecondWavehitstheWorldBreakoleeDecreaseaDiskSizeonAzureVMPauloNunesDeveloponKubernetesSeries — OperatorDev — UnderstandingandDissectingKubebuilderYashvardhanKukrejaGameDevDigestIssue#77 — ModellingandmoreGameDevDigest
延伸文章資訊
- 1Python Black-Scholes Model and the Basics of Option Pricing
Let St be the price of a stock at time t. The Black-Scholes model is based on the Geometric Brown...
- 2Black-Scholes Formula and Python Implementation - Aaron ...
The Black-Scholes model was first introduced by Fischer Black and Myron Scholes in 1973 in the pa...
- 3Pricing Options with Black-Scholes in Python - LinkedIn
Further developments have been made to this formula with Merton and the inclusion of dividend yie...
- 4Black Scholes and Option Greeks in Python
Implement Black-Scholes Model using Opstrat ... Opstrat is a python package which deals with opti...
- 5Option pricing using the Black-Scholes model, without the ...
Black-Scholes PDE. We will solve this equation numerically, using Python. The main advantage of t...