import requests import streamlit as st import yfinance as yf import pandas_ta as ta from tradingview_ta import * st.set_page_config('Crypto',":moneybag:","wide",menu_items={'About': "This is an *extremely* cool app!"}) menu=['Chart','RSI Indicator','Pivot points','Trading-view'] ch=st.sidebar.selectbox('Menu',menu) if ch== 'Chart': with st.container(): list_asset = ['BTC-USD', 'ETH-USD', 'DOGE-USD'] ms = st.multiselect('choose asset', list_asset) dates1 = st.date_input('from') dates2 = st.date_input('to') st.write('---') if len(ms) > 0: with st.container(): df = yf.download(ms, dates1, dates2) st.write(df) df2 = yf.download(ms, dates1, dates2)['Close'] st.line_chart(df2) if ch== 'RSI Indicator': with st.container(): list_asset = ['BTC-USD', 'ETH-USD', 'DOGE-USD'] ms = st.selectbox('choose asset', list_asset) dates1 = st.date_input('from') dates2 = st.date_input('to') st.write('---') lis=[] if len(ms) > 0: with st.container(): df = yf.download(ms, dates1, dates2) x=ta.rsi(df['Close'],lenght=14) try: st.write(x) for i,j in x.items(): lis.append(j) st.write(f'RSI(14): {lis[-1]}') except: st.warning('Minimum interval should be 14 days.') if ch== 'Pivot points': with st.container(): list_asset = ['BTC-USD', 'ETH-USD', 'DOGE-USD'] ms = st.selectbox('choose asset', list_asset) dates1 = st.date_input('from') dates2 = st.date_input('to') st.write('---') hlis=[] llis=[] clis=[] if len(ms) > 0: with st.container(): df = yf.download(ms, dates1, dates2) for i,j in df['Close'].items(): clis.append(j) close=clis[-1] for ii,jj in df['High'].items(): hlis.append(jj) high=hlis[-1] for iii,jjj in df['Low'].items(): llis.append(jjj) low=llis[-1] PP = (high + low + close) / 3 R1 = 2 * PP - low S1 = 2 * PP - high st.write(f'S1:{S1}----R1:{R1}') R2 = PP + (high - low) S2 = PP - (high - low) st.write(f'S2:{S2}----R2:{R2}') R3 = PP + 2 * (high - low) S3 = PP - 2 * (high - low) st.write(f'S3:{S3}----R3:{R3}') R4 = PP + 3 * (high - low) S4 = PP - 3 * (high - low) st.write(f'S4:{S4}----R4:{R4}') list_pair= ["BTCUSDT" ,"ETHUSDT","BNBUSDT","ADAUSDT","DOGEUSDT","SHIBAUSDT","MATICUSDT","ALGOUSDT","CHZUSDT"] list_interval = ["Monthly","Weekly","Daily","4h","2h","1h","30m","15m","5m","1m"] dict = { "1m":Interval.INTERVAL_1_MINUTE, "5m":Interval.INTERVAL_5_MINUTES , "15m":Interval.INTERVAL_15_MINUTES, "30m":Interval.INTERVAL_30_MINUTES, "1h":Interval.INTERVAL_1_HOUR, "2h":Interval.INTERVAL_2_HOURS, "4h":Interval.INTERVAL_4_HOURS, "Daily":Interval.INTERVAL_1_DAY, "Weekly":Interval.INTERVAL_1_WEEK, "Monthly":Interval.INTERVAL_1_MONTH, } list_exchange = ["BINANCE" ,"COINEX","UNISWAP","GATEIO","HUOBI","GATEIO","KUCOIN","FTX","COINBASE","OKX"] screener="CRYPTO" if ch== 'Trading-view': with st.container(): pair = st.selectbox('Choose pair',list_pair) exchange = st.selectbox('Choose exchange', list_exchange) interval2 = st.selectbox('Choose interval', list_interval) interval2=(dict[interval2]) handler = TA_Handler( symbol=pair, screener=screener, exchange=exchange, interval=interval2 ) with st.container(): try: rec = handler.get_analysis().summary["RECOMMENDATION"] st.warning("RECOMMENDATION: "+ rec) ind = handler.get_analysis().indicators for k,v in ind.items(): st.write(f'{k} ----- {v}') #handler.get_analysis(). except: st.error('Exchange or pair not found.')