|
2 | 2 |
|
3 | 3 |  |
4 | 4 |
|
5 | | -Ruby FFI wrapper for TA-Lib (Technical Analysis Library) |
| 5 | +## Introduction |
| 6 | + |
| 7 | +TALib is a Ruby binding for [TA-Lib](https://ta-lib.org/) (Technical Analysis Library) using FFI (Foreign Function Interface). It provides a comprehensive set of functions for technical analysis of financial market data. |
| 8 | + |
| 9 | +## Requirements |
| 10 | + |
| 11 | +- Ruby >= 3.0.0 |
| 12 | +- TA-Lib >= 0.6.4 |
6 | 13 |
|
7 | 14 | ## Installation |
8 | 15 |
|
9 | | -TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org. |
| 16 | +### [Install TA-Lib](https://ta-lib.org/install/) |
| 17 | + |
| 18 | +#### Windows |
| 19 | +Download and run the installer: [ta-lib-0.6.4-windows-x86_64.msi](https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib-0.6.4-windows-x86_64.msi) |
| 20 | + |
| 21 | +#### macOS |
| 22 | +```bash |
| 23 | +brew install ta-lib |
| 24 | +``` |
| 25 | + |
| 26 | +#### Linux (Debian/Ubuntu) |
| 27 | +```bash |
| 28 | +# For Intel/AMD 64-bit |
| 29 | +wget https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib_0.6.4_amd64.deb |
| 30 | +sudo dpkg -i ta-lib_0.6.4_amd64.deb |
| 31 | + |
| 32 | +# For ARM64 |
| 33 | +wget https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib_0.6.4_arm64.deb |
| 34 | +sudo dpkg -i ta-lib_0.6.4_arm64.deb |
| 35 | + |
| 36 | +# For Intel/AMD 32-bits |
| 37 | +wget https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib_0.6.4_i386.deb |
| 38 | +sudo dpkg -i ta-lib_0.6.4_i386.deb |
| 39 | +``` |
10 | 40 |
|
11 | | -Install the gem and add to the application's Gemfile by executing: |
| 41 | +### Installing the Ruby Gem |
12 | 42 |
|
13 | | - $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG |
| 43 | +Add this to your application's Gemfile: |
14 | 44 |
|
15 | | -If bundler is not being used to manage dependencies, install the gem by executing: |
| 45 | +```ruby |
| 46 | +gem 'ta_lib_ffi' |
| 47 | +``` |
16 | 48 |
|
17 | | - $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG |
| 49 | +Then execute: |
| 50 | + |
| 51 | + $ bundle install |
| 52 | + |
| 53 | +Or install it directly: |
| 54 | + |
| 55 | + $ gem install ta_lib_ffi |
18 | 56 |
|
19 | 57 | ## Usage |
20 | 58 |
|
21 | | -TODO: Write usage instructions here |
| 59 | +```ruby |
| 60 | +require 'ta_lib' |
22 | 61 |
|
23 | | -## Development |
| 62 | +# Initialize data |
| 63 | +prices = [10.0, 11.0, 12.0, 11.0, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0] |
24 | 64 |
|
25 | | -After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. |
| 65 | +# Calculate SMA |
| 66 | +puts TALib.sma(prices, time_period: 3) |
| 67 | +# => [11.0, 11.333333333333334, 11.0, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0] |
| 68 | +``` |
| 69 | + |
| 70 | +## TODO |
| 71 | +- [ ] Add RDoc documentation for Ruby methods |
| 72 | +- [ ] Create detailed function examples with input/output samples |
| 73 | +- [ ] Add more tests for each function |
| 74 | +- [ ] Support custom TA-Lib installation location |
| 75 | + |
| 76 | +## Development |
26 | 77 |
|
27 | | -To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org). |
| 78 | +1. Fork the repository |
| 79 | +2. Create your feature branch (`git checkout -b feature/amazing-feature`) |
| 80 | +3. Commit your changes (`git commit -am 'Add some amazing feature'`) |
| 81 | +4. Push to the branch (`git push origin feature/amazing-feature`) |
| 82 | +5. Create a Pull Request |
28 | 83 |
|
29 | 84 | ## Contributing |
30 | 85 |
|
31 | | -Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ta_lib_ffi. |
| 86 | +Bug reports and pull requests are welcome on GitHub at https://github.com/Youngv/ta_lib_ffi |
32 | 87 |
|
33 | 88 | ## License |
34 | 89 |
|
35 | | -The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). |
| 90 | +This gem is available as open source under the terms of the [MIT License](LICENSE). |
0 commit comments