Skip to content

Commit c598f80

Browse files
committed
changes
1 parent db1f492 commit c598f80

40 files changed

+392
-358
lines changed

add_stocks_process.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
$companyinfo = $_POST['company_info'];
1414

1515
$field = array("sName"=>$sname,"cSymbol"=>$companyinfo,"murl"=>$murl,"curl"=>$curl,"notes"=>$notes,"sType"=>$type);
16-
insert($field , "stocklist"); //Adding in record
16+
insert($field , "stocklistbackup"); //Adding in record
1717

1818
header("location:add_stocks.php?msg=$sname added successfully");
1919
exit;

add_support_value.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
$resistance = $_POST['resistance_value'];
88

99
$field = array('support_value' => $support,'resistance_value' => $resistance);
10-
$table = "stocklist";
10+
$table = "stocklistbackup";
1111
$condition = "id = $id";
1212
$arugment = array( "field" => $field , "table" => $table, "condition" => $condition);
1313
update($arugment);

change_priority.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$id = $_POST['id'];
77

88
$field = array('priority' => $no);
9-
$table = "stocklist";
9+
$table = "stocklistbackup";
1010
$condition = "id = $id";
1111
$arugment = array( "field" => $field , "table" => $table, "condition" => $condition);
1212
update($arugment);

checklist_stock.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//Watchlist stocks in share calculator
1010
$type = "nifty";
1111
$field = array("id,sName,murl,curl,tickertape,id,support_value,qbuy,qvolume,qtotal,cSymbol,current_volume,stock_signal,order_type,stop_loss,target");
12-
$table = "stocklist";
12+
$table = "stocklistbackup";
1313
$order = "sName";
1414
$condition = "isWatch = 'yes' and priority = 3";
1515
$arugment = array( "field" => $field , "table" => $table, "condition" => $condition,"order" => $order);

clean_resistance_trend.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require_once './include/common.php';
33

44
//Fetching stock Symbol
5-
$query = "UPDATE `stocklist` SET `resistance_signal`='0'";
5+
$query = "UPDATE `stocklistbackup` SET `resistance_signal`='0'";
66
$result = mysqli_query($GLOBALS['mysqlConnect'],$query);
77

88

clean_support_trend.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require_once './include/common.php';
33

44
//Fetching stock Symbol
5-
$query = "UPDATE `stocklist` SET `support_signal`='0'";
5+
$query = "UPDATE `stocklistbackup` SET `support_signal`='0'";
66
$result = mysqli_query($GLOBALS['mysqlConnect'],$query);
77

88

data/analytics (2).sql

+68-68
Large diffs are not rendered by default.

data/analytics.sql

+54-54
Large diffs are not rendered by default.

edit_process.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
$field = array('curl' => $curl,'murl' => $murl, 'grow' => $notes );
17-
$table = "stocklist";
17+
$table = "stocklistbackup";
1818
$condition = "id = $id";
1919
$arugment = array( "field" => $field , "table" => $table, "condition" => $condition);
2020
update($arugment);

edit_stock.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//Checking stock already exists in table
77
$id = $_GET['id'];
88
$field = array("sName,murl,curl,cSymbol,grow");
9-
$table = "stocklist";
9+
$table = "stocklistbackup";
1010
$condition = "id='$id'";
1111
$arugment = array( "field" => $field , "table" => $table, "condition" => $condition);
1212
$data = select($arugment,"one");

fetch_price.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717

1818

1919
#reseting the order_status
20-
$query = "UPDATE stocklist SET `order_status`='0' ";
20+
$query = "UPDATE stocklistbackup SET `order_status`='0' ";
2121
$result = mysqli_query($GLOBALS['mysqlConnect'],$query);
2222

23-
$delete_query = "DELETE FROM stockvalues WHERE `createdDate` = '$date'";
23+
$delete_query = "DELETE FROM stockvaluesbackup WHERE `createdDate` = '$date'";
2424
$delete_result = mysqli_query($GLOBALS['mysqlConnect'],$delete_query);
2525

2626

2727

2828
//Getting all stocks
2929

30-
$query = "Select cSymbol from stocklist";
30+
$query = "Select cSymbol from stocklistbackup";
3131
$result = mysqli_query($GLOBALS['mysqlConnect'],$query);
3232
$row = mysqli_fetch_all($result);
3333
$i = 1;
@@ -93,16 +93,16 @@
9393

9494

9595

96-
$query = "Select id from stocklist where cSymbol = '$api_symbol' ";
96+
$query = "Select id from stocklistbackup where cSymbol = '$api_symbol' ";
9797
$result = mysqli_query($GLOBALS['mysqlConnect'], $query);
9898
$id = $result->fetch_all(MYSQLI_ASSOC);
9999
$sid = $id[0]['id'];
100100

101-
$query = "INSERT INTO stockvalues(sid, open, high, allHigh, low, allLow, close, schange, schangePercent, volume, stockValues, addClear, createdDate)
101+
$query = "INSERT INTO stockvaluesbackup(sid, open, high, allHigh, low, allLow, close, schange, schangePercent, volume, stockvaluesbackup, addClear, createdDate)
102102
VALUES ('$sid','$open','$high','$allhigh','$low','$alllow','$close','$chng','$chng_percentage','$volume','$value',1,'$date')";
103103
$result = mysqli_query($GLOBALS['mysqlConnect'], $query);
104104

105-
$query = "UPDATE stocklist SET dailyEntry='yes',current_volume='$volume',qbuy='$chng' WHERE id = '$sid'";
105+
$query = "UPDATE stocklistbackup SET dailyEntry='yes',current_volume='$volume',qbuy='$chng' WHERE id = '$sid'";
106106
$result = mysqli_query($GLOBALS['mysqlConnect'], $query);
107107

108108

fetch_price_backup.php

+63-59
Original file line numberDiff line numberDiff line change
@@ -17,107 +17,111 @@
1717

1818

1919
#reseting the order_status
20-
$query = "UPDATE stocklistbackup SET `order_status`='0' ";
20+
$query = "UPDATE stocklistbackupbackup SET `order_status`='0' ";
2121
$result = mysqli_query($GLOBALS['mysqlConnect'],$query);
2222

23-
$delete_query = "DELETE FROM stockvaluesbackup WHERE `createdDate` = '$date'";
23+
$delete_query = "DELETE FROM stockvaluesbackupbackup WHERE `createdDate` = '$date'";
2424
$delete_result = mysqli_query($GLOBALS['mysqlConnect'],$delete_query);
2525

2626

27+
$ranges = array("0,501", "500,1001", "1000,1501","1500,2001","2000,2500");
2728

28-
//Getting all stocks
29+
//$ranges = array("0,5", "6,10", "11,17","18,29","45,57");
2930

30-
$query = "Select cSymbol from stocklistbackup";
31-
$result = mysqli_query($GLOBALS['mysqlConnect'],$query);
32-
$row = mysqli_fetch_all($result);
33-
$i = 1;
34-
35-
//Concating all stocks at onces
36-
foreach ($row as $record) {
3731

38-
$api_symbol = $record[0];
32+
//Getting all stocks
3933

40-
if (str_contains($api_symbol, "&")) {
41-
$api_symbol = str_replace("&", "%26", $api_symbol);
42-
}
34+
foreach ($ranges as $range) {
4335

36+
$all_stocks = [];
4437

45-
$all_stocks[] = "i=NSE:" . $api_symbol;
38+
$two_range = explode(",", $range);
4639

47-
}
40+
$query = "Select cSymbol from stocklistbackupbackup where id > $two_range[0] and id < $two_range[1]";
41+
$result = mysqli_query($GLOBALS['mysqlConnect'], $query);
42+
$row = mysqli_fetch_all($result);
4843

44+
//Concating all stocks at onces
45+
foreach ($row as $record) {
4946

50-
//Got all data from kite instruments
51-
$all_stocks = implode("&",$all_stocks);
52-
$end_point = "https://api.kite.trade/quote?$all_stocks";
53-
$res = $client->request('GET', $end_point);
54-
$response = $res->getBody()->getContents();
55-
$response = (json_decode($response, true));
47+
$api_symbol = $record[0];
5648

49+
if (str_contains($api_symbol, "&")) {
50+
$api_symbol = str_replace("&", "%26", $api_symbol);
51+
}
5752

58-
//Updating in Database
59-
foreach ($row as $record) {
6053

61-
$api_symbol = $record[0];
54+
$all_stocks[] = "i=NSE:" . $api_symbol;
6255

63-
if(str_contains($api_symbol,"%26")) {
64-
$api_symbol = str_replace("%26", "&", $api_symbol);
65-
}
56+
}
6657

67-
$fetch = $response['data']["NSE:$api_symbol"]["ohlc"];
58+
//Got all data from kite instruments
59+
$all_stock = implode("&", $all_stocks);
60+
$end_point = "https://api.kite.trade/quote?$all_stock";
61+
$res = $client->request('GET', $end_point);
62+
$response = $res->getBody()->getContents();
63+
$response = (json_decode($response, true));
6864

69-
$open = $fetch['open'];
70-
$open = str_replace(",", "", $open);
65+
//Updating in Database
66+
foreach ($row as $record) {
7167

72-
$low = $fetch['low'];
73-
$low = str_replace(",", "", $low);
68+
$api_symbol = $record[0];
7469

75-
$high = $fetch['high'];
76-
$high = str_replace(",", "", $high);
70+
if (str_contains($api_symbol, "%26")) {
71+
$api_symbol = str_replace("%26", "&", $api_symbol);
72+
}
7773

78-
$close = $response['data']["NSE:$api_symbol"]['last_price'];
79-
$close = str_replace(",", "", $close);
74+
$fetch = $response['data']["NSE:$api_symbol"]["ohlc"];
8075

81-
$prev_close = $fetch['close'];
82-
$prev_close = str_replace(",", "", $prev_close);
76+
$open = $fetch['open'];
77+
$open = str_replace(",", "", $open);
8378

79+
$low = $fetch['low'];
80+
$low = str_replace(",", "", $low);
8481

85-
$volume = $response['data']["NSE:$api_symbol"]['volume'];
86-
$alllow = 0;
87-
$allhigh = 0;
88-
$value = 0;
89-
$chng_percentage = 0;
82+
$high = $fetch['high'];
83+
$high = str_replace(",", "", $high);
9084

91-
$chng = $close - $prev_close;
92-
$chng = number_format($chng, 1);
85+
$close = $response['data']["NSE:$api_symbol"]['last_price'];
86+
$close = str_replace(",", "", $close);
9387

88+
$prev_close = $fetch['close'];
89+
$prev_close = str_replace(",", "", $prev_close);
9490

9591

96-
$query = "Select id from stocklistbackup where cSymbol = '$api_symbol' ";
97-
$result = mysqli_query($GLOBALS['mysqlConnect'], $query);
98-
$id = $result->fetch_all(MYSQLI_ASSOC);
99-
$sid = $id[0]['id'];
92+
$volume = $response['data']["NSE:$api_symbol"]['volume'];
93+
$alllow = 0;
94+
$allhigh = 0;
95+
$value = 0;
96+
$chng_percentage = 0;
10097

101-
$query = "INSERT INTO stockvaluesbackup(sid, open, high, allHigh, low, allLow, close, schange, schangePercent, volume, stockValues, addClear, createdDate)
102-
VALUES ('$sid','$open','$high','$allhigh','$low','$alllow','$close','$chng','$chng_percentage','$volume','$value',1,'$date')";
103-
$result = mysqli_query($GLOBALS['mysqlConnect'], $query);
98+
$chng = $close - $prev_close;
99+
$chng = number_format($chng, 1);
104100

105-
$query = "UPDATE stocklistbackup SET dailyEntry='yes',current_volume='$volume',qbuy='$chng' WHERE id = '$sid'";
106-
$result = mysqli_query($GLOBALS['mysqlConnect'], $query);
107101

102+
$query = "Select id from stocklistbackupbackup where cSymbol = '$api_symbol' ";
103+
$result = mysqli_query($GLOBALS['mysqlConnect'], $query);
104+
$id = $result->fetch_all(MYSQLI_ASSOC);
105+
$sid = $id[0]['id'];
108106

107+
$query = "INSERT INTO stockvaluesbackupbackup(sid, open, high, allHigh, low, allLow, close, schange, schangePercent, volume, stockvaluesbackup, addClear, createdDate)
108+
VALUES ('$sid','$open','$high','$allhigh','$low','$alllow','$close','$chng','$chng_percentage','$volume','$value',1,'$date')";
109+
$result = mysqli_query($GLOBALS['mysqlConnect'], $query);
109110

110-
echo "$api_symbol Completed - $chng";
111-
echo "\n";
111+
$query = "UPDATE stocklistbackupbackup SET dailyEntry='yes',current_volume='$volume',qbuy='$chng' WHERE id = '$sid'";
112+
$result = mysqli_query($GLOBALS['mysqlConnect'], $query);
112113

113-
$i++;
114114

115+
echo "$api_symbol Completed - $chng";
116+
echo "\n";
115117

116-
}
117118

118119

120+
}
119121

120122

123+
sleep(2);
124+
}
121125

122126

123127

fetch_stock_future_price.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
$date = date('d-m-Y');
1818

19-
$delete_query = "DELETE FROM stockvaluesfutures WHERE `createdDate` = '$date'";
19+
$delete_query = "DELETE FROM stockvaluesbackupfutures WHERE `createdDate` = '$date'";
2020
$delete_result = mysqli_query($GLOBALS['mysqlConnect'],$delete_query);
2121

22-
$query = "Select id,cSymbol from stocklistfutures";
22+
$query = "Select id,cSymbol from stocklistbackupfutures";
2323
$result = mysqli_query($GLOBALS['mysqlConnect'],$query);
2424
$data = mysqli_fetch_all($result, MYSQLI_ASSOC);
2525

@@ -67,11 +67,11 @@
6767
$chng = number_format($chng,1);
6868

6969

70-
$query = "INSERT INTO stockvaluesfutures(sid, open, high, allHigh, low, allLow, close, schange, schangePercent, volume, stockValues, addClear, createdDate)
70+
$query = "INSERT INTO stockvaluesbackupfutures(sid, open, high, allHigh, low, allLow, close, schange, schangePercent, volume, stockvaluesbackup, addClear, createdDate)
7171
VALUES ('$sid','$open','$high','$allhigh','$low','$alllow','$close','$chng','$chng_percentage','$volume','$value',2,'$date')";
7272
$result = mysqli_query($GLOBALS['mysqlConnect'],$query);
7373

74-
$query = "UPDATE stocklistfutures SET current_volume='$volume' WHERE id = '$sid'";
74+
$query = "UPDATE stocklistbackupfutures SET current_volume='$volume' WHERE id = '$sid'";
7575
$result = mysqli_query($GLOBALS['mysqlConnect'],$query);
7676

7777

fetch_stock_price.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
$date = date('d-m-Y');
1717

1818
#reseting the order_status
19-
$query = "UPDATE stocklist SET `order_status`='0' ";
19+
$query = "UPDATE stocklistbackup SET `order_status`='0' ";
2020
$result = mysqli_query($GLOBALS['mysqlConnect'],$query);
2121

22-
$delete_query = "DELETE FROM stockvalues WHERE `createdDate` = '$date'";
22+
$delete_query = "DELETE FROM stockvaluesbackup WHERE `createdDate` = '$date'";
2323
$delete_result = mysqli_query($GLOBALS['mysqlConnect'],$delete_query);
2424

25-
$query = "Select cSymbol from stocklist";
25+
$query = "Select cSymbol from stocklistbackup";
2626
$result = mysqli_query($GLOBALS['mysqlConnect'],$query);
2727
$row = mysqli_fetch_all($result);
2828
$i = 1;
@@ -75,16 +75,16 @@
7575
$chng = number_format($chng, 1);
7676

7777

78-
$query = "Select id from stocklist where cSymbol = '$api_symbol' ";
78+
$query = "Select id from stocklistbackup where cSymbol = '$api_symbol' ";
7979
$result = mysqli_query($GLOBALS['mysqlConnect'], $query);
8080
$id = $result->fetch_all(MYSQLI_ASSOC);
8181
$sid = $id[0]['id'];
8282

83-
$query = "INSERT INTO stockvalues(sid, open, high, allHigh, low, allLow, close, schange, schangePercent, volume, stockValues, addClear, createdDate)
83+
$query = "INSERT INTO stockvaluesbackup(sid, open, high, allHigh, low, allLow, close, schange, schangePercent, volume, stockvaluesbackup, addClear, createdDate)
8484
VALUES ('$sid','$open','$high','$allhigh','$low','$alllow','$close','$chng','$chng_percentage','$volume','$value',1,'$date')";
8585
$result = mysqli_query($GLOBALS['mysqlConnect'], $query);
8686

87-
$query = "UPDATE stocklist SET dailyEntry='yes',current_volume='$volume',qbuy='$chng' WHERE id = '$sid'";
87+
$query = "UPDATE stocklistbackup SET dailyEntry='yes',current_volume='$volume',qbuy='$chng' WHERE id = '$sid'";
8888
$result = mysqli_query($GLOBALS['mysqlConnect'], $query);
8989

9090

generate_json.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require_once './include/common.php';
44

5-
$query = "SELECT `cSymbol`,`qbuy`,`qvolume`,`stock_signal`,`target`,`stop_loss`,`order_type` FROM `stocklist` WHERE `isWatch` = 'Yes' and `priority` = '1' ";
5+
$query = "SELECT `cSymbol`,`qbuy`,`qvolume`,`stock_signal`,`target`,`stop_loss`,`order_type` FROM `stocklistbackup` WHERE `isWatch` = 'Yes' and `priority` = '1' ";
66
$result = mysqli_query($GLOBALS['mysqlConnect'],$query);
77
$id = $result->fetch_all(MYSQLI_ASSOC);
88

0 commit comments

Comments
 (0)