-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstock_options_entry.php
43 lines (29 loc) · 1.13 KB
/
stock_options_entry.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
//including common files
require_once './include/common.php';
// setting up end headers
$headers = [
'Content-Type' => 'application/json',
'X-Kite-Version' => '3',
'Authorization' => 'token '.KEY.':'.TOKEN
];
$client = new GuzzleHttp\Client([
'headers' => $headers
]);
$end_point = "https://api.kite.trade/instruments/NFO";
$res = $client->request('GET', $end_point);
$response = $res->getBody()->getContents();
$option_list = explode(PHP_EOL, $response);
foreach ($option_list as $list) {
if(str_contains($list,"NFO-OPT")) {
$list = str_replace('"','',$list);
$entry = explode(",", $list);
//stock option entry
$query = "INSERT INTO stockOption(instrument_token, exchange_token, tradingsymbol, name, last_price, expiry, strike, tick_size, lot_size, instrument_type, segment, exchan)
VALUES ('$entry[0]','$entry[1]','$entry[2]','$entry[3]','$entry[4]','$entry[5]','$entry[6]','$entry[7]','$entry[8]','$entry[9]','$entry[10]','$entry[11]')";
$result = mysqli_query($GLOBALS['mysqlConnect'],$query);
echo $entry[2]." Completed";
echo "\n";
}
}
?>