Aibytec

logo
AI BY TEC

Build an AI Bitcoin Sentiment Monitor with Python & Streamlit (Free)

Build an AI Bitcoin Market Analyzer with Python & Streamlit (Free, 2026 Tutorial) | AIByTec
🛠️ Hands-On Tutorial · AI + Crypto · 2026
✅ Beginner Friendly ⏱️ ~2 Hours to Complete 💰 100% Free Tools

Build Your Own AI Bitcoin Market Analyzer with Python & Streamlit — Free

While Bitcoin sits in extreme fear territory, you could be building a real AI tool that monitors market sentiment, tracks price data, and gives you an analytical edge — using 100% free tools. This tutorial takes you from zero to a deployed app in about 2 hours.

By Muhammad Rustam · 14 min read · AIByTec.com · Feb 24, 2026

What You'll Build

By the end of this tutorial, you'll have a fully functional, publicly accessible AI web app that displays real-time Bitcoin data, AI sentiment scores, and market indicators — all for free.

📈
Live BTC Price
Real-time Bitcoin price with 30-day historical chart from CoinGecko's free API
🧠
AI Sentiment Score
HuggingFace FinBERT analyzes crypto news headlines for Bullish / Bearish signal
😨
Fear & Greed Meter
Live Fear & Greed Index with visual indicator and historical context
🚀
Free Deployment
Hosted on HuggingFace Spaces — share the link with anyone, zero cost

Requirements — All 100% Free

🐍
Python 3.9+
Any OS — Windows, Mac, Linux
🤗
HuggingFace Account
Free — huggingface.co
🦎
CoinGecko API
Free tier — no credit card needed
💻
VS Code (Recommended)
Any code editor works
💡 Pro Tip

This project is perfect for your AIByTec course portfolio. Once deployed on HuggingFace Spaces, add the link to your LinkedIn — it demonstrates real AI + financial data integration skills that employers love in 2026.

Step 1 Set Up Your Environment

Open your terminal and create a new project folder. We'll set up a virtual environment to keep dependencies clean and avoid conflicts with other projects.

terminal bash
# Create project directory
mkdir ai-bitcoin-analyzer
cd ai-bitcoin-analyzer

# Create and activate virtual environment
python -m venv venv

# On Windows:
venv\Scripts\activate

# On Mac/Linux:
source venv/bin/activate

# Install required packages
pip install streamlit requests plotly python-dotenv transformers

Create a requirements.txt file — you'll need this for deployment:

requirements.txt text
streamlit==1.32.0
requests==2.31.0
plotly==5.18.0
python-dotenv==1.0.0
transformers==4.38.0

Step 2 Fetch Live Bitcoin Data

We'll use the CoinGecko free API to get real-time Bitcoin price data and 30-day historical prices. No API key is required for the free tier endpoints we're using.

data_fetcher.py python
import requests
from datetime import datetime

def get_bitcoin_price():
    """Fetch current Bitcoin price from CoinGecko free API"""
    url = "https://api.coingecko.com/api/v3/simple/price"
    params = {
        "ids": "bitcoin",
        "vs_currencies": "usd",
        "include_24hr_change": "true",
        "include_market_cap": "true",
        "include_24hr_vol": "true"
    }
    response = requests.get(url, params=params)
    data = response.json()
    return {
        "price": data["bitcoin"]["usd"],
        "change_24h": data["bitcoin"]["usd_24h_change"],
        "market_cap": data["bitcoin"]["usd_market_cap"],
        "volume_24h": data["bitcoin"]["usd_24h_vol"]
    }

def get_price_history(days=30):
    """Get historical price data for chart"""
    url = "https://api.coingecko.com/api/v3/coins/bitcoin/market_chart"
    params = {"vs_currency": "usd", "days": days, "interval": "daily"}
    response = requests.get(url, params=params)
    data = response.json()
    prices = [p[1] for p in data["prices"]]
    timestamps = [datetime.fromtimestamp(p[0]/1000).strftime("%Y-%m-%d")
                  for p in data["prices"]]
    return timestamps, prices

def get_fear_greed_index():
    """Fetch Fear & Greed Index from alternative.me"""
    url = "https://api.alternative.me/fng/"
    response = requests.get(url)
    data = response.json()
    return {
        "value": int(data["data"][0]["value"]),
        "classification": data["data"][0]["value_classification"]
    }

Step 3 Add AI Sentiment Analysis

Now the exciting part — we'll use a free HuggingFace financial sentiment model to analyze crypto headlines. FinBERT (ProsusAI/finbert) is specifically trained on financial text and classifies sentiment as Positive, Negative, or Neutral with high accuracy.

sentiment_analyzer.py python
import requests
import os

# Free HuggingFace Inference API — get your token at:
# https://huggingface.co/settings/tokens
HF_TOKEN = os.getenv("HF_TOKEN", "")

def analyze_sentiment(headlines: list) -> dict:
    """
    Analyze a list of news headlines using FinBERT.
    Returns overall sentiment score and per-headline breakdown.
    """
    API_URL = "https://api-inference.huggingface.co/models/ProsusAI/finbert"
    headers = {"Authorization": f"Bearer {HF_TOKEN}"}
    results = {"positive": 0, "negative": 0, "neutral": 0}
    detailed = []

    for headline in headlines:
        response = requests.post(
            API_URL, headers=headers,
            json={"inputs": headline}
        )
        if response.status_code == 200:
            scores = response.json()[0]
            top = max(scores, key=lambda x: x["score"])
            label = top["label"].lower()
            results[label] += 1
            detailed.append({
                "headline": headline[:80] + "...",
                "sentiment": label,
                "confidence": round(top["score"] * 100, 1)
            })

    total = max(sum(results.values()), 1)
    return {
        "overall": ("BULLISH" if results["positive"] > results["negative"]
                    else "BEARISH" if results["negative"] > results["positive"]
                    else "NEUTRAL"),
        "scores": results,
        "bull_pct": round(results["positive"] / total * 100),
        "bear_pct": round(results["negative"] / total * 100),
        "detailed": detailed
    }

# Sample headlines — replace with live news API in production
SAMPLE_HEADLINES = [
    "Bitcoin falls below $63,000 amid extreme investor fear",
    "Crypto ETF sees $203 million in outflows this week",
    "CZ predicts Bitcoin could reach $200,000",
    "Bitcoin RSI more oversold than during 2020 COVID crash",
    "Institutional investors quietly accumulating Bitcoin",
    "U.S. tariff proposals spark crypto selloff",
]

Step 4 Build the Streamlit Dashboard

Now we bring everything together in the main Streamlit app file. This is where your data and AI model combine into a real interactive web dashboard:

app.py python
import streamlit as st
import plotly.graph_objects as go
from data_fetcher import get_bitcoin_price, get_price_history, get_fear_greed_index
from sentiment_analyzer import analyze_sentiment, SAMPLE_HEADLINES

st.set_page_config(
    page_title="AI Bitcoin Monitor | AIByTec",
    page_icon="₿",
    layout="wide"
)

st.title("₿ AI Bitcoin Market Analyzer")
st.caption("Powered by FinBERT + CoinGecko API | Built with AIByTec")
st.divider()

# Fetch live data
with st.spinner("Fetching live Bitcoin data..."):
    btc = get_bitcoin_price()
    fng = get_fear_greed_index()
    dates, prices = get_price_history(30)

# Metrics row
col1, col2, col3, col4 = st.columns(4)
with col1:
    st.metric("Bitcoin Price", f"${btc['price']:,.0f}", f"{btc['change_24h']:.2f}%")
with col2:
    st.metric("Market Cap", f"${btc['market_cap']/1e9:.1f}B")
with col3:
    st.metric("24h Volume", f"${btc['volume_24h']/1e9:.1f}B")
with col4:
    icon = "🔴" if fng['value'] < 25 else "🟡" if fng['value'] < 50 else "🟢"
    st.metric("Fear & Greed", f"{icon} {fng['value']}/100", fng['classification'])

# Price chart
st.subheader("📈 30-Day Price History")
fig = go.Figure()
fig.add_trace(go.Scatter(
    x=dates, y=prices, fill="tozeroy",
    line=dict(color="#6366f1", width=2),
    fillcolor="rgba(99,102,241,0.1)", name="BTC/USD"
))
fig.update_layout(
    paper_bgcolor="rgba(0,0,0,0)", plot_bgcolor="rgba(0,0,0,0)",
    height=350, yaxis=dict(tickprefix="$")
)
st.plotly_chart(fig, use_container_width=True)

# AI Sentiment
st.subheader("🧠 AI Sentiment Analysis (FinBERT)")
if st.button("Run AI Sentiment Analysis", type="primary"):
    with st.spinner("Analyzing headlines with AI..."):
        sentiment = analyze_sentiment(SAMPLE_HEADLINES)
    st.metric("Overall Sentiment", sentiment["overall"],
              f"Bull: {sentiment['bull_pct']}% | Bear: {sentiment['bear_pct']}%")
    for item in sentiment["detailed"]:
        icon = "🟢" if item['sentiment']=='positive' else "🔴" if item['sentiment']=='negative' else "⚪"
        st.write(f"{icon} **{item['label'].upper()}** ({item['confidence']}%) — {item['headline']}")

st.caption("⚠️ Educational tool only. Not financial advice. AIByTec.com")

Expected Output Preview

Sample Dashboard Output
Bitcoin Price$62,847 ↓ −3.2%
Market Cap$1.24T
Fear & Greed Index🔴 5/100 — Extreme Fear
AI Sentiment (6 headlines)BEARISH — 67% Bear / 17% Bull
30-Day TrendDowntrend with high volatility

Step 5 Run Locally & Test

terminal bash
# Set your HuggingFace token (free at huggingface.co/settings/tokens)
# Windows:
set HF_TOKEN=hf_yourTokenHere

# Mac/Linux:
export HF_TOKEN=hf_yourTokenHere

# Run the Streamlit app
streamlit run app.py

# Browser opens automatically at: http://localhost:8501

Step 6 Deploy Free on HuggingFace Spaces

HuggingFace Spaces gives you free hosting for Streamlit apps. Your app will be publicly accessible with a shareable URL — perfect for your LinkedIn portfolio and AIByTec course showcase.

1
Go to huggingface.co/spaces and click "Create new Space". Choose Streamlit as the SDK.
2
Upload your app.py, data_fetcher.py, sentiment_analyzer.py, and requirements.txt files.
3
Go to Settings → Variables and Secrets and add your HF_TOKEN as a secret (keeps it secure).
4
HuggingFace builds and deploys automatically. Your URL: huggingface.co/spaces/YourUsername/ai-bitcoin-analyzer
5
Share on LinkedIn and tag #AIByTec #StreamlitApp #AIProject to get visibility from the AI community.
🚀 Next-Level Upgrades

Once the basic version works, consider: connecting CryptoPanic's free API for live headlines, adding Twilio SMS alerts when sentiment drops below 20, integrating RSI indicators with the ta-lib library, or expanding to multi-coin monitoring with an ETH/SOL dropdown. Any of these upgrades make excellent capstone projects for your AIByTec course.

Frequently Asked Questions

Do I need advanced Python to build this?
No — if you know basic Python (variables, functions, lists, dictionaries), you can follow this tutorial. Streamlit is designed to make web apps simple for Python developers. The most complex part is the HuggingFace API call, which is just a few lines of requests code.
Is the CoinGecko API really free?
Yes. CoinGecko's free tier allows up to 10,000 calls per month without an API key, and 30 calls per minute with a free key. For a personal dashboard refreshed manually, you'll never hit those limits. The free tier is more than enough for this entire project.
How accurate is the HuggingFace FinBERT sentiment model?
FinBERT was trained specifically on financial text and significantly outperforms general-purpose sentiment models for finance. However, no sentiment model is perfectly accurate, and financial sentiment analysis should be used as one data point among many — never as a sole trading signal.
Can I add more cryptocurrencies beyond Bitcoin?
Yes! The CoinGecko API supports thousands of cryptocurrencies. Replace "bitcoin" in the API calls with any CoinGecko coin ID (e.g., "ethereum", "solana", "fetch-ai"). You can also add a Streamlit dropdown to let users select any coin dynamically.
Can this project be used as a portfolio piece?
Absolutely — this is an excellent portfolio project because it demonstrates real AI integration (NLP/sentiment analysis), API consumption, data visualization, and web deployment. It combines two hot domains (AI + crypto) which makes it memorable to potential employers or clients.

Learn to Build More AI-Powered Applications

This tutorial is just one project from our comprehensive Generative AI curriculum at AIByTec. Learn RAG chatbots, OpenAI Agents, FastAPI backends, and production-grade AI deployments.

Leave a Comment

Your email address will not be published. Required fields are marked *

Verified by MonsterInsights