Outline ·
[ Standard ] ·
Linear+
FundSuperMart v18 (FSM) MY : Online UT Platform, UT DIY : Babystep to Investing :D
|
idyllrain
|
Dec 22 2018, 11:03 AM
|
Getting Started

|
QUOTE(yklooi @ Dec 22 2018, 10:08 AM) previously I got the marco from the earlier version of that file. it was 'modified" to be a stand alone "Get NAVs from FSM" get the NAVs and copy paste into existing spreadsheet.  now it cannot function anymore.... could you be kind enough to amend the macro for me? Sure thing! I'll PM you in a bit.
|
|
|
|
|
|
idyllrain
|
Dec 22 2018, 03:31 PM
|
Getting Started

|
These are the instructions for the Mac versions. If you're feeling adventurous or impatient, below are the steps to modify your own copy of the Excel Spreadsheet to cater for changes in the new FSMOne site. It's pretty straightforward: MAKE A COPY OF YOUR FILE BEFORE YOU DO THIS! Just in case... » Click to show Spoiler - click again to hide... « Instructions- Right click on the "Update Current Fund Price" button, and choose "Assign Macro"


- Click on the "Edit" button

- On the main screen you'll see the subroutine that says "GetFundPrices" (I'm using the screenshot from the Windows version, but it's similar)

- This subroutine goes all the way down here

- Now select all the lines of code that is in this subroutine. (Select until the line.)

- Press the "Backspace" key or "Delete" key on your keyboard
- Copy the code in the Spoiler section below, and paste it here


Code in here vvvv
» Click to show Spoiler - click again to hide... « CODE Sub GetFundPrices() ' ORIGINALLY CREATED BY idyllrain @ Lowyat.net ' ORIGINAL SOURCE(S): ' - https://forum.lowyat.net/index.php?showtopic=3633445&view=findpost&p=75357733 ' - https://forum.lowyat.net/index.php?showtopic=3633445&view=findpost&p=75383114 ' UPDATED BY polarzbearz @ Lowyat.net ' Last Updated - 23 Dec 2018
' Get current state of various Excel settings screenUpdateState = Application.ScreenUpdating statusBarState = Application.DisplayStatusBar eventsState = Application.EnableEvents displayPageBreakState = ActiveSheet.DisplayPageBreaks 'note this is a sheet-level setting ' Turn off some Excel functionality temporarily Application.ScreenUpdating = False Application.DisplayStatusBar = False Application.EnableEvents = False ActiveSheet.DisplayPageBreaks = False 'note this is a sheet-level setting
Set WS = Worksheets("Investment Details") Dim i As Long Dim lastRow As Long 'Search for the last line item (column A) with value 0 lastRow = WS.Range("A:A").Find(What:="0", After:=WS.Cells(1, 1), LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False).Row 'Executing logs placeholder Dim logs As String logs = "Fund update has been successfully executed!" & vbNewLine & "Please refer to the status logs below:" & vbNewLine & vbNewLine logs = logs & vbTab & "LINE" & vbTab & "FSM CODE" & vbTab & "STATUS" 'Set a Number of Updates counter, starting from zero before going into the loop Dim successfulUpdate As Long Dim totalUpdate As Long sucessfulUpdate = 0 totalUpdate = 0 'From first row all the way to the last row with line item = 0 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 ' total update counter +1 totalUpdate = totalUpdate + 1 'Get the fund code' Dim fundName As String fundName = WS.Cells(i, 3).Value On Error GoTo ErrHandler: 'Download the correct price list' content = DownloadFromFSMMac(fundName) 'Update date value from 4th table cell of first row' Dim datestring As String datestring = Split(content, ";")(1) WS.Cells(i, 4).Value = ((datestring + 28800000) / 86400000) + 25569 'Update NAV value from the DIV element in the 3rd table cell of first row' WS.Cells(i, 9).Value = Split(content, ";")(0) successfulUpdate = successfulUpdate + 1 logs = logs & vbNewLine & vbTab & i & vbTab & Left(fundName & Space(15), 15) & vbTab & "OK!" SkipBlocks: 'skip everything above from "On Error GoTo ErrHandler:" block End If Next i ' Restore Excel state Application.ScreenUpdating = screenUpdateState Application.DisplayStatusBar = statusBarState Application.EnableEvents = eventsState ActiveSheet.DisplayPageBreaks = displayPageBreaksState 'note this is a sheet-level setting 'Add final line to logs and display to user logs = logs & vbNewLine & vbNewLine & "If there are errors in updating the Fund Price, please double check on the FSM Codes and try again." MsgBox logs WS.Range("portfolioLastUpdate").Value = Date Exit Sub ErrHandler: ' fail counter, messages logs = logs & vbNewLine & vbTab & i & vbTab & Left(fundName & Space(15), 15) & vbTab & "ERROR!" 'reset date field to TODAY() - Update date value from 4th table cell of first row' WS.Cells(i, 4).Value = "=TODAY()" Resume SkipBlocks: EndHandler: MsgBox ("Unable to connect to FSM website. Please try again later.") End Sub
- Look on the left side of the panel, and find "Module 2" in the "Modules" folder. Double click on it.


- Select all the lines of the function called "DownloadFromFSMMac"

- Press the "Backspace" key or "Delete" key on your keyboard
- Copy the code in the Spoiler section below, and paste it here


Code in here vvvv
» Click to show Spoiler - click again to hide... « CODE Function DownloadFromFSMMac(sCode As String) As String
Dim sCmd As String Dim sResult As String Dim sXSRFToken As String Dim lExitCode As Long
' Idyllrain-Leverage OSX perl commands because there is no built-in support for the HTML object nor regular expressions sCmd = "perl -MLWP::UserAgent -le '$l=""https://www.fundsupermart.com.my/fsmone/rest/"";$u=LWP::UserAgent->new(ssl_opts=>{verify_hostname=>0},cookie_jar=>{});$u->post($l.""csrf/get-new-csrf-token"")->decoded_content()=~/(?<=\""message\"":\"")([a-f0-9\-]{36})/;$u->default_header(""x-xsrf-token""=>$1);$u->post($l.""fund/get-factsheet?paramSedolnumber="".shift)->decoded_content()=~/latestNavPrice.+?showDate.:(\d+).+?bidPrice.:([0-9.]+)/;print $2."";"".$1;' " + sCode sResult = execShell(sCmd, lExitCode)
DownloadFromFSMMac = sResult
End Function
- Finally, click on the Save button and close the window"


Attached is an updated base file for Excel 2016 for Mac 64-bit. Note that this file does not contain functionality that polarzbearz added when she published her beta version a while ago. This is merely the previous spreadsheet with the FSM retrieval code updated. If you do not want to start afresh, I would recommend following the instructions above to update your own file.
Portfolio_IRR_Mac_Office_2016_64bit.xlsm.zip ( 1.88mb )
Number of downloads: 30--- Windows version: https://forum.lowyat.net/index.php?showtopi...post&p=91302147-- EDIT --I updated the instructions and base file above. Changes- Switched to using a different date value in the API response. - Fixed timezone issues in date calculation - Optimized regular expressions Thanks to yklooi for discovering these issues. I should've been more careful. Those who followed my instructions above will have to redo them again. I'm terribly sorry for the trouble; please forgive me. This post has been edited by idyllrain: Apr 29 2023, 10:55 AM
|
|
|
|
|
|
idyllrain
|
Dec 22 2018, 08:52 PM
|
Getting Started

|
QUOTE(howszat @ Dec 22 2018, 07:11 PM) Daily Fund Prices not available? Singapore site has it. Still a work in progress? You can get it in a roundabout fashion through the fund selector. The actual API call contains more info than what is displayed on the site though. This post has been edited by idyllrain: Dec 22 2018, 08:52 PM
|
|
|
|
|
|
idyllrain
|
Dec 23 2018, 01:56 AM
|
Getting Started

|
QUOTE(howszat @ Dec 22 2018, 09:49 PM) Yes, that's an option, but I suspect they would probably include the Daily price soon. Thank you for your questions; in the interests of keeping the thread focussed, I've PMed you the answers. I must strongly caution everyone that you should always be careful when running any macro code given to you that you don't understand. Macros can be coded to do some really destructive things. I published all the code is so that everyone can see what it does and compare it with what you have in your files (if you're using it). Please feel free to ask me if there are portions of the code that look suspicious to you. This post has been edited by idyllrain: Dec 23 2018, 02:31 AM
|
|
|
|
|
|
idyllrain
|
Jan 5 2019, 08:49 PM
|
Getting Started

|
QUOTE(spiderman17 @ Jan 3 2019, 10:33 AM) Great job!! Just wanna mention that the new code doesn't update the "portfolio summary" date. I copy and add "WS.Range("portfolioLastUpdate").Value = Date" just before Exit Sub based on old version. Thanks for the heads up spiderman17! I must've accidentally removed that line in the Windows post during the copy/paste. I updated the code in the post. Edit: The Excel file attached in the post contains that line. This post has been edited by idyllrain: Jan 5 2019, 08:55 PM
|
|
|
|
|
|
idyllrain
|
Jan 25 2019, 02:39 AM
|
Getting Started

|
QUOTE(alexkos @ Jan 24 2019, 11:51 PM) tuan tuan dan puan puan.. aiyo, my bond lesson give back to teacher d....help me to calculate this... https://www.fundsupermart.com.my/fsm/bonds/...et/MYBMZ1300078how to arrive at MYR 10,756.67 Estimated Payment Amount? Thank you D= See Item #10: https://www.fundsupermart.com.my/fsm/bonds/faq
|
|
|
|
|
|
idyllrain
|
Jan 26 2019, 08:41 PM
|
Getting Started

|
QUOTE(2387581 @ Jan 25 2019, 10:32 PM) Hi, I was trying to do the update myself - and it returned When I tried download the new spreadsheet and without doing anything, click on the button, same thing happens. Any idea? [attachmentid=10171525] Hi 2387581, find this line in the GetFundPrices() routine (it's somewhere in the first 25 lines): CODE 'Connection.Option(WinHttpRequestOption_SecureProtocols) = 2048 Remove the ' (single quote) from the front of that line to activate that line. Save and try again. That should stop the error. Edit (In case you're wondering why you're seeing that error and what that line does): You're seeing the error because FSM requires a secure connection established using the TLS 1.2 protocol and your computer attempted the connection using some other protocol (probably TLS 1.1). What that line does is to force the connection to be established using TLS 1.2. Btw, if the error still occurs, you will most likely need to update your copy of Windows as per this article: https://support.microsoft.com/en-my/help/31...protocols-in-wiThis post has been edited by idyllrain: Jan 26 2019, 08:57 PM
|
|
|
|
|
|
idyllrain
|
Jan 27 2019, 02:11 PM
|
Getting Started

|
QUOTE(2387581 @ Jan 27 2019, 02:05 AM) I have done with the line above. Now there's another error. [attachmentid=10172210] I have also checked the said windows update, which was already installed in my Windows 7 x64 laptop at home. I have also tried the same excel file in my office desktop, which is running Windows 10 x64 (via AnyDesk), same error as above happens - Tried with the quote mark (deactivated line), the same error as above returns.  Hmm this error happens when a non-native variable type is used incorrectly or a reference isn't loaded. Can you PM me a blanked copy of your file? I'll look into it.
|
|
|
|
|
|
idyllrain
|
Apr 21 2019, 09:58 PM
|
Getting Started

|
QUOTE(Nicholas Kang @ Apr 21 2019, 01:38 PM) 1. Is there any plan to include calculations of portfolio risk-return ratio, volatility, Sharpe Ratio, Jensen's Alpha, portfolio beta and other portfolio analysis computations in the IRR Excel spreadsheet? (I hardly see Pinky online...) The spreadsheet is currently being maintained by polarzbearz and me. I personally have no plans to add more portfolio metrics to the spreadsheet primarily because I think the spreadsheet should be simple enough for most people to understand it. Furthermore many portfolio metrics require historical data on a timespan that is not available through public interfaces or require the spreadsheet user to religiously record NAV/return/distribution every single trading day. You're free to add them yourself if you wish, though it will require significant modification and customization. QUOTE(Nicholas Kang @ Apr 21 2019, 01:38 PM) 2. I am currently including ASNB FP and VP funds together in the FSM spreadsheet. I wonder if the excel marco can be edited/modified slightly to fetch VP fund price from the ASNB official webpage. Any thoughts on how to do this? 3. If I were to purchase funds on FSM Singapore, can I include them in Excel spreadsheet? What if I want to update the latest fund's NAV, will the current marco automatically link to Singapore's FSM webpage to fetch the latest NAV price? The public version of the spreadsheet macros only support FSM Malaysia by retrieving NAV from a REST API. To support FSM Singapore, you'll need to write more code to support FSM Singapore's slightly different interface. If you want it to fetch ASNB data, you'll need to write custom parsing code to extract data out of their webpage.
|
|
|
|
|
|
idyllrain
|
Jun 23 2019, 10:07 PM
|
Getting Started

|
QUOTE(T231H @ Jun 21 2019, 11:04 AM) there is one very canggih one that can be downloaded in post 1....Polarbearz file. Post 1 files are severely outdated by now. The most updated version is here: https://forum.lowyat.net/index.php?showtopi...entry91302147Anyway, since AIYH is no longer active here, should we start a new thread with someone who can actually update the first post?
|
|
|
|
|
|
idyllrain
|
Nov 1 2020, 05:31 PM
|
Getting Started

|
Instructions for Mac OSIf you prefer not to start fresh, and if you are still using the older version of Polarzbearz's file. You can use these instructions to update your copy to work with the new FSM site. MAKE A COPY OF YOUR FILE BEFORE YOU DO THIS! Just in case... » Click to show Spoiler - click again to hide... « This post has been edited by idyllrain: Apr 29 2023, 10:59 AM
|
|
|
|
|
|
idyllrain
|
Nov 1 2020, 05:46 PM
|
Getting Started

|
QUOTE(yklooi @ Nov 1 2020, 05:41 PM) idyllrain, 23 months ago, you managed to help amend the macro inside my file, can you amend it again for me so that it will get the NAV from FSM as they have changed the interface again? thanks Here you go Attached File(s)
Auto_Nav_update_for_Idyllrain_Nov_2020_to_change.zip ( 29.55k )
Number of downloads: 38
|
|
|
|
|