Example of fund key figures

Fund fund key figures realized with PHP

This PHP based example fetches the fund key figures API endpoint by cURL and places all parts in a HTML structure.

Key figures for HANSAsecur (DE0008479023)

Investitionsgrad 97.087436  
VaR 5,31%  
offene Fremdwährungsquote 0,14 %  
Sharpe Ratio 0,08  
Max Drawdown -0,12  
Drawdown -0,02  
Anzahl positiver Monate 19  
Anzahl negativer Monate 17  
Bester Monat 11,05 %  
Schlechtester Monat -10,09 %  
Anteil positiver Monate 52,78 %  
Volatilität 13,63 %  
all fund details
<?php

// Get cURL resource
$curl = curl_init();

// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, [
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL            => 'https://api.hansainvest.com/api/v1/figures/DE0008479023/',
    CURLOPT_USERAGENT      => 'Sample cURL Request',
    CURLOPT_HTTPHEADER     => [
        'Content-Type: application/json',
    ],
]);

// Send the request & save response to $respJson
$respJson = curl_exec($curl);
$fundData = json_decode($respJson);

// Close request to clear up some resources
curl_close($curl);

?>

<h3 class="hi-figures-title">Key figures for <?php echo $fundData->fund->name; ?> (<?php echo $fundData->fund->isin; ?>
    )</h3>
<table class="table hi-figures-table">
    <tbody>
    <?php if (is_array($fundData->figures)): ?>
        <?php foreach ($fundData->figures as $figure): ?>
            <tr>
                <th scope="row"><?php echo $figure->name; ?></th>
                <td class="hi-figures-value">
                    <?php echo $figure->value; ?>
                </td>
                <td class="hi-figures-value">
                    <?php if ($figure->value2): ?>
                        <?php echo $figure->value2; ?>
                    <?php else: ?>
                        &nbsp;
                    <?php endif; ?>
                </td>
            </tr>
        <?php endforeach; ?>
    <?php endif; ?>
    </tbody>
</table>
<a class="hi-figures-link" href="<?php echo $fundData->fund->url; ?>">all fund details</a>