yf-options 0.2.1

A fast, reliable command-line tool for downloading options chain data from Yahoo Finance. Features include Black-Scholes Greeks calculation (Delta, Gamma, Theta, Vega, Rho), filtering by expiration date, strike range, and ITM/OTM status. Supports multiple symbols with combined output, JSON/CSV export formats, and built-in rate limiting. Ideal for options analysis, volatility screening, and quantitative trading workflows.
Documentation
//! Error types for yf-options
//!
//! Re-exports yf-common errors with tool-specific additions.

use thiserror::Error;
use yf_common::error::YfCommonError;

/// Tool-specific errors for yf-options
#[derive(Error, Debug)]
pub enum YfOptionsError {
    /// Common library error (wraps all yf-common errors)
    #[error(transparent)]
    Common(#[from] YfCommonError),

    /// Invalid strike range format
    #[error("Invalid strike range format: {0}")]
    StrikeRangeError(String),

    /// No options data found
    #[error("No options data found for symbol {0}")]
    NoDataError(String),

    /// API returned error
    #[error("API returned error: {0}")]
    ApiError(String),

    /// Greeks calculation error
    #[error("Greeks calculation error: {0}")]
    #[allow(dead_code)] // Public API - may be used by library consumers
    GreeksError(String),
}

pub type Result<T> = std::result::Result<T, YfOptionsError>;

// Convenience conversions so `?` works seamlessly with common error sources
impl From<std::io::Error> for YfOptionsError {
    fn from(err: std::io::Error) -> Self {
        YfOptionsError::Common(YfCommonError::IoError(err))
    }
}

impl From<serde_json::Error> for YfOptionsError {
    fn from(err: serde_json::Error) -> Self {
        YfOptionsError::Common(YfCommonError::JsonError(err))
    }
}

impl From<reqwest::Error> for YfOptionsError {
    fn from(err: reqwest::Error) -> Self {
        YfOptionsError::Common(YfCommonError::RequestError(err))
    }
}