{"id":3718,"date":"2022-11-22T07:58:11","date_gmt":"2022-11-22T07:58:11","guid":{"rendered":"https:\/\/www.paytmmoney.com\/blog\/?p=3718"},"modified":"2022-11-22T13:57:37","modified_gmt":"2022-11-22T13:57:37","slug":"optimizing-savings-calculation-on-direct-mutual-funds","status":"publish","type":"post","link":"https:\/\/www.paytmmoney.com\/blog\/optimizing-savings-calculation-on-direct-mutual-funds\/","title":{"rendered":"Optimizing the Savings Calculation on Direct Mutual Funds"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">There are two categories of Mutual Funds namely Direct Mutual Fund and Regular Mutual Fund. <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><b><\/b><\/p>\n<h2><b>What are Direct Mutual Funds?\u00a0<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Direct Mutual Funds is the type of mutual fund that is directly offered by the AMC or fund house. In other words, there is no involvement of third party agents \u2013 brokers or distributors. Since there are no third party agents involved, there are no commissions and brokerage.<\/span><\/p>\n<h2><b>What are Regular Mutual Funds?<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Regular plans are those mutual fund plans that are bought through an intermediary. These intermediaries can be brokers, advisors, or distributors. The intermediaries charge the fund house a certain fee for selling their mutual funds.<\/span><\/p>\n<h2><b>What is Expense Ratio?\u00a0<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">The expense ratio is the percentage that denotes the amount of money you are paying to the AMC as a fee to manage your investments. In other words, it is the per-unit cost for running and managing the mutual fund. The expense ratio differs from one mutual fund to another. You do not pay for this expense ratio separately; it is calculated as a percentage of the daily investment value.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For example, if you invest Rs 5000 in a mutual fund with an expense ratio of 2%, then (2%\/365=0.0054%) will be deducted from the investment value each day. The per-day levying of the expense ratio ensures that you only pay for the period you stay invested. But this deduction of the expense ratio is lowering your returns by a tiny amount every day. Hence, a mutual fund scheme with a lower expense ratio is more beneficial to you because it takes away a lesser portion of money from your returns.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\"><b>Mutual Funds in Paytm Money<\/b><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">All Mutual Funds in Paytm Money are Direct Mutual Funds. Hence Paytm Money ensures investors to save their money since expense ratio is lower compared to regular funds. <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">Hence a new amazing feature has been proposed to show the savings card to the users in the portfolio. This card contains the information of total savings till date by investing in Paytm Money Platform.<\/span><\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-3721\" src=\"https:\/\/paytmmoney.wpengine.com\/wp-content\/uploads\/2022\/11\/Savings_Image.png\" alt=\"savings from mutual fund paytm money\" width=\"858\" height=\"174\" srcset=\"https:\/\/www.paytmmoney.com\/blog\/wp-content\/uploads\/2022\/11\/Savings_Image.png 858w, https:\/\/www.paytmmoney.com\/blog\/wp-content\/uploads\/2022\/11\/Savings_Image-300x61.png 300w, https:\/\/www.paytmmoney.com\/blog\/wp-content\/uploads\/2022\/11\/Savings_Image-768x156.png 768w\" sizes=\"(max-width: 858px) 100vw, 858px\" \/><\/p>\n<h2><b>Formula to Calculate Savings<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">For every Transaction, savings is calculated on a particular day. <\/span><span style=\"font-weight: 400;\">This formula has been taken from Compound Interest calculation.<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><b>Savings<\/b><span style=\"font-weight: 400;\"> = (<\/span><b>Transaction_Sign<\/b><span style=\"font-weight: 400;\">)(txn_amount) [(1+expense_ratio)<\/span><sup>days_till_today \/ 365<\/sup><span style=\"font-weight: 400;\"> &#8211; 1]<\/span><\/p>\n<table style=\"height: 100px; border-bottom: 1.5px solid #000;\" border=\"1\" width=\"414\">\n<tbody>\n<tr>\n<td style=\"background-color: #00baf1;\"><span style=\"font-size: 12pt; color: #fff;\"><b>Txn_type<\/b><\/span><\/td>\n<td style=\"background-color: #004393;\"><span style=\"font-size: 12pt; color: #fff;\"><b>Transaction_Sign<\/b><\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">BUY<\/span><\/td>\n<td><span style=\"font-weight: 400;\">+1<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">SELL<\/span><\/td>\n<td><span style=\"font-weight: 400;\">-1<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">The expense ratio varies from one mutual fund to another. After the analysis by the product team, expense ratio has been kept the same across all funds which is <\/span><b>one percent<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h2><strong>Straight Approach:<\/strong><\/h2>\n<p><span style=\"font-weight: 400;\">Below are the steps to find total savings using straight approach :<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Let&#8217;s assume the user is having 500 transactions till today.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Fetch all the valid transactions . Each transaction will contain txn_amount, txn_date and txn_type.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The savings for each transaction will be calculated using the above mentioned formula. In order to use the above formula, the number of days from a transaction date till today has to be deduced.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Then total savings is derived after adding each savings.<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/p>\n<pre><b>Total Savings <\/b><span style=\"font-weight: 400;\">= Savings<\/span><sub>1<\/sub><span style=\"font-weight: 400;\"> + Savings<sub>2<\/sub><\/span><span style=\"font-weight: 400;\"> + Savings<sub>3<\/sub><\/span><span style=\"font-weight: 400;\">+ ........Savings<sub>N<\/sub><\/span><\/pre>\n<\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0where N is the number of transactions done by the user.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This will be stored in database table like<\/span><\/p>\n<table style=\"height: 100px; border-bottom: 1.5px solid #000;\" border=\"1\" width=\"414\">\n<tbody>\n<tr>\n<td style=\"background-color: #00baf1;\"><span style=\"font-size: 12pt; color: #fff;\"><b>userId<\/b><\/span><\/td>\n<td style=\"background-color: #004393;\"><span style=\"font-size: 12pt; color: #fff;\"><b>total_savings<\/b><\/span><\/td>\n<td style=\"background-color: #00baf1;\"><span style=\"font-size: 12pt; color: #fff;\"><b>as_on_date<\/b><\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">1234<\/span><\/td>\n<td><span style=\"font-weight: 400;\">2000<\/span><\/td>\n<td><span style=\"font-weight: 400;\">2022-03-16<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><strong>Problem with the above Approach:<\/strong><\/h2>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Calculating a total savings for each user involves many steps.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The cron is required to calculate the total savings and store it in a table. The table will be used for redirecting the total savings amount to the front-end.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">If it is a daily cron, the CPU and memory consumption of servers will be significant along with other heavy jobs since enormous calculations and bulky database calls are involved here.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">If it is a weekly cron, the user will not be knowing the updated savings everyday. The next savings would update after every week. The user could do many transactions in the interval of week and these transactions would not contribute in total savings until the next cron triggers.<\/span><\/li>\n<\/ol>\n<h2><strong>Optimized Approach:<\/strong><\/h2>\n<p><span style=\"font-weight: 400;\">The aim of the optimized approach is to store the previously calculated savings and use the same for the subsequent days instead of fetching all the transactions from the first day.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Optimised Approach involves simplification of the formula.<\/span><\/p>\n<h3><b>Simplification:<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">1- Assume there are three transactions present for a user.<\/span><\/p>\n<table style=\"height: 100px; border-bottom: 1.5px solid #000;\" border=\"1\" width=\"414\">\n<tbody>\n<tr>\n<td style=\"background-color: #00baf1;\"><span style=\"font-size: 12pt; color: #fff;\"><b>txn_type<\/b><\/span><\/td>\n<td style=\"background-color: #004393;\"><span style=\"font-size: 12pt; color: #fff;\"><b>txn_amount<\/b><\/span><\/td>\n<td style=\"background-color: #00baf1;\"><span style=\"font-size: 12pt; color: #fff;\"><b>days_till_now<\/b><\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">BUY<\/span><\/td>\n<td><span style=\"font-weight: 400;\">x<\/span><\/td>\n<td><span style=\"font-weight: 400;\">a<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">BUY<\/span><\/td>\n<td><span style=\"font-weight: 400;\">y<\/span><\/td>\n<td><span style=\"font-weight: 400;\">b<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">SELL<\/span><\/td>\n<td><span style=\"font-weight: 400;\">z<\/span><\/td>\n<td><span style=\"font-weight: 400;\">c<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">2- Expense ratio is &#8220;<\/span><b>r<\/b><span style=\"font-weight: 400;\">&#8220;.<\/span><\/p>\n<p><strong>Total savings as on till date\u00a0<\/strong><\/p>\n<pre><span style=\"font-family: terminal, monaco;\"><span style=\"font-weight: 400;\">= \u00a0 [x(1+r)<\/span><sup>a\/365<\/sup><span style=\"font-weight: 400;\"> -x] + [y(1+r)<sup>b\/365<\/sup><\/span><span style=\"font-weight: 400;\"> -y] - [z(1+r)<sup>c\/365<\/sup><\/span><span style=\"font-weight: 400;\"> - z]<\/span><\/span>\r\n\r\n<span style=\"font-family: terminal, monaco;\"><span style=\"font-weight: 400;\">= \u00a0 (x(1+r)<sup>a\/365<\/sup><\/span><span style=\"font-weight: 400;\"> + y(1+r)<sup>b\/365<\/sup><\/span><span style=\"font-weight: 400;\"> - z(1+r)<sup>c\/365<\/sup><\/span><span style=\"font-weight: 400;\">) - (x + y - z)<\/span><\/span><\/pre>\n<pre><span style=\"font-family: terminal, monaco;\"><span style=\"font-weight: 400;\">Considering \u201c<\/span><b>x + y - z<\/b><span style=\"font-weight: 400;\">\u201d is equal to <\/span><b>Net_Txn_Amount\r\n\r\n<\/b><\/span><\/pre>\n<pre><span style=\"font-family: terminal, monaco;\"><span style=\"font-weight: 400;\">= \u00a0 (x(1+r)<sup>a\/365<\/sup><\/span><span style=\"font-weight: 400;\"> + y(1+r)<sup>b\/365<\/sup><\/span><span style=\"font-weight: 400;\"> - z(1+r)<sup>c\/365<\/sup><\/span><span style=\"font-weight: 400;\">) - <\/span><b>Net_Txn_Amount<\/b><span style=\"font-weight: 400;\"> \u00a0 <\/span><\/span><\/pre>\n<pre><span style=\"font-family: terminal, monaco;\"><span style=\"font-weight: 400;\">Considering (x(1+r)<sup>a\/365<\/sup><\/span><span style=\"font-weight: 400;\"> + y(1+r)<sup>b\/365<\/sup><\/span><span style=\"font-weight: 400;\"> - z(1+r)<sup>c\/365<\/sup><\/span><span style=\"font-weight: 400;\">)\u00a0 as <\/span><b>Net_Investment_Change<\/b><\/span><\/pre>\n<pre><span style=\"font-family: terminal, monaco;\"><span style=\"font-weight: 400;\">= \u00a0 <\/span><b>Net_Investment_Change<\/b><span style=\"font-weight: 400;\"> - <\/span><b>Net_Txn_Amount<\/b><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><\/span><\/pre>\n<p><span style=\"font-weight: 400;\">As one day passes, the total savings has to be calculated for (t+1)<\/span><span style=\"font-weight: 400;\">th<\/span><span style=\"font-weight: 400;\"> day<\/span><\/p>\n<table style=\"height: 100px; border-bottom: 1.5px solid #000;\" border=\"1\" width=\"414\">\n<tbody>\n<tr>\n<td style=\"background-color: #00baf1;\"><span style=\"font-size: 12pt; color: #fff;\"><b>txn_type<\/b><\/span><\/td>\n<td style=\"background-color: #004393;\"><span style=\"font-size: 12pt; color: #fff;\"><b>txn_amount<\/b><\/span><\/td>\n<td style=\"background-color: #00baf1;\"><span style=\"font-size: 12pt; color: #fff;\"><b>days_till_now<\/b><\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">BUY<\/span><\/td>\n<td><span style=\"font-weight: 400;\">x<\/span><\/td>\n<td><span style=\"font-weight: 400;\">a+1<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">BUY<\/span><\/td>\n<td><span style=\"font-weight: 400;\">y<\/span><\/td>\n<td><span style=\"font-weight: 400;\">b+1<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">SELL<\/span><\/td>\n<td><span style=\"font-weight: 400;\">z<\/span><\/td>\n<td><span style=\"font-weight: 400;\">c+1<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">Total savings as on (t+1)<\/span><span style=\"font-weight: 400;\">th<\/span><span style=\"font-weight: 400;\"> date =\u00a0<\/span><\/p>\n<pre><span style=\"font-weight: 400;\"> = \u00a0 [x(1+r)<span style=\"font-family: terminal, monaco;\"><sup>a+1\/365<\/sup><\/span><\/span><span style=\"font-weight: 400;\"> -x] + [y(1+r)<span style=\"font-family: terminal, monaco;\"><sup>b+1\/365<\/sup><\/span><\/span><span style=\"font-weight: 400;\"> -y] - [z(1+r)<span style=\"font-family: terminal, monaco;\"><sup>c+1\/365<\/sup><\/span><\/span><span style=\"font-weight: 400;\"> - z]<\/span>\r\n\r\n<span style=\"font-weight: 400;\">= \u00a0 (x(1+r)<span style=\"font-family: terminal, monaco;\"><sup>a+1\/365<\/sup><\/span><\/span><span style=\"font-weight: 400;\"> + y(1+r)<span style=\"font-family: terminal, monaco;\"><sup>b+1\/365<\/sup><\/span><\/span><span style=\"font-weight: 400;\"> - z(1+r)<span style=\"font-family: terminal, monaco;\"><sup>c+1\/365<\/sup><\/span><\/span><span style=\"font-weight: 400;\">) - (x + y - z)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">= \u00a0 (x(1+r)<span style=\"font-family: terminal, monaco;\"><sup>(a\/365)(1\/365)<\/sup><\/span><\/span><span style=\"font-weight: 400;\"> + y(1+r)<span style=\"font-family: terminal, monaco;\"><sup>(b\/365)(1\/365)<\/sup><\/span><\/span><span style=\"font-weight: 400;\"> - z(1+r)<span style=\"font-family: terminal, monaco;\"><sup>(c\/365)(1\/365)<\/sup><\/span><\/span><span style=\"font-weight: 400;\">) - <\/span><b>Net_Txn_Amount<\/b><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span>\r\n\r\n<span style=\"font-weight: 400;\">Since \u201cx + y - z\u201d is equal to <\/span><b>Net_Txn_Amount<\/b>\r\n\r\n<span style=\"font-weight: 400;\">= \u00a0 (1+r)<span style=\"font-family: terminal, monaco;\"><sup>1\/365<\/sup><\/span><\/span><span style=\"font-weight: 400;\">[x(1+r)<span style=\"font-family: terminal, monaco;\"><sup>a\/365<\/sup><\/span><\/span><span style=\"font-weight: 400;\"> + y(1+r)<span style=\"font-family: terminal, monaco;\"><sup>b\/365<\/sup><\/span><\/span><span style=\"font-weight: 400;\"> - z(1+r)<span style=\"font-family: terminal, monaco;\"><sup>c\/365<\/sup><\/span><\/span><span style=\"font-weight: 400;\">] - <\/span><b>Net_Txn_Amount<\/b><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \/\/ Taking out common multiplier <\/span><b>(1+r)<span style=\"font-family: terminal, monaco;\"><sup>1\/365<\/sup><\/span><\/b>\r\n\r\n<span style=\"font-weight: 400;\">=\u00a0 \u00a0 (1+r)<span style=\"font-family: terminal, monaco;\"><sup>1\/365<\/sup><\/span><\/span><span style=\"font-weight: 400;\">[ <\/span><b>Net_Investment_Change<\/b><span style=\"font-weight: 400;\"> ] - <\/span><b>Net_Txn_Amount<\/b><span style=\"font-weight: 400;\"> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span>\r\n<span style=\"font-weight: 400;\">\/\/ because <\/span><b>Net_Investment_Change<\/b><span style=\"font-weight: 400;\"> = x(1+r)<span style=\"font-family: terminal, monaco;\"><sup>a\/365<\/sup><\/span><\/span><span style=\"font-weight: 400;\"> + y(1+r)<span style=\"font-family: terminal, monaco;\"><sup>b\/365<\/sup><\/span><\/span><span style=\"font-weight: 400;\"> - z(1+r)<span style=\"font-family: terminal, monaco;\"><sup>c\/365<\/sup><\/span><\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">Hence total savings on (t+1)<span style=\"font-family: terminal, monaco;\"><sup>th<\/sup><\/span><\/span><span style=\"font-weight: 400;\"> date = <\/span><b>(1+r)<span style=\"font-family: terminal, monaco;\"><sup>1\/365<\/sup><\/span><\/b><b>[ Net_Investment_Change ] - Net_Txn_Amount<\/b><span style=\"font-weight: 400;\">\u00a0\u00a0<\/span>\r\n\r\n<span style=\"font-weight: 400;\">Therefore total savings on (<\/span><b>t+q<\/b><span style=\"font-weight: 400;\">)<span style=\"font-family: terminal, monaco;\"><sup>th<\/sup><\/span><\/span><span style=\"font-weight: 400;\"> date = <\/span><b>(1+r)<span style=\"font-family: terminal, monaco;\"><sup>q\/365<\/sup><\/span><\/b><b>[ Net_Investment_Change ] - Net_Txn_Amount<\/b><\/pre>\n<h2><b>How has the simplified formula been used ?<\/b><\/h2>\n<p><span style=\"font-weight: 400;\"><strong>1-<\/strong> A database table in portfolio-insights called <\/span><b>total_savings_info<\/b><span style=\"font-weight: 400;\"> is created.<\/span><\/p>\n<table style=\"height: 100px; border-bottom: 1.5px solid #000;\" border=\"1\" width=\"414\">\n<tbody>\n<tr>\n<td style=\"background-color: #00baf1;\"><span style=\"font-size: 12pt; color: #fff;\"><b>userId<\/b><\/span><\/td>\n<td style=\"background-color: #004393;\"><span style=\"font-size: 12pt; color: #fff;\"><b>net_investment_change<\/b><\/span><\/td>\n<td style=\"background-color: #00baf1;\"><span style=\"font-size: 12pt; color: #fff;\"><b>net_transaction_amount<\/b><\/span><\/td>\n<td style=\"background-color: #004393;\"><span style=\"font-size: 12pt; color: #fff;\"><b>total_savings<\/b><\/span><\/td>\n<td style=\"background-color: #00baf1;\"><span style=\"font-size: 12pt; color: #fff;\"><b>as_on_date<\/b><\/span><\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\"><strong>2-<\/strong> Let\u2019s assume, today is March 16, 2022. The new transaction has been received for the userId : 1234 with the following details<\/span><\/p>\n<table style=\"height: 100px; border-bottom: 1.5px solid #000;\" border=\"1\" width=\"414\">\n<tbody>\n<tr>\n<td style=\"background-color: #00baf1;\"><span style=\"font-size: 12pt; color: #fff;\"><b>userId<\/b><\/span><\/td>\n<td style=\"background-color: #004393;\"><span style=\"font-size: 12pt; color: #fff;\"><b>txn_amount<\/b><\/span><\/td>\n<td style=\"background-color: #00baf1;\"><span style=\"font-size: 12pt; color: #fff;\"><b>txn_type<\/b><\/span><\/td>\n<td style=\"background-color: #004393;\"><span style=\"font-size: 12pt; color: #fff;\"><b>txn_date<\/b><\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">1234<\/span><\/td>\n<td><span style=\"font-weight: 400;\">1,00,000<\/span><\/td>\n<td><span style=\"font-weight: 400;\">BUY<\/span><\/td>\n<td><span style=\"font-weight: 400;\">2022-03-14<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\"><strong>3-<\/strong> The <\/span><b>total_savings_info<\/b><span style=\"font-weight: 400;\"> table is populated once the new transaction has been received.<\/span><\/p>\n<table style=\"height: 100px; border-bottom: 1.5px solid #000;\" border=\"1\" width=\"414\">\n<tbody>\n<tr>\n<td style=\"background-color: #00baf1;\"><span style=\"font-size: 12pt; color: #fff;\"><b>userId<\/b><\/span><\/td>\n<td style=\"background-color: #004393;\"><span style=\"font-size: 12pt; color: #fff;\"><b>net_investment_change<\/b><\/span><\/td>\n<td style=\"background-color: #00baf1;\"><span style=\"font-size: 12pt; color: #fff;\"><b>net_transaction_amount<\/b><\/span><\/td>\n<td style=\"background-color: #004393;\"><span style=\"font-size: 12pt; color: #fff;\"><b>total_savings<\/b><\/span><\/td>\n<td style=\"background-color: #00baf1;\"><span style=\"font-size: 12pt; color: #fff;\"><b>as_on_date<\/b><\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">1234<\/span><\/td>\n<td><span style=\"font-weight: 400;\">100005.45<\/span><\/td>\n<td><span style=\"font-weight: 400;\">100000<\/span><\/td>\n<td><span style=\"font-weight: 400;\">5.452<\/span><\/td>\n<td><span style=\"font-weight: 400;\">2022-03-16<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\"><strong>4-<\/strong> Let\u2019s suppose the user lands on a portfolio page on the next day which is March 17, 2022. The savings till\u00a0 2022-03-17 will be calculated on the fly using the simplified formula.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">Total savings on (<\/span><b>t+q<\/b><span style=\"font-weight: 400;\">)<span style=\"font-family: terminal, monaco;\"><sup>th<\/sup><\/span><\/span><span style=\"font-weight: 400;\"> date = <\/span><b>(1+r)<span style=\"font-family: terminal, monaco;\"><sup>q\/365<\/sup><\/span><\/b><b>[ Net_Investment_Change ] - Net_Txn_Amount<\/b><b>\r\n<\/b><span style=\"font-weight: 400;\">Here the \u201c<\/span><b>q<\/b><span style=\"font-weight: 400;\">\u201d is 1 because the difference between 2022-03-16 and 2022-03-17 is 1.<\/span>\r\n<b>Total Savings<\/b><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">(1+r)<span style=\"font-family: terminal, monaco;\"><sup>1\/365<\/sup><\/span><\/span><span style=\"font-weight: 400;\">[ Net_Investment_Change ] - Net_Txn_Amount\u00a0 <\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 =\u00a0 (1.000027)[100005.45] - 100000<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 = \u00a0 8.178<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Whenever there is a new transaction, , <\/span><b>total_savings_info <\/b><span style=\"font-weight: 400;\">table is populated from the scratch for the given userId. Therefore net_investment_change, net_transaction_amount and total_savings will be changed in case of a new transaction.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Thus the pre-calculated values are used to calculate the savings for any subsequent days.<\/span><\/p>\n<h2><b>Advantages of Optimized Approach:\u00a0<\/b><\/h2>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">This will save a lot of computations to calculate the savings for every user.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>With the above formula, the daily or weekly cron is not required.<\/b><b><br \/>\n<\/b><span style=\"font-weight: 400;\">Since as_on_date is saved in the total_savings_info table. <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">Thus the number of days from as_on_date till date is considered as &#8220;q&#8221; and below formula can be used.<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">Total savings on (<\/span><b>t+q<\/b><span style=\"font-weight: 400;\">)<span style=\"font-family: terminal, monaco;\"><sup>th<\/sup><\/span><\/span><span style=\"font-weight: 400;\">\u00a0date = <\/span><b>(1+r)<\/b><span style=\"font-family: terminal, monaco;\"><sup>q\/365<\/sup><\/span><b>[ Net_Investment_Change ] &#8211; Net_Txn_Amount.<\/b><b><br \/>\n<\/b><b>Hence the total savings can be calculated on the fly whenever there is a request rather than updating in the database all the time.<\/b><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The CPU and memory utilization of servers will be reduced significantly if the cron is not configured for the bulky computation.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Currently, there are around 6 lakh active users in the mutual fund. Calculating savings for all of them would have incurred cost on infrastructure because this would have taken around 1-2 hours to complete the process<\/span><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Tech Design :\u00a0 <\/span><a href=\"https:\/\/www.linkedin.com\/in\/shreyas-hosur3096\"><span style=\"font-weight: 400;\">Shreyas Hosur<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/a><span style=\"font-weight: 400;\">Developers : <\/span><a href=\"https:\/\/www.linkedin.com\/in\/shreyas-hosur3096\"><span style=\"font-weight: 400;\">Shreyas Hosur<\/span><\/a><span style=\"font-weight: 400;\">, <\/span><a href=\"https:\/\/www.linkedin.com\/in\/tiwari-karan\/\"><span style=\"font-weight: 400;\">Karan Tiwari<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/a><span style=\"font-weight: 400;\">Product : <\/span><a href=\"https:\/\/www.linkedin.com\/in\/harpreetbhatoa\"><span style=\"font-weight: 400;\">Harpreet Bhatoa<\/span><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are two categories of Mutual Funds namely Direct Mutual Fund and Regular Mutual Fund. What are Direct Mutual Funds?\u00a0 Direct Mutual Funds is the type of mutual fund that is directly offered by the AMC or fund house. In other words, there is no involvement of third party agents \u2013 brokers or distributors. Since<a href=\"https:\/\/www.paytmmoney.com\/blog\/optimizing-savings-calculation-on-direct-mutual-funds\/\">Continue reading <span class=\"sr-only\">&#8220;Optimizing the Savings Calculation on Direct Mutual Funds&#8221;<\/span><\/a><\/p>\n","protected":false},"author":27,"featured_media":3719,"comment_status":"open","ping_status":"open","sticky":false,"template":"single-classic-ns.php","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-3718","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/www.paytmmoney.com\/blog\/wp-json\/wp\/v2\/posts\/3718","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.paytmmoney.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.paytmmoney.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.paytmmoney.com\/blog\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/www.paytmmoney.com\/blog\/wp-json\/wp\/v2\/comments?post=3718"}],"version-history":[{"count":0,"href":"https:\/\/www.paytmmoney.com\/blog\/wp-json\/wp\/v2\/posts\/3718\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.paytmmoney.com\/blog\/wp-json\/wp\/v2\/media\/3719"}],"wp:attachment":[{"href":"https:\/\/www.paytmmoney.com\/blog\/wp-json\/wp\/v2\/media?parent=3718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.paytmmoney.com\/blog\/wp-json\/wp\/v2\/categories?post=3718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.paytmmoney.com\/blog\/wp-json\/wp\/v2\/tags?post=3718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}