### Finance Query CLI: Get Detailed Help Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/installation.md Displays detailed help information for the Finance Query CLI. Use this to understand all available commands and their options. ```bash fq --help fq --help ``` -------------------------------- ### Build and Install Finance Query CLI from Source Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/installation.md Builds and installs the Finance Query CLI from its source code repository. This involves cloning the repository, navigating to the CLI directory, and then using Cargo to install. ```bash git clone https://github.com/Verdenroz/finance-query cd finance-query/finance-query-cli cargo install --path . ``` -------------------------------- ### Verify Finance Query CLI Installation Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/installation.md Checks if the Finance Query CLI has been installed correctly by displaying its version number. This command should be run after installation to confirm success. ```bash fq --version ``` -------------------------------- ### Troubleshoot and Debug Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/examples.md Commands to verify installation, check versioning, and enable verbose logging for diagnosing connection or execution issues. ```bash fq --version RUST_LOG=debug fq quote AAPL fq quote AAPL --verbose ``` -------------------------------- ### Install Finance Query CLI via Cargo Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/installation.md Installs the Finance Query CLI from crates.io using the Cargo package manager. This method requires Rust to be installed on your system. ```bash cargo install finance-query-cli ``` -------------------------------- ### Finance Query CLI: Launch Dashboard Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/installation.md Launches the interactive dashboard for the Finance Query CLI. This provides a comprehensive overview and access to various features. ```bash fq dashboard ``` -------------------------------- ### Install Finance Query CLI via Linux/macOS Script Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/installation.md Installs the Finance Query CLI using a shell script downloaded from GitHub. This is a recommended method for Linux and macOS users. ```bash curl --proto '=https' --tlsv1.2 -LsSf https://github.com/Verdenroz/finance-query/releases/latest/download/finance-query-cli-installer.sh | sh ``` -------------------------------- ### Install Finance Query CLI via Windows PowerShell Script Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/installation.md Installs the Finance Query CLI using a PowerShell script downloaded from GitHub. This is the recommended method for Windows users. ```powershell powershell -c "irm https://github.com/Verdenroz/finance-query/releases/latest/download/finance-query-cli-installer.ps1 | iex" ``` -------------------------------- ### Install Finance Query CLI via Homebrew (macOS) Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/installation.md Installs the Finance Query CLI on macOS using the Homebrew package manager. Ensure Homebrew is installed before running this command. ```bash brew install verdenroz/tap/fq ``` -------------------------------- ### Install and Use Finance Query CLI Source: https://github.com/verdenroz/finance-query/blob/master/README.md Commands for installing the CLI tool on various operating systems and examples of common CLI operations like quoting, charting, and backtesting. ```bash fq quote AAPL MSFT GOOGL fq stream AAPL TSLA NVDA fq chart AAPL -r 6mo fq indicator AAPL --indicator rsi:14 fq backtest AAPL --preset swing ``` -------------------------------- ### Get Company Overview and Financials (Bash) Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/examples.md Demonstrates how to retrieve basic company information, profiles, and financial summaries using the 'fq' command. This includes commands like 'info', 'profile', and 'financials' followed by a company ticker. ```bash fq info AAPL fq profile AAPL foregroundColor fq financials AAPL ``` -------------------------------- ### Configure Network Timeouts and Proxies Source: https://github.com/verdenroz/finance-query/blob/master/docs/library/configuration.md Provides an example of configuring a Ticker instance with custom proxy settings and connection timeouts for corporate network environments. ```rust use finance_query::Ticker; use std::time::Duration; // Configure for corporate network with proxy and longer timeout let ticker = Ticker::builder("AAPL") .proxy("http://corporate-proxy.company.com:8080") .timeout(Duration::from_secs(45)) .build() .await?; ``` -------------------------------- ### Track Multiple Stock Prices (Bash) Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/examples.md Shows how to get current price quotes for multiple stocks simultaneously by listing their tickers after the 'fq quote' command. ```bash fq quote AAPL MSFT GOOGL AMZN META ``` -------------------------------- ### View Company Earnings and Transcripts (Bash) Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/examples.md Provides examples for retrieving earnings data and transcripts for a specific company and quarter using 'fq earnings' and 'fq transcript'. ```bash fq earnings AAPL foregroundColor fq transcript AAPL --quarter 2024-Q1 ``` -------------------------------- ### Combined SEC EDGAR Workflow Example (Bash) Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/examples.md Illustrates a combined workflow for SEC EDGAR research using 'fq edgar' and 'fq facts'. This includes browsing recent filings, retrieving financial facts, searching for specific disclosures, and comparing financial data with competitors. Requires setting the EDGAR_EMAIL environment variable. ```bash export EDGAR_EMAIL="analyst@example.com" # Or persist it once fq edgar --email analyst@example.com # 1. Browse recent filings fq edgar TSLA # 2. Get financial facts fq facts TSLA --concept Revenue fq facts TSLA --concept Assets # 3. Search for specific disclosures fq edgar -s "risk factors" --start-date 2024-01-01 # 4. Compare with competitors fq facts F --concept Revenue # Ford fq facts GM --concept Revenue # GM ``` -------------------------------- ### FRED Setup and Initialization Source: https://github.com/verdenroz/finance-query/blob/master/docs/library/fred.md Instructions on how to initialize the FRED client with an API key and optional timeout. ```APIDOC ## FRED Setup ### Description Initialize the FRED client with your API key. This should be called once at application startup. ### Method `fred::init` or `fred::init_with_timeout` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust use finance_query::fred; // Initialize with API key fred::init("your-fred-api-key")?; // Optional: initialize with a custom timeout use std::time::Duration; fred::init_with_timeout("your-fred-api-key", Duration::from_secs(60))?; ``` ### Response #### Success Response (200) Initialization is successful. #### Response Example None (success is indicated by the absence of an error) !!! warning Calling `init` more than once returns an error. Call it exactly once per process, typically at startup. ``` -------------------------------- ### Documenting Public APIs in Rust Source: https://github.com/verdenroz/finance-query/blob/master/docs/development/contributing.md Shows how to document public Rust functions using doc comments, including a basic example and a more detailed example with a usage scenario and a `no_run` doctest. ```rust /// Fetches the latest quote for the ticker. /// /// # Example /// /// ```no_run /// use finance_query::Ticker; /// /// let ticker = Ticker::builder("AAPL").logo().build().await?; /// let quote = ticker.quote().await?; /// println!("Price: ${}", quote.regular_market_price); /// ``` pub async fn quote(&self) -> Result { // ... } ``` -------------------------------- ### Browse SEC EDGAR Company Filings Interactively (Bash) Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/examples.md Demonstrates how to interactively browse company filings on the SEC EDGAR database using the 'fq edgar' command. It covers starting with an empty prompt or specifying a company ticker. Requires setting the EDGAR_EMAIL environment variable. ```bash # Set your email (required by SEC) export EDGAR_EMAIL="analyst@example.com" # Option 1: Start with empty search prompt fq edgar # Type your search query and press Enter # Option 2: Browse specific company fq edgar AAPL # Navigate with arrow keys, press '/' to search, 'f' to filter, Enter to open # Or persist it once fq edgar --email analyst@example.com ``` -------------------------------- ### Analyze SEC EDGAR XBRL Financial Data (Bash) Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/examples.md Provides examples for analyzing XBRL financial data from SEC EDGAR filings using 'fq facts'. Demonstrates fetching all key facts, specific concepts (like Revenue), filtering by unit and year, comparing multiple concepts, and exporting data to CSV. Requires setting the EDGAR_EMAIL environment variable. ```bash export EDGAR_EMAIL="analyst@example.com" # Or persist it once fq facts --email analyst@example.com AAPL # Get all key financial facts fq facts AAPL # Get specific concept (Revenue) fq facts AAPL --concept Revenue # Filter by fiscal year and unit fq facts AAPL --concept Revenue --unit USD --limit 5 # Multiple concepts for comparison fq facts AAPL --concept Assets -o json fq facts AAPL --concept Liabilities -o json # Export to CSV for analysis fq facts MSFT --concept NetIncomeLoss --unit USD -o csv > msft_income.csv ``` -------------------------------- ### Backtesting Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/examples.md Commands for testing trading strategies on historical data, with presets and export options. ```APIDOC ## Backtesting ### Test a Simple Strategy Run backtests for trading strategies on historical stock data. Supports interactive TUI and predefined presets. **Method:** CLI Command **Endpoint:** N/A (Local CLI Tool) **Parameters:** #### CLI Arguments - **`backtest `** - Initiates a backtest for the specified stock. - **`--preset `** (string, optional) - Applies a predefined strategy preset (e.g., `swing`, `trend`, `mean-reversion`). - **`--json`** (flag) - Outputs backtest results in JSON format. - **`--no-tui`** (flag) - Disables the interactive TUI. **Usage Examples:** ```bash # Interactive backtest TUI for AAPL Chirurgien backtest AAPL # Run backtest using the 'swing' trading preset Chirurgien backtest AAPL --preset swing # Run backtest using the 'trend' following preset Chirurgien backtest AAPL --preset trend # Run backtest using the 'mean-reversion' preset Chirurgien backtest AAPL --preset mean-reversion ``` ### Export Results Export backtest results to JSON format for programmatic analysis. **Method:** CLI Command **Endpoint:** N/A (Local CLI Tool) **Parameters:** #### CLI Arguments - **`backtest `** - Initiates a backtest. - **`--preset `** (string, optional) - Specifies the strategy preset. - **`--json`** (flag) - Outputs results in JSON format. - **`--no-tui`** (flag) - Disables the interactive TUI. **Usage Examples:** ```bash # Run backtest with 'swing' preset and export results to JSON Chirurgien backtest AAPL --preset swing --json > backtest_results.json # Run backtest with 'aggressive' preset without TUI Chirurgien backtest AAPL --no-tui --preset aggressive ``` ``` -------------------------------- ### Finance Query CLI: Get Stock Quote Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/installation.md Retrieves the current stock quote for a specified ticker symbol. This is a basic command to quickly get financial data. ```bash fq quote AAPL ``` -------------------------------- ### Run finance-query-server using Make or Cargo Source: https://github.com/verdenroz/finance-query/blob/master/server/README.md Instructions for running the finance-query-server either from the repository root using a make command or directly using Cargo. ```bash # From repository root make serve # Or directly car go run -p finance-query-server ``` -------------------------------- ### Configure finance-query-server with environment variables Source: https://github.com/verdenroz/finance-query/blob/master/server/README.md Example configuration for the finance-query-server using a .env file. It shows essential variables like PORT and RUST_LOG, and optional ones for Redis, rate limiting, and EDGAR email. ```bash PORT=8000 RUST_LOG=info REDIS_URL=redis://localhost:6379 # Optional RATE_LIMIT_PER_MINUTE=60 # Optional, default 60 EDGAR_EMAIL=you@example.com # Required for EDGAR endpoints ``` -------------------------------- ### Compare Stock Performance with Charts (Bash) Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/examples.md Illustrates how to generate historical price charts for stocks over a specified period (e.g., 1 year) and export them as CSV files for comparison in external tools. ```bash # Get 1-year charts for comparison foregroundColor fq chart AAPL -r 1y -o csv > aapl_1y.csv foregroundColor fq chart MSFT -r 1y -o csv > msft_1y.csv # Then compare in your preferred tool ``` -------------------------------- ### Set and Manage Stock Price Alerts (Bash) Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/examples.md Explains how to set up price-based alerts for stocks using 'fq alerts'. Covers adding alerts for price thresholds (above/below), percentage changes, listing existing alerts, and continuously monitoring them. ```bash # Open alerts TUI foregroundColor fq alerts # Alert when Apple hits $200 foregroundColor fq alerts add AAPL price-above:200 # Alert when Tesla drops below $150 foregroundColor fq alerts add TSLA price-below:150 # Alert on 5%+ change foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor foregroundColor ``` -------------------------------- ### Stream Live Stock Prices (Bash) Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/examples.md Demonstrates how to stream live price updates for a list of specified stocks using the 'fq stream' command. ```bash fq stream AAPL TSLA NVDA PLTR ``` -------------------------------- ### Finance Query CLI: View Interactive Stock Chart Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/installation.md Displays an interactive chart for a given stock ticker symbol. This allows for visual analysis of stock performance. ```bash fq chart AAPL ``` -------------------------------- ### Finance Query CLI: Stream Live Stock Prices Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/installation.md Streams live price updates for specified stock ticker symbols. This command provides real-time market data. ```bash fq stream AAPL TSLA ``` -------------------------------- ### Initialize Tickers with Regional Settings Source: https://github.com/verdenroz/finance-query/blob/master/docs/library/configuration.md Illustrates how to use the Ticker builder to specify regions for international stocks and perform parallel quote fetching. ```rust use finance_query::{Ticker, Region}; // US stock let apple = Ticker::builder("AAPL") .region(Region::UnitedStates) .logo() .build() .await?; // Taiwan stock let tsmc = Ticker::builder("2330.TW") .region(Region::Taiwan) .logo() .build() .await?; // German stock let sap = Ticker::builder("SAP.DE") .region(Region::Germany) .logo() .build() .await?; // Fetch quotes in parallel let (apple_quote, tsmc_quote, sap_quote) = tokio::join!( apple.quote(), tsmc.quote(), sap.quote() ); ``` -------------------------------- ### Finance Query CLI: View Multiple Stock Quotes Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/installation.md Retrieves current stock quotes for multiple ticker symbols simultaneously. This is useful for comparing prices of several stocks. ```bash fq quote AAPL MSFT GOOGL TSLA ``` -------------------------------- ### Build and run finance-query-server with Docker Source: https://github.com/verdenroz/finance-query/blob/master/server/README.md Commands to build a Docker image for the finance-query-server and then run it as a container. It maps port 8000 for external access. ```bash docker build -t finance-query-server -f server/Dockerfile . docker run -p 8000:8000 finance-query-server ``` -------------------------------- ### Access Finance Data via REST API Source: https://github.com/verdenroz/finance-query/blob/master/docs/index.md This demonstrates how to interact with the Finance Query REST API using curl. Examples include fetching detailed quotes with logos, historical chart data, searching for symbols, retrieving predefined screeners, and getting company news. ```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" ``` -------------------------------- ### Get Options Chain Source: https://github.com/verdenroz/finance-query/blob/master/docs/server/mcp-html/index.html Retrieves the options chain for a specified stock symbol. An expiration timestamp can be provided to get a specific expiry; otherwise, the nearest expiration is used. ```APIDOC ## GET /options ### Description Get the options chain for a symbol. Provide an expiration timestamp to get a specific expiry, or omit for the nearest expiration. ### Method GET ### Endpoint /options ### Parameters #### Query Parameters - **symbol** (string) - Required - Stock ticker symbol - **expiration** (integer) - Optional - Expiration date as Unix timestamp in seconds (optional; defaults to nearest expiration) ### Request Example ``` GET /options?symbol=TSLA&expiration=1700000000 ``` ### Response #### Success Response (200) - **options_chain** (object) - An object detailing call and put options for the specified expiration. #### Response Example ```json { "options_chain": { "expiration_date": "2023-11-17", "calls": [ { "strike": 200.00, "last_price": 5.50, "volume": 1000 } ], "puts": [ { "strike": 190.00, "last_price": 3.20, "volume": 800 } ] } } ``` ``` -------------------------------- ### Idiomatic Rust Code Example Source: https://github.com/verdenroz/finance-query/blob/master/docs/development/contributing.md Illustrates idiomatic Rust programming practices by showing a clear and concise implementation of an async function to fetch quote data, contrasting it with an over-engineered alternative. ```rust // Good - simple and clear pub async fn quote(&self) -> Result { self.get_quote_data().await } // Bad - over-engineered pub async fn quote(&self) -> Result> { match self.get_quote_data().await { Ok(data) => Ok(data), Err(e) => Err(Box::new(e)), } } ``` -------------------------------- ### Unit Test Example in Rust Source: https://github.com/verdenroz/finance-query/blob/master/docs/development/contributing.md Provides an example of a unit test in Rust using the `tokio::test` attribute to test the `Ticker::builder` functionality, asserting the correctness of the built ticker's symbol. ```rust #[tokio::test] async fn test_ticker_builder() { let ticker = Ticker::builder("AAPL") .region(Region::UnitedStates) .build() .await .unwrap(); assert_eq!(ticker.symbol(), "AAPL"); } ``` -------------------------------- ### Clone and Set Up Development Environment (Bash) Source: https://github.com/verdenroz/finance-query/blob/master/docs/development/contributing.md Clones the FinanceQuery repository and installs development dependencies, including Rust tooling like rustfmt, clippy, and prek, and sets up pre-commit hooks. ```bash git clone https://github.com/Verdenroz/finance-query.git cd finance-query make install-dev ``` -------------------------------- ### Doc Test Example with `no_run` in Rust Source: https://github.com/verdenroz/finance-query/blob/master/docs/development/contributing.md Shows a documentation test in Rust using `no_run` for examples that depend on external resources like network access. This prevents the doctest runner from attempting to execute code that would fail in a standard test environment. ```rust /// # Example /// /// ```no_run /// # use finance_query::Ticker; /// # async fn example() -> Result<(), Box> { /// let ticker = Ticker::builder("AAPL").logo().build().await?; /// let quote = ticker.quote().await?; /// # Ok(()) /// # } /// ``` ``` -------------------------------- ### GET /v2/crypto/coins Source: https://github.com/verdenroz/finance-query/blob/master/docs/server/openapi-html/index.html Retrieves the top cryptocurrencies by market capitalization. ```APIDOC ## GET /v2/crypto/coins ### Description Fetch the top N cryptocurrencies by market cap from CoinGecko. ### Method GET ### Endpoint /v2/crypto/coins ### Parameters #### Query Parameters - **vs_currency** (string) - Optional - Quote currency (default: usd) - **count** (integer) - Optional - Number of coins to return (max 250, default: 50) ### Response #### Success Response (200) - **Array** (object) - List of coin market data objects #### Response Example [ { "id": "bitcoin", "symbol": "btc", "current_price": 50000 } ] ``` -------------------------------- ### Check Analyst Recommendations and Ratings (Bash) Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/examples.md Shows how to fetch analyst recommendations and ratings for a given company ticker using 'fq recommendations' and 'fq grades'. ```bash fq recommendations AAPL foregroundColor fq grades AAPL ``` -------------------------------- ### GET /v2/health Source: https://github.com/verdenroz/finance-query/blob/master/docs/server/openapi-html/index.html Checks the operational status and version of the API. ```APIDOC ## GET /v2/health ### Description Check API health status and retrieve current server version. ### Method GET ### Endpoint /v2/health ### Response #### Success Response (200) - **status** (string) - API health status (e.g., "healthy") - **version** (string) - Current API version - **timestamp** (string) - Current server timestamp (ISO 8601) #### Response Example { "status": "healthy", "version": "2.1.0", "timestamp": "2023-10-27T10:00:00Z" } ``` -------------------------------- ### Running Tests in FinanceQuery (Bash) Source: https://github.com/verdenroz/finance-query/blob/master/docs/development/contributing.md Demonstrates how to run different sets of tests for the FinanceQuery project, including fast tests, all tests, library-specific tests, server-specific tests, and ignored integration tests that require network access. ```bash # Run tests as you work make test-fast # Quick tests only make test # All tests including network calls # Library changes cargo test -p finance-query # Server changes cargo test -p finance-query-server # Specific test cargo test test_ticker_quote # Integration tests (makes real API calls) cargo test -- --ignored ``` -------------------------------- ### Interact with Finance Query API via CLI Source: https://github.com/verdenroz/finance-query/blob/master/README.md Demonstrates how to use curl and wscat to fetch quotes, stream real-time data, and access the GraphQL playground from the hosted API. ```bash curl "https://finance-query.com/v2/quote/AAPL" wscat -c "wss://finance-query.com/v2/stream" open "https://finance-query.com/graphql" ``` -------------------------------- ### Parameter Optimization via Grid and Bayesian Search Source: https://github.com/verdenroz/finance-query/blob/master/docs/library/backtesting.md Demonstrates exhaustive grid search for parallel parameter tuning and Bayesian search for efficient adaptive optimization. These methods help identify the best strategy parameters based on defined metrics. ```rust // Grid Search Example let report = GridSearch::new() .param("fast", ParamRange::int_range(5, 20, 5)) .param("slow", ParamRange::int_range(20, 60, 10)) .optimize_for(OptimizeMetric::SharpeRatio) .run("AAPL", &candles, &config, |params| { SmaCrossover::new( params["fast"].as_int() as usize, params["slow"].as_int() as usize, ) })?; // Bayesian Search Example let report = BayesianSearch::new() .param("fast", ParamRange::int_bounds(5, 50)) .param("slow", ParamRange::int_bounds(20, 200)) .max_evaluations(100) .optimize_for(OptimizeMetric::SharpeRatio) .run("AAPL", &candles, &config, |params| { SmaCrossover::new( params["fast"].as_int() as usize, params["slow"].as_int() as usize, ) })?; ``` -------------------------------- ### GET /v2/metrics Source: https://github.com/verdenroz/finance-query/blob/master/docs/server/openapi-html/index.html Exposes system metrics in Prometheus format for monitoring purposes. ```APIDOC ## GET /v2/metrics ### Description Exposes Prometheus-format metrics for monitoring, including request counts, latencies, and error rates. ### Method GET ### Endpoint /v2/metrics ### Response #### Success Response (200) - **body** (string) - Prometheus exposition format metrics ``` -------------------------------- ### GET /v2/ping Source: https://github.com/verdenroz/finance-query/blob/master/docs/server/openapi-html/index.html A simple connectivity test endpoint that returns a pong message. ```APIDOC ## GET /v2/ping ### Description Simple ping-pong endpoint to verify connectivity. ### Method GET ### Endpoint /v2/ping ### Response #### Success Response (200) - **message** (string) - Should return "pong" #### Response Example { "message": "pong" } ``` -------------------------------- ### Get Historical Stock Split History Source: https://github.com/verdenroz/finance-query/blob/master/docs/server/mcp-html/index.html Retrieves the historical stock split history for a specified stock symbol. ```APIDOC ## GET /splits ### Description Get historical stock split history for a symbol. ### Method GET ### Endpoint /splits ### Parameters #### Query Parameters - **symbol** (string) - Required - Stock ticker symbol - **range** (string) - Optional - Time range: 1y|2y|5y|10y|max (default: max) ### Request Example ``` GET /splits?symbol=AAPL&range=5y ``` ### Response #### Success Response (200) - **splits** (array) - An array of split event objects, each detailing the split ratio and date. #### Response Example ```json { "splits": [ { "date": "2020-08-31", "ratio": "4:1" } ] } ``` ``` -------------------------------- ### GET /crypto/coins Source: https://github.com/verdenroz/finance-query/blob/master/docs/library/crypto.md Retrieves a list of top cryptocurrencies ordered by market capitalization. ```APIDOC ## GET /crypto/coins ### Description Fetches the top cryptocurrencies based on market capitalization in a specified quote currency. ### Method GET ### Endpoint crypto::coins(vs_currency, count) ### Parameters #### Query Parameters - **vs_currency** (String) - Required - The target fiat or crypto currency (e.g., "usd", "btc"). - **count** (u32) - Required - Number of coins to return (max 250). ### Request Example ```rust crypto::coins("usd", 10) ``` ### Response #### Success Response (200) - **List** (Array) - A list of coin objects containing price, market cap, and rank data. #### Response Example ```json [ { "id": "bitcoin", "symbol": "BTC", "name": "Bitcoin", "current_price": 65000.0, "market_cap_rank": 1 } ] ``` ``` -------------------------------- ### Technical Analysis Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/examples.md Commands for calculating and exporting technical indicators for stocks. ```APIDOC ## Technical Analysis ### Calculate Indicators for a Stock Compute various technical indicators for a given stock ticker with customizable parameters. **Method:** CLI Command **Endpoint:** N/A (Local CLI Tool) **Parameters:** #### CLI Arguments - **`indicator `** - Calculates technical indicators. - **`--indicator :`** (string, repeatable) - Specifies the indicator and its parameters (e.g., `rsi:14`, `sma:20,50,200`). - **`-i `** (string, optional) - Sets the data interval (e.g., `1d` for daily). - **`-r `** (string, optional) - Sets the historical data range (e.g., `6mo` for 6 months). - **`--no-tui`** (flag) - Disables the interactive TUI and outputs directly. - **`--latest`** (flag) - Retrieves only the latest indicator value. **Usage Examples:** ```bash # Interactive TUI to choose indicators for AAPL Chirurgien indicator AAPL # Calculate RSI(14) without TUI Chirurgien indicator AAPL --indicator rsi:14 --no-tui # Calculate multiple SMAs (20, 50, 200) for daily data over 6 months Chirurgien indicator AAPL --indicator sma:20,50,200 -i 1d -r 6mo --no-tui # Calculate MACD(12,26,9) Chirurgien indicator AAPL --indicator macd:12,26,9 --no-tui # Calculate Bollinger Bands (20, 2) for daily data over 3 months Chirurgien indicator AAPL --indicator bollinger:20,2 -i 1d -r 3mo --no-tui ``` ### Export Indicator Data Export calculated technical indicator data to CSV format for further analysis. **Method:** CLI Command **Endpoint:** N/A (Local CLI Tool) **Parameters:** #### CLI Arguments - **`indicator `** - Calculates technical indicators. - **`--indicator :`** (string, repeatable) - Specifies the indicator and its parameters. - **`-i `** (string, optional) - Sets the data interval. - **`-r `** (string, optional) - Sets the historical data range. - **`-o `** (string, optional) - Specifies the output format, use `csv`. - **`--no-tui`** (flag) - Disables the interactive TUI. **Usage Examples:** ```bash # Export RSI(14) data for AAPL over 1 year to CSV Chirurgien indicator AAPL --indicator rsi:14 -i 1d -r 1y -o csv --no-tui > aapl_indicators.csv # Export SMA(20,50,200) data to CSV Chirurgien indicator AAPL --indicator sma:20,50,200 -o csv --no-tui > sma_analysis.csv ``` ### Get Latest Indicator Values Retrieve only the most recent value for a specified technical indicator. **Method:** CLI Command **Endpoint:** N/A (Local CLI Tool) **Parameters:** #### CLI Arguments - **`indicator `** - Calculates technical indicators. - **`--indicator :`** (string) - Specifies the indicator and its parameters. - **`--latest`** (flag) - Retrieves only the latest value. - **`--no-tui`** (flag) - Disables the interactive TUI. **Usage Examples:** ```bash # Get the latest RSI(14) value for AAPL Chirurgien indicator AAPL --indicator rsi:14 --latest --no-tui ``` ``` -------------------------------- ### Execute Backtest via CLI Source: https://github.com/verdenroz/finance-query/blob/master/docs/cli/commands.md Run trading strategy backtests using the fq command-line tool. Supports interactive TUI mode, loading predefined strategy presets, and exporting results directly to JSON. ```bash fq backtest AAPL # Interactive backtest TUI fq backtest AAPL --preset swing # Load swing trading preset into TUI fq backtest AAPL --preset rsi --no-tui # Run preset directly, skip TUI fq backtest AAPL --json # Output JSON instead of TUI fq backtest AAPL --preset trend --json # JSON output with preset ``` -------------------------------- ### GET /v2/risk/{symbol} Source: https://github.com/verdenroz/finance-query/blob/master/docs/server/openapi-html/index.html Calculates portfolio risk metrics for a specific financial symbol. ```APIDOC ## GET /v2/risk/{symbol} ### Description Compute portfolio risk metrics including VaR, Sharpe/Sortino/Calmar ratios, beta, and max drawdown. ### Method GET ### Endpoint /v2/risk/{symbol} ### Parameters #### Path Parameters - **symbol** (string) - Required - The ticker symbol (e.g., AAPL) #### Query Parameters - **interval** (string) - Optional - Price interval (1m, 5m, 1h, 1d, etc. Default: 1d) - **range** (string) - Optional - Lookback period (1d, 1mo, 1y, etc. Default: 1mo) - **benchmark** (string) - Optional - Benchmark symbol for beta calculation ### Response #### Success Response (200) - **var_95** (number) - Historical 95% Value at Risk - **sharpe** (number) - Sharpe ratio - **beta** (number) - Beta relative to benchmark - **max_drawdown** (number) - Maximum peak-to-trough drawdown #### Response Example { "var_95": 0.025, "sharpe": 1.5, "beta": 1.1, "max_drawdown": 0.15 } ``` -------------------------------- ### Perform Batch Operations with Tickers Source: https://github.com/verdenroz/finance-query/blob/master/docs/library/configuration.md Illustrates how to fetch data for multiple stock symbols simultaneously using the Tickers builder pattern, which supports the same configuration options as the single Ticker builder. ```rust use finance_query::{Tickers, Region}; use std::time::Duration; let tickers = Tickers::builder(vec!["2330.TW", "2317.TW", "2454.TW"]) .region(Region::Taiwan) .timeout(Duration::from_secs(60)) .build() .await?; ``` -------------------------------- ### GET /macro/treasury Source: https://github.com/verdenroz/finance-query/blob/master/docs/server/openapi-html/index.html Retrieves daily US Treasury yield curve data from treasury.gov. ```APIDOC ## GET /macro/treasury ### Description Fetch daily US Treasury yield curve data. Records are returned sorted from newest to oldest. ### Method GET ### Endpoint /macro/treasury ### Parameters #### Query Parameters - **year** (integer) - Optional - Calendar year (defaults to current year) ### Request Example GET /macro/treasury?year=2026 ### Response #### Success Response (200) - **date** (string) - Record date - **y1m - y30** (number) - Yield values for various maturities (1 month to 30 years) #### Response Example [ { "date": "02/20/2026", "y10": 4.25 } ] ```