PHP code example of larsbadke / portfolio-selector
1. Go to this page and download the library: Download larsbadke/portfolio-selector library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
larsbadke / portfolio-selector example snippets
// Create Apple stock object and set performances in percent.
$apple = new Stock('Apple');
$apple->setPerformances([0, 3, 0, 3]);
// Create Google stock object.
$google = new Stock('Google');
$google->setPerformances([0, 3, 0, 3]);
// Create a new portfolio instance and add your stocks to it
$portfolio = new Portfolio();
$portfolio->add($apple);
$portfolio->add($google);
// Get the expectation value of your portfolio
$portfolio->expectation();
// Get the variance of your portfolio
$portfolio->variance();
$selector = new Selector($portfolio);
$selector->run();