finance-query v3.0.0

Finance Query

Finance Query

Crates.io Documentation Build Status License: MIT

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 from Yahoo Finance (default) and additional providers via a multi-provider architecture.

A free hosted API is available at finance-query.com — no setup required!

It is designed to be used in three ways:


Documentation#

Getting Started#

For installation instructions and a quick start guide, see Getting Started.

Reference#

Getting Started#

The fq command-line tool lives in its own repository: Verdenroz/fq-cli.

bash
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/Verdenroz/fq-cli/releases/latest/download/fq-cli-installer.sh | sh

Quick Start#

bash
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#

See Verdenroz/fq-cli for installation options, the full command reference, and examples.

Getting Started#

Run the server locally (requires Rust):

bash
git clone https://github.com/Verdenroz/finance-query.git
cd finance-query
make serve  # Compiles and runs v2 server

Or run the full stack with Docker Compose:

bash
docker compose up -d  # Starts v1 (port 8002), v2 (port 8001), Redis, Caddy, and the full monitoring stack

Reference#


Example Usage#

Finance Query is ready to use out of the box. Here's how to get stock data:

rust
use finance_query::{Ticker, Interval, TimeRange, format::Raw};

#[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::<Raw>().await?;
    println!("{} price: ${:.2}", quote.symbol, quote.regular_market_price.unwrap_or(0.0));

    // Get historical charts
    let chart = ticker.chart(Interval::OneDay, TimeRange::OneMonth).await?;
    println!("Retrieved {} candles", chart.candles.len());

    Ok(())
}
bash
# 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
bash
# 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"
javascript
// 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);
};

This library fetches data from Yahoo Finance. Use responsibly and be aware of Yahoo's rate limits and terms of service.

built with cargo soothfast docs build source