Skip to content

Commit

Permalink
File to Host on Your Virtual Machine
Browse files Browse the repository at this point in the history
  • Loading branch information
yash12392 authored Jul 24, 2021
1 parent 4c60c4b commit c947f7b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions codes_on_blog/cloud_robotv2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from jugaad_data.nse import NSELive
import telegram_send as ts
import time

def get_prices(stockSymbol):

n = NSELive()
q = n.stock_quote(stockSymbol)
return q['priceInfo']['lastPrice']

def send_telegram_message(message):
ts.send(messages = [str(message)])

live_prices = []
count = 0

while True:
current_price = get_prices('HDFC')
live_prices.append(current_price)
count = count + 1
print(f'{count} Minutes Done')

if len(live_prices) == 5:
avg_price = round((sum(live_prices[-5:])/len(live_prices[-5:])),2)
if count == 5:
send_telegram_message(f'The Average Price of HDFC For Last 5 Minutes is {avg_price}')
#print(f'The Average Price of HDFC For Last 5 Minutes is {avg_price}')
count = 0
live_prices.clear()

time.sleep(60)


0 comments on commit c947f7b

Please sign in to comment.