jmfernandes / robin_stocks

This is a library to use with Robinhood Financial App. It currently supports trading crypto-currencies, options, and stocks. In addition, it can be used to get real time ticker information, assess the performance of your portfolio, and can also get tax documents, total dividends paid, and more. More info at
http://www.robin-stocks.com
MIT License
1.74k stars 467 forks source link

(Error) List all stocks available to be traded on Robinhood platform #404

Open CatchyUsername30 opened 1 year ago

CatchyUsername30 commented 1 year ago

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?

W-M-D commented 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}")
mfjones27 commented 7 months ago

Where could I find a list of all valid tags?