File size: 5,154 Bytes
9c64518
 
82152ce
9c64518
 
 
 
 
 
 
 
82152ce
 
 
 
9c64518
2768541
c994a1b
b14a992
9c64518
 
 
b14a992
9c64518
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82152ce
9c64518
 
 
 
82152ce
9c64518
 
 
 
 
82152ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9c64518
 
 
 
 
 
 
 
 
 
 
 
 
 
e1ef2ee
2e093d7
 
 
e1ef2ee
ff5b72b
c804cc1
1fa1fe4
4d4684e
 
c804cc1
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
from nsepython import *
import seaborn as sns
import pandas as pd
import streamlit as st
from datetime import datetime
from time import gmtime, strftime
from IPython.display import clear_output 
import matplotlib.pyplot as plt
from pytz import timezone 






def get_data():
    print('Hello')
    a=nse_fno("BANKNIFTY")
    print(a)
    last_prices=round(nse_quote_ltp("BANKNIFTY"))
    exp=list(set(a['expiryDates']))
    exp.sort(key = lambda date: datetime.strptime(date, '%d-%b-%Y')) 
    # print(exp)
    if last_prices%100>50:
        x=(last_prices-last_prices%100+100)
        strike=[x-200,x-100,x,x+100,x+200]
    elif last_prices%100<50:
        x=(last_prices-last_prices%100)
        strike=[x-200,x-100,x,x+100,x+200]
    d={'call change op':[],
        'call vwap':[],
        '% change op':[],
        'strike':[],
        'put change op':[],
        'put vwap':[],
        '% change op put':[]
        }
    for i in a['stocks']:
        for sp in strike: 
            if i['metadata']['expiryDate']==exp[0] and i['metadata']['optionType']=='Call' and i['metadata']['strikePrice']==sp:
                d['strike'].append(sp)
                d['call change op'].append(i['marketDeptOrderBook']['tradeInfo']['changeinOpenInterest'])
                d['% change op'].append(i['marketDeptOrderBook']['tradeInfo']['pchangeinOpenInterest'])
                d['call vwap'].append(i['marketDeptOrderBook']['tradeInfo']['vmap'])

            elif i['metadata']['expiryDate']==exp[0] and i['metadata']['optionType']=='Put' and i['metadata']['strikePrice']==sp:
                d['put change op'].append(i['marketDeptOrderBook']['tradeInfo']['changeinOpenInterest'])
                d['% change op put'].append(i['marketDeptOrderBook']['tradeInfo']['pchangeinOpenInterest'])
                d['put vwap'].append(i['marketDeptOrderBook']['tradeInfo']['vmap'])

    out=pd.json_normalize(d)
    out=out.explode(list(out.columns)).reset_index(drop = True)
    out.fillna(0,inplace=True)
    x=out.astype(float).round(2)
    return x
# def get_info(dataset):
#     df= pd.DataFrame(columns=['value', 'pcr', 'cal_per','put_per'])
#     value= dataset['put change op'].sum() - dataset['call change op'].sum()
#     pcr= dataset['put change op'].sum()/dataset['call change op'].sum()
#     cal_per= dataset['% change op'].mean()
#     put_per= dataset['% change op put'].mean()
#     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)}
#     df = df.append(new_row,ignore_index=True, verify_integrity=False, sort=None)
#     return df  
# def ploting():
#         try:
#             global final
#         except:
#              df = pd.DataFrame(columns=['value', 'pcr', 'cal_per','put_per'])
#         dataset= get_data()
#         main= get_info(dataset)
#         final =final.append(main,ignore_index=True, verify_integrity=False, sort=None)
#         return dataset,final

# final = pd.DataFrame(columns=['value', 'pcr', 'cal_per','put_per','time'])
    

# if __name__=='__main__':
    
#     st.title('WELCOME BULLS CARTEL')
#     today_date =strftime("%d %b %Y", gmtime()),datetime.now(timezone("Asia/Kolkata")).strftime('%I.%M %p')
#     st.markdown(f"as at {today_date}")
#     option= st.selectbox(
#     'How would you like to be contacted?',
#     ('5', '10', '15')) 
#     st.write('You selected:', option)
#     st.header('Important Information')
#     st.markdown(""" CALL % INCREASE MEANS MARKET GOES DOWN  
#              PUT % INCREASE MEANS MARKET GOES UP
#              """)    
#     while True:
#         dataset,final=ploting()
#         p1=st.empty()
#         p2=st.empty()
#         p3=st.empty()
#         p1.dataframe(dataset.style.highlight_max(['% change op put','% change op'],axis=0)) #Column hightlight 
#         p2.dataframe(final.style.highlight_max(['cal_per','put_per'],axis=1)) # row highlight
#         fig, ax = plt.subplots(figsize=(6, 2)) 
#         ax.plot(final['time'],final['pcr'])
#         ax.axhline(y=0, color='black', linestyle='solid') # 0 line graph
#         fig.autofmt_xdate(rotation=70)
#         p3.pyplot(fig)
#         time.sleep(3*60) # how to the start again code check upper condition min * sec
#         p1.empty() # then clean all data frame 
#         p2.empty()
#         p3.empty()
                   

import streamlit as st
import pandas as pd
st.title('A Simple Streamlit Web App')
option= st.selectbox(
    'How would you like to be contacted?',
    ('5', '10', '15'))
st.write('You selected:', option)
st.header('Important Information')
st.markdown(""" CALL % INCREASE MEANS MARKET GOES DOWN  
             PUT % INCREASE MEANS MARKET GOES UP
             """)
x = st.slider('Select an integer x', 0, 10, 1)
y = st.slider('Select an integer y', 0, 10, 1)
df = pd.DataFrame({'x': [x], 'y': [y] , 'x + y': [x + y]}, index = ['addition row'])
# if st.button('add'):
#     result = get_data()
#     st.dataframe(result)
# df = (get_data())
st.write(df)
# result = get_data()
print('banknifty')
a=(nse_quote_ltp("BANKNIFTY") ,'bank  ')
st.write(a)
# st.write(result)