Skip to contents

Data for four stocks since 2016-01-01.

Usage

data("four_stocks_since2016_01_01")

Format

A list with components "DELL","MSFT", "INTC", "IBM". Each component is a time series from class "xts" "zoo".

Details

Note: This dataset is temporary for use in testing, although it may appear in some examples. Eventually it may be renamed and/or replaced by other data.

Stock market data for Dell, Microsoft, Intel and IBM, from 2016-01-01 to 2020-04-17. The Dell data start from 2016-08-17. All data were downloaded from Yahoo Finance on 2020-04-18.

Source

https://finance.yahoo.com/

Examples

data(four_stocks_since2016_01_01)
DELL <- four_stocks_since2016_01_01$DELL
head(DELL)
#>            DELL.Open DELL.High DELL.Low DELL.Close DELL.Volume DELL.Adjusted
#> 2016-08-17  24.08638  24.36323 23.80953   23.80953      137600      23.80953
#> 2016-08-18  24.36323  24.36323 23.53267   23.67110      895700      23.67110
#> 2016-08-19  23.64341  24.08638 23.61573   24.08638     2400300      24.08638
#> 2016-08-22  23.80953  25.24917 23.58804   24.16944     1138300      24.16944
#> 2016-08-23  24.22481  25.41528 24.08638   24.91694      751600      24.91694
#> 2016-08-24  27.68549  27.68549 24.97231   25.24917     1280200      25.24917
tail(DELL)
#>            DELL.Open DELL.High DELL.Low DELL.Close DELL.Volume DELL.Adjusted
#> 2020-04-09     41.67     42.75    41.14      41.56     4231200         41.56
#> 2020-04-13     40.66     41.32    39.92      40.46     1740500         40.46
#> 2020-04-14     41.19     42.35    40.80      41.34     2536300         41.34
#> 2020-04-15     40.03     40.86    39.60      40.45     2087900         40.45
#> 2020-04-16     40.74     41.19    39.87      41.10     1540600         41.10
#> 2020-04-17     42.15     42.27    41.00      41.51     3242500         41.51

dell <- pcts(DELL)

head(as_datetime(dell))
#> [1] "2016-08-17 UTC" "2016-08-18 UTC" "2016-08-19 UTC" "2016-08-22 UTC"
#> [5] "2016-08-23 UTC" "2016-08-24 UTC"
head(Pctime(dell))
#> [1] "W2434 Wed" "W2434 Thu" "W2434 Fri" "W2435 Mon" "W2435 Tue" "W2435 Wed"

## Weekends are totally absent from the data,
## so a Monday-Friday sub-cycle is created:
nSeasons(dell)
#> [1] 5
dell@cycle
#> Object from class 'PartialCycle'
#>     partial cycle of 'DayWeekCycle', seasons: 1, 2, 3, 4, 5
#> Cycle start: Monday 


## there are some NA's in the data, due to Bank holidays
Pctime(c(2624, 5), pcCycle(dell))               # "W2624 Fri"
#> [1] "W2624 Fri"
as_datetime(Pctime(c(2624, 5), pcCycle(dell)))  # "2020-04-10 UTC"
#> [1] "2020-04-10 UTC"

## dell["2020-04-10 UTC"]

head(cycle(dell))
#> An object of class "PeriodicTS"
#> Slot "cycle": Start:  2434   Wednesday 
#> Cycle:  PartialCycle 
#> Number of seasons: 5 
#> 
#>       Mon Tue Wed Thu Fri
#> W2434          3   4   5 
#> W2435  1   2   3         

tail(Pctime(dell))
#> [1] "W2624 Fri" "W2625 Mon" "W2625 Tue" "W2625 Wed" "W2625 Thu" "W2625 Fri"
tail(as.Date(Pctime(dell)))
#> [1] "2020-04-10" "2020-04-13" "2020-04-14" "2020-04-15" "2020-04-16"
#> [6] "2020-04-17"