Skip to content
vmore2Public

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

2 Commits

Folders and files

Repository files navigation

πŸ“ˆ FinFlow: Financial Intelligence Pipeline

An automated data pipeline that fetches real-time stock and cryptocurrency prices, performs technical analysis, and generates trading signals using Apache Airflow.

Python Airflow Astro


πŸ“‹ Problem Definition

The Challenge

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

The Solution

FinFlow automates the entire process:

  1. Fetches prices from Yahoo Finance (stocks) and CoinGecko (crypto)
  2. Calculates technical indicators (RSI, Moving Averages)
  3. Generates trading signals (BUY / SELL / HOLD)
  4. Alerts when significant price movements occur

All scheduled to run automatically during market hours (Mon-Fri, 9 AM).


πŸ—οΈ Architecture

High-Level Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         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) β”‚           β”‚  β”‚
β”‚  β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Project Structure

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

🧠 Logic & Technical Indicators

Moving Average (MA)

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 πŸ“ˆ

RSI (Relative Strength Index)

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

Signal Generation Logic

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"

πŸ”§ Key Airflow Concepts Used

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

πŸš€ How to Run

Prerequisites

  1. Docker Desktop - Download here
  2. Astro CLI - Install with:
    # macOS/Linux
    curl -sSL https://install.astronomer.io | sudo bash -s
    
    # Windows (PowerShell)
    winget install astronomer.astro

Step-by-Step

# 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

Viewing Results

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

Stop the Environment

astro dev stop

βš™οΈ Configuration

Add More Assets

Edit dags/finflow_pipeline.py:

STOCK_SYMBOLS = ['AAPL', 'GOOGL', 'MSFT', 'NVDA', 'TSLA']
CRYPTO_SYMBOLS = ['bitcoin', 'ethereum', 'solana']

Adjust Alert Thresholds

PRICE_DROP_THRESHOLD = -10  # Alert if drops more than 10%
RSI_OVERBOUGHT = 75         # Custom overbought level
RSI_OVERSOLD = 25           # Custom oversold level

πŸ“Š Sample Output

βœ… 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

πŸ›£οΈ Roadmap

  • 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

πŸ“œ License

MIT License - Feel free to use this for your portfolio!


🀝 Author

Vrushket More | GitHub

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages