TALibFFI is a Ruby binding for TA-Lib (Technical Analysis Library) using FFI (Foreign Function Interface). It provides a comprehensive set of functions for technical analysis of financial market data. This gem is based on the TA-Lib C headers, providing a Ruby-friendly interface to the underlying C library.
- Ruby >= 3.1.0
- TA-Lib >= 0.6.4
Download and run the installer: ta-lib-0.6.4-windows-x86_64.msi
brew install ta-lib# For Intel/AMD 64-bit
wget https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib_0.6.4_amd64.deb
sudo dpkg -i ta-lib_0.6.4_amd64.deb
# For ARM64
wget https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib_0.6.4_arm64.deb
sudo dpkg -i ta-lib_0.6.4_arm64.deb
# For Intel/AMD 32-bits
wget https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib_0.6.4_i386.deb
sudo dpkg -i ta-lib_0.6.4_i386.debAdd this to your application's Gemfile:
gem'ta_lib_ffi'Then execute:
$ bundle install
Or install it directly:
$ gem install ta_lib_ffi
require'ta_lib_ffi'# Initialize dataprices=[10.0,11.0,12.0,11.0,10.0,9.0,8.0,7.0,6.0,5.0,4.0]# Calculate SMAputsTALibFFI.sma(prices,time_period: 3)# => [11.0, 11.333333333333334, 11.0, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0]# Average True Range (ATR) Examplehigh=[82.15,81.89,83.03,83.30,83.85,83.90,83.33,84.30,84.84,85.00,85.90,86.58,86.98,88.00,87.87]low=[81.29,80.64,81.31,82.65,83.07,83.11,82.49,82.30,84.15,84.11,84.03,85.39,85.76,87.17,87.01]close=[81.59,81.06,82.87,83.00,83.61,83.15,82.84,83.99,84.55,84.36,85.53,86.54,86.89,87.77,87.29]# Calculate ATR with period = 5result=TALibFFI.atr([high,low,close],time_period: 5)# => [1.101999999999998, 1.0495999999999992, 1.2396799999999994, 1.1617440000000012, 1.1073952000000011, ...]- API Documentation - Detailed documentation of all available methods and classes
- Add RDoc documentation for Ruby methods
- Create detailed function examples with input/output samples
- Add more tests for each function
- Support custom TA-Lib installation location
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -am 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Create a Pull Request
Bug reports and pull requests are welcome on GitHub at https://github.com/TA-Lib/ta-lib-ruby
This gem is available as open source under the terms of the MIT License.