Quant.Explorer.SchemaStandardizer (quant v0.1.0-alpha.1)

Comprehensive schema standardization for financial data analysis.

This module provides unified parameter handling and output schema standardization across all providers to ensure complete interoperability for financial analysis.

Design Principles

  1. Universal Parameters: All providers accept the same parameter names
  2. Automatic Translation: Provider-specific parameters are translated internally
  3. Consistent Output: All DataFrames have identical schemas regardless of provider
  4. Type Safety: Strong typing and validation for all fields
  5. Timezone Handling: All timestamps normalized to UTC with timezone info

Summary

Functions

Standardizes historical data DataFrame to consistent schema.

Standardizes query parameters across all providers.

Standardizes quote data DataFrame to consistent schema.

Standardizes search results DataFrame to consistent schema.

Lists all supported currencies.

Lists all supported standard intervals.

Lists all supported standard periods.

Validates parameter compatibility with provider.

Functions

standardize_history_schema(df, opts \\ [])

@spec standardize_history_schema(
  Explorer.DataFrame.t(),
  keyword()
) :: {:ok, Explorer.DataFrame.t()} | {:error, term()}

Standardizes historical data DataFrame to consistent schema.

Standard Historical Data Schema

  • symbol (string): Stock/crypto symbol
  • timestamp (datetime): UTC timestamp with timezone info
  • open (f64): Opening price
  • high (f64): Highest price
  • low (f64): Lowest price
  • close (f64): Closing price
  • volume (s64): Trading volume
  • adj_close (f64): Adjusted closing price (when available)
  • market_cap (f64): Market capitalization (crypto only)
  • provider (string): Data source provider
  • currency (string): Price currency
  • timezone (string): Original timezone

standardize_params(params, provider)

@spec standardize_params(
  keyword(),
  atom()
) :: {:ok, keyword()} | {:error, term()}

Standardizes query parameters across all providers.

Standard Parameters

  • :interval - Time interval: "1m", "5m", "15m", "30m", "1h", "1d", "1w", "1mo"
  • :period - Time period: "1d", "5d", "1mo", "3mo", "6mo", "1y", "2y", "5y", "10y", "max"
  • :limit - Number of data points to return (integer)
  • :start_date - Start date (Date, DateTime, or ISO string)
  • :end_date - End date (Date, DateTime, or ISO string)
  • :currency - Base currency for crypto quotes: "usd", "eur", "btc", "eth"
  • :adjusted - Whether to use adjusted prices (boolean, default: true)
  • :api_key - API key for authentication

Returns

{:ok, standardized_params} or {:error, reason}

standardize_quote_schema(df, opts \\ [])

@spec standardize_quote_schema(
  Explorer.DataFrame.t(),
  keyword()
) :: {:ok, Explorer.DataFrame.t()} | {:error, term()}

Standardizes quote data DataFrame to consistent schema.

Standard Quote Data Schema

  • symbol (string): Stock/crypto symbol
  • price (f64): Current price
  • change (f64): Absolute price change
  • change_percent (f64): Percentage change
  • volume (s64): Current/24h volume
  • high_24h (f64): 24-hour high price
  • low_24h (f64): 24-hour low price
  • market_cap (f64): Market capitalization (when available)
  • timestamp (datetime): UTC timestamp
  • provider (string): Data source provider
  • currency (string): Quote currency
  • market_state (string): Market state (open/closed/pre/post)

standardize_search_schema(df, opts \\ [])

@spec standardize_search_schema(
  Explorer.DataFrame.t(),
  keyword()
) :: {:ok, Explorer.DataFrame.t()} | {:error, term()}

Standardizes search results DataFrame to consistent schema.

Standard Search Results Schema

  • symbol (string): Trading symbol
  • name (string): Full company/asset name
  • type (string): Asset type (stock, etf, crypto, forex, index)
  • exchange (string): Primary exchange
  • currency (string): Trading currency
  • country (string): Country/region
  • sector (string): Business sector (when available)
  • industry (string): Industry classification (when available)
  • market_cap (f64): Market capitalization (when available)
  • provider (string): Data source provider
  • match_score (f64): Search relevance score (0.0 - 1.0)

supported_currencies()

@spec supported_currencies() :: [String.t()]

Lists all supported currencies.

supported_intervals()

@spec supported_intervals() :: [String.t()]

Lists all supported standard intervals.

supported_periods()

@spec supported_periods() :: [String.t()]

Lists all supported standard periods.

validate_provider_support(params, provider)

@spec validate_provider_support(
  keyword(),
  atom()
) :: :ok | {:error, term()}

Validates parameter compatibility with provider.