Skip to content

Commit

Permalink
Merge branch 'kite3'
Browse files Browse the repository at this point in the history
  • Loading branch information
vividvilla committed May 20, 2018
2 parents cea0774 + e2b8ee8 commit 6e6826d
Show file tree
Hide file tree
Showing 4 changed files with 715 additions and 210 deletions.
58 changes: 58 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
New features
=============
- method: `getProfile`
- method: `getOHLC`
- method: `getLTP`
- method: `getMFOrders`
- method: `getMFHoldings`
- method: `placeMFOrder`
- method: `cancelMFOrder`
- method: `getMFSIPS`
- method: `placeMFSIP`
- method: `modifyMFSIP`
- method: `cancelMFSIP`
- method: `getMFInstruments`
- method: `exitOrder`
- method: `renewAccessToken`
- method: `invalidateRefreshToken`

API method name changes
=======================

| v2 | v3 |
| ------------------------- | ------------------------- |
| requestAccessToken | generateSession |
| invalidateToken | invalidateAccessToken |
| setSessionHook | setSessionExpiryHook |
| loginUrl | getLoginURL |
| margins | getMargins |
| orderPlace | placeOrder |
| orderModify | modifyOrder |
| orderCancel | cancelOrder |
| orders | getOrders |
| orders(order_id) | getOrderHistory |
| trades | getTrades |
| trades(order_id) | getOrderTrades |
| holdings | getHoldings |
| positions | getPositions |
| productModify | convertPosition |
| instruments | getInstruments |
| historical | getHistoricalData |
| triggerRange | getTriggerRange |

Params and other changes
========================
- `convertPosition` method takes all the params as array
- `getHistoricalData` method takes all the params as array
- [Changes in `generateSession` response structure](https://kite.trade/docs/connect/v3/user/#response-attributes)
- [Changes in `getPositions` response structure](https://kite.trade/docs/connect/v3/portfolio/#response-attributes_1)
- [Changes in `getQuote` response structure](https://kite.trade/docs/connect/v3/market-quotes/#retrieving-full-market-quotes)
- [Changes in `placeOrder` params](https://kite.trade/docs/connect/v3/orders/#bracket-order-bo-parameters)
- Changes in `getHistoricalData` params
- All datetime string fields has been converted to `Date` object.
- `getOrders`, `getOrderHistory`, `getTrades`, `getOrderTrades`, `getMFOrders` responses fields `order_timestamp`, `exchange_timestamp`, `fill_timestamp`
- `getMFSIPS` fields `created`, `last_instalment`
- `generateSession` field `login_time`
- `getQuote` fields `timestamp`, `last_trade_time`
- `getInstruments` field `expiry`
- `getMFInstruments` field `last_price_date`
25 changes: 11 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
> **NOTICE (Jan 2018): Upgrade to Kite Connect 3.0**
> This repository is being phased and will be replaced soon by Kite Connect v3. Use the [kite3](https://github.com/zerodhatech/phpkiteconnect/tree/kite3) branch instead. Read the [announcement](https://kite.trade/forum/discussion/2998/upgrade-to-kite-connect-3-0) on the forum.
# The Kite Connect API PHP client
# The Kite Connect API PHP client - v3
The official PHP client for communicating with the [Kite Connect API](https://kite.trade).

Kite Connect is a set of REST-like APIs that expose many capabilities required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio and more, with the simple HTTP API collection.

[Rainmatter](http://rainmatter.com) (c) 2016. Licensed under the MIT License.
[Zerodha Technology](http://zerodha.com) (c) 2018. Licensed under the MIT License.

## Documentation
- [PHP client documentation](https://kite.trade/docs/phpkiteconnect/)
- [Kite Connect HTTP API documentation](https://kite.trade/docs/connect/v1)
- [PHP client documentation](https://kite.trade/docs/phpkiteconnect/v3)
- [Kite Connect HTTP API documentation](https://kite.trade/docs/connect/v3)

## Installing
Download `kiteconnect.php` and `include()` it in your application.
Expand All @@ -27,7 +24,7 @@ Download `kiteconnect.php` and `include()` it in your application.
// after the auth flow redirect by redirecting the
// user to $kite->login_url()
try {
$user = $kite->requestAccessToken("request_token_obtained", "your_api_secret");
$user = $kite->generateSession("request_token_obtained", "your_api_secret");

echo "Authentication successful. \n";
print_r($user);
Expand All @@ -42,24 +39,24 @@ Download `kiteconnect.php` and `include()` it in your application.

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

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

echo "Order id is ".$order_id;
?>
```

Refer to the [PHP client documentation](https://kite.trade/docs/phpkiteconnect/) for the complete list of supported methods.

Refer to the [PHP client documentation](https://kite.trade/docs/phpkiteconnect/v3) for the complete list of supported methods.

## Changelog
- 2016-07-05 Added `$parent_order_id` to orderModify() and orderCancel() for multi-legged orders.
[Check CHANGELOG.md](CHANGELOG.md)

47 changes: 47 additions & 0 deletions examples/kiteconnect_sample.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
include dirname(__FILE__)."/kiteconnect.php";

// 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());

// Get the list of holdings.
echo "Holdings: \n";
print_r($kite->getHoldings());

// Retrieve quote and market depth for list of instruments.
echo "Quote: \n";
print_r($kite->getQuote(["NSE:INFY", "NSE:SBIN"]));

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

echo "Order id is ".$order_id;
?>
Loading

0 comments on commit 6e6826d

Please sign in to comment.