pushpak1300/phpkiteconnect

此包已被弃用,不再维护。作者建议使用 zerodha/phpkiteconnect 包代替。

Kite Connect 交易 API 的 PHP 客户端库资源

dev-unofficial 2021-04-07 07:28 UTC

This package is auto-updated.

Last update: 2021-04-17 15:29:13 UTC


README

Kite Connect API PHP 客户端 - v3

Kite Connect API 通信的非官方 PHP 客户端。

Kite Connect 是一组类似于 REST 的 API,提供构建完整投资和交易平台所需的各种功能。使用简单的 HTTP API 集合实时执行订单、管理用户投资组合等。

Zerodha Technology (c) 2018. MIT 许可证授权。

文档

安装

您可以通过 composer 安装此包

composer require zerodha/phpkiteconnect

使用方法

<?php
    use KiteConnect\KiteConnect;

    // Initialise.
    $kite = new KiteConnect("your_api_key");

    // Assuming you have obtained the `request_token`
    // after the auth flow redirect by redirecting the
    // user to $kite->login_url()
    try {
        $user = $kite->generateSession("request_token_obtained", "your_api_secret");
        echo "Authentication successful. \n";
        print_r($user);
        $kite->setAccessToken($user->access_token);
    } catch(Exception $e) {
        echo "Authentication failed: ".$e->getMessage();
        throw $e;
    }

    echo $user->user_id." has logged in";

    // Get the list of positions.
    echo "Positions: \n";
    print_r($kite->getPositions());

    // Place order.
    $order = $kite->placeOrder("regular", [
        "tradingsymbol" => "INFY",
        "exchange" => "NSE",
        "quantity" => 1,
        "transaction_type" => "BUY",
        "order_type" => "MARKET",
        "product" => "NRML"
    ]);

    echo "Order id is ".$order->order_id;
?>

有关支持方法的完整列表,请参阅 PHP 客户端文档

变更日志

检查 CHANGELOG.md

稳定性

此包仅为将 composer 支持添加到之前的 SDE 工具包。官方包的拉取请求已经进行中。一旦官方存储库上的拉取请求被合并,此包将不再维护。请参阅 拉取请求