Examples of performance per calendar year
Performance per calendar year realized with PHP
This PHP based example fetches the performance per calendar year API endpoint by cURL and places all parts in a HTML structure.
Performance per calendar year for HANSAsmart Select E (Class-I) (DE000A1JXM68)
2018 | 0,17% |
---|---|
2017 | 11,63% |
2016 | -2,50% |
2015 | 11,01% |
2014 | 11,72% |
2013 | 19,14% |
2012 | 3,22% |
<?php
// Get cURL resource
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'https://api.hansainvest.com/api/v1/performance-years/DE000A1JXM68/',
CURLOPT_USERAGENT => 'Sample cURL Request',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
)
));
// Send the request & save response to $resp
$respJson = curl_exec($curl);
$fundPerformanceYears = json_decode($respJson);
// Close request to clear up some resources
curl_close($curl);
?>
<h3 class="hi-performanceyears-title">Performance per calendar year for <?php echo $fundPerformanceYears->fund->name; ?> (<?php echo $fundPerformanceYears->fund->isin; ?>)</h3>
<table class="table hi-performanceyears-table">
<tbody>
<?php
foreach ($fundPerformanceYears->years as $year => $performance) {
?>
<tr>
<th scope="row"><?php echo $year; ?></th>
<td class="hi-performanceyears-value"><?php echo number_format($performance, 2, ',', ''); ?>%</td>
</tr>
<?php
}
?>
</tbody>
</table>
<a class="hi-performanceyears-link" href="<?php echo $fundPerformanceYears->fund->url; ?>">all fund details</a>