Package 'bdscale'

Title: Remove Weekends and Holidays from ggplot2 Axes
Description: Provides a continuous date scale, omitting weekends and holidays.
Authors: Dave Mills [aut, cre]
Maintainer: Dave Mills <[email protected]>
License: GPL-2
Version: 2.0.0
Built: 2024-11-22 03:20:57 UTC
Source: https://github.com/dvmlls/bdscale

Help Index


Date breaks corresponding to the first trading day of standard periods

Description

The periods are:

  • years

  • quarters

  • months

  • weeks

  • days

Usage

bd_breaks(business.dates, n.max = 5)

Arguments

business.dates

a vector of Date objects, sorted ascending

n.max

the maximum number of breaks to return

Value

returns a function function: max => [date range] => breaks that generates the breaks for the interval with the largest number of breaks less than n.max


Transform Dates into your business-date scale.

Description

Transform Dates into your business-date scale.

Usage

bd2t(dates, business.dates)

Arguments

dates

a Date vector for which you want to transform each date into an integer t which is the number of business days after the first date in your business.dates vector

business.dates

a vector of Date objects, sorted ascending

Value

returns an integer vector where each element is the number of business days t after the first date in your business.dates vector

Examples

monday <- as.Date('2014-10-13')
weekdays <- monday + 0:4
bd2t(monday + c(1, 3), weekdays)

Trading dates for the New York Stock Exchange extracted from the close prices of the S&P 500.

Description

Trading dates for the New York Stock Exchange extracted from the close prices of the S&P 500.

Usage

nyse

Format

A vector of 16657 Date objects, starting on 1950-01-03 and ending on 2016-03-15

Source

https://finance.yahoo.com/q/hp?s=SPY+Historical+Prices


Weekend- and holiday-ignoring position scale for a ggplot.

Description

Weekend- and holiday-ignoring position scale for a ggplot.

Usage

scale_x_bd(..., business.dates, max.major.breaks = 5,
  max.minor.breaks = max.major.breaks * 5,
  breaks = bd_breaks(business.dates))

Arguments

...

other arguments passed to continuous_scale

business.dates

a vector of Date objects, sorted ascending

max.major.breaks

maximum major breaks bd_breaks will return, default=5

max.minor.breaks

maximum minor breaks bd_breaks will return, default=major*5

breaks

a function max => [date range] => breaks

Examples

## Not run: 
 ggplot(ts, aes(x=date, y=price)) + 
   scale_x_bd(business.dates=yahoo('SPY'), max.major.breaks=10, labels=date_format("%b '%y"))

## End(Not run)

Get past trading days using close prices of supplied ticker

Description

Get past trading days using close prices of supplied ticker

Usage

yahoo(ticker = "^GSPC")

Arguments

ticker

The ticker you want to use, defaults to S&P 500: ^GSPC

Value

returns a vector of Dates