Finance Query
Finance Query is a Rust library, CLI, and server for financial data, inspired by the popular yfinance Python library. It provides access to real-time quotes, historical charts, technical analysis, and financial statements primarily from Yahoo Finance.
A free hosted API is available at finance-query.com — no setup required!
It is designed to be used in three ways:
- Rust Library: A type-safe crate for direct integration into your Rust projects.
- Command-Line Tool: Interactive
fqtool for market data, analysis, and trading. - REST & WebSocket Server: A standalone service that exposes the library's functionality over HTTP.
Documentation¶
Getting Started¶
For installation instructions and a quick start guide, see Getting Started.
Reference¶
Getting Started¶
Install the command-line tool:
Or download pre-built binaries for Linux, macOS, and Windows.
Quick Start¶
fq quote AAPL # Get a quote
fq stream AAPL TSLA NVDA # Live prices
fq chart AAPL -r 6mo # Interactive chart
fq indicator AAPL --indicator rsi:14 --no-tui # Technical analysis
fq backtest AAPL --preset swing # Backtest strategy
fq dashboard # Interactive dashboard
Reference¶
Example Usage¶
Finance Query is ready to use out of the box. Here's how to get stock data:
use finance_query::{Ticker, Interval, TimeRange};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Get detailed quote for Apple
let ticker = Ticker::builder("AAPL").logo().build().await?;
let quote = ticker.quote().await?;
println!("{} price: ${:?}", quote.symbol, quote.regular_market_price);
// Get historical charts
let chart = ticker.chart(Interval::OneDay, TimeRange::OneMonth).await?;
println!("Retrieved {} candles", chart.candles.len());
Ok(())
}
# Get a stock quote
fq quote AAPL
# Multiple quotes
fq quote AAPL MSFT GOOGL AMZN
# Stream live prices
fq stream AAPL TSLA NVDA
# Interactive price chart
fq chart AAPL -r 6mo
# Technical indicators
fq indicator AAPL --indicator rsi:14 --no-tui
# Backtest a strategy
fq backtest AAPL --preset swing
# Market dashboard
fq dashboard
# Get detailed quote for Apple
curl "https://finance-query.com/v2/quote/AAPL?logo=true"
# Get historical chart data
curl "https://finance-query.com/v2/chart/AAPL?interval=1d&range=1mo"
# Search for symbols
curl "https://finance-query.com/v2/lookup?q=Apple"
# Get predefined screeners
curl "https://finance-query.com/v2/screeners/most-actives"
# Get company news
curl "https://finance-query.com/v2/news/AAPL"
// Connect to WebSocket for real-time updates
const ws = new WebSocket('wss://finance-query.com/v2/stream');
ws.onopen = () => {
console.log('Connected to Finance Query WebSocket');
ws.send(JSON.stringify({
action: 'subscribe',
symbols: ['AAPL', 'NVDA']
}));
};
ws.onmessage = (event) => {
const update = JSON.parse(event.data);
console.log('Real-time update:', update);
};
Legal¶
This library fetches data from Yahoo Finance. Use responsibly and be aware of Yahoo's rate limits and terms of service.