ta_lib_ffi 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +50 -68
- data/Rakefile +5 -4
- data/lib/ta_lib_ffi/version.rb +5 -0
- data/lib/ta_lib_ffi.rb +1035 -308
- data/ta_lib_ffi.gemspec +3 -2
- metadata +20 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c3c72ea70613feff1a82c4043750737ceb8b3addabbc39a5a4c08d030c3f9a32
|
|
4
|
+
data.tar.gz: 4cbd7911b66a29ef0d7d333fbdf57392d75d81bfb5204b71463dc17eb51ee32d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1e10c494d6e06892b1acdc3a281b4ae9d7c36b0ce3afbd5966056ab58f82105d057a34c566acce85dc3f3b8bb7100c715d5cdab89d0a1d884e74e0d5127c83b8
|
|
7
|
+
data.tar.gz: f9bce5cae744b44f6947a73cf9244bb9a7495d937d1b19f093213a411f957d1154a030231bbd385918cde9e9254bfe9d7a812b0609aee55e75c9512526f0e629
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.4.0] - 2026-11-23
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Support for the TA-Lib 0.8.3 function metadata layout and indicators, including ALMA, alongside 0.6.4. Set `TA_LIB_PATH` to select a particular shared library.
|
|
13
|
+
- Direct C comparisons for the indicators in each installed library and CI coverage for the latest stable Ruby 4.x.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- Fixed HTML documentation generation on Ruby 4. The local API reference includes the indicators and defaults from the selected TA-Lib C library.
|
|
18
|
+
- Fixed unbounded memory growth during repeated indicator calls. Numeric arrays are packed in bulk, and Ruby owns the input and output buffers for the duration of each call.
|
|
19
|
+
- Invalid input counts, incorrectly grouped price fields, unequal lengths and unknown keywords raise `TALibFFI::TALibError` with details. Previously unknown keywords silently used the default.
|
|
20
|
+
|
|
21
|
+
Indicator defaults and results follow the installed TA-Lib version. This includes the BBANDS default period and how MINMAXINDEX selects among equal extrema.
|
|
22
|
+
|
|
8
23
|
## [0.3.0] - 2025-02-23
|
|
9
24
|
|
|
10
25
|
### Added
|
|
@@ -54,6 +69,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
54
69
|
### Security
|
|
55
70
|
- N/A
|
|
56
71
|
|
|
72
|
+
[0.4.0]: https://github.com/TA-Lib/ta-lib-ruby/compare/v0.3.0...v0.4.0
|
|
57
73
|
[0.3.0]: https://github.com/TA-Lib/ta-lib-ruby/compare/v0.2.0...v0.3.0
|
|
58
74
|
[0.2.0]: https://github.com/TA-Lib/ta-lib-ruby/compare/v0.1.0...v0.2.0
|
|
59
75
|
[0.1.0]: https://github.com/TA-Lib/ta-lib-ruby/releases/tag/v0.1.0
|
data/README.md
CHANGED
|
@@ -1,103 +1,85 @@
|
|
|
1
1
|
# TALibFFI
|
|
2
2
|
|
|
3
|
-

|
|
4
|
-
[](https://github.com/TA-Lib/ta-lib-ruby/actions/workflows/main.yml)
|
|
4
|
+
[](https://rubygems.org/gems/ta_lib_ffi)
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
`ta_lib_ffi` exposes the technical indicators in your installed TA-Lib C library as Ruby methods. A three-period simple moving average returns its first value at the third price.
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
## Requirements
|
|
8
|
+
```ruby
|
|
9
|
+
require "ta_lib_ffi"
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
close = [10, 11, 12, 13, 14]
|
|
12
|
+
TALibFFI.sma(close, time_period: 3)
|
|
13
|
+
# => [11.0, 12.0, 13.0]
|
|
14
|
+
```
|
|
14
15
|
|
|
15
16
|
## Installation
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
You need Ruby 3.1 or later and the TA-Lib C shared library 0.6.4 or later. If you already use C library 0.6.4, you can keep it when upgrading the gem to 0.4.0.
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
Download
|
|
20
|
+
- **macOS** — Run `brew install ta-lib`.
|
|
21
|
+
- **Debian or Ubuntu** — Download the `.deb` matching `dpkg --print-architecture`. For example, on `amd64`, install the downloaded file with `sudo dpkg -i ./ta-lib_0.8.3_amd64.deb`. [Debian packages](https://ta-lib.org/install/c/#linux-debian-packages)
|
|
22
|
+
- **Windows x64** — Run the [TA-Lib 0.8.3 x64 installer](https://github.com/TA-Lib/ta-lib/releases/download/v0.8.3/ta-lib-0.8.3-windows-x86_64.msi).
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
brew install ta-lib
|
|
25
|
-
```
|
|
24
|
+
For a custom installation, set `TA_LIB_PATH` to the full path of the shared library (`.so`, `.dylib` or `.dll`) before requiring the gem. [TA-Lib installation guide](https://ta-lib.org/install/c/)
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
# For Intel/AMD 64-bit
|
|
30
|
-
wget https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib_0.6.4_amd64.deb
|
|
31
|
-
sudo dpkg -i ta-lib_0.6.4_amd64.deb
|
|
26
|
+
Add the gem to your application with `bundle add ta_lib_ffi`, or install it directly with `gem install ta_lib_ffi`.
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
wget https://github.com/ta-lib/ta-lib/releases/download/v0.6.4/ta-lib_0.6.4_arm64.deb
|
|
35
|
-
sudo dpkg -i ta-lib_0.6.4_arm64.deb
|
|
28
|
+
## Inputs and results
|
|
36
29
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
Pass price fields together in the order the indicator expects. For Average True Range (ATR), pass high, low and close as one argument. All input series must be nonempty and have the same length.
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
high = [11, 13, 12, 14, 15]
|
|
34
|
+
low = [9, 10, 9, 11, 12]
|
|
35
|
+
close = [10, 12, 10, 13, 14]
|
|
41
36
|
|
|
42
|
-
|
|
37
|
+
TALibFFI.atr([high, low, close], time_period: 2)
|
|
38
|
+
# => [3.0, 3.5, 3.25]
|
|
39
|
+
```
|
|
43
40
|
|
|
44
|
-
|
|
41
|
+
Single-output indicators return an array. Indicators with several outputs return a hash of arrays keyed by output name. Each array starts at the first input position for which the indicator has enough history.
|
|
45
42
|
|
|
46
43
|
```ruby
|
|
47
|
-
|
|
44
|
+
TALibFFI.minmax([12, 10, 14, 11, 13], time_period: 3)
|
|
45
|
+
# => { min: [10.0, 10.0, 11.0], max: [14.0, 14.0, 14.0] }
|
|
48
46
|
```
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
$ bundle install
|
|
48
|
+
## C library compatibility
|
|
53
49
|
|
|
54
|
-
|
|
50
|
+
The loaded C library determines which methods are available and their default parameters. CI tests Ruby 3.1 through the latest stable Ruby 4.x across Linux, macOS and Windows with TA-Lib C 0.6.4 and 0.8.3.
|
|
55
51
|
|
|
56
|
-
|
|
52
|
+
| TA-Lib C | Indicators | Default BBANDS period | ALMA available |
|
|
53
|
+
| --- | ---: | ---: | --- |
|
|
54
|
+
| 0.6.4 | 161 | 5 | No |
|
|
55
|
+
| 0.7.1 | 161 | 5 | No |
|
|
56
|
+
| 0.8.1 | 201 | 20 | No |
|
|
57
|
+
| 0.8.3 | 237 | 20 | Yes |
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
Pass `time_period:` explicitly to use the same BBANDS window across versions. Use `respond_to?` when calling an indicator that some installations may lack, such as the Arnaud Legoux Moving Average (ALMA), or inspect `TALibFFI.group_table` and `TALibFFI.function_table(group)` to list loaded indicators.
|
|
59
60
|
|
|
60
61
|
```ruby
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
puts TALibFFI.sma(prices, time_period: 3)
|
|
68
|
-
# => [11.0, 11.333333333333334, 11.0, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0]
|
|
62
|
+
if TALibFFI.respond_to?(:alma)
|
|
63
|
+
prices = (1..8).map(&:to_f)
|
|
64
|
+
TALibFFI.alma(prices, time_period: 4, sigma: 4.0, offset: 0.75).map { |value| value.round(4) }
|
|
65
|
+
# => [2.8847, 3.8847, 4.8847, 5.8847, 6.8847]
|
|
66
|
+
end
|
|
67
|
+
```
|
|
69
68
|
|
|
70
|
-
|
|
71
|
-
high = [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]
|
|
72
|
-
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]
|
|
73
|
-
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]
|
|
69
|
+
When upgrading to gem 0.4.0, check your keyword arguments. A misspelling such as `timeperiod:` now raises `TALibFFI::TALibError` and the error lists the accepted keywords. [Changelog](CHANGELOG.md)
|
|
74
70
|
|
|
75
|
-
|
|
76
|
-
result = TALibFFI.atr([high, low, close], time_period: 5)
|
|
77
|
-
# => [1.101999999999998, 1.0495999999999992, 1.2396799999999994, 1.1617440000000012, 1.1073952000000011, ...]
|
|
78
|
-
```
|
|
71
|
+
## API documentation
|
|
79
72
|
|
|
80
|
-
|
|
81
|
-
- [API Documentation](https://www.rubydoc.info/github/TA-Lib/ta-lib-ruby/main) - Detailed documentation of all available methods and classes
|
|
73
|
+
The gem ships method signatures generated with TA-Lib C 0.8.3. [Online API reference](https://www.rubydoc.info/github/TA-Lib/ta-lib-ruby/main/TALibFFI)
|
|
82
74
|
|
|
83
|
-
|
|
84
|
-
- [ ] Add RDoc documentation for Ruby methods
|
|
85
|
-
- [ ] Create detailed function examples with input/output samples
|
|
86
|
-
- [ ] Add more tests for each function
|
|
87
|
-
- [ ] Support custom TA-Lib installation location
|
|
75
|
+
To build the reference for your installed C library, run `bundle install` and `bundle exec rake yard` from a checkout, then open `doc/TALibFFI.html`. The task also updates the generated method comments in `lib/ta_lib_ffi.rb`. Use TA-Lib C 0.8.3 when refreshing the signatures for this release.
|
|
88
76
|
|
|
89
77
|
## Development
|
|
90
78
|
|
|
91
|
-
|
|
92
|
-
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
93
|
-
3. Commit your changes (`git commit -am 'Add some amazing feature'`)
|
|
94
|
-
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
95
|
-
5. Create a Pull Request
|
|
96
|
-
|
|
97
|
-
## Contributing
|
|
79
|
+
From a checkout, run `bundle install` followed by `bundle exec rake` to run RSpec and RuboCop. To run just the C comparison tests, use `bundle exec rspec spec/ta_lib_ffi_c_reference_spec.rb`. They call each indicator through Ruby and directly through the installed C library with the same inputs, then compare output values, types, lengths and keys.
|
|
98
80
|
|
|
99
|
-
Bug reports and pull requests are welcome
|
|
81
|
+
Bug reports and pull requests are welcome. [GitHub repository](https://github.com/TA-Lib/ta-lib-ruby)
|
|
100
82
|
|
|
101
83
|
## License
|
|
102
84
|
|
|
103
|
-
|
|
85
|
+
[MIT License](LICENSE.txt)
|
data/Rakefile
CHANGED
|
@@ -13,12 +13,13 @@ RuboCop::RakeTask.new
|
|
|
13
13
|
task default: %i[spec rubocop]
|
|
14
14
|
|
|
15
15
|
YARD::Rake::YardocTask.new do |t|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
t.before = lambda do
|
|
17
|
+
require_relative "lib/ta_lib_ffi"
|
|
18
|
+
require_relative "lib/ta_lib_ffi/doc"
|
|
19
|
+
TALibFFI::Doc.insert
|
|
20
|
+
end
|
|
19
21
|
|
|
20
22
|
t.files = ["lib/**/*.rb"]
|
|
21
23
|
t.options = ["--exclude", "lib/ta_lib_ffi/doc.rb"]
|
|
22
24
|
t.stats_options = ["--list-undoc"]
|
|
23
|
-
# t.after = -> { TALibFFI::Doc.remove }
|
|
24
25
|
end
|