-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
File to Host on Your Virtual Machine
Implementation Article: https://tradewithpython.com/steps-to-deploy-your-trading-robot-to-the-cloud
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
|