YfinancePipeline
Handles OHLCV and metadata scraping from yfinance. Each method processes one ticker - Airflow does the parallelization.
Component Separation
Pipeline focuses on data scraping. For ticker lists see YfinanceTickers, for validation see YfinanceValidation.
Quick Start
from sec_data_pipeline.yfinance.yfinance_pipeline import YfinancePipeline
from datetime import date
pipeline = YfinancePipeline()
# Download OHLCV data
df = pipeline.scrape_date_range('AAPL', date(2024, 1, 1), date.today())
# Get metadata (50+ fundamental fields)
meta = pipeline.scrape_metadata('AAPL')
Data Scraping
| Type | Configuration | Returns |
|---|---|---|
| OHLCV | auto_adjust=True, flattened MultiIndex |
DataFrame with Date, Open, High, Low, Close, Volume |
| Metadata | 50+ fields via yfinance .info |
Dict with company info, valuation, profitability, analyst coverage |
Adjusted Prices
auto_adjust=True handles stock splits and dividends automatically - no manual adjustments needed
API Reference
Main data pipeline for OHLCV and metadata scraping - Atomic methods (should be bareboned & simple) - No retry logic & debug logging only (maybe error log) NO INFO LOGS! - Each method should download data for one stock (airflow handles parallel execution)
Source code in data_pipeline/sec_data_pipeline/yfinance/yfinance_pipeline.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
scrape_date_range(ticker, start_date, end_date, interval='1d')
Scrape historical data for a specific date range for a single ticker
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
A single ticker symbol |
required |
start_date
|
date
|
Start date |
required |
end_date
|
date
|
End date |
required |
interval
|
str
|
Data interval (1d only) |
'1d'
|
Returns:
| Type | Description |
|---|---|
DataFrame | None
|
Returns a dataframe containing the ohlcv for a single stock |
Source code in data_pipeline/sec_data_pipeline/yfinance/yfinance_pipeline.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
scrape_metadata(ticker)
Scrape fundamental metadata for a single ticker
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ticker
|
str
|
A string for the ticker |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
A dictionary with metadata about the ticker |
Source code in data_pipeline/sec_data_pipeline/yfinance/yfinance_pipeline.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |