Comments (7)
Hi @ElKron
Thanks for your feedback and comments. I'll start commenting below:
- All quotes are the result of querying Yahoo's free API, using
quantmod
'ssrc = '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 usingquantmod
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. - ROI: I have a similar situation. In my current role, my company gives us actions every quarter (which I don't pay). So, I add them in the Excel file as if I'd deposited and bought the actions for the same price, the same date. You could try a similar trick for those actions you sold! (I'm supposing "closed" is the same as "sold" and you received the money back into your account as cash).
- Regarding the currencies, I think it is a nice to have but will definetly take a lot of time thinking it through in a way that works for everyone. As I haven't needed it, I haven't developed or coded anything here. Feel free to clone the project and request a pull if you'd like to collaborate.
- I did not understand the dividends question. I think they are not lost anywhere. Do you have a reproducible example?
- Yes: note that when you run the
stocks_obj()
function, you'll get a list object with 3 dataframes and a list with all plots. In theportfolio
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.
from lares.
So, my homework here would be:
- Try to get a way around those outlier picks so the data returned by Yahoo's API does not get modified in anyway but the plots make sense, especially daily ROI.
Good-to-haves that I will NOT invest my time in right now:
- Logic and development around different currencies in a portfolio (may use
lares::get_currency()
when developing)
from lares.
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!
from lares.
- After debugging for a while, I think I've found the issue: actually was a consequence of the previous fix... now it should work!
- Actually that's how it was intended.. having repeated rows per day if nothing has changed doesn't add much value to the data. Now, the issue seems to be in the cumulative values, it sure is a bug.. give me some time and I'll fix that
from lares.
@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!
from lares.
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...
from lares.
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.
from lares.
Related Issues (20)
- corr_var for categorical variables? HOT 9
- link to "dummyPortfolio.xlsx" is dead HOT 1
- dplyr 1.0.8 HOT 1
- Can the target of categorical numeric variable to be treated as "regression" target HOT 3
- corr_cross plot incomplete HOT 4
- Is it possible to auto-compare different models? HOT 2
- Keep original row names when running h2o_automl HOT 4
- geom_text_repel() as substitution for geom_text() HOT 3
- Error in `dplyr::filter()`: HOT 6
- Customising (applying limits to fill scale for) corr_cross HOT 3
- lares::holidays produces empty frame HOT 11
- Getting error in corr_varr HOT 2
- error due to h2o package HOT 2
- Problem installing the package HOT 2
- holidays(countries = "Italy", years = 2022) issue HOT 1
- Terminology: Independent or dependent variable? HOT 6
- Error in `combine_vars()`: ! Faceting variables must have at least one value HOT 4
- font_exist is false if ttf file in subdir HOT 6
- robyn_performance Error in if (totals) ret <- rbind(ret, totals_base, grand_total) : the condition has length > 1 HOT 6
- broken holidays function HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lares.