-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCode.py
More file actions
74 lines (66 loc) · 4.42 KB
/
Copy pathCode.py
File metadata and controls
74 lines (66 loc) · 4.42 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from yahoo_fin.stock_info import * #pip install yahoo_fin
import requests_html #pip install requests_html
from time import time , sleep #in-built module
from datetime import datetime #in-built module
from datetime import date #in-built module
from plyer import notification #pip install plyer
if __name__ == "__main__":
dt = date.today() #taking current date
tme = datetime.now().time() #taking current time
print(f"Today's date is: {dt} ") #printing current date
print(f"Today's time is: {tme} s") #printing current time
x = round(get_live_price('dji'),2) #getting real-time price of a Dow-Jones-Industrial-Average
y = round(get_live_price('ndaq'),2) #getting real-time price of a Nasdaq
# def todayAt (hr, min=0, sec=0, micros=0): #converting time format into only hours.
# return tme.replace(hour=hr, minute=min, second=sec, microsecond=micros)
print(f"Dow Jones Industrial Average: $ {x}")
print(f"Nasdaq: $ {y}")
print("**********Welcome to the Markets***********")
hours = datetime.now().hour
# print(hours)
if hours>= 19 or hours<= 1:
while True: #applying condition on opening and closing time of USA markets
a1 = input('Enter company name you want to trade \n') #getting company's name from user
a = round(get_live_price(a1),2) #getting real-time price of the company
print(f"Current Stock price of {a1} is: $ {a}") #printing current price
b = int(input("Enter maximum price to be notified: $ ")) #taking maximum price on which user want to sell shares.... to get notified
c = int(input("Enter stop loss price to be notified: $ ")) #taking stop loss price on which user want to sell shares.... to get notified
while True:
q = get_live_price(a1)
print(q) #getting current price of entered company.
if q > b:
notification.notify ( #creating desktop notification bar for user to get notified if share price rise...
title = 'Stock Price has raised',
message = f"Price of {a1} is: $ {q}",
timeout = 1*60
)
get_live_price(a1)
break
elif q < c:
notification.notify ( #creating desktop notification bar for user to get notified if share price fall...
title = 'Stock Price has fallen',
message = f"Price of {a1} is: ${q}",
timeout = 1*60
)
get_live_price(a1)
break
else:
sleep(20)
continue
##### printing top gainers and top losers of current or previous day when markets are closed ######
elif hours> 1 or hours=< 19: #condition of time - when markets are close
w = get_day_gainers() #getting day gainers
print(f"Day gainers are: {w}")
y = get_day_losers() #getting day losers
print(f"Day losers are: {y}")
print("*****Markets are currently closed*****")
print("Thank you for choosing us!!!")
###Other features when markets are closed#####
#get_earnings("Company's name")
#get_balance_sheet("Company's name")
#get_analysts_info("Company's name")
#get_income_statement("Company's name")
#get_data("Company's name")
else:
print("Hope you have a great trading......") #printing sweet messages
print("Thank you for choosing us!!!")