Skip to content

Commit 73c6fd2

Browse files
authored
Added News_App for indian Stock market
1 parent 0085020 commit 73c6fd2

File tree

4 files changed

+218
-0
lines changed

4 files changed

+218
-0
lines changed

News_App/Newsapp.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import os
2+
import solara as sr
3+
import yfinance as yf
4+
5+
6+
from patterns import Company_Name
7+
from datetime import datetime as date,timedelta
8+
9+
srart_date = date.today()
10+
end_date = date.today() + timedelta(days=1)
11+
12+
13+
def News(symbol):
14+
get_Data = yf.Ticker(symbol)
15+
# msft.news
16+
17+
#news section
18+
try:
19+
NEWS = get_Data.news
20+
# sr.Markdown(f"{NEWS}")
21+
sr.Markdown(f"# News of {v.value} :")
22+
for i in range(len(NEWS)):
23+
sr.Markdown("\n********************************\n")
24+
sr.Markdown(f"## {i+1}. {NEWS[i]['title']} \n ")
25+
sr.Markdown(f"**Publisher** : {NEWS[i]['publisher']}\n")
26+
sr.Markdown(f"**Link** : {NEWS[i]['link']}\n")
27+
sr.Markdown(f"**News type** : {NEWS[i]['type']}\n\n\n")
28+
try:
29+
30+
resolutions = NEWS[i]['thumbnail']['resolutions']
31+
img = resolutions[0]['url']
32+
sr.Image(img)
33+
34+
except:
35+
pass
36+
except Exception as e:
37+
sr.Markdown(e)
38+
sr.Markdown("No news available")
39+
# News(select)
40+
41+
42+
43+
company = list(Company_Name.keys())
44+
v=sr.reactive(company[0])
45+
46+
@sr.component
47+
def Page():
48+
with sr.Column() as main:
49+
with sr.Sidebar():
50+
sr.Markdown("## **stock Analysis**")
51+
# sr.SliderInt(label="Ideal for placing controls")
52+
# sr.header("**srock Analysis**")
53+
sr.Select("Select stock",value=v,values=company)
54+
55+
select=Company_Name.get(v.value)
56+
57+
58+
# sr.Text(select_company)
59+
# sr.Info("I'm in the main content area, put your main content here")
60+
61+
News(select)
62+
63+
# sr.FigurePlotly(qs.plots.daily_returns(ITC,benchmark="US"))
64+
return main
65+
66+
67+
68+
# @app.route("/")
69+
# def hello_world():
70+
# return "<p>Hello, World!</p>"
71+
72+
# if __name__=="__main__":
73+
# app.run(debug=False)

News_App/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## News App
2+
3+
- I have create News app using python solara framework and yfinace for getting news.
4+
5+
Steps to run the app:
6+
7+
1. Download the folder of News app or clone the whole repositery and go to the `python-beginner-projects/projects/News_App` and Install all the requirements
8+
9+
```
10+
pip install -r requirements.txt
11+
```
12+
13+
2. Run the solara app
14+
15+
```
16+
solara run Newsapp.py
17+
```

News_App/patterns.py

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
2+
3+
4+
patterns = {
5+
'CDLHARAMI':'Harami Pattern',
6+
'CDLHARAMICROSS':'Harami Cross Pattern',
7+
'CDL2CROWS':'Two Crows',
8+
'CDL3BLACKCROWS':'Three Black Crows',
9+
'CDL3INSIDE':'Three Inside Up/Down',
10+
'CDL3LINESTRIKE':'Three-Line Strike',
11+
'CDL3OUTSIDE':'Three Outside Up/Down',
12+
'CDL3STARSINSOUTH':'Three Stars In The South',
13+
'CDL3WHITESOLDIERS':'Three Advancing White Soldiers',
14+
'CDLABANDONEDBABY':'Abandoned Baby',
15+
'CDLADVANCEBLOCK':'Advance Block',
16+
'CDLBELTHOLD':'Belt-hold',
17+
'CDLBREAKAWAY':'Breakaway',
18+
'CDLCLOSINGMARUBOZU':'Closing Marubozu',
19+
'CDLCONCEALBABYSWALL':'Concealing Baby Swallow',
20+
'CDLCOUNTERATTACK':'Counterattack',
21+
'CDLDARKCLOUDCOVER':'Dark Cloud Cover',
22+
'CDLDOJI':'Doji',
23+
'CDLDOJISTAR':'Doji Star',
24+
'CDLDRAGONFLYDOJI':'Dragonfly Doji',
25+
'CDLENGULFING':'Engulfing Pattern',
26+
'CDLEVENINGDOJISTAR':'Evening Doji Star',
27+
'CDLEVENINGSTAR':'Evening Star',
28+
'CDLGAPSIDESIDEWHITE':'Up/Down-gap side-by-side white lines',
29+
'CDLGRAVESTONEDOJI':'Gravestone Doji',
30+
'CDLHAMMER':'Hammer',
31+
'CDLHANGINGMAN':'Hanging Man',
32+
'CDLHIGHWAVE':'High-Wave Candle',
33+
'CDLHIKKAKE':'Hikkake Pattern',
34+
'CDLHIKKAKEMOD':'Modified Hikkake Pattern',
35+
'CDLHOMINGPIGEON':'Homing Pigeon',
36+
'CDLIDENTICAL3CROWS':'Identical Three Crows',
37+
'CDLINNECK':'In-Neck Pattern',
38+
'CDLINVERTEDHAMMER':'Inverted Hammer',
39+
'CDLKICKING':'Kicking',
40+
'CDLKICKINGBYLENGTH':'Kicking - bull/bear determined by the longer marubozu',
41+
'CDLLADDERBOTTOM':'Ladder Bottom',
42+
'CDLLONGLEGGEDDOJI':'Long Legged Doji',
43+
'CDLLONGLINE':'Long Line Candle',
44+
'CDLMARUBOZU':'Marubozu',
45+
'CDLMATCHINGLOW':'Matching Low',
46+
'CDLMATHOLD':'Mat Hold',
47+
'CDLMORNINGDOJISTAR':'Morning Doji Star',
48+
'CDLMORNINGSTAR':'Morning Star',
49+
'CDLONNECK':'On-Neck Pattern',
50+
'CDLPIERCING':'Piercing Pattern',
51+
'CDLRICKSHAWMAN':'Rickshaw Man',
52+
'CDLRISEFALL3METHODS':'Rising/Falling Three Methods',
53+
'CDLSEPARATINGLINES':'Separating Lines',
54+
'CDLSHOOTINGSTAR':'Shooting Star',
55+
'CDLSHORTLINE':'Short Line Candle',
56+
'CDLSPINNINGTOP':'Spinning Top',
57+
'CDLSTALLEDPATTERN':'Stalled Pattern',
58+
'CDLSTICKSANDWICH':'Stick Sandwich',
59+
'CDLTAKURI':'Takuri (Dragonfly Doji with very long lower shadow)',
60+
'CDLTASUKIGAP':'Tasuki Gap',
61+
'CDLTHRUSTING':'Thrusting Pattern',
62+
'CDLTRISTAR':'Tristar Pattern',
63+
'CDLUNIQUE3RIVER':'Unique 3 River',
64+
'CDLUPSIDEGAP2CROWS':'Upside Gap Two Crows',
65+
'CDLXSIDEGAP3METHODS':'Upside/Downside Gap Three Methods'
66+
}
67+
68+
Company_Name ={
69+
"NIFTY 50" :"^NSEI",
70+
"NIFTY BANK" : "^NSEBANK",
71+
"INDIA VIX" : "^INDIAVIX",
72+
"ADANI ENTERPRISES ":"ADANIENT.NS",
73+
"ADANI PORTS AND SPECIAL ECONOMIC ZONE ":"ADANIPORTS.NS",
74+
"APOLLO HOSPITALS ENTERPRISE ":"APOLLOHOSP.NS",
75+
"ASIAN PAINTS ":"ASIANPAINT.NS",
76+
"Axis Bank ":"AXISBANK.NS",
77+
"MARUTI SUZUKI INDIA ":"MARUTI.NS",
78+
"BAJAJ FINANCE ":"BAJFINANCE.NS",
79+
"Bajaj Finserv ":"BAJAJFINSV.NS",
80+
"BHARAT PETROLEUM CORPORATION ":"BPCL.NS",
81+
"Bharti Airtel ":"BHARTIARTL.NS", # change
82+
"BRITANNIA INDUSTRIES LTD" :"BRITANNIA.NS",
83+
"CIPLA ":"CIPLA.NS",
84+
"COAL INDIA LTD " :"COALINDIA.NS",
85+
"DIVI'S LABORATORIES ":"DIVISLAB.NS",
86+
"DR.REDDY'S LABORATORIES LTD ":"DRREDDY.NS",
87+
"EICHER MOTORS ":"EICHERMOT.NS",
88+
"GRASIM INDUSTRIES LTD ":"GRASIM.NS",
89+
"HCL TECHNOLOGIES ":"HCLTECH.NS",
90+
"HDFC BANK ":"HDFCBANK.NS",
91+
"HDFC LIFE INSURANCE COMPANY ":"HDFCLIFE.NS",
92+
"Hero MotoCorp ":"HEROMOTOCO.NS",
93+
"HINDALCO INDUSTRIES ":"HINDALCO.NS",
94+
"HINDUSTAN UNILEVER ":"HINDUNILVR.NS",
95+
"HOUSING DEVELOPMENT FINANCE CORPORATION ":"HDFC.NS",
96+
"ICICI BANK ":"ICICIBANK.NS",
97+
"ITC ":"ITC.NS",
98+
"INDUSIND BANK LTD. ":"INDUSINDBK.NS",
99+
"INFOSYS ":"INFY.NS",
100+
"JSW Steel ":"JSWSTEEL.NS",
101+
"KOTAK MAHINDRA BANK ":"KOTAKBANK.NS",
102+
"LARSEN AND TOUBRO ":"LT.NS",
103+
"MAHINDRA AND MAHINDRA ":"M&M.NS",
104+
"MARUTI SUZUKI INDIA ":"MARUTI.NS",
105+
"NTPC ":"NTPC.NS",
106+
"NESTLE INDIA ":"NESTLEIND.NS",
107+
"OIL AND NATURAL GAS CORPORATION ":"ONGC.NS",
108+
"POWER GRID CORPORATION OF INDIA ":"POWERGRID.NS",
109+
"RELIANCE INDUSTRIES ":"RELIANCE.NS", #cahnged
110+
"SBI LIFE INSURANCE COMPANY ":"SBILIFE.NS",
111+
"SBI":"SBIN.NS",
112+
"SUN PHARMACEUTICAL INDUSTRIES ":"SUNPHARMA.NS",
113+
"TATA CONSULTANCY SERVICES ":"TCS.NS",
114+
"TATA CONSUMER PRODUCTS ":"TATACONSUM.NS",
115+
"TATA MOTORS ":"TATAMTRDVR.NS",
116+
"TATA STEEL ":"TATASTEEL.NS",
117+
"TECH MAHINDRA ":"TECHM.NS",
118+
"TITAN COMPANY ":"TITAN.NS",
119+
"UPL ":"UPL.NS",
120+
"ULTRATECH CEMENT ":"ULTRACEMCO.NS",
121+
"WIPRO ":"WIPRO.NS"
122+
}

News_App/requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
solara == 1.19.0
2+
Flask
3+
gunicorn ==21.2.0
4+
simple-websocket
5+
flask-sock
6+
yfinance

0 commit comments

Comments
 (0)