The wallstreetflets Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The wallstreetflets Reference Manual

This is the wallstreetflets Reference Manual, version 1.0, generated automatically by Declt version 3.0 "Montgomery Scott" on Mon Apr 19 18:14:32 2021 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

WALL STREET FLETS

wallstreetflets (wsf) is a utility library to compute the so-called Greeks and other properties of derivative securities (specifically options) using the Black-Scholes model.

Usage

The meat and potatoes of the library are two functions:

Example

At the time of writing, MSFT is trading at $212.65 per share and the 19 Feb $190 Put has 33 days to expiry with an implied volatility of 35.19%. To compute the Greeks for this put:

CL-USER> (wsf:compute-greeks 0.3519 190 212.65 33 t)
(:DELTA -0.13178630823047255d0 :GAMMA 0.009490863086237849d0 :VEGA
 0.13654531297316355d0 :THETA -0.0727376753241109d0 :RHO
 -0.026847670995063383d0)
 
CL-USER>

Risk-Free Rate

One of the inputs to the Black-Scholes model is the "risk-free rate" which is a theoretical value. Customarily for US securities the interest rate on a US Treasury Bill with the same maturity is used as a proxy. Wallstreetflets scrapes data from the US Treasury website to calculate the risk-free rate, but in the event the website cannot be reached or scraped, a fallback rate of 0.1% is used.

Users can configure this fallback rate with the exported symbol *fallback-rate*.

Disclaimers

There might be bugs herein that might cost you money. Before investing carry out your own due diligence, including on the source code of this library.

I develop primarily on/for SBCL and occasionally test this code on CCL. No other Common Lisp implementations are tested but pull requests are welcome.


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 wallstreetflets

Author

Nathan Van Ymeren <nathan.vany@gmail.com>

License

GPL v3

Description

Wall Street FLETs: A library for calculating Options Greeks

Version

1.0

Dependencies
Source

wallstreetflets.asd (file)

Component

wallstreetflets.lisp (file)


Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 wallstreetflets.asd

Location

wallstreetflets.asd

Systems

wallstreetflets (system)


Previous: , Up: Lisp files   [Contents][Index]

3.1.2 wallstreetflets/wallstreetflets.lisp

Parent

wallstreetflets (system)

Location

wallstreetflets.lisp

Packages

wallstreetflets

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 wallstreetflets

Wall Street FLETs: Calculate Options Greeks based on scraped data

Source

wallstreetflets.lisp (file)

Nickname

wsf

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Special variables

Special Variable: *fallback-rate*
Package

wallstreetflets

Source

wallstreetflets.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Functions

Function: compute-greeks VOLATILITY STRIKE-PRICE SPOT-PRICE DAYS-TO-EXPIRY &optional PUT

Computes the Greeks for the given Option, as specified by the arguments, and returns them as a plist. The final argument is optional and if set to T (true) will compute a Put option, otherwise a Call is assumed. For a function that prints the calculated Greeks to stdout see PRINT-GREEKS

Package

wallstreetflets

Source

wallstreetflets.lisp (file)

Function: print-greeks VOLATILITY STRIKE-PRICE SPOT-PRICE DAYS-TO-EXPIRY &optional PUT

Computes the Greeks for the given Option and prints them to stdout. If you want to consume this info programmatically then you probably want the function COMPUTE-GREEKS

Package

wallstreetflets

Source

wallstreetflets.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Special variables

Special Variable: *six-sigma*
Package

wallstreetflets

Source

wallstreetflets.lisp (file)

Special Variable: *url*
Package

wallstreetflets

Source

wallstreetflets.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Functions

Function: avg A &rest REST
Package

wallstreetflets

Source

wallstreetflets.lisp (file)

Function: condition-rate-list RATE-LIST
Package

wallstreetflets

Source

wallstreetflets.lisp (file)

Function: d-one SPOT SIGMA STRIKE R DTE
Package

wallstreetflets

Source

wallstreetflets.lisp (file)

Function: d-two SIGMA DTE D1
Package

wallstreetflets

Source

wallstreetflets.lisp (file)

Function: delta D1 &optional PUT
Package

wallstreetflets

Source

wallstreetflets.lisp (file)

Function: fetch-yield-rates ()

Scrapes US Treasury Bond yields for interpolation in another function

Package

wallstreetflets

Source

wallstreetflets.lisp (file)

Function: gamma D1 SIGMA SPOT TAU
Package

wallstreetflets

Source

wallstreetflets.lisp (file)

Function: gaussian-cdf LO HI

Numeric approximation of the CDF of a gaussian/normal distribution

Package

wallstreetflets

Source

wallstreetflets.lisp (file)

Function: gaussian-pdf X

PDF of the Standard Gaussian/Normal distribution

Package

wallstreetflets

Source

wallstreetflets.lisp (file)

Function: interpolate-rate TERM

Expects a time-to-maturity/days-to-expiry value in calendar days

Package

wallstreetflets

Source

wallstreetflets.lisp (file)

Function: linear-interpolate X X0 X1 Y0 Y1
Package

wallstreetflets

Source

wallstreetflets.lisp (file)

Function: rho D2 STRIKE R TAU &optional PUT
Package

wallstreetflets

Source

wallstreetflets.lisp (file)

Function: risk-free-rate TERM
Package

wallstreetflets

Source

wallstreetflets.lisp (file)

Function: theta D1 D2 SPOT STRIKE TAU SIGMA R &optional PUT
Package

wallstreetflets

Source

wallstreetflets.lisp (file)

Function: trap-int F LO HI &key STEPS

Trapezoidal integral approximation

Package

wallstreetflets

Source

wallstreetflets.lisp (file)

Function: vega D1 SPOT TAU
Package

wallstreetflets

Source

wallstreetflets.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   W  
Index Entry  Section

F
File, Lisp, wallstreetflets.asd: The wallstreetflets․asd file
File, Lisp, wallstreetflets/wallstreetflets.lisp: The wallstreetflets/wallstreetflets․lisp file

L
Lisp File, wallstreetflets.asd: The wallstreetflets․asd file
Lisp File, wallstreetflets/wallstreetflets.lisp: The wallstreetflets/wallstreetflets․lisp file

W
wallstreetflets.asd: The wallstreetflets․asd file
wallstreetflets/wallstreetflets.lisp: The wallstreetflets/wallstreetflets․lisp file

Jump to:   F   L   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   A   C   D   F   G   I   L   P   R   T   V  
Index Entry  Section

A
avg: Internal functions

C
compute-greeks: Exported functions
condition-rate-list: Internal functions

D
d-one: Internal functions
d-two: Internal functions
delta: Internal functions

F
fetch-yield-rates: Internal functions
Function, avg: Internal functions
Function, compute-greeks: Exported functions
Function, condition-rate-list: Internal functions
Function, d-one: Internal functions
Function, d-two: Internal functions
Function, delta: Internal functions
Function, fetch-yield-rates: Internal functions
Function, gamma: Internal functions
Function, gaussian-cdf: Internal functions
Function, gaussian-pdf: Internal functions
Function, interpolate-rate: Internal functions
Function, linear-interpolate: Internal functions
Function, print-greeks: Exported functions
Function, rho: Internal functions
Function, risk-free-rate: Internal functions
Function, theta: Internal functions
Function, trap-int: Internal functions
Function, vega: Internal functions

G
gamma: Internal functions
gaussian-cdf: Internal functions
gaussian-pdf: Internal functions

I
interpolate-rate: Internal functions

L
linear-interpolate: Internal functions

P
print-greeks: Exported functions

R
rho: Internal functions
risk-free-rate: Internal functions

T
theta: Internal functions
trap-int: Internal functions

V
vega: Internal functions

Jump to:   A   C   D   F   G   I   L   P   R   T   V  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*fallback-rate*: Exported special variables
*six-sigma*: Internal special variables
*url*: Internal special variables

S
Special Variable, *fallback-rate*: Exported special variables
Special Variable, *six-sigma*: Internal special variables
Special Variable, *url*: Internal special variables

Jump to:   *  
S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   P   S   W  
Index Entry  Section

P
Package, wallstreetflets: The wallstreetflets package

S
System, wallstreetflets: The wallstreetflets system

W
wallstreetflets: The wallstreetflets system
wallstreetflets: The wallstreetflets package

Jump to:   P   S   W