Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import datetime | |
| import time | |
| st.set_page_config(page_title="Inraday_Screener",page_icon="π",layout="wide") | |
| from tradingview_screener import Scanner, Query, Column | |
| # Assuming the crosses_below method is defined in a class | |
| class YourClass: | |
| def crosses_below(self, column, other): | |
| return {'left': column.name, 'operation': 'crosses_below', 'right': column._extract_value(other)} | |
| def crosses_above(self, column, other): | |
| return {'left': column.name, 'operation': 'crosses_above', 'right': column._extract_value(other)} | |
| # Create an instance of your class | |
| your_instance = YourClass() | |
| con10, con20 = st.columns(2) | |
| st.success('*_Setup_*') | |
| with con10: | |
| st.write('') | |
| time1 = st.selectbox('*_Time Frame_*', ('1','5','15','30','60','120','240','D','1W','1M'),key=1) | |
| if time1 == 'D': | |
| timevolume = 'volume' | |
| timeADXnegDI = 'ADX-DI' | |
| timeADXposDI = 'ADX+DI' | |
| timeclose = 'close' | |
| else: | |
| timeclose = f'close|{time1}' | |
| timevolume = f'volume|{time}' | |
| timeADXnegDI = f'ADX-DI|{time}' | |
| timeADXposDI = f'ADX+DI|{time}' | |
| with con20: | |
| st.write('') | |
| price_from = st.number_input('*_Price_From_*', min_value=float(1), max_value=float(10000), value=float(100), step=float(5),key=23) | |
| price_to = st.number_input('*_Price_To_*', min_value=float(1), max_value=float(10000), value=float(200), step=float(5),key=2) | |
| def create_link(url:str) -> str: | |
| return f'<a href="https://in.tradingview.com/chart/?symbol={url}">{url}</a>' | |
| if st.button('*_SUBMIT_*'): | |
| # Create a query with the required columns and conditions | |
| df_Bulliesh = (Query().select('Exchange','name',timeclose, timevolume, timeADXnegDI, timeADXposDI).where(your_instance.crosses_below(Column(timeADXnegDI), Column(timeADXposDI)),Column(timeclose).between(price_from, price_to)).order_by(timevolume, ascending=False).limit(10)) | |
| df_Beariesh = (Query().select('Exchange','name',timeclose, timevolume, timeADXnegDI, timeADXposDI).where(your_instance.crosses_above(Column(timeADXnegDI), Column(timeADXposDI)),Column(timeclose).between(price_from, price_to)).order_by(timevolume, ascending=False).limit(10)) | |
| # Display the result | |
| df_Bulliesh = df_Bulliesh.set_markets('india').get_scanner_data() | |
| df_Bulliesh = df_Bulliesh[1] | |
| df_Bulliesh = df_Bulliesh[df_Bulliesh['exchange'] == 'NSE'] | |
| #-------------------------------- | |
| df_Beariesh = df_Beariesh.set_markets('india').get_scanner_data() | |
| df_Beariesh = df_Beariesh[1] | |
| df_Beariesh = df_Beariesh[df_Beariesh['exchange'] == 'NSE'] | |
| df_Beariesh['π Link'] = [create_link(url) for url in df_Beariesh["ticker"]] | |
| df_Bulliesh['π Link'] = [create_link(url) for url in df_Bulliesh["ticker"]] | |
| st.success('*_Bulliesh_*') | |
| #st.table(df_Bulliesh) | |
| st.write(df_Bulliesh.to_html(escape=False, index=False), unsafe_allow_html=True) | |
| st.error('*_Beariesh_*') | |
| #st.table(df_Beariesh) | |
| st.write(df_Beariesh.to_html(escape=False, index=False), unsafe_allow_html=True) |