AnnuityConnector Demo Examples
AnnuityConnector Demo Assumption Sets
AnnuityValue
Demo version 6.1 contains two archived assumption sets:
1949A_4.85_5.02_5.09
1949A_5.44_5.95_5.41
You may
reference these assumption sets in your code when calling the AnnuityConnector demo.
AnnuityConnector Sample Code 1 – Visual Basic
Example code
1 demonstrates calling AnnuityConnector using Visual
Basic.
This type of
code can be used in an Excel Macro.
To verify this, copy the
routine below ‘as is’ to an Excel macro and run the macro.
Visual Basic
code calls AnnuityConnector with
following parameters:
Assumption=1949A_4.85_5.02_5.09
Primary Age = 62 years and 0 months
Secondary Age = 66 years and 0 months
J&S% = 75
This routine
overrides the archived assumption with J&S percent value of 75.
Thus, all
Joint values generated will utilize the 75% survivor assumption.
We capture
the Joint & Contingent conversion factor from Single Life to 75% Joint
& Contingent and place the value in Excel cell A10.
This transaction
represents one (1) call to AnnuityConnector.
Sub httprequest()
'
' httprequest Macro
'
'
Dim objWinHTTP As Object
Dim TextStatus As String
Dim PageResponse As String
' Create WinHTTP Object
Set objWinHTTP = CreateObject("WinHTTP.WinHttpRequest.5.1")
' Set Parameters
and Assemble an HTTP Request referencing OMS
BaseURL =
"http://www.oakmountainsoftware.com/cgi-bin/demov61/segment.pl?"
Parms =
"assump=1949A_4.85_5.02_5.09" + _
"&pindyear=62"
+ _
"&pindmonth=0"
+ _
"&sindyear=66"
+ _
"&sindmonth=0"
+ _
"&setback=" + _
"&certain=" + _
"&defyear="
+ _
"&defmonth="
+ _
"&survivor=75"
' Define full URL
string
URLQuery = BaseURL & Parms
objWinHTTP.Open
"GET", URLQuery
' Set the user
name and password.
objWinHTTP.SetCredentials
"demouser", "demopswd",
_
HTTPREQUEST_SETCREDENTIALS_FOR_SERVER
' Send the HTTP
Request to OMS
objWinHTTP.Send
' Put status and
content type into status text box.
TextStatus = objWinHTTP.StatusText
PageResponse = objWinHTTP.ResponseText
' Capture J&S
Conversion Factor from the <jointcontcflife>
tag
' on the Response
page
MyPosStart = InStr(1, PageResponse, "<jointcontcflife>",
1)
MyPosEnd = InStr(1, PageResponse, "</jointcontcflife>",
1)
ValueStart = MyPosStart + 17
JSFactor = Mid(PageResponse, ValueStart, 10) '
J&S Factor
' Set Excel cell A10 to the J&S Factor
Range("A10")
= JSFactor
End
Sub
AnnuityConnector Sample Code 2 - Perl
Example code
2 in Perl code calls AnnuityConnector with
following parameters:
Assumption=1949A_4.85_5.02_5.09
Primary Age = 55 years and 0 months
Secondary Age = 62 years and 3 months
The routine
captures two values:
The Primary Immediate annuity factor at age 55 and 0 months
And
The Secondary Deferred annuity factor at age 62 and 3
months.
This
transaction represents one (1) call to AnnuityConnector –
yet, the user obtains two values.
#
#
use
URI;
use
LWP::UserAgent;
use
HTTP::Request;
my
$browser = LWP::UserAgent->new;
#
#
#
Create URL string and parameter values to pass to OMS Demo site
#
#
#
my
$url = URI->new('http://www.oakmountainsoftware.com/cgi-bin/demov61/segment.pl');
#
$url->query_form( 'assump' =>
1949A_4.85_5.02_5.09,
'pindyear' => 55,
'pindmonth' => 0,
'sindyear' => 62,
'sindmonth' => 3,
'setback'
=> $setback,
'certain'
=> $yrscertain,
'defyear' => $defyear,
'defmonth' => $defmonth,
'survivor' => $survivorpct);
#
#
Call to AnnuityConnector
#
$req = HTTP::Request->new(GET => $url);
#
#
Pass in Authorization values
#
$req->authorization_basic('demouser', 'demopswd');
#
$response = $browser->request($req);
#
#
#
die
"Error: ", $response->status_line unless
$response->is_success;
#
#
#
Capture factors in various name tags generated per assumption and parameters
#
Use factors in program as needed
#
# Capture
Immediate Single Life annuity factor - Primary
if
($response->content =~ m{<pannimm>(.*?)</pannimm>}) {
$plifeann=$1;
}
#
# Capture
Deferred Single Life annuity factor - Secondary
if
($response->content =~ m{<sanndef>(.*?)</sanndef>}) {
$sdefann=$1;
}
AnnuityConnector Sample Code 3 - Perl
Example code
3 in Perl code calls AnnuityConnector with
following parameters:
Assumption=1949A_4.85_5.02_5.09
Primary Age = 55 years and 0 months
Secondary Age = 62 years and 3 months
Years Certain = 10
This routine
overrides the archived assumption with the N Year Certain & Life value of
10.
Thus, all
the values generated will utilize the 10 Year Certain & Life assumption.
We capture
the Primary conversion factor from Single Life to 10 Year Certain & Life at
age 55 and 0 months.
This
transaction represents one (1) call to AnnuityConnector.
#
#
use
URI;
use
LWP::UserAgent;
use
HTTP::Request;
my
$browser = LWP::UserAgent->new;
#
#
#
Create URL string and parameter values to pass to OMS Demo site
#
#
#
my
$url =
URI->new('http://www.oakmountainsoftware.com/cgi-bin/demov61/segment.pl');
#
$url->query_form( 'assump' =>
1949A_4.85_5.02_5.09,
'pindyear' => 55,
'pindmonth' => 0,
'sindyear' => 62,
'sindmonth' => 3,
'setback'
=> $setback,
'certain'
=> 10,
'defyear' => $defyear,
'defmonth' => $defmonth,
'survivor' => $survivorpct);
#
#
Call to AnnuityConnector
#
$req = HTTP::Request->new(GET => $url);
#
#
Pass in Authorization values
#
$req->authorization_basic('demouser', 'demopswd');
#
$response = $browser->request($req);
#
#
#
die
"Error: ", $response->status_line unless
$response->is_success;
#
#
#
Capture factors in various name tags generated per assumption and parameters
#
Use factors in program as needed
#
# Capture
Primary Conversion Factor from Single Life to 10 year Certain
and Life
if
($response->content =~ m{<pcflife>(.*?)</pcflife>}) {
$nyearcf=$1;
}
#