Search Shortcut cmd + k | ctrl + k
finance

SQL-native quant finance functions for DuckDB

Maintainer(s): leonardovida

Installing and Loading

INSTALL finance FROM community;
LOAD finance;

Example

INSTALL finance FROM community;
LOAD finance;
SELECT
  fin_bsm_price('call', 100.0, 100.0, 1.0, 0.05, 0.20) AS price,
  fin_simple_return(105.0, 100.0) AS simple_return;

About finance

DuckDB Finance adds SQL-native quant finance analytics to DuckDB under the fin_ namespace. It includes return and risk analytics, option pricing and Greeks, fixed-income and cash-flow helpers, portfolio math, technical indicators, and table functions. The extension is deterministic and local: it does not call market-data vendors or remote pricing services.

Added Functions

function_name function_type description comment examples
fin_accrued_interest scalar NULL NULL  
fin_active_return macro NULL NULL  
fin_ad_line macro NULL NULL  
fin_adf macro NULL NULL  
fin_adosc macro NULL NULL  
fin_adx macro NULL NULL  
fin_adxr macro NULL NULL  
fin_aggregate_return macro NULL NULL  
fin_alpha macro NULL NULL  
fin_alpha_beta macro NULL NULL  
fin_amihud_illiquidity macro NULL NULL  
fin_annual_return macro NULL NULL  
fin_annuity_payment scalar NULL NULL  
fin_anova_oneway macro NULL NULL  
fin_apo macro NULL NULL  
fin_arithmetic_return macro NULL NULL  
fin_aroon macro NULL NULL  
fin_aroonosc macro NULL NULL  
fin_asian_geometric_price scalar NULL NULL  
fin_asset_or_nothing_price scalar NULL NULL  
fin_atr macro NULL NULL  
fin_autocorr macro NULL NULL  
fin_avg_drawdown aggregate NULL NULL  
fin_avg_price scalar NULL NULL  
fin_bachelier_greeks scalar NULL NULL  
fin_bachelier_implied_vol scalar NULL NULL  
fin_bachelier_price scalar NULL NULL  
fin_bar_spec macro NULL NULL  
fin_barrier_price scalar NULL NULL  
fin_bbands macro NULL NULL  
fin_beta macro NULL NULL  
fin_binomial_price scalar NULL NULL  
fin_bipower_variation macro NULL NULL  
fin_black76_greeks scalar NULL NULL  
fin_black76_implied_vol scalar NULL NULL  
fin_black76_price scalar NULL NULL  
fin_black_litterman_returns macro NULL NULL  
fin_bond_convexity scalar NULL NULL  
fin_bond_duration scalar NULL NULL  
fin_bond_price scalar NULL NULL  
fin_bond_ytm scalar NULL NULL  
fin_bootstrap_curve table NULL NULL  
fin_bop macro NULL NULL  
fin_bps scalar NULL NULL  
fin_bsm_all scalar NULL NULL  
fin_bsm_charm scalar NULL NULL  
fin_bsm_color scalar NULL NULL  
fin_bsm_d1 scalar NULL NULL  
fin_bsm_d2 scalar NULL NULL  
fin_bsm_delta scalar NULL NULL  
fin_bsm_elasticity scalar NULL NULL  
fin_bsm_gamma scalar NULL NULL  
fin_bsm_greeks scalar NULL NULL  
fin_bsm_implied_vol scalar NULL NULL  
fin_bsm_price scalar NULL NULL  
fin_bsm_price_dates scalar NULL NULL  
fin_bsm_prob_itm scalar NULL NULL  
fin_bsm_prob_touch scalar NULL NULL  
fin_bsm_rho scalar NULL NULL  
fin_bsm_speed scalar NULL NULL  
fin_bsm_theta scalar NULL NULL  
fin_bsm_ultima scalar NULL NULL  
fin_bsm_vanna scalar NULL NULL  
fin_bsm_vega scalar NULL NULL  
fin_bsm_vomma scalar NULL NULL  
fin_bsm_zomma scalar NULL NULL  
fin_business_days_between scalar NULL NULL  
fin_cagr macro NULL NULL  
fin_calendar table NULL NULL  
fin_calendar_spec macro NULL NULL  
fin_calmar macro NULL NULL  
fin_cashflow_spec macro NULL NULL  
fin_cci macro NULL NULL  
fin_cents_to_money macro NULL NULL  
fin_changes macro NULL NULL  
fin_changes_to_grid table NULL NULL  
fin_chi2_cdf scalar NULL NULL  
fin_chi2_inv scalar NULL NULL  
fin_clip scalar NULL NULL  
fin_cmo macro NULL NULL  
fin_component_risk macro NULL NULL  
fin_conditional_drawdown_at_risk macro NULL NULL  
fin_corr_matrix macro NULL NULL  
fin_cov_matrix macro NULL NULL  
fin_cramers_v macro NULL NULL  
fin_crosscorr macro NULL NULL  
fin_cum_return macro NULL NULL  
fin_curve_bootstrap table NULL NULL  
fin_curve_discount_factor scalar NULL NULL  
fin_curve_spec macro NULL NULL  
fin_curve_zero_rate scalar NULL NULL  
fin_cvar macro NULL NULL  
fin_data_quality_report macro NULL NULL  
fin_delta macro NULL NULL  
fin_delta_to_grid table NULL NULL  
fin_dema macro NULL NULL  
fin_digital_price scalar NULL NULL  
fin_discount_factor scalar NULL NULL  
fin_dollar_bars table NULL NULL  
fin_donchian macro NULL NULL  
fin_dot scalar NULL NULL  
fin_down_capture macro NULL NULL  
fin_downside_deviation macro NULL NULL  
fin_drawdown aggregate NULL NULL  
fin_drawdown_at_risk macro NULL NULL  
fin_drawdown_duration aggregate NULL NULL  
fin_dv01 scalar NULL NULL  
fin_dx macro NULL NULL  
fin_efficient_frontier table NULL NULL  
fin_ema macro NULL NULL  
fin_ema_halflife macro NULL NULL  
fin_entropy macro NULL NULL  
fin_equal_weights scalar NULL NULL  
fin_ewma_variance aggregate NULL NULL  
fin_ewma_vol aggregate NULL NULL  
fin_excess_return macro NULL NULL  
fin_exp_decay_avg macro NULL NULL  
fin_exp_decay_count macro NULL NULL  
fin_exp_decay_max macro NULL NULL  
fin_exp_decay_sum macro NULL NULL  
fin_expectancy macro NULL NULL  
fin_expected_shortfall macro NULL NULL  
fin_factor_alpha macro NULL NULL  
fin_factor_ic macro NULL NULL  
fin_factor_report table NULL NULL  
fin_factor_turnover macro NULL NULL  
fin_fama_macbeth table NULL NULL  
fin_first_non_null macro NULL NULL  
fin_forward_price scalar NULL NULL  
fin_forward_rate scalar NULL NULL  
fin_fra_rate scalar NULL NULL  
fin_from_bps scalar NULL NULL  
fin_from_log_return macro NULL NULL  
fin_future_value scalar NULL NULL  
fin_gain_to_pain macro NULL NULL  
fin_garch11_forecast macro NULL NULL  
fin_garch_fit table NULL NULL  
fin_garman_klass_vol macro NULL NULL  
fin_geometric_return macro NULL NULL  
fin_gross_return macro NULL NULL  
fin_half_life_mean_reversion macro NULL NULL  
fin_hit_ratio macro NULL NULL  
fin_hma macro NULL NULL  
fin_hrp_weights table NULL NULL  
fin_hurst macro NULL NULL  
fin_imbalance_bars table NULL NULL  
fin_information_ratio macro NULL NULL  
fin_interpolate_curve scalar NULL NULL  
fin_inverse_vol_weights scalar NULL NULL  
fin_irr scalar NULL NULL  
fin_is_business_day scalar NULL NULL  
fin_is_decimal_return macro NULL NULL  
fin_is_finite scalar NULL NULL  
fin_is_outlier_zscore scalar NULL NULL  
fin_is_price scalar NULL NULL  
fin_is_rate scalar NULL NULL  
fin_is_regular_session scalar NULL NULL  
fin_is_vol scalar NULL NULL  
fin_iv_percentile aggregate NULL NULL  
fin_iv_rank aggregate NULL NULL  
fin_jensen_alpha macro NULL NULL  
fin_kahan_sum macro NULL NULL  
fin_kama macro NULL NULL  
fin_keltner macro NULL NULL  
fin_ks_test macro NULL NULL  
fin_kyle_lambda macro NULL NULL  
fin_last_non_null macro NULL NULL  
fin_last_to_grid table NULL NULL  
fin_linear_trend macro NULL NULL  
fin_linearreg macro NULL NULL  
fin_linearreg_intercept macro NULL NULL  
fin_linearreg_slope macro NULL NULL  
fin_ljung_box macro NULL NULL  
fin_log_nav macro NULL NULL  
fin_log_return macro NULL NULL  
fin_loss_rate macro NULL NULL  
fin_macd macro NULL NULL  
fin_mad macro NULL NULL  
fin_mann_whitney_u macro NULL NULL  
fin_marginal_risk macro NULL NULL  
fin_matrix_cholesky scalar NULL NULL  
fin_matrix_is_psd scalar NULL NULL  
fin_matrix_mul scalar NULL NULL  
fin_matrix_shape scalar NULL NULL  
fin_matrix_transpose scalar NULL NULL  
fin_matrix_vecmul scalar NULL NULL  
fin_max_drawdown aggregate NULL NULL  
fin_max_sharpe_weights macro NULL NULL  
fin_median_price scalar NULL NULL  
fin_mfi macro NULL NULL  
fin_microprice scalar NULL NULL  
fin_mid scalar NULL NULL  
fin_min_variance_weights macro NULL NULL  
fin_minus_di macro NULL NULL  
fin_minus_dm macro NULL NULL  
fin_mirr scalar NULL NULL  
fin_missing_count macro NULL NULL  
fin_mom macro NULL NULL  
fin_money_round macro NULL NULL  
fin_money_sum macro NULL NULL  
fin_money_to_cents macro NULL NULL  
fin_money_weighted_sum macro NULL NULL  
fin_mutual_information macro NULL NULL  
fin_natr macro NULL NULL  
fin_nav macro NULL NULL  
fin_nearest_psd scalar NULL NULL  
fin_newey_west_tstat macro NULL NULL  
fin_next_business_day scalar NULL NULL  
fin_norm_cdf scalar NULL NULL  
fin_norm_inv scalar NULL NULL  
fin_norm_pdf scalar NULL NULL  
fin_normalize_currency scalar NULL NULL  
fin_normalize_ohlcv table NULL NULL  
fin_normalize_option_chain table NULL NULL  
fin_normalize_returns table NULL NULL  
fin_npv scalar NULL NULL  
fin_obv macro NULL NULL  
fin_ohlc macro NULL NULL  
fin_ohlcv macro NULL NULL  
fin_ols macro NULL NULL  
fin_ols_no_intercept macro NULL NULL  
fin_omega_ratio macro NULL NULL  
fin_optimizer_spec macro NULL NULL  
fin_option_chain table NULL NULL  
fin_option_market_spec macro NULL NULL  
fin_option_payoff scalar NULL NULL  
fin_option_spec macro NULL NULL  
fin_option_spec_dates macro NULL NULL  
fin_order_imbalance scalar NULL NULL  
fin_outlier_count aggregate NULL NULL  
fin_parametric_cvar macro NULL NULL  
fin_parametric_var macro NULL NULL  
fin_parkinson_vol macro NULL NULL  
fin_parse_compounding scalar NULL NULL  
fin_parse_day_count scalar NULL NULL  
fin_parse_exercise_style scalar NULL NULL  
fin_parse_option_kind scalar NULL NULL  
fin_parse_return_method scalar NULL NULL  
fin_payoff_ratio macro NULL NULL  
fin_pct_change macro NULL NULL  
fin_plus_di macro NULL NULL  
fin_plus_dm macro NULL NULL  
fin_portfolio_expected_return scalar NULL NULL  
fin_portfolio_optimize table NULL NULL  
fin_portfolio_optimize_table table NULL NULL  
fin_portfolio_return scalar NULL NULL  
fin_portfolio_return_table table NULL NULL  
fin_portfolio_sharpe scalar NULL NULL  
fin_portfolio_spec macro NULL NULL  
fin_portfolio_variance scalar NULL NULL  
fin_portfolio_variance_table table NULL NULL  
fin_portfolio_vector macro NULL NULL  
fin_portfolio_vol scalar NULL NULL  
fin_ppo macro NULL NULL  
fin_predict_linear_to_grid table NULL NULL  
fin_present_value scalar NULL NULL  
fin_prev_business_day scalar NULL NULL  
fin_price_from_return macro NULL NULL  
fin_profit_factor macro NULL NULL  
fin_put_call_parity scalar NULL NULL  
fin_quantile_spread aggregate NULL NULL  
fin_queue_imbalance scalar NULL NULL  
fin_rank_corr macro NULL NULL  
fin_rank_ic macro NULL NULL  
fin_rate macro NULL NULL  
fin_rate_from_discount scalar NULL NULL  
fin_rate_spec macro NULL NULL  
fin_rate_to_grid table NULL NULL  
fin_realized_beta macro NULL NULL  
fin_realized_corr macro NULL NULL  
fin_realized_cov macro NULL NULL  
fin_realized_quarticity macro NULL NULL  
fin_realized_variance macro NULL NULL  
fin_realized_vol macro NULL NULL  
fin_rebalance_trades table NULL NULL  
fin_recovery_factor macro NULL NULL  
fin_resample_grid table NULL NULL  
fin_resets macro NULL NULL  
fin_resets_to_grid table NULL NULL  
fin_return macro NULL NULL  
fin_risk_contribution macro NULL NULL  
fin_risk_parity_weights macro NULL NULL  
fin_risk_spec macro NULL NULL  
fin_roc macro NULL NULL  
fin_rocp macro NULL NULL  
fin_rocr macro NULL NULL  
fin_rocr100 macro NULL NULL  
fin_rogers_satchell_vol macro NULL NULL  
fin_roll_spread macro NULL NULL  
fin_rolling_beta macro NULL NULL  
fin_rolling_zscore macro NULL NULL  
fin_round_to_tick scalar NULL NULL  
fin_rsi aggregate NULL NULL  
fin_sabr_vol scalar NULL NULL  
fin_safe_div scalar NULL NULL  
fin_sar macro NULL NULL  
fin_sarext macro NULL NULL  
fin_schema_template table NULL NULL  
fin_semivariance macro NULL NULL  
fin_session_date scalar NULL NULL  
fin_sharpe macro NULL NULL  
fin_simple_return macro NULL NULL  
fin_sma macro NULL NULL  
fin_sortino aggregate NULL NULL  
fin_spread scalar NULL NULL  
fin_spread_bps scalar NULL NULL  
fin_stability macro NULL NULL  
fin_stable_corr macro NULL NULL  
fin_stable_cov macro NULL NULL  
fin_stable_mean macro NULL NULL  
fin_stable_stddev macro NULL NULL  
fin_stable_var macro NULL NULL  
fin_stddev macro NULL NULL  
fin_stoch macro NULL NULL  
fin_stochrsi macro NULL NULL  
fin_student_t_cdf scalar NULL NULL  
fin_student_t_inv scalar NULL NULL  
fin_svi_total_variance scalar NULL NULL  
fin_svi_vol scalar NULL NULL  
fin_swap_rate scalar NULL NULL  
fin_t3 macro NULL NULL  
fin_tail_ratio macro NULL NULL  
fin_tema macro NULL NULL  
fin_theils_u macro NULL NULL  
fin_tick_bars table NULL NULL  
fin_to_log_return macro NULL NULL  
fin_total_return macro NULL NULL  
fin_tracking_error macro NULL NULL  
fin_trade_sign scalar NULL NULL  
fin_treynor_ratio macro NULL NULL  
fin_trima macro NULL NULL  
fin_trimmed_mean macro NULL NULL  
fin_trix macro NULL NULL  
fin_true_range macro NULL NULL  
fin_ts_grid_spec macro NULL NULL  
fin_tsf macro NULL NULL  
fin_ttest_1samp macro NULL NULL  
fin_ttest_2samp macro NULL NULL  
fin_turnover scalar NULL NULL  
fin_twap macro NULL NULL  
fin_typ_price scalar NULL NULL  
fin_typeof macro NULL NULL  
fin_ulcer_index aggregate NULL NULL  
fin_ultosc macro NULL NULL  
fin_up_capture macro NULL NULL  
fin_upside_deviation macro NULL NULL  
fin_validate_curve_spec macro NULL NULL  
fin_validate_ohlc scalar NULL NULL  
fin_validate_option_spec macro NULL NULL  
fin_validate_rate_spec macro NULL NULL  
fin_validate_return scalar NULL NULL  
fin_validate_schema table NULL NULL  
fin_var macro NULL NULL  
fin_var_indicator macro NULL NULL  
fin_var_spec macro NULL NULL  
fin_vector_add scalar NULL NULL  
fin_vector_mean scalar NULL NULL  
fin_vector_normalize_sum scalar NULL NULL  
fin_vector_scale scalar NULL NULL  
fin_vector_sub scalar NULL NULL  
fin_vector_sum scalar NULL NULL  
fin_version scalar NULL NULL  
fin_vol_of_vol macro NULL NULL  
fin_volatility macro NULL NULL  
fin_volume_bars table NULL NULL  
fin_volume_profile macro NULL NULL  
fin_vpin macro NULL NULL  
fin_vwap macro NULL NULL  
fin_weighted_close scalar NULL NULL  
fin_weighted_mean macro NULL NULL  
fin_weighted_quantile macro NULL NULL  
fin_weighted_stddev macro NULL NULL  
fin_weighted_var macro NULL NULL  
fin_welch_ttest macro NULL NULL  
fin_willr macro NULL NULL  
fin_win_rate macro NULL NULL  
fin_winsorized_mean macro NULL NULL  
fin_wma macro NULL NULL  
fin_xirr scalar NULL NULL  
fin_yang_zhang_vol macro NULL NULL  
fin_yearfrac scalar NULL NULL  
fin_zscore_last macro NULL NULL  
fin_ztest_mean macro NULL NULL  

Overloaded Functions

This extension does not add any function overloads.

Added Types

This extension does not add any types.

Added Settings

This extension does not add any settings.