mage67 (mage67) wrote,
mage67
mage67

  • Mood:

Guideline Premiums

OK, here's the main part of the C++ Code I've been writing for over a week. It's not bug-free yet, but it did compile well. Unless you really really like looking at longwinded confusing boring code, for G-d's sake, don't




//Calculate_Guideline_Prem rewritten by Jeffrey Frankel on 6-5-02
void CRate_Server::Calculate_Guideline_Prem(Read_Info Person, CMarketing_Strategy* Concept)
{
double dInterestFactor4 = pow(1.04,(1.0/12.0));
double dInterestFactor4Opt2 = dInterestFactor4 - 1.0;
double dInterestFactor6 = pow(1.06,(1.0/12.0));
int iAge = Person.iIssue_Age;
int intTermAdjustYrs = 0.0;
double dMinimumTermFace;

if(NEWYORK == Person.iIssue_State)
intTermAdjustYrs = 15;//m_iMaturityAge - 15 = 80 Age Term drops
else
intTermAdjustYrs = 0; //m_iMaturityAge - 0 = 95 Age Term drops

double dGuaranteedQ = 0.0;
double dQAccum = 1.0;
double dDenomWork = 1.0;

double dPVFee4 = 0.0;
double dPVFee4_DBO2 = 0.0;
double dPVCharge4 = 0.0;
double dPVCharge4_DBO2 = 0.0;
double dPVGMDB4 = 0.0;
double dPVFTD4 = 0.0;
double dIAccum4 = 1.0;
double dMort4 = 0.0;
double dMort4_DBO2 = 0.0;
double dMort4Opt3 = 0.0;
double dGLPExp = 0.0;
double dPVTargetLoad4 = 0.0;
double dPVTotalLoad4 = 0.0;
double dPVTotalLoad4_DBO2 = 0.0;

double dIQAccum4 = 1.0;
double dPVFee6 = 0.0;
double dPVCharge6 = 0.0;
double dPVGMDB6 = 0.0;
double dPVFTD6 = 0.0;
double dIAccum6 = 1.0;
double dMort6 = 0.0;

double dPVTotalLoad6 = 1.0;

double dTerm = 1.0;
double dTermMort4 = 0.0;
double dTermMort4_DBO2 = 0.0;
double dTermMort6 = 0.0;
double dPVTermCharge4 = 0.0;
double dPVTermCharge6 = 0.0;
double dPVBelowTarget4 = 0.0;

double dEndow4 = 0.0;
double dEndow4_DBO2 = 0.0;
double dEndow6 = 0.0;


double dDAC_Tax_Percentage = 1.25;
double dState_Tax_Percentage = 2.00;

int iPremium_Load_Below_Target1 = 0.0;
int iPremium_Load_Above_Target1 = 0.0;
int iPremium_Load_Below_Target = 0.0;
int iPremium_Load_Above_Target = 0.0;

double dCurrent_Load_Above_Target1 = 0.0;
double dCurrent_Load_Below_Target1 = 0.0;
double dCurrent_Load_Above_Target = 0.0;
double dCurrent_Load_Below_Target = 0.0;
double dPVTargetPremiumLoad4 = 0.0;
double dPVTargetPremiumLoad4_DBO2 = 0.0;
double dPVTargetPremiumLoad6 = 0.0;
double dTest_Denom4 = 0.0;
double dTest_Denom4_DBO2 = 0.0;

double dCurrPer1000Charge = 0.0;

double dTemp = 0.0;

double dAK_Threshold = 136825.0;
double dAK_Percentage = 0.0;
double dAK_Part = 0.0;
double dAK_Part_DBO2 = 0.0;
double dAK_Denom = 0.0;
double dAK_Denom_DBO2 = 0.0;

double dBaseFaceThousands = Person.dFace / 1000.0;

dMinimumTermFace = Concept->getTerm_Sched()->GetMinimumValue();

int dST = Person.iIssue_State;

double dPremium_Target_Load_Difference = 0.0;



for (int iYear =1; iYear <= Person.iNo_Yrs_Illus; iYear++)
{
dGuaranteedQ = dGuar_Mort[iYear];// + m_pdFlatExtra[iYear];

dTemp = Get_dCurrLoadAboveTarget(iYear);
iPremium_Load_Above_Target = (int)(dTemp * 100.0);
dTemp = Get_dCurrLoadToTarget(iYear);
iPremium_Load_Below_Target = (int)(dTemp * 100.0);

dCurrent_Load_Above_Target = (dDAC_Tax_Percentage + dState_Tax_Percentage + (iPremium_Load_Above_Target1/100.0)) * .01;
dCurrent_Load_Below_Target = (dDAC_Tax_Percentage + dState_Tax_Percentage + (iPremium_Load_Below_Target1/100.0)) * .01;

dPremium_Target_Load_Difference = (iPremium_Load_Below_Target - iPremium_Load_Above_Target);


if (((dTarget[1] * dBaseFaceThousands)> dAK_Threshold) && (ALASKA == dST))
{
dPVTargetPremiumLoad4 += ((190.0 / 10000.0) * (dAK_Threshold/1000.0) * (1.0 + dGuaranteedQ)) / (dIAccum4 * dQAccum);
dPVTargetPremiumLoad4_DBO2 += ((190.0 / 10000.0) * (dAK_Threshold/1000.0) * (1.0 + dGuaranteedQ)) / (dIQAccum4);
}
else
{
dPVTargetPremiumLoad4 += ((dPremium_Target_Load_Difference / 10000.0) * dTarget[1] * (1.0 + dGuaranteedQ))/ (dIAccum4 * dQAccum);
dPVTargetPremiumLoad4_DBO2 += ((dPremium_Target_Load_Difference / 10000.0) * dTarget[1] * (1.0 + dGuaranteedQ))/ (dIQAccum4);
}

dTemp = iPremium_Load_Below_Target + 325;
dTest_Denom4 += (1.0 / (dIAccum4 * dQAccum)) * (1 - (dTemp/10000));
dTest_Denom4_DBO2 += (1.0 / dIQAccum4) * (1 - (dTemp/10000));


dTemp = iPremium_Load_Above_Target + 325;
dPVTotalLoad4 += (1.0 / (dIAccum4 * dQAccum)) * (1 - (dTemp/10000));
dPVTotalLoad4_DBO2 += (1.0 / dIQAccum4) * (1 - (dTemp/10000));

dAK_Percentage = __min(dCurrent_Load_Above_Target, .019);
dAK_Part += ((dAK_Percentage * __max((dTarget[1]*dBaseFaceThousands),dAK_Threshold)) * (1.0 + dGuaranteedQ)) / (dIAccum4 * dQAccum);
dAK_Part_DBO2 += ((dAK_Percentage * __max((dTarget[1]*dBaseFaceThousands),dAK_Threshold)) * (1.0 + dGuaranteedQ)) / (dIQAccum4);

dAK_Denom += ((__min((1 - (dCurrent_Load_Above_Target - .019)),1.0))* (1.0 + dGuaranteedQ)) / (dIAccum4 * dQAccum);
dAK_Denom_DBO2 += ((__min((1 - (dCurrent_Load_Above_Target - .019)),1.0))* (1.0 + dGuaranteedQ)) / (dIAccum4 * dQAccum);



for (int iMonth = 1; iMonth <= 12; iMonth++)
{
dQAccum *= (1.0 + dGuaranteedQ);


dPVFee4 += (ADMIN_FEE / (dIAccum4 * dQAccum)) * (1.0 + dGuaranteedQ);
dPVFee4_DBO2 += (ADMIN_FEE / dIQAccum4);

if (iYear < 11)
{
dCurrPer1000Charge = Get_dCurrPer1000Charge(1);
dPVCharge4 += (dCurrPer1000Charge/ (dIAccum4 * dQAccum)) * (1.0 + dGuaranteedQ);
dPVCharge4_DBO2 += (dCurrPer1000Charge / dIQAccum4);
}

dTermMort4 += (dMinimumTermFace*(dGuaranteedQ / (dIAccum4 * dQAccum))) * (1.0 + dGuaranteedQ);
dTermMort4_DBO2 += (dMinimumTermFace*(dGuaranteedQ / dIQAccum4));

dIAccum4 *= dInterestFactor4;
dIQAccum4 *= (1.0 + (dInterestFactor4Opt2 * (1.0 + dGuaranteedQ)));

dMort4 += (dGuaranteedQ / (dIAccum4 * dQAccum));
dMort4_DBO2 += (dGuaranteedQ / dIQAccum4);

dMort4Opt3 += ((dGuaranteedQ * (double)iYear) / (dIAccum4 * dQAccum));



dPVFee6 += (ADMIN_FEE / (dIAccum6 * dQAccum)) * (1.0 + dGuaranteedQ);
if (iYear < 11)
{
dCurrPer1000Charge = Get_dCurrPer1000Charge(1);
dPVCharge6 += (dCurrPer1000Charge / (dIAccum6 * dQAccum)) * (1.0 + dGuaranteedQ);
}
dTermMort6 += (dMinimumTermFace*(dGuaranteedQ / (dIAccum6 * dQAccum))) * (1.0 + dGuaranteedQ);
dIAccum6 *= dInterestFactor6;
dMort6 += (dGuaranteedQ / (dIAccum6 * dQAccum));



}//End of the Monthly Loop



}//End of the Yearly Loop




dEndow6 = (1.0 / (dIAccum6 * dQAccum));
dEndow4 = (1.0 / (dIAccum4 * dQAccum));
dEndow4_DBO2 = (1.0 / dIQAccum4);


double dTarget_Test1 = 0.0;
double dTarget_Test2 = 0.0;

double dTest_Denom6 = (iPremium_Load_Below_Target1 + 325.0) / 10000.0;

double dAK_Percentage1 = __min(dCurrent_Load_Above_Target1, .019);
double dAK_Part1 = dAK_Percentage * __max((dTarget[1]*dBaseFaceThousands),dAK_Threshold);
double dAK_Denom1 = __min((1 - (dCurrent_Load_Above_Target1 - .019)),1.0);

double dTP = dTarget[1] * dBaseFaceThousands;




// Guideline Level Premium Rates per $1000
// NOTE: GMDB rate used in this calc is already per $1000 and is not multipled by 1000 below


// case LEVEL_DEATH_BENEFIT: //Death Benefit Option 1

dTarget_Test1 = (dPVCharge4 + (dEndow4 * 1000.0) + (dMort4 * 1000.0));
dTarget_Test1 *= dBaseFaceThousands;
dTarget_Test1 += dPVFee4 + dTermMort4;
dTarget_Test1 /= dTest_Denom4;

dTarget_Test2 = (dPVCharge4 + (dPVTargetPremiumLoad4 / 1000.0) + (dEndow4 * 1000.0) + (dMort4 * 1000.0));
dTarget_Test2 *= dBaseFaceThousands;
dTarget_Test2 += dPVFee4 + dTermMort4;
dTarget_Test2 /= dPVTotalLoad4;

if (((dTarget_Test1 <= dTP) && (ALASKA != dST)) || ((dTarget_Test1 <= dTP) && (ALASKA == dST) && (dTarget_Test1 <= dAK_Threshold)))
{
dBase_GLP_Option1[1] = (dPVCharge4 + (dEndow4 * 1000.0) + (dMort4 * 1000.0)) / dTest_Denom4;
dBase_GLP_Flat_Option1[1] = dPVFee4 / dTest_Denom4;
if (dMinimumTermFace == 0.0)
dTerm_GLP_Option1[1] = 0.0;
else
dTerm_GLP_Option1[1] = (dTermMort4 * 1000.0) / (dTest_Denom4 * dMinimumTermFace);
}

if (((dTarget_Test1 <= dTP) && (ALASKA == dST) && (dTarget_Test1 > dAK_Threshold)) || ((dTarget_Test1 > dTP) && (ALASKA == dST) && (dTarget_Test2 <= dAK_Threshold)) || ((dTarget_Test1 > dTP) && (ALASKA != dST)))
{
dBase_GLP_Option1[1] = (dPVCharge4 + dPVTargetPremiumLoad4 + (dEndow4 * 1000.0) + (dMort4 * 1000.0)) / dPVTotalLoad4;
dBase_GLP_Flat_Option1[1] = dPVFee4 / dPVTotalLoad4;
if (dMinimumTermFace == 0.0)
dTerm_GLP_Option1[1] = 0.0;
else
dTerm_GLP_Option1[1] = (dTermMort4 *1000.0) / (dPVTotalLoad4 * dMinimumTermFace);
}

if ((dTarget_Test1 > dTP) && (ALASKA == dST) && (dTarget_Test2 > dAK_Threshold))
{
dBase_GLP_Option1[1] = (dPVCharge4 + dPVTargetPremiumLoad4 + (dEndow4 * 1000.0) + (dMort4 * 1000.0)) / dAK_Denom;
dBase_GLP_Flat_Option1[1] = (dPVFee4 + dAK_Part) / dAK_Denom;
if (dMinimumTermFace == 0.0)
dTerm_GLP_Option1[1] = 0.0;
else
dTerm_GLP_Option1[1] = (dTermMort4 *1000.0) / (dAK_Denom * dMinimumTermFace);
}

dBase_GLP_Option1[1] *= .998;
dBase_GLP_Flat_Option1[1] *= .998;
dTerm_GLP_Option1[1] *= .998;


// case INCREASE_DEATH_BENEFIT: //Death Benefit Option 2

dTarget_Test1 = (dPVCharge4_DBO2 + (dEndow4_DBO2 * 1000.0) + (dMort4_DBO2 * 1000.0));
dTarget_Test1 *= dBaseFaceThousands;
dTarget_Test1 += dPVFee4_DBO2 + dTermMort4_DBO2;
dTarget_Test1 /= dTest_Denom4_DBO2;

dTarget_Test2 = (dPVCharge4_DBO2 + (dPVTargetPremiumLoad4_DBO2 / 1000.0) + (dEndow4_DBO2 * 1000.0) + (dMort4_DBO2 * 1000.0));
dTarget_Test2 *= dBaseFaceThousands;
dTarget_Test2 += dPVFee4_DBO2 + dTermMort4_DBO2;
dTarget_Test2 /= dPVTotalLoad4_DBO2;

if (((dTarget_Test1 <= dTP) && (ALASKA != dST)) || ((dTarget_Test1 <= dTP) && (ALASKA == dST) && (dTarget_Test1 <= dAK_Threshold)))
{
dBase_GLP_Option2[1] = (dPVCharge4_DBO2 + (dEndow4_DBO2 * 1000.0) + (dMort4_DBO2 * 1000.0)) / dTest_Denom4_DBO2;
dBase_GLP_Flat_Option2[1] = dPVFee4_DBO2 / dTest_Denom4_DBO2;
if (dMinimumTermFace == 0.0)
dTerm_GLP_Option2[1] = 0.0;
else
dTerm_GLP_Option2[1] = (dTermMort4_DBO2 * 1000.0) / (dTest_Denom4_DBO2 * dMinimumTermFace);
}

if (((dTarget_Test1 <= dTP) && (ALASKA == dST) && (dTarget_Test1 > dAK_Threshold)) || ((dTarget_Test1 > dTP) && (ALASKA == dST) && (dTarget_Test2 <= dAK_Threshold)) || ((dTarget_Test1 > dTP) && (ALASKA != dST)))
{
dBase_GLP_Option2[1] = (dPVCharge4_DBO2 + dPVTargetPremiumLoad4_DBO2 + (dEndow4_DBO2 * 1000.0) + (dMort4_DBO2 * 1000.0)) / dPVTotalLoad4_DBO2;
dBase_GLP_Flat_Option2[1] = dPVFee4_DBO2 / dPVTotalLoad4_DBO2;
if (dMinimumTermFace == 0.0)
dTerm_GLP_Option2[1] = 0.0;
else
dTerm_GLP_Option2[1] = (dTermMort4_DBO2 * 1000.0) / (dPVTotalLoad4_DBO2 * dMinimumTermFace);
}

if ((dTarget_Test1 > dTP) && (ALASKA == dST) && (dTarget_Test2 > dAK_Threshold))
{
dBase_GLP_Option2[1] = (dPVCharge4_DBO2 + dPVTargetPremiumLoad4_DBO2 + (dEndow4_DBO2 * 1000.0) + (dMort4_DBO2 * 1000.0)) / dAK_Denom_DBO2;
dBase_GLP_Flat_Option2[1] = (dPVFee4_DBO2 + dAK_Part_DBO2) / dAK_Denom_DBO2;
if (dMinimumTermFace == 0.0)
dTerm_GLP_Option2[1] = 0.0;
else
dTerm_GLP_Option2[1] = (dTermMort4_DBO2 * 1000.0) / (dAK_Denom_DBO2 * dMinimumTermFace);
}

dBase_GLP_Option2[1] *= .998;
dBase_GLP_Flat_Option2[1] *= .998;
dTerm_GLP_Option2[1] *= .998;



// case RETURN_OF_PREMIUM: // Death Benefit Option 3

dTarget_Test1 = (dPVCharge4 + (dEndow4 * 1000.0) + (dMort4 * 1000.0));
dTarget_Test1 *= dBaseFaceThousands;
dTarget_Test1 += dPVFee4 + dTermMort4;
dTarget_Test1 /= (dTest_Denom4 - dMort4Opt3);

dTarget_Test2 = (dPVCharge4 + (dPVTargetPremiumLoad4 / 1000.0) + (dEndow4 * 1000.0) + (dMort4 * 1000.0));
dTarget_Test2 *= dBaseFaceThousands;
dTarget_Test2 += dPVFee4 + dTermMort4;
dTarget_Test2 /= (dPVTotalLoad4 - dMort4Opt3);

if (((dTarget_Test1 <= dTP) && (ALASKA != dST)) || ((dTarget_Test1 <= dTP) && (ALASKA == dST) && (dTarget_Test1 <= dAK_Threshold)))
{
dBase_GLP_Option3[1] = (dPVCharge4 + (dEndow4 * 1000.0) + (dMort4 * 1000.0)) / (dTest_Denom4 - dMort4Opt3);
dBase_GLP_Flat_Option3[1] = dPVFee4 / (dTest_Denom4 - dMort4Opt3);
if (dMinimumTermFace == 0.0)
dTerm_GLP_Option3[1] = 0.0;
else
dTerm_GLP_Option3[1] = (dTermMort4 * 1000.0) / ((dTest_Denom4 - dMort4Opt3) * dMinimumTermFace);
}

if (((dTarget_Test1 <= dTP) && (ALASKA == dST) && (dTarget_Test1 > dAK_Threshold)) || ((dTarget_Test1 > dTP) && (ALASKA == dST) && (dTarget_Test2 <= dAK_Threshold)) || ((dTarget_Test1 > dTP) && (ALASKA != dST)))
{
dBase_GLP_Option3[1] = (dPVCharge4 + dPVTargetPremiumLoad4 + (dEndow4 * 1000.0) + (dMort4 * 1000.0)) / (dPVTotalLoad4 - dMort4Opt3);
dBase_GLP_Flat_Option3[1] = dPVFee4 / (dPVTotalLoad4 - dMort4Opt3);
if (dMinimumTermFace == 0.0)
dTerm_GLP_Option3[1] = 0.0;
else
dTerm_GLP_Option3[1] = (dTermMort4 * 1000.0) / ((dPVTotalLoad4 - dMort4Opt3) * dMinimumTermFace);
}

if ((dTarget_Test1 > dTP) && (ALASKA == dST) && (dTarget_Test2 > dAK_Threshold))
{
dBase_GLP_Option3[1] = (dPVCharge4 + dPVTargetPremiumLoad4 + (dEndow4 * 1000.0) + (dMort4 * 1000.0)) / (dAK_Denom - - dMort4Opt3);
dBase_GLP_Flat_Option3[1] = (dPVFee4 + dAK_Part) / (dAK_Denom - dMort4Opt3);
if (dMinimumTermFace == 0.0)
dTerm_GLP_Option3[1] = 0.0;
else
dTerm_GLP_Option3[1] = (dTermMort4 * 1000.0) / ((dAK_Denom - dMort4Opt3) * dMinimumTermFace);
}

dBase_GLP_Option3[1] *= .998;
dBase_GLP_Flat_Option3[1] *= .998;
dTerm_GLP_Option3[1] *= .998;


/// dBase_GLP_Option3[1] = (dPVCharge4 + dPVTargetLoad4 + (dMort4 * 1000.0)) / (dPVTotalLoad4 - dMort4Opt3);
/// dBase_GLP_Flat_Option3[1] = dPVFee4 / (dPVTotalLoad4 - dMort4Opt3);
/// dTerm_GLP_Option3[1] = (dPVTermCharge4 + (dTermMort4 * 1000.0)) / (dPVTotalLoad4 - dMort4Opt3);


// Guideline Single Rates per $1000
// (same for Death Benefit Options 1, 2, 3)

dTemp = Get_dCurrLoadAboveTarget(1);
iPremium_Load_Above_Target1 = (int)(dTemp * 100.0);
dTemp = Get_dCurrLoadToTarget(1);
iPremium_Load_Below_Target1 = (int)(dTemp * 100.0);

dCurrent_Load_Above_Target1 = (dDAC_Tax_Percentage + dState_Tax_Percentage + (iPremium_Load_Above_Target1/100.0)) * .01;
dCurrent_Load_Below_Target1 = (dDAC_Tax_Percentage + dState_Tax_Percentage + (iPremium_Load_Below_Target1/100.0)) * .01;

dPVTotalLoad6 = (1 - dCurrent_Load_Above_Target1);
dTemp = (iPremium_Load_Below_Target1 - iPremium_Load_Above_Target1);

if (((dTarget[1] * dBaseFaceThousands)> dAK_Threshold) && (ALASKA == dST))
dPVTargetPremiumLoad6 = (190.0 / 10000.0) * (dAK_Threshold / 1000.0);
else
dPVTargetPremiumLoad6 = (dTemp / 10000.0) * (dTarget[1]);


// p
[Error: Irreparable invalid markup ('<target [...] *>') in entry. Owner must fix manually. Raw contents below.]

OK, here's the main part of the C++ Code I've been writing for over a week. It's not bug-free yet, but it did compile well. Unless you really really like looking at longwinded confusing boring code, for G-d's sake, don't

<lj-cut text="click here...">


//Calculate_Guideline_Prem rewritten by Jeffrey Frankel on 6-5-02
void CRate_Server::Calculate_Guideline_Prem(Read_Info Person, CMarketing_Strategy* Concept)
{
double dInterestFactor4 = pow(1.04,(1.0/12.0));
double dInterestFactor4Opt2 = dInterestFactor4 - 1.0;
double dInterestFactor6 = pow(1.06,(1.0/12.0));
int iAge = Person.iIssue_Age;
int intTermAdjustYrs = 0.0;
double dMinimumTermFace;

if(NEWYORK == Person.iIssue_State)
intTermAdjustYrs = 15;//m_iMaturityAge - 15 = 80 Age Term drops
else
intTermAdjustYrs = 0; //m_iMaturityAge - 0 = 95 Age Term drops

double dGuaranteedQ = 0.0;
double dQAccum = 1.0;
double dDenomWork = 1.0;

double dPVFee4 = 0.0;
double dPVFee4_DBO2 = 0.0;
double dPVCharge4 = 0.0;
double dPVCharge4_DBO2 = 0.0;
double dPVGMDB4 = 0.0;
double dPVFTD4 = 0.0;
double dIAccum4 = 1.0;
double dMort4 = 0.0;
double dMort4_DBO2 = 0.0;
double dMort4Opt3 = 0.0;
double dGLPExp = 0.0;
double dPVTargetLoad4 = 0.0;
double dPVTotalLoad4 = 0.0;
double dPVTotalLoad4_DBO2 = 0.0;

double dIQAccum4 = 1.0;
double dPVFee6 = 0.0;
double dPVCharge6 = 0.0;
double dPVGMDB6 = 0.0;
double dPVFTD6 = 0.0;
double dIAccum6 = 1.0;
double dMort6 = 0.0;

double dPVTotalLoad6 = 1.0;

double dTerm = 1.0;
double dTermMort4 = 0.0;
double dTermMort4_DBO2 = 0.0;
double dTermMort6 = 0.0;
double dPVTermCharge4 = 0.0;
double dPVTermCharge6 = 0.0;
double dPVBelowTarget4 = 0.0;

double dEndow4 = 0.0;
double dEndow4_DBO2 = 0.0;
double dEndow6 = 0.0;


double dDAC_Tax_Percentage = 1.25;
double dState_Tax_Percentage = 2.00;

int iPremium_Load_Below_Target1 = 0.0;
int iPremium_Load_Above_Target1 = 0.0;
int iPremium_Load_Below_Target = 0.0;
int iPremium_Load_Above_Target = 0.0;

double dCurrent_Load_Above_Target1 = 0.0;
double dCurrent_Load_Below_Target1 = 0.0;
double dCurrent_Load_Above_Target = 0.0;
double dCurrent_Load_Below_Target = 0.0;
double dPVTargetPremiumLoad4 = 0.0;
double dPVTargetPremiumLoad4_DBO2 = 0.0;
double dPVTargetPremiumLoad6 = 0.0;
double dTest_Denom4 = 0.0;
double dTest_Denom4_DBO2 = 0.0;

double dCurrPer1000Charge = 0.0;

double dTemp = 0.0;

double dAK_Threshold = 136825.0;
double dAK_Percentage = 0.0;
double dAK_Part = 0.0;
double dAK_Part_DBO2 = 0.0;
double dAK_Denom = 0.0;
double dAK_Denom_DBO2 = 0.0;

double dBaseFaceThousands = Person.dFace / 1000.0;

dMinimumTermFace = Concept->getTerm_Sched()->GetMinimumValue();

int dST = Person.iIssue_State;

double dPremium_Target_Load_Difference = 0.0;



for (int iYear =1; iYear <= Person.iNo_Yrs_Illus; iYear++)
{
dGuaranteedQ = dGuar_Mort[iYear];// + m_pdFlatExtra[iYear];

dTemp = Get_dCurrLoadAboveTarget(iYear);
iPremium_Load_Above_Target = (int)(dTemp * 100.0);
dTemp = Get_dCurrLoadToTarget(iYear);
iPremium_Load_Below_Target = (int)(dTemp * 100.0);

dCurrent_Load_Above_Target = (dDAC_Tax_Percentage + dState_Tax_Percentage + (iPremium_Load_Above_Target1/100.0)) * .01;
dCurrent_Load_Below_Target = (dDAC_Tax_Percentage + dState_Tax_Percentage + (iPremium_Load_Below_Target1/100.0)) * .01;

dPremium_Target_Load_Difference = (iPremium_Load_Below_Target - iPremium_Load_Above_Target);


if (((dTarget[1] * dBaseFaceThousands)> dAK_Threshold) && (ALASKA == dST))
{
dPVTargetPremiumLoad4 += ((190.0 / 10000.0) * (dAK_Threshold/1000.0) * (1.0 + dGuaranteedQ)) / (dIAccum4 * dQAccum);
dPVTargetPremiumLoad4_DBO2 += ((190.0 / 10000.0) * (dAK_Threshold/1000.0) * (1.0 + dGuaranteedQ)) / (dIQAccum4);
}
else
{
dPVTargetPremiumLoad4 += ((dPremium_Target_Load_Difference / 10000.0) * dTarget[1] * (1.0 + dGuaranteedQ))/ (dIAccum4 * dQAccum);
dPVTargetPremiumLoad4_DBO2 += ((dPremium_Target_Load_Difference / 10000.0) * dTarget[1] * (1.0 + dGuaranteedQ))/ (dIQAccum4);
}

dTemp = iPremium_Load_Below_Target + 325;
dTest_Denom4 += (1.0 / (dIAccum4 * dQAccum)) * (1 - (dTemp/10000));
dTest_Denom4_DBO2 += (1.0 / dIQAccum4) * (1 - (dTemp/10000));


dTemp = iPremium_Load_Above_Target + 325;
dPVTotalLoad4 += (1.0 / (dIAccum4 * dQAccum)) * (1 - (dTemp/10000));
dPVTotalLoad4_DBO2 += (1.0 / dIQAccum4) * (1 - (dTemp/10000));

dAK_Percentage = __min(dCurrent_Load_Above_Target, .019);
dAK_Part += ((dAK_Percentage * __max((dTarget[1]*dBaseFaceThousands),dAK_Threshold)) * (1.0 + dGuaranteedQ)) / (dIAccum4 * dQAccum);
dAK_Part_DBO2 += ((dAK_Percentage * __max((dTarget[1]*dBaseFaceThousands),dAK_Threshold)) * (1.0 + dGuaranteedQ)) / (dIQAccum4);

dAK_Denom += ((__min((1 - (dCurrent_Load_Above_Target - .019)),1.0))* (1.0 + dGuaranteedQ)) / (dIAccum4 * dQAccum);
dAK_Denom_DBO2 += ((__min((1 - (dCurrent_Load_Above_Target - .019)),1.0))* (1.0 + dGuaranteedQ)) / (dIAccum4 * dQAccum);



for (int iMonth = 1; iMonth <= 12; iMonth++)
{
dQAccum *= (1.0 + dGuaranteedQ);


dPVFee4 += (ADMIN_FEE / (dIAccum4 * dQAccum)) * (1.0 + dGuaranteedQ);
dPVFee4_DBO2 += (ADMIN_FEE / dIQAccum4);

if (iYear < 11)
{
dCurrPer1000Charge = Get_dCurrPer1000Charge(1);
dPVCharge4 += (dCurrPer1000Charge/ (dIAccum4 * dQAccum)) * (1.0 + dGuaranteedQ);
dPVCharge4_DBO2 += (dCurrPer1000Charge / dIQAccum4);
}

dTermMort4 += (dMinimumTermFace*(dGuaranteedQ / (dIAccum4 * dQAccum))) * (1.0 + dGuaranteedQ);
dTermMort4_DBO2 += (dMinimumTermFace*(dGuaranteedQ / dIQAccum4));

dIAccum4 *= dInterestFactor4;
dIQAccum4 *= (1.0 + (dInterestFactor4Opt2 * (1.0 + dGuaranteedQ)));

dMort4 += (dGuaranteedQ / (dIAccum4 * dQAccum));
dMort4_DBO2 += (dGuaranteedQ / dIQAccum4);

dMort4Opt3 += ((dGuaranteedQ * (double)iYear) / (dIAccum4 * dQAccum));



dPVFee6 += (ADMIN_FEE / (dIAccum6 * dQAccum)) * (1.0 + dGuaranteedQ);
if (iYear < 11)
{
dCurrPer1000Charge = Get_dCurrPer1000Charge(1);
dPVCharge6 += (dCurrPer1000Charge / (dIAccum6 * dQAccum)) * (1.0 + dGuaranteedQ);
}
dTermMort6 += (dMinimumTermFace*(dGuaranteedQ / (dIAccum6 * dQAccum))) * (1.0 + dGuaranteedQ);
dIAccum6 *= dInterestFactor6;
dMort6 += (dGuaranteedQ / (dIAccum6 * dQAccum));



}//End of the Monthly Loop



}//End of the Yearly Loop




dEndow6 = (1.0 / (dIAccum6 * dQAccum));
dEndow4 = (1.0 / (dIAccum4 * dQAccum));
dEndow4_DBO2 = (1.0 / dIQAccum4);


double dTarget_Test1 = 0.0;
double dTarget_Test2 = 0.0;

double dTest_Denom6 = (iPremium_Load_Below_Target1 + 325.0) / 10000.0;

double dAK_Percentage1 = __min(dCurrent_Load_Above_Target1, .019);
double dAK_Part1 = dAK_Percentage * __max((dTarget[1]*dBaseFaceThousands),dAK_Threshold);
double dAK_Denom1 = __min((1 - (dCurrent_Load_Above_Target1 - .019)),1.0);

double dTP = dTarget[1] * dBaseFaceThousands;




// Guideline Level Premium Rates per $1000
// NOTE: GMDB rate used in this calc is already per $1000 and is not multipled by 1000 below


// case LEVEL_DEATH_BENEFIT: //Death Benefit Option 1

dTarget_Test1 = (dPVCharge4 + (dEndow4 * 1000.0) + (dMort4 * 1000.0));
dTarget_Test1 *= dBaseFaceThousands;
dTarget_Test1 += dPVFee4 + dTermMort4;
dTarget_Test1 /= dTest_Denom4;

dTarget_Test2 = (dPVCharge4 + (dPVTargetPremiumLoad4 / 1000.0) + (dEndow4 * 1000.0) + (dMort4 * 1000.0));
dTarget_Test2 *= dBaseFaceThousands;
dTarget_Test2 += dPVFee4 + dTermMort4;
dTarget_Test2 /= dPVTotalLoad4;

if (((dTarget_Test1 <= dTP) && (ALASKA != dST)) || ((dTarget_Test1 <= dTP) && (ALASKA == dST) && (dTarget_Test1 <= dAK_Threshold)))
{
dBase_GLP_Option1[1] = (dPVCharge4 + (dEndow4 * 1000.0) + (dMort4 * 1000.0)) / dTest_Denom4;
dBase_GLP_Flat_Option1[1] = dPVFee4 / dTest_Denom4;
if (dMinimumTermFace == 0.0)
dTerm_GLP_Option1[1] = 0.0;
else
dTerm_GLP_Option1[1] = (dTermMort4 * 1000.0) / (dTest_Denom4 * dMinimumTermFace);
}

if (((dTarget_Test1 <= dTP) && (ALASKA == dST) && (dTarget_Test1 > dAK_Threshold)) || ((dTarget_Test1 > dTP) && (ALASKA == dST) && (dTarget_Test2 <= dAK_Threshold)) || ((dTarget_Test1 > dTP) && (ALASKA != dST)))
{
dBase_GLP_Option1[1] = (dPVCharge4 + dPVTargetPremiumLoad4 + (dEndow4 * 1000.0) + (dMort4 * 1000.0)) / dPVTotalLoad4;
dBase_GLP_Flat_Option1[1] = dPVFee4 / dPVTotalLoad4;
if (dMinimumTermFace == 0.0)
dTerm_GLP_Option1[1] = 0.0;
else
dTerm_GLP_Option1[1] = (dTermMort4 *1000.0) / (dPVTotalLoad4 * dMinimumTermFace);
}

if ((dTarget_Test1 > dTP) && (ALASKA == dST) && (dTarget_Test2 > dAK_Threshold))
{
dBase_GLP_Option1[1] = (dPVCharge4 + dPVTargetPremiumLoad4 + (dEndow4 * 1000.0) + (dMort4 * 1000.0)) / dAK_Denom;
dBase_GLP_Flat_Option1[1] = (dPVFee4 + dAK_Part) / dAK_Denom;
if (dMinimumTermFace == 0.0)
dTerm_GLP_Option1[1] = 0.0;
else
dTerm_GLP_Option1[1] = (dTermMort4 *1000.0) / (dAK_Denom * dMinimumTermFace);
}

dBase_GLP_Option1[1] *= .998;
dBase_GLP_Flat_Option1[1] *= .998;
dTerm_GLP_Option1[1] *= .998;


// case INCREASE_DEATH_BENEFIT: //Death Benefit Option 2

dTarget_Test1 = (dPVCharge4_DBO2 + (dEndow4_DBO2 * 1000.0) + (dMort4_DBO2 * 1000.0));
dTarget_Test1 *= dBaseFaceThousands;
dTarget_Test1 += dPVFee4_DBO2 + dTermMort4_DBO2;
dTarget_Test1 /= dTest_Denom4_DBO2;

dTarget_Test2 = (dPVCharge4_DBO2 + (dPVTargetPremiumLoad4_DBO2 / 1000.0) + (dEndow4_DBO2 * 1000.0) + (dMort4_DBO2 * 1000.0));
dTarget_Test2 *= dBaseFaceThousands;
dTarget_Test2 += dPVFee4_DBO2 + dTermMort4_DBO2;
dTarget_Test2 /= dPVTotalLoad4_DBO2;

if (((dTarget_Test1 <= dTP) && (ALASKA != dST)) || ((dTarget_Test1 <= dTP) && (ALASKA == dST) && (dTarget_Test1 <= dAK_Threshold)))
{
dBase_GLP_Option2[1] = (dPVCharge4_DBO2 + (dEndow4_DBO2 * 1000.0) + (dMort4_DBO2 * 1000.0)) / dTest_Denom4_DBO2;
dBase_GLP_Flat_Option2[1] = dPVFee4_DBO2 / dTest_Denom4_DBO2;
if (dMinimumTermFace == 0.0)
dTerm_GLP_Option2[1] = 0.0;
else
dTerm_GLP_Option2[1] = (dTermMort4_DBO2 * 1000.0) / (dTest_Denom4_DBO2 * dMinimumTermFace);
}

if (((dTarget_Test1 <= dTP) && (ALASKA == dST) && (dTarget_Test1 > dAK_Threshold)) || ((dTarget_Test1 > dTP) && (ALASKA == dST) && (dTarget_Test2 <= dAK_Threshold)) || ((dTarget_Test1 > dTP) && (ALASKA != dST)))
{
dBase_GLP_Option2[1] = (dPVCharge4_DBO2 + dPVTargetPremiumLoad4_DBO2 + (dEndow4_DBO2 * 1000.0) + (dMort4_DBO2 * 1000.0)) / dPVTotalLoad4_DBO2;
dBase_GLP_Flat_Option2[1] = dPVFee4_DBO2 / dPVTotalLoad4_DBO2;
if (dMinimumTermFace == 0.0)
dTerm_GLP_Option2[1] = 0.0;
else
dTerm_GLP_Option2[1] = (dTermMort4_DBO2 * 1000.0) / (dPVTotalLoad4_DBO2 * dMinimumTermFace);
}

if ((dTarget_Test1 > dTP) && (ALASKA == dST) && (dTarget_Test2 > dAK_Threshold))
{
dBase_GLP_Option2[1] = (dPVCharge4_DBO2 + dPVTargetPremiumLoad4_DBO2 + (dEndow4_DBO2 * 1000.0) + (dMort4_DBO2 * 1000.0)) / dAK_Denom_DBO2;
dBase_GLP_Flat_Option2[1] = (dPVFee4_DBO2 + dAK_Part_DBO2) / dAK_Denom_DBO2;
if (dMinimumTermFace == 0.0)
dTerm_GLP_Option2[1] = 0.0;
else
dTerm_GLP_Option2[1] = (dTermMort4_DBO2 * 1000.0) / (dAK_Denom_DBO2 * dMinimumTermFace);
}

dBase_GLP_Option2[1] *= .998;
dBase_GLP_Flat_Option2[1] *= .998;
dTerm_GLP_Option2[1] *= .998;



// case RETURN_OF_PREMIUM: // Death Benefit Option 3

dTarget_Test1 = (dPVCharge4 + (dEndow4 * 1000.0) + (dMort4 * 1000.0));
dTarget_Test1 *= dBaseFaceThousands;
dTarget_Test1 += dPVFee4 + dTermMort4;
dTarget_Test1 /= (dTest_Denom4 - dMort4Opt3);

dTarget_Test2 = (dPVCharge4 + (dPVTargetPremiumLoad4 / 1000.0) + (dEndow4 * 1000.0) + (dMort4 * 1000.0));
dTarget_Test2 *= dBaseFaceThousands;
dTarget_Test2 += dPVFee4 + dTermMort4;
dTarget_Test2 /= (dPVTotalLoad4 - dMort4Opt3);

if (((dTarget_Test1 <= dTP) && (ALASKA != dST)) || ((dTarget_Test1 <= dTP) && (ALASKA == dST) && (dTarget_Test1 <= dAK_Threshold)))
{
dBase_GLP_Option3[1] = (dPVCharge4 + (dEndow4 * 1000.0) + (dMort4 * 1000.0)) / (dTest_Denom4 - dMort4Opt3);
dBase_GLP_Flat_Option3[1] = dPVFee4 / (dTest_Denom4 - dMort4Opt3);
if (dMinimumTermFace == 0.0)
dTerm_GLP_Option3[1] = 0.0;
else
dTerm_GLP_Option3[1] = (dTermMort4 * 1000.0) / ((dTest_Denom4 - dMort4Opt3) * dMinimumTermFace);
}

if (((dTarget_Test1 <= dTP) && (ALASKA == dST) && (dTarget_Test1 > dAK_Threshold)) || ((dTarget_Test1 > dTP) && (ALASKA == dST) && (dTarget_Test2 <= dAK_Threshold)) || ((dTarget_Test1 > dTP) && (ALASKA != dST)))
{
dBase_GLP_Option3[1] = (dPVCharge4 + dPVTargetPremiumLoad4 + (dEndow4 * 1000.0) + (dMort4 * 1000.0)) / (dPVTotalLoad4 - dMort4Opt3);
dBase_GLP_Flat_Option3[1] = dPVFee4 / (dPVTotalLoad4 - dMort4Opt3);
if (dMinimumTermFace == 0.0)
dTerm_GLP_Option3[1] = 0.0;
else
dTerm_GLP_Option3[1] = (dTermMort4 * 1000.0) / ((dPVTotalLoad4 - dMort4Opt3) * dMinimumTermFace);
}

if ((dTarget_Test1 > dTP) && (ALASKA == dST) && (dTarget_Test2 > dAK_Threshold))
{
dBase_GLP_Option3[1] = (dPVCharge4 + dPVTargetPremiumLoad4 + (dEndow4 * 1000.0) + (dMort4 * 1000.0)) / (dAK_Denom - - dMort4Opt3);
dBase_GLP_Flat_Option3[1] = (dPVFee4 + dAK_Part) / (dAK_Denom - dMort4Opt3);
if (dMinimumTermFace == 0.0)
dTerm_GLP_Option3[1] = 0.0;
else
dTerm_GLP_Option3[1] = (dTermMort4 * 1000.0) / ((dAK_Denom - dMort4Opt3) * dMinimumTermFace);
}

dBase_GLP_Option3[1] *= .998;
dBase_GLP_Flat_Option3[1] *= .998;
dTerm_GLP_Option3[1] *= .998;


/// dBase_GLP_Option3[1] = (dPVCharge4 + dPVTargetLoad4 + (dMort4 * 1000.0)) / (dPVTotalLoad4 - dMort4Opt3);
/// dBase_GLP_Flat_Option3[1] = dPVFee4 / (dPVTotalLoad4 - dMort4Opt3);
/// dTerm_GLP_Option3[1] = (dPVTermCharge4 + (dTermMort4 * 1000.0)) / (dPVTotalLoad4 - dMort4Opt3);


// Guideline Single Rates per $1000
// (same for Death Benefit Options 1, 2, 3)

dTemp = Get_dCurrLoadAboveTarget(1);
iPremium_Load_Above_Target1 = (int)(dTemp * 100.0);
dTemp = Get_dCurrLoadToTarget(1);
iPremium_Load_Below_Target1 = (int)(dTemp * 100.0);

dCurrent_Load_Above_Target1 = (dDAC_Tax_Percentage + dState_Tax_Percentage + (iPremium_Load_Above_Target1/100.0)) * .01;
dCurrent_Load_Below_Target1 = (dDAC_Tax_Percentage + dState_Tax_Percentage + (iPremium_Load_Below_Target1/100.0)) * .01;

dPVTotalLoad6 = (1 - dCurrent_Load_Above_Target1);
dTemp = (iPremium_Load_Below_Target1 - iPremium_Load_Above_Target1);

if (((dTarget[1] * dBaseFaceThousands)> dAK_Threshold) && (ALASKA == dST))
dPVTargetPremiumLoad6 = (190.0 / 10000.0) * (dAK_Threshold / 1000.0);
else
dPVTargetPremiumLoad6 = (dTemp / 10000.0) * (dTarget[1]);


// p<target & AK Test

dBaseFaceThousands = Person.dFace / 1000.0;
dTarget_Test1 = 0.0;
dTarget_Test2 = 0.0;
dTest_Denom6 = (iPremium_Load_Below_Target1 + 325.0) / 10000.0;


if (((dTarget[1] * dBaseFaceThousands)> dAK_Threshold) && (ALASKA == dST))
{
dAK_Percentage1 = __max((dCurrent_Load_Below_Target1 - .019), 0.0) - __max((dCurrent_Load_Above_Target1 - .019), 0.0);
dAK_Part1 = (dTarget[1] * dBaseFaceThousands);
dAK_Part1 *= dAK_Percentage1;
}
else
{
dAK_Percentage1 = __min(dCurrent_Load_Above_Target1, .019);
dAK_Part1 = dAK_Percentage1 * dAK_Threshold;
}
dAK_Denom1 = __min((1 - (dCurrent_Load_Above_Target1 - .019)),1.0);



dTarget_Test1 = (dPVCharge6 + (dEndow6 * 1000.0) + (dMort6 * 1000.0));
dTarget_Test1 *= dBaseFaceThousands;
dTarget_Test1 += dPVFee6 + dTermMort6;
dTarget_Test1 /= (1 - dTest_Denom6);

dTarget_Test2 = (dPVCharge6 + (dPVTargetPremiumLoad6 / 1000.0) + (dEndow6 * 1000.0) + (dMort6 * 1000.0));
dTarget_Test2 *= dBaseFaceThousands;
dTarget_Test2 += dPVFee6 + dTermMort6;
dTarget_Test2 /= dPVTotalLoad6;

if (((dTarget_Test1 <= dTP) && (ALASKA != dST)) || ((dTarget_Test1 <= dTP) && (ALASKA == dST) && (dTarget_Test1 <= dAK_Threshold)))
{
dBase_GSP[1] = (dPVCharge6 + (dEndow6 * 1000.0) + (dMort6 * 1000.0)) / (1 - dTest_Denom6);
dBase_GSP_Flat[1] = dPVFee6 / (1 - dTest_Denom6);
if (dMinimumTermFace == 0.0)
dTerm_GSP[1] = 0.0;
else
dTerm_GSP[1] = (1000.0 * dTermMort6)/ ((1 - dTest_Denom6) * dMinimumTermFace);
}

if (((dTarget_Test1 <= dTP) && (ALASKA == dST) && (dTarget_Test1 > dAK_Threshold)) || ((dTarget_Test1 > dTP) && (ALASKA == dST) && (dTarget_Test2 <= dAK_Threshold)) || ((dTarget_Test1 > dTP) && (ALASKA != dST)))
{
dBase_GSP[1] = (dPVCharge6 + dPVTargetPremiumLoad6 + (dEndow6 * 1000.0) + (dMort6 * 1000.0)) / dPVTotalLoad6;
dBase_GSP_Flat[1] = dPVFee6 / dPVTotalLoad6;
if (dMinimumTermFace == 0.0)
dTerm_GSP[1] = 0.0;
else
dTerm_GSP[1] = (1000.0 * dTermMort6) / (dPVTotalLoad6 * dMinimumTermFace);
}

if ((dTarget_Test1 > dTP) && (ALASKA == dST) && (dTarget_Test2 > dAK_Threshold))
{
dBase_GSP[1] = (dPVCharge6 + dPVTargetPremiumLoad6 + (dEndow6 * 1000.0) + (dMort6 * 1000.0)) / dAK_Denom1;
dBase_GSP_Flat[1] = (dPVFee6 + dAK_Part1) / dAK_Denom1;
if (dMinimumTermFace == 0.0)
dTerm_GSP[1] = 0.0;
else
dTerm_GSP[1] = (1000.0 * dTermMort6)/ (dAK_Denom1 * dMinimumTermFace);
}
}
</lj-cut>
Subscribe
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 5 comments