Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,71 +1,55 @@
|
|
1 |
-
|
2 |
-
|
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 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
""")
|
22 |
-
x = st.slider('Select an integer x', 0, 10, 1)
|
23 |
-
y = st.slider('Select an integer y', 0, 10, 1)
|
24 |
-
df = pd.DataFrame({'x': [x], 'y': [y] , 'x + y': [x + y]}, index = ['addition row'])
|
25 |
-
st.write(df)
|
26 |
|
27 |
|
28 |
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
|
|
|
|
|
|
|
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
# if last_prices%100>50:
|
38 |
-
# x=(last_prices-last_prices%100+100)
|
39 |
-
# strike=[x-200,x-100,x,x+100,x+200]
|
40 |
-
# elif last_prices%100<50:
|
41 |
-
# x=(last_prices-last_prices%100)
|
42 |
-
# strike=[x-200,x-100,x,x+100,x+200]
|
43 |
-
# d={'call change op':[],
|
44 |
-
# 'call vwap':[],
|
45 |
-
# '% change op':[],
|
46 |
-
# 'strike':[],
|
47 |
-
# 'put change op':[],
|
48 |
-
# 'put vwap':[],
|
49 |
-
# '% change op put':[]
|
50 |
-
# }
|
51 |
-
# for i in a['stocks']:
|
52 |
-
# for sp in strike:
|
53 |
-
# if i['metadata']['expiryDate']==exp[0] and i['metadata']['optionType']=='Call' and i['metadata']['strikePrice']==sp:
|
54 |
-
# d['strike'].append(sp)
|
55 |
-
# d['call change op'].append(i['marketDeptOrderBook']['tradeInfo']['changeinOpenInterest'])
|
56 |
-
# d['% change op'].append(i['marketDeptOrderBook']['tradeInfo']['pchangeinOpenInterest'])
|
57 |
-
# d['call vwap'].append(i['marketDeptOrderBook']['tradeInfo']['vmap'])
|
58 |
-
|
59 |
-
# elif i['metadata']['expiryDate']==exp[0] and i['metadata']['optionType']=='Put' and i['metadata']['strikePrice']==sp:
|
60 |
-
# d['put change op'].append(i['marketDeptOrderBook']['tradeInfo']['changeinOpenInterest'])
|
61 |
-
# d['% change op put'].append(i['marketDeptOrderBook']['tradeInfo']['pchangeinOpenInterest'])
|
62 |
-
# d['put vwap'].append(i['marketDeptOrderBook']['tradeInfo']['vmap'])
|
63 |
-
|
64 |
-
# out=pd.json_normalize(d)
|
65 |
-
# out=out.explode(list(out.columns)).reset_index(drop = True)
|
66 |
-
# out.fillna(0,inplace=True)
|
67 |
-
# x=out.astype(float).round(2)
|
68 |
-
# return x
|
69 |
# def get_info(dataset):
|
70 |
# df= pd.DataFrame(columns=['value', 'pcr', 'cal_per','put_per'])
|
71 |
# value= dataset['put change op'].sum() - dataset['call change op'].sum()
|
@@ -118,3 +102,26 @@ st.write(df)
|
|
118 |
# p2.empty()
|
119 |
# p3.empty()
|
120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
+
def get_data():
|
17 |
+
a=(nse_fno("BANKNIFTY"))
|
18 |
+
last_prices=round(nse_quote_ltp("BANKNIFTY"))
|
19 |
+
exp=list(set(a['expiryDates']))
|
20 |
+
exp.sort(key = lambda date: datetime.strptime(date, '%d-%b-%Y'))
|
21 |
+
if last_prices%100>50:
|
22 |
+
x=(last_prices-last_prices%100+100)
|
23 |
+
strike=[x-200,x-100,x,x+100,x+200]
|
24 |
+
elif last_prices%100<50:
|
25 |
+
x=(last_prices-last_prices%100)
|
26 |
+
strike=[x-200,x-100,x,x+100,x+200]
|
27 |
+
d={'call change op':[],
|
28 |
+
'call vwap':[],
|
29 |
+
'% change op':[],
|
30 |
+
'strike':[],
|
31 |
+
'put change op':[],
|
32 |
+
'put vwap':[],
|
33 |
+
'% change op put':[]
|
34 |
+
}
|
35 |
+
for i in a['stocks']:
|
36 |
+
for sp in strike:
|
37 |
+
if i['metadata']['expiryDate']==exp[0] and i['metadata']['optionType']=='Call' and i['metadata']['strikePrice']==sp:
|
38 |
+
d['strike'].append(sp)
|
39 |
+
d['call change op'].append(i['marketDeptOrderBook']['tradeInfo']['changeinOpenInterest'])
|
40 |
+
d['% change op'].append(i['marketDeptOrderBook']['tradeInfo']['pchangeinOpenInterest'])
|
41 |
+
d['call vwap'].append(i['marketDeptOrderBook']['tradeInfo']['vmap'])
|
42 |
|
43 |
+
elif i['metadata']['expiryDate']==exp[0] and i['metadata']['optionType']=='Put' and i['metadata']['strikePrice']==sp:
|
44 |
+
d['put change op'].append(i['marketDeptOrderBook']['tradeInfo']['changeinOpenInterest'])
|
45 |
+
d['% change op put'].append(i['marketDeptOrderBook']['tradeInfo']['pchangeinOpenInterest'])
|
46 |
+
d['put vwap'].append(i['marketDeptOrderBook']['tradeInfo']['vmap'])
|
47 |
|
48 |
+
out=pd.json_normalize(d)
|
49 |
+
out=out.explode(list(out.columns)).reset_index(drop = True)
|
50 |
+
out.fillna(0,inplace=True)
|
51 |
+
x=out.astype(float).round(2)
|
52 |
+
return x
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
# def get_info(dataset):
|
54 |
# df= pd.DataFrame(columns=['value', 'pcr', 'cal_per','put_per'])
|
55 |
# value= dataset['put change op'].sum() - dataset['call change op'].sum()
|
|
|
102 |
# p2.empty()
|
103 |
# p3.empty()
|
104 |
|
105 |
+
|
106 |
+
import streamlit as st
|
107 |
+
import pandas as pd
|
108 |
+
st.title('A Simple Streamlit Web App')
|
109 |
+
option= st.selectbox(
|
110 |
+
'How would you like to be contacted?',
|
111 |
+
('5', '10', '15'))
|
112 |
+
st.write('You selected:', option)
|
113 |
+
st.header('Important Information')
|
114 |
+
st.markdown(""" CALL % INCREASE MEANS MARKET GOES DOWN
|
115 |
+
PUT % INCREASE MEANS MARKET GOES UP
|
116 |
+
""")
|
117 |
+
x = st.slider('Select an integer x', 0, 10, 1)
|
118 |
+
y = st.slider('Select an integer y', 0, 10, 1)
|
119 |
+
df = pd.DataFrame({'x': [x], 'y': [y] , 'x + y': [x + y]}, index = ['addition row'])
|
120 |
+
st.write(df)
|
121 |
+
get=get_data
|
122 |
+
st.DataFrame(get)
|
123 |
+
|
124 |
+
|
125 |
+
|
126 |
+
|
127 |
+
|