Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tut] Strategic Investing with Python: Ensuring Your Kids Have $70k at 21

#1
Strategic Investing with Python: Ensuring Your Kids Have $70k at 21

<div>
<div class="kk-star-ratings kksr-auto kksr-align-left kksr-valign-top" data-payload='{&quot;align&quot;:&quot;left&quot;,&quot;id&quot;:&quot;1039597&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;top&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;2&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;5&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;5\/5 - (2 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;width&quot;:&quot;142.5&quot;,&quot;_legend&quot;:&quot;{score}\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>
<div class="kksr-stars">
<div class="kksr-stars-inactive">
<div class="kksr-star" data-star="1" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="2" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="3" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="4" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="5" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
</p></div>
<div class="kksr-stars-active" style="width: 142.5px;">
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
</p></div>
</div>
<div class="kksr-legend" style="font-size: 19.2px;"> 5/5 – (2 votes) </div>
</p></div>
<p>As a parent, planning for your children’s future is one of the most important things you can do. </p>
<p>To ensure they have the best possible start in life, I’ve been looking into ways to invest money to provide them with a lump sum of $70k when they reach 21. But I don’t want to spend that much money at once when they turn 21.</p>
<p><strong><em>So what to do?</em></strong></p>
<p>In this blog post, I’ll be exploring how Python helped me figure out a simple investment plan, so I can give my kids a nice nest egg without needing to spend a lot of our (parents’Wink money at once.</p>
<p class="has-base-background-color has-background"><img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f449.png" alt="?" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Result</strong>: I need to set up a savings plan contributing $90 per month for 21 years in a vehicle earning 9% per year (e.g., S&amp;P500 ETF), so my kids get a $70k nest egg when they start into their own lives.</p>
<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="956" height="637" src="https://blog.finxter.com/wp-content/uploads/2023/01/image-26.png" alt="" class="wp-image-1039620" srcset="https://blog.finxter.com/wp-content/uploads/2023/01/image-26.png 956w, https://blog.finxter.com/wp-content/uplo...00x200.png 300w, https://blog.finxter.com/wp-content/uplo...68x512.png 768w" sizes="(max-width: 956px) 100vw, 956px" /></figure>
</div>
<p>Here’s the Python code — I’ll explain it in a moment:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="" data-enlighter-highlight="5-8" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import matplotlib.pyplot as plt
import numpy as np # Define initial investment value, investment return, and monthly contributions
initial_investment = 1000
investment_return = 0.09
monthly_contributions = [30,60,90]
num_years = 21 # Create list of portfolio values over time for each savings rate
portfolio_values = []
for contribution in monthly_contributions: portfolio = [initial_investment] portfolio_value = initial_investment for i in range(1,num_years-1): portfolio_value = portfolio_value * (1 + investment_return) + contribution * 12 portfolio.append(portfolio_value) portfolio_values.append(portfolio) # Plot portfolio values over time
time = np.arange(1,num_years)
for i in range(len(monthly_contributions)): plt.plot(time, portfolio_values[i], label='$' + str(monthly_contributions[i]) + '/m')
plt.title('Portfolio Value over Time')
plt.xlabel('Time (years)')
plt.ylabel('Portfolio Value ($)') # Add end value labels
for i in range(len(monthly_contributions)): plt.text(num_years-3, portfolio_values[i][-1], '$' + str(int(portfolio_values[i][-1]*1.3))) plt.legend()
plt.show()
</pre>
<p>Result:</p>
<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" loading="lazy" width="796" height="687" src="https://blog.finxter.com/wp-content/uploads/2023/01/image-25.png" alt="" class="wp-image-1039601" srcset="https://blog.finxter.com/wp-content/uploads/2023/01/image-25.png 796w, https://blog.finxter.com/wp-content/uplo...00x259.png 300w, https://blog.finxter.com/wp-content/uplo...68x663.png 768w" sizes="(max-width: 796px) 100vw, 796px" /></figure>
</div>
<p>This code snippet plots the value of a portfolio for different monthly contributions over a period of 21 years. </p>
<p>You specify the </p>
<ul>
<li>initial investment value, </li>
<li>investment return, </li>
<li>number of years, and </li>
<li>monthly contributions. </li>
</ul>
<p>Then, you <a href="https://blog.finxter.com/how-to-create-a-python-list/" data-type="post" data-id="10436" target="_blank" rel="noreferrer noopener">create a list</a> to store the portfolio values over time for each monthly contribution.</p>
<p>You calculate the portfolio values by multiplying the previous value of the portfolio by the investment return plus the contribution for each month. You repeat this calculation over the number of years minus one, taking the initial investment into account.</p>
<p>You use Matplotlib to plot the portfolio values. The x-axis is the time in years and the y-axis is the portfolio value in dollars. </p>
<p class="has-base-background-color has-background"><img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f449.png" alt="?" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Recommended Tutorial</strong>: <a href="https://blog.finxter.com/matplotlib-full-guide/" data-type="post" data-id="20151" target="_blank" rel="noreferrer noopener">A Video Guide on Matplotlib</a></p>
<p>You add a title and labels to the plot. You also add the end value for each of the portfolios to the plot with a text label. Finally, you display the plot.</p>
<h2>Action Steps</h2>
<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" loading="lazy" width="957" height="637" src="https://blog.finxter.com/wp-content/uploads/2023/01/image-27.png" alt="" class="wp-image-1039634" srcset="https://blog.finxter.com/wp-content/uploads/2023/01/image-27.png 957w, https://blog.finxter.com/wp-content/uplo...00x200.png 300w, https://blog.finxter.com/wp-content/uplo...68x511.png 768w" sizes="(max-width: 957px) 100vw, 957px" /></figure>
</div>
<ul>
<li>Copy the code into your own Python script.</li>
<li>Figure out your (base) investment goals for your kids or yourself. What do you need to accomplish? What would be your dream outcome?</li>
<li>Change the input values until you’re happy with your results.</li>
</ul>
<p>You can check out our <a rel="noreferrer noopener" href="https://academy.finxter.com/university/matplotlib-a-guide-to-becoming-a-data-visualization-wizard/" data-type="URL" data-id="https://academy.finxter.com/university/matplotlib-a-guide-to-becoming-a-data-visualization-wizard/" target="_blank">Finxter Academy course on Matplotlib</a> to learn all you need to use plotting and data visualization in Python.</p>
<hr class="wp-block-separator has-alpha-channel-opacity"/>
<p>This is part of our <strong>100 practical Python projects</strong> series. <a rel="noreferrer noopener" href="https://blog.finxter.com/email-academy/" data-type="page" data-id="12278" target="_blank">Subscribe here</a>.</p>
</div>


https://www.sickgaming.net/blog/2023/01/...70k-at-21/
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016