If statement implemation - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: If statement implemation (/thread-27025.html) |
If statement implemation - jovetp - May-23-2020 Im trying to implement an if statement that turns the RSI values digits RED when the values is greater or equal to 70 and when its less or equal 30 it turns green. please help me implement this code into my program. import pandas as pd import requests from bs4 import BeautifulSoup def start(): indices = ["us-30", "nasdaq-composite", "us-spx-500"] def get_rsi(tick): page = requests.get('https://www.investing.com/indices/' + tick + "-technical", headers={"user-agent": "Chrome"}) soup = BeautifulSoup(page.content, 'html.parser') summary = soup.find(id="techStudiesInnerWrap") name = soup.find("td", class_="first left symbol", string="RSI(14)") value = name.find_next('td') action = value.find_next('td') return name.text, value.text, action.span.text name_list=[] rsi_list=[] action_list=[] for index in indices: name,rsi,action = get_rsi(index) name_list.append(name) rsi_list.append(rsi) action_list.append(action) rsi_action = {"INDEX": indices,"NAME":name_list,"RSI":rsi_list,"ACTION":action_list} df=pd.DataFrame.from_dict(rsi_action, orient='index') print(df.transpose()) print("--------------------------------------------------------\n") print("--------------------------------------------------------\n") while True: start() time.sleep(2)
RE: If statement implemation - bowlofred - May-24-2020 Are you asking how to test the value, or how to print colored text? |