V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
airbotgo
V2EX  ›  问与答

这个计算公式可以推导出来吗?

  •  
  •   airbotgo · 69 天前 · 1008 次点击
    这是一个创建于 69 天前的主题,其中的信息可能已经有所发展或是发生改变。
    这是农行的利率计算公式,有没有数学好的,这个计算公式是怎样的?

    农行分期实际年化利率(单利)计算器:
    https://www.abchina.com/cn/CreditCard/WealthManagement/fqnhl/
    4 条回复    2022-06-02 13:16:33 +08:00
    Stendan
        1
    Stendan  
       69 天前
    js 里面的,不知道帮到你没-,-!

    function getAPR(instalment_amt, instalment_day, instalment_rate, instalment_type) {

    // 现金流
    var cashFlows = new Array();
    // 实际年化利率
    var APR = 0;

    // 每期还款本金
    var principal_base = Math.round(instalment_amt / instalment_day);
    // 最后一期还款本金
    var principal_end = instalment_amt - (principal_base * (instalment_day - 1));

    // 手续费收取方式总手续费就是本金*费率*期数保留两位小数,然后前面 N-1 期都是本金*每期费率保留 2 位小数,然后第 N 期用总手续费减去前面 N-1 期手续费
    var fee_total = Math.round(instalment_day * instalment_amt * instalment_rate) / 100;
    var fee_base = Math.round(instalment_amt * instalment_rate) / 100;
    var fee_end = fee_total - (fee_base * (instalment_day - 1));

    cashFlows.push(-instalment_amt);

    if(instalment_type == '1') {

    for(var i = instalment_day - 1; i >= 0; i--) {

    if(i > 0) {
    cashFlows.push(principal_base + fee_base);
    } else {
    cashFlows.push(principal_end + fee_end);
    }

    }

    } else if(instalment_type == '2') {

    for(var i = instalment_day - 1; i >= 0; i--) {

    if(i == instalment_day - 1) {
    var fee = fee_total;
    } else {
    var fee = 0;
    }

    if(i > 0) {
    cashFlows.push(principal_base + fee);
    } else {
    cashFlows.push(principal_end + fee);
    }

    }

    } else {

    alert('请正确选择 [分期手续费收取方式] !');
    return '';

    }

    // cashFlows=[-2000,679,679,666,0,0,0,0];
    APR = (12 * IRR(cashFlows) * 100).toFixed(2);

    return APR;

    }

    function IRR(cashFlows, estimatedResult) {
    var result = "isNAN";
    if(cashFlows != null && cashFlows.length > 0) {
    // check if business startup costs is not zero:
    if(cashFlows[0] != 0) {
    var noOfCashFlows = cashFlows.length;
    var sumCashFlows = 0;
    // check if at least 1 positive and 1 negative cash flow exists:
    var noOfNegativeCashFlows = 0;
    var noOfPositiveCashFlows = 0;
    for(var i = 0; i < noOfCashFlows; i++) {
    sumCashFlows += cashFlows[i];
    if(cashFlows[i] > 0) {
    noOfPositiveCashFlows++;
    } else {
    if(cashFlows[i] < 0) {
    noOfNegativeCashFlows++;
    }
    }
    }

    // at least 1 negative and 1 positive cash flow available?
    if(noOfNegativeCashFlows > 0 && noOfPositiveCashFlows > 0) {
    // set estimated result:
    var irrGuess = 0.1; // default: 10%
    if(!isNaN(estimatedResult)) {
    irrGuess = estimatedResult;
    if(irrGuess <= 0) {
    irrGuess = 0.5;
    }
    }

    // initialize first IRR with estimated result:
    var irr = 0;
    if(sumCashFlows < 0) { // sum of cash flows negative?
    irr = -irrGuess;
    } else { // sum of cash flows not negative
    irr = irrGuess;
    }

    // iteration:
    // the smaller the distance, the smaller the interpolation
    // error
    var minDistance = 1e-15;

    // business startup costs
    var cashFlowStart = cashFlows[0];
    var maxIteration = 100;
    var wasHi = false;
    var cashValue = 0;
    for(var i = 0; i <= maxIteration; i++) {
    // calculate cash value with current irr:
    cashValue = cashFlowStart; // init with startup costs

    // for each cash flow
    for(var j = 1; j < noOfCashFlows; j++) {
    cashValue += cashFlows[j] / Math.pow(1 + irr, j);
    }

    // cash value is nearly zero
    if(Math.abs(cashValue) < 0.01) {
    result = irr;
    break;
    }

    // adjust irr for next iteration:
    // cash value > 0 => next irr > current irr
    if(cashValue > 0) {
    if(wasHi) {
    irrGuess /= 2;
    }
    irr += irrGuess;
    if(wasHi) {
    irrGuess -= minDistance;
    wasHi = false;
    }
    } else { // cash value < 0 => next irr < current irr
    irrGuess /= 2;
    irr -= irrGuess;
    wasHi = true;
    }

    // estimated result too small to continue => end
    // calculation
    if(irrGuess <= minDistance) {
    result = irr;
    break;
    }
    }
    }
    }
    }
    return result;
    }
    shakoon
        2
    shakoon  
       69 天前
    实际年化利率=月利率*24n/(1+n),n 为分期期数
    IMRES
        3
    IMRES  
       69 天前
    关键词:XIRR
    wgsgyes
        4
    wgsgyes  
       69 天前
    假设名义利率是 i , 根据借贷合同约定:每月计息一次、每月利率为 i/12, 实际利率=(1+i/12)^12-1
    关于   ·   帮助文档   ·   API   ·   FAQ   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   1646 人在线   最高记录 5497   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 17:11 · PVG 01:11 · LAX 10:11 · JFK 13:11
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.