Update levels.py
Browse files
levels.py
CHANGED
@@ -27,19 +27,23 @@ def info(ticker):
|
|
27 |
Industry = data.Industry.values[0]
|
28 |
return logo, Industry
|
29 |
|
|
|
30 |
def calculate_percentage_loss(buying_price, ltp):
|
31 |
percentage_loss = ((ltp - buying_price) / buying_price) * 100
|
32 |
return f"{percentage_loss:.2f}%"
|
33 |
|
34 |
def latestprice(ticker):
|
35 |
ticker = ticker.split(".")[0]
|
36 |
-
url = f
|
37 |
-
|
|
|
|
|
|
|
38 |
if response.status_code == 200:
|
39 |
data = response.json()
|
40 |
-
return data['ltp']
|
41 |
else:
|
42 |
-
return
|
43 |
|
44 |
def process_dataframe(df):
|
45 |
|
|
|
27 |
Industry = data.Industry.values[0]
|
28 |
return logo, Industry
|
29 |
|
30 |
+
|
31 |
def calculate_percentage_loss(buying_price, ltp):
|
32 |
percentage_loss = ((ltp - buying_price) / buying_price) * 100
|
33 |
return f"{percentage_loss:.2f}%"
|
34 |
|
35 |
def latestprice(ticker):
|
36 |
ticker = ticker.split(".")[0]
|
37 |
+
url = f'https://groww.in/v1/api/stocks_data/v1/accord_points/exchange/NSE/segment/CASH/latest_prices_ohlc/{ticker}'
|
38 |
+
headers = {
|
39 |
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0'
|
40 |
+
}
|
41 |
+
response = requests.get(url, headers=headers)
|
42 |
if response.status_code == 200:
|
43 |
data = response.json()
|
44 |
+
return float(data['ltp'])
|
45 |
else:
|
46 |
+
return 0.0
|
47 |
|
48 |
def process_dataframe(df):
|
49 |
|