Skip to content

Commit

Permalink
fix: OI param for historical data API
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakesh Ranjan committed Feb 11, 2021
1 parent fda9d7e commit f71cba8
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions kiteconnect.php
Original file line number Diff line number Diff line change
Expand Up @@ -670,12 +670,14 @@ public function getLTP($instruments) {
* $params bool "continuous" is a bool flag to get continuous data for futures and options instruments. Defaults to false.
* @return array
*/
public function getHistoricalData($instrument_token, $interval, $from, $to, $continuous = false) {
public function getHistoricalData($instrument_token, $interval, $from, $to, $continuous = false, $oi = false) {
$params = [
"instrument_token" => $instrument_token,
"interval" => $interval,
"from" => $from,
"to" => $to
"to" => $to,
"continuous" => $continuous,
"oi" => $oi
];

if ($from instanceof DateTime) {
Expand All @@ -686,12 +688,18 @@ public function getHistoricalData($instrument_token, $interval, $from, $to, $con
$params["to"] = $to->format("Y-m-d H:i:s");
}

if (empty($params["continuous"]) || $continuous == false) {
if ($params["continuous"] == false) {
$params["continuous"] = 0;
} else {
$params["continuous"] = 1;
}

if ($params["oi"] == false) {
$params["oi"] = 0;
} else {
$params["oi"] = 1;
}

$data = $this->_get("market.historical", $params);

$records = [];
Expand All @@ -703,6 +711,9 @@ public function getHistoricalData($instrument_token, $interval, $from, $to, $con
$r->low = $j[3];
$r->close = $j[4];
$r->volume = $j[5];
if (!empty($j[6])) {
$r->oi = $j[6];
}

$records[] = $r;
}
Expand Down Expand Up @@ -844,7 +855,7 @@ public function getGTTs() {
}

/**
* Get history of the individual order.
* Get detail of individual GTT order.
* @param string $trigger_id "trigger_id" Trigger ID
* @return array
*/
Expand All @@ -853,7 +864,7 @@ public function getGTT($trigger_id) {
}

/**
* Cancel an open order.
* Delete an GTT order
* @param string $trigger_id "trigger_id" Trigger ID
* @return void
*/
Expand Down

0 comments on commit f71cba8

Please sign in to comment.