adnanhussainturki / dhan-php
PHP Wrapper for Dhan Trading API
0.1
2024-02-29 13:11 UTC
Requires
- guzzlehttp/guzzle: ^7.8
Requires (Dev)
- vlucas/phpdotenv: ^5.6
README
PHP Wrapper for Dhan Trading API
Installation
Install the package via Composer:
composer require adnanhussainturki/dhan-php
Requirements
- PHP >= 7.4
- Guzzle HTTP client
Usage
Initialize the Dhan client:
// Initialize Dhan client
$dhan = new Dhan($clientId, $accessToken);
Example usage:
// Place an order
$newOrder = new NewOrder();
$newOrder->setTransactionType(TransactionType::BUY);
$newOrder->setSecurityId("505685"); // TAPARIA
$newOrder->setQuantity(1);
$newOrder->setPrice(3.21);
$newOrder->setOrderType(OrderType::LIMIT);
$newOrder->setExchangeSegment(ExchangeSegment::BSE_EQ);
$newOrder->setProductType(ProductType::CNC);
$newOrder->setValidity(OrderValidity::DAY);
try {
$orderManager->placeOrder($newOrder);
} catch (\Throwable $th) {
echo "ERROR: " . $th->getMessage() . "\n";
}
License
MIT License
Author
Adnan Hussain Turki adnanhussainturki@gmail.com