Standard Securities Calculation Methods

APIs and MCP

Code Samples

Use the following samples to quickly integrate the SSCMFI Public API into your application. Each sample demonstrates how to build a calculation request and handle the JSON response.

PHP
💾 Download
<?php
/**
 * SSCMFI Public API - PHP Sample Code
 * 
 * This script demonstrates how to call the sscmfiPublicAPI using PHP's cURL extension.
 * It uses a sample "Periodic" bond with a complex call schedule.
 */

// 1. Configuration

// --- Option A: Public API (No API Key required, rate limited) ---
$api_url = "https://api.sscmfi.com/api/sscmfiPublicAPI";
$api_key = ""; 

// --- Option B: Subscription API (Requires API Key) ---
// $api_url = "https://api.sscmfi.com/api/sscmfiAPICalculate"; 
// $api_key = "YOUR_API_KEY_HERE";

// 2. Prepare the Request Payload (based on Sample data for code examples)
$payload = [
    'metadata' => [
        'calculationID' => "ABC987"
    ],
    'securityDefinition' => [
        'securityID' => 'Testsec77',
        'paymentType' => 'Periodic',
        'securityType' => 'Corporate',
        'maturityDate' => '3/31/2031',
        'couponRate' => 8.75,
        'redemption_value' => 100.0,
        'dayCountBasis' => 'SSCM30/360',
        'eomRule' => 'Adjust',
        'periodsPerYear' => 'Monthly',
        'callRedemptions' => [
            'redemptionScheduleType' => 'Continuous with notification',
            'notifyMinDays' => 30,
            'notifyMaxDays' => 60,
            'notifyStart' => 'Trade date',
            'notifyCalendarBusiness' => 'Calendar days',
            'redemptionList' => [
                ['date' => '03/31/2027', 'value' => 101.50],
                ['date' => '09/30/2027', 'value' => 101.25],
                ['date' => '03/31/2028', 'value' => 101.0],
                ['date' => '09/03/2028', 'value' => 100.75],
                ['date' => '03/31/2029', 'value' => 100.50],
                ['date' => '09/30/2029', 'value' => 100.25]
            ]
        ]
    ],
    '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
        ]
    ]
];

// 3. Initialize cURL
$ch = curl_init($api_url);

// 4. Set cURL Options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));

$headers = ['Content-Type: application/json'];
if (!empty($api_key)) {
    $headers[] = 'X-API-KEY: ' . $api_key;
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

// 5. Execute API Call
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

// 6. Handle Response
$is_cli = (php_sapi_name() === 'cli');

if (!$is_cli) echo "<pre>";

if (curl_errno($ch)) {
    echo "Curl Error: " . curl_error($ch) . "\n";
} else {
    $decoded_response = json_decode($response, true);
    
    echo "HTTP Status: $http_code\n";
    
    if ($http_code === 200 && isset($decoded_response['success']) && $decoded_response['success']) {
        echo "Status: SUCCESS\n\n";
        print_r($decoded_response);
    } else {
        echo "Status: FAILED\n\n";
        print_r($decoded_response);
    }
}

if (!$is_cli) echo "</pre>";

// 7. Cleanup
curl_close($ch);
?>