shahariaazam / bd-stock-exchange
Bangladeshi stock exchange (share market) stock price data fetch with PHP. Get Dhaka Stock Exchange (DSE) and Chittagong Stock Exchange (CSE) stock price data
Installs: 87
Dependents: 0
Suggesters: 0
Security: 0
Stars: 31
Watchers: 6
Forks: 20
Open Issues: 2
Language:HTML
Requires
- ext-curl: *
- ext-json: *
- nyholm/psr7: ^1.2
- psr/http-client: ^1.0
- symfony/dom-crawler: ^4.4
- symfony/http-client: ^4.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- php-http/mock-client: ^1.3
- phpcompatibility/php-compatibility: ^9.3
- phpunit/phpunit: ^8.5
- squizlabs/php_codesniffer: ^3.5
Suggests
- guzzlehttp/psr7: PSR-7 message implementation that also provides common utility methods
- php-http/curl-client: cURL client for PHP-HTTP
This package is auto-updated.
Last update: 2024-11-29 04:58:06 UTC
README
Bangladesh Stock Exchange
This PHP library provides a simple way to get and parse the stock price for Dhaka Stock Exchange & Chittagong Stock Exchange in real time directly from the official website.
Installation
Install this library via composer
by running the following command
composer require shahariaazam/bd-stock-exchange
Note: This library has been upgraded from it's old (legacy) code and made it as a standard library. if you still want to use legacy (OLD) codes, you can find that in old-legacy-codes branch.
Or you can download OLD codes as zip
. Click here to download old codes.
Usage
After installing you can simply get the latest Dhaka Stock Exchange price data
Get Bangladeshi Stock Exchange Share Price
<?php use ShahariaAzam\BDStockExchange\StockExchange\ChittagongStockExchange; use ShahariaAzam\BDStockExchange\StockExchange\DhakaStockExchange; use ShahariaAzam\BDStockExchange\StockPrice; require "vendor/autoload.php"; $dse = new DhakaStockExchange(); // For Dhaka Stock Exchange // $cse = new ChittagongStockExchange(); // For Chittagong Stock Exchange $stock = new StockPrice(); $stock->setStockExchange($dse); var_dump($stock->getPricing()); // Return PricingEntity[] var_dump($stock->toArray()); // Return as array
And you are done. You will get the following output. Array of PricingEntity
array(350) {
[0] =>
class ShahariaAzam\BDStockExchange\PricingEntity#20 (6) {
private $company =>
string(9) "1JANATAMF"
private $lastTradeValue =>
double(4.1)
private $changeInAmount =>
double(0)
private $changeInPercentage =>
double(0)
private $highPrice =>
NULL
private $lowPrice =>
NULL
}
Docker Image
You can also use Docker. To use Docker, you can find the image on Docker Hub or you can build Docker image from this repo.
To get the latest Bangladeshi Stock Market price via Docker, run the following command -
docker run -it --rm shaharia/bd-stock-price:latest php bin/stock dse --json
dse = Dhaka Stock Exchange
cse = Chittagong Stock Exchange
--json = Display in a JSON format
--line = Display as new line for each stock
If you want to build your own Docker image, run -
docker build . --tag IMAGE:TAG
Contribution
This is a helpful PHP library for programmers who want to get the latest Bangladesh stock exchange market data in their PHP application.
I always welcome any people who want to contribute to this library if it helps. You can contribute by doing -
-
Creating Issue from https://github.com/shahariaazam/DSE-Share-Market-Update/issues/new
-
Fixing existing issues from https://github.com/shahariaazam/DSE-Share-Market-Update/issues
-
Extending library by forking and send a pull request to merge. To fork this repository, go to https://github.com/shahariaazam/DSE-Share-Market-Update/fork.
After writing codes to fix issues or extending this library, please send me a pull request and I will be happy to see and merge if everything is OK.
To see all the contributors, please click here
License
MIT
Connect with me
Social: LinkedIn | Twitter | Facebook
Website: blog.shaharia.com | shaharia.com