An automated data pipeline that fetches real-time stock and cryptocurrency prices, performs technical analysis, and generates trading signals using Apache Airflow.
Individual investors and traders need to monitor multiple assets (stocks, crypto) across different markets. Manually tracking prices and calculating technical indicators is:
- Time-consuming: Checking multiple sources daily
- Error-prone: Manual calculations can be wrong
- Reactive: You find out about price drops too late
FinFlow automates the entire process:
- Fetches prices from Yahoo Finance (stocks) and CoinGecko (crypto)
- Calculates technical indicators (RSI, Moving Averages)
- Generates trading signals (BUY / SELL / HOLD)
- Alerts when significant price movements occur
All scheduled to run automatically during market hours (Mon-Fri, 9 AM).
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AIRFLOW DAG β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β TASKGROUP: DATA INGESTION β β
β β βββββββββββββββββββ βββββββββββββββββββ β β
β β β Fetch Stocks β β Fetch Crypto β β β
β β β (Yahoo Finance)β β (CoinGecko) β β β
β β ββββββββββ¬βββββββββ ββββββββββ¬βββββββββ β β
β β β β β β
β β ββββββββββββ¬ββββββββββββ β β
β β βΌ β β
β β XCom (price data) β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β TASKGROUP: DATA PROCESSING β β
β β βββββββββββββββββββ βββββββββββββββββββ β β
β β β Analyze Stocks β β Analyze Crypto β β β
β β β (RSI, MA) β β (24h Change) β β β
β β ββββββββββ¬βββββββββ ββββββββββ¬βββββββββ β β
β β β β β β
β β ββββββββββββ¬ββββββββββββ β β
β β βΌ β β
β β XCom (analysis) β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β BRANCHING LOGIC β β
β β β β
β β ββββββββββββββββ β β
β β β Check Alerts β β β
β β ββββββββ¬ββββββββ β β
β β β β β
β β βββββββββββββββ΄ββββββββββββββ β β
β β βΌ βΌ β β
β β ββββββββββββββββ ββββββββββββββββ β β
β β β Send Alert β OR β Gen Report β β β
β β β (if signals) β β (no signals) β β β
β β ββββββββββββββββ ββββββββββββββββ β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
finflow/
βββ dags/
β βββ finflow_pipeline.py # Main DAG orchestrator
β βββ utils/
β βββ fetchers.py # API integration (Yahoo, CoinGecko)
β βββ indicators.py # Technical analysis functions
βββ include/
β βββ data/ # Generated reports
βββ requirements.txt # Python dependencies
βββ Dockerfile # Astro runtime
βββ README.md
Smooths out price fluctuations to identify trends.
MA = (Priceβ + Priceβ + ... + Priceβ) / n
Example (5-day MA):
Prices: [150, 152, 148, 155, 153]
MA = (150 + 152 + 148 + 155 + 153) / 5 = 151.6
Signal: If current price (153) > MA (151.6) β Bullish π
Measures momentum on a scale of 0-100.
RSI = 100 - (100 / (1 + RS))
where RS = Average Gain / Average Loss
Interpretation:
- RSI > 70 β Overbought (potential SELL)
- RSI < 30 β Oversold (potential BUY)
- RSI 30-70 β Neutral
if rsi < 30 and price > moving_average:
signal = "BUY" # Oversold but trending up
elif rsi > 70 and price < moving_average:
signal = "SELL" # Overbought and trending down
else:
signal = "HOLD"| Concept | What It Does | Where Used |
|---|---|---|
| TaskGroup | Groups related tasks for cleaner DAG | data_ingestion, data_processing |
| XCom | Passes data between tasks | Price data β Analysis |
| BranchPythonOperator | Conditional task execution | Alert vs Report path |
| PythonOperator | Runs Python functions | All data processing |
| Default Args | Retries, timeouts, ownership | DAG configuration |
- Docker Desktop - Download here
- Astro CLI - Install with:
# macOS/Linux curl -sSL https://install.astronomer.io | sudo bash -s # Windows (PowerShell) winget install astronomer.astro
# 1. Clone the repository
git clone https://github.com/vmore2/Finflow.git
cd Finflow
# 2. Start Docker Desktop (make sure it's running!)
# 3. Start Airflow locally
astro dev start
# First time takes ~5 minutes to pull images
# 4. Access the Airflow UI
# Open: http://localhost:8080
# Username: admin
# Password: admin
# 5. Enable and trigger the DAG
# - Find 'finflow_pipeline' in the DAG list
# - Toggle the switch to ON (blue)
# - Click the Play button β Trigger DAG| Where to Look | What You'll See |
|---|---|
| Logs tab | Print statements with analysis |
| XCom tab | Raw JSON data between tasks |
| include/data/ | Generated report.json file |
astro dev stopEdit dags/finflow_pipeline.py:
STOCK_SYMBOLS = ['AAPL', 'GOOGL', 'MSFT', 'NVDA', 'TSLA']
CRYPTO_SYMBOLS = ['bitcoin', 'ethereum', 'solana']PRICE_DROP_THRESHOLD = -10 # Alert if drops more than 10%
RSI_OVERBOUGHT = 75 # Custom overbought level
RSI_OVERSOLD = 25 # Custom oversold levelβ
Fetched AAPL: $195.50 (+2.35%)
β
Fetched GOOGL: $141.20 (-0.85%)
β
Fetched MSFT: $378.90 (+1.20%)
πͺ Fetched bitcoin: $42,500.00 (+3.50%)
πͺ Fetched ethereum: $2,250.00 (+2.10%)
π AAPL: HOLD - Price above 20-day MA (bullish) | RSI 55.2 is neutral
π GOOGL: HOLD - Price below 20-day MA (bearish) | RSI 48.1 is neutral
π MSFT: HOLD - Price above 20-day MA (bullish) | RSI 62.3 is neutral
- Stock price fetching (Yahoo Finance)
- Crypto price fetching (CoinGecko)
- Technical indicators (RSI, MA)
- Branching logic for alerts
- Slack/Email notifications
- PostgreSQL storage
- Historical backtesting
- Airflow Sensors for market hours
MIT License - Feel free to use this for your portfolio!
Vrushket More | GitHub