Python SDK for financial data and visualization
Project description
finsdk
Python SDK for financial data and visualization.
Get economic indicators, stock prices, and create beautiful charts with just a few lines of code.
Installation
pip install finsdk
Quick Start
import finsdk
# Set your API key (or use SAVVY_API_KEY environment variable)
finsdk.configure(api_key="sk_...")
# Fetch economic data (returns pandas DataFrame)
df = finsdk.economic_data.fetch("UNRATE", start="2020-01-01")
print(df.head())
# date value
# 0 2020-01-01 3.6
# 1 2020-02-01 3.5
# 2 2020-03-01 4.4
# Fetch stock data
df = finsdk.stock_data.fetch("AAPL", period="1y")
# Create a visualization
chart = finsdk.visualize(df, "Stock price over time")
print(chart.url) # https://savvy-mcp.com/c/abc123
Features
Economic Data
Access data from 20+ sources including FRED, World Bank, IMF, ECB, and more:
# US unemployment rate
df = finsdk.economic_data.fetch("UNRATE")
# GDP growth with date range
df = finsdk.economic_data.fetch("GDP", start="2010-01-01", end="2023-12-31")
# Search for data series
results = finsdk.economic_data.search("inflation")
for r in results:
print(f"{r['provider']}: {r['series_id']} - {r['name']}")
# Compare across countries
df = finsdk.economic_data.compare("unemployment", ["US", "Germany", "Japan"])
Stock Data
Get stock prices from Yahoo Finance:
# Historical data
df = finsdk.stock_data.fetch("AAPL", period="1y")
df = finsdk.stock_data.fetch("MSFT", period="5y", interval="1wk")
# Current quote
quote = finsdk.stock_data.quote("AAPL")
print(f"AAPL: ${quote['price']:.2f} ({quote['change_percent']:+.2f}%)")
Cryptocurrency Data
# Bitcoin price history
df = finsdk.crypto_data.fetch("BTC-USD", period="1y")
# Ethereum quote
quote = finsdk.crypto_data.quote("ETH")
Visualization
Create charts with natural language:
# Simple visualization
chart = finsdk.visualize(df, "Line chart of stock price over time")
# With options
chart = finsdk.visualize(
df,
"Show closing prices with a trendline",
title="AAPL Stock Price",
theme="executive",
)
# Access chart URLs
print(chart.url) # Interactive HTML
print(chart.png) # PNG image
print(chart.svg) # SVG image
print(chart.python) # Python code
Configuration
import finsdk
# Option 1: Use configure()
finsdk.configure(api_key="sk_...")
# Option 2: Environment variable (recommended for production)
# export SAVVY_API_KEY=sk_...
# Option 3: Custom API URL (for development)
finsdk.configure(api_key="sk_...", api_url="https://custom.api.com")
# Read current config
print(finsdk.api_key) # Returns configured key
Error Handling
from finsdk import SavvyError, AuthenticationError, DataNotFoundError
try:
df = finsdk.economic_data.fetch("INVALID_SERIES")
except DataNotFoundError as e:
print(f"Series not found: {e.series_id}")
except AuthenticationError:
print("Invalid API key")
except SavvyError as e:
print(f"API error: {e}")
Data Sources
| Provider | Data Types | Example |
|---|---|---|
| FRED | US economic indicators | UNRATE, GDP, CPIAUCSL |
| World Bank | Global development | NY.GDP.MKTP.CD |
| IMF | Forecasts | gdp_growth |
| ECB | Eurozone rates | EONIA, EURUSD |
| Yahoo Finance | Stocks, ETFs, crypto | AAPL, SPY, BTC-USD |
| Zillow | Housing data | ZHVI:San Francisco |
| And 15+ more... |
Requirements
- Python 3.9+
- pandas
- httpx
Links
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file finsdk-0.3.0.tar.gz.
File metadata
- Download URL: finsdk-0.3.0.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecf63ea1fe1fa558b63e1e055af41da1766d0cc6a2c07c08fef0c4b9967a9f12
|
|
| MD5 |
be1c9ea633632d27ee133311574f57f8
|
|
| BLAKE2b-256 |
5c639d90dc156d92120f580ef60d578a8a32cbb2ce0b6d1fc5008c33aaf91710
|
File details
Details for the file finsdk-0.3.0-py3-none-any.whl.
File metadata
- Download URL: finsdk-0.3.0-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ed20555a5b7c94e2003ae3d2c59d3d0c1fa59b967f2ba96ac5b33afba246816
|
|
| MD5 |
809baee3f9cc1bc8a45d30e170519952
|
|
| BLAKE2b-256 |
def90286c0263fff411f76c3dd68d0a74d1e37ea29521c90f14a76fe4d125af9
|