Open CatchyUsername30 opened 1 year ago
i use this but it takes a while.
def fetch_new_stock_tickers():
# Define the minimum market cap (in billions of dollars)
min_market_cap = 1
all_stocks = r.markets.get_all_stocks_from_market_tag("upcoming-earnings")
all_stocks += r.markets.get_all_stocks_from_market_tag("technology")
all_stocks += r.markets.get_all_stocks_from_market_tag("biopharmaceutical")
large_cap_stocks = []
for stock in all_stocks:
x = r.stocks.get_fundamentals(stock['symbol'])
if x[0]['market_cap'] and float(x[0]['market_cap'])/10**9 > min_market_cap:
large_cap_stocks.append(stock['symbol'])
return(large_cap_stocks)
i then write them to a file and read them
def read_lines_from_file(filename):
with open(filename, 'r') as f:
lines = f.readlines()
return [line.strip() for line in lines]
def append_unique_ticker(ticker, file_path):
with open(file_path, "r") as f:
tickers = f.read().splitlines()
if ticker not in tickers:
with open(file_path, "a") as f:
f.write(ticker + "\n")
print(f"Ticker {ticker} added to {file_path}")
Where could I find a list of all valid tags?
I'm trying to check each stock available on the Robinhood platform (no options, no crypto) and was told I could use 'get_all_stocks' to pull the list and check each one individually for buy and sell triggers but when I add this to my code, I get an error:
AttributeError: module 'robin_stocks.robinhood.stocks' has no attribute 'get_all_stocks'.
Does anyone have a solution better than writing a CSV or txt document with every stock on Robinhood?