是否有Java API或内置函数可以解决年金问题?

发布于 2024-07-26 19:53:10 字数 216 浏览 6 评论 0原文

我的老板要求我创建一个用于计算反向复合的模块。

问题是:如果我想在 24 个月内达到 1.000.000,00 美元,利率为 18%/年(或 1.5%/月)。 我每个月必须存多少钱?

我在网上查了一下,除了有人提到Excel公式之外,什么也没找到。 你知道这种情况的数学公式是什么吗?

我在这个模块中使用 Java。 有Java库或者API吗?

I was asked by my boss to create a module for calculating reverse compound.

The question is: if I want to achieve $1.000.000,00 in 24 months with interest rate 18%/year (or 1.5%/month). how much money do I have to save every month?

I searched on the internet, but found nothing except people referring to the Excel formula.
Do you know what the mathematical formula is for this case?

I am using Java for this module. Is there any Java library or API?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

与君绝 2024-08-02 19:53:10

假设您在每个月初投资 D 美元,为期 M 个月,每月复利利率为 r。 我们将设置i = r / 12M 个月结束后,您

D * (1 + i)^M + D * (1 + i)^(M - 1) + D * (1 + i)^(M - 2) + ...
    D * (1 + i)

的帐户中将有资金。 这是因为第一个月的D美元投资了M个月,第二个月的D美元投资了M-1 个月,依此类推。 这是一个几何级数并简化为

D * (1 + i) * ((1 + i)^M - 1) / i.

因此,如果你想要X 在您的帐户中,在 M 个月结束时,您解决了

X = D * (1 + i) * ((1 + i)^M - 1) / i

D 以获得问题

D = X * i / ((1 + i) * ((1 + i)^M - 1)).

您实际上并不需要 API 来解决此问题,因为您可以看到该解决方案非常简单简单的。 您可能想在这里阅读的概念是年金

Let us say that you are investing D dollars at the beginning of each month for M months earning an interest rate of r compounded monthly. We will set i = r / 12. At the end of M months you will have

D * (1 + i)^M + D * (1 + i)^(M - 1) + D * (1 + i)^(M - 2) + ...
    D * (1 + i)

in your account. This is because the D dollars in the first month are invested for M months, the D dollars in the second month are invested for M-1 months, and so on. This is a geometric progression and simplifies to

D * (1 + i) * ((1 + i)^M - 1) / i.

Therefore, if you want X in your account at the end of M months you solve

X = D * (1 + i) * ((1 + i)^M - 1) / i

for D to obtain

D = X * i / ((1 + i) * ((1 + i)^M - 1)).

You don't really need an API here to solve this as you can see the solution is quite simple. The concept that you might want to read about here is that of annuities.

陈甜 2024-08-02 19:53:10

如果您这样做不是为了贷款目的,其他答案中发布的简单公式可能就足够了。

如果这是针对任何类型的金融活动,请注意任何简单的复利计算。 如果是任何贷款,您可能需要遵守严格的规则(例如在英国,利率必须以年利率的形式报价)。

计算需要考虑以下因素:

  • 一个月中的可变天数
  • 利息是每日还是每月
  • 计算 借款在哪一天提取
  • 每月还款日是哪一天。
  • 其他东西我不记得了,但你最好查一下你的合同是否具有法律约束力。

实际上,这需要一种迭代形式来找到定期和最终付款。

If you are not doing it for lending purposes, the simple formulae posted in other answers will probably be good enough.

If this is for any kind of financial activity, beware of any simple calculation for compound interest. If it is for any lending you are probably required to conform to strict rules (e.g in the UK the rate must be quoted in the form of an APR).

The calculations need to take into account:

  • the variable days in a month
  • whether interest is applied daily or monthly
  • what day the borrowing was drawn down
  • the day of the month payment has been taken.
  • other stuff I can't remember but you'd better look up for your contract to be legally binding

In practice this needs a form of iteration to find the regular and final payments.

童话里做英雄 2024-08-02 19:53:10

您想要的公式S = R * [(1+i )^n - 1] / i

S = the required amount at the end (1,000,000)
R = the regular payment (what you want)
i = the periodic rate of interest (0.015)
n = the number of time periods (24)

所以你的答案 R = 1000000 * .015 / (1.015^24 - 1) (~= 34924.10)

编辑:

这假设付款是在每个周期结束时,如果在每个周期开始时付款,则将您的答案除以 (1+i)

The formula you want is S = R * [(1+i)^n - 1] / i where

S = the required amount at the end (1,000,000)
R = the regular payment (what you want)
i = the periodic rate of interest (0.015)
n = the number of time periods (24)

so your answer R = 1000000 * .015 / (1.015^24 - 1) (~= 34924.10)

EDIT:

This assumes payments are at the end of each period, if payments are made at the beginning of each period, then divide your answer by (1+i)

一桥轻雨一伞开 2024-08-02 19:53:10

我认为可以满足您的需求。 它甚至是 LGPL,即使您的资金回报率为 18%,价格也不重要;-)。

I think this gets you what you want. Its even LGPL, even though if you are getting 18% returns on your money, price shouldn't matter ;-).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文