- GuruFinance Insights
- Posts
- Digging into Stocks with finvizfinance: A Python Guide for Investors and Analysts
Digging into Stocks with finvizfinance: A Python Guide for Investors and Analysts
Join 400,000+ executives and professionals who trust The AI Report for daily, practical AI updates.
Built for business—not engineers—this newsletter delivers expert prompts, real-world use cases, and decision-ready insights.
No hype. No jargon. Just results.
🚀 Your Investing Journey Just Got Better: Premium Subscriptions Are Here! 🚀
It’s been 4 months since we launched our premium subscription plans at GuruFinance Insights, and the results have been phenomenal! Now, we’re making it even better for you to take your investing game to the next level. Whether you’re just starting out or you’re a seasoned trader, our updated plans are designed to give you the tools, insights, and support you need to succeed.
Here’s what you’ll get as a premium member:
Exclusive Trading Strategies: Unlock proven methods to maximize your returns.
In-Depth Research Analysis: Stay ahead with insights from the latest market trends.
Ad-Free Experience: Focus on what matters most—your investments.
Monthly AMA Sessions: Get your questions answered by top industry experts.
Coding Tutorials: Learn how to automate your trading strategies like a pro.
Masterclasses & One-on-One Consultations: Elevate your skills with personalized guidance.
Our three tailored plans—Starter Investor, Pro Trader, and Elite Investor—are designed to fit your unique needs and goals. Whether you’re looking for foundational tools or advanced strategies, we’ve got you covered.
Don’t wait any longer to transform your investment strategy. The last 4 months have shown just how powerful these tools can be—now it’s your turn to experience the difference.
Tt’s late, I’m hunched over my laptop, coffee gone cold, trying to figure out if Tesla’s stock is worth the hype. I’m flipping between browser tabs, jotting down numbers from FinViz like some caffeinated detective. Sound familiar?
That was me until I discovered finvizfinance, a Python package that pulls financial data — stock charts, fundamentals, insider trades, you name it — straight from FinViz without the headache.
If you’re into markets, coding, or just curious, stick with me. I’m gonna walk you through this tool, show you some code, and explain why it’s now my go-to for financial sleuthing.

Disclaimer: Trading is highly risky, and you could lose some or all of your investment. This article is purely for educational purposes, designed to explain concepts and demonstrate code using finvizfinance in a backtested environment.
He’s already IPO’d once – this time’s different
Spencer Rascoff grew Zillow from seed to IPO. But everyday investors couldn’t join until then, missing early gains. So he did things differently with Pacaso. They’ve made $110M+ in gross profits disrupting a $1.3T market. And after reserving the Nasdaq ticker PCSO, you can join for $2.80/share until 5/29.
This is a paid advertisement for Pacaso’s Regulation A offering. Please read the offering circular at invest.pacaso.com. Reserving a ticker symbol is not a guarantee that the company will go public. Listing on the NASDAQ is subject to approvals. Under Regulation A+, a company has the ability to change its share price by up to 20%, without requalifying the offering with the SEC.
What’s finvizfinance, Anyway?
Alright, let’s break it down. finvizfinance is like a magic key to the FinViz website, a treasure trove for stock nerds. It’s a Python library that grabs all sorts of financial goodies:
Stocks: Price charts, key metrics (like P/E ratios), insider trades, and news.
Forex and Crypto: Performance data for currency pairs or Bitcoin.
Screeners: Tools to hunt down stocks that match your vibe — say, cheap tech stocks or high-flyers in the S&P 500.
Why Use finvizfinance?
I’ve messed with a few financial APIs before, but finvizfinance hits different. Here’s why it’s earned a spot in my coding toolbox:
No Fuss: A couple of lines of code, and boom — data’s yours. No web-scraping nightmares.
Loaded with Info: From stock news to crypto trends, it’s got range.
Python Power: Pairs perfectly with Pandas for slicing and dicing data.
Zero Cost: It’s just you, Python, and FinViz’s free data.
Enough chit-chat — let’s code!
Getting Started: Installation
First, you’ll need Python (3.6 or newer works best). Installing finvizfinance is a breeze.
PyPI (Easiest)
Fire up your terminal and type:
pip install finvizfinance
Install via GitHub (for the latest version)
Want the freshest version? Clone it:
git clone https://github.com/lit26/finvizfinance.git
cd finvizfinance
pip install .
Now you’re ready to roll. Let’s poke around with Tesla’s data to see what this thing can do.
Exploring Stock Data: Tesla
Tesla’s always making waves, so let’s use it as our guinea pig. The finvizfinance.quote module is our starting point.
Step 1: Import and Initialize
Here’s how I kick things off:
from finvizfinance.quote import finvizfinance
# Initialize the stock object for Tesla
stock = finvizfinance('TSLA')
This sets up a little Tesla data machine, ready to spill the beans.
Step 2: Fetch Fundamentals
I’m always curious about a company’s vitals — stuff like market cap or earnings. The ticker_fundament() method delivers:
# Get fundamental data
stock_fundament = stock.ticker_fundament()
# Print the results
print(stock_fundament)
What You Get:
{
'Company': 'Tesla, Inc.',
'Sector': 'Consumer Cyclical',
'Industry': 'Auto Manufacturers',
'Country': 'USA',
'P/E': '849.57',
'EPS (ttm)': '1.94',
'Market Cap': '302.10B',
'Perf Week': '13.63%',
# ... and more
}
It’s like a cheat sheet for Tesla — market cap in billions, P/E ratio sky-high, and even how it’s been doing this week. Perfect for sizing up a stock fast.
Step 3: Visualize Stock Charts
Numbers are cool, but I’m a visual guy. Want to see Tesla’s price action? Try this:
# Open Tesla's stock chart
stock.ticker_charts()
This flings open a browser tab with a FinViz chart — price, volume, the works. It’s like having a stock dashboard without the hassle.
Step 4: Stay informed about the latest happenings.
News can move markets using ticker_news(), so let’s check what’s up with Tesla:
# Fetch recent news
news_df = stock.ticker_news()
# Display the top 5 articles
print(news_df.head())
Sample Output: A Pandas DataFrame with columns like Date, Title, Source, and Link. For example:
Date Title Source
2025-04-10 Tesla Q1 Deliveries Beat Expectations Yahoo Finance
2025-04-09 Musk Announces New Tesla Factory Bloomberg
...
I use this to gauge whether the market’s hyped or spooked — super handy for context.
Step 5: Insider Trading
Here’s where it gets juicy: what are Tesla’s big shots buying or selling?
# Get insider trading data
inside_trader_df = stock.ticker_inside_trader()
# Display the data
print(inside_trader_df.head())
You’ll see a DataFrame with names, buy/sell moves, and share counts. If the CEO’s dumping stock, I wanna know why.
Beyond Stocks: News and Insider Trading
Sometimes, I wanna step back and see the bigger picture. finvizfinance has my back here too.
Catching Up on News
To get the latest market buzz, I use the News module:
from finvizfinance.news import News
# Initialize news object
fnews = News()
# Get all news (includes 'news' and 'blogs')
all_news = fnews.get_news()
# Display top 5 news articles
print(all_news['news'].head())
# Display top 5 blog posts
print(all_news['blogs'].head())
This splits news into two piles: legit articles and blog posts. It’s like skimming Twitter for market vibes, but cleaner.
Tracking Insider Activity
Curious about who’s buying or selling big-time? The Insider module’s got you:
from finvizfinance.insider import Insider
# Initialize insider object with 'top owner trade' filter
finsider = Insider(option='top owner trade')
# Fetch insider trading data
insider_trader = finsider.get_insider()
# Display the data
print(insider_trader.head())
You can swap top owner trade for latest or top week to tweak what you see. It’s like eavesdropping on Wall Street’s inner circle.
Power of Screening: Finding the Right Stocks
Here’s where finvizfinance flexes. Its screener lets you hunt for stocks that fit your style — say, Basic Materials companies in the S&P 500. Last month, I was curious about mining stocks, so here’s how I did it:
from finvizfinance.screener.overview import Overview
# Initialize screener
foverview = Overview()
# Set filters (S&P 500, Basic Materials sector)
filters_dict = {'Index': 'S&P 500', 'Sector': 'Basic Materials'}
# Apply filters
foverview.set_filter(filters_dict=filters_dict)
# Get the results
df = foverview.screener_view()
# Display the top 5 stocks
print(df.head())
Sample Output: A table with tickers like DOW or FCX, plus stats like market cap and P/E. You can filter by valuation, performance, even technical signals — whatever sparks your interest.
Advanced: Using Proxies
One time, my Wi-Fi was acting up, and FinViz kept giving me the cold shoulder. Turns out, finvizfinance lets you use proxies to keep things smooth:
from finvizfinance.util import set_proxy
# Set proxy configuration
proxies = {'http': 'http://127.0.0.1:8080'}
set_proxy(proxies)
# Now proceed with your queries
stock = finvizfinance('TSLA')
print(stock.ticker_fundament())
This saved my bacon when I was pulling data from a dodgy network.
What Can You Build with This?
I’ve had a blast with finvizfinance, and here’s what I’ve tried (or dreamed up):
Portfolio Tracker: I pulled fundamentals for my stocks and calculated my average dividend yield.
News Bot: Wrote a script to ping me on Discord when big Tesla news drops.
Stock Picks: Used the screener to find low P/E tech stocks — found a few gems!
Charts Galore: Plotted market cap vs. EPS for fun (and maybe some insights).
Wanna see a quick plot? Here’s one I threw together for Tesla:
import matplotlib.pyplot as plt
# Fetch Tesla's fundamentals
stock = finvizfinance('TSLA')
fundamentals = stock.ticker_fundament()
# Extract data
market_cap = float(fundamentals['Market Cap'].replace('B', '')) # Convert to billions
pe_ratio = float(fundamentals['P/E'])
# Plot
plt.bar(['Market Cap (B)'], [market_cap], color='blue', alpha=0.5)
plt.twinx()
plt.plot(['P/E Ratio'], [pe_ratio], color='red', marker='o')
plt.title('Tesla: Market Cap vs. P/E Ratio')
plt.show()
It’s a simple bar-line combo, but it shows how wild Tesla’s valuation is compared to its P/E.
A Few Pointers
Before you go wild, here’s some wisdom from my trial-and-error:
Don’t Spam FinViz: It’s free, so play nice to avoid getting blocked.
Read the Docs: The official guide lists every filter and trick.
Pandas Is Your Friend: Export to CSV or filter DataFrames for deeper dives.
Stay Fresh: Check the GitHub page for updates.