The Option-Graph Project Option-Graph.com

The timeleft() Visual Basic Function

     The Black-Scholes option model needs to know the remaining life of an options contract, expressed as a fraction of a year.

     That is the purpose of the timeleft() function. It determines the number of days between two dates such as the Entry Date and the Expiration Date, and divides by 365 to express those days as a fraction of a year.

     Copy and paste the code below into the OptionCalcs module, below the words "end function" of the NORMSDIST() function. Save your Project.

Function timeleft(ByVal dte1 As Date, ByVal dte2 As Date) As Single

'takes the current date and the expiration date, and returns the time remaining as a fraction of a year

Dim daysleft As Integer = DateDiff(DateInterval.Day, dte1, dte2)

Return daysleft / 365

End Function

    

Home Page Downloads
Previous Step: The NORMSDIST() Visual Basic Function
Next Step: The changeexpiration() Function

Copyright 2017 option-info.com Privacy Policy

Questions, corrections, suggestions, comments to: this contact

Want to learn options, find strategies? Visit www.option-info.com