General
Fundamental analysis in Ruby, straight from SEC EDGAR
0 views

fundamentalista is a Ruby gem for fundamental analysis of listed companies. Version 0.6.0 is on RubyGems.
Fundamentalista.configure { |c| c.edgar_user_agent = "Acme Research research@acme.com" }
apple = Fundamentalista.company("AAPL")
year = apple.financials.latest
year.income.revenue # BigDecimal
year.ratios.roe
year.ratios.cash_conversion_cycle
year.piotroski.score
valuation = apple.valuation(price: 230)
valuation.pe
valuation.fcf_yield
valuation.altman_z.zone # => :safe
valuation.intrinsic_value(growth: 0.06, discount_rate: 0.09)
Why another one
Most fundamental data libraries wrap a paid API and hand you a hash. I wanted the shape of RubyLLM: small value objects, one obvious call per question, nil when a filing lacks an input so a ratio never raises on an incomplete company, and to_json on everything so it drops into a Rails view.
Where the data comes from
SEC EDGAR XBRL company facts. Free, no key, only a User-Agent with your contact. US GAAP and IFRS filers, in their reporting currency.
Financial Modeling Prep with a key, for quotes, estimates, prices, segments and exchange rates.
EDGAR is the interesting part. Companies tag the same idea under different concepts, so every line item has an ordered list of alternatives measured over the 500 largest filers with script/coverage. Fourth quarters exist only as annual figures, so they are derived, except weighted average shares, which are not additive. Some filers negate expenses, some tag three currencies. Every figure remembers the concept, form and filing it came from:
year.source(:revenue)
# => #<Fundamentalista::Source concept: "RevenueFromContractWithCustomerExcludingAssessedTax", form: "10-K", filed: 2025-10-31, derivation: :reported>
What is inside
Income, balance and cash flow statements with derived lines (EBIT, EBITDA, free cash flow, net debt, working capital)
Annual, quarterly and trailing twelve months periods
Profitability, liquidity, leverage, efficiency and working capital ratios, DuPont, accruals
Piotroski F, Altman Z, Beneish M, owner earnings
Multiples, yields, Graham number, DCF with fading growth, reverse DCF, earnings power value, residual income, WACC
Banking and insurance lines and ratios: net interest margin, cost of risk, combined ratio, the float
Peer comparison with rankings, Greenblatt's magic formula and currency conversion
Rails
fundamentalista-rails is a mountable engine with watchlists that snapshot ratios and valuations per holding.
Limitations
As-filed data has edges the gem documents rather than hides: stock splits are restated only in later filings, multi-class companies tag share counts per class, and a filer that negates a provision keeps its sign.
Repo: https://github.com/bruno-costanzo/fundamentalista
Read original: https://dev.to/bruno_costanzo/fundamental-analysis-in-ruby-straight-from-sec-edgar-45b1
PreviousFunctional options design pattern and implementation.NextFuture AWS Agent Engineer? I Didn't Write the Code. Does It Count?
Related posts
Adventurer returns home to Hull after 28-year walk from South America
0Hacker News New
Vending machine has terms and conditions you must accept before using [video]
0Hacker News New
Tomorrow Corporation Tech Demo [video]
0Hacker News New
Does Social Status Run in Families?
0Hacker News New
Show HN: Svoxx – A multilingual freelance marketplace with social features
0Hacker News New
433MHz TUI scanner: using a FT232H connected to a CC1101
0Hacker News New