Comments (11)
Hi tarioch,
Yes. This is in fact one of my top wished feature. I would like to know, what is my return of investment in yearly basic. i.e., am I getting 20% return every year?
To calculate return,
net worth end of the year - net worth beginning of the year
To calculate net worth, we need to take consideration into
- Stock holding value
- Profit generated from stock sales
- Received dividend
Thing doesn't straight forward. We need some proper planning before kick start on this feature.
from jstock.
Here's the trello card : https://trello.com/c/E0pvlWqT
from jstock.
I found a java implementation for xirr, might come in handy: https://github.com/ept/jxirr
Correct me if I'm wrong but what works quite well is every transaction is listed with the value, e.g.
-1000 buy stock
+200 dividend
+500 sell stock
-1000 buy stock
+2000 current stock value
(internal transactions such as splits, direct reinvestment and so on can be ignored)
now using the dates of the transactions, using xirr on this works quite well for me in a spreadsheet.
from jstock.
In fact, this is one of my top wishlist features. My ideal case is drawn in the following picture.
from jstock.
Here are some more thoughts and a possible way to do it.
xirr takes into account the actual dates of value relevant actions and computes an interest rate, basically it tells me if, instead of investing in a stock, I would have put the same money transactions into an account, what would have been the interest rate of the account.
Could your chart be done like this:
Dividend gain rate
xirr with
-buy transaction: cash value
-sell transaction: purchase value (not cash value)
-not directly reinvested dividend: cash value
-purchase value at end (not market value)
That way only dividend profits should be taken into account
Sales gain rate
xirr with
-buy transaction: cash value
-sell transaction: cash value
-not directly reinvested dividend: ignore
-purchase value at end (not market value)
That way only sales gains should be taken into account
Paper gain rate
xirr with
-buy transaction: cash value
-sell transaction: purchase value (not cash value)
-not directly reinvested dividend: ignore
-market value at end
That way only paper profit should be taken into account
I would also find it great if besides the yearly values, an overall annualized value would be available (given the algorithm above, the only change would be to take all transactions instead of only the ones from one year).
from jstock.
Hi @tarioch,
Now, I just want to kick start this very exciting feature :)
I came across some obstacle while implementing it (I don't have any format financial or quantitative background)
Would you like to participate in such discussion?
Thanks.
from jstock.
Hi @tarioch ,
After spending a few hours studying starting from http://www.mathsisfun.com/money/internal-rate-return.html, I can get a rough understanding on NPV, IRR & XIRR.
Code implementation shouldn't be much trouble, after looking at your pointer on those implementation (Java at GitHub, Stackoverflow....) But, I will surely spend time looking at StackOverflow discussion, as there seems to be edge case where Newton method doesn't work. We need to fall back to BisectionMethod in those edge case. jxirr might not handle those cases (I just did a rough search on keyword "bisection"). But, it is still too early to judge till I run their unit test.
What is more important is, I need to ensure my understanding on this subject is more or less accurate. I got some doubt in my mind still. Do you mind to take a look? http://quant.stackexchange.com/questions/12974/is-there-any-relationship-between-investment-return-of-a-stock-for-individual-y
Thank you.
from jstock.
The reply you got looks good.
Wikipedia also has a nice article about the bisect algorithm
http://en.wikipedia.org/wiki/Bisection_method
And here's an example implementation for xirr
http://puneinvestor.wordpress.com/2013/10/01/calculate-xirr-in-ruby-bisection-method/
from jstock.
Work in progress.
https://github.com/yccheok/xirr
Still need bisect algorithm and more unit test cases.
Contribution is very much welcomed.
from jstock.
Hi @tarioch,
While implementing, I came across a roadblock, while trying to break down yearly XIRR into different segments.
Would you mind to take a look http://quant.stackexchange.com/questions/14013/break-down-xirr-to-different-segments
Also, I tried to understand your previous thread
Dividend gain rate
xirr with
-buy transaction: cash value
-sell transaction: purchase value (not cash value)
-not directly reinvested dividend: cash value
-purchase value at end (not market value)
I don't understand what do you mean by
-sell transaction: purchase value (not cash value)
-purchase value at end (not market value)
I would be very much appreciated, if you could provide an example.
Thank you.
from jstock.
My thought is to ignore all the other profits. So when looking at dividend profits you're not interested in sales or paper profits. Therefore I cancel them out by using the original purchase price when selling them.
e.g.
buy 1000 for 1$ get dividend of 100$ and sell for 2$
Dividend profit would be:
-1000
+100
+1000
vs total profits
-1000
+100
+2000
from jstock.
Related Issues (20)
- Colors for volume, trendline, TA
- Fails to load Indian Stock Exchange BOM data
- Issue with hdpi and dimension of fonts HOT 2
- Question: Compare by percent & Not able to simulate
- Add Stock: All stocks are added
- Java null exception when enabling email alert
- Question: Data source in the code HOT 4
- F-Droid
- LPPF.JK show "Pacific Utama Tbk", instead of "PT Matahari Department Store Tbk"
- Incorrectly calculated lastPrice in candlestick charts on weekly and monthly base
- Increasing decimals for Bitcoins
- Metals / Commodity not working
- ExceptionInInitializationError: jstock does not start HOT 4
- Broker Setup for Indian Trading house and Exchanges
- Can't find on Google Drive HOT 2
- WARNING: An illegal reflective access operation has occurred
- Please convert the project to maven and java 8 atleast so that more people could use it
- JStock Desktop Version Dividend Information ??? HOT 1
- Technical analysis not working on some stocks
- Upgrade the project to support java 17 and onwards HOT 1
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 jstock.