Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
@knockaway/loan-calculator
Advanced tools
The goal of this project is to make loan calculations as simple as using any one of the free online loan calculators. Just inputs and outputs!
The goal of this project is to make loan calculations as simple as using any one of the free online loan calculators. Just inputs and outputs!
Do you have an idea for a loan-calculator function? We welcome open source contributions!
Brought to you by the developers at Knock, who found the need to calculate APR, APY, and monthly payments for features related to the Knock Home Swap.
It may be used by both CJS and ESM module formats.
Calculates the APR (Annual Percentage Rate) of a loan with the given fees and structure.
import { calculateApr } from '@knockaway/loan-calculator';
const apr = calculateApr({
loanAmount: 320000,
interestRate: 0.03,
numberOfPayments: 360,
paymentFrequency: 12,
compoundingFrequency: 12,
financedFees: 4000,
upfrontFees: 1000
});
// apr ~ 0.03122
loanAmount
Amount to be loaned, after down payment.interestRate
Raw interest rate, e.g. 0.03125numberOfPayments
Number of payments in full loan term, e.g. 360 for a
30 Year Mortgage paid monthlypaymentFrequency
How many times per year payments are made. Default: 12compoundingFrequency
How many times per year interest compounds. Default: 12financedFees
Financed fees are rolled into the loan and increase the
monthly payment. Default: 0upfrontFees
Upfront fees effectively reduce the amount initially received in the
loan instead of increasing monthly payment. Default: 0Calculates the APY (Annual Percentage Yield) of a loan with the given interest rate.
import { calculateApy } from '@knockaway/loan-calculator';
const apy = calculateApy({
interestRate: 0.03122,
compoundingFrequency: 12
});
// apy ~ 0.03167
interestRate
Raw interest rate, e.g. 0.03125compoundingFrequency
How many times per year interest compounds. Default: 12Just like the PMT function of a spreadsheet, this function calculates the periodic payment needed to pay off the present loan balance after n periods of payments and compounding at the given interest rate.
import { calculatePayment } from '@knockaway/loan-calculator';
const pmt = calculatePayment({
presentValue: 320000,
interestRate: 0.03 / 12,
numberOfPayments: 360
});
// pmt ~ 1349.13
presentValue
Present value of the loaninterestRate
Raw interest rate, e.g. 0.03125numberOfPayments
Number of payments in full loan term, e.g. 360 for a
30 Year Mortgage paid monthlyFinds the interest rate where compounding at the new annual frequency generates the same effective annual interest as the given interest rate at the old annual frequency.
This is best explained by an example. Suppose you have a loan with 4% annual interest compounding monthly but payments are made quarterly. The monthly interest rate is 0.04 / 12, which compounded 12 times gives an APY rate of (1 + 0.04 / 12)^12 - 1 == 0.04074. This function wlil determine the interest rate which can be compounded only 4 times (quarterly) and produce the same effective interest rate of 0.04074.
import { convertCompoundingFrequency } from '@knockaway/loan-calculator';
const rate = convertCompoundingFrequency({
interestRate: 0.06,
oldCompoundingFrequency: 12,
newCompoundingFrequency: 4
});
// rate ~ 0.0603
interestRate
Raw interest rate, e.g. 0.03125oldCompoundingFrequency
How many times per year interest compounds.newCompoundingFrequency
How many times per year interest will compound after conversion.FAQs
The goal of this project is to make loan calculations as simple as using any one of the free online loan calculators. Just inputs and outputs!
We found that @knockaway/loan-calculator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 30 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.