当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Simulation.presentValue方法代码示例

本文整理汇总了TypeScript中src/service/simulation.Simulation.presentValue方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Simulation.presentValue方法的具体用法?TypeScript Simulation.presentValue怎么用?TypeScript Simulation.presentValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在src/service/simulation.Simulation的用法示例。


在下文中一共展示了Simulation.presentValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

 it('should be the present value of the future value of each of the asset type return rates', () => {
   let mixedAccount = new Account(1, 'Mixed account', '401k', 10000, 1200, 25, 25, 50);
   let stockPercentage = mixedAccount.stockPercentage / 100;
   let bondPecentage = mixedAccount.bondPercentage / 100;
   let cashPercentage = mixedAccount.cashPercentage / 100;
   let stockBalance = mixedAccount.balance * stockPercentage;
   let bondBalance = mixedAccount.balance * bondPecentage;
   let cashBalance = mixedAccount.balance * cashPercentage;
   let stockRetirementBalance = Simulation.presentValue(Simulation.futureValueWithContribution(stockBalance, 10, Simulation.STOCK_RETURN, mixedAccount.contribution * stockPercentage), 10, Simulation.INTEREST);
   let bondRetirementBalance = Simulation.presentValue(Simulation.futureValueWithContribution(bondBalance, 10, Simulation.BOND_RETURN, mixedAccount.contribution * bondPecentage), 10, Simulation.INTEREST);
   let cashRetirementBalance = Simulation.presentValue(Simulation.futureValueWithContribution(cashBalance, 10, Simulation.CASH_RETURN, mixedAccount.contribution * cashPercentage), 10, Simulation.INTEREST);
   let retirementBalance = Simulation.retirementBalance(mixedAccount, 10);
   let expectedRetirementBalance = stockRetirementBalance + bondRetirementBalance + cashRetirementBalance;
   expect(retirementBalance).toBeCloseTo(expectedRetirementBalance, 2);
 });
开发者ID:jasoncarreira,项目名称:choices,代码行数:15,代码来源:simulation.spec.ts

示例2: describe

describe('The present value of a future amount ', () => {
  let pv = Simulation.presentValue(20000, 10, .025);
  it('is not null', () => {
    expect(pv).not.toBeNull();
  });
  it('should be less than the future value', () => {
    expect(pv).toBeLessThan(20000);
  });
  it('should be the expected present value', () => {
    expect(pv).toBeCloseTo(15623.97, 2);
  });
});
开发者ID:jasoncarreira,项目名称:choices,代码行数:12,代码来源:simulation.spec.ts


注:本文中的src/service/simulation.Simulation.presentValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。