pure_greeks
Pure-Ruby options Greeks (delta, gamma, theta, vega, rho), pricing, and implied volatility for vanilla European and American options. No Python, no QuantLib system dep, no native code.
Documentation, examples, and engine internals: https://jayravaliya.com/ruby-pure-greeks/
Author's note
Hi folks! I've been working on some options-related projects recently and came across the need to calculate options greeks in Ruby. The solution was to invoke a Python script from a Rails app to generate these numbers and then ingest. That was fine, but I saw that there was a vacuum in this type of library in the Ruby world, so I decided to pair with Claude and make it.
Check out the great details available on the Pages site about the different strategies available. Contributions welcome!
Installation
Add to your Gemfile:
gem "pure_greeks"Then bundle install. Or install directly:
gem install pure_greeksRequires Ruby 3.2 or newer. No system dependencies.
Quick example
require "pure_greeks"
option = PureGreeks::Option.new(
exercise_style: :american, type: :call,
strike: 150.0, expiration: Date.new(2026, 6, 19),
underlying_price: 148.5, implied_volatility: 0.35,
risk_free_rate: 0.05, dividend_yield: 0.0,
valuation_date: Date.today
)
option.price # => 4.27
option.delta # => 0.42For the full API, the implied-volatility solver, how the three engines fall back to one another, validation methodology, and limitations, see the documentation site.
Development
Clone and bootstrap:
git clone https://github.com/jayrav13/ruby-pure-greeks.git
cd ruby-pure-greeks
bin/setupRun the test suite:
bundle exec rspecRun the linter:
bundle exec rubocopOpen a console with the gem loaded:
bin/consoleTo install this gem onto your local machine for trial use:
bundle exec rake installReleasing
Releases are tag-driven through CI — no manual gem push needed.
- On a feature branch, bump
lib/pure_greeks/version.rbto the new version. - Add a section to
CHANGELOG.mdfor the new version (Keep-a-Changelog format). - Open a PR; CI must be green.
- Merge to
main. The release workflow (.github/workflows/release.yml) detects the version bump, runs the test suite, builds the gem, publishes to RubyGems via Trusted Publishing (no API key), creates avX.Y.Zgit tag, and opens a GitHub Release with auto-generated notes from the merged PRs.
The RubyGems version badge above refreshes automatically once the new version indexes on rubygems.org (usually within a minute).
Contributing
Bug reports and pull requests are welcome at https://github.com/jayrav13/ruby-pure-greeks. Please run bundle exec rspec and bundle exec rubocop locally before opening a PR. CI runs both on Ruby 3.2, 3.3, and 3.4.
License
MIT. See LICENSE.txt.