PHP code example of finazon / finazon-grpc-php
1. Go to this page and download the library: Download finazon/finazon-grpc-php 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/ */
finazon / finazon-grpc-php example snippets
Finazon\Grpc\Api\GetTimeSeriesRequest;
use Finazon\Grpc\Api\TimeSeries;
use Finazon\Grpc\Exception\RequestException;
use Finazon\Grpc\Service\TimeSeriesService;
// Load last OHLCV candles for AAPL
$service = new TimeSeriesService('your_api_key');
$request = new GetTimeSeriesRequest();
$request->setDataset('sip_non_pro')
->setTicker('AAPL')
->setInterval('1h')
->setPageSize(10);
try {
$response = $service->getTimeSeries($request);
echo 'Last AAPL OHLCV data' . PHP_EOL;
foreach ($response->getResult() as $t) {
/** @var Timeseries $t */
echo sprintf(
'%s - %s, %s, %s, %s, %s %s',
$t->getTimestamp(), $t->getOpen(), $t->getHigh(), $t->getLow(), $t->getClose(),
$t->getVolume(), PHP_EOL,
);
}
} catch (RequestException $e) {
echo sprintf('Received error, code: %s, message: %s%s', $e->getCode(), $e->getMessage(), PHP_EOL);
}
Finazon\Grpc\Api\RpcNameRequest;
use Finazon\Grpc\Service\ServiceNameService;
# ...
$service = new ServiceNameService('your_api_key');
$request = new RpcNameRequest();
$response = service->rpcName($request);
composer
shell
composer update finazon/finazon-grpc-php
shell
composer
bash
php time_series.php