Skip to content

HaedronResearch/TulipIndicators.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TulipIndicators.jl

Purpose

A simple Julia wrapper for Tulip Indicators.

Install

Install this package to your Julia project environment as you would any other package from a Git repo.

From the Julia REPL:

julia> ]
(MyProject) pkg> add https://github.com/HaedronResearch/TulipIndicators.jl

Overview

The only functions this package exports are: ti{p}, tc, and {ti, tc}_show. Use ti to compute an indicator based on a Symbol identifier. The indicator may require options (parameters) to be supplied.

The upstream Tulip Indicators website lists the valid indicators and their identifiers. The indicator options can also be found at the upstream website or by calling ti_show(:<identifier>).

The lowest level wrapper method takes in a vector of vectors. There are higher level methods dispatching on AbstractMatrix. All methods output a Matrix result. Use tip if you want a PaddedView output (pad element is missing by default).

The tc function provides an interface to Tulip Candles. This is not a priority for me, but the interface exists if you want to play with it. I couldn't find documentation on the candle patterns.

Toy Example

julia> using TulipIndicators

julia> ti_show()
(version = "0.9.2", build = 1660687722, indicator_count = 104)

julia> ti_show(:atr)
(type = :indicator, inputs = 3, options = 1, outputs = 1, input_names = [:high, :low, :close], option_names = [:period], output_names = [:atr], start = Ptr{Nothing} ..., indicator = Ptr{Nothing} ..., indicator_ref = Ptr{Nothing} ...)

julia> n=10
julia> hlc = [cumsum(ones(n)), -cumsum(ones(n)), zeros(n)]
julia> ti(:atr, hlc, [3.]) # vec of vecs
8×1 Matrix{Float64}:
  4.0
  5.333333333333333
  6.888888888888888
  8.592592592592592
 10.395061728395062
 12.263374485596708
 14.175582990397805
 16.11705532693187

julia> ti(:atr, hcat(hlc...), [3.]) # matrix
8×1 Matrix{Float64}:
  4.0
  5.333333333333333
  6.888888888888888
  8.592592592592592
 10.395061728395062
 12.263374485596708
 14.175582990397805
 16.11705532693187

julia> tip(:atr, hcat(hlc...), [3.]) # matrix, padded output
10×1 PaddedView(missing, ::Matrix{Float64}, (-1:8, 1:1)) with eltype Union{Missing, Float64} with indices -1:8×1:1:
   missing
   missing
  4.0
  5.333333333333333
  6.888888888888888
  8.592592592592592
 10.395061728395062
 12.263374485596708
 14.175582990397805
 16.11705532693187

Implementation

  • The C lib is packaged via a BinaryBuilder.jl jll package dependency.
  • src/base/base.jl was autogenerated by Clang.jl from the header files, this file contains all common types and constants.
  • TulipIndicators.jl calls libindicators C functions via @ccall
  • When a symbol is passed to ti{p}, ti_find_indicator is @ccalled, the resulting struct contains function pointers which can be @ccalled to initialize and compute the indicator. A similar process occurs for tc.
  • This avoids a whole bunch of unnecessary function definitions because @ccall/ccall cannot be efficiently @evaled over.

TODO

  • Put all the indicator information into a constant table deserialized when the package is loaded.
  • An interface for NamedTuple instead of AbstractVector option arguments, so option names can be included in ti{p} calls.
  • Add tindicators Tulip Indicators fork library

Releases

No releases published

Packages

No packages published

Languages