Giter Club home page Giter Club logo

talib-ruby's Introduction

talib-ruby

Ruby Wrapper for ta-lib

This project has been started by Timur Adigamov on Rubyforge,
but since it didn’t build on my machine and wasn’t complete i modified it slightly, et voila.

Important note for commit id 11277315208a8bfcfd2a3211e10b5732d6705fc7 and gem version 1.0.6

From now on all returned lists from talib_ruby now correspond to what ta-lib returns, i.e. there will be no longer leading nil values in any outXYZ lists.
The nil values will now be trailing nil values if your inserted outXYZ lists are too large (let’s say you always insert out arrays with the same length as the inXYZ lists).
Therefore the returned value outBegIdx is no more relevant for the outXYZ lists, since the first calculated value can be found right at index 0 in the outXYZ lists.
All calculated values are still the same, it’s only a shifting issue which has been corrected now.
Thanks go to Masayuki Yamamoto who showed me this.

Install and build instructions

Install ta-lib:

Install ta-lib from MacPorts:

sudo port install ta-lib

Or install ta-lib from Homebrew:

sudo brew install ta-lib

If you want to compile ta-lib from the sources (ta-lib.org) you have to use the following statements (thanks to rmldj):

./configure LDFLAGS="-lm"
make
sudo make install

Install the ruby wrapper talib_ruby:

sudo env ARCHFLAGS="-arch PLATFORM" gem install talib_ruby -- --with-talib-include=ABSOLUTE_PATH_TO_TALIB_HEADERS  --with-talib-lib=ABSOLUTE_PATH_TO_TALIB_LIBS
  • PLATFORM = [i386 | x86_64 | …]
  • ABSOLUTE_PATH_TO_TALIB_HEADERS = The path to the ta-lib header files
    • e.g. for Port: /opt/local/var/macports/software/ta-lib/0.4.0_0/opt/local/include
    • e.g. for Homebrew: /usr/local/Cellar/ta-lib/0.4.0/include
  • ABSOLUTE_PATH_TO_TALIB_LIBS = The path to the ta-lib lib files
    • e.g. fo Port: /opt/local/var/macports/software/ta-lib/0.4.0_0/opt/local/lib
    • e.g. fo Homebrew: /usr/local/Cellar/ta-lib/0.4.0/lib

Now ta-lib can be used by using require ‘talib_ruby’
Needs at least Mac OSX 10.5. Has not been tested on Windows, but works there too what i’ve heard.
Tested with Ruby 1.8.7, 1.9.3 and 2.0.0.

Example

Calculation of Moving Average (MA):

require 'rubygems'
require 'talib_ruby'

# init input data
a = Array.new
10.times { |i| a.push i.to_f }

10.times do |k|
    b = Array.new(10)
    l = TaLib::Function.new("MA")
    # setup input parameter
    l.in_real(0,a)
    # setup optional parameter
    l.opt_int(0,k+2)
    # setup output parameter
    l.out_real(0,b)
    lookback = l.lookback
    l.call(0,9)
    p "k=#{k+2}"
    p b
end

Useful links

Donate

If you think this library is useful i would be grateful for a donation.

License

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright © 2013 by Valentin Treu, released under the MIT license.

talib-ruby's People

Contributors

rivella50 avatar christopher-a-taylor avatar marcocarvalho avatar escudero avatar ricpruss avatar mlamby avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.