opcvm360/sdk-php

A PHP library for communicating with the OPCVM360 REST API

Installs: 1 288

Dependents: 1

Stars: 1

Watchers: 3

Language: PHP

v0.6 2014-03-31 13:42 UTC

README

OPCVM360 provides financial datas of European funds, on a daily basis.

Please request a login and password to FINANCE Web Working. Or contact through:

Install the OPCVM360/sdk-php

Via Composer:

OPCVM360/sdk-php is available on Packagist as the ff OPCVM360/sdk-php package.

Via ZIP file:

Click here to download the source (.zip) which includes all dependencies.

Once you download the library, move the OPCVM360/sdk-php folder to your project directory and then include the library file:

require ('/path/to/OPCVM360/Services/OPCVM360.php');

and you're good to go!

Via git:
git clone https://github.com/OPCVM360/sdk-php.git

Code Example

Retrieve 2013 to know prices of the fund whose ISIN is LU0068578508.

<?php
require('path/to/the/sdk-php/Services/OPCVM360.php');
$service = new Services_OPCVM360('My_OPCVM360_Login', 'My_OPCVM360_Password');

//inputs
$isin="LU0068578508";       //FIRST EAGLE AMUNDI INTERNATIONAL
$HistoryFrom="2013-01-01";  //from jan 1st 2013
$HistoryTo=Null;            //till now


//retrieve the fundShare by its ISIN
$fundShare=$service->getFundShareByIsin($isin);

//retrieve history of that fundShare, for the specified range of dates
//the $fundShareHistory object act as an iterator
$fundShareHistory = $fundShare->getHistoryRange($HistoryFrom,$HistoryTo);
?>

<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css">
    td, th { border: 1px solid }
    th { font-weight: bold }
</style>
<h1>Raw fundshare meta data for <?php echo $isin ?></h1>
<?php var_dump($fundShare) ?>
<hr/>
<h1>Prices table from <?php echo $HistoryFrom==null ? inception : $HistoryFrom ?> to <?php echo $HistoryTo==null ? now : $HistoryTo ?></h1>
<table>
    <?php
    $firstRow=true;
    while ($fundShareHistory->getCurrentPage() < $fundShareHistory->getNumberOfPages())
    {
        foreach ($fundShareHistory->getResults() as $historyLine)
        {
            if ($firstRow)
                    {echo "<tr><th>".implode("</td><th>",array_keys($historyLine))."</th></tr>";$firstRow=false;}
            echo "<tr><td>".implode("</td><td>",$historyLine)."</td></tr>";
        }
        $fundShareHistory->goToNextPage();
    }
    ?>
</table>

Data model

https://docs.google.com/a/idm.io/presentation/d/1mMebINgxVJpfNDRLN2leE7hpUINmC8-jZAC85P0GVIg/edit#slide=id.g2b66ed8ed_00

Class Methods available for the service

  • $service->getCompanyById($id) // returns a Company object
  • $service->getFundById($id) // returns a Fund object
  • $service->getFundshareById($id) // returns a FundShare object
  • $service->getFundshareByIsin($isin) // returns a FundShare object

Methods available by object

company

  • $this->getFunds() // returns an array of Fund objects linked to that company;

fund

  • $this->getFundShares() // returns an array of Fundshare objects linked to current fund

fundshare

  • $this->getHistoryRange($fromDate=null,$toDate=null) // returns a object List with data = array of fundshareHistory objects With List object you can paginate results. When a List is constructed, the active page is the first one, ie the oldest set of datas. Then you can use the following methods on this object:
    • $this->getResults() //returns an array of datas for the actual page (vl, date, ...)
    • $this->goToNextPage() //set the current page to the next one
    • $this->getNumberOfPages() //returns the total number of pages
    • $this->getCurrentPage() //returns the actual page number
    • $this->setCurrentPage($page) //set the current page number to $page
    • $this->goToLastPage() //set the current page to the last page
  • $this->getHistoryLastValue() // returns the last fundshareHistory associated with current FundShare
  • $this->get($field) // returns field value formatted if needed

manager

No method available

document

No method available