Description GitHub Wiki Vignettes Functions Installation Author(s) References Examples
The ustreasuries package downloads daily Constant-Maturity Treasury (CMT) yields and provides visualizations & analytics that use that data including all the 'greeks' for derivative analysis.
https://github.com/grfiv/ustreasuries/wiki
summary Overview of package functionality
veronesi-ch02 Examples and figures from Veronesi, Ch2
cmt-rates a description of Constant Maturity and Annualized Percentage rates
yield-curves examples of downloading the data and printing yield curves for interesting periods in recent financial history.
plot-10year a plot of the 10-year from 1962 to present
utilities examples of the utility functions
black-scholes-merton examples of options pricing
Treasury Rate Data
CMTrates downloads real-time daily CMT data from 1962
PrintYieldCurves prints one or more yield curves
APY converts Constant-Maturity Treasury (CMT) yields to Annualized Percentage Yields (APY)
FedInvestData downloads real-time treasury bond price data from 2010
CoerceFedInvest_xts Turn FedInvest data into a time series
Black Scholes Merton
EuroCall Calculate the price of a European call option with or without dividends
EuroPut Calculate the price of a European put option with or without dividends
EuroCallVol Implied Volatility for a European call option
EuroPutlVol Implied Volatility for a European put option
Greeks
DeltaCall Amount call-option price changes for a change in asset price
DeltaPut Amount put-option price changes for a change in asset price
ThetaCall the decay in the value of a call or a portfolio of calls as time passes
ThetaPut the decay in the value of a put or a portfolio of puts as time passes
Gamma the change in Delta with respect to asset price
Vega the sensitivity to changes in the volatility of the underlying
RhoCall the sensitivity to changes in the risk-free rate of return
RhoPut the sensitivity to changes in the risk-free rate of return
Utility Functions
Bonds
NSzeros Convert Nelson Seigel and Svensson rates to Z(0, T)
Zbootstrap Derive Z(0, T_i) using the bootstrap method
spot_rate Derive spot rate from Z(0, T) and T
CAGR
CAGR Calculate Compound Annual Growth Rate; geometric or continuous
r_continuous Convert from discrete to continuous
r_discrete Convert from continuous to discrete
Discount Factors
discount_factor Calculate discount factor Z(t, T)
interest_rate Calculate annualized interest rate r(t, T) from a discount factor Z(t, T)
Put/Call Parity
CallParity Convert from a put-option price using put/call parity
PutParity Convert from a call-option price using put/call parity
Risk Neutral/Forwards
RiskNeutralProb Binomial tree risk-neutral probability
ForwardPrice Forward price with or without income or yield
ForwardRate Forward rate from Time1 to Time2 (discrete compounding)
Options
IntrinsicValueCall The in-the-money portion of a call option's premium
IntrinsicValuePut The in-the-money portion of a put option's premium
TimeValueCall Price = Intrinsic + Time
TimeValuePut Price = Intrinsic + Time
InTheMoneyCall Is a call in the money?
InTheMoneyPut Is a put in the money?
Equities
SP500 Daily S&P 500 data from 1950
SP500TR Daily S&P 500 Total Return data from 1988
Installed but not yet tested and documented
Digital
CashCall
CashPut
AssetCall
AssetPut
Greeks
RhoFuturesCall
RhoFuturesPut
RhoFXCall
RhoFXPut
American
American_Put_Binomial
American_Call_Dividend
## Windows users STOP: see https://github.com/hadley/devtools
install.packages("devtools")
devtools::install_github("grfiv/ustreasuries",
build_vignettes=TRUE)
## NOTE: If you get a 404 on installation, contact the author for the 'auth_token' parameter
(restart R)
George Fisher GeorgeRFisher@gmail.com
Back, K., A Course in Derivative Securities 2005 Springer Finance ISBN 9783540253734
Consiglio A. and Guirreri S.S. Simulating the Term Structure of Interest Rates with arbitrary marginals. International Journal of Risk Assessment and Management, 15(4), September 2011.
Hull, J., Options, Futures and Other Derivatives Seventh Edition 2008 Pearson/Prentice Hall ISBN 9780136015864
US Dept. of Treasury Daily Treasury Yield Curve Rates https://www.treasury.gov/resource-center/data-chart-center/interest-rates/Pages/TextView.aspx?data=yield
US Federal Reserve Board Data Download Program http://www.federalreserve.gov/datadownload/Choose.aspx?rel=H15
Varma, J. jrvFinance v1.03 https://github.com/jrvarma/jrvFinance
Veronesi P., Fixed Income Securities 2010 John Wiley & Sons ISBN 9780470109106
Wall Street Journal Market Data Center http://online.wsj.com/mdc/public/page/mdc_bonds.html?mod=mdc_topnav_2_3010
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # example of US Treasury rate data download
# =========================================
all_data <- CMTrates()
tail(all_data)
# ==================================================
# last row displayed should be for last business day
# ==================================================
# example of option pricing
# =========================
# Hull 7th edition Ch 13 P 294
Stock <- 42 # S_0
Exercise <- 40 # K
Time <- 0.50 # T
Interest <- 0.10 # r
Yield <- 0 # q
sigma <- 0.20
ans <- EuroCall(Stock, Exercise, Time, Interest, Yield, sigma)
round(ans,2) # 4.76
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.