Module: TALibFFI
- Extended by:
- Fiddle::Importer
- Defined in:
- lib/ta_lib_ffi.rb
Overview
Ruby FFI wrapper for TA-Lib (Technical Analysis Library)
This module provides a Ruby interface to the TA-Lib technical analysis library using FFI (Foreign Function Interface). It allows you to perform various technical analysis calculations on financial market data.
Defined Under Namespace
Classes: TALibError
Constant Summary collapse
- VERSION =
"0.2.0"
- TA_SUCCESS =
0
- TA_LIB_NOT_INITIALIZE =
1
- TA_BAD_PARAM =
2
- TA_ALLOC_ERR =
3
- TA_GROUP_NOT_FOUND =
4
- TA_FUNC_NOT_FOUND =
5
- TA_INVALID_HANDLE =
6
- TA_INVALID_PARAM_HOLDER =
7
- TA_INVALID_PARAM_HOLDER_TYPE =
8
- TA_INVALID_PARAM_FUNCTION =
9
- TA_INPUT_NOT_ALL_INITIALIZE =
10
- TA_OUTPUT_NOT_ALL_INITIALIZE =
11
- TA_OUT_OF_RANGE_START_INDEX =
12
- TA_OUT_OF_RANGE_END_INDEX =
13
- TA_INVALID_LIST_TYPE =
14
- TA_BAD_OBJECT =
15
- TA_NOT_SUPPORTED =
16
- TA_INTERNAL_ERROR =
5000
- TA_UNKNOWN_ERR =
0xFFFF
- TA_StringTable =
struct [ "unsigned int size", "const char **string", "void *hiddenData" ]
- TA_FuncInfo =
struct [ "const char *name", "const char *group", "const char *hint", "const char *camelCaseName", "TA_FuncFlags flags", "unsigned int nbInput", "unsigned int nbOptInput", "unsigned int nbOutput", "const TA_FuncHandle *handle" ]
- TA_ParamHolder =
struct [ "void *hiddenData" ]
- TA_InputParameterInfo =
struct [ "TA_InputParameterType type", "const char *paramName", "TA_InputFlags flags" ]
- TA_OptInputParameterInfo =
struct [ "TA_OptInputParameterType type", "const char *paramName", "TA_OptInputFlags flags", "const char *displayName", "const void *dataSet", "TA_Real defaultValue", "const char *hint", "const char *helpFile" ]
- TA_OutputParameterInfo =
struct [ "TA_OutputParameterType type", "const char *paramName", "TA_OutputFlags flags" ]
- TA_PARAM_TYPE =
{ TA_Input_Price: 0, TA_Input_Real: 1, TA_Input_Integer: 2, TA_OptInput_RealRange: 0, TA_OptInput_RealList: 1, TA_OptInput_IntegerRange: 2, TA_OptInput_IntegerList: 3, TA_Output_Real: 0, TA_Output_Integer: 1 }.freeze
- TA_FLAGS =
{ TA_InputFlags: { TA_IN_PRICE_OPEN: 0x00000001, TA_IN_PRICE_HIGH: 0x00000002, TA_IN_PRICE_LOW: 0x00000004, TA_IN_PRICE_CLOSE: 0x00000008, TA_IN_PRICE_VOLUME: 0x00000010, TA_IN_PRICE_OPENINTEREST: 0x00000020, TA_IN_PRICE_TIMESTAMP: 0x00000040 }, TA_OptInputFlags: { TA_OPTIN_IS_PERCENT: 0x00100000, TA_OPTIN_IS_DEGREE: 0x00200000, TA_OPTIN_IS_CURRENCY: 0x00400000, TA_OPTIN_ADVANCED: 0x01000000 }, TA_OutputFlags: { TA_OUT_LINE: 0x00000001, TA_OUT_DOT_LINE: 0x00000002, TA_OUT_DASH_LINE: 0x00000004, TA_OUT_DOT: 0x00000008, TA_OUT_HISTO: 0x00000010, TA_OUT_PATTERN_BOOL: 0x00000020, TA_OUT_PATTERN_BULL_BEAR: 0x00000040, TA_OUT_PATTERN_STRENGTH: 0x00000080, TA_OUT_POSITIVE: 0x00000100, TA_OUT_NEGATIVE: 0x00000200, TA_OUT_ZERO: 0x00000400, TA_OUT_UPPER_LIMIT: 0x00000800, TA_OUT_LOWER_LIMIT: 0x00001000 } }.freeze
Class Method Summary collapse
-
.accbands(price_hlc, time_period: 20.0) ⇒ Hash
GENERATED DOCUMENTATION START ### Acceleration Bands.
-
.acos(real) ⇒ Array<Float>
Vector Trigonometric ACos.
-
.ad(price_hlcv) ⇒ Array<Float>
Chaikin A/D Line.
-
.add(real0, real1) ⇒ Array<Float>
Vector Arithmetic Add.
-
.adosc(price_hlcv, fast_period: 3.0, slow_period: 10.0) ⇒ Array<Float>
Chaikin A/D Oscillator.
-
.adx(price_hlc, time_period: 14.0) ⇒ Array<Float>
Average Directional Movement Index.
-
.adxr(price_hlc, time_period: 14.0) ⇒ Array<Float>
Average Directional Movement Index Rating.
-
.apo(real, fast_period: 12.0, slow_period: 26.0, ma_type: 0.0) ⇒ Array<Float>
Absolute Price Oscillator.
-
.aroon(price_hl, time_period: 14.0) ⇒ Hash
Aroon.
-
.aroonosc(price_hl, time_period: 14.0) ⇒ Array<Float>
Aroon Oscillator.
-
.asin(real) ⇒ Array<Float>
Vector Trigonometric ASin.
-
.atan(real) ⇒ Array<Float>
Vector Trigonometric ATan.
-
.atr(price_hlc, time_period: 14.0) ⇒ Array<Float>
Average True Range.
-
.avgdev(real, time_period: 14.0) ⇒ Array<Float>
Average Deviation.
-
.avgprice(price_ohlc) ⇒ Array<Float>
Average Price.
-
.bbands(real, time_period: 5.0, nb_dev_up: 2.0, nb_dev_dn: 2.0, ma_type: 0.0) ⇒ Hash
Bollinger Bands.
-
.beta(real0, real1, time_period: 5.0) ⇒ Array<Float>
Beta.
-
.bop(price_ohlc) ⇒ Array<Float>
Balance Of Power.
-
.build_function_info_map ⇒ Hash
Builds a map of function information for all functions.
-
.calculate_lookback(params_ptr) ⇒ Integer
Calculates the lookback period for a function with given parameters.
-
.calculate_results(params_ptr, input_size, func_name) ⇒ Array, Hash
Calculates function results.
-
.call_func(func_name, args) ⇒ Array, Hash
Calls a TA-Lib function with the given arguments.
-
.cci(price_hlc, time_period: 14.0) ⇒ Array<Float>
Commodity Channel Index.
-
.cdl2crows(price_ohlc) ⇒ Array<Integer>
Two Crows.
-
.cdl3blackcrows(price_ohlc) ⇒ Array<Integer>
Three Black Crows.
-
.cdl3inside(price_ohlc) ⇒ Array<Integer>
Three Inside Up/Down.
-
.cdl3linestrike(price_ohlc) ⇒ Array<Integer>
Three-Line Strike.
-
.cdl3outside(price_ohlc) ⇒ Array<Integer>
Three Outside Up/Down.
-
.cdl3starsinsouth(price_ohlc) ⇒ Array<Integer>
Three Stars In The South.
-
.cdl3whitesoldiers(price_ohlc) ⇒ Array<Integer>
Three Advancing White Soldiers.
-
.cdlabandonedbaby(price_ohlc, penetration: 0.3) ⇒ Array<Integer>
Abandoned Baby.
-
.cdladvanceblock(price_ohlc) ⇒ Array<Integer>
Advance Block.
-
.cdlbelthold(price_ohlc) ⇒ Array<Integer>
Belt-hold.
-
.cdlbreakaway(price_ohlc) ⇒ Array<Integer>
Breakaway.
-
.cdlclosingmarubozu(price_ohlc) ⇒ Array<Integer>
Closing Marubozu.
-
.cdlconcealbabyswall(price_ohlc) ⇒ Array<Integer>
Concealing Baby Swallow.
-
.cdlcounterattack(price_ohlc) ⇒ Array<Integer>
Counterattack.
-
.cdldarkcloudcover(price_ohlc, penetration: 0.5) ⇒ Array<Integer>
Dark Cloud Cover.
-
.cdldoji(price_ohlc) ⇒ Array<Integer>
Doji.
-
.cdldojistar(price_ohlc) ⇒ Array<Integer>
Doji Star.
-
.cdldragonflydoji(price_ohlc) ⇒ Array<Integer>
Dragonfly Doji.
-
.cdlengulfing(price_ohlc) ⇒ Array<Integer>
Engulfing Pattern.
-
.cdleveningdojistar(price_ohlc, penetration: 0.3) ⇒ Array<Integer>
Evening Doji Star.
-
.cdleveningstar(price_ohlc, penetration: 0.3) ⇒ Array<Integer>
Evening Star.
-
.cdlgapsidesidewhite(price_ohlc) ⇒ Array<Integer>
Up/Down-gap side-by-side white lines.
-
.cdlgravestonedoji(price_ohlc) ⇒ Array<Integer>
Gravestone Doji.
-
.cdlhammer(price_ohlc) ⇒ Array<Integer>
Hammer.
-
.cdlhangingman(price_ohlc) ⇒ Array<Integer>
Hanging Man.
-
.cdlharami(price_ohlc) ⇒ Array<Integer>
Harami Pattern.
-
.cdlharamicross(price_ohlc) ⇒ Array<Integer>
Harami Cross Pattern.
-
.cdlhighwave(price_ohlc) ⇒ Array<Integer>
High-Wave Candle.
-
.cdlhikkake(price_ohlc) ⇒ Array<Integer>
Hikkake Pattern.
-
.cdlhikkakemod(price_ohlc) ⇒ Array<Integer>
Modified Hikkake Pattern.
-
.cdlhomingpigeon(price_ohlc) ⇒ Array<Integer>
Homing Pigeon.
-
.cdlidentical3crows(price_ohlc) ⇒ Array<Integer>
Identical Three Crows.
-
.cdlinneck(price_ohlc) ⇒ Array<Integer>
In-Neck Pattern.
-
.cdlinvertedhammer(price_ohlc) ⇒ Array<Integer>
Inverted Hammer.
-
.cdlkicking(price_ohlc) ⇒ Array<Integer>
Kicking.
-
.cdlkickingbylength(price_ohlc) ⇒ Array<Integer>
Kicking - bull/bear determined by the longer marubozu.
-
.cdlladderbottom(price_ohlc) ⇒ Array<Integer>
Ladder Bottom.
-
.cdllongleggeddoji(price_ohlc) ⇒ Array<Integer>
Long Legged Doji.
-
.cdllongline(price_ohlc) ⇒ Array<Integer>
Long Line Candle.
-
.cdlmarubozu(price_ohlc) ⇒ Array<Integer>
Marubozu.
-
.cdlmatchinglow(price_ohlc) ⇒ Array<Integer>
Matching Low.
-
.cdlmathold(price_ohlc, penetration: 0.5) ⇒ Array<Integer>
Mat Hold.
-
.cdlmorningdojistar(price_ohlc, penetration: 0.3) ⇒ Array<Integer>
Morning Doji Star.
-
.cdlmorningstar(price_ohlc, penetration: 0.3) ⇒ Array<Integer>
Morning Star.
-
.cdlonneck(price_ohlc) ⇒ Array<Integer>
On-Neck Pattern.
-
.cdlpiercing(price_ohlc) ⇒ Array<Integer>
Piercing Pattern.
-
.cdlrickshawman(price_ohlc) ⇒ Array<Integer>
Rickshaw Man.
-
.cdlrisefall3methods(price_ohlc) ⇒ Array<Integer>
Rising/Falling Three Methods.
-
.cdlseparatinglines(price_ohlc) ⇒ Array<Integer>
Separating Lines.
-
.cdlshootingstar(price_ohlc) ⇒ Array<Integer>
Shooting Star.
-
.cdlshortline(price_ohlc) ⇒ Array<Integer>
Short Line Candle.
-
.cdlspinningtop(price_ohlc) ⇒ Array<Integer>
Spinning Top.
-
.cdlstalledpattern(price_ohlc) ⇒ Array<Integer>
Stalled Pattern.
-
.cdlsticksandwich(price_ohlc) ⇒ Array<Integer>
Stick Sandwich.
-
.cdltakuri(price_ohlc) ⇒ Array<Integer>
Takuri (Dragonfly Doji with very long lower shadow).
-
.cdltasukigap(price_ohlc) ⇒ Array<Integer>
Tasuki Gap.
-
.cdlthrusting(price_ohlc) ⇒ Array<Integer>
Thrusting Pattern.
-
.cdltristar(price_ohlc) ⇒ Array<Integer>
Tristar Pattern.
-
.cdlunique3river(price_ohlc) ⇒ Array<Integer>
Unique 3 River.
-
.cdlupsidegap2crows(price_ohlc) ⇒ Array<Integer>
Upside Gap Two Crows.
-
.cdlxsidegap3methods(price_ohlc) ⇒ Array<Integer>
Upside/Downside Gap Three Methods.
-
.ceil(real) ⇒ Array<Float>
Vector Ceil.
-
.check_ta_return_code(code) ⇒ Object
Checks TA-Lib return codes and raises appropriate errors.
-
.cmo(real, time_period: 14.0) ⇒ Array<Float>
Chande Momentum Oscillator.
-
.collect_input_info(func_info) ⇒ Array<Fiddle::CStructEntity>
Collects input parameter information for a function.
-
.collect_opt_input_info(func_info) ⇒ Array<Fiddle::CStructEntity>
Collects optional input parameter information for a function.
-
.collect_output_info(func_info) ⇒ Array<Fiddle::CStructEntity>
Collects output parameter information for a function.
-
.correl(real0, real1, time_period: 30.0) ⇒ Array<Float>
Pearson’s Correlation Coefficient ®.
-
.cos(real) ⇒ Array<Float>
Vector Trigonometric Cos.
-
.cosh(real) ⇒ Array<Float>
Vector Trigonometric Cosh.
-
.create_parameter_holder(handle_ptr) ⇒ Fiddle::Pointer
Creates a parameter holder for a function.
-
.define_ta_function(method_name, func_name) ⇒ Object
Defines a TA-Lib function as a Ruby method with documentation.
-
.dema(real, time_period: 30.0) ⇒ Array<Float>
Double Exponential Moving Average.
-
.div(real0, real1) ⇒ Array<Float>
Vector Arithmetic Div.
-
.dx(price_hlc, time_period: 14.0) ⇒ Array<Float>
Directional Movement Index.
-
.each_function {|func_info| ... } ⇒ Object
Iterates over all available TA-Lib functions.
-
.ema(real, time_period: 30.0) ⇒ Array<Float>
Exponential Moving Average.
-
.exp(real) ⇒ Array<Float>
Vector Arithmetic Exp.
-
.extract_flags(value, type) ⇒ Array<Symbol>
Extracts flags from a bitmask value based on the flag type.
-
.floor(real) ⇒ Array<Float>
Vector Floor.
-
.format_output_results(output_ptrs, size, func_name) ⇒ Array, Hash
Formats output results from TA-Lib function.
-
.function_description_xml ⇒ String
Gets XML description of all TA-Lib functions.
-
.function_info(name) ⇒ Fiddle::CStructEntity
Gets detailed information about a specific TA-Lib function.
-
.function_info_map ⇒ Hash
Gets or builds the function information map.
-
.function_table(group) ⇒ Array<String>
Returns a list of all functions in a specific group.
-
.generate_ta_functions ⇒ Object
Generates Ruby methods for all TA-Lib functions.
-
.get_function_handle(func_name) ⇒ Fiddle::Pointer
Gets a function handle for a given function name.
-
.group_table ⇒ Array<String>
Returns a list of all available function groups in TA-Lib.
-
.ht_dcperiod(real) ⇒ Array<Float>
Hilbert Transform - Dominant Cycle Period.
-
.ht_dcphase(real) ⇒ Array<Float>
Hilbert Transform - Dominant Cycle Phase.
-
.ht_phasor(real) ⇒ Hash
Hilbert Transform - Phasor Components.
-
.ht_sine(real) ⇒ Hash
Hilbert Transform - SineWave.
-
.ht_trendline(real) ⇒ Array<Float>
Hilbert Transform - Instantaneous Trendline.
-
.ht_trendmode(real) ⇒ Array<Integer>
Hilbert Transform - Trend vs Cycle Mode.
-
.imi(price_oc, time_period: 14.0) ⇒ Array<Float>
Intraday Momentum Index.
-
.initialize_ta_lib ⇒ Object
Initializes the TA-Lib library.
-
.kama(real, time_period: 30.0) ⇒ Array<Float>
Kaufman Adaptive Moving Average.
-
.linearreg(real, time_period: 14.0) ⇒ Array<Float>
Linear Regression.
-
.linearreg_angle(real, time_period: 14.0) ⇒ Array<Float>
Linear Regression Angle.
-
.linearreg_intercept(real, time_period: 14.0) ⇒ Array<Float>
Linear Regression Intercept.
-
.linearreg_slope(real, time_period: 14.0) ⇒ Array<Float>
Linear Regression Slope.
-
.ln(real) ⇒ Array<Float>
Vector Log Natural.
-
.log10(real) ⇒ Array<Float>
Vector Log10.
-
.ma(real, time_period: 30.0, ma_type: 0.0) ⇒ Array<Float>
Moving average.
-
.macd(real, fast_period: 12.0, slow_period: 26.0, signal_period: 9.0) ⇒ Hash
Moving Average Convergence/Divergence.
-
.macdext(real, fast_period: 12.0, fast_ma_type: 0.0, slow_period: 26.0, slow_ma_type: 0.0, signal_period: 9.0, signal_ma_type: 0.0) ⇒ Hash
MACD with controllable MA type.
-
.macdfix(real, signal_period: 9.0) ⇒ Hash
Moving Average Convergence/Divergence Fix 12/26.
-
.mama(real, fast_limit: 0.5, slow_limit: 0.05) ⇒ Hash
MESA Adaptive Moving Average.
-
.mavp(real, periods, min_period: 2.0, max_period: 30.0, ma_type: 0.0) ⇒ Array<Float>
Moving average with variable period.
-
.max(real, time_period: 30.0) ⇒ Array<Float>
Highest value over a specified period.
-
.maxindex(real, time_period: 30.0) ⇒ Array<Integer>
Index of highest value over a specified period.
-
.medprice(price_hl) ⇒ Array<Float>
Median Price.
-
.mfi(price_hlcv, time_period: 14.0) ⇒ Array<Float>
Money Flow Index.
-
.midpoint(real, time_period: 14.0) ⇒ Array<Float>
MidPoint over period.
-
.midprice(price_hl, time_period: 14.0) ⇒ Array<Float>
Midpoint Price over period.
-
.min(real, time_period: 30.0) ⇒ Array<Float>
Lowest value over a specified period.
-
.minindex(real, time_period: 30.0) ⇒ Array<Integer>
Index of lowest value over a specified period.
-
.minmax(real, time_period: 30.0) ⇒ Hash
Lowest and highest values over a specified period.
-
.minmaxindex(real, time_period: 30.0) ⇒ Hash
Indexes of lowest and highest values over a specified period.
-
.minus_di(price_hlc, time_period: 14.0) ⇒ Array<Float>
Minus Directional Indicator.
-
.minus_dm(price_hl, time_period: 14.0) ⇒ Array<Float>
Minus Directional Movement.
-
.mom(real, time_period: 10.0) ⇒ Array<Float>
Momentum.
-
.mult(real0, real1) ⇒ Array<Float>
Vector Arithmetic Mult.
-
.natr(price_hlc, time_period: 14.0) ⇒ Array<Float>
Normalized Average True Range.
-
.normalize_parameter_name(name) ⇒ String
Normalizes parameter names to Ruby style.
-
.obv(real, price_v) ⇒ Array<Float>
On Balance Volume.
-
.plus_di(price_hlc, time_period: 14.0) ⇒ Array<Float>
Plus Directional Indicator.
-
.plus_dm(price_hl, time_period: 14.0) ⇒ Array<Float>
Plus Directional Movement.
-
.ppo(real, fast_period: 12.0, slow_period: 26.0, ma_type: 0.0) ⇒ Array<Float>
Percentage Price Oscillator.
-
.prepare_double_array(array) ⇒ Fiddle::Pointer
Prepares a double array for TA-Lib input.
-
.prepare_integer_array(array) ⇒ Fiddle::Pointer
Prepares an integer array for TA-Lib input.
-
.print_function_info(func_info) ⇒ Object
Prints detailed information about a TA-Lib function.
-
.roc(real, time_period: 10.0) ⇒ Array<Float>
Rate of change : ((price/prevPrice)-1)*100.
-
.rocp(real, time_period: 10.0) ⇒ Array<Float>
Rate of change Percentage: (price-prevPrice)/prevPrice.
-
.rocr(real, time_period: 10.0) ⇒ Array<Float>
Rate of change ratio: (price/prevPrice).
-
.rocr100(real, time_period: 10.0) ⇒ Array<Float>
Rate of change ratio 100 scale: (price/prevPrice)*100.
-
.rsi(real, time_period: 14.0) ⇒ Array<Float>
Relative Strength Index.
-
.sar(price_hl, acceleration: 0.02, maximum: 0.2) ⇒ Array<Float>
Parabolic SAR.
-
.sarext(price_hl, start_value: 0.0, offset_on_reverse: 0.0, acceleration_init_long: 0.02, acceleration_long: 0.02, acceleration_max_long: 0.2, acceleration_init_short: 0.02, acceleration_short: 0.02, acceleration_max_short: 0.2) ⇒ Array<Float>
Parabolic SAR - Extended.
-
.set_input_parameter(params_ptr, index, array, input_info) ⇒ Integer
Sets a single input parameter.
-
.set_optional_parameter(params_ptr, index, value, type) ⇒ Object
Sets a single optional parameter.
-
.setup_input_parameters(params_ptr, input_arrays, func_name) ⇒ Object
Sets up input parameters for a function call.
-
.setup_optional_parameters(params_ptr, options, func_name) ⇒ Object
Sets up optional parameters for a function call.
-
.setup_output_buffers(params_ptr, size, func_name) ⇒ Array<Fiddle::Pointer>
Sets up output buffers for function results.
-
.setup_price_inputs(params_ptr, index, price_data, flags) ⇒ Object
Sets up price inputs for functions that take price data.
-
.sin(real) ⇒ Array<Float>
Vector Trigonometric Sin.
-
.sinh(real) ⇒ Array<Float>
Vector Trigonometric Sinh.
-
.sma(real, time_period: 30.0) ⇒ Array<Float>
Simple Moving Average.
-
.sqrt(real) ⇒ Array<Float>
Vector Square Root.
-
.stddev(real, time_period: 5.0, nb_dev: 1.0) ⇒ Array<Float>
Standard Deviation.
-
.stoch(price_hlc, fast_k_period: 5.0, slow_k_period: 3.0, slow_k_ma_type: 0.0, slow_d_period: 3.0, slow_d_ma_type: 0.0) ⇒ Hash
Stochastic.
-
.stochf(price_hlc, fast_k_period: 5.0, fast_d_period: 3.0, fast_d_ma_type: 0.0) ⇒ Hash
Stochastic Fast.
-
.stochrsi(real, time_period: 14.0, fast_k_period: 5.0, fast_d_period: 3.0, fast_d_ma_type: 0.0) ⇒ Hash
Stochastic Relative Strength Index.
-
.sub(real0, real1) ⇒ Array<Float>
Vector Arithmetic Subtraction.
-
.sum(real, time_period: 30.0) ⇒ Array<Float>
Summation.
-
.t3(real, time_period: 5.0, v_factor: 0.7) ⇒ Array<Float>
Triple Exponential Moving Average (T3).
-
.tan(real) ⇒ Array<Float>
Vector Trigonometric Tan.
-
.tanh(real) ⇒ Array<Float>
Vector Trigonometric Tanh.
-
.tema(real, time_period: 30.0) ⇒ Array<Float>
Triple Exponential Moving Average.
-
.trange(price_hlc) ⇒ Array<Float>
True Range.
-
.trima(real, time_period: 30.0) ⇒ Array<Float>
Triangular Moving Average.
-
.trix(real, time_period: 30.0) ⇒ Array<Float>
1-day Rate-Of-Change (ROC) of a Triple Smooth EMA.
-
.tsf(real, time_period: 14.0) ⇒ Array<Float>
Time Series Forecast.
-
.typprice(price_hlc) ⇒ Array<Float>
Typical Price.
-
.ultosc(price_hlc, time_period1: 7.0, time_period2: 14.0, time_period3: 28.0) ⇒ Array<Float>
Ultimate Oscillator.
-
.validate_inputs!(arrays) ⇒ Object
Validates input arrays for TA-Lib functions.
-
.var(real, time_period: 5.0, nb_dev: 1.0) ⇒ Array<Float>
Variance.
-
.wclprice(price_hlc) ⇒ Array<Float>
Weighted Close Price.
-
.willr(price_hlc, time_period: 14.0) ⇒ Array<Float>
Williams’ %R.
-
.wma(real, time_period: 30.0) ⇒ Array<Float>
Weighted Moving Average.
Class Method Details
.accbands(price_hlc, time_period: 20.0) ⇒ Hash
GENERATED DOCUMENTATION START ### Acceleration Bands
|
# File 'lib/ta_lib_ffi.rb', line 792
|
.acos(real) ⇒ Array<Float>
Vector Trigonometric ACos
|
# File 'lib/ta_lib_ffi.rb', line 804
|
.ad(price_hlcv) ⇒ Array<Float>
Chaikin A/D Line
|
# File 'lib/ta_lib_ffi.rb', line 811
|
.add(real0, real1) ⇒ Array<Float>
Vector Arithmetic Add
|
# File 'lib/ta_lib_ffi.rb', line 818
|
.adosc(price_hlcv, fast_period: 3.0, slow_period: 10.0) ⇒ Array<Float>
Chaikin A/D Oscillator
|
# File 'lib/ta_lib_ffi.rb', line 826
|
.adx(price_hlc, time_period: 14.0) ⇒ Array<Float>
Average Directional Movement Index
|
# File 'lib/ta_lib_ffi.rb', line 835
|
.adxr(price_hlc, time_period: 14.0) ⇒ Array<Float>
Average Directional Movement Index Rating
|
# File 'lib/ta_lib_ffi.rb', line 843
|
.apo(real, fast_period: 12.0, slow_period: 26.0, ma_type: 0.0) ⇒ Array<Float>
Absolute Price Oscillator
|
# File 'lib/ta_lib_ffi.rb', line 851
|
.aroon(price_hl, time_period: 14.0) ⇒ Hash
Aroon
|
# File 'lib/ta_lib_ffi.rb', line 861
|
.aroonosc(price_hl, time_period: 14.0) ⇒ Array<Float>
Aroon Oscillator
|
# File 'lib/ta_lib_ffi.rb', line 871
|
.asin(real) ⇒ Array<Float>
Vector Trigonometric ASin
|
# File 'lib/ta_lib_ffi.rb', line 879
|
.atan(real) ⇒ Array<Float>
Vector Trigonometric ATan
|
# File 'lib/ta_lib_ffi.rb', line 886
|
.atr(price_hlc, time_period: 14.0) ⇒ Array<Float>
Average True Range
|
# File 'lib/ta_lib_ffi.rb', line 893
|
.avgdev(real, time_period: 14.0) ⇒ Array<Float>
Average Deviation
|
# File 'lib/ta_lib_ffi.rb', line 908
|
.avgprice(price_ohlc) ⇒ Array<Float>
Average Price
|
# File 'lib/ta_lib_ffi.rb', line 901
|
.bbands(real, time_period: 5.0, nb_dev_up: 2.0, nb_dev_dn: 2.0, ma_type: 0.0) ⇒ Hash
Bollinger Bands
|
# File 'lib/ta_lib_ffi.rb', line 916
|
.beta(real0, real1, time_period: 5.0) ⇒ Array<Float>
Beta
|
# File 'lib/ta_lib_ffi.rb', line 930
|
.bop(price_ohlc) ⇒ Array<Float>
Balance Of Power
|
# File 'lib/ta_lib_ffi.rb', line 939
|
.build_function_info_map ⇒ Hash
Builds a map of function information for all functions
622 623 624 625 626 627 628 629 630 631 632 633 |
# File 'lib/ta_lib_ffi.rb', line 622 def build_function_info_map info_map = {} each_function do |func_info| info_map[func_info["name"].to_s] = { info: func_info, inputs: collect_input_info(func_info), outputs: collect_output_info(func_info), opt_inputs: collect_opt_input_info(func_info) } end info_map end |
.calculate_lookback(params_ptr) ⇒ Integer
Calculates the lookback period for a function with given parameters
388 389 390 391 392 393 |
# File 'lib/ta_lib_ffi.rb', line 388 def calculate_lookback(params_ptr) lookback_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT) ret_code = TA_GetLookback(params_ptr, lookback_ptr) check_ta_return_code(ret_code) lookback_ptr[0, Fiddle::SIZEOF_INT].unpack1("l") end |
.calculate_results(params_ptr, input_size, func_name) ⇒ Array, Hash
Calculates function results
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 |
# File 'lib/ta_lib_ffi.rb', line 529 def calculate_results(params_ptr, input_size, func_name) # rubocop:disable Metrics/MethodLength out_begin = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT) out_size = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT) output_arrays = setup_output_buffers(params_ptr, input_size, func_name) begin ret_code = TA_CallFunc(params_ptr, 0, input_size - 1, out_begin, out_size) check_ta_return_code(ret_code) actual_size = out_size[0, Fiddle::SIZEOF_INT].unpack1("l") format_output_results(output_arrays, actual_size, func_name) ensure out_begin.free out_size.free output_arrays.each(&:free) end end |
.call_func(func_name, args) ⇒ Array, Hash
Calls a TA-Lib function with the given arguments
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
# File 'lib/ta_lib_ffi.rb', line 365 def call_func(func_name, args) # rubocop:disable Metrics/MethodLength = args.last.is_a?(Hash) ? args.pop : {} input_arrays = args validate_inputs!(input_arrays) handle_ptr = get_function_handle(func_name) params_ptr = create_parameter_holder(handle_ptr) begin setup_input_parameters(params_ptr, input_arrays, func_name) setup_optional_parameters(params_ptr, , func_name) _lookback = calculate_lookback(params_ptr) calculate_results(params_ptr, input_arrays.first.length, func_name) ensure TA_ParamHolderFree(params_ptr) end end |
.cci(price_hlc, time_period: 14.0) ⇒ Array<Float>
Commodity Channel Index
|
# File 'lib/ta_lib_ffi.rb', line 946
|
.cdl2crows(price_ohlc) ⇒ Array<Integer>
Two Crows
|
# File 'lib/ta_lib_ffi.rb', line 954
|
.cdl3blackcrows(price_ohlc) ⇒ Array<Integer>
Three Black Crows
|
# File 'lib/ta_lib_ffi.rb', line 961
|
.cdl3inside(price_ohlc) ⇒ Array<Integer>
Three Inside Up/Down
|
# File 'lib/ta_lib_ffi.rb', line 968
|
.cdl3linestrike(price_ohlc) ⇒ Array<Integer>
Three-Line Strike
|
# File 'lib/ta_lib_ffi.rb', line 975
|
.cdl3outside(price_ohlc) ⇒ Array<Integer>
Three Outside Up/Down
|
# File 'lib/ta_lib_ffi.rb', line 982
|
.cdl3starsinsouth(price_ohlc) ⇒ Array<Integer>
Three Stars In The South
|
# File 'lib/ta_lib_ffi.rb', line 989
|
.cdl3whitesoldiers(price_ohlc) ⇒ Array<Integer>
Three Advancing White Soldiers
|
# File 'lib/ta_lib_ffi.rb', line 996
|
.cdlabandonedbaby(price_ohlc, penetration: 0.3) ⇒ Array<Integer>
Abandoned Baby
|
# File 'lib/ta_lib_ffi.rb', line 1003
|
.cdladvanceblock(price_ohlc) ⇒ Array<Integer>
Advance Block
|
# File 'lib/ta_lib_ffi.rb', line 1011
|
.cdlbelthold(price_ohlc) ⇒ Array<Integer>
Belt-hold
|
# File 'lib/ta_lib_ffi.rb', line 1018
|
.cdlbreakaway(price_ohlc) ⇒ Array<Integer>
Breakaway
|
# File 'lib/ta_lib_ffi.rb', line 1025
|
.cdlclosingmarubozu(price_ohlc) ⇒ Array<Integer>
Closing Marubozu
|
# File 'lib/ta_lib_ffi.rb', line 1032
|
.cdlconcealbabyswall(price_ohlc) ⇒ Array<Integer>
Concealing Baby Swallow
|
# File 'lib/ta_lib_ffi.rb', line 1039
|
.cdlcounterattack(price_ohlc) ⇒ Array<Integer>
Counterattack
|
# File 'lib/ta_lib_ffi.rb', line 1046
|
.cdldarkcloudcover(price_ohlc, penetration: 0.5) ⇒ Array<Integer>
Dark Cloud Cover
|
# File 'lib/ta_lib_ffi.rb', line 1053
|
.cdldoji(price_ohlc) ⇒ Array<Integer>
Doji
|
# File 'lib/ta_lib_ffi.rb', line 1061
|
.cdldojistar(price_ohlc) ⇒ Array<Integer>
Doji Star
|
# File 'lib/ta_lib_ffi.rb', line 1068
|
.cdldragonflydoji(price_ohlc) ⇒ Array<Integer>
Dragonfly Doji
|
# File 'lib/ta_lib_ffi.rb', line 1075
|
.cdlengulfing(price_ohlc) ⇒ Array<Integer>
Engulfing Pattern
|
# File 'lib/ta_lib_ffi.rb', line 1082
|
.cdleveningdojistar(price_ohlc, penetration: 0.3) ⇒ Array<Integer>
Evening Doji Star
|
# File 'lib/ta_lib_ffi.rb', line 1089
|
.cdleveningstar(price_ohlc, penetration: 0.3) ⇒ Array<Integer>
Evening Star
|
# File 'lib/ta_lib_ffi.rb', line 1097
|
.cdlgapsidesidewhite(price_ohlc) ⇒ Array<Integer>
Up/Down-gap side-by-side white lines
|
# File 'lib/ta_lib_ffi.rb', line 1105
|
.cdlgravestonedoji(price_ohlc) ⇒ Array<Integer>
Gravestone Doji
|
# File 'lib/ta_lib_ffi.rb', line 1112
|
.cdlhammer(price_ohlc) ⇒ Array<Integer>
Hammer
|
# File 'lib/ta_lib_ffi.rb', line 1119
|
.cdlhangingman(price_ohlc) ⇒ Array<Integer>
Hanging Man
|
# File 'lib/ta_lib_ffi.rb', line 1126
|
.cdlharami(price_ohlc) ⇒ Array<Integer>
Harami Pattern
|
# File 'lib/ta_lib_ffi.rb', line 1133
|
.cdlharamicross(price_ohlc) ⇒ Array<Integer>
Harami Cross Pattern
|
# File 'lib/ta_lib_ffi.rb', line 1140
|
.cdlhighwave(price_ohlc) ⇒ Array<Integer>
High-Wave Candle
|
# File 'lib/ta_lib_ffi.rb', line 1147
|
.cdlhikkake(price_ohlc) ⇒ Array<Integer>
Hikkake Pattern
|
# File 'lib/ta_lib_ffi.rb', line 1154
|
.cdlhikkakemod(price_ohlc) ⇒ Array<Integer>
Modified Hikkake Pattern
|
# File 'lib/ta_lib_ffi.rb', line 1161
|
.cdlhomingpigeon(price_ohlc) ⇒ Array<Integer>
Homing Pigeon
|
# File 'lib/ta_lib_ffi.rb', line 1168
|
.cdlidentical3crows(price_ohlc) ⇒ Array<Integer>
Identical Three Crows
|
# File 'lib/ta_lib_ffi.rb', line 1175
|
.cdlinneck(price_ohlc) ⇒ Array<Integer>
In-Neck Pattern
|
# File 'lib/ta_lib_ffi.rb', line 1182
|
.cdlinvertedhammer(price_ohlc) ⇒ Array<Integer>
Inverted Hammer
|
# File 'lib/ta_lib_ffi.rb', line 1189
|
.cdlkicking(price_ohlc) ⇒ Array<Integer>
Kicking
|
# File 'lib/ta_lib_ffi.rb', line 1196
|
.cdlkickingbylength(price_ohlc) ⇒ Array<Integer>
Kicking - bull/bear determined by the longer marubozu
|
# File 'lib/ta_lib_ffi.rb', line 1203
|
.cdlladderbottom(price_ohlc) ⇒ Array<Integer>
Ladder Bottom
|
# File 'lib/ta_lib_ffi.rb', line 1210
|
.cdllongleggeddoji(price_ohlc) ⇒ Array<Integer>
Long Legged Doji
|
# File 'lib/ta_lib_ffi.rb', line 1217
|
.cdllongline(price_ohlc) ⇒ Array<Integer>
Long Line Candle
|
# File 'lib/ta_lib_ffi.rb', line 1224
|
.cdlmarubozu(price_ohlc) ⇒ Array<Integer>
Marubozu
|
# File 'lib/ta_lib_ffi.rb', line 1231
|
.cdlmatchinglow(price_ohlc) ⇒ Array<Integer>
Matching Low
|
# File 'lib/ta_lib_ffi.rb', line 1238
|
.cdlmathold(price_ohlc, penetration: 0.5) ⇒ Array<Integer>
Mat Hold
|
# File 'lib/ta_lib_ffi.rb', line 1245
|
.cdlmorningdojistar(price_ohlc, penetration: 0.3) ⇒ Array<Integer>
Morning Doji Star
|
# File 'lib/ta_lib_ffi.rb', line 1253
|
.cdlmorningstar(price_ohlc, penetration: 0.3) ⇒ Array<Integer>
Morning Star
|
# File 'lib/ta_lib_ffi.rb', line 1261
|
.cdlonneck(price_ohlc) ⇒ Array<Integer>
On-Neck Pattern
|
# File 'lib/ta_lib_ffi.rb', line 1269
|
.cdlpiercing(price_ohlc) ⇒ Array<Integer>
Piercing Pattern
|
# File 'lib/ta_lib_ffi.rb', line 1276
|
.cdlrickshawman(price_ohlc) ⇒ Array<Integer>
Rickshaw Man
|
# File 'lib/ta_lib_ffi.rb', line 1283
|
.cdlrisefall3methods(price_ohlc) ⇒ Array<Integer>
Rising/Falling Three Methods
|
# File 'lib/ta_lib_ffi.rb', line 1290
|
.cdlseparatinglines(price_ohlc) ⇒ Array<Integer>
Separating Lines
|
# File 'lib/ta_lib_ffi.rb', line 1297
|
.cdlshootingstar(price_ohlc) ⇒ Array<Integer>
Shooting Star
|
# File 'lib/ta_lib_ffi.rb', line 1304
|
.cdlshortline(price_ohlc) ⇒ Array<Integer>
Short Line Candle
|
# File 'lib/ta_lib_ffi.rb', line 1311
|
.cdlspinningtop(price_ohlc) ⇒ Array<Integer>
Spinning Top
|
# File 'lib/ta_lib_ffi.rb', line 1318
|
.cdlstalledpattern(price_ohlc) ⇒ Array<Integer>
Stalled Pattern
|
# File 'lib/ta_lib_ffi.rb', line 1325
|
.cdlsticksandwich(price_ohlc) ⇒ Array<Integer>
Stick Sandwich
|
# File 'lib/ta_lib_ffi.rb', line 1332
|
.cdltakuri(price_ohlc) ⇒ Array<Integer>
Takuri (Dragonfly Doji with very long lower shadow)
|
# File 'lib/ta_lib_ffi.rb', line 1339
|
.cdltasukigap(price_ohlc) ⇒ Array<Integer>
Tasuki Gap
|
# File 'lib/ta_lib_ffi.rb', line 1346
|
.cdlthrusting(price_ohlc) ⇒ Array<Integer>
Thrusting Pattern
|
# File 'lib/ta_lib_ffi.rb', line 1353
|
.cdltristar(price_ohlc) ⇒ Array<Integer>
Tristar Pattern
|
# File 'lib/ta_lib_ffi.rb', line 1360
|
.cdlunique3river(price_ohlc) ⇒ Array<Integer>
Unique 3 River
|
# File 'lib/ta_lib_ffi.rb', line 1367
|
.cdlupsidegap2crows(price_ohlc) ⇒ Array<Integer>
Upside Gap Two Crows
|
# File 'lib/ta_lib_ffi.rb', line 1374
|
.cdlxsidegap3methods(price_ohlc) ⇒ Array<Integer>
Upside/Downside Gap Three Methods
|
# File 'lib/ta_lib_ffi.rb', line 1381
|
.ceil(real) ⇒ Array<Float>
Vector Ceil
|
# File 'lib/ta_lib_ffi.rb', line 1388
|
.check_ta_return_code(code) ⇒ Object
Checks TA-Lib return codes and raises appropriate errors
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 |
# File 'lib/ta_lib_ffi.rb', line 698 def check_ta_return_code(code) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength return if code == TA_SUCCESS = case code when TA_LIB_NOT_INITIALIZE "TA-Lib not initialized, please call TA_Initialize first" when TA_BAD_PARAM "Bad parameter, please check input parameters" when TA_ALLOC_ERR "Memory allocation error, possibly insufficient memory" when TA_GROUP_NOT_FOUND "Function group not found" when TA_FUNC_NOT_FOUND "Function not found" when TA_INVALID_HANDLE "Invalid handle" when TA_INVALID_PARAM_HOLDER "Invalid parameter holder" when TA_INVALID_PARAM_HOLDER_TYPE "Invalid parameter holder type" when TA_INVALID_PARAM_FUNCTION "Invalid parameter function" when TA_INPUT_NOT_ALL_INITIALIZE "Input parameters not fully initialized" when TA_OUTPUT_NOT_ALL_INITIALIZE "Output parameters not fully initialized" when TA_OUT_OF_RANGE_START_INDEX "Start index out of range" when TA_OUT_OF_RANGE_END_INDEX "End index out of range" when TA_INVALID_LIST_TYPE "Invalid list type" when TA_BAD_OBJECT "Invalid object" when TA_NOT_SUPPORTED "Operation not supported" when TA_INTERNAL_ERROR "TA-Lib internal error" when TA_UNKNOWN_ERR "Unknown error" else "Undefined TA-Lib error (Error code: #{code})" end raise TALibError, end |
.cmo(real, time_period: 14.0) ⇒ Array<Float>
Chande Momentum Oscillator
|
# File 'lib/ta_lib_ffi.rb', line 1395
|
.collect_input_info(func_info) ⇒ Array<Fiddle::CStructEntity>
Collects input parameter information for a function
639 640 641 642 643 644 645 |
# File 'lib/ta_lib_ffi.rb', line 639 def collect_input_info(func_info) func_info["nbInput"].times.map do |i| param_info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP) TA_GetInputParameterInfo(func_info["handle"], i, param_info_ptr.ref) TA_InputParameterInfo.new(param_info_ptr) end end |
.collect_opt_input_info(func_info) ⇒ Array<Fiddle::CStructEntity>
Collects optional input parameter information for a function
651 652 653 654 655 656 657 |
# File 'lib/ta_lib_ffi.rb', line 651 def collect_opt_input_info(func_info) func_info["nbOptInput"].times.map do |i| param_info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP) TA_GetOptInputParameterInfo(func_info["handle"], i, param_info_ptr.ref) TA_OptInputParameterInfo.new(param_info_ptr) end end |
.collect_output_info(func_info) ⇒ Array<Fiddle::CStructEntity>
Collects output parameter information for a function
663 664 665 666 667 668 669 |
# File 'lib/ta_lib_ffi.rb', line 663 def collect_output_info(func_info) func_info["nbOutput"].times.map do |i| param_info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP) TA_GetOutputParameterInfo(func_info["handle"], i, param_info_ptr.ref) TA_OutputParameterInfo.new(param_info_ptr) end end |
.correl(real0, real1, time_period: 30.0) ⇒ Array<Float>
Pearson’s Correlation Coefficient ®
|
# File 'lib/ta_lib_ffi.rb', line 1403
|
.cos(real) ⇒ Array<Float>
Vector Trigonometric Cos
|
# File 'lib/ta_lib_ffi.rb', line 1412
|
.cosh(real) ⇒ Array<Float>
Vector Trigonometric Cosh
|
# File 'lib/ta_lib_ffi.rb', line 1419
|
.create_parameter_holder(handle_ptr) ⇒ Fiddle::Pointer
Creates a parameter holder for a function
429 430 431 432 433 434 |
# File 'lib/ta_lib_ffi.rb', line 429 def create_parameter_holder(handle_ptr) params_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP) ret_code = TA_ParamHolderAlloc(handle_ptr, params_ptr.ref) check_ta_return_code(ret_code) params_ptr end |
.define_ta_function(method_name, func_name) ⇒ Object
Defines a TA-Lib function as a Ruby method with documentation
759 760 761 762 763 |
# File 'lib/ta_lib_ffi.rb', line 759 def define_ta_function(method_name, func_name) define_singleton_method(method_name) do |*args| call_func(func_name, args) end end |
.dema(real, time_period: 30.0) ⇒ Array<Float>
Double Exponential Moving Average
|
# File 'lib/ta_lib_ffi.rb', line 1426
|
.div(real0, real1) ⇒ Array<Float>
Vector Arithmetic Div
|
# File 'lib/ta_lib_ffi.rb', line 1434
|
.dx(price_hlc, time_period: 14.0) ⇒ Array<Float>
Directional Movement Index
|
# File 'lib/ta_lib_ffi.rb', line 1442
|
.each_function {|func_info| ... } ⇒ Object
Iterates over all available TA-Lib functions
292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/ta_lib_ffi.rb', line 292 def each_function(&block) callback = Fiddle::Closure::BlockCaller.new( Fiddle::TYPE_VOID, [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP], Fiddle::Function::DEFAULT ) do |func_info_ptr, _| block.call TA_FuncInfo.new(func_info_ptr) end ret_code = TA_ForEachFunc(callback, nil) check_ta_return_code(ret_code) end |
.ema(real, time_period: 30.0) ⇒ Array<Float>
Exponential Moving Average
|
# File 'lib/ta_lib_ffi.rb', line 1450
|
.exp(real) ⇒ Array<Float>
Vector Arithmetic Exp
|
# File 'lib/ta_lib_ffi.rb', line 1458
|
.extract_flags(value, type) ⇒ Array<Symbol>
Extracts flags from a bitmask value based on the flag type
232 233 234 235 236 237 238 |
# File 'lib/ta_lib_ffi.rb', line 232 def extract_flags(value, type) flags_set = [] TA_FLAGS[type].each do |k, v| flags_set << k if (value & v) != 0 end flags_set end |
.floor(real) ⇒ Array<Float>
Vector Floor
|
# File 'lib/ta_lib_ffi.rb', line 1465
|
.format_output_results(output_ptrs, size, func_name) ⇒ Array, Hash
Formats output results from TA-Lib function
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 |
# File 'lib/ta_lib_ffi.rb', line 586 def format_output_results(output_ptrs, size, func_name) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength func_info = function_info_map[func_name] results = output_ptrs.zip(func_info[:outputs]).map do |ptr, output| case output["type"] when TA_PARAM_TYPE[:TA_Output_Real] ptr[0, Fiddle::SIZEOF_DOUBLE * size].unpack("d#{size}") when TA_PARAM_TYPE[:TA_Output_Integer] ptr[0, Fiddle::SIZEOF_INT * size].unpack("l#{size}") end end return results.first if results.length == 1 output_names = func_info[:outputs].map do |output| normalize_parameter_name(output["paramName"].to_s).to_sym end output_names.zip(results).to_h end |
.function_description_xml ⇒ String
Gets XML description of all TA-Lib functions
608 609 610 |
# File 'lib/ta_lib_ffi.rb', line 608 def function_description_xml TA_FunctionDescriptionXML().to_s end |
.function_info(name) ⇒ Fiddle::CStructEntity
Gets detailed information about a specific TA-Lib function
276 277 278 279 280 281 282 283 284 285 286 |
# File 'lib/ta_lib_ffi.rb', line 276 def function_info(name) handle_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP) ret_code = TA_GetFuncHandle(name, handle_ptr.ref) check_ta_return_code(ret_code) info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP) ret_code = TA_GetFuncInfo(handle_ptr, info_ptr.ref) check_ta_return_code(ret_code) TA_FuncInfo.new(info_ptr) end |
.function_info_map ⇒ Hash
Gets or builds the function information map
615 616 617 |
# File 'lib/ta_lib_ffi.rb', line 615 def function_info_map @function_info_map ||= build_function_info_map end |
.function_table(group) ⇒ Array<String>
Returns a list of all functions in a specific group
259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/ta_lib_ffi.rb', line 259 def function_table(group) string_table_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP) ret_code = TA_FuncTableAlloc(group, string_table_ptr.ref) check_ta_return_code(ret_code) string_table = TA_StringTable.new(string_table_ptr) func_names = Fiddle::Pointer.new(string_table["string"])[0, Fiddle::SIZEOF_VOIDP * string_table["size"]].unpack("Q*").collect { |ptr| Fiddle::Pointer.new(ptr).to_s } TA_FuncTableFree(string_table) func_names end |
.generate_ta_functions ⇒ Object
Generates Ruby methods for all TA-Lib functions
This method iterates through all available TA-Lib functions and creates corresponding Ruby methods with proper documentation.
675 676 677 678 679 |
# File 'lib/ta_lib_ffi.rb', line 675 def generate_ta_functions each_function do |func_info| define_ta_function(func_info["name"].to_s.downcase, func_info["name"].to_s) end end |
.get_function_handle(func_name) ⇒ Fiddle::Pointer
Gets a function handle for a given function name
418 419 420 421 422 423 |
# File 'lib/ta_lib_ffi.rb', line 418 def get_function_handle(func_name) handle_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP) ret_code = TA_GetFuncHandle(func_name, handle_ptr.ref) check_ta_return_code(ret_code) handle_ptr end |
.group_table ⇒ Array<String>
Returns a list of all available function groups in TA-Lib
243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/ta_lib_ffi.rb', line 243 def group_table string_table_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP) ret_code = TA_GroupTableAlloc(string_table_ptr.ref) check_ta_return_code(ret_code) string_table = TA_StringTable.new(string_table_ptr) group_names = Fiddle::Pointer.new(string_table["string"])[0, Fiddle::SIZEOF_VOIDP * string_table["size"]].unpack("Q*").collect { |ptr| Fiddle::Pointer.new(ptr).to_s } TA_GroupTableFree(string_table_ptr) group_names end |
.ht_dcperiod(real) ⇒ Array<Float>
Hilbert Transform - Dominant Cycle Period
|
# File 'lib/ta_lib_ffi.rb', line 1472
|
.ht_dcphase(real) ⇒ Array<Float>
Hilbert Transform - Dominant Cycle Phase
|
# File 'lib/ta_lib_ffi.rb', line 1479
|
.ht_phasor(real) ⇒ Hash
Hilbert Transform - Phasor Components
|
# File 'lib/ta_lib_ffi.rb', line 1486
|
.ht_sine(real) ⇒ Hash
Hilbert Transform - SineWave
|
# File 'lib/ta_lib_ffi.rb', line 1495
|
.ht_trendline(real) ⇒ Array<Float>
Hilbert Transform - Instantaneous Trendline
|
# File 'lib/ta_lib_ffi.rb', line 1504
|
.ht_trendmode(real) ⇒ Array<Integer>
Hilbert Transform - Trend vs Cycle Mode
|
# File 'lib/ta_lib_ffi.rb', line 1511
|
.imi(price_oc, time_period: 14.0) ⇒ Array<Float>
Intraday Momentum Index
|
# File 'lib/ta_lib_ffi.rb', line 1518
|
.initialize_ta_lib ⇒ Object
Initializes the TA-Lib library
746 747 748 749 750 751 752 753 |
# File 'lib/ta_lib_ffi.rb', line 746 def initialize_ta_lib return if @initialized ret_code = TA_Initialize() check_ta_return_code(ret_code) at_exit { TA_Shutdown() } @initialized = true end |
.kama(real, time_period: 30.0) ⇒ Array<Float>
Kaufman Adaptive Moving Average
|
# File 'lib/ta_lib_ffi.rb', line 1526
|
.linearreg(real, time_period: 14.0) ⇒ Array<Float>
Linear Regression
|
# File 'lib/ta_lib_ffi.rb', line 1534
|
.linearreg_angle(real, time_period: 14.0) ⇒ Array<Float>
Linear Regression Angle
|
# File 'lib/ta_lib_ffi.rb', line 1542
|
.linearreg_intercept(real, time_period: 14.0) ⇒ Array<Float>
Linear Regression Intercept
|
# File 'lib/ta_lib_ffi.rb', line 1550
|
.linearreg_slope(real, time_period: 14.0) ⇒ Array<Float>
Linear Regression Slope
|
# File 'lib/ta_lib_ffi.rb', line 1558
|
.ln(real) ⇒ Array<Float>
Vector Log Natural
|
# File 'lib/ta_lib_ffi.rb', line 1566
|
.log10(real) ⇒ Array<Float>
Vector Log10
|
# File 'lib/ta_lib_ffi.rb', line 1573
|
.ma(real, time_period: 30.0, ma_type: 0.0) ⇒ Array<Float>
Moving average
|
# File 'lib/ta_lib_ffi.rb', line 1580
|
.macd(real, fast_period: 12.0, slow_period: 26.0, signal_period: 9.0) ⇒ Hash
Moving Average Convergence/Divergence
|
# File 'lib/ta_lib_ffi.rb', line 1589
|
.macdext(real, fast_period: 12.0, fast_ma_type: 0.0, slow_period: 26.0, slow_ma_type: 0.0, signal_period: 9.0, signal_ma_type: 0.0) ⇒ Hash
MACD with controllable MA type
|
# File 'lib/ta_lib_ffi.rb', line 1602
|
.macdfix(real, signal_period: 9.0) ⇒ Hash
Moving Average Convergence/Divergence Fix 12/26
|
# File 'lib/ta_lib_ffi.rb', line 1618
|
.mama(real, fast_limit: 0.5, slow_limit: 0.05) ⇒ Hash
MESA Adaptive Moving Average
|
# File 'lib/ta_lib_ffi.rb', line 1629
|
.mavp(real, periods, min_period: 2.0, max_period: 30.0, ma_type: 0.0) ⇒ Array<Float>
Moving average with variable period
|
# File 'lib/ta_lib_ffi.rb', line 1640
|
.max(real, time_period: 30.0) ⇒ Array<Float>
Highest value over a specified period
|
# File 'lib/ta_lib_ffi.rb', line 1651
|
.maxindex(real, time_period: 30.0) ⇒ Array<Integer>
Index of highest value over a specified period
|
# File 'lib/ta_lib_ffi.rb', line 1659
|
.medprice(price_hl) ⇒ Array<Float>
Median Price
|
# File 'lib/ta_lib_ffi.rb', line 1667
|
.mfi(price_hlcv, time_period: 14.0) ⇒ Array<Float>
Money Flow Index
|
# File 'lib/ta_lib_ffi.rb', line 1674
|
.midpoint(real, time_period: 14.0) ⇒ Array<Float>
MidPoint over period
|
# File 'lib/ta_lib_ffi.rb', line 1682
|
.midprice(price_hl, time_period: 14.0) ⇒ Array<Float>
Midpoint Price over period
|
# File 'lib/ta_lib_ffi.rb', line 1690
|
.min(real, time_period: 30.0) ⇒ Array<Float>
Lowest value over a specified period
|
# File 'lib/ta_lib_ffi.rb', line 1698
|
.minindex(real, time_period: 30.0) ⇒ Array<Integer>
Index of lowest value over a specified period
|
# File 'lib/ta_lib_ffi.rb', line 1706
|
.minmax(real, time_period: 30.0) ⇒ Hash
Lowest and highest values over a specified period
|
# File 'lib/ta_lib_ffi.rb', line 1714
|
.minmaxindex(real, time_period: 30.0) ⇒ Hash
Indexes of lowest and highest values over a specified period
|
# File 'lib/ta_lib_ffi.rb', line 1724
|
.minus_di(price_hlc, time_period: 14.0) ⇒ Array<Float>
Minus Directional Indicator
|
# File 'lib/ta_lib_ffi.rb', line 1734
|
.minus_dm(price_hl, time_period: 14.0) ⇒ Array<Float>
Minus Directional Movement
|
# File 'lib/ta_lib_ffi.rb', line 1742
|
.mom(real, time_period: 10.0) ⇒ Array<Float>
Momentum
|
# File 'lib/ta_lib_ffi.rb', line 1750
|
.mult(real0, real1) ⇒ Array<Float>
Vector Arithmetic Mult
|
# File 'lib/ta_lib_ffi.rb', line 1758
|
.natr(price_hlc, time_period: 14.0) ⇒ Array<Float>
Normalized Average True Range
|
# File 'lib/ta_lib_ffi.rb', line 1766
|
.normalize_parameter_name(name) ⇒ String
Normalizes parameter names to Ruby style
685 686 687 688 689 690 691 692 |
# File 'lib/ta_lib_ffi.rb', line 685 def normalize_parameter_name(name) name.sub(/^(optIn|outReal|outInteger|out|in)/, "") .gsub(/::/, "/") .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr("-", "_") .downcase end |
.obv(real, price_v) ⇒ Array<Float>
On Balance Volume
|
# File 'lib/ta_lib_ffi.rb', line 1774
|
.plus_di(price_hlc, time_period: 14.0) ⇒ Array<Float>
Plus Directional Indicator
|
# File 'lib/ta_lib_ffi.rb', line 1782
|
.plus_dm(price_hl, time_period: 14.0) ⇒ Array<Float>
Plus Directional Movement
|
# File 'lib/ta_lib_ffi.rb', line 1790
|
.ppo(real, fast_period: 12.0, slow_period: 26.0, ma_type: 0.0) ⇒ Array<Float>
Percentage Price Oscillator
|
# File 'lib/ta_lib_ffi.rb', line 1798
|
.prepare_double_array(array) ⇒ Fiddle::Pointer
Prepares a double array for TA-Lib input
474 475 476 477 478 479 480 |
# File 'lib/ta_lib_ffi.rb', line 474 def prepare_double_array(array) array_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE * array.length) array.each_with_index do |value, i| array_ptr[i * Fiddle::SIZEOF_DOUBLE, Fiddle::SIZEOF_DOUBLE] = [value.to_f].pack("d") end array_ptr end |
.prepare_integer_array(array) ⇒ Fiddle::Pointer
Prepares an integer array for TA-Lib input
486 487 488 489 490 491 492 |
# File 'lib/ta_lib_ffi.rb', line 486 def prepare_integer_array(array) array_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT * array.length) array.each_with_index do |value, i| array_ptr[i * Fiddle::SIZEOF_INT, Fiddle::SIZEOF_INT] = [value.to_i].pack("l") end array_ptr end |
.print_function_info(func_info) ⇒ Object
Prints detailed information about a TA-Lib function
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# File 'lib/ta_lib_ffi.rb', line 308 def print_function_info(func_info) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength puts "Function Name: #{func_info["name"]}" puts "Function Group: #{func_info["group"]}" puts "Function Hint: #{func_info["hint"]}" puts "Camel Case Name: #{func_info["camelCaseName"]}" puts "Flags: #{func_info["flags"]}" puts "Number of Inputs: #{func_info["nbInput"]}" puts "Number of Optional Inputs: #{func_info["nbOptInput"]}" puts "Number of Outputs: #{func_info["nbOutput"]}" puts "Function Handle: #{func_info["handle"].to_i}" puts "\nInput Parameter Info:" func_info["nbInput"].times do |i| param_info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP) ret_code = TA_GetInputParameterInfo(func_info["handle"], i, param_info_ptr.ref) check_ta_return_code(ret_code) param_info = TA_InputParameterInfo.new(param_info_ptr) puts " Parameter #{i + 1}:" puts " Name: #{param_info["paramName"]}" puts " Type: #{param_info["type"]}" puts " Flags: #{extract_flags(param_info["flags"], :TA_InputFlags)}" end puts "\nOptional Input Parameter Info:" func_info["nbOptInput"].times do |i| param_info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP) ret_code = TA_GetOptInputParameterInfo(func_info["handle"], i, param_info_ptr.ref) check_ta_return_code(ret_code) param_info = TA_OptInputParameterInfo.new(param_info_ptr) puts " Parameter #{i + 1}:" puts " Name: #{param_info["paramName"]}" puts " Type: #{param_info["type"]}" puts " Flags: #{extract_flags(param_info["flags"], :TA_OptInputFlags)}" puts " Display Name: #{param_info["displayName"]}" puts " Default Value: #{param_info["defaultValue"]}" puts " Hint: #{param_info["hint"]}" end puts "\nOutput Parameter Info:" func_info["nbOutput"].times do |i| param_info_ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP) ret_code = TA_GetOutputParameterInfo(func_info["handle"], i, param_info_ptr.ref) check_ta_return_code(ret_code) param_info = TA_OutputParameterInfo.new(param_info_ptr) puts " Parameter #{i + 1}:" puts " Name: #{param_info["paramName"]}" puts " Type: #{param_info["type"]}" puts " Flags: #{extract_flags(param_info["flags"], :TA_OutputFlags)}" end end |
.roc(real, time_period: 10.0) ⇒ Array<Float>
Rate of change : ((price/prevPrice)-1)*100
|
# File 'lib/ta_lib_ffi.rb', line 1808
|
.rocp(real, time_period: 10.0) ⇒ Array<Float>
Rate of change Percentage: (price-prevPrice)/prevPrice
|
# File 'lib/ta_lib_ffi.rb', line 1816
|
.rocr(real, time_period: 10.0) ⇒ Array<Float>
Rate of change ratio: (price/prevPrice)
|
# File 'lib/ta_lib_ffi.rb', line 1824
|
.rocr100(real, time_period: 10.0) ⇒ Array<Float>
Rate of change ratio 100 scale: (price/prevPrice)*100
|
# File 'lib/ta_lib_ffi.rb', line 1832
|
.rsi(real, time_period: 14.0) ⇒ Array<Float>
Relative Strength Index
|
# File 'lib/ta_lib_ffi.rb', line 1840
|
.sar(price_hl, acceleration: 0.02, maximum: 0.2) ⇒ Array<Float>
Parabolic SAR
|
# File 'lib/ta_lib_ffi.rb', line 1848
|
.sarext(price_hl, start_value: 0.0, offset_on_reverse: 0.0, acceleration_init_long: 0.02, acceleration_long: 0.02, acceleration_max_long: 0.2, acceleration_init_short: 0.02, acceleration_short: 0.02, acceleration_max_short: 0.2) ⇒ Array<Float>
Parabolic SAR - Extended
|
# File 'lib/ta_lib_ffi.rb', line 1857
|
.set_input_parameter(params_ptr, index, array, input_info) ⇒ Integer
Sets a single input parameter
457 458 459 460 461 462 463 464 465 466 467 468 |
# File 'lib/ta_lib_ffi.rb', line 457 def set_input_parameter(params_ptr, index, array, input_info) case input_info["type"] when TA_PARAM_TYPE[:TA_Input_Real] input_ptr = prepare_double_array(array) TA_SetInputParamRealPtr(params_ptr, index, input_ptr) when TA_PARAM_TYPE[:TA_Input_Integer] input_ptr = prepare_integer_array(array) TA_SetInputParamIntegerPtr(params_ptr, index, input_ptr) when TA_PARAM_TYPE[:TA_Input_Price] setup_price_inputs(params_ptr, index, array, input_info["flags"]) end end |
.set_optional_parameter(params_ptr, index, value, type) ⇒ Object
Sets a single optional parameter
513 514 515 516 517 518 519 520 521 |
# File 'lib/ta_lib_ffi.rb', line 513 def set_optional_parameter(params_ptr, index, value, type) case type when TA_PARAM_TYPE[:TA_OptInput_RealRange], TA_PARAM_TYPE[:TA_OptInput_RealList] ret_code = TA_SetOptInputParamReal(params_ptr, index, value) when TA_PARAM_TYPE[:TA_OptInput_IntegerRange], TA_PARAM_TYPE[:TA_OptInput_IntegerList] ret_code = TA_SetOptInputParamInteger(params_ptr, index, value) end check_ta_return_code(ret_code) end |
.setup_input_parameters(params_ptr, input_arrays, func_name) ⇒ Object
Sets up input parameters for a function call
441 442 443 444 445 446 447 448 |
# File 'lib/ta_lib_ffi.rb', line 441 def setup_input_parameters(params_ptr, input_arrays, func_name) func_info = function_info_map[func_name] input_arrays.each_with_index do |array, index| input_info = func_info[:inputs][index] ret_code = set_input_parameter(params_ptr, index, array, input_info) check_ta_return_code(ret_code) end end |
.setup_optional_parameters(params_ptr, options, func_name) ⇒ Object
Sets up optional parameters for a function call
499 500 501 502 503 504 505 |
# File 'lib/ta_lib_ffi.rb', line 499 def setup_optional_parameters(params_ptr, , func_name) func_info = function_info_map[func_name] func_info[:opt_inputs]&.each_with_index do |opt_input, index| param_name = normalize_parameter_name(opt_input["paramName"].to_s) set_optional_parameter(params_ptr, index, [param_name.to_sym], opt_input["type"]) if .key?(param_name.to_sym) end end |
.setup_output_buffers(params_ptr, size, func_name) ⇒ Array<Fiddle::Pointer>
Sets up output buffers for function results
553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 |
# File 'lib/ta_lib_ffi.rb', line 553 def setup_output_buffers(params_ptr, size, func_name) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize func_info = function_info_map[func_name] output_ptrs = [] func_info[:outputs].each_with_index do |output, index| ptr = case output["type"] when TA_PARAM_TYPE[:TA_Output_Real] Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE * size) when TA_PARAM_TYPE[:TA_Output_Integer] Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT * size) end output_ptrs << ptr ret_code = case output["type"] when TA_PARAM_TYPE[:TA_Output_Real] TA_SetOutputParamRealPtr(params_ptr, index, ptr) when TA_PARAM_TYPE[:TA_Output_Integer] TA_SetOutputParamIntegerPtr(params_ptr, index, ptr) end check_ta_return_code(ret_code) end output_ptrs end |
.setup_price_inputs(params_ptr, index, price_data, flags) ⇒ Object
Sets up price inputs for functions that take price data
771 772 773 774 775 776 777 778 779 780 781 782 783 |
# File 'lib/ta_lib_ffi.rb', line 771 def setup_price_inputs(params_ptr, index, price_data, flags) required_flags = extract_flags(flags, :TA_InputFlags) data_pointers = Array.new(6) { nil } TA_FLAGS[:TA_InputFlags].keys[0..5].each_with_index do |flag, i| data_pointers[i] = if required_flags.include?(flag) prepare_double_array(price_data[required_flags.index(flag)]) else Fiddle::Pointer.malloc(0) end end TA_SetInputParamPricePtr(params_ptr, index, *data_pointers) end |
.sin(real) ⇒ Array<Float>
Vector Trigonometric Sin
|
# File 'lib/ta_lib_ffi.rb', line 1872
|
.sinh(real) ⇒ Array<Float>
Vector Trigonometric Sinh
|
# File 'lib/ta_lib_ffi.rb', line 1879
|
.sma(real, time_period: 30.0) ⇒ Array<Float>
Simple Moving Average
|
# File 'lib/ta_lib_ffi.rb', line 1886
|
.sqrt(real) ⇒ Array<Float>
Vector Square Root
|
# File 'lib/ta_lib_ffi.rb', line 1894
|
.stddev(real, time_period: 5.0, nb_dev: 1.0) ⇒ Array<Float>
Standard Deviation
|
# File 'lib/ta_lib_ffi.rb', line 1901
|
.stoch(price_hlc, fast_k_period: 5.0, slow_k_period: 3.0, slow_k_ma_type: 0.0, slow_d_period: 3.0, slow_d_ma_type: 0.0) ⇒ Hash
Stochastic
|
# File 'lib/ta_lib_ffi.rb', line 1910
|
.stochf(price_hlc, fast_k_period: 5.0, fast_d_period: 3.0, fast_d_ma_type: 0.0) ⇒ Hash
Stochastic Fast
|
# File 'lib/ta_lib_ffi.rb', line 1924
|
.stochrsi(real, time_period: 14.0, fast_k_period: 5.0, fast_d_period: 3.0, fast_d_ma_type: 0.0) ⇒ Hash
Stochastic Relative Strength Index
|
# File 'lib/ta_lib_ffi.rb', line 1936
|
.sub(real0, real1) ⇒ Array<Float>
Vector Arithmetic Subtraction
|
# File 'lib/ta_lib_ffi.rb', line 1949
|
.sum(real, time_period: 30.0) ⇒ Array<Float>
Summation
|
# File 'lib/ta_lib_ffi.rb', line 1957
|
.t3(real, time_period: 5.0, v_factor: 0.7) ⇒ Array<Float>
Triple Exponential Moving Average (T3)
|
# File 'lib/ta_lib_ffi.rb', line 1965
|
.tan(real) ⇒ Array<Float>
Vector Trigonometric Tan
|
# File 'lib/ta_lib_ffi.rb', line 1974
|
.tanh(real) ⇒ Array<Float>
Vector Trigonometric Tanh
|
# File 'lib/ta_lib_ffi.rb', line 1981
|
.tema(real, time_period: 30.0) ⇒ Array<Float>
Triple Exponential Moving Average
|
# File 'lib/ta_lib_ffi.rb', line 1988
|
.trange(price_hlc) ⇒ Array<Float>
True Range
|
# File 'lib/ta_lib_ffi.rb', line 1996
|
.trima(real, time_period: 30.0) ⇒ Array<Float>
Triangular Moving Average
|
# File 'lib/ta_lib_ffi.rb', line 2003
|
.trix(real, time_period: 30.0) ⇒ Array<Float>
1-day Rate-Of-Change (ROC) of a Triple Smooth EMA
|
# File 'lib/ta_lib_ffi.rb', line 2011
|
.tsf(real, time_period: 14.0) ⇒ Array<Float>
Time Series Forecast
|
# File 'lib/ta_lib_ffi.rb', line 2019
|
.typprice(price_hlc) ⇒ Array<Float>
Typical Price
|
# File 'lib/ta_lib_ffi.rb', line 2027
|
.ultosc(price_hlc, time_period1: 7.0, time_period2: 14.0, time_period3: 28.0) ⇒ Array<Float>
Ultimate Oscillator
|
# File 'lib/ta_lib_ffi.rb', line 2034
|
.validate_inputs!(arrays) ⇒ Object
Validates input arrays for TA-Lib functions
399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
# File 'lib/ta_lib_ffi.rb', line 399 def validate_inputs!(arrays) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity raise TALibError, "Input arrays cannot be empty" if arrays.empty? arrays.each do |arr| raise TALibError, "Input must be arrays" unless arr.is_a?(Array) end sizes = arrays.map(&:length) raise TALibError, "Input arrays cannot be empty" if sizes.any?(&:zero?) arrays.each do |arr| raise TALibError, "Input arrays must contain only numbers" unless arr.flatten.all? { |x| x.is_a?(Numeric) } end end |
.var(real, time_period: 5.0, nb_dev: 1.0) ⇒ Array<Float>
Variance
|
# File 'lib/ta_lib_ffi.rb', line 2044
|
.wclprice(price_hlc) ⇒ Array<Float>
Weighted Close Price
|
# File 'lib/ta_lib_ffi.rb', line 2053
|
.willr(price_hlc, time_period: 14.0) ⇒ Array<Float>
Williams’ %R
|
# File 'lib/ta_lib_ffi.rb', line 2060
|
.wma(real, time_period: 30.0) ⇒ Array<Float>
Weighted Moving Average
|
# File 'lib/ta_lib_ffi.rb', line 2068
|