-
-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In getDividends have option to not append .div to the column name #369
Comments
Thanks for the suggestion. Whatever we do here should be done for |
This allows the user to specify a custom column name, instead of the default being hard-coded to the symbol + .div or .spl. Fixes #369.
Please try the change on the stocks <- c("AAPL", "MMM", "CAT", "MSFT", "TSLA")
map_dfr(stocks, \(x) getDividends(x, colname = x) |>
fortify.zoo(melt = TRUE, names = c("date", "name", "div")) |>
tail(2))
## date name div
## 1 2022-08-05 AAPL 0.23
## 2 2022-11-04 AAPL 0.23
## 3 2008-02-20 MMM 0.50
## 4 2022-11-17 MMM 1.49
## 5 2020-01-17 CAT 1.03
## 6 2023-01-19 CAT 1.20
## 7 2022-08-17 MSFT 0.62
## 8 2022-11-16 MSFT 0.68
|
That presumably would work but does have the disadvantage that it is not ideal with pipes since x had to be repeated requiring that it be put in a function. |
Good point. What do you think about changing the arg to "AAPL" |> quantmod::getSplits(suffix = "")
AAPL
1987-06-16 0.5000000
2000-06-21 0.5000000
2005-02-28 0.5000000
2014-06-09 0.1428571
2020-08-31 0.2500000 |
Give the user opportunity to remove the ".div" or ".spl" suffix from the symbol column name, rather than require they specify the entire column name. See #369.
@ggrothendieck what do you think of the latest commit on this branch? R$ "AAPL" |> quantmod::getSplits(colname.suffix = "")
AAPL
1987-06-16 0.5000000
2000-06-21 0.5000000
2005-02-28 0.5000000
2014-06-09 0.1428571
2020-08-31 0.2500000
R$ "AAPL" |> quantmod::getDividends(colname.suffix = "") |> head()
AAPL
1987-05-11 0.000536
1987-08-10 0.000536
1987-11-17 0.000714
1988-02-12 0.000714
1988-05-16 0.000714
1988-08-15 0.000714 |
@ggrothendieck any feedback on this before I merge? |
Currently
getDividends
is hard coded to append.div
to the column name. Would like to be able to specify name. Maybe name = "%s.div" if you wanted it and that could be the default or "%s" if not or "div" if you wanted name to be literally div.In that case this could be simplified:
to
The text was updated successfully, but these errors were encountered: