diff --git a/articles/TQ00-introduction-to-tidyquant.html b/articles/TQ00-introduction-to-tidyquant.html index ded4436c..50d732cc 100644 --- a/articles/TQ00-introduction-to-tidyquant.html +++ b/articles/TQ00-introduction-to-tidyquant.html @@ -101,7 +101,7 @@
vignettes/TQ00-introduction-to-tidyquant.Rmd
TQ00-introduction-to-tidyquant.Rmd
vignettes/TQ01-core-functions-in-tidyquant.Rmd
TQ01-core-functions-in-tidyquant.Rmd
aapl_prices <- tq_get("AAPL", get = "stock.prices", from = " 1990-01-01")
aapl_prices
-## # A tibble: 8,503 × 8
+## # A tibble: 8,524 × 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 AAPL 1990-01-02 0.315 0.335 0.312 0.333 183198400 0.264
@@ -232,7 +232,7 @@ 2.1 Yahoo! Finance## 8 AAPL 1990-01-11 0.324 0.324 0.308 0.308 211052800 0.244
## 9 AAPL 1990-01-12 0.306 0.310 0.301 0.308 171897600 0.244
## 10 AAPL 1990-01-15 0.308 0.319 0.306 0.306 161739200 0.243
-## # ℹ 8,493 more rows
+## # ℹ 8,514 more rows
Yahoo Japan stock prices can be retrieved using a similar call,
get = "stock.prices.japan"
.
@@ -250,7 +250,7 @@2.2 FRED Economic Data
wti_price_usd <- tq_get("DCOILWTICO", get = "economic.data") wti_price_usd
## # A tibble: 2,800 × 3
+## # A tibble: 2,820 × 3
## symbol date price
## <chr> <date> <dbl>
## 1 DCOILWTICO 2013-01-01 NA
@@ -263,7 +263,7 @@ 2.2 FRED Economic Data## 8 DCOILWTICO 2013-01-10 93.8
## 9 DCOILWTICO 2013-01-11 93.6
## 10 DCOILWTICO 2013-01-14 94.3
-## # ℹ 2,790 more rows
+## # ℹ 2,810 more rows
## # A tibble: 129 × 2
+## # A tibble: 130 × 2
## date `WTI Price`
## <date> <dbl>
## 1 2013-01-31 97.6
@@ -605,7 +605,7 @@ Working with non-OHLC data## 8 2013-08-30 108.
## 9 2013-09-30 102.
## 10 2013-10-31 96.3
-## # ℹ 119 more rows
+## # ℹ 120 more rows
vignettes/TQ02-quant-integrations-in-tidyquant.Rmd
TQ02-quant-integrations-in-tidyquant.Rmd
vignettes/TQ03-scaling-and-modeling-with-tidyquant.Rmd
TQ03-scaling-and-modeling-with-tidyquant.Rmd
tq_index("DOW")
## # A tibble: 31 × 8
+## # A tibble: 32 × 8
## symbol company identifier sedol weight sector shares_held local_currency
## <chr> <chr> <chr> <chr> <dbl> <chr> <dbl> <chr>
-## 1 UNH UNITEDHEALT… 91324P102 2917… 0.101 - 5477820 USD
-## 2 MSFT MICROSOFT C… 594918104 2588… 0.0632 - 5477820 USD
-## 3 GS GOLDMAN SAC… 38141G104 2407… 0.0626 - 5477820 USD
-## 4 HD HOME DEPOT … 437076102 2434… 0.0589 - 5477820 USD
-## 5 CAT CATERPILLAR… 149123101 2180… 0.0534 - 5477820 USD
-## 6 AMGN AMGEN INC 031162100 2023… 0.0523 - 5477820 USD
-## 7 MCD MCDONALD S … 580135101 2550… 0.0506 - 5477820 USD
-## 8 V VISA INC CL… 92826C839 B2PZ… 0.0454 - 5477820 USD
-## 9 CRM SALESFORCE … 79466L302 2310… 0.0400 - 5477820 USD
-## 10 BA BOEING CO/T… 097023105 2108… 0.0369 - 5477820 USD
-## # ℹ 21 more rows
+## 1 UNH UNITEDHEALT… 91324P102 2917… 0.106 - 5339472 USD
+## 2 MSFT MICROSOFT C… 594918104 2588… 0.0675 - 5339472 USD
+## 3 GS GOLDMAN SAC… 38141G104 2407… 0.0602 - 5339472 USD
+## 4 HD HOME DEPOT … 437076102 2434… 0.0563 - 5339472 USD
+## 5 AMGN AMGEN INC 031162100 2023… 0.0526 - 5339472 USD
+## 6 MCD MCDONALD S … 580135101 2550… 0.0520 - 5339472 USD
+## 7 CAT CATERPILLAR… 149123101 2180… 0.0484 - 5339472 USD
+## 8 V VISA INC CL… 92826C839 B2PZ… 0.0466 - 5339472 USD
+## 9 CRM SALESFORCE … 79466L302 2310… 0.0399 - 5339472 USD
+## 10 BA BOEING CO/T… 097023105 2108… 0.0365 - 5339472 USD
+## # ℹ 22 more rows
…or, get an exchange.
tq_exchange("NYSE")
## # A tibble: 8,118 × 15
+## # A tibble: 8,181 × 15
## symbol company identifier sedol weight sector shares_held local_currency
## <chr> <chr> <chr> <chr> <dbl> <chr> <dbl> <chr>
-## 1 UNH UNITEDHEALT… 91324P102 2917… 0.101 - 5477820 USD
-## 2 UNH UNITEDHEALT… 91324P102 2917… 0.101 - 5477820 USD
-## 3 UNH UNITEDHEALT… 91324P102 2917… 0.101 - 5477820 USD
-## 4 UNH UNITEDHEALT… 91324P102 2917… 0.101 - 5477820 USD
-## 5 UNH UNITEDHEALT… 91324P102 2917… 0.101 - 5477820 USD
-## 6 UNH UNITEDHEALT… 91324P102 2917… 0.101 - 5477820 USD
-## 7 UNH UNITEDHEALT… 91324P102 2917… 0.101 - 5477820 USD
-## 8 UNH UNITEDHEALT… 91324P102 2917… 0.101 - 5477820 USD
-## 9 UNH UNITEDHEALT… 91324P102 2917… 0.101 - 5477820 USD
-## 10 UNH UNITEDHEALT… 91324P102 2917… 0.101 - 5477820 USD
-## # ℹ 8,108 more rows
+## 1 UNH UNITEDHEALT… 91324P102 2917… 0.106 - 5339472 USD
+## 2 UNH UNITEDHEALT… 91324P102 2917… 0.106 - 5339472 USD
+## 3 UNH UNITEDHEALT… 91324P102 2917… 0.106 - 5339472 USD
+## 4 UNH UNITEDHEALT… 91324P102 2917… 0.106 - 5339472 USD
+## 5 UNH UNITEDHEALT… 91324P102 2917… 0.106 - 5339472 USD
+## 6 UNH UNITEDHEALT… 91324P102 2917… 0.106 - 5339472 USD
+## 7 UNH UNITEDHEALT… 91324P102 2917… 0.106 - 5339472 USD
+## 8 UNH UNITEDHEALT… 91324P102 2917… 0.106 - 5339472 USD
+## 9 UNH UNITEDHEALT… 91324P102 2917… 0.106 - 5339472 USD
+## 10 UNH UNITEDHEALT… 91324P102 2917… 0.106 - 5339472 USD
+## # ℹ 8,171 more rows
## # ℹ 7 more variables: date <date>, open <dbl>, high <dbl>, low <dbl>,
## # close <dbl>, volume <dbl>, adjusted <dbl>
You can use any applicable “getter” to get data for every
@@ -426,7 +426,7 @@ Analyze a Single Stock##
## Coefficients:
## (Intercept) year(date)
-## 58.86280 -0.02915
+## 58.86279 -0.02915
We can utilize the broom
package to get “tidy” data from
the model. There’s three primary functions:
We can now apply our analysis function to the stocks using
dplyr::mutate()
and purrr::map()
. The
mutate()
function adds a column to our tibble, and the
@@ -518,15 +518,14 @@
## # A tibble: 5 × 7
-## # Groups: symbol, company [5]
+## # A tibble: 4 × 7
+## # Groups: symbol, company [4]
## symbol company data estimate std.error statistic p.value
## <chr> <chr> <list> <dbl> <dbl> <dbl> <dbl>
-## 1 IEX IDEX CORP <tibble> 0.0178 0.0264 0.673 0.520
-## 2 FRT FEDERAL REALTY INVS TRUST <tibble> 0.0170 0.0165 1.03 0.334
-## 3 ALLE ALLEGION PLC <tibble> 0.0157 0.0850 0.185 0.870
-## 4 VRSN VERISIGN INC <tibble> 0.00669 0.0411 0.163 0.875
-## 5 PXD PIONEER NATURAL RESOURCE… <tibble> 0.00664 0.0686 0.0969 0.925
+## 1 ALLE ALLEGION PLC <tibble> 0.0157 0.0850 0.185 0.870
+## 2 IRM IRON MOUNTAIN INC <tibble> 0.0137 0.0300 0.458 0.659
+## 3 PSX PHILLIPS 66 <tibble> -0.0978 0.0530 -1.84 0.162
+## 4 NCLH NORWEGIAN CRUISE LINE HO… <tibble> -0.209 0.0823 -2.53 0.127
We’re done! We now have the coefficient of the linear regression that tracks the direction of the trend line. We can easily extend this type of analysis to larger lists or stock indexes. For example, the entire @@ -585,7 +584,7 @@
## # A tibble: 5,412 × 8
+## # A tibble: 5,454 × 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 AAPL 2013-01-02 19.8 19.8 19.3 19.6 560518000 16.8
@@ -598,7 +597,7 @@ Bad Apples Fail Gracefully, tq_get## 8 AAPL 2013-01-11 18.6 18.8 18.5 18.6 350506800 15.9
## 9 AAPL 2013-01-14 18.0 18.1 17.8 17.9 734207600 15.3
## 10 AAPL 2013-01-15 17.8 17.8 17.3 17.4 876772400 14.9
-## # ℹ 5,402 more rows
+## # ℹ 5,444 more rows
Now switching complete_cases = FALSE
will retain any
errors as NA
values in a nested data frame. Notice that the
error message and output change. The error message now states that the
@@ -612,7 +611,7 @@
## # A tibble: 5,413 × 8
+## # A tibble: 5,455 × 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 AAPL 2013-01-02 19.8 19.8 19.3 19.6 560518000 16.8
@@ -625,7 +624,7 @@ Bad Apples Fail Gracefully, tq_get## 8 AAPL 2013-01-11 18.6 18.8 18.5 18.6 350506800 15.9
## 9 AAPL 2013-01-14 18.0 18.1 17.8 17.9 734207600 15.3
## 10 AAPL 2013-01-15 17.8 17.8 17.3 17.4 876772400 14.9
-## # ℹ 5,403 more rows
+## # ℹ 5,445 more rows
In both cases, the prudent user will review the warnings to determine
what happened and whether or not this is acceptable. In the
complete_cases = FALSE
example, if the user attempts to
diff --git a/articles/TQ03-scaling-and-modeling-with-tidyquant_files/figure-html/unnamed-chunk-15-1.png b/articles/TQ03-scaling-and-modeling-with-tidyquant_files/figure-html/unnamed-chunk-15-1.png
index 1028f6f6..6ca0cbf2 100644
Binary files a/articles/TQ03-scaling-and-modeling-with-tidyquant_files/figure-html/unnamed-chunk-15-1.png and b/articles/TQ03-scaling-and-modeling-with-tidyquant_files/figure-html/unnamed-chunk-15-1.png differ
diff --git a/articles/TQ04-charting-with-tidyquant.html b/articles/TQ04-charting-with-tidyquant.html
index 36fb2f97..f2e33fdb 100644
--- a/articles/TQ04-charting-with-tidyquant.html
+++ b/articles/TQ04-charting-with-tidyquant.html
@@ -101,7 +101,7 @@
vignettes/TQ04-charting-with-tidyquant.Rmd
TQ04-charting-with-tidyquant.Rmd
vignettes/TQ05-performance-analysis-with-tidyquant.Rmd
TQ05-performance-analysis-with-tidyquant.Rmd
Dancho M, Vaughan D (2023). tidyquant: Tidy Quantitative Financial Analysis. -https://business-science.github.io/tidyquant/, https://github.com/business-science/tidyquant. +R package version 1.0.7.9000, https://github.com/business-science/tidyquant, https://business-science.github.io/tidyquant/.
@Manual{, title = {tidyquant: Tidy Quantitative Financial Analysis}, author = {Matt Dancho and Davis Vaughan}, year = {2023}, - note = {https://business-science.github.io/tidyquant/, https://github.com/business-science/tidyquant}, + note = {R package version 1.0.7.9000, https://github.com/business-science/tidyquant}, + url = {https://business-science.github.io/tidyquant/}, }