Questions tagged [tidyquant]

The R tidyquant package makes it easy to use common financial data analysis packages such as xts, zoo, and quantmod along with tidyverse data manipulation packages such as dplyr, tidyr, and purrr.

's tidyquant package brings financial analysis to the tidyverse. The tidyquant package provides a convenient wrapper to various , , and package functions and returns the objects in the tidy tibble format. The main advantage is being able to use quantitative functions with the tidyverse functions including , , , , , etc. See the tidyquant website for more information, documentation and examples.

Repositories

Detailed HTML vignettes

Other resources

Related tags

93 questions
0
votes
1 answer

how to fix error in for loop for quantmod

I write a for loop in order to use getDividends() function from quantmod library. I want to read the symbol and the date of buy from a dataframe and use them to download the dividends from a specific year this is my tibble "div_dummy" symbol shares…
salvo
  • 11
  • 2
0
votes
0 answers

How to retrieve the coefficients which calculated by rolling lm() function

Using function slidify() in package timetk to create lm_roll(), how to retrieve the coefficients calculated by lm_roll() and calculate slope ? Below code , the last muate can't work . Thanks! library(timetk) library(tidyverse) …
anderwyang
  • 1,801
  • 4
  • 18
0
votes
1 answer

Assign columns to new datasets with a for loop

I tried to do a for loop to assign firms to different funds. I've created a dataset of 2000 different companies. Now I would like to assign the first 50 to fund1, the next 50 to fund2 and so on. Fund <- list() for (i in seq(1, 1950, 50)) { …
Rafael
  • 1
  • 1
0
votes
1 answer

How can I use R to download the stock price at a particular date based on the company name from Master Index

I'm struggling to download the stock price in R. Here are my questions. I used getMasterIndex to download the MasterIndex of all SEC filings and filter 10-k reports (I only need 10-k reports for analysis) I need to use the company.name from the…
0
votes
1 answer

EOMONTH returning NA

In the code below, the first call to the EOMONTH function returns NA when I expect February 28, 2019. The second call works correctly. Both calls work correctly in Excel which this function is trying to replicate. Is this a bug or am I doing…
rmacey
  • 599
  • 3
  • 22
0
votes
0 answers

Only 'grobs' allowed in 'gList' error when calling grid.arrange inside a for loop

I'm trying to plot a price series and a return series using grid.arrange inside a for loop: The set up: library(tidyquant) start_date <- as.Date('2022-01-01') end_date <- as.Date('2022-03-31') assets_list <- c('DGS30', 'T10Y2Y') for (asset in…
equanimity
  • 2,371
  • 3
  • 29
  • 53
0
votes
1 answer

Error when updating a dataframe with new column inside a for loop using Dplyr

I have the following R dataframe df: library(tidyquant) start_date <- as.Date('2022-01-01') end_date <- as.Date('2022-03-31') assets_list <- c('DGS30', 'T10Y2Y') for (asset in assets_list){ assign(paste('sym', asset, sep = '_'),…
equanimity
  • 2,371
  • 3
  • 29
  • 53
0
votes
1 answer

adding more standard deviations to a plot

I'm trying to add more standard deviation to my current plot. I need to add 1std and 3std, I've already addeed the 2std to my plot. This is my code: tidyverse_downloads_rollmean <- treasury %>% tq_mutate( # tq_mutate args select =…
Jose Montoya
  • 147
  • 1
  • 10
0
votes
1 answer

Rename() function in R not working with Dplyr pipe inside for loop

I retrieve a bunch of data using the Tidyquant API, as follows: library(tidyquant) symbols_list <- c('DGS2', 'DGS5', 'DGS10', 'DGS30') start_date <- as.Date('2022-01-01') end_date <- as.Date('2022-03-31') for (asset in symbols_list){ #…
equanimity
  • 2,371
  • 3
  • 29
  • 53
0
votes
0 answers

How I can change dynamically the frequency of data in r/shiny?

Hi an thanks for reading me. I am currently working on a small app that displays a simple time series chart, but I would like it to dynamically change the aggregation of the data. I'm trying the Tidyquant function, but it's giving me an error…
0
votes
0 answers

Custom function returning unused argument

I am trying to learn a little more about how to optimize repeated operations. I have created the following example which generates a random little time series data frame to plot the rolling 7-day average for 3 different…
Ollie
  • 69
  • 5
0
votes
0 answers

How to rename column with tq_mutate

When I use tq_transmute, I am able to rename all the columns. When I use tq_mutate, only the first 2 columns are getting renamed. The last two columns remain as it is. Is this a limitation, or am I missing something to fix for tq_mutate? In the…
junkone
  • 1,427
  • 1
  • 20
  • 45
0
votes
1 answer

Calculating rolling Beta

I'm trying to generate rolling betas for stocks and my rolling function is not working. What I have tried so far: library(tidyquant) library(tidyverse) library(tibbletime) ticker_data <- tq_get(c("AAPL", "SPY")) daily_returns <- ticker_data %>% …
cephalopod
  • 1,826
  • 22
  • 31
0
votes
2 answers

Moving averages appear to be calculating from the most recent date backwards using geom_ma

Moving averages appear to be plotting from right to left on my timeseries. Here is my code: library(Quandl) library(ggplot2) # Get Historical Futures Prices: Crude Oil Futures from Quandl. Contract Code is CL CME_CL_Data <- Quandl('CHRIS/CME_CL1',…
0
votes
1 answer

RSI is different in R vs Yahoo Finance/TradingView

The RSI calculated in R is different than that I see in Yahoo-Finance. Yahoo-Finance documentation says it uses SMA and close. I done the same in R but the values don't match. I am not sure which one to trust. I tried both close & Adjusted…
Aman J
  • 1,825
  • 1
  • 16
  • 30