Examples of fund prices
Current fund prices realized with PHP
This PHP based example fetches the fund prices API endpoint by cURL and places all parts in a HTML structure.
HANSArenta (DE0008479015)
Datum: 14.02.2018
Ausgabepreis | 25,029 EUR |
---|---|
Rücknahmepreis | 24,183 EUR |
Net asset value | 24,183 EUR |
Differenz zum Vortag | -0,030 EUR |
Wertentwicklung in % seit 31.12.2017 | -0,750% |
<?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/prices-current/DE0008479015/',
CURLOPT_USERAGENT => 'Sample cURL Request',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
)
));
// Send the request & save response to $respJson
$respJson = curl_exec($curl);
$fundPrices = json_decode($respJson);
// Close request to clear up some resources
curl_close($curl);
?>
<h3 class="hi-fundprices-title">Current fund prices for <?php echo $fundPrices->fund->name; ?> (<?php echo $fundPrices->fund->isin; ?>)</h3>
<h4 class="hi-fundprices-date">Date: <?php echo date('d.m.Y', strtotime($fundPrices->prices->date)); ?></h4>
<table class="table hi-fundprices-table">
<tbody>
<tr>
<th scope="row"><?php echo $fundPrices->prices->issue_price->name; ?></th>
<td class="hi-fundprices-issue_price"><?php echo $fundPrices->prices->issue_price->value; ?> <?php echo $fundPrices->currency; ?></td>
</tr>
<tr>
<th scope="row"><?php echo $fundPrices->prices->repurchase_price->name; ?></th>
<td class="hi-fundprices-repurchase_price"><?php echo $fundPrices->prices->repurchase_price->value; ?> <?php echo $fundPrices->currency; ?></td>
</tr>
<tr>
<th scope="row"><?php echo $fundPrices->prices->net_asset_value->name; ?></th>
<td class="hi-fundprices-net_asset_value"><?php echo $fundPrices->prices->net_asset_value->value; ?> <?php echo $fundPrices->currency; ?></td>
</tr>
<tr>
<th scope="row"><?php echo $fundPrices->prices->change->name; ?></th>
<td class="hi-fundprices-change"><?php echo $fundPrices->prices->change->value; ?> <?php echo $fundPrices->currency; ?></td>
</tr>
<tr>
<th scope="row"><?php echo $fundPrices->prices->performance->name; ?></th>
<td class="hi-fundprices-performance"><?php echo $fundPrices->prices->performance->value; ?>%</td>
</tr>
</tbody>
</table>
<a class="hi-fundprices-link" href="<?php echo $fundPrices->fund->url; ?>">all fund details</a>
Historic fund prices realized with PHP
This PHP based example fetches the fund prices API endpoint by cURL and places all parts in a HTML structure.
HANSAsecur (DE0008479023)
Datum | Ausgabepreis | Rücknahmepreis | Net asset value | Differenz zum Vortag | Kalenderjährliche Wertentwicklung |
---|---|---|---|---|---|
28.12.2017 | 48.064 EUR | 45.775 EUR | 45.775 EUR | 0.030 EUR | 13.070% |
29.12.2017 | 47.781 EUR | 45.506 EUR | 45.506 EUR | -0.270 EUR | 12.410% |
02.01.2018 | 47.539 EUR | 45.275 EUR | 45.275 EUR | -0.230 EUR | -0.260% |
03.01.2018 | 47.568 EUR | 45.303 EUR | 45.303 EUR | 0.030 EUR | -0.200% |
04.01.2018 | 47.924 EUR | 45.642 EUR | 45.642 EUR | 0.340 EUR | 0.550% |
05.01.2018 | 48.479 EUR | 46.170 EUR | 46.170 EUR | 0.530 EUR | 1.710% |
<?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/prices-historic/DE0008479023/2017-12-01/2018-02-01/',
CURLOPT_USERAGENT => 'Sample cURL Request',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
)
));
// Send the request & save response to $respJson
$respJson = curl_exec($curl);
$fundPrices = json_decode($respJson);
// Close request to clear up some resources
curl_close($curl);
?>
<h3 class="hi-fundprices-title">Historic fund prices for <?php echo $fundPrices->fund->name; ?> (<?php echo $fundPrices->fund->isin; ?>)</h3>
<table class="table hi-fundprices-table">
<thead>
<tr>
<th scope="col">
Date
</th>
<th scope="col">
<?php echo $fundPrices->prices[0]->issue_price->name; ?>
</th>
<th scope="col">
<?php echo $fundPrices->prices[0]->repurchase_price->name; ?>
</th>
<th scope="col">
<?php echo $fundPrices->prices[0]->net_asset_value->name; ?>
</th>
<th scope="col">
<?php echo $fundPrices->prices[0]->change->name; ?>
</th>
<th scope="col">
<?php echo $fundPrices->prices[0]->performance->name; ?>
</th>
</tr>
</thead>
<tbody>
<?php foreach ($fundPrices->prices as $historicPrice): ?>
<tr>
<th scope="row"><?php echo date('d.m.Y', strtotime($historicPrice->date)); ?></th>
<td class="hi-fundprices-issue_price"><?php echo $historicPrice->issue_price->value; ?> <?php echo $fundPrices->currency; ?></td>
<td class="hi-fundprices-repurchase_price"><?php echo $historicPrice->repurchase_price->value; ?> <?php echo $fundPrices->currency; ?></td>
<td class="hi-fundprices-net_asset_value"><?php echo $historicPrice->net_asset_value->value; ?> <?php echo $fundPrices->currency; ?></td>
<td class="hi-fundprices-change"><?php echo $historicPrice->change->value; ?> <?php echo $fundPrices->currency; ?></td>
<td class="hi-fundprices-performance"><?php echo $historicPrice->performance->value; ?>%</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<a class="hi-fundprices-link" href="<?php echo $fundPrices->fund->url; ?>">all fund details</a>