Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# from nsepython import *
|
2 |
+
# import seaborn as sns
|
3 |
+
# import pandas as pd
|
4 |
+
# import streamlit as st
|
5 |
+
# from datetime import datetime
|
6 |
+
# from time import gmtime, strftime
|
7 |
+
# from IPython.display import clear_output
|
8 |
+
# import matplotlib.pyplot as plt
|
9 |
+
# from pytz import timezone
|
10 |
+
|
11 |
+
import streamlit as st
|
12 |
+
import pandas as pd
|
13 |
+
st.title('A Simple Streamlit Web App')
|
14 |
+
name = st.text_input('Enter your name', '')
|
15 |
+
st.write(f"Hello {name}!")
|
16 |
+
x = st.slider('Select an integer x', 0, 10, 1)
|
17 |
+
y = st.slider('Select an integer y', 0, 10, 1)
|
18 |
+
df = pd.DataFrame({'x': [x], 'y': [y] , 'x + y': [x + y]}, index = ['addition row'])
|
19 |
+
st.write(df)
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
|
26 |
+
# def get_data():
|
27 |
+
# a=(nse_fno("BANKNIFTY"))
|
28 |
+
# last_prices=round(nse_quote_ltp("BANKNIFTY"))
|
29 |
+
# exp=list(set(a['expiryDates']))
|
30 |
+
# exp.sort(key = lambda date: datetime.strptime(date, '%d-%b-%Y'))
|
31 |
+
# if last_prices%100>50:
|
32 |
+
# x=(last_prices-last_prices%100+100)
|
33 |
+
# strike=[x-200,x-100,x,x+100,x+200]
|
34 |
+
# elif last_prices%100<50:
|
35 |
+
# x=(last_prices-last_prices%100)
|
36 |
+
# strike=[x-200,x-100,x,x+100,x+200]
|
37 |
+
# d={'call change op':[],
|
38 |
+
# 'call vwap':[],
|
39 |
+
# '% change op':[],
|
40 |
+
# 'strike':[],
|
41 |
+
# 'put change op':[],
|
42 |
+
# 'put vwap':[],
|
43 |
+
# '% change op put':[]
|
44 |
+
# }
|
45 |
+
# for i in a['stocks']:
|
46 |
+
# for sp in strike:
|
47 |
+
# if i['metadata']['expiryDate']==exp[0] and i['metadata']['optionType']=='Call' and i['metadata']['strikePrice']==sp:
|
48 |
+
# d['strike'].append(sp)
|
49 |
+
# d['call change op'].append(i['marketDeptOrderBook']['tradeInfo']['changeinOpenInterest'])
|
50 |
+
# d['% change op'].append(i['marketDeptOrderBook']['tradeInfo']['pchangeinOpenInterest'])
|
51 |
+
# d['call vwap'].append(i['marketDeptOrderBook']['tradeInfo']['vmap'])
|
52 |
+
|
53 |
+
# elif i['metadata']['expiryDate']==exp[0] and i['metadata']['optionType']=='Put' and i['metadata']['strikePrice']==sp:
|
54 |
+
# d['put change op'].append(i['marketDeptOrderBook']['tradeInfo']['changeinOpenInterest'])
|
55 |
+
# d['% change op put'].append(i['marketDeptOrderBook']['tradeInfo']['pchangeinOpenInterest'])
|
56 |
+
# d['put vwap'].append(i['marketDeptOrderBook']['tradeInfo']['vmap'])
|
57 |
+
|
58 |
+
# out=pd.json_normalize(d)
|
59 |
+
# out=out.explode(list(out.columns)).reset_index(drop = True)
|
60 |
+
# out.fillna(0,inplace=True)
|
61 |
+
# x=out.astype(float).round(2)
|
62 |
+
# return x
|
63 |
+
# def get_info(dataset):
|
64 |
+
# df= pd.DataFrame(columns=['value', 'pcr', 'cal_per','put_per'])
|
65 |
+
# value= dataset['put change op'].sum() - dataset['call change op'].sum()
|
66 |
+
# pcr= dataset['put change op'].sum()/dataset['call change op'].sum()
|
67 |
+
# cal_per= dataset['% change op'].mean()
|
68 |
+
# put_per= dataset['% change op put'].mean()
|
69 |
+
# new_row={'time':datetime.now(timezone("Asia/Kolkata")).strftime('%I.%M %p'),'value':value, 'pcr':round(pcr,2), 'cal_per':round(cal_per,2), 'put_per':round(put_per,2)}
|
70 |
+
# df = df.append(new_row,ignore_index=True, verify_integrity=False, sort=None)
|
71 |
+
# return df
|
72 |
+
# def ploting():
|
73 |
+
# try:
|
74 |
+
# global final
|
75 |
+
# except:
|
76 |
+
# df = pd.DataFrame(columns=['value', 'pcr', 'cal_per','put_per'])
|
77 |
+
# dataset= get_data()
|
78 |
+
# main= get_info(dataset)
|
79 |
+
# final =final.append(main,ignore_index=True, verify_integrity=False, sort=None)
|
80 |
+
# return dataset,final
|
81 |
+
|
82 |
+
# final = pd.DataFrame(columns=['value', 'pcr', 'cal_per','put_per','time'])
|
83 |
+
|
84 |
+
|
85 |
+
# if __name__=='__main__':
|
86 |
+
|
87 |
+
# st.title('WELCOME BULLS CARTEL')
|
88 |
+
# today_date =strftime("%d %b %Y", gmtime()),datetime.now(timezone("Asia/Kolkata")).strftime('%I.%M %p')
|
89 |
+
# st.markdown(f"as at {today_date}")
|
90 |
+
# option= st.selectbox(
|
91 |
+
# 'How would you like to be contacted?',
|
92 |
+
# ('5', '10', '15'))
|
93 |
+
# st.write('You selected:', option)
|
94 |
+
# st.header('Important Information')
|
95 |
+
# st.markdown(""" CALL % INCREASE MEANS MARKET GOES DOWN
|
96 |
+
# PUT % INCREASE MEANS MARKET GOES UP
|
97 |
+
# """)
|
98 |
+
# while True:
|
99 |
+
# dataset,final=ploting()
|
100 |
+
# p1=st.empty()
|
101 |
+
# p2=st.empty()
|
102 |
+
# p3=st.empty()
|
103 |
+
# p1.dataframe(dataset.style.highlight_max(['% change op put','% change op'],axis=0)) #Column hightlight
|
104 |
+
# p2.dataframe(final.style.highlight_max(['cal_per','put_per'],axis=1)) # row highlight
|
105 |
+
# fig, ax = plt.subplots(figsize=(6, 2))
|
106 |
+
# ax.plot(final['time'],final['pcr'])
|
107 |
+
# ax.axhline(y=0, color='black', linestyle='solid') # 0 line graph
|
108 |
+
# fig.autofmt_xdate(rotation=70)
|
109 |
+
# p3.pyplot(fig)
|
110 |
+
# time.sleep(3*60) # how to the start again code check upper condition min * sec
|
111 |
+
# p1.empty() # then clean all data frame
|
112 |
+
# p2.empty()
|
113 |
+
# p3.empty()
|
114 |
+
|