Closed ElKron closed 4 years ago
Hi @ElKron Thanks for your feedback and comments. I'll start commenting below:
quantmod
's src = 'yahoo'
. Google Finance stopped providing data in March, 2018 so that wouldn't be an option. And the other ones available are paid or need further settings, thus I'd recommend using quantmod
library instead. So, the quote values are never changed inside the library. I'll try to check those outlier picks and see a logical way to skip them.stocks_obj()
function, you'll get a list object with 3 dataframes and a list with all plots. In the portfolio
dataframe, you'll have your daily ROI, Portfolio overall balance with and without Cash, etc.
> lapply(dft, names)
$quotes
[1] "Date" "Symbol" "Value" "Div" "DivReal"
$stocks
[1] "Date" "Symbol" "Value" "Quant" "Each" "Invested" "Cost"
[8] "Dividend" "CumValue" "CumInvested" "CumROI" "CumQuant" "DifUSD" "CumDividend"
[15] "CumCost" "Weight" "Type"
$portfolio
[1] "Date" "CumInvested" "CumValue" "CumCost" "CumDividend" "ROI" "Invested"
[8] "Dividend" "Cash" "DifUSD" "CumCash" "Portfolio"
$plots [1] "roi1" "roi2" "growth" "summary" "change1" "change2" "types"
- And for your last question, I'd simply add those up in the transactions tab with a minus. So instead of deposits, those costs would be negative deposits.
So, my homework here would be:
Good-to-haves that I will NOT invest my time in right now:
lares::get_currency()
when developing)Thank you for all the help!
I have 2 follow-up concerns:
For the dividend issue (dividends not present in the data or portfolio value), I added an example portfolio. BPOST.BR is a dividend-paying stock which is registered when downloading the ticker data from Yahoo. However, subsequently it is lost in the mutate
calculations.
When ticker data is not available/complete on a date of transaction, that transaction is not registered in the tool. As an example, see the tracker in the same dummy portfolio. Yahoo does not give data on the latest transaction date causing it to not to be registered in the tool even when later data is available. The stocks dataframe indicates that 500 shares of the tracker are the latest quantity instead of the supposed 1500 including the latest transaction. I understand that portfolio/stock value is not available or incomplete for dates where Yahoo is incomplete. But is it possible to make the cumulative amount of shares still consistent over later dates?
Code you can use to check the above:
library(lares)
df <- stocks_file(filename = "PortfolioDummy.xlsx")
df$transactions$Date <- as.Date(df$transactions$Date)
str(df$transactions)
dfp <- stocks_obj(df)
dfp$stocks
In any case, thank you for your time and help!
@ElKron done! With the latest fix, you should have the correct cumulative value even though for some days you have no quotes over some of the stocks. Cheers and thanks for reporting this case!
@laresbernardo ,
The dividends work like a charm indeed! Many thanks!
The cumulative stock quantity however is not yet fully fixed (see previous example Excel). The issue lies in the following line
daily <- hist %>% left_join(trans, by = c("Date", "Symbol"))
If the history does not contain the same date for a specific symbol as is present in the transaction data, the quantity sold or bought will not show up in the daily
dataframe. Maybe another join function (full_join?) might help, but then the follow-up data wrangling code needs adjustments.
I do understand that you don't want repeated rows though.
Sorry to bother you with these tedious bugs and thanks for all the help...
Ok, please do check again. Should be fixed by now to work with your portfolio @ElKron
A full_join
wouldn't work. I did an expand.grid
over all dates and existing Symbols so every day has all possible tickers, and tidyr::fill
ed up the values.
Hi Bernardo,
I tried out your portfolio performance functions. The graphs are very useful in conjunction with the automatic data scraping and processing. I have some questions and uncovered some issues you could have a look at if you have the time. I also have some suggestions for functionality but will put that in a separate issue,
Issues:
Questions:
Sorry for the long post. Thank you for all the help!
ElKron