本文整理汇总了Python中numpy.pmt函数的典型用法代码示例。如果您正苦于以下问题:Python pmt函数的具体用法?Python pmt怎么用?Python pmt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pmt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pmt
def test_pmt(self):
res = np.pmt(0.08 / 12, 5 * 12, 15000)
tgt = -304.145914
assert_allclose(res, tgt)
# Test the edge case where rate == 0.0
res = np.pmt(0.0, 5 * 12, 15000)
tgt = -250.0
assert_allclose(res, tgt)
# Test the case where we use broadcast and
# the arguments passed in are arrays.
res = np.pmt([[0.0, 0.8], [0.3, 0.8]], [12, 3], [2000, 20000])
tgt = np.array([[-166.66667, -19311.258], [-626.90814, -19311.258]])
assert_allclose(res, tgt)
示例2: __init__
def __init__(self, loan_id, grade, int_rate, term, amount, issue_date,
last_date, defaults, investment, total_payment, total_principle, recoveries):
self.id = loan_id
self.grade = grade
self.int_rate = int_rate
self.term = int(term.strip().split(' ')[0])
self.amount = amount
self.initial_amount = self.amount
self.issue_date = issue_date
self.last_date = last_date
self.investment = investment
self.defaults = defaults
self.total_payment = total_payment
self.total_principle = total_principle
self.recoveries = recoveries
self.imbalance_ratio = np.nan
self.term_realized = self.last_date - self.issue_date
if self.defaults:
# warnings.warn('have not yet implemented defaulting loans')
self.amount = self.total_payment
self.installment = np.round(-np.pmt(self.int_rate / 12, self.term_realized, self.amount), 2)
self.remaining_term = self.term_realized
self.scale = (self.investment / self.initial_amount)
self.imbalance = 0
self.complete = False
self.fee = 0.01
示例3: add_current_rents
def add_current_rents(dataset,buildings,year,rent=0,convert_res_rent_to_yearly=0,convert_res_sales_to_yearly=0):
buildings['nonres_rent'] = dataset.load_attr('nonresidential_rent',year)
if not rent:
buildings['res_rent'] = dataset.load_attr('residential_sales_price',year)
if convert_res_sales_to_yearly: buildings.res_rent = np.pmt(developer.INTERESTRATE,developer.PERIODS,buildings.res_rent)*-1
else: buildings['res_rent'] = dataset.load_attr('residential_rent',year)*(12 if convert_res_rent_to_yearly else 1)
buildings['rent'] = buildings['nonres_rent'].combine_first(buildings['res_rent'])
return buildings
示例4: levelize_costs
def levelize_costs(self):
if hasattr(self, 'is_levelized'):
inflation = float(cfg.cfgfile.get('case', 'inflation_rate'))
rate = self.cost_of_capital - inflation
if self.is_levelized == 0:
self.values_level = - np.pmt(rate, self.book_life, 1, 0, 'end') * self.values
util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False)
else:
self.values_level = self.values.copy()
util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False)
self.values = np.pv(rate, self.book_life, -1, 0, 'end') * self.values
else:
raise ValueError('Supply Technology id %s needs to indicate whether costs are levelized ' %self.id)
示例5: levelize_costs
def levelize_costs(self):
if hasattr(self, 'is_levelized'):
inflation = float(cfg.cfgfile.get('case', 'inflation_rate'))
rate = self.cost_of_capital - inflation
if self.is_levelized == 0:
self.values_level = - np.pmt(rate, self.book_life, 1, 0, 'end') * self.values
util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False)
else:
self.values_level = self.values.copy()
util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False)
self.values = np.pv(rate, self.book_life, -1, 0, 'end') * self.values
else:
util.convert_age(self, vintages=self.vintages, years=self.years, reverse=False)
示例6: test_pmt_decimal
def test_pmt_decimal(self):
res = np.pmt(Decimal('0.08') / Decimal('12'), 5 * 12, 15000)
tgt = Decimal('-304.1459143262052370338701494')
assert_equal(res, tgt)
# Test the edge case where rate == 0.0
res = np.pmt(Decimal('0'), Decimal('60'), Decimal('15000'))
tgt = -250
assert_equal(res, tgt)
# Test the case where we use broadcast and
# the arguments passed in are arrays.
res = np.pmt([[Decimal('0'), Decimal('0.8')], [Decimal('0.3'), Decimal('0.8')]],
[Decimal('12'), Decimal('3')], [Decimal('2000'), Decimal('20000')])
tgt = np.array([[Decimal('-166.6666666666666666666666667'), Decimal('-19311.25827814569536423841060')],
[Decimal('-626.9081401700757748402586600'), Decimal('-19311.25827814569536423841060')]])
# Cannot use the `assert_allclose` because it uses isfinite under the covers
# which does not support the Decimal type
# See issue: https://github.com/numpy/numpy/issues/9954
assert_equal(res[0][0], tgt[0][0])
assert_equal(res[0][1], tgt[0][1])
assert_equal(res[1][0], tgt[1][0])
assert_equal(res[1][1], tgt[1][1])
示例7: get_possible_rents_by_use
def get_possible_rents_by_use(dset):
parcels = dset.parcels
# need a prevailing rent for each parcel
nodeavgrents = pd.read_csv('avenodeprice.csv',index_col='node_id')
# convert from price per sqft to yearly rent per sqft
nodeavgrents['rent'] = np.pmt(spotproforma.INTERESTRATE,spotproforma.PERIODS,nodeavgrents.price*-1)
# need predictions of rents for each parcel
avgrents = pd.DataFrame(index=parcels.index)
avgrents['residential'] = nodeavgrents.rent.ix[parcels._node_id].values
# make a stupid assumption converting the residential
# rent which I have to non-residential rent which I don't have
avgrents['office'] = nodeavgrents.rent.ix[parcels._node_id].values*1.0
avgrents['retail'] = nodeavgrents.rent.ix[parcels._node_id].values*.8
avgrents['industrial'] = nodeavgrents.rent.ix[parcels._node_id].values*.5
return avgrents
示例8: actual_monthly
def actual_monthly(self):
"""User actually paid monthly money for the car."""
actual_monthly = numpy.pmt(
self.loan_at / 12,
self.total_months,
-self.finance_value,
self.loan_at_end
)
logger.info('numpy.pmt({},{},{},{})={}'.format(
self.loan_at / 12,
self.total_months,
-self.finance_value,
self.loan_at_end,
actual_monthly
))
return round(actual_monthly, 2)
示例9: main
def main():
"""Module retirement"""
if not len(sys.argv) == 2:
print('usage: {} rate'.format(sys.argv[0]))
sys.exit(1)
rate = float(sys.argv[1])/12/100
startdate = 2004 + 10./12
today = 2015 + 5./12
amount = 222000
retirementdate = 1981 + 60 + 10./12
endend = 1981 + 10./12 + 100
inflation = 2./100./12. + 1
spending = 40000
contribution = np.pmt(rate, int(round((today - startdate) * 12)), 0, amount)
print('contribution {}'.format(contribution))
cur_time = today
while cur_time < retirementdate:
cur_time += 1./12
interest = amount * rate
amount += -contribution + interest
contribution *= inflation
spending *= inflation
print('retire contribution {} amount {} spending {}'
.format(contribution, amount, spending))
while cur_time < endend and amount > 0:
cur_time += 1./12
interest = amount * rate
amount += interest
amount -= spending / 12.
spending *= inflation
print('end time {} spending {} amount {}'.format(cur_time, spending, amount))
print('')
示例10: walk_forward_projection
def walk_forward_projection(principal, annual_rate, months=None, payment=1200):
"""
:param payment:
:param principal: positive value
:param months: compounding periods (can be weeks)
:param annual_rate: matches compounding periods (can be weekly rate)
:return:
"""
loan_table = pd.DataFrame(columns=('payment', 'interest_segment', 'principal_segment', 'balance'))
annual_rate /= 12 # Make the rate a monthly rate.
# Initialise Table
loan_table.loc[0] = [0, 0, 0, principal]
# Handles pay by amount
if months is not None:
payment = -np.pmt(annual_rate, months, principal) # Handles pay by amount
time_step = 1
balance = principal
while not (balance <= 0 or time_step > 100):
fraction_interest = balance * annual_rate
if balance > payment:
balance = round(balance + fraction_interest - payment, 2)
else:
payment = balance
balance = 0
fractional_principal = payment - fraction_interest
loan_table.loc[time_step] = [payment, fraction_interest, fractional_principal, balance]
time_step += 1
return loan_table
示例11: test_when
def test_when(self):
# begin
assert_almost_equal(np.rate(10, 20, -3500, 10000, 1), np.rate(10, 20, -3500, 10000, "begin"), 4)
# end
assert_almost_equal(np.rate(10, 20, -3500, 10000), np.rate(10, 20, -3500, 10000, "end"), 4)
assert_almost_equal(np.rate(10, 20, -3500, 10000, 0), np.rate(10, 20, -3500, 10000, "end"), 4)
# begin
assert_almost_equal(np.pv(0.07, 20, 12000, 0, 1), np.pv(0.07, 20, 12000, 0, "begin"), 2)
# end
assert_almost_equal(np.pv(0.07, 20, 12000, 0), np.pv(0.07, 20, 12000, 0, "end"), 2)
assert_almost_equal(np.pv(0.07, 20, 12000, 0, 0), np.pv(0.07, 20, 12000, 0, "end"), 2)
# begin
assert_almost_equal(np.fv(0.075, 20, -2000, 0, 1), np.fv(0.075, 20, -2000, 0, "begin"), 4)
# end
assert_almost_equal(np.fv(0.075, 20, -2000, 0), np.fv(0.075, 20, -2000, 0, "end"), 4)
assert_almost_equal(np.fv(0.075, 20, -2000, 0, 0), np.fv(0.075, 20, -2000, 0, "end"), 4)
# begin
assert_almost_equal(np.pmt(0.08 / 12, 5 * 12, 15000.0, 0, 1), np.pmt(0.08 / 12, 5 * 12, 15000.0, 0, "begin"), 4)
# end
assert_almost_equal(np.pmt(0.08 / 12, 5 * 12, 15000.0, 0), np.pmt(0.08 / 12, 5 * 12, 15000.0, 0, "end"), 4)
assert_almost_equal(np.pmt(0.08 / 12, 5 * 12, 15000.0, 0, 0), np.pmt(0.08 / 12, 5 * 12, 15000.0, 0, "end"), 4)
# begin
assert_almost_equal(np.ppmt(0.1 / 12, 1, 60, 55000, 0, 1), np.ppmt(0.1 / 12, 1, 60, 55000, 0, "begin"), 4)
# end
assert_almost_equal(np.ppmt(0.1 / 12, 1, 60, 55000, 0), np.ppmt(0.1 / 12, 1, 60, 55000, 0, "end"), 4)
assert_almost_equal(np.ppmt(0.1 / 12, 1, 60, 55000, 0, 0), np.ppmt(0.1 / 12, 1, 60, 55000, 0, "end"), 4)
# begin
assert_almost_equal(np.ipmt(0.1 / 12, 1, 24, 2000, 0, 1), np.ipmt(0.1 / 12, 1, 24, 2000, 0, "begin"), 4)
# end
assert_almost_equal(np.ipmt(0.1 / 12, 1, 24, 2000, 0), np.ipmt(0.1 / 12, 1, 24, 2000, 0, "end"), 4)
assert_almost_equal(np.ipmt(0.1 / 12, 1, 24, 2000, 0, 0), np.ipmt(0.1 / 12, 1, 24, 2000, 0, "end"), 4)
# begin
assert_almost_equal(np.nper(0.075, -2000, 0, 100000.0, 1), np.nper(0.075, -2000, 0, 100000.0, "begin"), 4)
# end
assert_almost_equal(np.nper(0.075, -2000, 0, 100000.0), np.nper(0.075, -2000, 0, 100000.0, "end"), 4)
assert_almost_equal(np.nper(0.075, -2000, 0, 100000.0, 0), np.nper(0.075, -2000, 0, 100000.0, "end"), 4)
示例12:
#fv函数参数为利率,参数,每期支付金额,现值
print "Future value",np.fv(0.03/4, 5*4,-10,1000)
print u"现值"
#pv函数参数为利率,参数,每期支付金额,终值
print "Present value",np.pv(0.03/4,5*4,-10,1376.09633204)
#npv参数为利率和一个表示现金流的数组.
cashflows = np.random.randint(100,size=5)
cashflows = np.insert(cashflows,0,-100)
print "Cashflows",cashflows
print "Net present value",np.npv(0.03,cashflows)
print u"内部收益率"
print "Internal rate of return",np.irr([-100, 38, 48,90 ,17,36])
print u"分期付款"
#pmt输入为利率和期数,总价,输出每期钱数
print "Payment",np.pmt(0.10/12,12*30,100000)
#nper参数为贷款利率,固定的月供和贷款额,输出付款期数
print "Number of payments", np.nper(0.10/12,-100,9000)
#rate参数为付款期数,每期付款资金,现值和终值计算利率
print "Interest rate",12*np.rate(167,-100,9000,0)
print u"窗函数"
#bartlett函数可以计算巴特利特窗
window = np.bartlett(42)
print "bartlett",window
#blackman函数返回布莱克曼窗。该函数唯一的参数为输出点的数量。如果数量
#为0或小于0,则返回一个空数组。
window = np.blackman(10)
print "blackman",window
# hamming函数返回汉明窗。该函数唯一的参数为输出点的数量。如果数量为0或
# 小于0,则返回一个空数组。
示例13: range
import pandas as pd
import numpy as np
import Tkinter
original_balance = 250000
term_month = 360
yr_int_rate = 0.05
remain_term_in_month = term_month
current_balance = original_balance
payment = -np.pmt(yr_int_rate / 12, term_month, original_balance)
month_prepay = 0.01
lgd = 0.4
month_drawdown_rate = 0.01
# part 1: prep for 0 to 75 months
cum_pd = pd.read_excel(r'C:\Users\shm\Downloads\Effective Maturity Tables & Lifetime EL Calculation.xlsx', sheetname = 'cum_pd')
cum_pd.columns = [x.lower() for x in cum_pd.columns]
cum_pd['month_i'] = range(3, (cum_pd.shape[0] + 1)* 3, 3)
row0 = pd.DataFrame([0, 0]).T
row0.columns = cum_pd.columns
cum_pd = pd.concat([row0, cum_pd], axis = 0)
cum_pd['month_incr'] = cum_pd.cumulative_pd.diff().fillna(0) / 3
# from 78 to 360
cum_after = pd.DataFrame(columns = cum_pd.columns)
cum_after['month_i'] = np.arange(cum_pd['month_i'].max() + 3, term_month + 3, 3)
cum_after['month_incr'] = cum_pd.month_incr.values[-1]
示例14:
import numpy as np
np.pmt(0.075 / 12, 12 * 15, 200000)
示例15: taxEquityFlip
def taxEquityFlip(PPARateSixYearsTE, discRate, totalCost, allYearGenerationMWh, distAdderDirect, loanYears, firstYearLandLeaseCosts, firstYearOPMainCosts, firstYearInsuranceCosts, numberPanels):
# Output Tax Equity Flip [C]
coopInvestmentTaxEquity = -totalCost * (1 - 0.53)
# Output Tax Equity Flip [D]
financeCostCashTaxEquity = 0
# Output Tax Equity Flip [E]
cashToSPEOForPPATE = []
# Output Tax Equity Flip [F]
derivedCostEnergyTE = 0
# Output Tax Equity Flip [G]
OMInsuranceETCTE = []
# Output Tax Equity Flip [H]
cashFromSPEToBlockerTE = []
# Output Tax Equity Flip [I]
cashFromBlockerTE = 0
# Output Tax Equity Flip [J]
distAdderTaxEquity = distAdderDirect
# Output Tax Equity Flip [K]
netCoopPaymentsTaxEquity = []
# Output Tax Equity Flip [L]
costToCustomerTaxEquity = []
# Output Tax Equity Flip [L64]
NPVLoanTaxEquity = 0
# Output Tax Equity Flip [F72]
Rate_Levelized_Equity = 0
# Tax Equity Flip Formulas
# Output Tax Equity Flip [D]
# TEI Calcs [E]
financeCostOfCashTE = 0
coopFinanceRateTE = 2.7 / 100
if (coopFinanceRateTE == 0):
financeCostOfCashTE = 0
else:
payment = pmt(
coopFinanceRateTE, loanYears, -coopInvestmentTaxEquity)
financeCostCashTaxEquity = payment
# Output Tax Equity Flip [E]
SPERevenueTE = []
for i in range(1, len(allYearGenerationMWh) + 1):
SPERevenueTE.append(
PPARateSixYearsTE * allYearGenerationMWh[i])
if ((i >= 1) and (i <= 6)):
cashToSPEOForPPATE.append(-SPERevenueTE[i - 1])
else:
cashToSPEOForPPATE.append(0)
# Output Tax Equity Flip [F]
derivedCostEnergyTE = cashToSPEOForPPATE[
0] / allYearGenerationMWh[1]
# Output Tax Equity Flip [G]
# TEI Calcs [F] [U] [V]
landLeaseTE = []
OMTE = []
insuranceTE = []
for i in range(1, len(allYearGenerationMWh) + 1):
landLeaseTE.append(
firstYearLandLeaseCosts * math.pow((1 + .01), (i - 1)))
OMTE.append(-firstYearOPMainCosts *
math.pow((1 + .01), (i - 1)))
insuranceTE.append(- firstYearInsuranceCosts *
math.pow((1 + .025), (i - 1)))
if (i < 7):
OMInsuranceETCTE.append(float(landLeaseTE[i - 1]))
else:
OMInsuranceETCTE.append(
float(OMTE[i - 1]) + float(insuranceTE[i - 1]) + float(landLeaseTE[i - 1]))
# Output Tax Equity Flip [H]
# TEI Calcs [T]
SPEMgmtFeeTE = []
EBITDATE = []
EBITDATEREDUCED = []
managementFee = 10000
for i in range(1, len(SPERevenueTE) + 1):
SPEMgmtFeeTE.append(-managementFee *
math.pow((1 + .01), (i - 1)))
EBITDATE.append(float(SPERevenueTE[
i - 1]) + float(OMTE[i - 1]) + float(insuranceTE[i - 1]) + float(SPEMgmtFeeTE[i - 1]))
if (i <= 6):
cashFromSPEToBlockerTE.append(float(EBITDATE[i - 1]) * .01)
else:
cashFromSPEToBlockerTE.append(0)
EBITDATEREDUCED.append(EBITDATE[i - 1])
# Output Tax Equity Flip [I]
# TEI Calcs [Y21]
cashRevenueTE = -totalCost * (1 - 0.53)
buyoutAmountTE = 0
for i in range(1, len(EBITDATEREDUCED) + 1):
buyoutAmountTE = buyoutAmountTE + \
EBITDATEREDUCED[i - 1] / (math.pow(1 + 0.12, i))
buyoutAmountTE = buyoutAmountTE * 0.05
cashFromBlockerTE = - (buyoutAmountTE) + 0.0725 * cashRevenueTE
# Output Tax Equity Flip [K] [L]
for i in range(1, len(allYearGenerationMWh) + 1):
if (i == 6):
#.........这里部分代码省略.........