Welcome Guest ( Log In | Register )

Bump Topic Topic Closed RSS Feed

Outline · [ Standard ] · Linear+

 Fundsupermart.com v11, Grexit or not, Europe will sail on...

views
     
polarzbearz
post Jul 12 2015, 01:23 PM

Gracie
*******
Senior Member
4,816 posts

Joined: Apr 2007


QUOTE(idyllrain @ Jul 12 2015, 12:57 AM)
If anyone's interested, I've added the following code in polarzbearz IRR Excel sheet to obtain the latest NAV prices from FSM with just one click (I attached the macro to a button).

CODE
Sub GetFundPrices()
   Set WS = Worksheets("Investment Details")
   Set htm = CreateObject("htmlFile")
   Set XML = CreateObject("msxml2.xmlhttp")
   
   Dim i As Long
   Dim lastRow As Long
   lastRow = WS.Range("C:C").Find(What:="*exit*", LookIn:=xlValues).Row

   'From first row all the way to the row containing the value *exit*'
   For i = 1 To lastRow
       'If this row is a group header row (Column A has a value of 1)'
       If WS.Cells(i, 1).Value = "1" Then
           Dim fundName As String

           'Get the fund code'
           fundName = WS.Cells(i, 3).Value
       
           'Download the correct price list'
           XML.Open "GET", "http://www.fundsupermart.com.my/main/fundinfo/dailyPricesHistory.tpl?id=" & fundName, False
           XML.send
           If XML.ReadyState = 4 And XML.Status = 200 Then
               htm.body.innerHTML = XML.responsetext

               On Error GoTo ErrHandler:
                   'Get all 4 cells in the first row of data'
                   Set FirstRow = htm.getElementsByTagName("tr")(2).Children
                   
                   'Update date value from 4th table cell of first row'
                   WS.Cells(i, 4).Value = FirstRow(3).innerText
                   
                   'Update NAV value from the DIV element in the 3rd table cell of first row'
                   WS.Cells(i, 9).Value = FirstRow(2).FirstChild().innerText
           End If
       End If
   Next i

   Exit Sub

ErrHandler:
   MsgBox ("Cannot load data. Either the FSM Code is incorrect or FundSuperMart is down.")
End Sub


As this code relies on FSM's price list pages, if there's any changes to that in the future, this code will break. The only modifications done on the table was changing Column C into the Fund Codes used at FundSuperMart (You can get these from the URL: http://www.fundsupermart.com.my/main/fundi...do?sedolnumber=MYKNGGF) and adding the value "*exit*" into the final row of Column C. Like this:
user posted image

Also, the formula for the Units calculation in Column M will sometimes result in an amount that doesn't reflect the value shown on FSM's website as the rounding order is different.

This is the existing rounding formula in Column M (Removed the @ coz it will trigger tagging):
CODE
(-ROUND((ROUND(([Amount]/(1+([[Sales Charge / Redemption Fee]]*(1+[[GST %]])))),2)/[[NAV Price]]),2))+[[Transaction Manual Adj.]]

Changing it to this has resulted in all my values matching the ones on FSM's website:
CODE
(-ROUND((ROUND(([Amount]/(1+([[Sales Charge / Redemption Fee]]*(1+[[GST %]]))))/[[NAV Price]],2)),2))+[[Transaction Manual Adj.]]

*
rclxms.gif rclxms.gif Very good job! Will try it out and consolidate it into downloadable version thumbup.gif
polarzbearz
post Jul 12 2015, 03:28 PM

Gracie
*******
Senior Member
4,816 posts

Joined: Apr 2007


QUOTE(idyllrain @ Jul 12 2015, 03:19 PM)
Here's my modified copy (with some slight differences): https://www.dropbox.com/s/r9vv8oib6blxia3/P...bearz.xlsm?dl=0

Modifications I've made:
Added macro to obtain fund prices (Options -> Customize Ribbon -> Developer tab)
If you are not comfortable with code, I highly suggest that you don't use this file and let polarzbearz look at the code and verify that it doesn't do anything malicious then include it into his version. As this file contains a macro, it will trigger security warnings and you will need to enable macros in order to use it. You have to do this only once.
user posted image

The macro code in this file is slightly different than the one I posted above. The differences in this file is just that I added a message indicator saying what is being updated so that if something fails you'll know which fund is causing the problem:
» Click to show Spoiler - click again to hide... «

Code here for auditing:
» Click to show Spoiler - click again to hide... «

Changed "Investment Details" table into range (Table Design tab -> Convert to Range)
Since I just want to insert rows by "Select rows -> right click -> insert copied cells" *and* I don't really want to have tons of placeholder rows, I converted it to a normal range. The only downside to this, is that Excel will not autofill the formulas for you. However, it is really really simple to do that manually:
- Shift + spacebar (This selects the row if its not already selected)
- Ctrl + D (This takes the formula from the row above and fills it into the current row)
» Click to show Spoiler - click again to hide... «

I removed the dummy values for the IRR calculations
Since I don't have any retired funds... I understand they're there to fix a summary bug

Changed unit amount rounding order
As mentioned in my first post, this rounding appears to match what is shown in FSM's site. I have not encountered any differences between my units and the units shown on FSM's website yet... but my dataset is a lot smaller than all the seasoned investors here so please do check. If you had to use Transaction Adjustments to adjust your units before, this should eliminate the need for it.
*
I'm currently modifying your original source (the first one which was provided), mainly on the ErrHandling part - so that the code continues to execute (for subsequent fund updates) even if there was error, and provides a summary at end of execution.
» Click to show Spoiler - click again to hide... «

Will release the next version with this feature once finalizing the codes laugh.gif

Here's a sneak peek:
Attached Image

thumbup.gif thumbup.gif Good work on your side, never thought about fetching the NAV price from FSM directly

This post has been edited by polarzbearz: Jul 12 2015, 03:28 PM
polarzbearz
post Jul 12 2015, 05:35 PM

Gracie
*******
Senior Member
4,816 posts

Joined: Apr 2007


QUOTE(idyllrain @ Jul 12 2015, 12:57 AM)

Also, the formula for the Units calculation in Column M will sometimes result in an amount that doesn't reflect the value shown on FSM's website as the rounding order is different.

This is the existing rounding formula in Column M (Removed the @ coz it will trigger tagging):
CODE
(-ROUND((ROUND(([Amount]/(1+([[Sales Charge / Redemption Fee]]*(1+[[GST %]])))),2)/[[NAV Price]]),2))+[[Transaction Manual Adj.]]

Changing it to this has resulted in all my values matching the ones on FSM's website:
CODE
(-ROUND((ROUND(([Amount]/(1+([[Sales Charge / Redemption Fee]]*(1+[[GST %]]))))/[[NAV Price]],2)),2))+[[Transaction Manual Adj.]]

*
Regarding the above formula, I have tested with my sample (which is relatively small also) and seems like it will still sometime returns wrong decimal calculation (which requires manual transaction adjustment). Need to test further on the rounding but guess I'll leave it untouched in coming version for now.

Surprisingly, some of the transaction which requires "Manual Adjustment" were fixed with your formula, but some of those transaction which was accurate (no issues) now requires manual adjustment laugh.gif
polarzbearz
post Jul 12 2015, 05:48 PM

Gracie
*******
Senior Member
4,816 posts

Joined: Apr 2007


QUOTE(idyllrain @ Jul 12 2015, 05:40 PM)
smile.gif In that case then yeah, I agree its best to use your version. I'll update my posts to reflect your findings.
*
Still trying to mess around with the placement of ROUND, ROUNDDOWN, but seems like there's always one or two weird transactions which just... have odd decimal sweat.gif

Will try it again next time laugh.gif
polarzbearz
post Jul 12 2015, 06:57 PM

Gracie
*******
Senior Member
4,816 posts

Joined: Apr 2007


Released v2.0 of the Portfolio Summary worksheet, with "Fund Update" features to fetch latest NAV price from FSM directly. Please remember to "ENABLE MACRO" when prompted by Microsoft Excel, as it is required for the Macro to run.
Attached Image

Here's the code for the macro to fetch NAV Price from FSM website, if anyone is interested:
» Click to show Spoiler - click again to hide... «


Download Link: http://bit.ly/polarzbearzPortfolioSummary2
Change Log:
» Click to show Spoiler - click again to hide... «


Special Thanks: idyllrain, for providing the original macro to fetch fund prices from FSM directly.

Pink Spider Need your help to update the download link in the front page tongue.gif The old link no longer works as I've converted the file extension, resulting in different dropbox link sad.gif

This post has been edited by polarzbearz: Jul 12 2015, 06:57 PM
polarzbearz
post Jul 12 2015, 07:37 PM

Gracie
*******
Senior Member
4,816 posts

Joined: Apr 2007


QUOTE(Pink Spider @ Jul 12 2015, 07:31 PM)
my experience is CIMB always round down wink.gif
*
Hmm, that could be the reason of deviation. Round down makes every transaction (with CIMB) appears OK, but other houses like RHB-OSK CMF became not ok sweat.gif

Gonna test more and if confirmed that differences come from different rounding methods per fundhouse, nothing much can be done (too much hassle tongue.gif) but use the manual adjustment

QUOTE(Pink Spider @ Jul 12 2015, 07:35 PM)
polarbear test my link ok or not? tongue.gif
*
Tested OK thumbup.gif notworthy.gif
polarzbearz
post Jul 13 2015, 10:00 PM

Gracie
*******
Senior Member
4,816 posts

Joined: Apr 2007


QUOTE(Pink Spider @ Jul 12 2015, 07:57 PM)
I got/once got...
RHB-OSK
CIMB-Principal
Affin Hwang
Eastspring Investments
Pheim
Aberdeen Islamic
Alliance
AmInvestment
Pacific

ONLY CIMB rounds down, the rest all round to nearest 2 decimals
*
That explains why rounding down fixes the difference in CIMB funds, but screw up my non cimb funds laugh.gif

I'll leave it as it is
polarzbearz
post Jul 13 2015, 10:06 PM

Gracie
*******
Senior Member
4,816 posts

Joined: Apr 2007


QUOTE(woonsc @ Jul 13 2015, 12:38 AM)
OMG! <3 that's so awesome! I love u all!
hahaha it's a good way to update and makes checking it daily so much easier..

T.T
sad thou.. my IRR +5 > +2.12%

Can i suggest the asset allocation also use macro tongue.gif
WeeeeW

That's version 3.0!  biggrin.gif  tongue.gif  biggrin.gif  tongue.gif
*
I was actually already prototyping something like what you mentioned (automation to fetch list of funds from Investment Details onto the Fund Allocation worksheet), so we only have to update the % of funds based on PDF fact sheet.

But I got too lazy and busy in between that I kinda put it on hold tongue.gif

It's still in the version I'm using, but not fully developed yet (some missing logic tongue.gif)
polarzbearz
post Jul 13 2015, 10:08 PM

Gracie
*******
Senior Member
4,816 posts

Joined: Apr 2007


QUOTE(idyllrain @ Jul 13 2015, 01:09 PM)
polarzbearz I just noticed that the msxml2.xmlhttp object we've used in our code appears to cache responses from the FSM server . If you have run the code once, and you don't exit Excel, and FundSuperMart updates their prices, and you run the code again, none of the prices in the Excel sheet will update to the latest (for non-techies, it means that Excel is storing old data and reusing it). (This caching is the reason why subsequent executions of the macro code are faster.)

To get past this, I've swapped to using the winhttp.winhttprequest.5.1 object that does not cache. These are the lines that need to be changed (I changed the variable name as well):
CODE
-- Set XML = CreateObject("msxml2.xmlhttp")
++ Set Conn = CreateObject("winhttp.winhttprequest.5.1")

-- If XML.ReadyState = 4 And XML.Status = 200 Then
++ If Conn.Status = 200 Then

p/s: While waiting for him to update his file, you can force an update by just saving, exiting Excel, open the file again, and run the code. This issue is just a minor annoyance. smile.gif
*
QUOTE(T231H @ Jul 13 2015, 01:49 PM)
calling polarzbearz...pls take note of post# 447
*
Well noted on this nod.gif

But I guess the impact is very minimal as chances of us updating the excel file the same time as FSM is minimal.

Will release a minor version for above fix soon (optional to download).
polarzbearz
post Jul 13 2015, 10:26 PM

Gracie
*******
Senior Member
4,816 posts

Joined: Apr 2007


As per recommendation from idyllrain, minor-fix has been applied to the "Fund Update" feature and v2.1 of the Portfolio Summary worksheet has been pushed to Dropbox available for download.

Note: This version has minor fix on the highlighted bug below, and is optional to download (if you are lazy to re-import your data to the worksheet

» Click to show Spoiler - click again to hide... «


Download Link: http://bit.ly/polarzbearzPortfolioSummary2
Change Log:
» Click to show Spoiler - click again to hide... «

New Code for Techies Only:
» Click to show Spoiler - click again to hide... «


user posted image

Previous Release:
» Click to show Spoiler - click again to hide... «


This post has been edited by polarzbearz: Jul 13 2015, 10:55 PM
polarzbearz
post Aug 24 2015, 10:54 PM

Gracie
*******
Senior Member
4,816 posts

Joined: Apr 2007


QUOTE(yklooi @ Aug 21 2015, 06:55 PM)
notworthy.gif  thanks for the tips....I did not aware of this....
(just realised that, the longer the investment years, it needs a bigger % of movement to have an impact on the IRR%)
pai-seh...getting lower by the days.... blush.gif
*
Unker yklooi! Do you mind to share how you calculate this / the formula behind? Interested tongue.gif

user posted image
polarzbearz
post Sep 16 2015, 10:07 AM

Gracie
*******
Senior Member
4,816 posts

Joined: Apr 2007


QUOTE(polarzbearz @ Aug 24 2015, 10:54 PM)
Unker yklooi! Do you mind to share how you calculate this / the formula behind? Interested tongue.gif

user posted image
*
QUOTE(yklooi @ Aug 24 2015, 11:15 PM)
I do copy and paste the results onto the table manually...
notworthy.gif
*
I added this to my spreadsheet after looking at yours, to capture it when I update my prices tongue.gif, so that at least i can see how it moves MoM or YoY laugh.gif


Attached Image
polarzbearz
post Sep 16 2015, 10:45 AM

Gracie
*******
Senior Member
4,816 posts

Joined: Apr 2007


QUOTE(yklooi @ Sep 16 2015, 10:30 AM)
rclxms.gif cool !  rclxms.gif
got this function in the latest file as in post# 1?

btw, the MoM and YoY movement is only the WHOLE portfolio or does is includes the movements of EACH individual funds?

hmm.gif BEST if it can be WHOLE and EACH individual fund (so can know which one NEEDS to be kicked out....OCHK  laugh.gif ).  rolleyes.gif  notworthy.gif
*
It's not in the latest file yet, it's on my personal file tongue.gif

Currently it only captures the snapshot - i.e. no further analysis on the raw data. Too lazy to do anything about it first tongue.gif

The MoM and YoY got two section, one captures the snapshot of the WHOLE portfolio, and another captures the snapshot of each and every fund individually.

However, as I said, it's just a snapshot (i.e. rows of data in the previous screenshot), no further analysis is added (i.e. chart) in the file, yet..
polarzbearz
post Sep 16 2015, 07:20 PM

Gracie
*******
Senior Member
4,816 posts

Joined: Apr 2007


Released v2.2 of the Portfolio Summary Tool, with new added feature to "Capture Snapshot" of your existing portfolio & fund with a single click! A chart has also been added for easy reference.
Attached Image

Download Link: http://bit.ly/polarzbearzPortfolioSummary2
Change Log:
» Click to show Spoiler - click again to hide... «


Note: The above file contains sample snapshot. Please remove it before you perform the "CAPTURE SNAPSHOT" function.
Attached Image

polarzbearz
post Sep 16 2015, 07:27 PM

Gracie
*******
Senior Member
4,816 posts

Joined: Apr 2007


QUOTE(yklooi @ Sep 16 2015, 07:23 PM)
rclxms.gif Thanks gain... thumbup.gif
hmm.gif Does "Pink" need to update this link into the 1st post?
*
No need to update the link, I'm reusing the link most of the time (except in special scenarios like changing file name / file extension which breaks the old link tongue.gif)

Topic ClosedOptions
 

Change to:
| Lo-Fi Version
0.0452sec    0.88    7 queries    GZIP Disabled
Time is now: 8th December 2025 - 02:45 PM