Donate to Remove ads

Got a credit card? use our Credit Card & Finance Calculators

Thanks to eyeball08,Wondergirly,bofh,johnstevens77,Bhoddhisatva, for Donating to support the site

XIRR Calculation

General discussions about equity high-yield income strategies
tjh290633
Lemon Half
Posts: 8271
Joined: November 4th, 2016, 11:20 am
Has thanked: 919 times
Been thanked: 4131 times

Re: XIRR Calculation

#206033

Postby tjh290633 » March 6th, 2019, 6:02 pm

PrefInvestor wrote:Part of my problem with implementing the XIRR calculation is that the data required needs to be drawn from three different tables on my spreadsheet, the purchase prices from one table, the dividends from a second table and the current stock price from a third. My original plan was to use queries to combine each of these elements into a single table which could then be sorted by the stock code to produce the necessary dates and values in a contiguous range of cells suitable to pass into the XIRR function. The ability to include blank cells as in your example and the formatting approach outlined above might provide an alternative solution eliminating the need for some sorting.

A simple solution would be to write a VBA function (MyXIRR ?) possibly passing the Epic Code as an argument. This function could then build the date/values in local variables (making them contiguous) and return the XIRR value. I might try this approach but I am worried that it might disrupt the operation of undo which I find essential. In my last major set of updates to my spreadsheet I spent a lot of time removing all my VBA functionality for this very reason.

ATB

Pref

I think that you may be reinventing the wheel here. I have a sheet for each share, with dates at the left, purchases or sales and dividends in columns to the right, share prices on the dates (announcement dates for dividends), etc. and a cash flow column at the right, picking up numbers from the appropriate columns.

When something happens, I add a row. The current price and value are below all this and the XIRR is worked out automatically. I can do it for the holding or just the single share first purchased.

Then I have a summary sheet for all the shares held, which picks up the value of XIRR from each individual share's sheet.

No need to undo anything.

TJH

PrefInvestor
Lemon Slice
Posts: 597
Joined: February 9th, 2019, 8:24 am
Has thanked: 31 times
Been thanked: 258 times

Re: XIRR Calculation

#206044

Postby PrefInvestor » March 6th, 2019, 7:08 pm

Hi tjh290633, Well the problem with spreadsheets is that you start of with a concept of how you are going to hold your data and you build on that incrementally. Then when you face the problem of adding some new functionality you have to extend it in some way to make it work. The better the data model you had to start with the easier that is........

I have only the following main worksheets in my spreadsheet:-
a) Investments - one for each purchase. If I buy a stock more than once there is one entry for each.
b) Cash - contains details of the cash amount of all buys/sells and brief summary of what was bought/sold. But all cash transactions are recorded here.
c) Shares - detailed information on EVERY stock I might ever want to invest in. Including dividend dates, EPS, buy/sell prices (obtained automatically from the web)
d) Dividends - table of all dividends on every stock I hold in date order going all the way back to when I started investing and forward to the end of the next calendar year. Also contains a lookup against a web site containing dividend info that highlights upcoming events and allows me to check that any dividend information that I have entered manually is correct.
e) Stocks - summary table of all my current investments with data being drawn from all of the other sheets. Provides all the usual sort of summary numbers.
f) i have a number of other sheets that contain data from queries that automatically fetch information from the web required to populate parts of the other sheets.

I can update my whole portfolio with a single click (Refresh All) using web sites that contain real-time pricing and other information eg exchange rates, almost no manual data entry is required (unfortunately my current pricing source does not hold prices for some of my ETFs). It took me some years to incrementally build the functionality that I have and I'm pretty happy with it really.

I dont really think that I could adopt your data model even if I wanted to now. To do so would involve enormous changes to what I have and/or duplication of data (which is never a good thing to do).

When I was talking about "undo" I meant the Excel feature where you undo the last action to a level of 99 deep. So that if you key something wrong or do a change to a formula or something that goes badly wrong (it happens) then you can easily undo it. If you include VBA code in your excel spreadsheet then each execution of some VBA code clears down the undo stack stopping you using that feature. This was the effect that I was referring to. I hit this problem with a previous version of my spreadsheet and do not want to go there again. Keying something and then being unable to undo it is quite unpleasant.

I can now see how I can implement XIRR via the methods I outlined in a previous post. I shall continue to develop this solution in slow time. Hey Ive lived without it this long I can wait a bit longer.

ATB

Pref

PrefInvestor
Lemon Slice
Posts: 597
Joined: February 9th, 2019, 8:24 am
Has thanked: 31 times
Been thanked: 258 times

Re: XIRR Calculation

#207411

Postby PrefInvestor » March 13th, 2019, 12:58 pm

Hi All, Well I've now completed incorporating an XIRR column/calculation into my spreadsheet. Solution comprised 3 queries to obtain purchase, dividend and current price data and then a further query to combine those 3 into a single table and then a formula to pass that data into the XIRR function. No changes required to my data model I am pleased to say.

Thanks to all for their help in explaining what was necessary to get a sensible XIRR result. Without that I am sure that my results would not have been correct.

ATB

Pref


Return to “High Yield Shares & Strategies - General”

Who is online

Users browsing this forum: No registered users and 29 guests