SDK Code Examples
Use the following samples to load and call the SSCMFI Function Library (SDK) dynamically inside your local applications. Make sure the compiled library (libsscmfi.dll, libsscmfi.so, or libsscmfi.dylib) is placed in your application's executable path.
cpp
#include <iostream>
#include <windows.h>
// Define function pointers matching sscmfi interface
typedef char* (*sscmfi_init_t)(char*);
typedef char* (*sscmfi_calculate_t)(char*);
typedef void (*sscmfi_free_string_t)(char*);
int main() {
// 1. Dynamic Load of Dynamic Link Library (DLL)
HINSTANCE hDll = LoadLibrary("libsscmfi.dll");
if (!hDll) {
std::cerr << "Failed to load libsscmfi.dll" << std::endl;
return 1;
}
// 2. Resolve Dynamic Function Entry Points
auto sscmfi_init = (sscmfi_init_t)GetProcAddress(hDll, "sscmfi_init");
auto sscmfi_calculate = (sscmfi_calculate_t)GetProcAddress(hDll, "sscmfi_calculate");
auto sscmfi_free_string = (sscmfi_free_string_t)GetProcAddress(hDll, "sscmfi_free_string");
if (!sscmfi_init || !sscmfi_calculate || !sscmfi_free_string) {
std::cerr << "Failed to resolve DLL functions" << std::endl;
FreeLibrary(hDll);
return 1;
}
// 3. Initialize Licensing with API Key (Only needs to be done once per process)
char* initRes = sscmfi_init("YOUR_API_KEY_HERE");
std::cout << "SSCMFI Init Status: " << initRes << std::endl;
// 4. Construct JSON Payload String
char* jsonPayload = R"({
"metadata": {
"calculationID": "SDK-CPP"
},
"securityDefinition": {
"securityID": "SDK-SEC",
"paymentType": "Periodic",
"securityType": "Corporate",
"maturityDate": "3/31/2031",
"couponRate": 8.75,
"redemption_value": 100.0,
"dayCountBasis": "SSCM30/360",
"eomRule": "Adjust",
"periodsPerYear": "Monthly"
},
"tradeDefinition": {
"tradeDate": "7/22/2025",
"settlementDate": "7/23/2025",
"givenType": "Price",
"givenValue": 103.5
},
"calculationSelection": {
"calcsToReturn": {
"calcPY": "Yes",
"calcPYAnalytics": "Yes",
"calcCFS": "No",
"calcCFSAnalytics": "Yes",
"calcCouponPeriod": "Yes"
},
"calculationsFor": "All redemptions"
},
"settings": {
"dateScheme": {
"dateTwoOrFourYear": "FOUR",
"dateFormat": "MDY",
"dateCutoffYear": 2075
}
}
})";
// 5. Execute In-Process calculation
char* response = sscmfi_calculate(jsonPayload);
std::cout << "Calculation Response:\n" << response << std::endl;
// 6. Free C-string Memory back to the DLL heap
sscmfi_free_string(response);
// 7. Cleanup & Unload DLL
FreeLibrary(hDll);
return 0;
}