From ec04cbd596639dd4451c10387745021e34e32360 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Thu, 9 Jul 2026 18:08:18 +0200 Subject: [PATCH 1/8] :fire: Initial Rust-based code generator * The code-generator currently only works for the TA-Lib (C-side) indicators and uses the TA-Lib functions list to identify all indicators with their respective signatures wrapped in X-Macros. The goal is to be independent from BASH and use an algorithmic approach so input arguments that has default values are not silently dropped. Furthermore it is expected that ALL TA-Lib indicators will be generated using X-Macros. --- codegen/.gitignore | 1 + codegen/Cargo.lock | 7 ++ codegen/Cargo.toml | 7 ++ codegen/src/main.rs | 66 ++++++++++ codegen/src/parser.rs | 286 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 367 insertions(+) create mode 100644 codegen/.gitignore create mode 100644 codegen/Cargo.lock create mode 100644 codegen/Cargo.toml create mode 100644 codegen/src/main.rs create mode 100644 codegen/src/parser.rs diff --git a/codegen/.gitignore b/codegen/.gitignore new file mode 100644 index 000000000..2f7896d1d --- /dev/null +++ b/codegen/.gitignore @@ -0,0 +1 @@ +target/ diff --git a/codegen/Cargo.lock b/codegen/Cargo.lock new file mode 100644 index 000000000..0dc6da228 --- /dev/null +++ b/codegen/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "codegen" +version = "0.1.0" diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml new file mode 100644 index 000000000..c7f0c6dc0 --- /dev/null +++ b/codegen/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "codegen" +description = "A parser for TA-Lib" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/codegen/src/main.rs b/codegen/src/main.rs new file mode 100644 index 000000000..ea1b1658e --- /dev/null +++ b/codegen/src/main.rs @@ -0,0 +1,66 @@ +// load the parser +mod parser; +use parser::purge_comments; +use std::fs; + +use crate::parser::{TA_Lib, extract_signature}; + +/// C_MACRO +/// +/// TA_INDICATOR: The indicator function of TA-Lib, e.g. TA_SMA() and its type +/// TA_INPUT: The input to the TA-Lib indicator, e.g. inReal +/// TA_OPTIONS: The optional input in the TA-Lib indicator, e.g. optInWindow +/// TA_OUTPUT: The output from the TA-Lib indicator, e.g. outReal +/// TA_OUTPUT_NAME: The output names from the TA-Lib indicator, e.g. outReal, outRealMiddleBand etc. +#[allow(non_snake_case)] +fn C_MACRO(function: &TA_Lib) -> String { + format!( + "TA_INDICATOR({}, {}, TA_INPUT({}), TA_OPTIONS({}), TA_OUTPUT({}), TA_OUTPUT_NAME({}))", + function.indicator, + function.argument_type, + function.input.join(", "), + function.optional_input.join(", "), + function.output_indicators.join(", "), + function.output_names.join(", "), + ) +} + +/// +fn main() { + // The goal is to write two files (I think) + let list = fs::read_to_string("src/ta-lib/ta_func_list.txt").expect("read ta_func_list.txt"); + let header = purge_comments( + &fs::read_to_string("src/ta-lib/include/ta_func.h").expect("read ta_func.h"), + ); + + let names: Vec = list + .lines() + .filter_map(|l| l.split_whitespace().next()) + .map(str::to_string) + .collect(); + + let funcs: Vec = names.iter().map(|n| extract_signature(n, &header)).collect(); + + // populate the src/TA-Lib.h file + // with decorative headers that only + // I will probably read ¯\_(ツ)_/¯ + let mut output = String::new(); + output.push_str("// TA-Lib.h - Autogenerated via codegen/\n"); + output.push_str("// Description:\n//\n"); + output.push_str("// \t\tTA_INDICATOR: TA-Lib indicator.\n"); + output.push_str("// \t\tTA_INPUT: Indicator input.\n"); + output.push_str("// \t\tTA_OPTIONS: Indicator input.\n"); + output.push_str("// \t\tTA_OUTPUT: Indicator input.\n"); + output.push_str("// \t\tTA_OUTPUT_NAMES: Indicator input.\n"); + output.push_str("//\n"); + output.push_str("// clang-format off\n"); + + for f in &funcs { + output.push_str(&C_MACRO(f)); + output.push('\n'); + } + + output.push_str("// clang-format on\n"); + + fs::write("src/TA-Lib.h", output).expect("msg") +} diff --git a/codegen/src/parser.rs b/codegen/src/parser.rs new file mode 100644 index 000000000..6976bc64e --- /dev/null +++ b/codegen/src/parser.rs @@ -0,0 +1,286 @@ +/// TA-Lib header parser +/// +/// Functions are parsed from 'src/ta-lib/include/ta_func.h' +/// deterministically - All functions follows the same structure +/// TA_foo(InputIdx, Input, OptionalArguments, OutputIdx, Output) +/// which means that the entire header can just be mined directly. +/// +/// Prior to this Rust parser, a BASH script were used to achieve the +/// same thing - however, it introduced a significant overhead when new +/// arguments were introduced on the R side and the BASH script kept +/// growing. +#[allow(non_camel_case_types)] +#[derive(Debug, Default, PartialEq)] +pub struct TA_Lib { + pub indicator: String, + pub argument_type: &'static str, + pub input: Vec, + pub optional_input: Vec, + pub output_indicators: Vec, + pub output_names: Vec +} + +/// Each TA_Lib function defined in the header +/// is on the following form: +/// +/// /* +/// * TA_ACCBANDS - Acceleration Bands +/// * +/// * Input = High, Low, Close +/// * Output = double, double, double +/// * +/// * Optional Parameters +/// * ------------------- +/// * optInTimePeriod:(From 2 to 100000) +/// * Number of period +/// * +/// * +/// */ +/// +/// TA_LIB_API TA_RetCode TA_ACCBANDS( +/// int startIdx, +/// int endIdx, +/// const double inHigh[], +/// const double inLow[], +/// const double inClose[], +/// int optInTimePeriod, /* From 2 to 100000 */ +/// int *outBegIdx, +/// int *outNBElement, +/// double outRealUpperBand[], +/// double outRealMiddleBand[], +/// double outRealLowerBand[] +/// ); +/// +/// So each function can be easily identified +/// and parsed accordingly +/// +/// The goal is to build a X-Macro on the C-side +/// that is variadic to reduce the amount of code +/// in the wrapper +#[allow(non_snake_case)] +pub fn purge_comments(TA: &str) -> String { + // delete all block comments + // from the files + let TA_bytes = TA.as_bytes(); + + // the function outputs + // a string + let mut output = String::with_capacity( + TA.len() + ); + + // strip all comments + let mut i = 0; + while i < TA_bytes.len() { + if i + 1 < TA_bytes.len() && TA_bytes[i] == b'/' && TA_bytes[i + 1] == b'*' { + i += 2; + while i + 1 < TA_bytes.len() && !(TA_bytes[i] == b'*' && TA_bytes[i + 1] == b'/') { + i += 1; + } + i += 2; + output.push(' '); + } else { + output.push(TA_bytes[i] as char); + i += 1; + } + } + + return output; +} + +/// The identifier of a parameter: drop `[]`/`*` and take the last token. +fn parameter_identifier(param: &str) -> String { + param + .replace("[]", " ") + .replace('*', " ") + .split_whitespace() + .last() + .unwrap_or("") + .to_string() +} + +/// Extract Signature - Like finding a needle in a haystack +/// Params: +/// indicator: The name of the indicator +/// header: Relative path to the the header +/// Returns +/// A TA-Lib struct with all relevant fields otherwise +/// it will panic if not found +pub fn extract_signature(indicator: &str, header: &str) -> TA_Lib { + let needle = format!("TA_RetCode TA_{indicator}("); + + let start = header + .find(&needle) + .unwrap_or_else(|| panic!("prototype not found: {indicator}")); + + let after = &header[start + needle.len()..]; + + let end = after + .find(')') + .unwrap_or_else(|| panic!("no closing paren for {indicator}")); + + let params: Vec<&str> = after[..end] + .split(',') + .map(str::trim) + .filter(|s| !s.is_empty()) + .collect(); + + let mut f = TA_Lib { + indicator: indicator.to_string(), + argument_type: "TA_DBL", + ..Default::default() + }; + + for (_idx, p) in params.iter().enumerate() { + // skip TA_INDICATOR(int startIdx, int endIdx, ...) + if p.contains("startIdx") || p.contains("endIdx") { + continue; + } + // skip TA_INDICATOR(..., int *outBegIdx, int *outNBElement, ...) + if p.contains("outBegIdx") || p.contains("outNBElement") { + continue; // int *outBegIdx, int *outNBElement + } + + // The TA_INDICATOR contains two types + // of arrays - immutable input arrays, and mutable + // output arrays. Input arrays are *always* doubles + // while output can be integer arrays (candlestick patterns) + if p.contains("[]") { + // if its an array determine whether + // its an input or output array + let nm = parameter_identifier(p); + + if p.contains("const") { + f.input.push(nm); // if its constant strip the keyword + } else { + // determine the type of the array + // if its an output arrays and set + // output indicator arrays (e.g outReal) + f.argument_type = if p.contains("double") { "TA_DOUBLE" } else { "TA_INTEGER" }; + f.output_indicators.push(nm); + } + } else { + // the remainder of the TA_INDICATOR(..., int optInTimePeriod, ...) + // can either be a double, integer or MAType + let nm = parameter_identifier(p); + + // determine the optional input + // type in the indicator + f.optional_input.push(if p.contains("TA_MAType") { + format!("OPTIONAL_MATYPE({nm})") + } else if p.contains("double") { + format!("OPTIONAL_DOUBLE({nm})") + } else { + format!("OPTIONAL_INTEGER({nm})") + }); + } + } + + // The output names are given as outReal, outRealUpperBand + // which needs to be stripped so it ouputs UpperBand and + // for univariate output where outReal is not identifiable + // from the outputs the indicator name is replaced so + // outReal becomes SMA for TA_SMA() + for output in &f.output_indicators { + + // strip the following strings + // from the output: 'out', 'Real' and 'Integer' + let bare = output.strip_prefix("out").unwrap_or(output); + let bare = bare.strip_prefix("Real").unwrap_or(bare); + let bare = bare.strip_prefix("Integer").unwrap_or(bare); + + // replace with indicator name or + // stripped names + f.output_names.push(if bare.is_empty() { + f.indicator.clone() + } else { + bare.to_string() + }); + } + f +} + +#[cfg(test)] +mod tests { + use super::*; + + const SAMPLE: &str = " + TA_LIB_API TA_RetCode TA_RSI( + int startIdx, + int endIdx, + const double inReal[], + int optInTimePeriod, + int *outBegIdx, + int *outNBElement, + double outReal[] + ); + + TA_LIB_API TA_RetCode TA_BBANDS( + int startIdx, int endIdx, + const double inReal[], + int optInTimePeriod, + double optInNbDevUp, + double optInNbDevDn, + TA_MAType optInMAType, + int *outBegIdx, + int *outNBElement, + double outRealUpperBand[], + double outRealMiddleBand[], + double outRealLowerBand[] + ); + + TA_LIB_API TA_RetCode TA_CDLDOJI( + int startIdx, + int endIdx, + const double inOpen[], + const double inHigh[], + const double inLow[], + const double inClose[], + int *outBegIdx, + int *outNBElement, + int outInteger[] + ); + "; + + #[test] + fn parses_single_real() { + let f = extract_signature("RSI", SAMPLE); + assert_eq!(f.argument_type, "TA_DBL"); + assert_eq!(f.input, ["inReal"]); + assert_eq!(f.optional_input, ["OPT_INT(optInTimePeriod)"]); + assert_eq!(f.output_indicators, ["outReal"]); + assert_eq!(f.output_names, ["RSI"]); + } + + #[test] + fn parses_multi_out_and_matypes() { + let f = extract_signature("BBANDS", SAMPLE); + assert_eq!(f.input, ["inReal"]); + assert_eq!( + f.optional_input, + [ + "OPT_INT(optInTimePeriod)", + "OPT_DBL(optInNbDevUp)", + "OPT_DBL(optInNbDevDn)", + "OPT_MA(optInMAType)" + ] + ); + assert_eq!(f.output_indicators, ["outRealUpperBand", "outRealMiddleBand", "outRealLowerBand"]); + assert_eq!(f.output_names, ["UpperBand", "MiddleBand", "LowerBand"]); + } + + #[test] + fn parses_int_output_and_ohlc() { + let f = extract_signature("CDLDOJI", SAMPLE); + assert_eq!(f.argument_type, "TA_INT"); + assert_eq!(f.input, ["inOpen", "inHigh", "inLow", "inClose"]); + assert!(f.optional_input.is_empty()); + assert_eq!(f.output_indicators, ["outInteger"]); + assert_eq!(f.output_names, ["CDLDOJI"]); + } + + #[test] + fn strips_comments() { + assert_eq!(purge_comments("a /* x */ b"), "a b"); + } +} \ No newline at end of file From 1daa6786bb5ec3a0892b5715220dc6bbe477a541 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Fri, 10 Jul 2026 07:22:15 +0200 Subject: [PATCH 2/8] :bug:-fix: Parser were using old type macros * The X-Macros will be using TA_* prefixes for readable preprocessing. So DBL --> TA_DOUBLE for doubles. --- codegen/src/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen/src/parser.rs b/codegen/src/parser.rs index 6976bc64e..7d2a06537 100644 --- a/codegen/src/parser.rs +++ b/codegen/src/parser.rs @@ -127,7 +127,7 @@ pub fn extract_signature(indicator: &str, header: &str) -> TA_Lib { let mut f = TA_Lib { indicator: indicator.to_string(), - argument_type: "TA_DBL", + argument_type: "TA_DOUBLE", ..Default::default() }; From 34c100293ad2ebe346be2396b15d1e8d6a100b5e Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Mon, 13 Jul 2026 09:52:16 +0200 Subject: [PATCH 3/8] :hammer: Lookback parsing + descriptive fn naming * The codegen/ now also parses the TA__Lookback signatures which is the optional inputs for all the functions. * The original C_MACRO has been renamed to BATCH to distinguish between streaming (Upcoming) and batch API for later TA-Lib versions. --- codegen/src/main.rs | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/codegen/src/main.rs b/codegen/src/main.rs index ea1b1658e..11c54e1a8 100644 --- a/codegen/src/main.rs +++ b/codegen/src/main.rs @@ -5,7 +5,7 @@ use std::fs; use crate::parser::{TA_Lib, extract_signature}; -/// C_MACRO +/// BATCH_INDICATOR_MACRO /// /// TA_INDICATOR: The indicator function of TA-Lib, e.g. TA_SMA() and its type /// TA_INPUT: The input to the TA-Lib indicator, e.g. inReal @@ -13,7 +13,7 @@ use crate::parser::{TA_Lib, extract_signature}; /// TA_OUTPUT: The output from the TA-Lib indicator, e.g. outReal /// TA_OUTPUT_NAME: The output names from the TA-Lib indicator, e.g. outReal, outRealMiddleBand etc. #[allow(non_snake_case)] -fn C_MACRO(function: &TA_Lib) -> String { +fn BATCH_INDICATOR_MACRO(function: &TA_Lib) -> String { format!( "TA_INDICATOR({}, {}, TA_INPUT({}), TA_OPTIONS({}), TA_OUTPUT({}), TA_OUTPUT_NAME({}))", function.indicator, @@ -25,6 +25,20 @@ fn C_MACRO(function: &TA_Lib) -> String { ) } +/// LOOKBACK_MACRO +/// +/// The TA__Lookback() companion of each indicator takes exactly the +/// indicator's optional inputs, so its macro only needs the name and TA_OPTIONS. +/// Void lookbacks (e.g. TA_ACOS_Lookback) yield an empty TA_OPTIONS(). +#[allow(non_snake_case)] +fn LOOKBACK_MACRO(function: &TA_Lib) -> String { + format!( + "TA_LOOKBACK({}, TA_OPTIONS({}))", + function.indicator, + function.optional_input.join(", "), + ) +} + /// fn main() { // The goal is to write two files (I think) @@ -51,12 +65,20 @@ fn main() { output.push_str("// \t\tTA_INPUT: Indicator input.\n"); output.push_str("// \t\tTA_OPTIONS: Indicator input.\n"); output.push_str("// \t\tTA_OUTPUT: Indicator input.\n"); - output.push_str("// \t\tTA_OUTPUT_NAMES: Indicator input.\n"); - output.push_str("//\n"); + output.push_str("// \t\tTA_OUTPUT_NAMES: Indicator input.\n"); + output.push_str("// \t\tTA_LOOKBACK: Indicator lookback (name + optional inputs).\n"); + output.push_str("//\n"); output.push_str("// clang-format off\n"); for f in &funcs { - output.push_str(&C_MACRO(f)); + output.push_str(&BATCH_INDICATOR_MACRO(f)); + output.push('\n'); + } + + output.push('\n'); + output.push_str("// Lookback\n"); + for f in &funcs { + output.push_str(&LOOKBACK_MACRO(f)); output.push('\n'); } From 4b806bd7477c4cf157480370f5b966e615059797 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Tue, 14 Jul 2026 09:48:34 +0200 Subject: [PATCH 4/8] :hammer: Candlestick/Non-candlestick specific identifiers * The identifiers follows a simple if-else statement for identifying candlesticks based on the indicator name 'CDL'. With this implementation it is now possible to implement candlestick-specific logic on the C preprocessing side without having to rewrite the logic downstream. --- codegen/src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/codegen/src/main.rs b/codegen/src/main.rs index 11c54e1a8..0cfcd24f9 100644 --- a/codegen/src/main.rs +++ b/codegen/src/main.rs @@ -1,7 +1,7 @@ // load the parser mod parser; use parser::purge_comments; -use std::fs; +use std::{fs}; use crate::parser::{TA_Lib, extract_signature}; @@ -15,13 +15,14 @@ use crate::parser::{TA_Lib, extract_signature}; #[allow(non_snake_case)] fn BATCH_INDICATOR_MACRO(function: &TA_Lib) -> String { format!( - "TA_INDICATOR({}, {}, TA_INPUT({}), TA_OPTIONS({}), TA_OUTPUT({}), TA_OUTPUT_NAME({}))", + "TA_INDICATOR({}, {}, TA_INPUT({}), TA_OPTIONS({}), TA_OUTPUT({}), TA_OUTPUT_NAME({}), {})", function.indicator, function.argument_type, function.input.join(", "), function.optional_input.join(", "), function.output_indicators.join(", "), function.output_names.join(", "), + if function.indicator.starts_with("CDL") { "CANDLESTICK" } else {"NOT_CANDLESTICK"} ) } From 420fba96f87e67aacadf0f17dbe1def8074f732a Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Tue, 14 Jul 2026 14:58:33 +0200 Subject: [PATCH 5/8] :wastebasket: Removed lookback functions * All lookback related functions have been removed to accomodate the new codegen that uses the exact signature of the TA__lookback funtions. --- R/ta_ACCBANDS.R | 32 ------------- R/ta_AD.R | 31 ------------- R/ta_ADOSC.R | 35 --------------- R/ta_ADX.R | 32 ------------- R/ta_ADXR.R | 32 ------------- R/ta_APO.R | 34 -------------- R/ta_AROON.R | 31 ------------- R/ta_AROONOSC.R | 31 ------------- R/ta_ATR.R | 32 ------------- R/ta_AVGPRICE.R | 32 ------------- R/ta_BBANDS.R | 36 --------------- R/ta_BETA.R | 16 ------- R/ta_BOP.R | 31 ------------- R/ta_CCI.R | 32 ------------- R/ta_CDL2CROWS.R | 30 ------------- R/ta_CDL3BLACKCROWS.R | 30 ------------- R/ta_CDL3INSIDE.R | 30 ------------- R/ta_CDL3LINESTRIKE.R | 30 ------------- R/ta_CDL3OUTSIDE.R | 30 ------------- R/ta_CDL3STARSINSOUTH.R | 30 ------------- R/ta_CDL3WHITESOLDIERS.R | 30 ------------- R/ta_CDLABANDONEDBABY.R | 32 ------------- R/ta_CDLADVANCEBLOCK.R | 30 ------------- R/ta_CDLBELTHOLD.R | 30 ------------- R/ta_CDLBREAKAWAY.R | 30 ------------- R/ta_CDLCLOSINGMARUBOZU.R | 30 ------------- R/ta_CDLCONCEALBABYSWALL.R | 30 ------------- R/ta_CDLCOUNTERATTACK.R | 30 ------------- R/ta_CDLDARKCLOUDCOVER.R | 32 ------------- R/ta_CDLDOJI.R | 30 ------------- R/ta_CDLDOJISTAR.R | 30 ------------- R/ta_CDLDRAGONFLYDOJI.R | 30 ------------- R/ta_CDLENGULFING.R | 30 ------------- R/ta_CDLEVENINGDOJISTAR.R | 32 ------------- R/ta_CDLEVENINGSTAR.R | 32 ------------- R/ta_CDLGAPSIDESIDEWHITE.R | 30 ------------- R/ta_CDLGRAVESTONEDOJI.R | 30 ------------- R/ta_CDLHAMMER.R | 30 ------------- R/ta_CDLHANGINGMAN.R | 30 ------------- R/ta_CDLHARAMI.R | 30 ------------- R/ta_CDLHARAMICROSS.R | 30 ------------- R/ta_CDLHIGHWAVE.R | 30 ------------- R/ta_CDLHIKKAKE.R | 30 ------------- R/ta_CDLHIKKAKEMOD.R | 30 ------------- R/ta_CDLHOMINGPIGEON.R | 30 ------------- R/ta_CDLIDENTICAL3CROWS.R | 30 ------------- R/ta_CDLINNECK.R | 30 ------------- R/ta_CDLINVERTEDHAMMER.R | 30 ------------- R/ta_CDLKICKING.R | 30 ------------- R/ta_CDLKICKINGBYLENGTH.R | 30 ------------- R/ta_CDLLADDERBOTTOM.R | 30 ------------- R/ta_CDLLONGLEGGEDDOJI.R | 30 ------------- R/ta_CDLLONGLINE.R | 30 ------------- R/ta_CDLMARUBOZU.R | 30 ------------- R/ta_CDLMATCHINGLOW.R | 30 ------------- R/ta_CDLMATHOLD.R | 32 ------------- R/ta_CDLMORNINGDOJISTAR.R | 32 ------------- R/ta_CDLMORNINGSTAR.R | 32 ------------- R/ta_CDLONNECK.R | 30 ------------- R/ta_CDLPIERCING.R | 30 ------------- R/ta_CDLRICKSHAWMAN.R | 30 ------------- R/ta_CDLRISEFALL3METHODS.R | 30 ------------- R/ta_CDLSEPARATINGLINES.R | 30 ------------- R/ta_CDLSHOOTINGSTAR.R | 30 ------------- R/ta_CDLSHORTLINE.R | 30 ------------- R/ta_CDLSPINNINGTOP.R | 30 ------------- R/ta_CDLSTALLEDPATTERN.R | 30 ------------- R/ta_CDLSTICKSANDWICH.R | 30 ------------- R/ta_CDLTAKURI.R | 30 ------------- R/ta_CDLTASUKIGAP.R | 30 ------------- R/ta_CDLTHRUSTING.R | 30 ------------- R/ta_CDLTRISTAR.R | 30 ------------- R/ta_CDLUNIQUE3RIVER.R | 30 ------------- R/ta_CDLUPSIDEGAP2CROWS.R | 30 ------------- R/ta_CDLXSIDEGAP3METHODS.R | 30 ------------- R/ta_CMO.R | 30 ------------- R/ta_CORREL.R | 16 ------- R/ta_DEMA.R | 31 ------------- R/ta_DX.R | 32 ------------- R/ta_EMA.R | 31 ------------- R/ta_HT_DCPERIOD.R | 28 ------------ R/ta_HT_DCPHASE.R | 28 ------------ R/ta_HT_PHASOR.R | 28 ------------ R/ta_HT_SINE.R | 28 ------------ R/ta_HT_TRENDLINE.R | 28 ------------ R/ta_HT_TRENDMODE.R | 28 ------------ R/ta_IMI.R | 31 ------------- R/ta_KAMA.R | 31 ------------- R/ta_MACD.R | 34 -------------- R/ta_MACDEXT.R | 37 --------------- R/ta_MACDFIX.R | 30 ------------- R/ta_MAMA.R | 34 -------------- R/ta_MAX.R | 14 ------ R/ta_MEDPRICE.R | 30 ------------- R/ta_MFI.R | 33 -------------- R/ta_MIDPRICE.R | 32 ------------- R/ta_MIN.R | 14 ------ R/ta_MINUS_DI.R | 32 ------------- R/ta_MINUS_DM.R | 31 ------------- R/ta_MOM.R | 30 ------------- R/ta_NATR.R | 32 ------------- R/ta_OBV.R | 29 ------------ R/ta_PLUS_DI.R | 32 ------------- R/ta_PLUS_DM.R | 31 ------------- R/ta_PPO.R | 34 -------------- R/ta_ROC.R | 30 ------------- R/ta_ROCR.R | 30 ------------- R/ta_RSI.R | 30 ------------- R/ta_SAR.R | 33 -------------- R/ta_SAREXT.R | 45 ------------------- R/ta_SMA.R | 31 ------------- R/ta_STDDEV.R | 16 ------- R/ta_STOCH.R | 38 ---------------- R/ta_STOCHF.R | 35 --------------- R/ta_STOCHRSI.R | 35 --------------- R/ta_SUM.R | 14 ------ R/ta_T3.R | 33 -------------- R/ta_TEMA.R | 31 ------------- R/ta_TRANGE.R | 30 ------------- R/ta_TRIMA.R | 31 ------------- R/ta_TRIX.R | 30 ------------- R/ta_TYPPRICE.R | 31 ------------- R/ta_ULTOSC.R | 34 -------------- R/ta_VAR.R | 16 ------- R/ta_VOLUME.R | 37 --------------- R/ta_WCLPRICE.R | 31 ------------- R/ta_WILLR.R | 32 ------------- R/ta_WMA.R | 31 ------------- codegen/generate_unit-tests.sh | 35 --------------- codegen/templates/candlestick_template.R.in | 30 ------------- codegen/templates/indicator_template.R.in | 28 ------------ .../templates/moving_average_template.R.in | 28 ------------ codegen/templates/rolling_template.R.in | 15 +------ tests/testthat/test-ta_ACCBANDS.R | 15 ------- tests/testthat/test-ta_AD.R | 18 -------- tests/testthat/test-ta_ADOSC.R | 18 -------- tests/testthat/test-ta_ADX.R | 15 ------- tests/testthat/test-ta_ADXR.R | 18 -------- tests/testthat/test-ta_APO.R | 15 ------- tests/testthat/test-ta_AROON.R | 15 ------- tests/testthat/test-ta_AROONOSC.R | 15 ------- tests/testthat/test-ta_ATR.R | 15 ------- tests/testthat/test-ta_AVGPRICE.R | 15 ------- tests/testthat/test-ta_BBANDS.R | 15 ------- tests/testthat/test-ta_BETA.R | 14 ------ tests/testthat/test-ta_BOP.R | 15 ------- tests/testthat/test-ta_CCI.R | 15 ------- tests/testthat/test-ta_CDL2CROWS.R | 15 ------- tests/testthat/test-ta_CDL3BLACKCROWS.R | 15 ------- tests/testthat/test-ta_CDL3INSIDE.R | 15 ------- tests/testthat/test-ta_CDL3LINESTRIKE.R | 15 ------- tests/testthat/test-ta_CDL3OUTSIDE.R | 15 ------- tests/testthat/test-ta_CDL3STARSINSOUTH.R | 15 ------- tests/testthat/test-ta_CDL3WHITESOLDIERS.R | 15 ------- tests/testthat/test-ta_CDLABANDONEDBABY.R | 15 ------- tests/testthat/test-ta_CDLADVANCEBLOCK.R | 15 ------- tests/testthat/test-ta_CDLBELTHOLD.R | 15 ------- tests/testthat/test-ta_CDLBREAKAWAY.R | 15 ------- tests/testthat/test-ta_CDLCLOSINGMARUBOZU.R | 15 ------- tests/testthat/test-ta_CDLCONCEALBABYSWALL.R | 15 ------- tests/testthat/test-ta_CDLCOUNTERATTACK.R | 15 ------- tests/testthat/test-ta_CDLDARKCLOUDCOVER.R | 15 ------- tests/testthat/test-ta_CDLDOJI.R | 15 ------- tests/testthat/test-ta_CDLDOJISTAR.R | 15 ------- tests/testthat/test-ta_CDLDRAGONFLYDOJI.R | 15 ------- tests/testthat/test-ta_CDLENGULFING.R | 15 ------- tests/testthat/test-ta_CDLEVENINGDOJISTAR.R | 15 ------- tests/testthat/test-ta_CDLEVENINGSTAR.R | 15 ------- tests/testthat/test-ta_CDLGAPSIDESIDEWHITE.R | 15 ------- tests/testthat/test-ta_CDLGRAVESTONEDOJI.R | 15 ------- tests/testthat/test-ta_CDLHAMMER.R | 15 ------- tests/testthat/test-ta_CDLHANGINGMAN.R | 15 ------- tests/testthat/test-ta_CDLHARAMI.R | 15 ------- tests/testthat/test-ta_CDLHARAMICROSS.R | 15 ------- tests/testthat/test-ta_CDLHIGHWAVE.R | 15 ------- tests/testthat/test-ta_CDLHIKKAKE.R | 15 ------- tests/testthat/test-ta_CDLHIKKAKEMOD.R | 15 ------- tests/testthat/test-ta_CDLHOMINGPIGEON.R | 15 ------- tests/testthat/test-ta_CDLIDENTICAL3CROWS.R | 15 ------- tests/testthat/test-ta_CDLINNECK.R | 15 ------- tests/testthat/test-ta_CDLINVERTEDHAMMER.R | 15 ------- tests/testthat/test-ta_CDLKICKING.R | 15 ------- tests/testthat/test-ta_CDLKICKINGBYLENGTH.R | 15 ------- tests/testthat/test-ta_CDLLADDERBOTTOM.R | 15 ------- tests/testthat/test-ta_CDLLONGLEGGEDDOJI.R | 15 ------- tests/testthat/test-ta_CDLLONGLINE.R | 15 ------- tests/testthat/test-ta_CDLMARUBOZU.R | 15 ------- tests/testthat/test-ta_CDLMATCHINGLOW.R | 15 ------- tests/testthat/test-ta_CDLMATHOLD.R | 15 ------- tests/testthat/test-ta_CDLMORNINGDOJISTAR.R | 15 ------- tests/testthat/test-ta_CDLMORNINGSTAR.R | 15 ------- tests/testthat/test-ta_CDLONNECK.R | 15 ------- tests/testthat/test-ta_CDLPIERCING.R | 15 ------- tests/testthat/test-ta_CDLRICKSHAWMAN.R | 15 ------- tests/testthat/test-ta_CDLRISEFALL3METHODS.R | 15 ------- tests/testthat/test-ta_CDLSEPARATINGLINES.R | 15 ------- tests/testthat/test-ta_CDLSHOOTINGSTAR.R | 15 ------- tests/testthat/test-ta_CDLSHORTLINE.R | 15 ------- tests/testthat/test-ta_CDLSPINNINGTOP.R | 15 ------- tests/testthat/test-ta_CDLSTALLEDPATTERN.R | 15 ------- tests/testthat/test-ta_CDLSTICKSANDWICH.R | 15 ------- tests/testthat/test-ta_CDLTAKURI.R | 15 ------- tests/testthat/test-ta_CDLTASUKIGAP.R | 15 ------- tests/testthat/test-ta_CDLTHRUSTING.R | 15 ------- tests/testthat/test-ta_CDLTRISTAR.R | 15 ------- tests/testthat/test-ta_CDLUNIQUE3RIVER.R | 15 ------- tests/testthat/test-ta_CDLUPSIDEGAP2CROWS.R | 15 ------- tests/testthat/test-ta_CDLXSIDEGAP3METHODS.R | 15 ------- tests/testthat/test-ta_CMO.R | 15 ------- tests/testthat/test-ta_CORREL.R | 18 -------- tests/testthat/test-ta_DEMA.R | 15 ------- tests/testthat/test-ta_DX.R | 15 ------- tests/testthat/test-ta_EMA.R | 15 ------- tests/testthat/test-ta_HT_DCPERIOD.R | 15 ------- tests/testthat/test-ta_HT_DCPHASE.R | 15 ------- tests/testthat/test-ta_HT_PHASOR.R | 15 ------- tests/testthat/test-ta_HT_SINE.R | 15 ------- tests/testthat/test-ta_HT_TRENDLINE.R | 15 ------- tests/testthat/test-ta_HT_TRENDMODE.R | 15 ------- tests/testthat/test-ta_IMI.R | 15 ------- tests/testthat/test-ta_KAMA.R | 15 ------- tests/testthat/test-ta_MACD.R | 18 -------- tests/testthat/test-ta_MACDEXT.R | 18 -------- tests/testthat/test-ta_MACDFIX.R | 18 -------- tests/testthat/test-ta_MAMA.R | 15 ------- tests/testthat/test-ta_MAX.R | 14 ------ tests/testthat/test-ta_MEDPRICE.R | 15 ------- tests/testthat/test-ta_MFI.R | 15 ------- tests/testthat/test-ta_MIDPRICE.R | 15 ------- tests/testthat/test-ta_MIN.R | 14 ------ tests/testthat/test-ta_MINUS_DI.R | 15 ------- tests/testthat/test-ta_MINUS_DM.R | 15 ------- tests/testthat/test-ta_MOM.R | 15 ------- tests/testthat/test-ta_NATR.R | 15 ------- tests/testthat/test-ta_OBV.R | 15 ------- tests/testthat/test-ta_PLUS_DI.R | 15 ------- tests/testthat/test-ta_PLUS_DM.R | 15 ------- tests/testthat/test-ta_PPO.R | 15 ------- tests/testthat/test-ta_ROC.R | 15 ------- tests/testthat/test-ta_ROCR.R | 15 ------- tests/testthat/test-ta_RSI.R | 15 ------- tests/testthat/test-ta_SAR.R | 15 ------- tests/testthat/test-ta_SAREXT.R | 15 ------- tests/testthat/test-ta_SMA.R | 15 ------- tests/testthat/test-ta_STDDEV.R | 14 ------ tests/testthat/test-ta_STOCH.R | 15 ------- tests/testthat/test-ta_STOCHF.R | 15 ------- tests/testthat/test-ta_STOCHRSI.R | 15 ------- tests/testthat/test-ta_SUM.R | 14 ------ tests/testthat/test-ta_T3.R | 15 ------- tests/testthat/test-ta_TEMA.R | 15 ------- tests/testthat/test-ta_TRANGE.R | 15 ------- tests/testthat/test-ta_TRIMA.R | 15 ------- tests/testthat/test-ta_TRIX.R | 15 ------- tests/testthat/test-ta_TYPPRICE.R | 15 ------- tests/testthat/test-ta_ULTOSC.R | 15 ------- tests/testthat/test-ta_VAR.R | 14 ------ tests/testthat/test-ta_VOLUME.R | 15 ------- tests/testthat/test-ta_WCLPRICE.R | 15 ------- tests/testthat/test-ta_WILLR.R | 15 ------- tests/testthat/test-ta_WMA.R | 15 ------- 261 files changed, 1 insertion(+), 5934 deletions(-) diff --git a/R/ta_ACCBANDS.R b/R/ta_ACCBANDS.R index 3866b181e..82a7d53ff 100644 --- a/R/ta_ACCBANDS.R +++ b/R/ta_ACCBANDS.R @@ -122,38 +122,6 @@ acceleration_bands.matrix <- function( ) } -#' @usage NULL -ACCBANDS_lookback <- acceleration_bands_lookback <- function( - x, - cols, - n = 20, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_ACCBANDS_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases acceleration_bands diff --git a/R/ta_AD.R b/R/ta_AD.R index 9b61ff832..e0198b404 100644 --- a/R/ta_AD.R +++ b/R/ta_AD.R @@ -116,37 +116,6 @@ chaikin_accumulation_distribution_line.matrix <- function( ) } -#' @usage NULL -AD_lookback <- chaikin_accumulation_distribution_line_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close + volume, - data = x, - ... - ) - - .Call( - C_impl_ta_AD_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases chaikin_accumulation_distribution_line diff --git a/R/ta_ADOSC.R b/R/ta_ADOSC.R index 1b16d6f7c..953c06a71 100644 --- a/R/ta_ADOSC.R +++ b/R/ta_ADOSC.R @@ -132,41 +132,6 @@ chaikin_accumulation_distribution_oscillator.matrix <- function( ) } -#' @usage NULL -ADOSC_lookback <- chaikin_accumulation_distribution_oscillator_lookback <- function( - x, - cols, - fast = 3, - slow = 10, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close + volume, - data = x, - ... - ) - - .Call( - C_impl_ta_ADOSC_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]], - as.integer(fast), - as.integer(slow) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases chaikin_accumulation_distribution_oscillator diff --git a/R/ta_ADX.R b/R/ta_ADX.R index a2a6495cc..9e0b41026 100644 --- a/R/ta_ADX.R +++ b/R/ta_ADX.R @@ -122,38 +122,6 @@ average_directional_movement_index.matrix <- function( ) } -#' @usage NULL -ADX_lookback <- average_directional_movement_index_lookback <- function( - x, - cols, - n = 14, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_ADX_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases average_directional_movement_index diff --git a/R/ta_ADXR.R b/R/ta_ADXR.R index 9923e53c4..1022b36c4 100644 --- a/R/ta_ADXR.R +++ b/R/ta_ADXR.R @@ -122,38 +122,6 @@ average_directional_movement_index_rating.matrix <- function( ) } -#' @usage NULL -ADXR_lookback <- average_directional_movement_index_rating_lookback <- function( - x, - cols, - n = 14, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_ADXR_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases average_directional_movement_index_rating diff --git a/R/ta_APO.R b/R/ta_APO.R index ea308b0ee..1b1fd1f3e 100644 --- a/R/ta_APO.R +++ b/R/ta_APO.R @@ -137,40 +137,6 @@ absolute_price_oscillator.matrix <- function( ) } -#' @usage NULL -APO_lookback <- absolute_price_oscillator_lookback <- function( - x, - cols, - fast = 12, - slow = 26, - ma = SMA(n = 9), - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_APO_lookback, - ## splice:lookback:start - constructed_series[[1]], - as.integer(fast), - as.integer(slow), - ma$maType - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases absolute_price_oscillator diff --git a/R/ta_AROON.R b/R/ta_AROON.R index 3b0578853..0cedc7c0f 100644 --- a/R/ta_AROON.R +++ b/R/ta_AROON.R @@ -121,37 +121,6 @@ aroon.matrix <- function( ) } -#' @usage NULL -AROON_lookback <- aroon_lookback <- function( - x, - cols, - n = 14, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low, - data = x, - ... - ) - - .Call( - C_impl_ta_AROON_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases aroon diff --git a/R/ta_AROONOSC.R b/R/ta_AROONOSC.R index 08a4598a1..81452a9d0 100644 --- a/R/ta_AROONOSC.R +++ b/R/ta_AROONOSC.R @@ -121,37 +121,6 @@ aroon_oscillator.matrix <- function( ) } -#' @usage NULL -AROONOSC_lookback <- aroon_oscillator_lookback <- function( - x, - cols, - n = 14, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low, - data = x, - ... - ) - - .Call( - C_impl_ta_AROONOSC_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases aroon_oscillator diff --git a/R/ta_ATR.R b/R/ta_ATR.R index d98f65450..9c1dbbd60 100644 --- a/R/ta_ATR.R +++ b/R/ta_ATR.R @@ -122,38 +122,6 @@ average_true_range.matrix <- function( ) } -#' @usage NULL -ATR_lookback <- average_true_range_lookback <- function( - x, - cols, - n = 14, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_ATR_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases average_true_range diff --git a/R/ta_AVGPRICE.R b/R/ta_AVGPRICE.R index efcf7e5c2..666fd0c66 100644 --- a/R/ta_AVGPRICE.R +++ b/R/ta_AVGPRICE.R @@ -115,35 +115,3 @@ average_price.matrix <- function( ... ) } - -#' @usage NULL -AVGPRICE_lookback <- average_price_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_AVGPRICE_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ## splice:lookback:end - ) -} diff --git a/R/ta_BBANDS.R b/R/ta_BBANDS.R index c49b9fca5..d1187f3b1 100644 --- a/R/ta_BBANDS.R +++ b/R/ta_BBANDS.R @@ -145,42 +145,6 @@ bollinger_bands.matrix <- function( ) } -#' @usage NULL -BBANDS_lookback <- bollinger_bands_lookback <- function( - x, - cols, - ma = SMA(n = 5), - sd = 2, - sd_down, - sd_up, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_BBANDS_lookback, - ## splice:lookback:start - constructed_series[[1]], - ma$n, - as.double(sd_up %or% sd), - as.double(sd_down %or% sd), - ma$maType - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases bollinger_bands diff --git a/R/ta_BETA.R b/R/ta_BETA.R index ee3a6c935..430918d6c 100644 --- a/R/ta_BETA.R +++ b/R/ta_BETA.R @@ -85,19 +85,3 @@ rolling_beta.numeric <- function( ## return indicator x } - -#' @usage NULL -BETA_lookback <- rolling_beta_lookback <- function( - x, - y, - n = 5 -) { - .Call( - C_impl_ta_BETA_lookback, - ## splice:lookback:start - as.double(x), - as.double(y), - as.integer(n) - ## splice:lookback:end - ) -} diff --git a/R/ta_BOP.R b/R/ta_BOP.R index 3e1d5e84a..2e313da83 100644 --- a/R/ta_BOP.R +++ b/R/ta_BOP.R @@ -116,37 +116,6 @@ balance_of_power.matrix <- function( ) } -#' @usage NULL -BOP_lookback <- balance_of_power_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_BOP_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases balance_of_power diff --git a/R/ta_CCI.R b/R/ta_CCI.R index c7c1a04e1..e4b93a9f3 100644 --- a/R/ta_CCI.R +++ b/R/ta_CCI.R @@ -122,38 +122,6 @@ commodity_channel_index.matrix <- function( ) } -#' @usage NULL -CCI_lookback <- commodity_channel_index_lookback <- function( - x, - cols, - n = 14, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CCI_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases commodity_channel_index diff --git a/R/ta_CDL2CROWS.R b/R/ta_CDL2CROWS.R index c79c556d3..1697f99c1 100644 --- a/R/ta_CDL2CROWS.R +++ b/R/ta_CDL2CROWS.R @@ -132,36 +132,6 @@ two_crows.matrix <- function( NextMethod() } -#' @usage NULL -CDL2CROWS_lookback <- two_crows_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDL2CROWS_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases two_crows #' diff --git a/R/ta_CDL3BLACKCROWS.R b/R/ta_CDL3BLACKCROWS.R index 4aeb645d0..a3f46cea1 100644 --- a/R/ta_CDL3BLACKCROWS.R +++ b/R/ta_CDL3BLACKCROWS.R @@ -132,36 +132,6 @@ three_black_crows.matrix <- function( NextMethod() } -#' @usage NULL -CDL3BLACKCROWS_lookback <- three_black_crows_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDL3BLACKCROWS_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases three_black_crows #' diff --git a/R/ta_CDL3INSIDE.R b/R/ta_CDL3INSIDE.R index cf1dffd32..cd46e3309 100644 --- a/R/ta_CDL3INSIDE.R +++ b/R/ta_CDL3INSIDE.R @@ -132,36 +132,6 @@ three_inside.matrix <- function( NextMethod() } -#' @usage NULL -CDL3INSIDE_lookback <- three_inside_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDL3INSIDE_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases three_inside #' diff --git a/R/ta_CDL3LINESTRIKE.R b/R/ta_CDL3LINESTRIKE.R index 13dc938f2..ac54cdbbf 100644 --- a/R/ta_CDL3LINESTRIKE.R +++ b/R/ta_CDL3LINESTRIKE.R @@ -132,36 +132,6 @@ three_line_strike.matrix <- function( NextMethod() } -#' @usage NULL -CDL3LINESTRIKE_lookback <- three_line_strike_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDL3LINESTRIKE_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases three_line_strike #' diff --git a/R/ta_CDL3OUTSIDE.R b/R/ta_CDL3OUTSIDE.R index 13afe056f..872ce706b 100644 --- a/R/ta_CDL3OUTSIDE.R +++ b/R/ta_CDL3OUTSIDE.R @@ -132,36 +132,6 @@ three_outside.matrix <- function( NextMethod() } -#' @usage NULL -CDL3OUTSIDE_lookback <- three_outside_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDL3OUTSIDE_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases three_outside #' diff --git a/R/ta_CDL3STARSINSOUTH.R b/R/ta_CDL3STARSINSOUTH.R index 2215b1764..bf6fbc1ec 100644 --- a/R/ta_CDL3STARSINSOUTH.R +++ b/R/ta_CDL3STARSINSOUTH.R @@ -132,36 +132,6 @@ three_stars_in_the_south.matrix <- function( NextMethod() } -#' @usage NULL -CDL3STARSINSOUTH_lookback <- three_stars_in_the_south_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDL3STARSINSOUTH_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases three_stars_in_the_south #' diff --git a/R/ta_CDL3WHITESOLDIERS.R b/R/ta_CDL3WHITESOLDIERS.R index 9e4c35425..3d800b3f7 100644 --- a/R/ta_CDL3WHITESOLDIERS.R +++ b/R/ta_CDL3WHITESOLDIERS.R @@ -132,36 +132,6 @@ three_white_soldiers.matrix <- function( NextMethod() } -#' @usage NULL -CDL3WHITESOLDIERS_lookback <- three_white_soldiers_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDL3WHITESOLDIERS_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases three_white_soldiers #' diff --git a/R/ta_CDLABANDONEDBABY.R b/R/ta_CDLABANDONEDBABY.R index a3ec95c7d..5decd6880 100644 --- a/R/ta_CDLABANDONEDBABY.R +++ b/R/ta_CDLABANDONEDBABY.R @@ -137,38 +137,6 @@ abandoned_baby.matrix <- function( NextMethod() } -#' @usage NULL -CDLABANDONEDBABY_lookback <- abandoned_baby_lookback <- function( - x, - cols, - eps = 0, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLABANDONEDBABY_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]], - eps - ) -} - #' @usage NULL #' @aliases abandoned_baby #' diff --git a/R/ta_CDLADVANCEBLOCK.R b/R/ta_CDLADVANCEBLOCK.R index 16c10bca5..7ffa59eb0 100644 --- a/R/ta_CDLADVANCEBLOCK.R +++ b/R/ta_CDLADVANCEBLOCK.R @@ -132,36 +132,6 @@ advance_block.matrix <- function( NextMethod() } -#' @usage NULL -CDLADVANCEBLOCK_lookback <- advance_block_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLADVANCEBLOCK_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases advance_block #' diff --git a/R/ta_CDLBELTHOLD.R b/R/ta_CDLBELTHOLD.R index 8e3a056d7..d241985d7 100644 --- a/R/ta_CDLBELTHOLD.R +++ b/R/ta_CDLBELTHOLD.R @@ -132,36 +132,6 @@ belt_hold.matrix <- function( NextMethod() } -#' @usage NULL -CDLBELTHOLD_lookback <- belt_hold_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLBELTHOLD_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases belt_hold #' diff --git a/R/ta_CDLBREAKAWAY.R b/R/ta_CDLBREAKAWAY.R index d90f1f10d..05fd11f8b 100644 --- a/R/ta_CDLBREAKAWAY.R +++ b/R/ta_CDLBREAKAWAY.R @@ -132,36 +132,6 @@ break_away.matrix <- function( NextMethod() } -#' @usage NULL -CDLBREAKAWAY_lookback <- break_away_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLBREAKAWAY_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases break_away #' diff --git a/R/ta_CDLCLOSINGMARUBOZU.R b/R/ta_CDLCLOSINGMARUBOZU.R index c26fa3299..8c12755f5 100644 --- a/R/ta_CDLCLOSINGMARUBOZU.R +++ b/R/ta_CDLCLOSINGMARUBOZU.R @@ -132,36 +132,6 @@ closing_marubozu.matrix <- function( NextMethod() } -#' @usage NULL -CDLCLOSINGMARUBOZU_lookback <- closing_marubozu_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLCLOSINGMARUBOZU_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases closing_marubozu #' diff --git a/R/ta_CDLCONCEALBABYSWALL.R b/R/ta_CDLCONCEALBABYSWALL.R index bcccd5ab3..1abe77544 100644 --- a/R/ta_CDLCONCEALBABYSWALL.R +++ b/R/ta_CDLCONCEALBABYSWALL.R @@ -132,36 +132,6 @@ concealing_baby_swallow.matrix <- function( NextMethod() } -#' @usage NULL -CDLCONCEALBABYSWALL_lookback <- concealing_baby_swallow_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLCONCEALBABYSWALL_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases concealing_baby_swallow #' diff --git a/R/ta_CDLCOUNTERATTACK.R b/R/ta_CDLCOUNTERATTACK.R index 703654191..3fb8660c4 100644 --- a/R/ta_CDLCOUNTERATTACK.R +++ b/R/ta_CDLCOUNTERATTACK.R @@ -132,36 +132,6 @@ counter_attack.matrix <- function( NextMethod() } -#' @usage NULL -CDLCOUNTERATTACK_lookback <- counter_attack_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLCOUNTERATTACK_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases counter_attack #' diff --git a/R/ta_CDLDARKCLOUDCOVER.R b/R/ta_CDLDARKCLOUDCOVER.R index 553c1a7c4..b56bd5113 100644 --- a/R/ta_CDLDARKCLOUDCOVER.R +++ b/R/ta_CDLDARKCLOUDCOVER.R @@ -137,38 +137,6 @@ dark_cloud_cover.matrix <- function( NextMethod() } -#' @usage NULL -CDLDARKCLOUDCOVER_lookback <- dark_cloud_cover_lookback <- function( - x, - cols, - eps = 0, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLDARKCLOUDCOVER_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]], - eps - ) -} - #' @usage NULL #' @aliases dark_cloud_cover #' diff --git a/R/ta_CDLDOJI.R b/R/ta_CDLDOJI.R index da7c64f14..2ca3a5002 100644 --- a/R/ta_CDLDOJI.R +++ b/R/ta_CDLDOJI.R @@ -132,36 +132,6 @@ doji.matrix <- function( NextMethod() } -#' @usage NULL -CDLDOJI_lookback <- doji_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLDOJI_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases doji #' diff --git a/R/ta_CDLDOJISTAR.R b/R/ta_CDLDOJISTAR.R index 6a6656a0c..9691c0ef6 100644 --- a/R/ta_CDLDOJISTAR.R +++ b/R/ta_CDLDOJISTAR.R @@ -132,36 +132,6 @@ doji_star.matrix <- function( NextMethod() } -#' @usage NULL -CDLDOJISTAR_lookback <- doji_star_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLDOJISTAR_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases doji_star #' diff --git a/R/ta_CDLDRAGONFLYDOJI.R b/R/ta_CDLDRAGONFLYDOJI.R index bba237b42..602530860 100644 --- a/R/ta_CDLDRAGONFLYDOJI.R +++ b/R/ta_CDLDRAGONFLYDOJI.R @@ -132,36 +132,6 @@ dragonfly_doji.matrix <- function( NextMethod() } -#' @usage NULL -CDLDRAGONFLYDOJI_lookback <- dragonfly_doji_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLDRAGONFLYDOJI_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases dragonfly_doji #' diff --git a/R/ta_CDLENGULFING.R b/R/ta_CDLENGULFING.R index 770935ea4..24038dd37 100644 --- a/R/ta_CDLENGULFING.R +++ b/R/ta_CDLENGULFING.R @@ -132,36 +132,6 @@ engulfing.matrix <- function( NextMethod() } -#' @usage NULL -CDLENGULFING_lookback <- engulfing_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLENGULFING_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases engulfing #' diff --git a/R/ta_CDLEVENINGDOJISTAR.R b/R/ta_CDLEVENINGDOJISTAR.R index d23789049..907656aa7 100644 --- a/R/ta_CDLEVENINGDOJISTAR.R +++ b/R/ta_CDLEVENINGDOJISTAR.R @@ -137,38 +137,6 @@ evening_doji_star.matrix <- function( NextMethod() } -#' @usage NULL -CDLEVENINGDOJISTAR_lookback <- evening_doji_star_lookback <- function( - x, - cols, - eps = 0, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLEVENINGDOJISTAR_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]], - eps - ) -} - #' @usage NULL #' @aliases evening_doji_star #' diff --git a/R/ta_CDLEVENINGSTAR.R b/R/ta_CDLEVENINGSTAR.R index 1c6e9db5f..944020248 100644 --- a/R/ta_CDLEVENINGSTAR.R +++ b/R/ta_CDLEVENINGSTAR.R @@ -137,38 +137,6 @@ evening_star.matrix <- function( NextMethod() } -#' @usage NULL -CDLEVENINGSTAR_lookback <- evening_star_lookback <- function( - x, - cols, - eps = 0, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLEVENINGSTAR_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]], - eps - ) -} - #' @usage NULL #' @aliases evening_star #' diff --git a/R/ta_CDLGAPSIDESIDEWHITE.R b/R/ta_CDLGAPSIDESIDEWHITE.R index 1caf72e03..50410f78b 100644 --- a/R/ta_CDLGAPSIDESIDEWHITE.R +++ b/R/ta_CDLGAPSIDESIDEWHITE.R @@ -132,36 +132,6 @@ gaps_side_white.matrix <- function( NextMethod() } -#' @usage NULL -CDLGAPSIDESIDEWHITE_lookback <- gaps_side_white_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLGAPSIDESIDEWHITE_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases gaps_side_white #' diff --git a/R/ta_CDLGRAVESTONEDOJI.R b/R/ta_CDLGRAVESTONEDOJI.R index 3bbf10d63..931163072 100644 --- a/R/ta_CDLGRAVESTONEDOJI.R +++ b/R/ta_CDLGRAVESTONEDOJI.R @@ -132,36 +132,6 @@ gravestone_doji.matrix <- function( NextMethod() } -#' @usage NULL -CDLGRAVESTONEDOJI_lookback <- gravestone_doji_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLGRAVESTONEDOJI_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases gravestone_doji #' diff --git a/R/ta_CDLHAMMER.R b/R/ta_CDLHAMMER.R index f129e628a..bf74d0411 100644 --- a/R/ta_CDLHAMMER.R +++ b/R/ta_CDLHAMMER.R @@ -132,36 +132,6 @@ hammer.matrix <- function( NextMethod() } -#' @usage NULL -CDLHAMMER_lookback <- hammer_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLHAMMER_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases hammer #' diff --git a/R/ta_CDLHANGINGMAN.R b/R/ta_CDLHANGINGMAN.R index 464d17b63..427325177 100644 --- a/R/ta_CDLHANGINGMAN.R +++ b/R/ta_CDLHANGINGMAN.R @@ -132,36 +132,6 @@ hanging_man.matrix <- function( NextMethod() } -#' @usage NULL -CDLHANGINGMAN_lookback <- hanging_man_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLHANGINGMAN_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases hanging_man #' diff --git a/R/ta_CDLHARAMI.R b/R/ta_CDLHARAMI.R index d27ef9645..0e1a5403f 100644 --- a/R/ta_CDLHARAMI.R +++ b/R/ta_CDLHARAMI.R @@ -132,36 +132,6 @@ harami.matrix <- function( NextMethod() } -#' @usage NULL -CDLHARAMI_lookback <- harami_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLHARAMI_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases harami #' diff --git a/R/ta_CDLHARAMICROSS.R b/R/ta_CDLHARAMICROSS.R index 73e808e05..749141b97 100644 --- a/R/ta_CDLHARAMICROSS.R +++ b/R/ta_CDLHARAMICROSS.R @@ -132,36 +132,6 @@ harami_cross.matrix <- function( NextMethod() } -#' @usage NULL -CDLHARAMICROSS_lookback <- harami_cross_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLHARAMICROSS_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases harami_cross #' diff --git a/R/ta_CDLHIGHWAVE.R b/R/ta_CDLHIGHWAVE.R index 6c344513d..17100b4e3 100644 --- a/R/ta_CDLHIGHWAVE.R +++ b/R/ta_CDLHIGHWAVE.R @@ -132,36 +132,6 @@ high_wave.matrix <- function( NextMethod() } -#' @usage NULL -CDLHIGHWAVE_lookback <- high_wave_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLHIGHWAVE_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases high_wave #' diff --git a/R/ta_CDLHIKKAKE.R b/R/ta_CDLHIKKAKE.R index 620a7d9b6..f5e218e47 100644 --- a/R/ta_CDLHIKKAKE.R +++ b/R/ta_CDLHIKKAKE.R @@ -132,36 +132,6 @@ hikakke.matrix <- function( NextMethod() } -#' @usage NULL -CDLHIKKAKE_lookback <- hikakke_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLHIKKAKE_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases hikakke #' diff --git a/R/ta_CDLHIKKAKEMOD.R b/R/ta_CDLHIKKAKEMOD.R index d5bc0e46b..43fdab5ee 100644 --- a/R/ta_CDLHIKKAKEMOD.R +++ b/R/ta_CDLHIKKAKEMOD.R @@ -132,36 +132,6 @@ hikakke_mod.matrix <- function( NextMethod() } -#' @usage NULL -CDLHIKKAKEMOD_lookback <- hikakke_mod_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLHIKKAKEMOD_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases hikakke_mod #' diff --git a/R/ta_CDLHOMINGPIGEON.R b/R/ta_CDLHOMINGPIGEON.R index aa59697fa..82566f6b6 100644 --- a/R/ta_CDLHOMINGPIGEON.R +++ b/R/ta_CDLHOMINGPIGEON.R @@ -132,36 +132,6 @@ homing_pigeon.matrix <- function( NextMethod() } -#' @usage NULL -CDLHOMINGPIGEON_lookback <- homing_pigeon_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLHOMINGPIGEON_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases homing_pigeon #' diff --git a/R/ta_CDLIDENTICAL3CROWS.R b/R/ta_CDLIDENTICAL3CROWS.R index f53a60013..6d53e8b46 100644 --- a/R/ta_CDLIDENTICAL3CROWS.R +++ b/R/ta_CDLIDENTICAL3CROWS.R @@ -132,36 +132,6 @@ three_identical_crows.matrix <- function( NextMethod() } -#' @usage NULL -CDLIDENTICAL3CROWS_lookback <- three_identical_crows_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLIDENTICAL3CROWS_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases three_identical_crows #' diff --git a/R/ta_CDLINNECK.R b/R/ta_CDLINNECK.R index ae93052c8..0ad45078d 100644 --- a/R/ta_CDLINNECK.R +++ b/R/ta_CDLINNECK.R @@ -132,36 +132,6 @@ in_neck.matrix <- function( NextMethod() } -#' @usage NULL -CDLINNECK_lookback <- in_neck_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLINNECK_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases in_neck #' diff --git a/R/ta_CDLINVERTEDHAMMER.R b/R/ta_CDLINVERTEDHAMMER.R index 6013b62b9..46b28e3a1 100644 --- a/R/ta_CDLINVERTEDHAMMER.R +++ b/R/ta_CDLINVERTEDHAMMER.R @@ -132,36 +132,6 @@ inverted_hammer.matrix <- function( NextMethod() } -#' @usage NULL -CDLINVERTEDHAMMER_lookback <- inverted_hammer_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLINVERTEDHAMMER_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases inverted_hammer #' diff --git a/R/ta_CDLKICKING.R b/R/ta_CDLKICKING.R index 027447af4..079feb387 100644 --- a/R/ta_CDLKICKING.R +++ b/R/ta_CDLKICKING.R @@ -132,36 +132,6 @@ kicking.matrix <- function( NextMethod() } -#' @usage NULL -CDLKICKING_lookback <- kicking_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLKICKING_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases kicking #' diff --git a/R/ta_CDLKICKINGBYLENGTH.R b/R/ta_CDLKICKINGBYLENGTH.R index 694df66eb..9e60f5a56 100644 --- a/R/ta_CDLKICKINGBYLENGTH.R +++ b/R/ta_CDLKICKINGBYLENGTH.R @@ -132,36 +132,6 @@ kicking_baby_length.matrix <- function( NextMethod() } -#' @usage NULL -CDLKICKINGBYLENGTH_lookback <- kicking_baby_length_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLKICKINGBYLENGTH_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases kicking_baby_length #' diff --git a/R/ta_CDLLADDERBOTTOM.R b/R/ta_CDLLADDERBOTTOM.R index f844980a0..a43a9cf41 100644 --- a/R/ta_CDLLADDERBOTTOM.R +++ b/R/ta_CDLLADDERBOTTOM.R @@ -132,36 +132,6 @@ ladder_bottom.matrix <- function( NextMethod() } -#' @usage NULL -CDLLADDERBOTTOM_lookback <- ladder_bottom_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLLADDERBOTTOM_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases ladder_bottom #' diff --git a/R/ta_CDLLONGLEGGEDDOJI.R b/R/ta_CDLLONGLEGGEDDOJI.R index 86e1274b1..342e5c135 100644 --- a/R/ta_CDLLONGLEGGEDDOJI.R +++ b/R/ta_CDLLONGLEGGEDDOJI.R @@ -132,36 +132,6 @@ long_legged_doji.matrix <- function( NextMethod() } -#' @usage NULL -CDLLONGLEGGEDDOJI_lookback <- long_legged_doji_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLLONGLEGGEDDOJI_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases long_legged_doji #' diff --git a/R/ta_CDLLONGLINE.R b/R/ta_CDLLONGLINE.R index 57c3adbd3..7c907f73c 100644 --- a/R/ta_CDLLONGLINE.R +++ b/R/ta_CDLLONGLINE.R @@ -132,36 +132,6 @@ long_line.matrix <- function( NextMethod() } -#' @usage NULL -CDLLONGLINE_lookback <- long_line_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLLONGLINE_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases long_line #' diff --git a/R/ta_CDLMARUBOZU.R b/R/ta_CDLMARUBOZU.R index a5f6eb9f5..fe592ac37 100644 --- a/R/ta_CDLMARUBOZU.R +++ b/R/ta_CDLMARUBOZU.R @@ -132,36 +132,6 @@ marubozu.matrix <- function( NextMethod() } -#' @usage NULL -CDLMARUBOZU_lookback <- marubozu_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLMARUBOZU_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases marubozu #' diff --git a/R/ta_CDLMATCHINGLOW.R b/R/ta_CDLMATCHINGLOW.R index 92b4f5280..c1aab57d1 100644 --- a/R/ta_CDLMATCHINGLOW.R +++ b/R/ta_CDLMATCHINGLOW.R @@ -132,36 +132,6 @@ matching_low.matrix <- function( NextMethod() } -#' @usage NULL -CDLMATCHINGLOW_lookback <- matching_low_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLMATCHINGLOW_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases matching_low #' diff --git a/R/ta_CDLMATHOLD.R b/R/ta_CDLMATHOLD.R index 15ea8f526..afe98eabf 100644 --- a/R/ta_CDLMATHOLD.R +++ b/R/ta_CDLMATHOLD.R @@ -137,38 +137,6 @@ mat_hold.matrix <- function( NextMethod() } -#' @usage NULL -CDLMATHOLD_lookback <- mat_hold_lookback <- function( - x, - cols, - eps = 0, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLMATHOLD_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]], - eps - ) -} - #' @usage NULL #' @aliases mat_hold #' diff --git a/R/ta_CDLMORNINGDOJISTAR.R b/R/ta_CDLMORNINGDOJISTAR.R index 6de0f62d1..5aa05cb81 100644 --- a/R/ta_CDLMORNINGDOJISTAR.R +++ b/R/ta_CDLMORNINGDOJISTAR.R @@ -137,38 +137,6 @@ morning_doji_star.matrix <- function( NextMethod() } -#' @usage NULL -CDLMORNINGDOJISTAR_lookback <- morning_doji_star_lookback <- function( - x, - cols, - eps = 0, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLMORNINGDOJISTAR_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]], - eps - ) -} - #' @usage NULL #' @aliases morning_doji_star #' diff --git a/R/ta_CDLMORNINGSTAR.R b/R/ta_CDLMORNINGSTAR.R index aa5404d8d..d2fd17206 100644 --- a/R/ta_CDLMORNINGSTAR.R +++ b/R/ta_CDLMORNINGSTAR.R @@ -137,38 +137,6 @@ morning_star.matrix <- function( NextMethod() } -#' @usage NULL -CDLMORNINGSTAR_lookback <- morning_star_lookback <- function( - x, - cols, - eps = 0, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLMORNINGSTAR_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]], - eps - ) -} - #' @usage NULL #' @aliases morning_star #' diff --git a/R/ta_CDLONNECK.R b/R/ta_CDLONNECK.R index dde28b5b1..4d9ed7fe6 100644 --- a/R/ta_CDLONNECK.R +++ b/R/ta_CDLONNECK.R @@ -132,36 +132,6 @@ on_neck.matrix <- function( NextMethod() } -#' @usage NULL -CDLONNECK_lookback <- on_neck_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLONNECK_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases on_neck #' diff --git a/R/ta_CDLPIERCING.R b/R/ta_CDLPIERCING.R index a5fda9945..5df9f1330 100644 --- a/R/ta_CDLPIERCING.R +++ b/R/ta_CDLPIERCING.R @@ -132,36 +132,6 @@ piercing.matrix <- function( NextMethod() } -#' @usage NULL -CDLPIERCING_lookback <- piercing_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLPIERCING_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases piercing #' diff --git a/R/ta_CDLRICKSHAWMAN.R b/R/ta_CDLRICKSHAWMAN.R index 093178afd..f96e13579 100644 --- a/R/ta_CDLRICKSHAWMAN.R +++ b/R/ta_CDLRICKSHAWMAN.R @@ -132,36 +132,6 @@ rickshaw_man.matrix <- function( NextMethod() } -#' @usage NULL -CDLRICKSHAWMAN_lookback <- rickshaw_man_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLRICKSHAWMAN_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases rickshaw_man #' diff --git a/R/ta_CDLRISEFALL3METHODS.R b/R/ta_CDLRISEFALL3METHODS.R index 279bd00c3..116fa14ee 100644 --- a/R/ta_CDLRISEFALL3METHODS.R +++ b/R/ta_CDLRISEFALL3METHODS.R @@ -132,36 +132,6 @@ rise_fall_3_methods.matrix <- function( NextMethod() } -#' @usage NULL -CDLRISEFALL3METHODS_lookback <- rise_fall_3_methods_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLRISEFALL3METHODS_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases rise_fall_3_methods #' diff --git a/R/ta_CDLSEPARATINGLINES.R b/R/ta_CDLSEPARATINGLINES.R index 878c9d226..e0ff5f769 100644 --- a/R/ta_CDLSEPARATINGLINES.R +++ b/R/ta_CDLSEPARATINGLINES.R @@ -132,36 +132,6 @@ separating_lines.matrix <- function( NextMethod() } -#' @usage NULL -CDLSEPARATINGLINES_lookback <- separating_lines_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLSEPARATINGLINES_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases separating_lines #' diff --git a/R/ta_CDLSHOOTINGSTAR.R b/R/ta_CDLSHOOTINGSTAR.R index ba4fadd0a..a99cea3f1 100644 --- a/R/ta_CDLSHOOTINGSTAR.R +++ b/R/ta_CDLSHOOTINGSTAR.R @@ -132,36 +132,6 @@ shooting_star.matrix <- function( NextMethod() } -#' @usage NULL -CDLSHOOTINGSTAR_lookback <- shooting_star_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLSHOOTINGSTAR_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases shooting_star #' diff --git a/R/ta_CDLSHORTLINE.R b/R/ta_CDLSHORTLINE.R index 749d270fe..c5dd4c8bf 100644 --- a/R/ta_CDLSHORTLINE.R +++ b/R/ta_CDLSHORTLINE.R @@ -132,36 +132,6 @@ short_line.matrix <- function( NextMethod() } -#' @usage NULL -CDLSHORTLINE_lookback <- short_line_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLSHORTLINE_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases short_line #' diff --git a/R/ta_CDLSPINNINGTOP.R b/R/ta_CDLSPINNINGTOP.R index f21273aac..cfb3609dd 100644 --- a/R/ta_CDLSPINNINGTOP.R +++ b/R/ta_CDLSPINNINGTOP.R @@ -132,36 +132,6 @@ spinning_top.matrix <- function( NextMethod() } -#' @usage NULL -CDLSPINNINGTOP_lookback <- spinning_top_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLSPINNINGTOP_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases spinning_top #' diff --git a/R/ta_CDLSTALLEDPATTERN.R b/R/ta_CDLSTALLEDPATTERN.R index 855622010..472c88d01 100644 --- a/R/ta_CDLSTALLEDPATTERN.R +++ b/R/ta_CDLSTALLEDPATTERN.R @@ -132,36 +132,6 @@ stalled_pattern.matrix <- function( NextMethod() } -#' @usage NULL -CDLSTALLEDPATTERN_lookback <- stalled_pattern_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLSTALLEDPATTERN_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases stalled_pattern #' diff --git a/R/ta_CDLSTICKSANDWICH.R b/R/ta_CDLSTICKSANDWICH.R index 2c27022f4..75b91ed4c 100644 --- a/R/ta_CDLSTICKSANDWICH.R +++ b/R/ta_CDLSTICKSANDWICH.R @@ -132,36 +132,6 @@ stick_sandwich.matrix <- function( NextMethod() } -#' @usage NULL -CDLSTICKSANDWICH_lookback <- stick_sandwich_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLSTICKSANDWICH_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases stick_sandwich #' diff --git a/R/ta_CDLTAKURI.R b/R/ta_CDLTAKURI.R index 313cd90bf..da480fd62 100644 --- a/R/ta_CDLTAKURI.R +++ b/R/ta_CDLTAKURI.R @@ -132,36 +132,6 @@ takuri.matrix <- function( NextMethod() } -#' @usage NULL -CDLTAKURI_lookback <- takuri_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLTAKURI_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases takuri #' diff --git a/R/ta_CDLTASUKIGAP.R b/R/ta_CDLTASUKIGAP.R index 4a6e25fe7..5ecd06cad 100644 --- a/R/ta_CDLTASUKIGAP.R +++ b/R/ta_CDLTASUKIGAP.R @@ -132,36 +132,6 @@ tasuki_gap.matrix <- function( NextMethod() } -#' @usage NULL -CDLTASUKIGAP_lookback <- tasuki_gap_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLTASUKIGAP_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases tasuki_gap #' diff --git a/R/ta_CDLTHRUSTING.R b/R/ta_CDLTHRUSTING.R index 3c2341de1..08b496e3e 100644 --- a/R/ta_CDLTHRUSTING.R +++ b/R/ta_CDLTHRUSTING.R @@ -132,36 +132,6 @@ thrusting.matrix <- function( NextMethod() } -#' @usage NULL -CDLTHRUSTING_lookback <- thrusting_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLTHRUSTING_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases thrusting #' diff --git a/R/ta_CDLTRISTAR.R b/R/ta_CDLTRISTAR.R index 8144bea0b..fb99feeef 100644 --- a/R/ta_CDLTRISTAR.R +++ b/R/ta_CDLTRISTAR.R @@ -132,36 +132,6 @@ tristar.matrix <- function( NextMethod() } -#' @usage NULL -CDLTRISTAR_lookback <- tristar_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLTRISTAR_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases tristar #' diff --git a/R/ta_CDLUNIQUE3RIVER.R b/R/ta_CDLUNIQUE3RIVER.R index a16348018..ee608e3ce 100644 --- a/R/ta_CDLUNIQUE3RIVER.R +++ b/R/ta_CDLUNIQUE3RIVER.R @@ -132,36 +132,6 @@ unique_3_river.matrix <- function( NextMethod() } -#' @usage NULL -CDLUNIQUE3RIVER_lookback <- unique_3_river_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLUNIQUE3RIVER_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases unique_3_river #' diff --git a/R/ta_CDLUPSIDEGAP2CROWS.R b/R/ta_CDLUPSIDEGAP2CROWS.R index 35f32c0c5..977c2b4e0 100644 --- a/R/ta_CDLUPSIDEGAP2CROWS.R +++ b/R/ta_CDLUPSIDEGAP2CROWS.R @@ -132,36 +132,6 @@ upside_gap_2_crows.matrix <- function( NextMethod() } -#' @usage NULL -CDLUPSIDEGAP2CROWS_lookback <- upside_gap_2_crows_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLUPSIDEGAP2CROWS_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases upside_gap_2_crows #' diff --git a/R/ta_CDLXSIDEGAP3METHODS.R b/R/ta_CDLXSIDEGAP3METHODS.R index 3ae89e583..ee6fa3088 100644 --- a/R/ta_CDLXSIDEGAP3METHODS.R +++ b/R/ta_CDLXSIDEGAP3METHODS.R @@ -132,36 +132,6 @@ xside_gap_3_methods.matrix <- function( NextMethod() } -#' @usage NULL -CDLXSIDEGAP3METHODS_lookback <- xside_gap_3_methods_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_CDLXSIDEGAP3METHODS_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] - ) -} - #' @usage NULL #' @aliases xside_gap_3_methods #' diff --git a/R/ta_CMO.R b/R/ta_CMO.R index 56575b837..5acfe81e9 100644 --- a/R/ta_CMO.R +++ b/R/ta_CMO.R @@ -120,36 +120,6 @@ chande_momentum_oscillator.matrix <- function( ) } -#' @usage NULL -CMO_lookback <- chande_momentum_oscillator_lookback <- function( - x, - cols, - n = 14, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_CMO_lookback, - ## splice:lookback:start - constructed_series[[1]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases chande_momentum_oscillator diff --git a/R/ta_CORREL.R b/R/ta_CORREL.R index a4b15df43..8ff959924 100644 --- a/R/ta_CORREL.R +++ b/R/ta_CORREL.R @@ -85,19 +85,3 @@ rolling_correlation.numeric <- function( ## return indicator x } - -#' @usage NULL -CORREL_lookback <- rolling_correlation_lookback <- function( - x, - y, - n = 30 -) { - .Call( - C_impl_ta_CORREL_lookback, - ## splice:lookback:start - as.double(x), - as.double(y), - as.integer(n) - ## splice:lookback:end - ) -} diff --git a/R/ta_DEMA.R b/R/ta_DEMA.R index a52d0f60d..c992315fc 100644 --- a/R/ta_DEMA.R +++ b/R/ta_DEMA.R @@ -170,37 +170,6 @@ double_exponential_moving_average.numeric <- function( x } -#' @usage NULL -DEMA_lookback <- double_exponential_moving_average_lookback <- function( - x, - cols, - n = 30, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_DEMA_lookback, - ## splice:lookback:start - as.double(constructed_series[[1]]), - as.integer(n) - ## splice:lookback:end - ) -} - #' @usage NULL #' @aliases double_exponential_moving_average #' diff --git a/R/ta_DX.R b/R/ta_DX.R index 22788b760..1db4d604a 100644 --- a/R/ta_DX.R +++ b/R/ta_DX.R @@ -122,38 +122,6 @@ directional_movement_index.matrix <- function( ) } -#' @usage NULL -DX_lookback <- directional_movement_index_lookback <- function( - x, - cols, - n = 14, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_DX_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases directional_movement_index diff --git a/R/ta_EMA.R b/R/ta_EMA.R index c9c285f27..bbef8a6c9 100644 --- a/R/ta_EMA.R +++ b/R/ta_EMA.R @@ -170,37 +170,6 @@ exponential_moving_average.numeric <- function( x } -#' @usage NULL -EMA_lookback <- exponential_moving_average_lookback <- function( - x, - cols, - n = 30, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_EMA_lookback, - ## splice:lookback:start - as.double(constructed_series[[1]]), - as.integer(n) - ## splice:lookback:end - ) -} - #' @usage NULL #' @aliases exponential_moving_average #' diff --git a/R/ta_HT_DCPERIOD.R b/R/ta_HT_DCPERIOD.R index 4df7ed2e4..610582833 100644 --- a/R/ta_HT_DCPERIOD.R +++ b/R/ta_HT_DCPERIOD.R @@ -113,34 +113,6 @@ dominant_cycle_period.matrix <- function( ) } -#' @usage NULL -HT_DCPERIOD_lookback <- dominant_cycle_period_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_HT_DCPERIOD_lookback, - ## splice:lookback:start - constructed_series[[1]] - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases dominant_cycle_period diff --git a/R/ta_HT_DCPHASE.R b/R/ta_HT_DCPHASE.R index 2b7edbc18..9ff769ecd 100644 --- a/R/ta_HT_DCPHASE.R +++ b/R/ta_HT_DCPHASE.R @@ -113,34 +113,6 @@ dominant_cycle_phase.matrix <- function( ) } -#' @usage NULL -HT_DCPHASE_lookback <- dominant_cycle_phase_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_HT_DCPHASE_lookback, - ## splice:lookback:start - constructed_series[[1]] - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases dominant_cycle_phase diff --git a/R/ta_HT_PHASOR.R b/R/ta_HT_PHASOR.R index 88acf387a..2a0ad0f3f 100644 --- a/R/ta_HT_PHASOR.R +++ b/R/ta_HT_PHASOR.R @@ -113,34 +113,6 @@ phasor_components.matrix <- function( ) } -#' @usage NULL -HT_PHASOR_lookback <- phasor_components_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_HT_PHASOR_lookback, - ## splice:lookback:start - constructed_series[[1]] - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases phasor_components diff --git a/R/ta_HT_SINE.R b/R/ta_HT_SINE.R index c0f4df3d0..6e821b0ef 100644 --- a/R/ta_HT_SINE.R +++ b/R/ta_HT_SINE.R @@ -113,34 +113,6 @@ sine_wave.matrix <- function( ) } -#' @usage NULL -HT_SINE_lookback <- sine_wave_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_HT_SINE_lookback, - ## splice:lookback:start - constructed_series[[1]] - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases sine_wave diff --git a/R/ta_HT_TRENDLINE.R b/R/ta_HT_TRENDLINE.R index ffe15f917..33d308fab 100644 --- a/R/ta_HT_TRENDLINE.R +++ b/R/ta_HT_TRENDLINE.R @@ -113,34 +113,6 @@ trendline.matrix <- function( ) } -#' @usage NULL -HT_TRENDLINE_lookback <- trendline_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_HT_TRENDLINE_lookback, - ## splice:lookback:start - constructed_series[[1]] - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases trendline diff --git a/R/ta_HT_TRENDMODE.R b/R/ta_HT_TRENDMODE.R index 3369c1745..522cd1d8f 100644 --- a/R/ta_HT_TRENDMODE.R +++ b/R/ta_HT_TRENDMODE.R @@ -113,34 +113,6 @@ trend_cycle_mode.matrix <- function( ) } -#' @usage NULL -HT_TRENDMODE_lookback <- trend_cycle_mode_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_HT_TRENDMODE_lookback, - ## splice:lookback:start - constructed_series[[1]] - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases trend_cycle_mode diff --git a/R/ta_IMI.R b/R/ta_IMI.R index 741057842..753987df7 100644 --- a/R/ta_IMI.R +++ b/R/ta_IMI.R @@ -121,37 +121,6 @@ intraday_movement_index.matrix <- function( ) } -#' @usage NULL -IMI_lookback <- intraday_movement_index_lookback <- function( - x, - cols, - n = 14, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ open + close, - data = x, - ... - ) - - .Call( - C_impl_ta_IMI_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases intraday_movement_index diff --git a/R/ta_KAMA.R b/R/ta_KAMA.R index 89af3fc3b..927e1ded1 100644 --- a/R/ta_KAMA.R +++ b/R/ta_KAMA.R @@ -170,37 +170,6 @@ kaufman_adaptive_moving_average.numeric <- function( x } -#' @usage NULL -KAMA_lookback <- kaufman_adaptive_moving_average_lookback <- function( - x, - cols, - n = 30, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_KAMA_lookback, - ## splice:lookback:start - as.double(constructed_series[[1]]), - as.integer(n) - ## splice:lookback:end - ) -} - #' @usage NULL #' @aliases kaufman_adaptive_moving_average #' diff --git a/R/ta_MACD.R b/R/ta_MACD.R index d580e6488..538d7639c 100644 --- a/R/ta_MACD.R +++ b/R/ta_MACD.R @@ -137,40 +137,6 @@ moving_average_convergence_divergence.matrix <- function( ) } -#' @usage NULL -MACD_lookback <- moving_average_convergence_divergence_lookback <- function( - x, - cols, - fast = 12, - slow = 26, - signal = 9, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_MACD_lookback, - ## splice:lookback:start - constructed_series[[1]], - as.integer(fast), - as.integer(slow), - as.integer(signal) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases moving_average_convergence_divergence diff --git a/R/ta_MACDEXT.R b/R/ta_MACDEXT.R index 6c5fa34f6..da7d543b4 100644 --- a/R/ta_MACDEXT.R +++ b/R/ta_MACDEXT.R @@ -140,43 +140,6 @@ extended_moving_average_convergence_divergence.matrix <- function( ) } -#' @usage NULL -MACDEXT_lookback <- extended_moving_average_convergence_divergence_lookback <- function( - x, - cols, - fast = SMA(n = 12), - slow = SMA(n = 26), - signal = SMA(n = 9), - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_MACDEXT_lookback, - ## splice:lookback:start - constructed_series[[1]], - fast$n, - fast$maType, - slow$n, - slow$maType, - signal$n, - signal$maType - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases extended_moving_average_convergence_divergence diff --git a/R/ta_MACDFIX.R b/R/ta_MACDFIX.R index 2585baeee..3db61d57b 100644 --- a/R/ta_MACDFIX.R +++ b/R/ta_MACDFIX.R @@ -121,36 +121,6 @@ fixed_moving_average_convergence_divergence.matrix <- function( ) } -#' @usage NULL -MACDFIX_lookback <- fixed_moving_average_convergence_divergence_lookback <- function( - x, - cols, - signal = 9, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_MACDFIX_lookback, - ## splice:lookback:start - constructed_series[[1]], - as.integer(signal) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases fixed_moving_average_convergence_divergence diff --git a/R/ta_MAMA.R b/R/ta_MAMA.R index f13d758fa..a1fea810a 100644 --- a/R/ta_MAMA.R +++ b/R/ta_MAMA.R @@ -189,40 +189,6 @@ mesa_adaptive_moving_average.numeric <- function( x } -#' @usage NULL -MAMA_lookback <- mesa_adaptive_moving_average_lookback <- function( - x, - cols, - n = 30, - fast = 0.5, - slow = 0.05, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_MAMA_lookback, - ## splice:lookback:start - as.double(constructed_series[[1]]), - as.double(fast), - as.double(slow) - ## splice:lookback:end - ) -} - #' @usage NULL #' @aliases mesa_adaptive_moving_average #' diff --git a/R/ta_MAX.R b/R/ta_MAX.R index f8f6d4097..6545e8596 100644 --- a/R/ta_MAX.R +++ b/R/ta_MAX.R @@ -80,17 +80,3 @@ rolling_max.numeric <- function( ## return indicator x } - -#' @usage NULL -MAX_lookback <- rolling_max_lookback <- function( - x, - n = 30 -) { - .Call( - C_impl_ta_MAX_lookback, - ## splice:lookback:start - as.double(x), - as.integer(n) - ## splice:lookback:end - ) -} diff --git a/R/ta_MEDPRICE.R b/R/ta_MEDPRICE.R index 4535323ef..d3dbb04dc 100644 --- a/R/ta_MEDPRICE.R +++ b/R/ta_MEDPRICE.R @@ -113,33 +113,3 @@ median_price.matrix <- function( ... ) } - -#' @usage NULL -MEDPRICE_lookback <- median_price_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low, - data = x, - ... - ) - - .Call( - C_impl_ta_MEDPRICE_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]] - ## splice:lookback:end - ) -} diff --git a/R/ta_MFI.R b/R/ta_MFI.R index 0f6ef5d31..7849841d2 100644 --- a/R/ta_MFI.R +++ b/R/ta_MFI.R @@ -123,39 +123,6 @@ money_flow_index.matrix <- function( ) } -#' @usage NULL -MFI_lookback <- money_flow_index_lookback <- function( - x, - cols, - n = 14, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close + volume, - data = x, - ... - ) - - .Call( - C_impl_ta_MFI_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases money_flow_index diff --git a/R/ta_MIDPRICE.R b/R/ta_MIDPRICE.R index 05f071ed6..ef6a798fe 100644 --- a/R/ta_MIDPRICE.R +++ b/R/ta_MIDPRICE.R @@ -120,35 +120,3 @@ midpoint_price.matrix <- function( ... ) } - -#' @usage NULL -MIDPRICE_lookback <- midpoint_price_lookback <- function( - x, - cols, - n = 14, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low, - data = x, - ... - ) - - .Call( - C_impl_ta_MIDPRICE_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - as.integer(n) - ## splice:lookback:end - ) -} diff --git a/R/ta_MIN.R b/R/ta_MIN.R index 50e8693b8..1a0864833 100644 --- a/R/ta_MIN.R +++ b/R/ta_MIN.R @@ -80,17 +80,3 @@ rolling_min.numeric <- function( ## return indicator x } - -#' @usage NULL -MIN_lookback <- rolling_min_lookback <- function( - x, - n = 30 -) { - .Call( - C_impl_ta_MIN_lookback, - ## splice:lookback:start - as.double(x), - as.integer(n) - ## splice:lookback:end - ) -} diff --git a/R/ta_MINUS_DI.R b/R/ta_MINUS_DI.R index dd54051dd..22dcea0d3 100644 --- a/R/ta_MINUS_DI.R +++ b/R/ta_MINUS_DI.R @@ -122,38 +122,6 @@ minus_directional_indicator.matrix <- function( ) } -#' @usage NULL -MINUS_DI_lookback <- minus_directional_indicator_lookback <- function( - x, - cols, - n = 14, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_MINUS_DI_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases minus_directional_indicator diff --git a/R/ta_MINUS_DM.R b/R/ta_MINUS_DM.R index e02717913..c46367eee 100644 --- a/R/ta_MINUS_DM.R +++ b/R/ta_MINUS_DM.R @@ -121,37 +121,6 @@ minus_directional_movement.matrix <- function( ) } -#' @usage NULL -MINUS_DM_lookback <- minus_directional_movement_lookback <- function( - x, - cols, - n = 14, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low, - data = x, - ... - ) - - .Call( - C_impl_ta_MINUS_DM_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases minus_directional_movement diff --git a/R/ta_MOM.R b/R/ta_MOM.R index 71a72cb78..8a881ab4f 100644 --- a/R/ta_MOM.R +++ b/R/ta_MOM.R @@ -120,36 +120,6 @@ momentum.matrix <- function( ) } -#' @usage NULL -MOM_lookback <- momentum_lookback <- function( - x, - cols, - n = 10, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_MOM_lookback, - ## splice:lookback:start - constructed_series[[1]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases momentum diff --git a/R/ta_NATR.R b/R/ta_NATR.R index b4f33977e..aaa630e4a 100644 --- a/R/ta_NATR.R +++ b/R/ta_NATR.R @@ -122,38 +122,6 @@ normalized_average_true_range.matrix <- function( ) } -#' @usage NULL -NATR_lookback <- normalized_average_true_range_lookback <- function( - x, - cols, - n = 14, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_NATR_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases normalized_average_true_range diff --git a/R/ta_OBV.R b/R/ta_OBV.R index 0d9b4c0cb..829fb3365 100644 --- a/R/ta_OBV.R +++ b/R/ta_OBV.R @@ -114,35 +114,6 @@ on_balance_volume.matrix <- function( ) } -#' @usage NULL -OBV_lookback <- on_balance_volume_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ close + volume, - data = x, - ... - ) - - .Call( - C_impl_ta_OBV_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]] - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases on_balance_volume diff --git a/R/ta_PLUS_DI.R b/R/ta_PLUS_DI.R index 3e9022746..98563a504 100644 --- a/R/ta_PLUS_DI.R +++ b/R/ta_PLUS_DI.R @@ -122,38 +122,6 @@ plus_directional_indicator.matrix <- function( ) } -#' @usage NULL -PLUS_DI_lookback <- plus_directional_indicator_lookback <- function( - x, - cols, - n = 14, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_PLUS_DI_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases plus_directional_indicator diff --git a/R/ta_PLUS_DM.R b/R/ta_PLUS_DM.R index 8f1615dca..b24dd5c7e 100644 --- a/R/ta_PLUS_DM.R +++ b/R/ta_PLUS_DM.R @@ -121,37 +121,6 @@ plus_directional_movement.matrix <- function( ) } -#' @usage NULL -PLUS_DM_lookback <- plus_directional_movement_lookback <- function( - x, - cols, - n = 14, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low, - data = x, - ... - ) - - .Call( - C_impl_ta_PLUS_DM_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases plus_directional_movement diff --git a/R/ta_PPO.R b/R/ta_PPO.R index ef11b663d..5082d351b 100644 --- a/R/ta_PPO.R +++ b/R/ta_PPO.R @@ -137,40 +137,6 @@ percentage_price_oscillator.matrix <- function( ) } -#' @usage NULL -PPO_lookback <- percentage_price_oscillator_lookback <- function( - x, - cols, - fast = 12, - slow = 26, - ma = SMA(n = 9), - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_PPO_lookback, - ## splice:lookback:start - constructed_series[[1]], - as.integer(fast), - as.integer(slow), - ma$maType - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases percentage_price_oscillator diff --git a/R/ta_ROC.R b/R/ta_ROC.R index c050d5464..e125bc39a 100644 --- a/R/ta_ROC.R +++ b/R/ta_ROC.R @@ -120,36 +120,6 @@ rate_of_change.matrix <- function( ) } -#' @usage NULL -ROC_lookback <- rate_of_change_lookback <- function( - x, - cols, - n = 10, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_ROC_lookback, - ## splice:lookback:start - constructed_series[[1]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases rate_of_change diff --git a/R/ta_ROCR.R b/R/ta_ROCR.R index 476f46f53..1c6b91ebb 100644 --- a/R/ta_ROCR.R +++ b/R/ta_ROCR.R @@ -120,36 +120,6 @@ ratio_of_change.matrix <- function( ) } -#' @usage NULL -ROCR_lookback <- ratio_of_change_lookback <- function( - x, - cols, - n = 10, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_ROCR_lookback, - ## splice:lookback:start - constructed_series[[1]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases ratio_of_change diff --git a/R/ta_RSI.R b/R/ta_RSI.R index b1bec585c..bae394305 100644 --- a/R/ta_RSI.R +++ b/R/ta_RSI.R @@ -120,36 +120,6 @@ relative_strength_index.matrix <- function( ) } -#' @usage NULL -RSI_lookback <- relative_strength_index_lookback <- function( - x, - cols, - n = 14, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_RSI_lookback, - ## splice:lookback:start - constructed_series[[1]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases relative_strength_index diff --git a/R/ta_SAR.R b/R/ta_SAR.R index 8698e7a69..948915275 100644 --- a/R/ta_SAR.R +++ b/R/ta_SAR.R @@ -130,39 +130,6 @@ parabolic_stop_and_reverse.matrix <- function( ) } -#' @usage NULL -SAR_lookback <- parabolic_stop_and_reverse_lookback <- function( - x, - cols, - acceleration = 0.02, - maximum = 0.2, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low, - data = x, - ... - ) - - .Call( - C_impl_ta_SAR_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - as.double(acceleration), - as.double(maximum) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases parabolic_stop_and_reverse diff --git a/R/ta_SAREXT.R b/R/ta_SAREXT.R index 8229f3c74..36b24f643 100644 --- a/R/ta_SAREXT.R +++ b/R/ta_SAREXT.R @@ -178,51 +178,6 @@ extended_parabolic_stop_and_reverse.matrix <- function( ) } -#' @usage NULL -SAREXT_lookback <- extended_parabolic_stop_and_reverse_lookback <- function( - x, - cols, - init = 0, - offset = 0, - init_long = 0.02, - long = 0.02, - max_long = 0.2, - init_short = 0.02, - short = 0.02, - max_short = 0.2, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low, - data = x, - ... - ) - - .Call( - C_impl_ta_SAREXT_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - init, - offset, - init_long, - long, - max_long, - init_short, - short, - max_short - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases extended_parabolic_stop_and_reverse diff --git a/R/ta_SMA.R b/R/ta_SMA.R index ce9400d98..6ae50eb3a 100644 --- a/R/ta_SMA.R +++ b/R/ta_SMA.R @@ -170,37 +170,6 @@ simple_moving_average.numeric <- function( x } -#' @usage NULL -SMA_lookback <- simple_moving_average_lookback <- function( - x, - cols, - n = 30, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_SMA_lookback, - ## splice:lookback:start - as.double(constructed_series[[1]]), - as.integer(n) - ## splice:lookback:end - ) -} - #' @usage NULL #' @aliases simple_moving_average #' diff --git a/R/ta_STDDEV.R b/R/ta_STDDEV.R index 21ae6b9af..00288162a 100644 --- a/R/ta_STDDEV.R +++ b/R/ta_STDDEV.R @@ -86,19 +86,3 @@ rolling_standard_deviation.numeric <- function( ## return indicator x } - -#' @usage NULL -STDDEV_lookback <- rolling_standard_deviation_lookback <- function( - x, - n = 5, - k = 1 -) { - .Call( - C_impl_ta_STDDEV_lookback, - ## splice:lookback:start - as.double(x), - as.integer(n), - as.double(k) - ## splice:lookback:end - ) -} diff --git a/R/ta_STOCH.R b/R/ta_STOCH.R index c1598beeb..735c6aa5d 100644 --- a/R/ta_STOCH.R +++ b/R/ta_STOCH.R @@ -141,44 +141,6 @@ stochastic.matrix <- function( ) } -#' @usage NULL -STOCH_lookback <- stochastic_lookback <- function( - x, - cols, - fastk = 5, - slowk = SMA(n = 3), - slowd = SMA(n = 3), - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_STOCH_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - as.integer(fastk), - as.integer(slowk$n), - as.integer(slowk$maType), - as.integer(slowd$n), - as.integer(slowd$maType) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases stochastic diff --git a/R/ta_STOCHF.R b/R/ta_STOCHF.R index 28939fc24..77fe43ad0 100644 --- a/R/ta_STOCHF.R +++ b/R/ta_STOCHF.R @@ -132,41 +132,6 @@ fast_stochastic.matrix <- function( ) } -#' @usage NULL -STOCHF_lookback <- fast_stochastic_lookback <- function( - x, - cols, - fastk = 5, - fastd = SMA(n = 3), - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_STOCHF_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - as.integer(fastk), - as.integer(fastd$n), - as.integer(fastd$maType) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases fast_stochastic diff --git a/R/ta_STOCHRSI.R b/R/ta_STOCHRSI.R index 04c9fe201..0a92ac8a7 100644 --- a/R/ta_STOCHRSI.R +++ b/R/ta_STOCHRSI.R @@ -137,41 +137,6 @@ stochastic_relative_strength_index.matrix <- function( ) } -#' @usage NULL -STOCHRSI_lookback <- stochastic_relative_strength_index_lookback <- function( - x, - cols, - n = 14, - fastk = 5, - fastd = SMA(n = 3), - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_STOCHRSI_lookback, - ## splice:lookback:start - constructed_series[[1]], - as.integer(n), - as.integer(fastk), - as.integer(fastd$n), - as.integer(fastd$maType) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases stochastic_relative_strength_index diff --git a/R/ta_SUM.R b/R/ta_SUM.R index f8fc6020f..a80cfa32b 100644 --- a/R/ta_SUM.R +++ b/R/ta_SUM.R @@ -80,17 +80,3 @@ rolling_sum.numeric <- function( ## return indicator x } - -#' @usage NULL -SUM_lookback <- rolling_sum_lookback <- function( - x, - n = 30 -) { - .Call( - C_impl_ta_SUM_lookback, - ## splice:lookback:start - as.double(x), - as.integer(n) - ## splice:lookback:end - ) -} diff --git a/R/ta_T3.R b/R/ta_T3.R index 5d3d00bf6..8759ee27f 100644 --- a/R/ta_T3.R +++ b/R/ta_T3.R @@ -180,39 +180,6 @@ t3_exponential_moving_average.numeric <- function( x } -#' @usage NULL -T3_lookback <- t3_exponential_moving_average_lookback <- function( - x, - cols, - n = 5, - vfactor = 0.7, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_T3_lookback, - ## splice:lookback:start - as.double(constructed_series[[1]]), - as.integer(n), - as.double(vfactor) - ## splice:lookback:end - ) -} - #' @usage NULL #' @aliases t3_exponential_moving_average #' diff --git a/R/ta_TEMA.R b/R/ta_TEMA.R index ec7832ffe..31ee465cd 100644 --- a/R/ta_TEMA.R +++ b/R/ta_TEMA.R @@ -170,37 +170,6 @@ triple_exponential_moving_average.numeric <- function( x } -#' @usage NULL -TEMA_lookback <- triple_exponential_moving_average_lookback <- function( - x, - cols, - n = 30, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_TEMA_lookback, - ## splice:lookback:start - as.double(constructed_series[[1]]), - as.integer(n) - ## splice:lookback:end - ) -} - #' @usage NULL #' @aliases triple_exponential_moving_average #' diff --git a/R/ta_TRANGE.R b/R/ta_TRANGE.R index 549858324..943ca796c 100644 --- a/R/ta_TRANGE.R +++ b/R/ta_TRANGE.R @@ -115,36 +115,6 @@ true_range.matrix <- function( ) } -#' @usage NULL -TRANGE_lookback <- true_range_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_TRANGE_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]] - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases true_range diff --git a/R/ta_TRIMA.R b/R/ta_TRIMA.R index 1884c1a47..17b855f23 100644 --- a/R/ta_TRIMA.R +++ b/R/ta_TRIMA.R @@ -170,37 +170,6 @@ triangular_moving_average.numeric <- function( x } -#' @usage NULL -TRIMA_lookback <- triangular_moving_average_lookback <- function( - x, - cols, - n = 30, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_TRIMA_lookback, - ## splice:lookback:start - as.double(constructed_series[[1]]), - as.integer(n) - ## splice:lookback:end - ) -} - #' @usage NULL #' @aliases triangular_moving_average #' diff --git a/R/ta_TRIX.R b/R/ta_TRIX.R index c019ef9ac..425cdc49a 100644 --- a/R/ta_TRIX.R +++ b/R/ta_TRIX.R @@ -120,36 +120,6 @@ triple_exponential_average.matrix <- function( ) } -#' @usage NULL -TRIX_lookback <- triple_exponential_average_lookback <- function( - x, - cols, - n = 30, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_TRIX_lookback, - ## splice:lookback:start - constructed_series[[1]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases triple_exponential_average diff --git a/R/ta_TYPPRICE.R b/R/ta_TYPPRICE.R index ef6b1f07a..a1628d57f 100644 --- a/R/ta_TYPPRICE.R +++ b/R/ta_TYPPRICE.R @@ -114,34 +114,3 @@ typical_price.matrix <- function( ... ) } - -#' @usage NULL -TYPPRICE_lookback <- typical_price_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_TYPPRICE_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]] - ## splice:lookback:end - ) -} diff --git a/R/ta_ULTOSC.R b/R/ta_ULTOSC.R index 5a41dc974..b9792b5b9 100644 --- a/R/ta_ULTOSC.R +++ b/R/ta_ULTOSC.R @@ -124,40 +124,6 @@ ultimate_oscillator.matrix <- function( ) } -#' @usage NULL -ULTOSC_lookback <- ultimate_oscillator_lookback <- function( - x, - cols, - n = c(7, 14, 28), - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_ULTOSC_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - as.integer(n[1]), - as.integer(n[2]), - as.integer(n[3]) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases ultimate_oscillator diff --git a/R/ta_VAR.R b/R/ta_VAR.R index 4b6e9a010..c6b435430 100644 --- a/R/ta_VAR.R +++ b/R/ta_VAR.R @@ -86,19 +86,3 @@ rolling_variance.numeric <- function( ## return indicator x } - -#' @usage NULL -VAR_lookback <- rolling_variance_lookback <- function( - x, - n = 5, - k = 1 -) { - .Call( - C_impl_ta_VAR_lookback, - ## splice:lookback:start - as.double(x), - as.integer(n), - as.double(k) - ## splice:lookback:end - ) -} diff --git a/R/ta_VOLUME.R b/R/ta_VOLUME.R index be68789bc..bff358c05 100644 --- a/R/ta_VOLUME.R +++ b/R/ta_VOLUME.R @@ -128,43 +128,6 @@ trading_volume.matrix <- function( ) } -#' @usage NULL -VOLUME_lookback <- trading_volume_lookback <- function( - x, - cols, - ma = list(SMA(n = 7), SMA(n = 15)), - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ volume + open + close, - data = x, - ... - ) - - .Call( - C_impl_ta_VOLUME_lookback, - ## splice:lookback:start - as.double(constructed_series[[1]]), - lapply( - ma, - function(x) { - as.integer( - unlist(x, use.names = FALSE) - ) - } - ) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases trading_volume diff --git a/R/ta_WCLPRICE.R b/R/ta_WCLPRICE.R index b4940943f..f0e20bbfe 100644 --- a/R/ta_WCLPRICE.R +++ b/R/ta_WCLPRICE.R @@ -114,34 +114,3 @@ weighted_close_price.matrix <- function( ... ) } - -#' @usage NULL -WCLPRICE_lookback <- weighted_close_price_lookback <- function( - x, - cols, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_WCLPRICE_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]] - ## splice:lookback:end - ) -} diff --git a/R/ta_WILLR.R b/R/ta_WILLR.R index 2f48ea2a9..21c0a78de 100644 --- a/R/ta_WILLR.R +++ b/R/ta_WILLR.R @@ -122,38 +122,6 @@ williams_oscillator.matrix <- function( ) } -#' @usage NULL -WILLR_lookback <- williams_oscillator_lookback <- function( - x, - cols, - n = 14, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~ high + low + close, - data = x, - ... - ) - - .Call( - C_impl_ta_WILLR_lookback, - ## splice:lookback:start - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - as.integer(n) - ## splice:lookback:end - ) -} #' @usage NULL #' @aliases williams_oscillator diff --git a/R/ta_WMA.R b/R/ta_WMA.R index 917817d28..4a95fbe26 100644 --- a/R/ta_WMA.R +++ b/R/ta_WMA.R @@ -170,37 +170,6 @@ weighted_moving_average.numeric <- function( x } -#' @usage NULL -WMA_lookback <- weighted_moving_average_lookback <- function( - x, - cols, - n = 30, - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ~close, - data = x, - ... - ) - - .Call( - C_impl_ta_WMA_lookback, - ## splice:lookback:start - as.double(constructed_series[[1]]), - as.integer(n) - ## splice:lookback:end - ) -} - #' @usage NULL #' @aliases weighted_moving_average #' diff --git a/codegen/generate_unit-tests.sh b/codegen/generate_unit-tests.sh index 9f907b6b2..f03f83c80 100755 --- a/codegen/generate_unit-tests.sh +++ b/codegen/generate_unit-tests.sh @@ -75,23 +75,6 @@ testthat::expect_true( }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - -output <- attr( - ${FUN}(x = SPY[,1]${ADDITIONAL}), - "lookback" -) - -testthat::expect_equal( - object = output, - expected = lookback(FUN = ${FUN}, x = SPY[,1]${ADDITIONAL}) - ) - -} -) - EOF @@ -250,24 +233,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - -output <- attr( - ${FUN}(SPY), - "lookback" -) - -testthat::expect_equal( - object = output, - expected = lookback(FUN = ${FUN}, x = SPY) - ) - -} -) - EOF ## Add plotly methods diff --git a/codegen/templates/candlestick_template.R.in b/codegen/templates/candlestick_template.R.in index 1f18d98c5..a1d685cb1 100644 --- a/codegen/templates/candlestick_template.R.in +++ b/codegen/templates/candlestick_template.R.in @@ -130,36 +130,6 @@ $FUN.matrix <- function( NextMethod() } -#' @usage NULL -${ALIAS}_lookback <- ${FUN}_lookback <- function( - x, - cols,${ARGS} - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ${FORMULA}, - data = x, - ... - ) - - .Call( - C_impl_ta_${TA_FUN}_lookback, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] ${CARGS} - ) -} - #' @usage NULL #' @aliases $FUN #' diff --git a/codegen/templates/indicator_template.R.in b/codegen/templates/indicator_template.R.in index 84b84f02d..0abd895ba 100644 --- a/codegen/templates/indicator_template.R.in +++ b/codegen/templates/indicator_template.R.in @@ -110,31 +110,3 @@ ${FUN}.matrix <- function( ... ) } - -#' @usage NULL -${ALIAS}_lookback <- ${FUN}_lookback <- function( - x, - cols,${ARGS} - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ${FORMULA}, - data = x, - ... - ) - - .Call( - C_impl_ta_${TA_FUN}_lookback, - ## splice:lookback:start - ## splice:lookback:end - ) -} \ No newline at end of file diff --git a/codegen/templates/moving_average_template.R.in b/codegen/templates/moving_average_template.R.in index 10ce0dbe6..f67bae0d9 100644 --- a/codegen/templates/moving_average_template.R.in +++ b/codegen/templates/moving_average_template.R.in @@ -163,34 +163,6 @@ $FUN.numeric <- function( } -#' @usage NULL -${ALIAS}_lookback <- ${FUN}_lookback <- function( - x, - cols,${ARGS} - ... -) { - ## validate 'cols'-argument - ## if explicitly passed - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series - ## from input - constructed_series <- series( - x = cols, - default_formula = ${FORMULA}, - data = x, - ... - ) - - .Call( - C_impl_ta_${TA_FUN}_lookback, - ## splice:lookback:start - ## splice:lookback:end - ) -} - #' @usage NULL #' @aliases $FUN #' diff --git a/codegen/templates/rolling_template.R.in b/codegen/templates/rolling_template.R.in index 70683b2f6..29bfa7cb0 100644 --- a/codegen/templates/rolling_template.R.in +++ b/codegen/templates/rolling_template.R.in @@ -79,17 +79,4 @@ ${FUN}.numeric <- function( ## return indicator x -} - -#' @usage NULL -${ALIAS}_lookback <- ${FUN}_lookback <- function( - x,${ARGS} -) { - - .Call( - C_impl_ta_${TA_FUN}_lookback, - ## splice:lookback:start - ## splice:lookback:end - ) - -} +} \ No newline at end of file diff --git a/tests/testthat/test-ta_ACCBANDS.R b/tests/testthat/test-ta_ACCBANDS.R index d27f7b6e0..2bce7be98 100644 --- a/tests/testthat/test-ta_ACCBANDS.R +++ b/tests/testthat/test-ta_ACCBANDS.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - acceleration_bands(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = acceleration_bands, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_AD.R b/tests/testthat/test-ta_AD.R index aa72aabca..28d61d694 100644 --- a/tests/testthat/test-ta_AD.R +++ b/tests/testthat/test-ta_AD.R @@ -145,24 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - chaikin_accumulation_distribution_line(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback( - FUN = chaikin_accumulation_distribution_line, - x = SPY - ) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_ADOSC.R b/tests/testthat/test-ta_ADOSC.R index 02e4e468a..9ed88a8d0 100644 --- a/tests/testthat/test-ta_ADOSC.R +++ b/tests/testthat/test-ta_ADOSC.R @@ -148,24 +148,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - chaikin_accumulation_distribution_oscillator(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback( - FUN = chaikin_accumulation_distribution_oscillator, - x = SPY - ) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_ADX.R b/tests/testthat/test-ta_ADX.R index ad23c49bd..aa0e9f651 100644 --- a/tests/testthat/test-ta_ADX.R +++ b/tests/testthat/test-ta_ADX.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - average_directional_movement_index(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = average_directional_movement_index, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_ADXR.R b/tests/testthat/test-ta_ADXR.R index 3169fe75a..ce5f58cbd 100644 --- a/tests/testthat/test-ta_ADXR.R +++ b/tests/testthat/test-ta_ADXR.R @@ -148,24 +148,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - average_directional_movement_index_rating(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback( - FUN = average_directional_movement_index_rating, - x = SPY - ) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_APO.R b/tests/testthat/test-ta_APO.R index 4c278a1d1..6a7db8ae0 100644 --- a/tests/testthat/test-ta_APO.R +++ b/tests/testthat/test-ta_APO.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - absolute_price_oscillator(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = absolute_price_oscillator, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_AROON.R b/tests/testthat/test-ta_AROON.R index 737e5d5ab..adfbecc4e 100644 --- a/tests/testthat/test-ta_AROON.R +++ b/tests/testthat/test-ta_AROON.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - aroon(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = aroon, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_AROONOSC.R b/tests/testthat/test-ta_AROONOSC.R index 0fe1ce0cf..6c96b785b 100644 --- a/tests/testthat/test-ta_AROONOSC.R +++ b/tests/testthat/test-ta_AROONOSC.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - aroon_oscillator(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = aroon_oscillator, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_ATR.R b/tests/testthat/test-ta_ATR.R index abc4294a8..4745c6a89 100644 --- a/tests/testthat/test-ta_ATR.R +++ b/tests/testthat/test-ta_ATR.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - average_true_range(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = average_true_range, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_AVGPRICE.R b/tests/testthat/test-ta_AVGPRICE.R index 35525c9d9..a6ae729b2 100644 --- a/tests/testthat/test-ta_AVGPRICE.R +++ b/tests/testthat/test-ta_AVGPRICE.R @@ -143,18 +143,3 @@ testthat::test_that(desc = 'Row names are respected for ', code = { expected = rownames(indicator) ) }) - - -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - average_price(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = average_price, x = SPY) - ) -}) diff --git a/tests/testthat/test-ta_BBANDS.R b/tests/testthat/test-ta_BBANDS.R index 97042ad25..7ac8d3f53 100644 --- a/tests/testthat/test-ta_BBANDS.R +++ b/tests/testthat/test-ta_BBANDS.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - bollinger_bands(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = bollinger_bands, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_BETA.R b/tests/testthat/test-ta_BETA.R index dc0ae3a3d..055c4cb84 100644 --- a/tests/testthat/test-ta_BETA.R +++ b/tests/testthat/test-ta_BETA.R @@ -46,17 +46,3 @@ testthat::test_that(desc = 'Output type', code = { is.null(dim(output)) ) }) - -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - rolling_beta(x = SPY[, 1], y = SPY[, 2]), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = rolling_beta, x = SPY[, 1], y = SPY[, 2]) - ) -}) diff --git a/tests/testthat/test-ta_BOP.R b/tests/testthat/test-ta_BOP.R index ab00b9c4e..55707da8f 100644 --- a/tests/testthat/test-ta_BOP.R +++ b/tests/testthat/test-ta_BOP.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - balance_of_power(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = balance_of_power, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CCI.R b/tests/testthat/test-ta_CCI.R index fb88cdc5f..00ae8c3d0 100644 --- a/tests/testthat/test-ta_CCI.R +++ b/tests/testthat/test-ta_CCI.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - commodity_channel_index(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = commodity_channel_index, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL2CROWS.R b/tests/testthat/test-ta_CDL2CROWS.R index 57e89c099..be0fcce24 100644 --- a/tests/testthat/test-ta_CDL2CROWS.R +++ b/tests/testthat/test-ta_CDL2CROWS.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - two_crows(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = two_crows, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL3BLACKCROWS.R b/tests/testthat/test-ta_CDL3BLACKCROWS.R index ae024da6d..3ffbd29c2 100644 --- a/tests/testthat/test-ta_CDL3BLACKCROWS.R +++ b/tests/testthat/test-ta_CDL3BLACKCROWS.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - three_black_crows(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = three_black_crows, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL3INSIDE.R b/tests/testthat/test-ta_CDL3INSIDE.R index b01e35a84..904d06ff1 100644 --- a/tests/testthat/test-ta_CDL3INSIDE.R +++ b/tests/testthat/test-ta_CDL3INSIDE.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - three_inside(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = three_inside, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL3LINESTRIKE.R b/tests/testthat/test-ta_CDL3LINESTRIKE.R index d90a2a525..52f5f28ae 100644 --- a/tests/testthat/test-ta_CDL3LINESTRIKE.R +++ b/tests/testthat/test-ta_CDL3LINESTRIKE.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - three_line_strike(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = three_line_strike, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL3OUTSIDE.R b/tests/testthat/test-ta_CDL3OUTSIDE.R index 8bd959af2..1e0d888a8 100644 --- a/tests/testthat/test-ta_CDL3OUTSIDE.R +++ b/tests/testthat/test-ta_CDL3OUTSIDE.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - three_outside(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = three_outside, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL3STARSINSOUTH.R b/tests/testthat/test-ta_CDL3STARSINSOUTH.R index 7711c3797..4949a6f17 100644 --- a/tests/testthat/test-ta_CDL3STARSINSOUTH.R +++ b/tests/testthat/test-ta_CDL3STARSINSOUTH.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - three_stars_in_the_south(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = three_stars_in_the_south, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL3WHITESOLDIERS.R b/tests/testthat/test-ta_CDL3WHITESOLDIERS.R index 1090b3a2c..2fead055e 100644 --- a/tests/testthat/test-ta_CDL3WHITESOLDIERS.R +++ b/tests/testthat/test-ta_CDL3WHITESOLDIERS.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - three_white_soldiers(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = three_white_soldiers, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLABANDONEDBABY.R b/tests/testthat/test-ta_CDLABANDONEDBABY.R index a756c7c0a..8af4d3e6a 100644 --- a/tests/testthat/test-ta_CDLABANDONEDBABY.R +++ b/tests/testthat/test-ta_CDLABANDONEDBABY.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - abandoned_baby(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = abandoned_baby, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLADVANCEBLOCK.R b/tests/testthat/test-ta_CDLADVANCEBLOCK.R index 0b2d49de5..99841b11a 100644 --- a/tests/testthat/test-ta_CDLADVANCEBLOCK.R +++ b/tests/testthat/test-ta_CDLADVANCEBLOCK.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - advance_block(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = advance_block, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLBELTHOLD.R b/tests/testthat/test-ta_CDLBELTHOLD.R index 0925897d7..cf98c69c9 100644 --- a/tests/testthat/test-ta_CDLBELTHOLD.R +++ b/tests/testthat/test-ta_CDLBELTHOLD.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - belt_hold(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = belt_hold, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLBREAKAWAY.R b/tests/testthat/test-ta_CDLBREAKAWAY.R index 5d7742f70..bc510b1bf 100644 --- a/tests/testthat/test-ta_CDLBREAKAWAY.R +++ b/tests/testthat/test-ta_CDLBREAKAWAY.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - break_away(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = break_away, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLCLOSINGMARUBOZU.R b/tests/testthat/test-ta_CDLCLOSINGMARUBOZU.R index fbadbae5c..d3e9fc72a 100644 --- a/tests/testthat/test-ta_CDLCLOSINGMARUBOZU.R +++ b/tests/testthat/test-ta_CDLCLOSINGMARUBOZU.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - closing_marubozu(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = closing_marubozu, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLCONCEALBABYSWALL.R b/tests/testthat/test-ta_CDLCONCEALBABYSWALL.R index 01944539c..6e5bbf613 100644 --- a/tests/testthat/test-ta_CDLCONCEALBABYSWALL.R +++ b/tests/testthat/test-ta_CDLCONCEALBABYSWALL.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - concealing_baby_swallow(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = concealing_baby_swallow, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLCOUNTERATTACK.R b/tests/testthat/test-ta_CDLCOUNTERATTACK.R index 6b88529b3..2de3e4319 100644 --- a/tests/testthat/test-ta_CDLCOUNTERATTACK.R +++ b/tests/testthat/test-ta_CDLCOUNTERATTACK.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - counter_attack(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = counter_attack, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLDARKCLOUDCOVER.R b/tests/testthat/test-ta_CDLDARKCLOUDCOVER.R index 887072eeb..df221cf64 100644 --- a/tests/testthat/test-ta_CDLDARKCLOUDCOVER.R +++ b/tests/testthat/test-ta_CDLDARKCLOUDCOVER.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - dark_cloud_cover(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = dark_cloud_cover, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLDOJI.R b/tests/testthat/test-ta_CDLDOJI.R index 9be0ca7a8..67e041f02 100644 --- a/tests/testthat/test-ta_CDLDOJI.R +++ b/tests/testthat/test-ta_CDLDOJI.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - doji(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = doji, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLDOJISTAR.R b/tests/testthat/test-ta_CDLDOJISTAR.R index 3dd27de85..cc48aeddd 100644 --- a/tests/testthat/test-ta_CDLDOJISTAR.R +++ b/tests/testthat/test-ta_CDLDOJISTAR.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - doji_star(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = doji_star, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLDRAGONFLYDOJI.R b/tests/testthat/test-ta_CDLDRAGONFLYDOJI.R index 7b5f5fbb1..098c48167 100644 --- a/tests/testthat/test-ta_CDLDRAGONFLYDOJI.R +++ b/tests/testthat/test-ta_CDLDRAGONFLYDOJI.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - dragonfly_doji(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = dragonfly_doji, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLENGULFING.R b/tests/testthat/test-ta_CDLENGULFING.R index b6de41d3d..fa7e4c09b 100644 --- a/tests/testthat/test-ta_CDLENGULFING.R +++ b/tests/testthat/test-ta_CDLENGULFING.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - engulfing(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = engulfing, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLEVENINGDOJISTAR.R b/tests/testthat/test-ta_CDLEVENINGDOJISTAR.R index e88be9f88..b4b9b5fc8 100644 --- a/tests/testthat/test-ta_CDLEVENINGDOJISTAR.R +++ b/tests/testthat/test-ta_CDLEVENINGDOJISTAR.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - evening_doji_star(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = evening_doji_star, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLEVENINGSTAR.R b/tests/testthat/test-ta_CDLEVENINGSTAR.R index 2fd5dd7e4..a8a232d0a 100644 --- a/tests/testthat/test-ta_CDLEVENINGSTAR.R +++ b/tests/testthat/test-ta_CDLEVENINGSTAR.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - evening_star(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = evening_star, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLGAPSIDESIDEWHITE.R b/tests/testthat/test-ta_CDLGAPSIDESIDEWHITE.R index 2cede5c71..10e7f8a07 100644 --- a/tests/testthat/test-ta_CDLGAPSIDESIDEWHITE.R +++ b/tests/testthat/test-ta_CDLGAPSIDESIDEWHITE.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - gaps_side_white(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = gaps_side_white, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLGRAVESTONEDOJI.R b/tests/testthat/test-ta_CDLGRAVESTONEDOJI.R index e9b9547e7..160936539 100644 --- a/tests/testthat/test-ta_CDLGRAVESTONEDOJI.R +++ b/tests/testthat/test-ta_CDLGRAVESTONEDOJI.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - gravestone_doji(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = gravestone_doji, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHAMMER.R b/tests/testthat/test-ta_CDLHAMMER.R index 89769d5f8..047e42d2e 100644 --- a/tests/testthat/test-ta_CDLHAMMER.R +++ b/tests/testthat/test-ta_CDLHAMMER.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - hammer(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = hammer, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHANGINGMAN.R b/tests/testthat/test-ta_CDLHANGINGMAN.R index 293d18582..da7084715 100644 --- a/tests/testthat/test-ta_CDLHANGINGMAN.R +++ b/tests/testthat/test-ta_CDLHANGINGMAN.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - hanging_man(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = hanging_man, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHARAMI.R b/tests/testthat/test-ta_CDLHARAMI.R index ad4d92e73..7ee501a58 100644 --- a/tests/testthat/test-ta_CDLHARAMI.R +++ b/tests/testthat/test-ta_CDLHARAMI.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - harami(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = harami, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHARAMICROSS.R b/tests/testthat/test-ta_CDLHARAMICROSS.R index 366621256..7a61982b9 100644 --- a/tests/testthat/test-ta_CDLHARAMICROSS.R +++ b/tests/testthat/test-ta_CDLHARAMICROSS.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - harami_cross(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = harami_cross, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHIGHWAVE.R b/tests/testthat/test-ta_CDLHIGHWAVE.R index d8fd29fc3..d928d8fc6 100644 --- a/tests/testthat/test-ta_CDLHIGHWAVE.R +++ b/tests/testthat/test-ta_CDLHIGHWAVE.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - high_wave(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = high_wave, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHIKKAKE.R b/tests/testthat/test-ta_CDLHIKKAKE.R index 8ff701939..a1639124e 100644 --- a/tests/testthat/test-ta_CDLHIKKAKE.R +++ b/tests/testthat/test-ta_CDLHIKKAKE.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - hikakke(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = hikakke, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHIKKAKEMOD.R b/tests/testthat/test-ta_CDLHIKKAKEMOD.R index f08218c21..82eecd158 100644 --- a/tests/testthat/test-ta_CDLHIKKAKEMOD.R +++ b/tests/testthat/test-ta_CDLHIKKAKEMOD.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - hikakke_mod(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = hikakke_mod, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHOMINGPIGEON.R b/tests/testthat/test-ta_CDLHOMINGPIGEON.R index dcbdcdbde..c2ea37eca 100644 --- a/tests/testthat/test-ta_CDLHOMINGPIGEON.R +++ b/tests/testthat/test-ta_CDLHOMINGPIGEON.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - homing_pigeon(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = homing_pigeon, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLIDENTICAL3CROWS.R b/tests/testthat/test-ta_CDLIDENTICAL3CROWS.R index efc977d05..c001ea8f4 100644 --- a/tests/testthat/test-ta_CDLIDENTICAL3CROWS.R +++ b/tests/testthat/test-ta_CDLIDENTICAL3CROWS.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - three_identical_crows(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = three_identical_crows, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLINNECK.R b/tests/testthat/test-ta_CDLINNECK.R index 67a0ffc99..17b847b8e 100644 --- a/tests/testthat/test-ta_CDLINNECK.R +++ b/tests/testthat/test-ta_CDLINNECK.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - in_neck(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = in_neck, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLINVERTEDHAMMER.R b/tests/testthat/test-ta_CDLINVERTEDHAMMER.R index 081a9961a..5a72d69e9 100644 --- a/tests/testthat/test-ta_CDLINVERTEDHAMMER.R +++ b/tests/testthat/test-ta_CDLINVERTEDHAMMER.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - inverted_hammer(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = inverted_hammer, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLKICKING.R b/tests/testthat/test-ta_CDLKICKING.R index 0e544cecc..54e26ba44 100644 --- a/tests/testthat/test-ta_CDLKICKING.R +++ b/tests/testthat/test-ta_CDLKICKING.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - kicking(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = kicking, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLKICKINGBYLENGTH.R b/tests/testthat/test-ta_CDLKICKINGBYLENGTH.R index 81efb459d..96b3dd158 100644 --- a/tests/testthat/test-ta_CDLKICKINGBYLENGTH.R +++ b/tests/testthat/test-ta_CDLKICKINGBYLENGTH.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - kicking_baby_length(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = kicking_baby_length, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLLADDERBOTTOM.R b/tests/testthat/test-ta_CDLLADDERBOTTOM.R index 74170a8a8..75d5b4bc9 100644 --- a/tests/testthat/test-ta_CDLLADDERBOTTOM.R +++ b/tests/testthat/test-ta_CDLLADDERBOTTOM.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - ladder_bottom(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = ladder_bottom, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLLONGLEGGEDDOJI.R b/tests/testthat/test-ta_CDLLONGLEGGEDDOJI.R index 0ca3a2d6f..353ca3b28 100644 --- a/tests/testthat/test-ta_CDLLONGLEGGEDDOJI.R +++ b/tests/testthat/test-ta_CDLLONGLEGGEDDOJI.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - long_legged_doji(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = long_legged_doji, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLLONGLINE.R b/tests/testthat/test-ta_CDLLONGLINE.R index 550647bf4..8982d3e8e 100644 --- a/tests/testthat/test-ta_CDLLONGLINE.R +++ b/tests/testthat/test-ta_CDLLONGLINE.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - long_line(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = long_line, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLMARUBOZU.R b/tests/testthat/test-ta_CDLMARUBOZU.R index 8cfa02440..2aa85275b 100644 --- a/tests/testthat/test-ta_CDLMARUBOZU.R +++ b/tests/testthat/test-ta_CDLMARUBOZU.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - marubozu(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = marubozu, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLMATCHINGLOW.R b/tests/testthat/test-ta_CDLMATCHINGLOW.R index e340936ee..cc0b2d134 100644 --- a/tests/testthat/test-ta_CDLMATCHINGLOW.R +++ b/tests/testthat/test-ta_CDLMATCHINGLOW.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - matching_low(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = matching_low, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLMATHOLD.R b/tests/testthat/test-ta_CDLMATHOLD.R index 19d711cb0..3061c6f99 100644 --- a/tests/testthat/test-ta_CDLMATHOLD.R +++ b/tests/testthat/test-ta_CDLMATHOLD.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - mat_hold(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = mat_hold, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLMORNINGDOJISTAR.R b/tests/testthat/test-ta_CDLMORNINGDOJISTAR.R index ec281f228..4e9d131eb 100644 --- a/tests/testthat/test-ta_CDLMORNINGDOJISTAR.R +++ b/tests/testthat/test-ta_CDLMORNINGDOJISTAR.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - morning_doji_star(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = morning_doji_star, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLMORNINGSTAR.R b/tests/testthat/test-ta_CDLMORNINGSTAR.R index 1701248cf..fb04a8d47 100644 --- a/tests/testthat/test-ta_CDLMORNINGSTAR.R +++ b/tests/testthat/test-ta_CDLMORNINGSTAR.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - morning_star(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = morning_star, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLONNECK.R b/tests/testthat/test-ta_CDLONNECK.R index e62388a5e..a18cf4f92 100644 --- a/tests/testthat/test-ta_CDLONNECK.R +++ b/tests/testthat/test-ta_CDLONNECK.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - on_neck(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = on_neck, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLPIERCING.R b/tests/testthat/test-ta_CDLPIERCING.R index 4734b0de6..118b1041a 100644 --- a/tests/testthat/test-ta_CDLPIERCING.R +++ b/tests/testthat/test-ta_CDLPIERCING.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - piercing(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = piercing, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLRICKSHAWMAN.R b/tests/testthat/test-ta_CDLRICKSHAWMAN.R index 3e7b17e1c..9b5de9900 100644 --- a/tests/testthat/test-ta_CDLRICKSHAWMAN.R +++ b/tests/testthat/test-ta_CDLRICKSHAWMAN.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - rickshaw_man(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = rickshaw_man, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLRISEFALL3METHODS.R b/tests/testthat/test-ta_CDLRISEFALL3METHODS.R index 1510aaf78..4a9f7fe73 100644 --- a/tests/testthat/test-ta_CDLRISEFALL3METHODS.R +++ b/tests/testthat/test-ta_CDLRISEFALL3METHODS.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - rise_fall_3_methods(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = rise_fall_3_methods, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLSEPARATINGLINES.R b/tests/testthat/test-ta_CDLSEPARATINGLINES.R index e7006563f..7756e474b 100644 --- a/tests/testthat/test-ta_CDLSEPARATINGLINES.R +++ b/tests/testthat/test-ta_CDLSEPARATINGLINES.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - separating_lines(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = separating_lines, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLSHOOTINGSTAR.R b/tests/testthat/test-ta_CDLSHOOTINGSTAR.R index 3a7010c90..7af511f6d 100644 --- a/tests/testthat/test-ta_CDLSHOOTINGSTAR.R +++ b/tests/testthat/test-ta_CDLSHOOTINGSTAR.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - shooting_star(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = shooting_star, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLSHORTLINE.R b/tests/testthat/test-ta_CDLSHORTLINE.R index c71da3c59..b98f773be 100644 --- a/tests/testthat/test-ta_CDLSHORTLINE.R +++ b/tests/testthat/test-ta_CDLSHORTLINE.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - short_line(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = short_line, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLSPINNINGTOP.R b/tests/testthat/test-ta_CDLSPINNINGTOP.R index 848de0884..6bd2ec372 100644 --- a/tests/testthat/test-ta_CDLSPINNINGTOP.R +++ b/tests/testthat/test-ta_CDLSPINNINGTOP.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - spinning_top(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = spinning_top, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLSTALLEDPATTERN.R b/tests/testthat/test-ta_CDLSTALLEDPATTERN.R index 7a08ac4ca..7e2bdff9f 100644 --- a/tests/testthat/test-ta_CDLSTALLEDPATTERN.R +++ b/tests/testthat/test-ta_CDLSTALLEDPATTERN.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - stalled_pattern(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = stalled_pattern, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLSTICKSANDWICH.R b/tests/testthat/test-ta_CDLSTICKSANDWICH.R index 66efd60ab..a083b6598 100644 --- a/tests/testthat/test-ta_CDLSTICKSANDWICH.R +++ b/tests/testthat/test-ta_CDLSTICKSANDWICH.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - stick_sandwich(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = stick_sandwich, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLTAKURI.R b/tests/testthat/test-ta_CDLTAKURI.R index aa9d1a6de..ca4ddf6c1 100644 --- a/tests/testthat/test-ta_CDLTAKURI.R +++ b/tests/testthat/test-ta_CDLTAKURI.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - takuri(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = takuri, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLTASUKIGAP.R b/tests/testthat/test-ta_CDLTASUKIGAP.R index e652c9127..151338573 100644 --- a/tests/testthat/test-ta_CDLTASUKIGAP.R +++ b/tests/testthat/test-ta_CDLTASUKIGAP.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - tasuki_gap(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = tasuki_gap, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLTHRUSTING.R b/tests/testthat/test-ta_CDLTHRUSTING.R index 895e33459..775b2c9fa 100644 --- a/tests/testthat/test-ta_CDLTHRUSTING.R +++ b/tests/testthat/test-ta_CDLTHRUSTING.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - thrusting(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = thrusting, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLTRISTAR.R b/tests/testthat/test-ta_CDLTRISTAR.R index 2bd3d5a70..561cd18de 100644 --- a/tests/testthat/test-ta_CDLTRISTAR.R +++ b/tests/testthat/test-ta_CDLTRISTAR.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - tristar(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = tristar, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLUNIQUE3RIVER.R b/tests/testthat/test-ta_CDLUNIQUE3RIVER.R index 48f97a82b..59f06585c 100644 --- a/tests/testthat/test-ta_CDLUNIQUE3RIVER.R +++ b/tests/testthat/test-ta_CDLUNIQUE3RIVER.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - unique_3_river(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = unique_3_river, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLUPSIDEGAP2CROWS.R b/tests/testthat/test-ta_CDLUPSIDEGAP2CROWS.R index 982790841..cb8d12ad3 100644 --- a/tests/testthat/test-ta_CDLUPSIDEGAP2CROWS.R +++ b/tests/testthat/test-ta_CDLUPSIDEGAP2CROWS.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - upside_gap_2_crows(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = upside_gap_2_crows, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLXSIDEGAP3METHODS.R b/tests/testthat/test-ta_CDLXSIDEGAP3METHODS.R index 710f3b903..f4b20b9e0 100644 --- a/tests/testthat/test-ta_CDLXSIDEGAP3METHODS.R +++ b/tests/testthat/test-ta_CDLXSIDEGAP3METHODS.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - xside_gap_3_methods(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = xside_gap_3_methods, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CMO.R b/tests/testthat/test-ta_CMO.R index af02063a1..cbc21a57b 100644 --- a/tests/testthat/test-ta_CMO.R +++ b/tests/testthat/test-ta_CMO.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - chande_momentum_oscillator(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = chande_momentum_oscillator, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CORREL.R b/tests/testthat/test-ta_CORREL.R index ba2697b70..2680ac24d 100644 --- a/tests/testthat/test-ta_CORREL.R +++ b/tests/testthat/test-ta_CORREL.R @@ -46,21 +46,3 @@ testthat::test_that(desc = 'Output type', code = { is.null(dim(output)) ) }) - -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - rolling_correlation(x = SPY[, 1], y = SPY[, 2]), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback( - FUN = rolling_correlation, - x = SPY[, 1], - y = SPY[, 2] - ) - ) -}) diff --git a/tests/testthat/test-ta_DEMA.R b/tests/testthat/test-ta_DEMA.R index c8948ad8b..1ef030463 100644 --- a/tests/testthat/test-ta_DEMA.R +++ b/tests/testthat/test-ta_DEMA.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - double_exponential_moving_average(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = double_exponential_moving_average, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_DX.R b/tests/testthat/test-ta_DX.R index 06e961326..0ef9a0ec7 100644 --- a/tests/testthat/test-ta_DX.R +++ b/tests/testthat/test-ta_DX.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - directional_movement_index(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = directional_movement_index, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_EMA.R b/tests/testthat/test-ta_EMA.R index ae062cbd4..680097900 100644 --- a/tests/testthat/test-ta_EMA.R +++ b/tests/testthat/test-ta_EMA.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - exponential_moving_average(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = exponential_moving_average, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_HT_DCPERIOD.R b/tests/testthat/test-ta_HT_DCPERIOD.R index 019049c5d..c74fd4266 100644 --- a/tests/testthat/test-ta_HT_DCPERIOD.R +++ b/tests/testthat/test-ta_HT_DCPERIOD.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - dominant_cycle_period(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = dominant_cycle_period, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_HT_DCPHASE.R b/tests/testthat/test-ta_HT_DCPHASE.R index 119ec638e..44073b4ad 100644 --- a/tests/testthat/test-ta_HT_DCPHASE.R +++ b/tests/testthat/test-ta_HT_DCPHASE.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - dominant_cycle_phase(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = dominant_cycle_phase, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_HT_PHASOR.R b/tests/testthat/test-ta_HT_PHASOR.R index 46a40970e..063b034bf 100644 --- a/tests/testthat/test-ta_HT_PHASOR.R +++ b/tests/testthat/test-ta_HT_PHASOR.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - phasor_components(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = phasor_components, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_HT_SINE.R b/tests/testthat/test-ta_HT_SINE.R index 7ddc825a1..21aab5ca8 100644 --- a/tests/testthat/test-ta_HT_SINE.R +++ b/tests/testthat/test-ta_HT_SINE.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - sine_wave(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = sine_wave, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_HT_TRENDLINE.R b/tests/testthat/test-ta_HT_TRENDLINE.R index 6ae935009..7d05c935b 100644 --- a/tests/testthat/test-ta_HT_TRENDLINE.R +++ b/tests/testthat/test-ta_HT_TRENDLINE.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - trendline(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = trendline, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_HT_TRENDMODE.R b/tests/testthat/test-ta_HT_TRENDMODE.R index 694549617..df8d30209 100644 --- a/tests/testthat/test-ta_HT_TRENDMODE.R +++ b/tests/testthat/test-ta_HT_TRENDMODE.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - trend_cycle_mode(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = trend_cycle_mode, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_IMI.R b/tests/testthat/test-ta_IMI.R index 68dc4224c..586fd435c 100644 --- a/tests/testthat/test-ta_IMI.R +++ b/tests/testthat/test-ta_IMI.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - intraday_movement_index(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = intraday_movement_index, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_KAMA.R b/tests/testthat/test-ta_KAMA.R index f35f4e86e..3a7c163a1 100644 --- a/tests/testthat/test-ta_KAMA.R +++ b/tests/testthat/test-ta_KAMA.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - kaufman_adaptive_moving_average(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = kaufman_adaptive_moving_average, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MACD.R b/tests/testthat/test-ta_MACD.R index 63353d8c7..ba3060c1f 100644 --- a/tests/testthat/test-ta_MACD.R +++ b/tests/testthat/test-ta_MACD.R @@ -145,24 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - moving_average_convergence_divergence(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback( - FUN = moving_average_convergence_divergence, - x = SPY - ) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MACDEXT.R b/tests/testthat/test-ta_MACDEXT.R index 4edcfc289..ad6b9ccb0 100644 --- a/tests/testthat/test-ta_MACDEXT.R +++ b/tests/testthat/test-ta_MACDEXT.R @@ -154,24 +154,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - extended_moving_average_convergence_divergence(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback( - FUN = extended_moving_average_convergence_divergence, - x = SPY - ) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MACDFIX.R b/tests/testthat/test-ta_MACDFIX.R index 027e2d979..2ebd33b7e 100644 --- a/tests/testthat/test-ta_MACDFIX.R +++ b/tests/testthat/test-ta_MACDFIX.R @@ -148,24 +148,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - fixed_moving_average_convergence_divergence(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback( - FUN = fixed_moving_average_convergence_divergence, - x = SPY - ) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MAMA.R b/tests/testthat/test-ta_MAMA.R index c45b1f38e..c817b02db 100644 --- a/tests/testthat/test-ta_MAMA.R +++ b/tests/testthat/test-ta_MAMA.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - mesa_adaptive_moving_average(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = mesa_adaptive_moving_average, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MAX.R b/tests/testthat/test-ta_MAX.R index e4ef3cf38..d18da372d 100644 --- a/tests/testthat/test-ta_MAX.R +++ b/tests/testthat/test-ta_MAX.R @@ -43,17 +43,3 @@ testthat::test_that(desc = 'Output type', code = { is.null(dim(output)) ) }) - -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - rolling_max(x = SPY[, 1]), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = rolling_max, x = SPY[, 1]) - ) -}) diff --git a/tests/testthat/test-ta_MEDPRICE.R b/tests/testthat/test-ta_MEDPRICE.R index 5d5c02888..a3268f1ec 100644 --- a/tests/testthat/test-ta_MEDPRICE.R +++ b/tests/testthat/test-ta_MEDPRICE.R @@ -143,18 +143,3 @@ testthat::test_that(desc = 'Row names are respected for ', code = { expected = rownames(indicator) ) }) - - -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - median_price(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = median_price, x = SPY) - ) -}) diff --git a/tests/testthat/test-ta_MFI.R b/tests/testthat/test-ta_MFI.R index c785d3196..b6f832c39 100644 --- a/tests/testthat/test-ta_MFI.R +++ b/tests/testthat/test-ta_MFI.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - money_flow_index(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = money_flow_index, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MIDPRICE.R b/tests/testthat/test-ta_MIDPRICE.R index 9ad709206..3b0ff3d34 100644 --- a/tests/testthat/test-ta_MIDPRICE.R +++ b/tests/testthat/test-ta_MIDPRICE.R @@ -143,18 +143,3 @@ testthat::test_that(desc = 'Row names are respected for ', code = { expected = rownames(indicator) ) }) - - -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - midpoint_price(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = midpoint_price, x = SPY) - ) -}) diff --git a/tests/testthat/test-ta_MIN.R b/tests/testthat/test-ta_MIN.R index 096b20dcb..8e4b4a794 100644 --- a/tests/testthat/test-ta_MIN.R +++ b/tests/testthat/test-ta_MIN.R @@ -43,17 +43,3 @@ testthat::test_that(desc = 'Output type', code = { is.null(dim(output)) ) }) - -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - rolling_min(x = SPY[, 1]), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = rolling_min, x = SPY[, 1]) - ) -}) diff --git a/tests/testthat/test-ta_MINUS_DI.R b/tests/testthat/test-ta_MINUS_DI.R index 661051c7d..a2d444dd9 100644 --- a/tests/testthat/test-ta_MINUS_DI.R +++ b/tests/testthat/test-ta_MINUS_DI.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - minus_directional_indicator(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = minus_directional_indicator, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MINUS_DM.R b/tests/testthat/test-ta_MINUS_DM.R index 567472906..bd13137d1 100644 --- a/tests/testthat/test-ta_MINUS_DM.R +++ b/tests/testthat/test-ta_MINUS_DM.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - minus_directional_movement(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = minus_directional_movement, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MOM.R b/tests/testthat/test-ta_MOM.R index 5a1ff1760..480243f7a 100644 --- a/tests/testthat/test-ta_MOM.R +++ b/tests/testthat/test-ta_MOM.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - momentum(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = momentum, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_NATR.R b/tests/testthat/test-ta_NATR.R index 2e73d0da5..5d3e8d6cf 100644 --- a/tests/testthat/test-ta_NATR.R +++ b/tests/testthat/test-ta_NATR.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - normalized_average_true_range(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = normalized_average_true_range, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_OBV.R b/tests/testthat/test-ta_OBV.R index 3cf6baa45..e15438b2b 100644 --- a/tests/testthat/test-ta_OBV.R +++ b/tests/testthat/test-ta_OBV.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - on_balance_volume(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = on_balance_volume, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_PLUS_DI.R b/tests/testthat/test-ta_PLUS_DI.R index 56bb268d0..252e91b89 100644 --- a/tests/testthat/test-ta_PLUS_DI.R +++ b/tests/testthat/test-ta_PLUS_DI.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - plus_directional_indicator(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = plus_directional_indicator, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_PLUS_DM.R b/tests/testthat/test-ta_PLUS_DM.R index d3382d5a2..2e960ee99 100644 --- a/tests/testthat/test-ta_PLUS_DM.R +++ b/tests/testthat/test-ta_PLUS_DM.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - plus_directional_movement(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = plus_directional_movement, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_PPO.R b/tests/testthat/test-ta_PPO.R index 1e6f59897..1325491b4 100644 --- a/tests/testthat/test-ta_PPO.R +++ b/tests/testthat/test-ta_PPO.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - percentage_price_oscillator(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = percentage_price_oscillator, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_ROC.R b/tests/testthat/test-ta_ROC.R index 6fbc18b1c..027cf91dc 100644 --- a/tests/testthat/test-ta_ROC.R +++ b/tests/testthat/test-ta_ROC.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - rate_of_change(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = rate_of_change, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_ROCR.R b/tests/testthat/test-ta_ROCR.R index 7db88ff95..88baa1d32 100644 --- a/tests/testthat/test-ta_ROCR.R +++ b/tests/testthat/test-ta_ROCR.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - ratio_of_change(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = ratio_of_change, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_RSI.R b/tests/testthat/test-ta_RSI.R index 42f0740d7..cef6ef1ba 100644 --- a/tests/testthat/test-ta_RSI.R +++ b/tests/testthat/test-ta_RSI.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - relative_strength_index(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = relative_strength_index, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_SAR.R b/tests/testthat/test-ta_SAR.R index b3d8365b4..a3e0a58d8 100644 --- a/tests/testthat/test-ta_SAR.R +++ b/tests/testthat/test-ta_SAR.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - parabolic_stop_and_reverse(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = parabolic_stop_and_reverse, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_SAREXT.R b/tests/testthat/test-ta_SAREXT.R index 136e064ff..3489c4c7f 100644 --- a/tests/testthat/test-ta_SAREXT.R +++ b/tests/testthat/test-ta_SAREXT.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - extended_parabolic_stop_and_reverse(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = extended_parabolic_stop_and_reverse, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_SMA.R b/tests/testthat/test-ta_SMA.R index 3758f8a78..aa5a058ac 100644 --- a/tests/testthat/test-ta_SMA.R +++ b/tests/testthat/test-ta_SMA.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - simple_moving_average(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = simple_moving_average, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_STDDEV.R b/tests/testthat/test-ta_STDDEV.R index f29474932..938920e2c 100644 --- a/tests/testthat/test-ta_STDDEV.R +++ b/tests/testthat/test-ta_STDDEV.R @@ -43,17 +43,3 @@ testthat::test_that(desc = 'Output type', code = { is.null(dim(output)) ) }) - -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - rolling_standard_deviation(x = SPY[, 1]), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = rolling_standard_deviation, x = SPY[, 1]) - ) -}) diff --git a/tests/testthat/test-ta_STOCH.R b/tests/testthat/test-ta_STOCH.R index ddb54a3d0..45fcbc33e 100644 --- a/tests/testthat/test-ta_STOCH.R +++ b/tests/testthat/test-ta_STOCH.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - stochastic(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = stochastic, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_STOCHF.R b/tests/testthat/test-ta_STOCHF.R index e0bf6cf3f..6605c6abf 100644 --- a/tests/testthat/test-ta_STOCHF.R +++ b/tests/testthat/test-ta_STOCHF.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - fast_stochastic(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = fast_stochastic, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_STOCHRSI.R b/tests/testthat/test-ta_STOCHRSI.R index 00dd50b0f..68e5a3cdc 100644 --- a/tests/testthat/test-ta_STOCHRSI.R +++ b/tests/testthat/test-ta_STOCHRSI.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - stochastic_relative_strength_index(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = stochastic_relative_strength_index, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_SUM.R b/tests/testthat/test-ta_SUM.R index 7fc77ecf6..793bc616c 100644 --- a/tests/testthat/test-ta_SUM.R +++ b/tests/testthat/test-ta_SUM.R @@ -43,17 +43,3 @@ testthat::test_that(desc = 'Output type', code = { is.null(dim(output)) ) }) - -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - rolling_sum(x = SPY[, 1]), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = rolling_sum, x = SPY[, 1]) - ) -}) diff --git a/tests/testthat/test-ta_T3.R b/tests/testthat/test-ta_T3.R index 8f9fd69a5..e1aa95eb5 100644 --- a/tests/testthat/test-ta_T3.R +++ b/tests/testthat/test-ta_T3.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - t3_exponential_moving_average(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = t3_exponential_moving_average, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_TEMA.R b/tests/testthat/test-ta_TEMA.R index 945f44b40..bfdf9cdb1 100644 --- a/tests/testthat/test-ta_TEMA.R +++ b/tests/testthat/test-ta_TEMA.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - triple_exponential_moving_average(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = triple_exponential_moving_average, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_TRANGE.R b/tests/testthat/test-ta_TRANGE.R index ce74863af..de90b9169 100644 --- a/tests/testthat/test-ta_TRANGE.R +++ b/tests/testthat/test-ta_TRANGE.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - true_range(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = true_range, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_TRIMA.R b/tests/testthat/test-ta_TRIMA.R index e64d69b06..0701e8b95 100644 --- a/tests/testthat/test-ta_TRIMA.R +++ b/tests/testthat/test-ta_TRIMA.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - triangular_moving_average(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = triangular_moving_average, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_TRIX.R b/tests/testthat/test-ta_TRIX.R index ead620360..584478123 100644 --- a/tests/testthat/test-ta_TRIX.R +++ b/tests/testthat/test-ta_TRIX.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - triple_exponential_average(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = triple_exponential_average, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_TYPPRICE.R b/tests/testthat/test-ta_TYPPRICE.R index ff52938ef..d6938c5aa 100644 --- a/tests/testthat/test-ta_TYPPRICE.R +++ b/tests/testthat/test-ta_TYPPRICE.R @@ -143,18 +143,3 @@ testthat::test_that(desc = 'Row names are respected for ', code = { expected = rownames(indicator) ) }) - - -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - typical_price(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = typical_price, x = SPY) - ) -}) diff --git a/tests/testthat/test-ta_ULTOSC.R b/tests/testthat/test-ta_ULTOSC.R index 686ced54c..3ddd6650c 100644 --- a/tests/testthat/test-ta_ULTOSC.R +++ b/tests/testthat/test-ta_ULTOSC.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - ultimate_oscillator(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = ultimate_oscillator, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_VAR.R b/tests/testthat/test-ta_VAR.R index 35182f887..f8403c2cd 100644 --- a/tests/testthat/test-ta_VAR.R +++ b/tests/testthat/test-ta_VAR.R @@ -43,17 +43,3 @@ testthat::test_that(desc = 'Output type', code = { is.null(dim(output)) ) }) - -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - rolling_variance(x = SPY[, 1]), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = rolling_variance, x = SPY[, 1]) - ) -}) diff --git a/tests/testthat/test-ta_VOLUME.R b/tests/testthat/test-ta_VOLUME.R index 9cbcd4024..2d5ad295f 100644 --- a/tests/testthat/test-ta_VOLUME.R +++ b/tests/testthat/test-ta_VOLUME.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - trading_volume(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = trading_volume, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_WCLPRICE.R b/tests/testthat/test-ta_WCLPRICE.R index 80cf3aedb..ab6ad34e9 100644 --- a/tests/testthat/test-ta_WCLPRICE.R +++ b/tests/testthat/test-ta_WCLPRICE.R @@ -143,18 +143,3 @@ testthat::test_that(desc = 'Row names are respected for ', code = { expected = rownames(indicator) ) }) - - -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - weighted_close_price(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = weighted_close_price, x = SPY) - ) -}) diff --git a/tests/testthat/test-ta_WILLR.R b/tests/testthat/test-ta_WILLR.R index 1c87c880c..a7e15e63b 100644 --- a/tests/testthat/test-ta_WILLR.R +++ b/tests/testthat/test-ta_WILLR.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - williams_oscillator(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = williams_oscillator, x = SPY) - ) -}) - - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_WMA.R b/tests/testthat/test-ta_WMA.R index 3ec6ccb77..0d27be6a0 100644 --- a/tests/testthat/test-ta_WMA.R +++ b/tests/testthat/test-ta_WMA.R @@ -145,21 +145,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { }) -## test the output's attribute "lookback" matches -## the lookback() -testthat::test_that(desc = 'Lookback equivalence', code = { - output <- attr( - weighted_moving_average(SPY), - "lookback" - ) - - testthat::expect_equal( - object = output, - expected = lookback(FUN = weighted_moving_average, x = SPY) - ) -}) - - ## -method checks for ## and ## From 4410628a337148ca9a033b3c86febd629d093141 Mon Sep 17 00:00:00 2001 From: Serkan Korkmaz <77464572+serkor1@users.noreply.github.com> Date: Tue, 14 Jul 2026 23:00:07 +0200 Subject: [PATCH 6/8] :hammer: X-Macros (#78) ## :books: What? This PR is a rewrite of the source code that binds TA-Lib to R. The overall goal is to reduce the amount of code, and simplify the C-wrappers. It has been implemented incrementally, so much of the original functionality as been deleted but is to be reintroduced in a similar fashion. There has been no consideration for backwards compatibility which in this case means that a part of the R logic has to be re-written (This does not affect the signatures at all). All *_lookback functions, for example, now only accepts the relevant arguments in `.Call()` which breaks with the current R side logic. (This should be possible by only rewriting the templates, so the PR is mainly focused on the C-side) --- codegen/gen_code/generate.R | 52 +-- codegen/generate_API.sh | 91 ----- codegen/generate_FFI.sh | 83 ---- codegen/generate_indicator_core.sh | 461 ---------------------- codegen/templates/indicator_template.c.in | 142 ------- src/MAType.h | 36 -- src/NA-handling.c | 144 +++++++ src/NA-handling.h | 58 +++ src/{lib.c => TA-Lib.c} | 135 ++++--- src/TA-Lib.h | 336 ++++++++++++++++ src/api.h | 274 ------------- src/attributes.c | 72 ++-- src/attributes.h | 14 +- src/container.h | 132 ------- src/{dataframe.c => data-frame.c} | 77 ++-- src/init.c | 372 +++++------------ src/lib.h | 29 -- src/na.h | 187 --------- src/names.c | 64 ++- src/names.h | 36 +- src/normalize.h | 84 +--- src/preprocessor.h | 64 +++ src/shift.c | 112 ++++++ src/shift.h | 121 +----- src/ta_ACCBANDS.c | 172 -------- src/ta_AD.c | 165 -------- src/ta_ADOSC.c | 181 --------- src/ta_ADX.c | 166 -------- src/ta_ADXR.c | 166 -------- src/ta_APO.c | 172 -------- src/ta_AROON.c | 163 -------- src/ta_AROONOSC.c | 160 -------- src/ta_ATR.c | 166 -------- src/ta_AVGPRICE.c | 165 -------- src/ta_BBANDS.c | 186 --------- src/ta_BETA.c | 160 -------- src/ta_BOP.c | 165 -------- src/ta_CCI.c | 166 -------- src/ta_CDL2CROWS.c | 179 --------- src/ta_CDL3BLACKCROWS.c | 179 --------- src/ta_CDL3INSIDE.c | 179 --------- src/ta_CDL3LINESTRIKE.c | 179 --------- src/ta_CDL3OUTSIDE.c | 179 --------- src/ta_CDL3STARSINSOUTH.c | 179 --------- src/ta_CDL3WHITESOLDIERS.c | 179 --------- src/ta_CDLABANDONEDBABY.c | 187 --------- src/ta_CDLADVANCEBLOCK.c | 179 --------- src/ta_CDLBELTHOLD.c | 179 --------- src/ta_CDLBREAKAWAY.c | 179 --------- src/ta_CDLCLOSINGMARUBOZU.c | 179 --------- src/ta_CDLCONCEALBABYSWALL.c | 179 --------- src/ta_CDLCOUNTERATTACK.c | 179 --------- src/ta_CDLDARKCLOUDCOVER.c | 187 --------- src/ta_CDLDOJI.c | 179 --------- src/ta_CDLDOJISTAR.c | 179 --------- src/ta_CDLDRAGONFLYDOJI.c | 179 --------- src/ta_CDLENGULFING.c | 179 --------- src/ta_CDLEVENINGDOJISTAR.c | 187 --------- src/ta_CDLEVENINGSTAR.c | 187 --------- src/ta_CDLGAPSIDESIDEWHITE.c | 179 --------- src/ta_CDLGRAVESTONEDOJI.c | 179 --------- src/ta_CDLHAMMER.c | 179 --------- src/ta_CDLHANGINGMAN.c | 179 --------- src/ta_CDLHARAMI.c | 179 --------- src/ta_CDLHARAMICROSS.c | 179 --------- src/ta_CDLHIGHWAVE.c | 179 --------- src/ta_CDLHIKKAKE.c | 179 --------- src/ta_CDLHIKKAKEMOD.c | 179 --------- src/ta_CDLHOMINGPIGEON.c | 179 --------- src/ta_CDLIDENTICAL3CROWS.c | 179 --------- src/ta_CDLINNECK.c | 179 --------- src/ta_CDLINVERTEDHAMMER.c | 179 --------- src/ta_CDLKICKING.c | 179 --------- src/ta_CDLKICKINGBYLENGTH.c | 179 --------- src/ta_CDLLADDERBOTTOM.c | 179 --------- src/ta_CDLLONGLEGGEDDOJI.c | 179 --------- src/ta_CDLLONGLINE.c | 179 --------- src/ta_CDLMARUBOZU.c | 179 --------- src/ta_CDLMATCHINGLOW.c | 179 --------- src/ta_CDLMATHOLD.c | 187 --------- src/ta_CDLMORNINGDOJISTAR.c | 187 --------- src/ta_CDLMORNINGSTAR.c | 187 --------- src/ta_CDLONNECK.c | 179 --------- src/ta_CDLPIERCING.c | 179 --------- src/ta_CDLRICKSHAWMAN.c | 179 --------- src/ta_CDLRISEFALL3METHODS.c | 179 --------- src/ta_CDLSEPARATINGLINES.c | 179 --------- src/ta_CDLSHOOTINGSTAR.c | 179 --------- src/ta_CDLSHORTLINE.c | 179 --------- src/ta_CDLSPINNINGTOP.c | 179 --------- src/ta_CDLSTALLEDPATTERN.c | 179 --------- src/ta_CDLSTICKSANDWICH.c | 179 --------- src/ta_CDLTAKURI.c | 179 --------- src/ta_CDLTASUKIGAP.c | 179 --------- src/ta_CDLTHRUSTING.c | 179 --------- src/ta_CDLTRISTAR.c | 179 --------- src/ta_CDLUNIQUE3RIVER.c | 179 --------- src/ta_CDLUPSIDEGAP2CROWS.c | 179 --------- src/ta_CDLXSIDEGAP3METHODS.c | 179 --------- src/ta_CMO.c | 154 -------- src/ta_CORREL.c | 160 -------- src/ta_DEMA.c | 154 -------- src/ta_DX.c | 166 -------- src/ta_EMA.c | 154 -------- src/ta_HT_DCPERIOD.c | 141 ------- src/ta_HT_DCPHASE.c | 141 ------- src/ta_HT_PHASOR.c | 149 ------- src/ta_HT_SINE.c | 143 ------- src/ta_HT_TRENDLINE.c | 141 ------- src/ta_HT_TRENDMODE.c | 141 ------- src/ta_IMI.c | 160 -------- src/ta_KAMA.c | 154 -------- src/ta_MACD.c | 178 --------- src/ta_MACDEXT.c | 202 ---------- src/ta_MACDFIX.c | 160 -------- src/ta_MAMA.c | 165 -------- src/ta_MAX.c | 154 -------- src/ta_MEDPRICE.c | 146 ------- src/ta_MFI.c | 173 -------- src/ta_MIDPRICE.c | 160 -------- src/ta_MIN.c | 154 -------- src/ta_MINUS_DI.c | 166 -------- src/ta_MINUS_DM.c | 160 -------- src/ta_MOM.c | 154 -------- src/ta_NATR.c | 166 -------- src/ta_OBV.c | 146 ------- src/ta_PLUS_DI.c | 166 -------- src/ta_PLUS_DM.c | 160 -------- src/ta_PPO.c | 172 -------- src/ta_ROC.c | 154 -------- src/ta_ROCR.c | 154 -------- src/ta_RSI.c | 154 -------- src/ta_SAR.c | 168 -------- src/ta_SAREXT.c | 226 ----------- src/ta_SMA.c | 154 -------- src/ta_STDDEV.c | 162 -------- src/ta_STOCH.c | 203 ---------- src/ta_STOCHF.c | 187 --------- src/ta_STOCHRSI.c | 183 --------- src/ta_SUM.c | 154 -------- src/ta_T3.c | 162 -------- src/ta_TEMA.c | 154 -------- src/ta_TRANGE.c | 158 -------- src/ta_TRIMA.c | 154 -------- src/ta_TRIX.c | 154 -------- src/ta_TYPPRICE.c | 158 -------- src/ta_ULTOSC.c | 184 --------- src/ta_VAR.c | 160 -------- src/ta_VOLUME.c | 170 -------- src/ta_WCLPRICE.c | 158 -------- src/ta_WILLR.c | 166 -------- src/ta_WMA.c | 154 -------- src/utils.c | 27 ++ src/utils.h | 22 ++ src/volume.c | 197 +++++++++ src/wrapper.h | 256 ++++++++++++ 156 files changed, 1593 insertions(+), 23984 deletions(-) delete mode 100755 codegen/generate_API.sh delete mode 100755 codegen/generate_FFI.sh delete mode 100755 codegen/generate_indicator_core.sh delete mode 100644 codegen/templates/indicator_template.c.in delete mode 100644 src/MAType.h create mode 100644 src/NA-handling.c create mode 100644 src/NA-handling.h rename src/{lib.c => TA-Lib.c} (67%) create mode 100644 src/TA-Lib.h delete mode 100644 src/api.h delete mode 100644 src/container.h rename src/{dataframe.c => data-frame.c} (50%) delete mode 100644 src/lib.h delete mode 100644 src/na.h create mode 100644 src/preprocessor.h create mode 100644 src/shift.c delete mode 100644 src/ta_ACCBANDS.c delete mode 100644 src/ta_AD.c delete mode 100644 src/ta_ADOSC.c delete mode 100644 src/ta_ADX.c delete mode 100644 src/ta_ADXR.c delete mode 100644 src/ta_APO.c delete mode 100644 src/ta_AROON.c delete mode 100644 src/ta_AROONOSC.c delete mode 100644 src/ta_ATR.c delete mode 100644 src/ta_AVGPRICE.c delete mode 100644 src/ta_BBANDS.c delete mode 100644 src/ta_BETA.c delete mode 100644 src/ta_BOP.c delete mode 100644 src/ta_CCI.c delete mode 100644 src/ta_CDL2CROWS.c delete mode 100644 src/ta_CDL3BLACKCROWS.c delete mode 100644 src/ta_CDL3INSIDE.c delete mode 100644 src/ta_CDL3LINESTRIKE.c delete mode 100644 src/ta_CDL3OUTSIDE.c delete mode 100644 src/ta_CDL3STARSINSOUTH.c delete mode 100644 src/ta_CDL3WHITESOLDIERS.c delete mode 100644 src/ta_CDLABANDONEDBABY.c delete mode 100644 src/ta_CDLADVANCEBLOCK.c delete mode 100644 src/ta_CDLBELTHOLD.c delete mode 100644 src/ta_CDLBREAKAWAY.c delete mode 100644 src/ta_CDLCLOSINGMARUBOZU.c delete mode 100644 src/ta_CDLCONCEALBABYSWALL.c delete mode 100644 src/ta_CDLCOUNTERATTACK.c delete mode 100644 src/ta_CDLDARKCLOUDCOVER.c delete mode 100644 src/ta_CDLDOJI.c delete mode 100644 src/ta_CDLDOJISTAR.c delete mode 100644 src/ta_CDLDRAGONFLYDOJI.c delete mode 100644 src/ta_CDLENGULFING.c delete mode 100644 src/ta_CDLEVENINGDOJISTAR.c delete mode 100644 src/ta_CDLEVENINGSTAR.c delete mode 100644 src/ta_CDLGAPSIDESIDEWHITE.c delete mode 100644 src/ta_CDLGRAVESTONEDOJI.c delete mode 100644 src/ta_CDLHAMMER.c delete mode 100644 src/ta_CDLHANGINGMAN.c delete mode 100644 src/ta_CDLHARAMI.c delete mode 100644 src/ta_CDLHARAMICROSS.c delete mode 100644 src/ta_CDLHIGHWAVE.c delete mode 100644 src/ta_CDLHIKKAKE.c delete mode 100644 src/ta_CDLHIKKAKEMOD.c delete mode 100644 src/ta_CDLHOMINGPIGEON.c delete mode 100644 src/ta_CDLIDENTICAL3CROWS.c delete mode 100644 src/ta_CDLINNECK.c delete mode 100644 src/ta_CDLINVERTEDHAMMER.c delete mode 100644 src/ta_CDLKICKING.c delete mode 100644 src/ta_CDLKICKINGBYLENGTH.c delete mode 100644 src/ta_CDLLADDERBOTTOM.c delete mode 100644 src/ta_CDLLONGLEGGEDDOJI.c delete mode 100644 src/ta_CDLLONGLINE.c delete mode 100644 src/ta_CDLMARUBOZU.c delete mode 100644 src/ta_CDLMATCHINGLOW.c delete mode 100644 src/ta_CDLMATHOLD.c delete mode 100644 src/ta_CDLMORNINGDOJISTAR.c delete mode 100644 src/ta_CDLMORNINGSTAR.c delete mode 100644 src/ta_CDLONNECK.c delete mode 100644 src/ta_CDLPIERCING.c delete mode 100644 src/ta_CDLRICKSHAWMAN.c delete mode 100644 src/ta_CDLRISEFALL3METHODS.c delete mode 100644 src/ta_CDLSEPARATINGLINES.c delete mode 100644 src/ta_CDLSHOOTINGSTAR.c delete mode 100644 src/ta_CDLSHORTLINE.c delete mode 100644 src/ta_CDLSPINNINGTOP.c delete mode 100644 src/ta_CDLSTALLEDPATTERN.c delete mode 100644 src/ta_CDLSTICKSANDWICH.c delete mode 100644 src/ta_CDLTAKURI.c delete mode 100644 src/ta_CDLTASUKIGAP.c delete mode 100644 src/ta_CDLTHRUSTING.c delete mode 100644 src/ta_CDLTRISTAR.c delete mode 100644 src/ta_CDLUNIQUE3RIVER.c delete mode 100644 src/ta_CDLUPSIDEGAP2CROWS.c delete mode 100644 src/ta_CDLXSIDEGAP3METHODS.c delete mode 100644 src/ta_CMO.c delete mode 100644 src/ta_CORREL.c delete mode 100644 src/ta_DEMA.c delete mode 100644 src/ta_DX.c delete mode 100644 src/ta_EMA.c delete mode 100644 src/ta_HT_DCPERIOD.c delete mode 100644 src/ta_HT_DCPHASE.c delete mode 100644 src/ta_HT_PHASOR.c delete mode 100644 src/ta_HT_SINE.c delete mode 100644 src/ta_HT_TRENDLINE.c delete mode 100644 src/ta_HT_TRENDMODE.c delete mode 100644 src/ta_IMI.c delete mode 100644 src/ta_KAMA.c delete mode 100644 src/ta_MACD.c delete mode 100644 src/ta_MACDEXT.c delete mode 100644 src/ta_MACDFIX.c delete mode 100644 src/ta_MAMA.c delete mode 100644 src/ta_MAX.c delete mode 100644 src/ta_MEDPRICE.c delete mode 100644 src/ta_MFI.c delete mode 100644 src/ta_MIDPRICE.c delete mode 100644 src/ta_MIN.c delete mode 100644 src/ta_MINUS_DI.c delete mode 100644 src/ta_MINUS_DM.c delete mode 100644 src/ta_MOM.c delete mode 100644 src/ta_NATR.c delete mode 100644 src/ta_OBV.c delete mode 100644 src/ta_PLUS_DI.c delete mode 100644 src/ta_PLUS_DM.c delete mode 100644 src/ta_PPO.c delete mode 100644 src/ta_ROC.c delete mode 100644 src/ta_ROCR.c delete mode 100644 src/ta_RSI.c delete mode 100644 src/ta_SAR.c delete mode 100644 src/ta_SAREXT.c delete mode 100644 src/ta_SMA.c delete mode 100644 src/ta_STDDEV.c delete mode 100644 src/ta_STOCH.c delete mode 100644 src/ta_STOCHF.c delete mode 100644 src/ta_STOCHRSI.c delete mode 100644 src/ta_SUM.c delete mode 100644 src/ta_T3.c delete mode 100644 src/ta_TEMA.c delete mode 100644 src/ta_TRANGE.c delete mode 100644 src/ta_TRIMA.c delete mode 100644 src/ta_TRIX.c delete mode 100644 src/ta_TYPPRICE.c delete mode 100644 src/ta_ULTOSC.c delete mode 100644 src/ta_VAR.c delete mode 100644 src/ta_VOLUME.c delete mode 100644 src/ta_WCLPRICE.c delete mode 100644 src/ta_WILLR.c delete mode 100644 src/ta_WMA.c create mode 100644 src/utils.c create mode 100644 src/utils.h create mode 100644 src/volume.c create mode 100644 src/wrapper.h diff --git a/codegen/gen_code/generate.R b/codegen/gen_code/generate.R index 311e2be0a..241fb104a 100644 --- a/codegen/gen_code/generate.R +++ b/codegen/gen_code/generate.R @@ -17,57 +17,37 @@ source("codegen/gen_code/indicators.R") ## 3) generate R wrapper generate_R <- function(x) { impl_generate_indicator( - title = x$title, - family = x$family, - fun = x$fun, - ta_fun = x$alias, - formula = x$formula, - args = x$signature, - plotly = x$plotly %||% 1L, - subchart = x$subchart %||% 1L, - agnostic = x$agnostic, + title = x$title, + family = x$family, + fun = x$fun, + ta_fun = x$alias, + formula = x$formula, + args = x$signature, + plotly = x$plotly %||% 1L, + subchart = x$subchart %||% 1L, + agnostic = x$agnostic, candlestick = x$candlestick %||% 0, - maType = x$maType %||% -1, - rolling = x$rolling %||% 0, + maType = x$maType %||% -1, + rolling = x$rolling %||% 0, univariate = x$univariate, n_default = x$n_default %||% 30L ) } ## 4) generate C wrapper -generate_C <- function(x) { - type <- x$c_generator %||% "standard" - - if (type == "skip") { - return(invisible(NULL)) - } - - ## Candlestick patterns share generate_indicator_core.sh with every other - ## indicator; the CANDLESTICK flag adds the `flag` SEXP argument and the - ## [-200, 200] -> real output normalization on top of the standard wrapper. - env <- if (type == "candlestick") "CANDLESTICK=1" else character() - - system2( - command = "bash", - args = c( - "codegen/generate_indicator_core.sh", - paste0(x$alias, " > src/ta_", x$alias, ".c") - ), - env = env - ) -} +generate_C <- function(x) {} ## 5) generate unit test generate_test <- function(x) { test_plotly <- x$test_plotly %||% (x$plotly %||% 1) impl_generate_test( - fun = x$fun, - ta_fun = x$alias, + fun = x$fun, + ta_fun = x$alias, formula = x$formula, - plotly = test_plotly, + plotly = test_plotly, rolling = x$rolling %||% 0, - args = x$signature + args = x$signature ) } diff --git a/codegen/generate_API.sh b/codegen/generate_API.sh deleted file mode 100755 index 7fa6829ca..000000000 --- a/codegen/generate_API.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -IFS=$'\n\t' - -usage() { - cat <&2 -Usage: ${0##*/} [SRC_DIR] [OUT_FILE] - SRC_DIR Directory with .c sources (default: src) - OUT_FILE Header file to generate (default: api.h) -EOF - exit 1 -} - -if [[ $# -gt 2 ]]; then - usage -fi - -SRC_DIR="${1:-src}" -OUT_FILE="${2:-api.h}" - -print_header() { - cat <<'EOF' -// Generated from codegen/generate_API.sh -#ifndef _API_H_ -#define _API_H_ - -#include - -// clang-format off -EOF -} - -extract_signatures() { - awk ' - # start of an SEXP function (skip static — those are TU-local helpers, - # not entry points, and declaring them in a shared header triggers - # -Wunused-function for every TU that does not define them) - /^[[:space:]]*SEXP[[:space:]]+/ { - sig = $0 - - # keep reading until we hit "{" or ";" - while (sig !~ /\{/ && sig !~ /;/) { - if (getline <= 0) break - # skip pure formatter lines while collecting - if ($0 ~ /^[[:space:]]*\/\/[[:space:]]*clang-format[[:space:]]+(on|off)/) - continue - sig = sig " " $0 - } - - # if the formatter marker still got attached at the end of sig, drop it - sub(/[[:space:]]*\/\/[[:space:]]*clang-format[[:space:]]+(on|off)[[:space:]]*$/, "", sig) - - # only handle real definitions (we saw "{") - if (sig ~ /\{/) { - left = gsub(/\(/, "&", sig) - right = gsub(/\)/, "&", sig) - if (left == right) { - sub(/\{.*$/, "", sig) - - gsub(/[[:space:]]+/, " ", sig) - sub(/^[[:space:]]+/, "", sig) - sub(/[[:space:]]+$/, "", sig) - gsub(/\( /, "(", sig) - gsub(/ \)/, ")", sig) - - printf("%s;\n", sig) - } - } - } - ' "${SRC_DIR}"/*.c | sort -u -} - - -print_footer() { - cat <<'EOF' -// clang-format on - -#endif //_API_H -EOF -} - -# === Main driver === -main() { - echo "Generating ${OUT_FILE} from C sources in ${SRC_DIR}/..." - print_header > "${OUT_FILE}" - extract_signatures >> "${OUT_FILE}" - print_footer >> "${OUT_FILE}" - echo "Done: ${OUT_FILE}" -} - -main diff --git a/codegen/generate_FFI.sh b/codegen/generate_FFI.sh deleted file mode 100755 index 3bb032c0a..000000000 --- a/codegen/generate_FFI.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -IFS=$'\n\t' - -if [[ $# -gt 2 ]]; then - usage -fi - -API_HEADER="${1:-api.h}" -OUT_FILE="${2:-init.c}" - -print_header() { - cat <<'EOF' -// Generated from codegen/generate_FFI.sh -#include -#include -#include -#include - -#include "api.h" - -// clang-format off -#define CALLDEF(name, n) {#name, (DL_FUNC) &name, n} -// clang-format on - -static const R_CallMethodDef CallEntries[] = { -EOF -} - -generate_entries() { - awk ' - # Match prototype lines - /^SEXP[[:space:]]+/ { - sig = $0 - sub(/^SEXP[[:space:]]+/, "", sig) - sub(/;[[:space:]]*$/, "", sig) - - # split name and argument list - split(sig, parts, /\(/) - name = parts[1] - args = parts[2] - sub(/\)$/, "", args) - - # count arguments: commas + 1 (or 0 if empty or "void") - if (args ~ /^[[:space:]]*$/ || args ~ /^[[:space:]]*void[[:space:]]*$/) { - n = 0 - } else { - tmp = args - n = gsub(/,/, ",", tmp) + 1 - } - printf(" CALLDEF(%s, %d),\n", name, n) - } - ' "$API_HEADER" - echo " {NULL, NULL, 0}" -} - -print_footer() { - cat <<'EOF' -}; -EOF -} - -print_init() { - cat < "$OUT_FILE" - generate_entries >> "$OUT_FILE" - print_footer >> "$OUT_FILE" - print_init >> "$OUT_FILE" - echo "Done: $OUT_FILE" -} - -main \ No newline at end of file diff --git a/codegen/generate_indicator_core.sh b/codegen/generate_indicator_core.sh deleted file mode 100755 index 011e26d61..000000000 --- a/codegen/generate_indicator_core.sh +++ /dev/null @@ -1,461 +0,0 @@ -#!/usr/bin/env bash -# generate_indicator_core.sh -# usage: -# ./generate_indicator_core.sh MACD > impl_ta_MACD.c -# TEMPLATE=indicator_template.c.in ./generate_indicator_core.sh ACCBANDS -set -euo pipefail - -if [ "$#" -ne 1 ]; then - echo "usage: $0 " >&2 - exit 1 -fi -NAME="$1" - -# 1) find header (new layout first) -if [ -f "src/ta-lib/include/ta-lib/ta_func.h" ]; then - TA_H="src/ta-lib/include/ta-lib/ta_func.h" -elif [ -f "src/ta-lib/include/ta_func.h" ]; then - TA_H="src/ta-lib/include/ta_func.h" -else - echo "error: ta_func.h not found" >&2 - exit 1 -fi - -# 2) exact main prototype: must be TA_( and must NOT contain TA__ -proto_line=$(awk -v name="$NAME" ' - { gsub(/\/\*[^*]*\*\//, "", $0) } - index($0, "TA_" name "(") { - if (index($0, "TA_" name "_") != 0) next; - line = $0 - while (line !~ /\);/) { - getline nxt - gsub(/\/\*[^*]*\*\//, "", nxt) - line = line " " nxt - } - gsub(/[\r\n]+/, " ", line) - print line - exit - } -' "$TA_H") -[ -n "$proto_line" ] || { echo "error: TA_${NAME}(...) not found" >&2; exit 1; } - -param_list=${proto_line#*(} -param_list=${param_list%);} - -# 3) exact lookback prototype -lb_line=$(awk -v name="$NAME" ' - { gsub(/\/\*[^*]*\*\//, "", $0) } - index($0, "TA_" name "_Lookback(") { - line = $0 - while (line !~ /\);/) { - getline nxt - gsub(/\/\*[^*]*\*\//, "", nxt) - line = line " " nxt - } - gsub(/[\r\n]+/, " ", line) - print line - exit - } -' "$TA_H") -[ -n "$lb_line" ] || { echo "error: TA_${NAME}_Lookback(...) not found" >&2; exit 1; } - -lb_params=${lb_line#*(} -lb_params=${lb_params%);} - -# 4) classify params -declare -a in_arrays_type=() -declare -a in_arrays_name=() -declare -a in_scalars_type=() -declare -a in_scalars_name=() -declare -a out_arrays_type=() -declare -a out_arrays_name=() - -IFS=',' read -r -a params <<<"$param_list" -for raw in "${params[@]}"; do - p=$(echo "$raw" | sed 's:/\*[^*]*\*/::g; s/^[[:space:]]*//; s/[[:space:]]*$//') - - [[ "$p" =~ ^int[[:space:]]+startIdx$ ]] && continue - [[ "$p" =~ ^int[[:space:]]+endIdx$ ]] && continue - [[ "$p" =~ ^int[[:space:]]+\*outBegIdx$ ]] && continue - [[ "$p" =~ ^int[[:space:]]+\*outNBElement$ ]] && continue - - if [[ "$p" =~ ^double[[:space:]]+out([A-Za-z0-9_]+)\[\]$ ]]; then - out_arrays_type+=("double") - out_arrays_name+=("${BASH_REMATCH[1]}") - continue - fi - if [[ "$p" =~ ^int[[:space:]]+out([A-Za-z0-9_]+)\[\]$ ]]; then - out_arrays_type+=("int") - out_arrays_name+=("${BASH_REMATCH[1]}") - continue - fi - - if [[ "$p" =~ ^const[[:space:]]+double[[:space:]]+([A-Za-z0-9_]+)\[\]$ ]]; then - in_arrays_type+=("double") - in_arrays_name+=("${BASH_REMATCH[1]}") - continue - fi - if [[ "$p" =~ ^const[[:space:]]+int[[:space:]]+([A-Za-z0-9_]+)\[\]$ ]]; then - in_arrays_type+=("int") - in_arrays_name+=("${BASH_REMATCH[1]}") - continue - fi - - if [[ "$p" =~ ^TA_MAType[[:space:]]+([A-Za-z0-9_]+)$ ]]; then - in_scalars_type+=("MAType") - in_scalars_name+=("${BASH_REMATCH[1]}") - continue - fi - if [[ "$p" =~ ^double[[:space:]]+([A-Za-z0-9_]+)$ ]]; then - in_scalars_type+=("double") - in_scalars_name+=("${BASH_REMATCH[1]}") - continue - fi - if [[ "$p" =~ ^int[[:space:]]+([A-Za-z0-9_]+)$ ]]; then - in_scalars_type+=("int") - in_scalars_name+=("${BASH_REMATCH[1]}") - continue - fi -done - -[ "${#in_arrays_name[@]}" -gt 0 ] || { echo "error: no array inputs" >&2; exit 1; } -[ "${#out_arrays_name[@]}" -gt 0 ] || { echo "error: no array outputs" >&2; exit 1; } - -## 5) R signature -## -## // clang-format off -## SEXP impl_ta_${NAME}($R_SIGNATURE) -## // clang-format on -## -## example output: -## -## // clang-format off -## SEXP impl_ta_AROONOSC( -## SEXP inHigh, -## SEXP inLow, -## SEXP optInTimePeriod -## ) -## // clang-format on -## -R_SIGNATURE=$'\n' -for i in "${!in_arrays_name[@]}"; do - R_SIGNATURE+=$'\tSEXP '"${in_arrays_name[$i]}"$',\n' -done -for i in "${!in_scalars_name[@]}"; do - R_SIGNATURE+=$'\tSEXP '"${in_scalars_name[$i]}"$',\n' -done -R_SIGNATURE=${R_SIGNATURE%,$'\n'} - -## 6) PARAM_DOC -## -## // Parameters -## // $PARAM_DOC -## // Returns -## -## example output: -## -## // Parameters -## // double inHigh -## // double inLow -## // integer optInTimePeriod -## // -## -PARAM_DOC=$'' -for i in "${!in_arrays_name[@]}"; do - n=${in_arrays_name[$i]} - t=${in_arrays_type[$i]} - if [ "$t" = "double" ]; then - PARAM_DOC+=$'\t\tdouble '"$n"$'\n// ' - else - PARAM_DOC+=$'\t\tinteger '"$n"$'\n' - fi -done -for i in "${!in_scalars_name[@]}"; do - n=${in_scalars_name[$i]} - t=${in_scalars_type[$i]} - case "$t" in - int) PARAM_DOC+=$'\t\tinteger '"$n"$'\n//' ;; - double) PARAM_DOC+=$'\t\tdouble '"$n"$'\n//' ;; - MAType) PARAM_DOC+=$'\t\tinteger '"$n"$' (MAType)\n//' ;; - esac -done - -## 7) VALUES -## -## // pointers to input -## $VALUES -## -## -## 7.1) length of the input array -## -## example output: -## -## // get length of 'inHigh' (assumes equal length across input) -## const int n = LENGTH(inHigh); -VALUES=$'' -first_arr_name=${in_arrays_name[0]} -first_arr_type=${in_arrays_type[0]} -VALUES+=$'// get length of \''"${first_arr_name}"$'\' (assumes equal length across input)\n' -VALUES+=$'int n = LENGTH('"${first_arr_name}"$');\n\n' - -## 7.2) extract the input array(s) -## -## example output: -## -## // pointers to input arrays -## const double *restrict inHigh_ptr = REAL(inHigh); -## const double *restrict inLow_ptr = REAL(inLow); -if [ "$first_arr_type" = "double" ]; then - VALUES+=$'// pointers to input arrays\n' - VALUES+=$'const double *'"${first_arr_name}"$'_ptr = REAL('"${first_arr_name}"$');\n' -else - VALUES+=$'const int *'"${first_arr_name}"$'_ptr = INTEGER('"${first_arr_name}"$');\n' -fi -for i in "${!in_arrays_name[@]}"; do - [ "$i" -eq 0 ] && continue - n=${in_arrays_name[$i]} - t=${in_arrays_type[$i]} - if [ "$t" = "double" ]; then - VALUES+=$'const double *'"$n"$'_ptr = REAL('"$n"$');\n' - else - VALUES+=$'const int *'"$n"$'_ptr = INTEGER('"$n"$');\n' - fi -done - -## 7.3) extract the input argumetns(s) -## -## example output: -## -## // extract input values -## const int optInTimePeriod_ptr = INTEGER(optInTimePeriod)[0]; -if [ "${#in_scalars_name[@]}" -gt 0 ]; then - VALUES+=$'\n// extract input values\n' -fi -for i in "${!in_scalars_name[@]}"; do - n=${in_scalars_name[$i]} - t=${in_scalars_type[$i]} - case "$t" in - int) VALUES+=$'const int '"$n"$'_value = INTEGER('"$n"$')[0];\n' ;; - double) VALUES+=$'const double '"$n"$'_value = REAL('"$n"$')[0];\n' ;; - MAType) VALUES+=$'const TA_MAType '"$n"$'_value = as_MAType('"$n"$');\n' ;; - esac -done - -## 8) Lookback args -## -## // calculate look back and exit -## // the function function early if -## // there is a mismatch -## const int lookback = TA_${NAME}_Lookback( -## $LOOKBACK_ARGS -## ); -## -LOOKBACK_ARGS="" -LOOKBACK_VALUES="" -IFS=',' read -r -a lbps <<<"$lb_params" -for raw in "${lbps[@]}"; do - # strip /* ... */ and trim - p=$(echo "$raw" | sed 's:/\*[^*]*\*/::g; s/^[[:space:]]*//; s/[[:space:]]*$//') - [ -z "$p" ] && continue - - # split into words - read -r -a toks <<<"$p" - - name="" - for ((idx=${#toks[@]}-1; idx>=0; idx--)); do - tok=${toks[$idx]} - tok=${tok%,} - tok=${tok%);} - tok=${tok%)} - tok=${tok%;} - [ -z "$tok" ] && continue - if [ "$tok" = "void" ]; then - name="" - break - fi - name="$tok" - break - done - [ -z "$name" ] && continue - - # declare only the scalar(s) the lookback consumes. The lookback - # prototype is a subset of the main signature (e.g. TA_BBANDS_Lookback - # takes period + maType, not the deviations), so extracting exactly - # these keeps impl_ta__lookback free of unused-variable warnings. - if [[ "$p" == *TA_MAType* ]]; then - LOOKBACK_VALUES+=$'const TA_MAType '"${name}"$'_value = as_MAType('"${name}"$');\n' - elif [[ "$p" == *double* ]]; then - LOOKBACK_VALUES+=$'const double '"${name}"$'_value = REAL('"${name}"$')[0];\n' - else - LOOKBACK_VALUES+=$'const int '"${name}"$'_value = INTEGER('"${name}"$')[0];\n' - fi - - LOOKBACK_ARGS+="${name}_value, " -done - -LOOKBACK_ARGS=${LOOKBACK_ARGS%, } - -if [ -n "$LOOKBACK_ARGS" ]; then - LOOKBACK_ARGS=$''"$LOOKBACK_ARGS"$'\n' -fi - -## 9) Value pointers -## -## TA_RetCode return_code = TA_${NAME}( -## 0, -## n - 1, -## $VALUE_POINTERS, -## &start_idx, -## &end_idx, -## $OUTPUT_POINTERS -## ); -## -## NOTE: It doesnt quite work as expected -## but clang-format handles the rest -VALUE_POINTERS=$'' -for i in "${!in_arrays_name[@]}"; do - VALUE_POINTERS+=$'\t\t'"${in_arrays_name[$i]}_ptr"$',' -done -for i in "${!in_scalars_name[@]}"; do - VALUE_POINTERS+=$'\t\t'"${in_scalars_name[$i]}_value"$',' -done -VALUE_POINTERS=${VALUE_POINTERS%$''} - -## 10) Outputs -## -## 10.1) constructs all output -## values -OUT_COLS=${#out_arrays_name[@]} -first_out_type=${out_arrays_type[0]} - -OUTPUT_COLS=$'' -OUTPUT_POINTERS=$'' -SHIFT_ARRAYS=$'' -COLNAMES=() - -for i in "${!out_arrays_name[@]}"; do - on=${out_arrays_name[$i]} - cbase=${on#out} - clower=$(echo "$cbase" | tr '[:upper:]' '[:lower:]') - if [ "$i" -eq 0 ]; then - OUTPUT_COLS+=$''"${first_out_type}"$' *'"${clower}"$' = output_ptr;\n' - else - OUTPUT_COLS+=$''"${first_out_type}"$' *'"${clower}"$' = output_ptr + '"${i}"$' * n;\n' - fi - OUTPUT_POINTERS+=$''"${clower}"$',\n' - SHIFT_ARRAYS+=$'shift_array('"${clower}"$', n, start_idx);\n' - - cname=${on#out} - if [[ "$cname" == Real* ]]; then - cname=${cname#Real} - fi - COLNAMES+=("$cname") -done -OUTPUT_POINTERS=${OUTPUT_POINTERS%,$'\n'} - -## 10.2) column names -## -## // set the column names of the output -## // see names.h for more details -## $SET_COLUMN_NAMES -## -## example output: -## -## // set the column names of the output -## // see names.h for more details -## set_colnames(output, "AROONOSC"); -if [ "$OUT_COLS" -eq 1 ]; then - SET_COLUMN_NAMES="set_colnames(output, \"$NAME\");" - RETURN_COLS="\"$NAME\"" -else - cn_join="" - for c in "${COLNAMES[@]}"; do - cn_join+="\"$c\", " - done - cn_join=${cn_join%, } - SET_COLUMN_NAMES="set_colnames(output, $cn_join);" - RETURN_COLS="$cn_join" -fi - -## 10.3) output type -OUTPUT_TYPE=${out_arrays_type[0]} - -## 11) NA handling code generation -## -## 11.1) build_na_mask call with all double input arrays -NA_MASK_PTRS="" -NA_N_ARRAYS=0 -for i in "${!in_arrays_name[@]}"; do - t=${in_arrays_type[$i]} - if [ "$t" = "double" ]; then - NA_MASK_PTRS+="${in_arrays_name[$i]}_ptr, " - ((NA_N_ARRAYS++)) || true - fi -done -NA_MASK_PTRS=${NA_MASK_PTRS%, } - -NA_MASK_BUILD=$'' -NA_MASK_BUILD+="const double *na_arrays[] = {${NA_MASK_PTRS}};"$'\n' -NA_MASK_BUILD+=" n = build_na_mask(na_mask, n, ${NA_N_ARRAYS}, na_arrays);" - -## 11.2) compact_arrays call + pointer reassignment -NA_COMPACT=$'' -NA_COMPACT+="compact_arrays(na_arrays, ${NA_N_ARRAYS}, na_mask, n_original, n);"$'\n' -ci=0 -for i in "${!in_arrays_name[@]}"; do - t=${in_arrays_type[$i]} - nm=${in_arrays_name[$i]} - if [ "$t" = "double" ]; then - NA_COMPACT+=" ${nm}_ptr = na_arrays[${ci}];"$'\n' - ((ci++)) || true - fi -done - -## 11.5) candlestick mode -## -## TA-Lib candlestick patterns (TA_CDL*) fit the standard machinery — four -## double inputs, an INTSXP output, an optional optInPenetration scalar — but -## additionally take a `flag` SEXP and, when it is set, normalize the -## [-200, 200] integer output to real values divided by 100. These extras are -## gated on the CANDLESTICK env var so one template serves both families. -CANDLESTICK="${CANDLESTICK:-0}" -if [ "$CANDLESTICK" = "1" ]; then - FLAG_ARG=$',\n\tSEXP flag' - NORMALIZE_INCLUDE=$'#include "normalize.h"\n' - NORMALIZE_BLOCK=$'// ta_'"${NAME}"$' returns values in the range [-200, 200]\n' - NORMALIZE_BLOCK+=$'// if flag is TRUE the output is converted from INTSXP\n' - NORMALIZE_BLOCK+=$'// to REALSXP and divided by 100, preserving pattern strength\n' - NORMALIZE_BLOCK+=$'// see normalize.h for more details\n' - NORMALIZE_BLOCK+=$'if (LOGICAL_ELT(flag, 0)) {\n' - NORMALIZE_BLOCK+=$'output = normalize_int_to_real(output, 100.0, (na_mask != NULL), &protection_count);\n' - NORMALIZE_BLOCK+=$'}' -else - FLAG_ARG="" - NORMALIZE_INCLUDE="" - NORMALIZE_BLOCK="" -fi - -# 12) export and run envsubst -export NAME -export R_SIGNATURE -export PARAM_DOC -export VALUES -export LOOKBACK_VALUES -export LOOKBACK_ARGS -export FLAG_ARG -export NORMALIZE_INCLUDE -export NORMALIZE_BLOCK -export OUT_COLS -export OUTPUT_COLS -export VALUE_POINTERS -export END_IDX="&end_idx," -export OUTPUT_POINTERS -export SHIFT_ARRAYS -export SET_COLUMN_NAMES -export RETURN_COLS -export OUTPUT_TYPE -export NA_MASK_BUILD -export NA_COMPACT - -TEMPLATE_FILE=${TEMPLATE:-codegen/templates/indicator_template.c.in} -envsubst < "$TEMPLATE_FILE" diff --git a/codegen/templates/indicator_template.c.in b/codegen/templates/indicator_template.c.in deleted file mode 100644 index 49df24b9e..000000000 --- a/codegen/templates/indicator_template.c.in +++ /dev/null @@ -1,142 +0,0 @@ -// interface to ta_${NAME}.c -// -// Parameters -// $PARAM_DOC -// Returns -// matrix (n x $OUT_COLS) with colum: -// $RETURN_COLS -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_${NAME}.c -// -#include "MAType.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include "attributes.h" -${NORMALIZE_INCLUDE}#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_${NAME}_lookback($R_SIGNATURE -) -// clang-format on -{ - // values - $LOOKBACK_VALUES - - // calculate lookback - const int lookback = TA_${NAME}_Lookback($LOOKBACK_ARGS); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_${NAME}(${R_SIGNATURE}${FLAG_ARG}, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - $VALUES - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - $NA_MASK_BUILD - if (n < n_original) { - $NA_COMPACT - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - $OUTPUT_TYPE *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_${NAME}_Lookback($LOOKBACK_ARGS); - - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = output_container( - n, - lookback, - $OUT_COLS, - &output, - &output_ptr, - &protection_count - ); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - $OUTPUT_COLS - - // TA_$NAME returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_${NAME}( - 0, - n - 1, - $VALUE_POINTERS - &start_idx, - &end_idx, - $OUTPUT_POINTERS - ); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - $SHIFT_ARRAYS - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - $SET_COLUMN_NAMES - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix(output, output_ptr, na_mask, n_original, &protection_count); - } - - ${NORMALIZE_BLOCK} - - UNPROTECT(protection_count); - return output; -} diff --git a/src/MAType.h b/src/MAType.h deleted file mode 100644 index ce2910b2c..000000000 --- a/src/MAType.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _MATYPE_H -#define _MATYPE_H -// as_MAType -// -// Parameters: -// x: SEXP -// Description -// Syntactic sugar for mapping SEXP -// to TA_MAType -#include "Rinternals.h" -#include "ta_defs.h" - -static inline TA_MAType as_MAType(SEXP x) { - int x_ = INTEGER(x)[0]; - return (TA_MAType)x_; -} - -// clang-format off -static inline const char *_MAType_(TA_MAType t) { - static const char *const k[] = { - "SMA", - "EMA", - "WMA", - "DEMA", - "TEMA", - "TRIMA", - "KAMA", - "MAMA", - "T3" - }; - unsigned u = (unsigned)t; - return u < (sizeof k / sizeof k[0]) ? k[u] : "INVALID"; -} -// clang-format on - -#endif // _MATYPE_H diff --git a/src/NA-handling.c b/src/NA-handling.c new file mode 100644 index 000000000..87880eb50 --- /dev/null +++ b/src/NA-handling.c @@ -0,0 +1,144 @@ +// -handling +// +// Description +// TA-Lib does handle -values if passed into the +// TA_()-function—it returns all if a +// single is passed via in*-arrays. +// +// This C-routine strips all while recording their positional +// index, and then reinserts them once the indicator is returned, +// if (bool) na.bridge is passed as TRUE from the R-side. +// +#include "NA-handling.h" +#include +#include +#include + +// clang-format off +#define TA_BIT_GET(bitmask, bit_index) \ + ((bitmask)[(R_xlen_t)(bit_index) >> 3] & (unsigned char) (1u << ((bit_index) & 7))) +#define TA_BIT_SET(bitmask, bit_index) \ + ((bitmask)[(R_xlen_t)(bit_index) >> 3] |= (unsigned char) (1u << ((bit_index) & 7))) +// clang-format on + +// clang-format off +R_xlen_t build_presence_mask( + const double *const *input_columns, + int k_columns, + R_xlen_t n_rows, + unsigned char **presence_mask +) +// clang-format on +{ + // one bit per row, rounded up to whole bytes + size_t nbytes = (size_t)((n_rows + 7) / 8); + + unsigned char *mask = (unsigned char *)R_alloc(nbytes, 1); + memset(mask, 0, nbytes); + + R_xlen_t num_present = 0; + for (R_xlen_t row = 0; row < n_rows; row++) { + int present = 1; + for (int col = 0; col < k_columns; col++) { + if (ISNAN(input_columns[col][row])) { + present = 0; + break; + } + } + if (present) { + TA_BIT_SET(mask, row); + num_present++; + } + } + + *presence_mask = mask; + return num_present; +} + +// clang-format off +double *dense_array( + R_xlen_t num_present_rows, + int k_columns +) +// clang-format on +{ + return (double *)R_alloc( + (size_t)num_present_rows * (size_t)k_columns, + sizeof(double)); +} + +// clang-format off +double *compact_array( + double *dense_column, + const double *full_column, + const unsigned char *presence_mask, + R_xlen_t n_rows +) +// clang-format on +{ + R_xlen_t dense = 0; + for (R_xlen_t row = 0; row < n_rows; row++) { + if (TA_BIT_GET(presence_mask, row)) { + dense_column[dense++] = full_column[row]; + } + } + return dense_column; +} + +// clang-format off +void scatter_double_array( + double *column, + R_xlen_t n_rows, + const unsigned char *presence_mask, + R_xlen_t num_present_rows, + int begIdx, + int nbElement +) +// clang-format on +{ + R_xlen_t dense = num_present_rows - 1; + R_xlen_t raw = (R_xlen_t)nbElement - 1; + for (R_xlen_t row = n_rows - 1; row >= 0; row--) { + if (dense >= 0 && TA_BIT_GET(presence_mask, row)) { + if (dense >= (R_xlen_t)begIdx && raw >= 0) { + column[row] = column[raw]; + raw--; + } else { + column[row] = NA_REAL; + } + dense--; + } else { + column[row] = NA_REAL; + } + } +} + +// clang-format off +void scatter_integer_array( + int *column, + R_xlen_t n_rows, + const unsigned char *presence_mask, + R_xlen_t num_present_rows, + int begIdx, + int nbElement +) +// clang-format on +{ + R_xlen_t dense = num_present_rows - 1; + R_xlen_t raw = (R_xlen_t)nbElement - 1; + for (R_xlen_t row = n_rows - 1; row >= 0; row--) { + if (dense >= 0 && TA_BIT_GET(presence_mask, row)) { + if (dense >= (R_xlen_t)begIdx && raw >= 0) { + column[row] = column[raw]; + raw--; + } else { + column[row] = NA_INTEGER; + } + dense--; + } else { + column[row] = NA_INTEGER; + } + } +} +#undef TA_BIT_GET +#undef TA_BIT_SET diff --git a/src/NA-handling.h b/src/NA-handling.h new file mode 100644 index 000000000..89506956f --- /dev/null +++ b/src/NA-handling.h @@ -0,0 +1,58 @@ +// NA-handling.h +// +// Description +// Public interface for the `na.bridge` path: drop rows where any input +// is NA/NaN, compute the indicator on the dense (gap-free) series, then +// scatter the results back to their original row positions. Kept in one +// place so all generated wrappers share a single, memory-lean routine. +// +#ifndef NA_HANDLING_H +#define NA_HANDLING_H + +#include + +R_xlen_t build_presence_mask( + const double *const *input_columns, + int k_columns, + R_xlen_t n_rows, + unsigned char **presence_mask); + +double *dense_array(R_xlen_t num_present_rows, int k_columns); + +double *compact_array( + double *dense_column, + const double *full_column, + const unsigned char *presence_mask, + R_xlen_t n_rows); + +void scatter_double_array( + double *column, + R_xlen_t n_rows, + const unsigned char *presence_mask, + R_xlen_t num_present_rows, + int begIdx, + int nbElement); + +void scatter_integer_array( + int *column, + R_xlen_t n_rows, + const unsigned char *presence_mask, + R_xlen_t num_present_rows, + int begIdx, + int nbElement); + +// clang-format off +// Generic scatter_array +// +// Description +// Works similar to S3 functions in R +// _Generic( (x), type: dispatch ) ( signature ) +#define scatter_array(column, n_rows, presence_mask, num_present_rows, begIdx, nbElement) \ + _Generic((column), \ + double *: scatter_double_array, \ + int *: scatter_integer_array \ + )((column), (n_rows), (presence_mask), (num_present_rows), (begIdx), (nbElement)) +// clang-format on +// scatter array end + +#endif /* NA_HANDLING_H */ diff --git a/src/lib.c b/src/TA-Lib.c similarity index 67% rename from src/lib.c rename to src/TA-Lib.c index 1d908e2e2..b8b7f7eff 100644 --- a/src/lib.c +++ b/src/TA-Lib.c @@ -1,54 +1,6 @@ -// TA-Lib specific options -#include "lib.h" -#include "R_ext/Error.h" -#include "api.h" -#include "shift.h" -#include "ta_defs.h" -#include "ta_func.h" -#include +#include "ta_libc.h" +#include "utils.h" #include -#include - -// initialize TA-Lib -SEXP initialize_ta_lib(void) { - TA_RetCode return_code = TA_Initialize(); - - if (return_code != TA_SUCCESS) { - Rf_error("TA_Initialize failed (code %d)", return_code); - } - - return ScalarLogical(1); -} - -// shutdown TA-Lib -SEXP shutdown_ta_lib(void) { - TA_RetCode return_code = TA_Shutdown(); - - if (return_code != TA_SUCCESS) { - Rf_error("TA_Shutdown failed (code %d)", return_code); - } - - return ScalarLogical(1); -} - -// candlestick options -// -SEXP reset_candle_setting(void) { - - // reset all candle settings - // clang-format off - TA_RetCode return_code = TA_RestoreCandleDefaultSettings( TA_AllCandleSettings - ); - // clang-format on - - // send a warning instead of error - // to allow the interface some slack - if (return_code != TA_SUCCESS) { - Rf_warning("Candle settings failed (Code %d)", return_code); - } - - return Rf_ScalarLogical(1); -} // Candle Settings // @@ -79,26 +31,19 @@ SEXP reset_candle_setting(void) { // // clang-format off SEXP set_candle_setting( - SEXP s_settingType, - SEXP s_rangeType, - SEXP s_avgPeriod, - SEXP s_factor + SEXP settingType, + SEXP rangeType, + SEXP avgPeriod, + SEXP factor ) { // clang-format on - // extract values to be passed - // onto settings - const TA_CandleSettingType settingType = INTEGER(s_settingType)[0]; - const TA_RangeType rangeType = INTEGER(s_rangeType)[0]; - const int avgPeriod = INTEGER(s_avgPeriod)[0]; - const double factor = REAL(s_factor)[0]; - // clang-format off TA_RetCode return_code = TA_SetCandleSettings( - settingType, - rangeType, - avgPeriod, - factor + (TA_CandleSettingType) Rf_asInteger(settingType), + (TA_RangeType) Rf_asInteger(rangeType), + (int) Rf_asInteger(avgPeriod), + (double) Rf_asReal(factor) ); // clang-format on @@ -108,5 +53,65 @@ SEXP set_candle_setting( Rf_warning("Candle settings failed (Code %d)", return_code); } + return Rf_ScalarLogical(1); +} + +SEXP reset_candle_setting(void) { + + // reset all candle settings + // clang-format off + TA_RetCode return_code = TA_RestoreCandleDefaultSettings( + TA_AllCandleSettings + ); + // clang-format on + + // send a warning instead of error + // to allow the interface some slack + if (return_code != TA_SUCCESS) { + Rf_warning("Candle settings failed (Code %d)", return_code); + } + + return Rf_ScalarLogical(1); +} +// Candle settings end + +SEXP ta_set_unstable_period(SEXP s_id, SEXP s_period) { + ta_check( + TA_SetUnstablePeriod( + (TA_FuncUnstId)Rf_asInteger(s_id), + (unsigned int)Rf_asInteger(s_period)), + "TA_SetUnstablePeriod"); + return R_NilValue; +} + +SEXP ta_set_compatibility(SEXP s_value) { + ta_check( + TA_SetCompatibility((TA_Compatibility)Rf_asInteger(s_value)), + "TA_SetCompatibility"); + return R_NilValue; +} + +// initialize TA-Lib +// +// NOTE: Only kept for backwards compatibility +// will be deleted after merge +SEXP initialize_ta_lib(void) { + TA_RetCode return_code = TA_Initialize(); + + if (return_code != TA_SUCCESS) { + Rf_error("TA_Initialize failed (code %d)", return_code); + } + + return Rf_ScalarLogical(1); +} + +// shutdown TA-Lib +SEXP shutdown_ta_lib(void) { + TA_RetCode return_code = TA_Shutdown(); + + if (return_code != TA_SUCCESS) { + Rf_error("TA_Shutdown failed (code %d)", return_code); + } + return Rf_ScalarLogical(1); } \ No newline at end of file diff --git a/src/TA-Lib.h b/src/TA-Lib.h new file mode 100644 index 000000000..5c9b4fb99 --- /dev/null +++ b/src/TA-Lib.h @@ -0,0 +1,336 @@ +// TA-Lib.h - Autogenerated via codegen/ +// Description: +// +// TA_INDICATOR: TA-Lib indicator. +// TA_INPUT: Indicator input. +// TA_OPTIONS: Indicator input. +// TA_OUTPUT: Indicator input. +// TA_OUTPUT_NAMES: Indicator input. +// TA_LOOKBACK: Indicator lookback (name + optional inputs). +// +// clang-format off +TA_INDICATOR(ACCBANDS, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outRealUpperBand, outRealMiddleBand, outRealLowerBand), TA_OUTPUT_NAME(UpperBand, MiddleBand, LowerBand), NOT_CANDLESTICK) +TA_INDICATOR(ACOS, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(ACOS), NOT_CANDLESTICK) +TA_INDICATOR(AD, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose, inVolume), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(AD), NOT_CANDLESTICK) +TA_INDICATOR(ADD, TA_DOUBLE, TA_INPUT(inReal0, inReal1), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(ADD), NOT_CANDLESTICK) +TA_INDICATOR(ADOSC, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose, inVolume), TA_OPTIONS(OPTIONAL_INTEGER(optInFastPeriod), OPTIONAL_INTEGER(optInSlowPeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(ADOSC), NOT_CANDLESTICK) +TA_INDICATOR(ADX, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(ADX), NOT_CANDLESTICK) +TA_INDICATOR(ADXR, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(ADXR), NOT_CANDLESTICK) +TA_INDICATOR(APO, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInFastPeriod), OPTIONAL_INTEGER(optInSlowPeriod), OPTIONAL_MATYPE(optInMAType)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(APO), NOT_CANDLESTICK) +TA_INDICATOR(AROON, TA_DOUBLE, TA_INPUT(inHigh, inLow), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outAroonDown, outAroonUp), TA_OUTPUT_NAME(AroonDown, AroonUp), NOT_CANDLESTICK) +TA_INDICATOR(AROONOSC, TA_DOUBLE, TA_INPUT(inHigh, inLow), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(AROONOSC), NOT_CANDLESTICK) +TA_INDICATOR(ASIN, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(ASIN), NOT_CANDLESTICK) +TA_INDICATOR(ATAN, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(ATAN), NOT_CANDLESTICK) +TA_INDICATOR(ATR, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(ATR), NOT_CANDLESTICK) +TA_INDICATOR(AVGDEV, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(AVGDEV), NOT_CANDLESTICK) +TA_INDICATOR(AVGPRICE, TA_DOUBLE, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(AVGPRICE), NOT_CANDLESTICK) +TA_INDICATOR(BBANDS, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod), OPTIONAL_DOUBLE(optInNbDevUp), OPTIONAL_DOUBLE(optInNbDevDn), OPTIONAL_MATYPE(optInMAType)), TA_OUTPUT(outRealUpperBand, outRealMiddleBand, outRealLowerBand), TA_OUTPUT_NAME(UpperBand, MiddleBand, LowerBand), NOT_CANDLESTICK) +TA_INDICATOR(BETA, TA_DOUBLE, TA_INPUT(inReal0, inReal1), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(BETA), NOT_CANDLESTICK) +TA_INDICATOR(BOP, TA_DOUBLE, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(BOP), NOT_CANDLESTICK) +TA_INDICATOR(CCI, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(CCI), NOT_CANDLESTICK) +TA_INDICATOR(CDL2CROWS, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDL2CROWS), CANDLESTICK) +TA_INDICATOR(CDL3BLACKCROWS, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDL3BLACKCROWS), CANDLESTICK) +TA_INDICATOR(CDL3INSIDE, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDL3INSIDE), CANDLESTICK) +TA_INDICATOR(CDL3LINESTRIKE, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDL3LINESTRIKE), CANDLESTICK) +TA_INDICATOR(CDL3OUTSIDE, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDL3OUTSIDE), CANDLESTICK) +TA_INDICATOR(CDL3STARSINSOUTH, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDL3STARSINSOUTH), CANDLESTICK) +TA_INDICATOR(CDL3WHITESOLDIERS, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDL3WHITESOLDIERS), CANDLESTICK) +TA_INDICATOR(CDLABANDONEDBABY, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_DOUBLE(optInPenetration)), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLABANDONEDBABY), CANDLESTICK) +TA_INDICATOR(CDLADVANCEBLOCK, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLADVANCEBLOCK), CANDLESTICK) +TA_INDICATOR(CDLBELTHOLD, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLBELTHOLD), CANDLESTICK) +TA_INDICATOR(CDLBREAKAWAY, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLBREAKAWAY), CANDLESTICK) +TA_INDICATOR(CDLCLOSINGMARUBOZU, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLCLOSINGMARUBOZU), CANDLESTICK) +TA_INDICATOR(CDLCONCEALBABYSWALL, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLCONCEALBABYSWALL), CANDLESTICK) +TA_INDICATOR(CDLCOUNTERATTACK, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLCOUNTERATTACK), CANDLESTICK) +TA_INDICATOR(CDLDARKCLOUDCOVER, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_DOUBLE(optInPenetration)), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLDARKCLOUDCOVER), CANDLESTICK) +TA_INDICATOR(CDLDOJI, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLDOJI), CANDLESTICK) +TA_INDICATOR(CDLDOJISTAR, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLDOJISTAR), CANDLESTICK) +TA_INDICATOR(CDLDRAGONFLYDOJI, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLDRAGONFLYDOJI), CANDLESTICK) +TA_INDICATOR(CDLENGULFING, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLENGULFING), CANDLESTICK) +TA_INDICATOR(CDLEVENINGDOJISTAR, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_DOUBLE(optInPenetration)), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLEVENINGDOJISTAR), CANDLESTICK) +TA_INDICATOR(CDLEVENINGSTAR, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_DOUBLE(optInPenetration)), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLEVENINGSTAR), CANDLESTICK) +TA_INDICATOR(CDLGAPSIDESIDEWHITE, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLGAPSIDESIDEWHITE), CANDLESTICK) +TA_INDICATOR(CDLGRAVESTONEDOJI, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLGRAVESTONEDOJI), CANDLESTICK) +TA_INDICATOR(CDLHAMMER, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLHAMMER), CANDLESTICK) +TA_INDICATOR(CDLHANGINGMAN, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLHANGINGMAN), CANDLESTICK) +TA_INDICATOR(CDLHARAMI, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLHARAMI), CANDLESTICK) +TA_INDICATOR(CDLHARAMICROSS, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLHARAMICROSS), CANDLESTICK) +TA_INDICATOR(CDLHIGHWAVE, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLHIGHWAVE), CANDLESTICK) +TA_INDICATOR(CDLHIKKAKE, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLHIKKAKE), CANDLESTICK) +TA_INDICATOR(CDLHIKKAKEMOD, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLHIKKAKEMOD), CANDLESTICK) +TA_INDICATOR(CDLHOMINGPIGEON, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLHOMINGPIGEON), CANDLESTICK) +TA_INDICATOR(CDLIDENTICAL3CROWS, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLIDENTICAL3CROWS), CANDLESTICK) +TA_INDICATOR(CDLINNECK, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLINNECK), CANDLESTICK) +TA_INDICATOR(CDLINVERTEDHAMMER, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLINVERTEDHAMMER), CANDLESTICK) +TA_INDICATOR(CDLKICKING, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLKICKING), CANDLESTICK) +TA_INDICATOR(CDLKICKINGBYLENGTH, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLKICKINGBYLENGTH), CANDLESTICK) +TA_INDICATOR(CDLLADDERBOTTOM, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLLADDERBOTTOM), CANDLESTICK) +TA_INDICATOR(CDLLONGLEGGEDDOJI, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLLONGLEGGEDDOJI), CANDLESTICK) +TA_INDICATOR(CDLLONGLINE, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLLONGLINE), CANDLESTICK) +TA_INDICATOR(CDLMARUBOZU, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLMARUBOZU), CANDLESTICK) +TA_INDICATOR(CDLMATCHINGLOW, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLMATCHINGLOW), CANDLESTICK) +TA_INDICATOR(CDLMATHOLD, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_DOUBLE(optInPenetration)), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLMATHOLD), CANDLESTICK) +TA_INDICATOR(CDLMORNINGDOJISTAR, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_DOUBLE(optInPenetration)), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLMORNINGDOJISTAR), CANDLESTICK) +TA_INDICATOR(CDLMORNINGSTAR, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_DOUBLE(optInPenetration)), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLMORNINGSTAR), CANDLESTICK) +TA_INDICATOR(CDLONNECK, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLONNECK), CANDLESTICK) +TA_INDICATOR(CDLPIERCING, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLPIERCING), CANDLESTICK) +TA_INDICATOR(CDLRICKSHAWMAN, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLRICKSHAWMAN), CANDLESTICK) +TA_INDICATOR(CDLRISEFALL3METHODS, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLRISEFALL3METHODS), CANDLESTICK) +TA_INDICATOR(CDLSEPARATINGLINES, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLSEPARATINGLINES), CANDLESTICK) +TA_INDICATOR(CDLSHOOTINGSTAR, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLSHOOTINGSTAR), CANDLESTICK) +TA_INDICATOR(CDLSHORTLINE, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLSHORTLINE), CANDLESTICK) +TA_INDICATOR(CDLSPINNINGTOP, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLSPINNINGTOP), CANDLESTICK) +TA_INDICATOR(CDLSTALLEDPATTERN, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLSTALLEDPATTERN), CANDLESTICK) +TA_INDICATOR(CDLSTICKSANDWICH, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLSTICKSANDWICH), CANDLESTICK) +TA_INDICATOR(CDLTAKURI, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLTAKURI), CANDLESTICK) +TA_INDICATOR(CDLTASUKIGAP, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLTASUKIGAP), CANDLESTICK) +TA_INDICATOR(CDLTHRUSTING, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLTHRUSTING), CANDLESTICK) +TA_INDICATOR(CDLTRISTAR, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLTRISTAR), CANDLESTICK) +TA_INDICATOR(CDLUNIQUE3RIVER, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLUNIQUE3RIVER), CANDLESTICK) +TA_INDICATOR(CDLUPSIDEGAP2CROWS, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLUPSIDEGAP2CROWS), CANDLESTICK) +TA_INDICATOR(CDLXSIDEGAP3METHODS, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLXSIDEGAP3METHODS), CANDLESTICK) +TA_INDICATOR(CEIL, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(CEIL), NOT_CANDLESTICK) +TA_INDICATOR(CMO, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(CMO), NOT_CANDLESTICK) +TA_INDICATOR(CORREL, TA_DOUBLE, TA_INPUT(inReal0, inReal1), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(CORREL), NOT_CANDLESTICK) +TA_INDICATOR(COS, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(COS), NOT_CANDLESTICK) +TA_INDICATOR(COSH, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(COSH), NOT_CANDLESTICK) +TA_INDICATOR(DEMA, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(DEMA), NOT_CANDLESTICK) +TA_INDICATOR(DIV, TA_DOUBLE, TA_INPUT(inReal0, inReal1), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(DIV), NOT_CANDLESTICK) +TA_INDICATOR(DX, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(DX), NOT_CANDLESTICK) +TA_INDICATOR(EMA, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(EMA), NOT_CANDLESTICK) +TA_INDICATOR(EXP, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(EXP), NOT_CANDLESTICK) +TA_INDICATOR(FLOOR, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(FLOOR), NOT_CANDLESTICK) +TA_INDICATOR(HT_DCPERIOD, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(HT_DCPERIOD), NOT_CANDLESTICK) +TA_INDICATOR(HT_DCPHASE, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(HT_DCPHASE), NOT_CANDLESTICK) +TA_INDICATOR(HT_PHASOR, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outInPhase, outQuadrature), TA_OUTPUT_NAME(InPhase, Quadrature), NOT_CANDLESTICK) +TA_INDICATOR(HT_SINE, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outSine, outLeadSine), TA_OUTPUT_NAME(Sine, LeadSine), NOT_CANDLESTICK) +TA_INDICATOR(HT_TRENDLINE, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(HT_TRENDLINE), NOT_CANDLESTICK) +TA_INDICATOR(HT_TRENDMODE, TA_INTEGER, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(HT_TRENDMODE), NOT_CANDLESTICK) +TA_INDICATOR(IMI, TA_DOUBLE, TA_INPUT(inOpen, inClose), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(IMI), NOT_CANDLESTICK) +TA_INDICATOR(KAMA, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(KAMA), NOT_CANDLESTICK) +TA_INDICATOR(LINEARREG, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(LINEARREG), NOT_CANDLESTICK) +TA_INDICATOR(LINEARREG_ANGLE, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(LINEARREG_ANGLE), NOT_CANDLESTICK) +TA_INDICATOR(LINEARREG_INTERCEPT, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(LINEARREG_INTERCEPT), NOT_CANDLESTICK) +TA_INDICATOR(LINEARREG_SLOPE, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(LINEARREG_SLOPE), NOT_CANDLESTICK) +TA_INDICATOR(LN, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(LN), NOT_CANDLESTICK) +TA_INDICATOR(LOG10, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(LOG10), NOT_CANDLESTICK) +TA_INDICATOR(MA, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod), OPTIONAL_MATYPE(optInMAType)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(MA), NOT_CANDLESTICK) +TA_INDICATOR(MACD, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInFastPeriod), OPTIONAL_INTEGER(optInSlowPeriod), OPTIONAL_INTEGER(optInSignalPeriod)), TA_OUTPUT(outMACD, outMACDSignal, outMACDHist), TA_OUTPUT_NAME(MACD, MACDSignal, MACDHist), NOT_CANDLESTICK) +TA_INDICATOR(MACDEXT, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInFastPeriod), OPTIONAL_MATYPE(optInFastMAType), OPTIONAL_INTEGER(optInSlowPeriod), OPTIONAL_MATYPE(optInSlowMAType), OPTIONAL_INTEGER(optInSignalPeriod), OPTIONAL_MATYPE(optInSignalMAType)), TA_OUTPUT(outMACD, outMACDSignal, outMACDHist), TA_OUTPUT_NAME(MACD, MACDSignal, MACDHist), NOT_CANDLESTICK) +TA_INDICATOR(MACDFIX, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInSignalPeriod)), TA_OUTPUT(outMACD, outMACDSignal, outMACDHist), TA_OUTPUT_NAME(MACD, MACDSignal, MACDHist), NOT_CANDLESTICK) +TA_INDICATOR(MAMA, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_DOUBLE(optInFastLimit), OPTIONAL_DOUBLE(optInSlowLimit)), TA_OUTPUT(outMAMA, outFAMA), TA_OUTPUT_NAME(MAMA, FAMA), NOT_CANDLESTICK) +TA_INDICATOR(MAVP, TA_DOUBLE, TA_INPUT(inReal, inPeriods), TA_OPTIONS(OPTIONAL_INTEGER(optInMinPeriod), OPTIONAL_INTEGER(optInMaxPeriod), OPTIONAL_MATYPE(optInMAType)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(MAVP), NOT_CANDLESTICK) +TA_INDICATOR(MAX, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(MAX), NOT_CANDLESTICK) +TA_INDICATOR(MAXINDEX, TA_INTEGER, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(MAXINDEX), NOT_CANDLESTICK) +TA_INDICATOR(MEDPRICE, TA_DOUBLE, TA_INPUT(inHigh, inLow), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(MEDPRICE), NOT_CANDLESTICK) +TA_INDICATOR(MFI, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose, inVolume), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(MFI), NOT_CANDLESTICK) +TA_INDICATOR(MIDPOINT, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(MIDPOINT), NOT_CANDLESTICK) +TA_INDICATOR(MIDPRICE, TA_DOUBLE, TA_INPUT(inHigh, inLow), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(MIDPRICE), NOT_CANDLESTICK) +TA_INDICATOR(MIN, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(MIN), NOT_CANDLESTICK) +TA_INDICATOR(MININDEX, TA_INTEGER, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(MININDEX), NOT_CANDLESTICK) +TA_INDICATOR(MINMAX, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outMin, outMax), TA_OUTPUT_NAME(Min, Max), NOT_CANDLESTICK) +TA_INDICATOR(MINMAXINDEX, TA_INTEGER, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outMinIdx, outMaxIdx), TA_OUTPUT_NAME(MinIdx, MaxIdx), NOT_CANDLESTICK) +TA_INDICATOR(MINUS_DI, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(MINUS_DI), NOT_CANDLESTICK) +TA_INDICATOR(MINUS_DM, TA_DOUBLE, TA_INPUT(inHigh, inLow), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(MINUS_DM), NOT_CANDLESTICK) +TA_INDICATOR(MOM, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(MOM), NOT_CANDLESTICK) +TA_INDICATOR(MULT, TA_DOUBLE, TA_INPUT(inReal0, inReal1), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(MULT), NOT_CANDLESTICK) +TA_INDICATOR(NATR, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(NATR), NOT_CANDLESTICK) +TA_INDICATOR(OBV, TA_DOUBLE, TA_INPUT(inReal, inVolume), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(OBV), NOT_CANDLESTICK) +TA_INDICATOR(PLUS_DI, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(PLUS_DI), NOT_CANDLESTICK) +TA_INDICATOR(PLUS_DM, TA_DOUBLE, TA_INPUT(inHigh, inLow), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(PLUS_DM), NOT_CANDLESTICK) +TA_INDICATOR(PPO, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInFastPeriod), OPTIONAL_INTEGER(optInSlowPeriod), OPTIONAL_MATYPE(optInMAType)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(PPO), NOT_CANDLESTICK) +TA_INDICATOR(ROC, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(ROC), NOT_CANDLESTICK) +TA_INDICATOR(ROCP, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(ROCP), NOT_CANDLESTICK) +TA_INDICATOR(ROCR, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(ROCR), NOT_CANDLESTICK) +TA_INDICATOR(ROCR100, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(ROCR100), NOT_CANDLESTICK) +TA_INDICATOR(RSI, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(RSI), NOT_CANDLESTICK) +TA_INDICATOR(SAR, TA_DOUBLE, TA_INPUT(inHigh, inLow), TA_OPTIONS(OPTIONAL_DOUBLE(optInAcceleration), OPTIONAL_DOUBLE(optInMaximum)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(SAR), NOT_CANDLESTICK) +TA_INDICATOR(SAREXT, TA_DOUBLE, TA_INPUT(inHigh, inLow), TA_OPTIONS(OPTIONAL_DOUBLE(optInStartValue), OPTIONAL_DOUBLE(optInOffsetOnReverse), OPTIONAL_DOUBLE(optInAccelerationInitLong), OPTIONAL_DOUBLE(optInAccelerationLong), OPTIONAL_DOUBLE(optInAccelerationMaxLong), OPTIONAL_DOUBLE(optInAccelerationInitShort), OPTIONAL_DOUBLE(optInAccelerationShort), OPTIONAL_DOUBLE(optInAccelerationMaxShort)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(SAREXT), NOT_CANDLESTICK) +TA_INDICATOR(SIN, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(SIN), NOT_CANDLESTICK) +TA_INDICATOR(SINH, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(SINH), NOT_CANDLESTICK) +TA_INDICATOR(SMA, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(SMA), NOT_CANDLESTICK) +TA_INDICATOR(SQRT, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(SQRT), NOT_CANDLESTICK) +TA_INDICATOR(STDDEV, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod), OPTIONAL_DOUBLE(optInNbDev)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(STDDEV), NOT_CANDLESTICK) +TA_INDICATOR(STOCH, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_INTEGER(optInFastK_Period), OPTIONAL_INTEGER(optInSlowK_Period), OPTIONAL_MATYPE(optInSlowK_MAType), OPTIONAL_INTEGER(optInSlowD_Period), OPTIONAL_MATYPE(optInSlowD_MAType)), TA_OUTPUT(outSlowK, outSlowD), TA_OUTPUT_NAME(SlowK, SlowD), NOT_CANDLESTICK) +TA_INDICATOR(STOCHF, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_INTEGER(optInFastK_Period), OPTIONAL_INTEGER(optInFastD_Period), OPTIONAL_MATYPE(optInFastD_MAType)), TA_OUTPUT(outFastK, outFastD), TA_OUTPUT_NAME(FastK, FastD), NOT_CANDLESTICK) +TA_INDICATOR(STOCHRSI, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod), OPTIONAL_INTEGER(optInFastK_Period), OPTIONAL_INTEGER(optInFastD_Period), OPTIONAL_MATYPE(optInFastD_MAType)), TA_OUTPUT(outFastK, outFastD), TA_OUTPUT_NAME(FastK, FastD), NOT_CANDLESTICK) +TA_INDICATOR(SUB, TA_DOUBLE, TA_INPUT(inReal0, inReal1), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(SUB), NOT_CANDLESTICK) +TA_INDICATOR(SUM, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(SUM), NOT_CANDLESTICK) +TA_INDICATOR(T3, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod), OPTIONAL_DOUBLE(optInVFactor)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(T3), NOT_CANDLESTICK) +TA_INDICATOR(TAN, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(TAN), NOT_CANDLESTICK) +TA_INDICATOR(TANH, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(TANH), NOT_CANDLESTICK) +TA_INDICATOR(TEMA, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(TEMA), NOT_CANDLESTICK) +TA_INDICATOR(TRANGE, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(TRANGE), NOT_CANDLESTICK) +TA_INDICATOR(TRIMA, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(TRIMA), NOT_CANDLESTICK) +TA_INDICATOR(TRIX, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(TRIX), NOT_CANDLESTICK) +TA_INDICATOR(TSF, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(TSF), NOT_CANDLESTICK) +TA_INDICATOR(TYPPRICE, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(TYPPRICE), NOT_CANDLESTICK) +TA_INDICATOR(ULTOSC, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod1), OPTIONAL_INTEGER(optInTimePeriod2), OPTIONAL_INTEGER(optInTimePeriod3)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(ULTOSC), NOT_CANDLESTICK) +TA_INDICATOR(VAR, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod), OPTIONAL_DOUBLE(optInNbDev)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(VAR), NOT_CANDLESTICK) +TA_INDICATOR(WCLPRICE, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose), TA_OPTIONS(), TA_OUTPUT(outReal), TA_OUTPUT_NAME(WCLPRICE), NOT_CANDLESTICK) +TA_INDICATOR(WILLR, TA_DOUBLE, TA_INPUT(inHigh, inLow, inClose), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(WILLR), NOT_CANDLESTICK) +TA_INDICATOR(WMA, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), TA_OUTPUT_NAME(WMA), NOT_CANDLESTICK) + +// Lookback +TA_LOOKBACK(ACCBANDS, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(ACOS, TA_OPTIONS()) +TA_LOOKBACK(AD, TA_OPTIONS()) +TA_LOOKBACK(ADD, TA_OPTIONS()) +TA_LOOKBACK(ADOSC, TA_OPTIONS(OPTIONAL_INTEGER(optInFastPeriod), OPTIONAL_INTEGER(optInSlowPeriod))) +TA_LOOKBACK(ADX, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(ADXR, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(APO, TA_OPTIONS(OPTIONAL_INTEGER(optInFastPeriod), OPTIONAL_INTEGER(optInSlowPeriod), OPTIONAL_MATYPE(optInMAType))) +TA_LOOKBACK(AROON, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(AROONOSC, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(ASIN, TA_OPTIONS()) +TA_LOOKBACK(ATAN, TA_OPTIONS()) +TA_LOOKBACK(ATR, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(AVGDEV, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(AVGPRICE, TA_OPTIONS()) +TA_LOOKBACK(BBANDS, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod), OPTIONAL_DOUBLE(optInNbDevUp), OPTIONAL_DOUBLE(optInNbDevDn), OPTIONAL_MATYPE(optInMAType))) +TA_LOOKBACK(BETA, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(BOP, TA_OPTIONS()) +TA_LOOKBACK(CCI, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(CDL2CROWS, TA_OPTIONS()) +TA_LOOKBACK(CDL3BLACKCROWS, TA_OPTIONS()) +TA_LOOKBACK(CDL3INSIDE, TA_OPTIONS()) +TA_LOOKBACK(CDL3LINESTRIKE, TA_OPTIONS()) +TA_LOOKBACK(CDL3OUTSIDE, TA_OPTIONS()) +TA_LOOKBACK(CDL3STARSINSOUTH, TA_OPTIONS()) +TA_LOOKBACK(CDL3WHITESOLDIERS, TA_OPTIONS()) +TA_LOOKBACK(CDLABANDONEDBABY, TA_OPTIONS(OPTIONAL_DOUBLE(optInPenetration))) +TA_LOOKBACK(CDLADVANCEBLOCK, TA_OPTIONS()) +TA_LOOKBACK(CDLBELTHOLD, TA_OPTIONS()) +TA_LOOKBACK(CDLBREAKAWAY, TA_OPTIONS()) +TA_LOOKBACK(CDLCLOSINGMARUBOZU, TA_OPTIONS()) +TA_LOOKBACK(CDLCONCEALBABYSWALL, TA_OPTIONS()) +TA_LOOKBACK(CDLCOUNTERATTACK, TA_OPTIONS()) +TA_LOOKBACK(CDLDARKCLOUDCOVER, TA_OPTIONS(OPTIONAL_DOUBLE(optInPenetration))) +TA_LOOKBACK(CDLDOJI, TA_OPTIONS()) +TA_LOOKBACK(CDLDOJISTAR, TA_OPTIONS()) +TA_LOOKBACK(CDLDRAGONFLYDOJI, TA_OPTIONS()) +TA_LOOKBACK(CDLENGULFING, TA_OPTIONS()) +TA_LOOKBACK(CDLEVENINGDOJISTAR, TA_OPTIONS(OPTIONAL_DOUBLE(optInPenetration))) +TA_LOOKBACK(CDLEVENINGSTAR, TA_OPTIONS(OPTIONAL_DOUBLE(optInPenetration))) +TA_LOOKBACK(CDLGAPSIDESIDEWHITE, TA_OPTIONS()) +TA_LOOKBACK(CDLGRAVESTONEDOJI, TA_OPTIONS()) +TA_LOOKBACK(CDLHAMMER, TA_OPTIONS()) +TA_LOOKBACK(CDLHANGINGMAN, TA_OPTIONS()) +TA_LOOKBACK(CDLHARAMI, TA_OPTIONS()) +TA_LOOKBACK(CDLHARAMICROSS, TA_OPTIONS()) +TA_LOOKBACK(CDLHIGHWAVE, TA_OPTIONS()) +TA_LOOKBACK(CDLHIKKAKE, TA_OPTIONS()) +TA_LOOKBACK(CDLHIKKAKEMOD, TA_OPTIONS()) +TA_LOOKBACK(CDLHOMINGPIGEON, TA_OPTIONS()) +TA_LOOKBACK(CDLIDENTICAL3CROWS, TA_OPTIONS()) +TA_LOOKBACK(CDLINNECK, TA_OPTIONS()) +TA_LOOKBACK(CDLINVERTEDHAMMER, TA_OPTIONS()) +TA_LOOKBACK(CDLKICKING, TA_OPTIONS()) +TA_LOOKBACK(CDLKICKINGBYLENGTH, TA_OPTIONS()) +TA_LOOKBACK(CDLLADDERBOTTOM, TA_OPTIONS()) +TA_LOOKBACK(CDLLONGLEGGEDDOJI, TA_OPTIONS()) +TA_LOOKBACK(CDLLONGLINE, TA_OPTIONS()) +TA_LOOKBACK(CDLMARUBOZU, TA_OPTIONS()) +TA_LOOKBACK(CDLMATCHINGLOW, TA_OPTIONS()) +TA_LOOKBACK(CDLMATHOLD, TA_OPTIONS(OPTIONAL_DOUBLE(optInPenetration))) +TA_LOOKBACK(CDLMORNINGDOJISTAR, TA_OPTIONS(OPTIONAL_DOUBLE(optInPenetration))) +TA_LOOKBACK(CDLMORNINGSTAR, TA_OPTIONS(OPTIONAL_DOUBLE(optInPenetration))) +TA_LOOKBACK(CDLONNECK, TA_OPTIONS()) +TA_LOOKBACK(CDLPIERCING, TA_OPTIONS()) +TA_LOOKBACK(CDLRICKSHAWMAN, TA_OPTIONS()) +TA_LOOKBACK(CDLRISEFALL3METHODS, TA_OPTIONS()) +TA_LOOKBACK(CDLSEPARATINGLINES, TA_OPTIONS()) +TA_LOOKBACK(CDLSHOOTINGSTAR, TA_OPTIONS()) +TA_LOOKBACK(CDLSHORTLINE, TA_OPTIONS()) +TA_LOOKBACK(CDLSPINNINGTOP, TA_OPTIONS()) +TA_LOOKBACK(CDLSTALLEDPATTERN, TA_OPTIONS()) +TA_LOOKBACK(CDLSTICKSANDWICH, TA_OPTIONS()) +TA_LOOKBACK(CDLTAKURI, TA_OPTIONS()) +TA_LOOKBACK(CDLTASUKIGAP, TA_OPTIONS()) +TA_LOOKBACK(CDLTHRUSTING, TA_OPTIONS()) +TA_LOOKBACK(CDLTRISTAR, TA_OPTIONS()) +TA_LOOKBACK(CDLUNIQUE3RIVER, TA_OPTIONS()) +TA_LOOKBACK(CDLUPSIDEGAP2CROWS, TA_OPTIONS()) +TA_LOOKBACK(CDLXSIDEGAP3METHODS, TA_OPTIONS()) +TA_LOOKBACK(CEIL, TA_OPTIONS()) +TA_LOOKBACK(CMO, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(CORREL, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(COS, TA_OPTIONS()) +TA_LOOKBACK(COSH, TA_OPTIONS()) +TA_LOOKBACK(DEMA, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(DIV, TA_OPTIONS()) +TA_LOOKBACK(DX, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(EMA, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(EXP, TA_OPTIONS()) +TA_LOOKBACK(FLOOR, TA_OPTIONS()) +TA_LOOKBACK(HT_DCPERIOD, TA_OPTIONS()) +TA_LOOKBACK(HT_DCPHASE, TA_OPTIONS()) +TA_LOOKBACK(HT_PHASOR, TA_OPTIONS()) +TA_LOOKBACK(HT_SINE, TA_OPTIONS()) +TA_LOOKBACK(HT_TRENDLINE, TA_OPTIONS()) +TA_LOOKBACK(HT_TRENDMODE, TA_OPTIONS()) +TA_LOOKBACK(IMI, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(KAMA, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(LINEARREG, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(LINEARREG_ANGLE, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(LINEARREG_INTERCEPT, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(LINEARREG_SLOPE, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(LN, TA_OPTIONS()) +TA_LOOKBACK(LOG10, TA_OPTIONS()) +TA_LOOKBACK(MA, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod), OPTIONAL_MATYPE(optInMAType))) +TA_LOOKBACK(MACD, TA_OPTIONS(OPTIONAL_INTEGER(optInFastPeriod), OPTIONAL_INTEGER(optInSlowPeriod), OPTIONAL_INTEGER(optInSignalPeriod))) +TA_LOOKBACK(MACDEXT, TA_OPTIONS(OPTIONAL_INTEGER(optInFastPeriod), OPTIONAL_MATYPE(optInFastMAType), OPTIONAL_INTEGER(optInSlowPeriod), OPTIONAL_MATYPE(optInSlowMAType), OPTIONAL_INTEGER(optInSignalPeriod), OPTIONAL_MATYPE(optInSignalMAType))) +TA_LOOKBACK(MACDFIX, TA_OPTIONS(OPTIONAL_INTEGER(optInSignalPeriod))) +TA_LOOKBACK(MAMA, TA_OPTIONS(OPTIONAL_DOUBLE(optInFastLimit), OPTIONAL_DOUBLE(optInSlowLimit))) +TA_LOOKBACK(MAVP, TA_OPTIONS(OPTIONAL_INTEGER(optInMinPeriod), OPTIONAL_INTEGER(optInMaxPeriod), OPTIONAL_MATYPE(optInMAType))) +TA_LOOKBACK(MAX, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(MAXINDEX, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(MEDPRICE, TA_OPTIONS()) +TA_LOOKBACK(MFI, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(MIDPOINT, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(MIDPRICE, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(MIN, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(MININDEX, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(MINMAX, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(MINMAXINDEX, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(MINUS_DI, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(MINUS_DM, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(MOM, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(MULT, TA_OPTIONS()) +TA_LOOKBACK(NATR, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(OBV, TA_OPTIONS()) +TA_LOOKBACK(PLUS_DI, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(PLUS_DM, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(PPO, TA_OPTIONS(OPTIONAL_INTEGER(optInFastPeriod), OPTIONAL_INTEGER(optInSlowPeriod), OPTIONAL_MATYPE(optInMAType))) +TA_LOOKBACK(ROC, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(ROCP, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(ROCR, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(ROCR100, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(RSI, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(SAR, TA_OPTIONS(OPTIONAL_DOUBLE(optInAcceleration), OPTIONAL_DOUBLE(optInMaximum))) +TA_LOOKBACK(SAREXT, TA_OPTIONS(OPTIONAL_DOUBLE(optInStartValue), OPTIONAL_DOUBLE(optInOffsetOnReverse), OPTIONAL_DOUBLE(optInAccelerationInitLong), OPTIONAL_DOUBLE(optInAccelerationLong), OPTIONAL_DOUBLE(optInAccelerationMaxLong), OPTIONAL_DOUBLE(optInAccelerationInitShort), OPTIONAL_DOUBLE(optInAccelerationShort), OPTIONAL_DOUBLE(optInAccelerationMaxShort))) +TA_LOOKBACK(SIN, TA_OPTIONS()) +TA_LOOKBACK(SINH, TA_OPTIONS()) +TA_LOOKBACK(SMA, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(SQRT, TA_OPTIONS()) +TA_LOOKBACK(STDDEV, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod), OPTIONAL_DOUBLE(optInNbDev))) +TA_LOOKBACK(STOCH, TA_OPTIONS(OPTIONAL_INTEGER(optInFastK_Period), OPTIONAL_INTEGER(optInSlowK_Period), OPTIONAL_MATYPE(optInSlowK_MAType), OPTIONAL_INTEGER(optInSlowD_Period), OPTIONAL_MATYPE(optInSlowD_MAType))) +TA_LOOKBACK(STOCHF, TA_OPTIONS(OPTIONAL_INTEGER(optInFastK_Period), OPTIONAL_INTEGER(optInFastD_Period), OPTIONAL_MATYPE(optInFastD_MAType))) +TA_LOOKBACK(STOCHRSI, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod), OPTIONAL_INTEGER(optInFastK_Period), OPTIONAL_INTEGER(optInFastD_Period), OPTIONAL_MATYPE(optInFastD_MAType))) +TA_LOOKBACK(SUB, TA_OPTIONS()) +TA_LOOKBACK(SUM, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(T3, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod), OPTIONAL_DOUBLE(optInVFactor))) +TA_LOOKBACK(TAN, TA_OPTIONS()) +TA_LOOKBACK(TANH, TA_OPTIONS()) +TA_LOOKBACK(TEMA, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(TRANGE, TA_OPTIONS()) +TA_LOOKBACK(TRIMA, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(TRIX, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(TSF, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(TYPPRICE, TA_OPTIONS()) +TA_LOOKBACK(ULTOSC, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod1), OPTIONAL_INTEGER(optInTimePeriod2), OPTIONAL_INTEGER(optInTimePeriod3))) +TA_LOOKBACK(VAR, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod), OPTIONAL_DOUBLE(optInNbDev))) +TA_LOOKBACK(WCLPRICE, TA_OPTIONS()) +TA_LOOKBACK(WILLR, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +TA_LOOKBACK(WMA, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod))) +// clang-format on diff --git a/src/api.h b/src/api.h deleted file mode 100644 index b88475603..000000000 --- a/src/api.h +++ /dev/null @@ -1,274 +0,0 @@ -// Generated from codegen/generate_API.sh -#ifndef _API_H_ -#define _API_H_ - -#include - -// clang-format off -SEXP impl_ta_ACCBANDS_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); -SEXP impl_ta_ACCBANDS(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_AD_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP inVolume); -SEXP impl_ta_ADOSC_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP inVolume, SEXP optInFastPeriod, SEXP optInSlowPeriod); -SEXP impl_ta_ADOSC(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP inVolume, SEXP optInFastPeriod, SEXP optInSlowPeriod, SEXP na_bridge); -SEXP impl_ta_AD(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP inVolume, SEXP na_bridge); -SEXP impl_ta_ADX_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); -SEXP impl_ta_ADXR_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); -SEXP impl_ta_ADXR(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_ADX(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_APO_lookback(SEXP inReal, SEXP optInFastPeriod, SEXP optInSlowPeriod, SEXP optInMAType); -SEXP impl_ta_APO(SEXP inReal, SEXP optInFastPeriod, SEXP optInSlowPeriod, SEXP optInMAType, SEXP na_bridge); -SEXP impl_ta_AROON_lookback(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod); -SEXP impl_ta_AROONOSC_lookback(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod); -SEXP impl_ta_AROONOSC(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_AROON(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_ATR_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); -SEXP impl_ta_ATR(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_AVGPRICE_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_AVGPRICE(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP na_bridge); -SEXP impl_ta_BBANDS_lookback(SEXP inReal, SEXP optInTimePeriod, SEXP optInNbDevUp, SEXP optInNbDevDn, SEXP optInMAType); -SEXP impl_ta_BBANDS(SEXP inReal, SEXP optInTimePeriod, SEXP optInNbDevUp, SEXP optInNbDevDn, SEXP optInMAType, SEXP na_bridge); -SEXP impl_ta_BETA_lookback(SEXP inReal0, SEXP inReal1, SEXP optInTimePeriod); -SEXP impl_ta_BETA(SEXP inReal0, SEXP inReal1, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_BOP_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_BOP(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP na_bridge); -SEXP impl_ta_CCI_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); -SEXP impl_ta_CCI(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_CDL2CROWS_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDL2CROWS(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDL3BLACKCROWS_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDL3BLACKCROWS(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDL3INSIDE_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDL3INSIDE(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDL3LINESTRIKE_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDL3LINESTRIKE(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDL3OUTSIDE_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDL3OUTSIDE(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDL3STARSINSOUTH_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDL3STARSINSOUTH(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDL3WHITESOLDIERS_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDL3WHITESOLDIERS(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLABANDONEDBABY_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration); -SEXP impl_ta_CDLABANDONEDBABY(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLADVANCEBLOCK_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLADVANCEBLOCK(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLBELTHOLD_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLBELTHOLD(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLBREAKAWAY_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLBREAKAWAY(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLCLOSINGMARUBOZU_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLCLOSINGMARUBOZU(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLCONCEALBABYSWALL_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLCONCEALBABYSWALL(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLCOUNTERATTACK_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLCOUNTERATTACK(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLDARKCLOUDCOVER_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration); -SEXP impl_ta_CDLDARKCLOUDCOVER(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLDOJI_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLDOJI(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLDOJISTAR_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLDOJISTAR(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLDRAGONFLYDOJI_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLDRAGONFLYDOJI(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLENGULFING_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLENGULFING(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLEVENINGDOJISTAR_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration); -SEXP impl_ta_CDLEVENINGDOJISTAR(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLEVENINGSTAR_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration); -SEXP impl_ta_CDLEVENINGSTAR(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLGAPSIDESIDEWHITE_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLGAPSIDESIDEWHITE(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLGRAVESTONEDOJI_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLGRAVESTONEDOJI(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLHAMMER_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLHAMMER(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLHANGINGMAN_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLHANGINGMAN(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLHARAMICROSS_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLHARAMICROSS(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLHARAMI_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLHARAMI(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLHIGHWAVE_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLHIGHWAVE(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLHIKKAKE_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLHIKKAKEMOD_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLHIKKAKEMOD(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLHIKKAKE(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLHOMINGPIGEON_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLHOMINGPIGEON(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLIDENTICAL3CROWS_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLIDENTICAL3CROWS(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLINNECK_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLINNECK(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLINVERTEDHAMMER_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLINVERTEDHAMMER(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLKICKINGBYLENGTH_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLKICKINGBYLENGTH(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLKICKING_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLKICKING(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLLADDERBOTTOM_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLLADDERBOTTOM(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLLONGLEGGEDDOJI_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLLONGLEGGEDDOJI(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLLONGLINE_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLLONGLINE(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLMARUBOZU_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLMARUBOZU(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLMATCHINGLOW_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLMATCHINGLOW(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLMATHOLD_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration); -SEXP impl_ta_CDLMATHOLD(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLMORNINGDOJISTAR_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration); -SEXP impl_ta_CDLMORNINGDOJISTAR(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLMORNINGSTAR_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration); -SEXP impl_ta_CDLMORNINGSTAR(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInPenetration, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLONNECK_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLONNECK(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLPIERCING_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLPIERCING(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLRICKSHAWMAN_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLRICKSHAWMAN(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLRISEFALL3METHODS_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLRISEFALL3METHODS(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLSEPARATINGLINES_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLSEPARATINGLINES(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLSHOOTINGSTAR_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLSHOOTINGSTAR(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLSHORTLINE_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLSHORTLINE(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLSPINNINGTOP_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLSPINNINGTOP(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLSTALLEDPATTERN_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLSTALLEDPATTERN(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLSTICKSANDWICH_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLSTICKSANDWICH(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLTAKURI_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLTAKURI(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLTASUKIGAP_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLTASUKIGAP(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLTHRUSTING_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLTHRUSTING(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLTRISTAR_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLTRISTAR(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLUNIQUE3RIVER_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLUNIQUE3RIVER(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLUPSIDEGAP2CROWS_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLUPSIDEGAP2CROWS(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CDLXSIDEGAP3METHODS_lookback(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_CDLXSIDEGAP3METHODS(SEXP inOpen, SEXP inHigh, SEXP inLow, SEXP inClose, SEXP flag, SEXP na_bridge); -SEXP impl_ta_CMO_lookback(SEXP inReal, SEXP optInTimePeriod); -SEXP impl_ta_CMO(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_CORREL_lookback(SEXP inReal0, SEXP inReal1, SEXP optInTimePeriod); -SEXP impl_ta_CORREL(SEXP inReal0, SEXP inReal1, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_DEMA_lookback(SEXP inReal, SEXP optInTimePeriod); -SEXP impl_ta_DEMA(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_DX_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); -SEXP impl_ta_DX(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_EMA_lookback(SEXP inReal, SEXP optInTimePeriod); -SEXP impl_ta_EMA(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_HT_DCPERIOD_lookback(SEXP inReal); -SEXP impl_ta_HT_DCPERIOD(SEXP inReal, SEXP na_bridge); -SEXP impl_ta_HT_DCPHASE_lookback(SEXP inReal); -SEXP impl_ta_HT_DCPHASE(SEXP inReal, SEXP na_bridge); -SEXP impl_ta_HT_PHASOR_lookback(SEXP inReal); -SEXP impl_ta_HT_PHASOR(SEXP inReal, SEXP na_bridge); -SEXP impl_ta_HT_SINE_lookback(SEXP inReal); -SEXP impl_ta_HT_SINE(SEXP inReal, SEXP na_bridge); -SEXP impl_ta_HT_TRENDLINE_lookback(SEXP inReal); -SEXP impl_ta_HT_TRENDLINE(SEXP inReal, SEXP na_bridge); -SEXP impl_ta_HT_TRENDMODE_lookback(SEXP inReal); -SEXP impl_ta_HT_TRENDMODE(SEXP inReal, SEXP na_bridge); -SEXP impl_ta_IMI_lookback(SEXP inOpen, SEXP inClose, SEXP optInTimePeriod); -SEXP impl_ta_IMI(SEXP inOpen, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_KAMA_lookback(SEXP inReal, SEXP optInTimePeriod); -SEXP impl_ta_KAMA(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_MACDEXT_lookback(SEXP inReal, SEXP optInFastPeriod, SEXP optInFastMAType, SEXP optInSlowPeriod, SEXP optInSlowMAType, SEXP optInSignalPeriod, SEXP optInSignalMAType); -SEXP impl_ta_MACDEXT(SEXP inReal, SEXP optInFastPeriod, SEXP optInFastMAType, SEXP optInSlowPeriod, SEXP optInSlowMAType, SEXP optInSignalPeriod, SEXP optInSignalMAType, SEXP na_bridge); -SEXP impl_ta_MACDFIX_lookback(SEXP inReal, SEXP optInSignalPeriod); -SEXP impl_ta_MACDFIX(SEXP inReal, SEXP optInSignalPeriod, SEXP na_bridge); -SEXP impl_ta_MACD_lookback(SEXP inReal, SEXP optInFastPeriod, SEXP optInSlowPeriod, SEXP optInSignalPeriod); -SEXP impl_ta_MACD(SEXP inReal, SEXP optInFastPeriod, SEXP optInSlowPeriod, SEXP optInSignalPeriod, SEXP na_bridge); -SEXP impl_ta_MAMA_lookback(SEXP inReal, SEXP optInFastLimit, SEXP optInSlowLimit); -SEXP impl_ta_MAMA(SEXP inReal, SEXP optInFastLimit, SEXP optInSlowLimit, SEXP na_bridge); -SEXP impl_ta_MAX_lookback(SEXP inReal, SEXP optInTimePeriod); -SEXP impl_ta_MAX(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_MEDPRICE_lookback(SEXP inHigh, SEXP inLow); -SEXP impl_ta_MEDPRICE(SEXP inHigh, SEXP inLow, SEXP na_bridge); -SEXP impl_ta_MFI_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP inVolume, SEXP optInTimePeriod); -SEXP impl_ta_MFI(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP inVolume, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_MIDPRICE_lookback(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod); -SEXP impl_ta_MIDPRICE(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_MIN_lookback(SEXP inReal, SEXP optInTimePeriod); -SEXP impl_ta_MIN(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_MINUS_DI_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); -SEXP impl_ta_MINUS_DI(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_MINUS_DM_lookback(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod); -SEXP impl_ta_MINUS_DM(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_MOM_lookback(SEXP inReal, SEXP optInTimePeriod); -SEXP impl_ta_MOM(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_NATR_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); -SEXP impl_ta_NATR(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_OBV_lookback(SEXP inReal, SEXP inVolume); -SEXP impl_ta_OBV(SEXP inReal, SEXP inVolume, SEXP na_bridge); -SEXP impl_ta_PLUS_DI_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); -SEXP impl_ta_PLUS_DI(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_PLUS_DM_lookback(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod); -SEXP impl_ta_PLUS_DM(SEXP inHigh, SEXP inLow, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_PPO_lookback(SEXP inReal, SEXP optInFastPeriod, SEXP optInSlowPeriod, SEXP optInMAType); -SEXP impl_ta_PPO(SEXP inReal, SEXP optInFastPeriod, SEXP optInSlowPeriod, SEXP optInMAType, SEXP na_bridge); -SEXP impl_ta_ROC_lookback(SEXP inReal, SEXP optInTimePeriod); -SEXP impl_ta_ROCR_lookback(SEXP inReal, SEXP optInTimePeriod); -SEXP impl_ta_ROCR(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_ROC(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_RSI_lookback(SEXP inReal, SEXP optInTimePeriod); -SEXP impl_ta_RSI(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_SAREXT_lookback(SEXP inHigh, SEXP inLow, SEXP optInStartValue, SEXP optInOffsetOnReverse, SEXP optInAccelerationInitLong, SEXP optInAccelerationLong, SEXP optInAccelerationMaxLong, SEXP optInAccelerationInitShort, SEXP optInAccelerationShort, SEXP optInAccelerationMaxShort); -SEXP impl_ta_SAREXT(SEXP inHigh, SEXP inLow, SEXP optInStartValue, SEXP optInOffsetOnReverse, SEXP optInAccelerationInitLong, SEXP optInAccelerationLong, SEXP optInAccelerationMaxLong, SEXP optInAccelerationInitShort, SEXP optInAccelerationShort, SEXP optInAccelerationMaxShort, SEXP na_bridge); -SEXP impl_ta_SAR_lookback(SEXP inHigh, SEXP inLow, SEXP optInAcceleration, SEXP optInMaximum); -SEXP impl_ta_SAR(SEXP inHigh, SEXP inLow, SEXP optInAcceleration, SEXP optInMaximum, SEXP na_bridge); -SEXP impl_ta_SMA_lookback(SEXP inReal, SEXP optInTimePeriod); -SEXP impl_ta_SMA(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_STDDEV_lookback(SEXP inReal, SEXP optInTimePeriod, SEXP optInNbDev); -SEXP impl_ta_STDDEV(SEXP inReal, SEXP optInTimePeriod, SEXP optInNbDev, SEXP na_bridge); -SEXP impl_ta_STOCHF_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInFastK_Period, SEXP optInFastD_Period, SEXP optInFastD_MAType); -SEXP impl_ta_STOCHF(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInFastK_Period, SEXP optInFastD_Period, SEXP optInFastD_MAType, SEXP na_bridge); -SEXP impl_ta_STOCH_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInFastK_Period, SEXP optInSlowK_Period, SEXP optInSlowK_MAType, SEXP optInSlowD_Period, SEXP optInSlowD_MAType); -SEXP impl_ta_STOCHRSI_lookback(SEXP inReal, SEXP optInTimePeriod, SEXP optInFastK_Period, SEXP optInFastD_Period, SEXP optInFastD_MAType); -SEXP impl_ta_STOCHRSI(SEXP inReal, SEXP optInTimePeriod, SEXP optInFastK_Period, SEXP optInFastD_Period, SEXP optInFastD_MAType, SEXP na_bridge); -SEXP impl_ta_STOCH(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInFastK_Period, SEXP optInSlowK_Period, SEXP optInSlowK_MAType, SEXP optInSlowD_Period, SEXP optInSlowD_MAType, SEXP na_bridge); -SEXP impl_ta_SUM_lookback(SEXP inReal, SEXP optInTimePeriod); -SEXP impl_ta_SUM(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_T3_lookback(SEXP inReal, SEXP optInTimePeriod, SEXP optInVFactor); -SEXP impl_ta_T3(SEXP inReal, SEXP optInTimePeriod, SEXP optInVFactor, SEXP na_bridge); -SEXP impl_ta_TEMA_lookback(SEXP inReal, SEXP optInTimePeriod); -SEXP impl_ta_TEMA(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_TRANGE_lookback(SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_TRANGE(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP na_bridge); -SEXP impl_ta_TRIMA_lookback(SEXP inReal, SEXP optInTimePeriod); -SEXP impl_ta_TRIMA(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_TRIX_lookback(SEXP inReal, SEXP optInTimePeriod); -SEXP impl_ta_TRIX(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_TYPPRICE_lookback(SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_TYPPRICE(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP na_bridge); -SEXP impl_ta_ULTOSC_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod1, SEXP optInTimePeriod2, SEXP optInTimePeriod3); -SEXP impl_ta_ULTOSC(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod1, SEXP optInTimePeriod2, SEXP optInTimePeriod3, SEXP na_bridge); -SEXP impl_ta_VAR_lookback(SEXP inReal, SEXP optInTimePeriod, SEXP optInNbDev); -SEXP impl_ta_VAR(SEXP inReal, SEXP optInTimePeriod, SEXP optInNbDev, SEXP na_bridge); -SEXP impl_ta_VOLUME_lookback(SEXP inReal, SEXP maSpec); -SEXP impl_ta_VOLUME(SEXP inReal, SEXP maSpec, SEXP na_rm); -SEXP impl_ta_WCLPRICE_lookback(SEXP inHigh, SEXP inLow, SEXP inClose); -SEXP impl_ta_WCLPRICE(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP na_bridge); -SEXP impl_ta_WILLR_lookback(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod); -SEXP impl_ta_WILLR(SEXP inHigh, SEXP inLow, SEXP inClose, SEXP optInTimePeriod, SEXP na_bridge); -SEXP impl_ta_WMA_lookback(SEXP inReal, SEXP optInTimePeriod); -SEXP impl_ta_WMA(SEXP inReal, SEXP optInTimePeriod, SEXP na_bridge); -SEXP initialize_ta_lib(void); -SEXP map_dfr_double(SEXP x); -SEXP map_dfr_integer(SEXP x); -SEXP reset_candle_setting(void); -SEXP rownames_data_frame(SEXP x, SEXP rownames); -SEXP rownames_matrix(SEXP x, SEXP rownames, SEXP colnames); -SEXP set_candle_setting(SEXP s_settingType, SEXP s_rangeType, SEXP s_avgPeriod, SEXP s_factor); -SEXP shutdown_ta_lib(void); -// clang-format on - -#endif //_API_H diff --git a/src/attributes.c b/src/attributes.c index affe5bbb4..6ccf364c7 100644 --- a/src/attributes.c +++ b/src/attributes.c @@ -2,49 +2,67 @@ // // This 'C'-program sets the attributes of the // output container. -// - Its currently hardcoded for lookback only -// but it will be expanded if there is any demand -// for it. +// - Attributes are dispatched by a attribute tag so new +// attributes can be added without changing the call sites: +// add an enum entry and a case in attribute_symbol() below. // #include "attributes.h" +#include "Rinternals.h" -// initialize the lookback value -static SEXP lookback_value = NULL; - -// set lookback value -static inline SEXP ta_lookback(void) { - - if (lookback_value == NULL) { - lookback_value = Rf_install("lookback"); +// resolve (and cache) the R symbol for an attribute +// clang-format off +static SEXP attribute_symbol(attribute attr) { + switch (attr) { + case LOOKBACK: { + static SEXP lookback = NULL; + if (lookback == NULL) { + lookback = Rf_install("lookback"); + } + return lookback; + } } - - return lookback_value; + + return R_NilValue; } +// clang-format on + +// Normalize lookback values +// +// Description: +// TA-Lib returns 0 for indicators that can +// be calculated as-is, which from an R perspective +// makes no sense as it is not possible to calculate +// indicators on "nothing." The normalization here translates +// to minimum number of observations. +int normalize_lookback(int lookback) { return lookback <= 0 ? 1 : lookback; } -// workhorse function to -// set the attribute // clang-format off void set_attribute( - SEXP output_object, - int lookback, + SEXP x, // object + attribute attr, // attribute + SEXP attr_value, // attribute value int *protection_count ) // clang-format on { - // upstream returns -1 if the indicator and data pairs - // are invalid - -1 is handled on the R side but - // attributes needs to be handled here - some functions - // returns (weighted closing price, for one) returns lookback - // of zero; this has to be normalized to 1 (can't calculate values on nothing) - int normalized_lookback = - lookback < 0 ? lookback : (lookback < 1 ? 1 : lookback); - SEXP symbolic_value = ta_lookback(); - SEXP value = PROTECT(Rf_ScalarInteger(normalized_lookback)); + // clang-format off + switch (attr) { + case LOOKBACK: { + attr_value = Rf_ScalarInteger( + normalize_lookback( + Rf_asInteger(attr_value) + ) + ); + } + } + // clang-format on + + SEXP protected_value = PROTECT(attr_value); if (protection_count) { (*protection_count)++; } - Rf_setAttrib(output_object, symbolic_value, value); + Rf_setAttrib(x, attribute_symbol(attr), protected_value); } diff --git a/src/attributes.h b/src/attributes.h index c4bbf77f4..ee74b0003 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -7,6 +7,18 @@ // #include -void set_attribute(SEXP obj, int lookback, int *protection_count); +// Extensible attribute identifiers +// +// Description +// Add new attribute(s) here and process it in attribute_symbol() +// to implement it. +typedef enum { + LOOKBACK, +} attribute; + +void set_attribute( + SEXP obj, attribute attr, SEXP attr_value, int *protection_count); + +int normalize_lookback(int lookback); #endif /* ATTRIBUTES_H */ diff --git a/src/container.h b/src/container.h deleted file mode 100644 index 0cc2e71e0..000000000 --- a/src/container.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef _CONTAINER_H -#define _CONTAINER_H -// conainter.h -// -// This header file abstracts a big part of the -// of common function calls: -// -// output_container: -// A generic function for constructing a double or integer matrix -// which is determined by out_ptr. -// -// The function returns an integer which serves as flag for the remaining -// function which if 1 passes the call to TA-Lib, or exits the function -// otherwise. -// -// See ta_AD.c for an example on how to use it -#include "lib.h" -#include "names.h" -#include -#include -#include - -// double -// clang-format off -static inline int double_container( - int n, - int lookback, - int ncol, - SEXP *out_sexp, - double **out_ptr, - int *protect_count) { - // clang-format on - - // construct matrix and iterate - // protect counter - // clang-format off - SEXP matrix = PROTECT( - allocMatrix(REALSXP, n, ncol) - ); - - (*protect_count)++; - // clang-format on - - // construct pointers to - // matrix - *out_sexp = matrix; - *out_ptr = REAL(matrix); - - // if N is less than lookback - // the function returns with the - // same length - if (n < lookback) { - - Rf_warning( - "Input length (%d) is smaller than required lookback (%d).", - n, - lookback); - - const int total = n * ncol; - for (int i = 0; i < total; ++i) { - (*out_ptr)[i] = NA_REAL; - } - - return 0; - } - - return 1; -} - -// integer -// clang-format off -static inline int integer_container( - int n, - int lookback, - int ncol, - SEXP *out_sexp, - int **out_ptr, - int *protect_count) { - // clang-format on - - // construct matrix and iterate - // protect counter - // clang-format off - SEXP matrix = PROTECT( - allocMatrix(INTSXP, n, ncol) - ); - - (*protect_count)++; - // clang-format on - - // construct pointers to - // matrix - *out_sexp = matrix; - *out_ptr = INTEGER(matrix); - - // if N is less than lookback - // the function returns with the - // same length - if (n < lookback) { - - Rf_warning( - "Input length (%d) is smaller than required lookback (%d).", - n, - lookback); - - const int total = n * ncol; - for (int i = 0; i < total; ++i) - (*out_ptr)[i] = NA_INTEGER; - return 0; - } - - return 1; -} - -// check output -// -// -static inline void check_output(TA_RetCode x, int protect_count) { - - if (x != TA_SUCCESS) { - Rf_unprotect(protect_count); - Rf_error("Failed with code %d", x); - } -} - -// clang-format off -#define output_container(n, lookback, ncol, out_sexp, out_ptr, protect_count) \ - _Generic(*(out_ptr), double *: double_container, int *: integer_container) \ - ((n), (lookback), (ncol), (out_sexp), (out_ptr), (protect_count)) -// clang-format on - -#endif /* _CONTAINER_H */ diff --git a/src/dataframe.c b/src/data-frame.c similarity index 50% rename from src/dataframe.c rename to src/data-frame.c index add02c167..e44492cf4 100644 --- a/src/dataframe.c +++ b/src/data-frame.c @@ -1,10 +1,37 @@ -// dataframe.c +// data-frame.c +// +// Description: +// This C-routine converts a to a +// on the R-side. It is implemented specifically for {talib} +// and its portability across other packages are, at best, zero to none. +// The only reason it has been written is to reduce the time taken to convert +// a to (see benchmarks below) +// +// Benchmark: +// +// ``` r +// x <- as.matrix(mtcars) +// +// bench::mark( +// `{talib}` = talib:::map_dfr(x), +// `{base}` = as.data.frame(x) +// ) +// +// #> # A tibble: 2 × 6 +// #> expression min median `itr/sec` mem_alloc `gc/sec` +// #> +// #> 1 {talib} 1.72µs 2.56µs 372826. 1.88MB 0 +// #> 2 {base} 16.04µs 19.4µs 49028. 13.36KB 29.4 +// ``` +// +// Created on 2026-07-13 with [reprex +// v2.1.1](https://reprex.tidyverse.org) #include #include #include // clang-format off -static SEXP map_dfr_impl( +static SEXP impl_map_dfr( SEXP x, SEXPTYPE type ) @@ -14,7 +41,7 @@ static SEXP map_dfr_impl( int protection_counter = 0; // input dimensions - SEXP dim = getAttrib(x, R_DimSymbol); + SEXP dim = Rf_getAttrib(x, R_DimSymbol); const int nrows = INTEGER(dim)[0]; const int ncols = INTEGER(dim)[1]; @@ -23,26 +50,29 @@ static SEXP map_dfr_impl( // clang-format off SEXP data_frame = PROTECT( - allocVector(VECSXP, ncols) + Rf_allocVector(VECSXP, ncols) ); // clang-format on ++protection_counter; // construct columns + // + // Each column is stored straight into data_frame with SET_VECTOR_ELT and + // then filled. allocVector() returns the vector before SET_VECTOR_ELT runs, + // and SET_VECTOR_ELT itself does not allocate, so the fresh column is rooted + // in the already-protected data_frame with no intervening GC - no per-column + // PROTECT is needed, and the protection stack stays at constant depth. if (type == REALSXP) { const double *restrict x_ptr = REAL(x); const size_t col_bytes = nrow_len * sizeof(double); for (int j = 0; j < ncols; ++j) { - SEXP column = PROTECT(allocVector(REALSXP, nrows)); - ++protection_counter; + SEXP column = Rf_allocVector(REALSXP, nrows); + SET_VECTOR_ELT(data_frame, j, column); double *restrict column_ptr = REAL(column); - const double *restrict src = x_ptr + (size_t)j * nrows; memcpy(column_ptr, src, col_bytes); - - SET_VECTOR_ELT(data_frame, j, column); } } else { @@ -50,19 +80,17 @@ static SEXP map_dfr_impl( const size_t col_bytes = nrow_len * sizeof(int); for (int j = 0; j < ncols; ++j) { - SEXP column = PROTECT(allocVector(INTSXP, nrows)); - ++protection_counter; + SEXP column = Rf_allocVector(INTSXP, nrows); + SET_VECTOR_ELT(data_frame, j, column); int *restrict column_ptr = INTEGER(column); const int *restrict src = x_ptr + (size_t)j * nrows; memcpy(column_ptr, src, col_bytes); - - SET_VECTOR_ELT(data_frame, j, column); } } // dimension names - SEXP dimnames = getAttrib(x, R_DimNamesSymbol); + SEXP dimnames = Rf_getAttrib(x, R_DimNamesSymbol); SEXP row_names = (dimnames == R_NilValue) ? R_NilValue : VECTOR_ELT(dimnames, 0); SEXP col_names = @@ -72,37 +100,42 @@ static SEXP map_dfr_impl( // c(NA_integer_, -nrows) - same representation base R uses for // automatic row names - when the matrix carries no row dimnames. if (row_names == R_NilValue) { - row_names = PROTECT(allocVector(INTSXP, 2)); + row_names = PROTECT(Rf_allocVector(INTSXP, 2)); ++protection_counter; INTEGER(row_names)[0] = NA_INTEGER; INTEGER(row_names)[1] = -nrows; } - setAttrib(data_frame, R_RowNamesSymbol, row_names); - setAttrib(data_frame, R_NamesSymbol, col_names); + Rf_setAttrib(data_frame, R_RowNamesSymbol, row_names); + Rf_setAttrib(data_frame, R_NamesSymbol, col_names); // clang-format off SEXP class = PROTECT( - mkString("data.frame") + Rf_mkString("data.frame") ); // clang-format on ++protection_counter; - setAttrib(data_frame, R_ClassSymbol, class); + Rf_setAttrib(data_frame, R_ClassSymbol, class); UNPROTECT(protection_counter); return data_frame; } +// Map to +// +// Description: +// Exported functions that converts to . +// Integers and doubles are handled on the R-side via utils.R // clang-format off SEXP map_dfr_double(SEXP x) // clang-format on { - return map_dfr_impl(x, REALSXP); + return impl_map_dfr(x, REALSXP); } // clang-format off SEXP map_dfr_integer(SEXP x) // clang-format on { - return map_dfr_impl(x, INTSXP); -} + return impl_map_dfr(x, INTSXP); +} \ No newline at end of file diff --git a/src/init.c b/src/init.c index cc2fe0911..1d5ad3068 100644 --- a/src/init.c +++ b/src/init.c @@ -1,284 +1,116 @@ -// Generated from codegen/generate_FFI.sh -#include +// init.c +// +// Description: +// This is where TA-Lib.h is being ported to +// R, and is the workhorse of the R package. +// +// Author: Serkan Korkmaz +#include "ta_libc.h" +#include "utils.h" +#include "wrapper.h" #include #include -#include - -#include "api.h" +#include +// TA_DECL / TA_LB_DECL emit the forward declarations (prototypes) for the +// mined TA-Lib entry points. They reuse the argument-shape helpers from +// wrapper.h, so each prototype tracks its TA_WRAPPER-generated definition. // clang-format off -#define CALLDEF(name, n) {#name, (DL_FUNC) &name, n} +#define TA_DECL(NAME, RT, INS_, OPTS_, OUTS_, TA_OUTPUT_NAME_, KIND) \ + extern SEXP impl_ta_##NAME( \ + TA_APPLY(TA_IN_ARG, INS_) \ + TA_APPLY(TA_OPT_ARG, OPTS_) \ + SEXP s_na_bridge \ + TA_CAT(TA_NORM_ARG_, KIND) \ + ); // clang-format on +#define TA_LB_DECL(NAME, OPTS_) \ + extern SEXP impl_ta_##NAME##_lookback(TA_LB_PARAMS(OPTS_)); + +// forward declaration of all +// mined TA-Lib functions (indicator + lookback) +#define TA_INDICATOR(...) TA_DECL(__VA_ARGS__) +#define TA_LOOKBACK(...) TA_LB_DECL(__VA_ARGS__) +#include "TA-Lib.h" +#undef TA_INDICATOR +#undef TA_LOOKBACK + +// construct TA-Lib wrappers (indicator + lookback) +#define TA_INDICATOR(...) TA_WRAPPER(__VA_ARGS__) +#define TA_LOOKBACK(...) TA_LB_WRAPPER(__VA_ARGS__) +#include "TA-Lib.h" +#undef TA_INDICATOR +#undef TA_LOOKBACK + +// trading-volume wrappers (volume.c) +extern SEXP impl_ta_VOLUME(SEXP, SEXP, SEXP); +extern SEXP impl_ta_VOLUME_lookback(SEXP, SEXP); + +// global-setter wrappers (TA-Lib.c) +extern SEXP ta_set_unstable_period(SEXP, SEXP); +extern SEXP ta_set_compatibility(SEXP); +extern SEXP set_candle_setting(SEXP, SEXP, SEXP, SEXP); +extern SEXP reset_candle_setting(SEXP); +extern SEXP initialize_ta_lib(void); +extern SEXP map_dfr_double(SEXP); +extern SEXP map_dfr_integer(SEXP); +extern SEXP shutdown_ta_lib(void); + +// TA_REG / TA_LB_REG emit the R_CallMethodDef rows. Arity is derived from the +// same TA_COUNT_ARGUMENTS / TA_NORM_ARITY helpers the wrapper signature uses: +// indicator = #inputs + #opts + 1 (na_bridge) + candlestick normalize arg +// lookback = #opts +// The registration STRING (not the C symbol) is what R names the routine: +// with useDynLib(.fixes = "C_"), R exposes C_ + this string, matching the +// generated .Call(C_impl_ta_, ...). +#define TA_REG(NAME, RT, INS_, OPTS_, OUTS_, TA_OUTPUT_NAME_, KIND) \ + {"impl_ta_" #NAME, \ + (DL_FUNC) & impl_ta_##NAME, \ + (TA_COUNT_ARGUMENTS INS_) + (TA_COUNT_ARGUMENTS OPTS_) + 1 + \ + TA_CAT(TA_NORM_ARITY_, KIND)}, +#define TA_LB_REG(NAME, OPTS_) \ + {"impl_ta_" #NAME "_lookback", \ + (DL_FUNC) & impl_ta_##NAME##_lookback, \ + TA_COUNT_ARGUMENTS OPTS_}, static const R_CallMethodDef CallEntries[] = { - CALLDEF(impl_ta_ACCBANDS_lookback, 4), - CALLDEF(impl_ta_ACCBANDS, 5), - CALLDEF(impl_ta_AD_lookback, 4), - CALLDEF(impl_ta_ADOSC_lookback, 6), - CALLDEF(impl_ta_ADOSC, 7), - CALLDEF(impl_ta_AD, 5), - CALLDEF(impl_ta_ADX_lookback, 4), - CALLDEF(impl_ta_ADXR_lookback, 4), - CALLDEF(impl_ta_ADXR, 5), - CALLDEF(impl_ta_ADX, 5), - CALLDEF(impl_ta_APO_lookback, 4), - CALLDEF(impl_ta_APO, 5), - CALLDEF(impl_ta_AROON_lookback, 3), - CALLDEF(impl_ta_AROONOSC_lookback, 3), - CALLDEF(impl_ta_AROONOSC, 4), - CALLDEF(impl_ta_AROON, 4), - CALLDEF(impl_ta_ATR_lookback, 4), - CALLDEF(impl_ta_ATR, 5), - CALLDEF(impl_ta_AVGPRICE_lookback, 4), - CALLDEF(impl_ta_AVGPRICE, 5), - CALLDEF(impl_ta_BBANDS_lookback, 5), - CALLDEF(impl_ta_BBANDS, 6), - CALLDEF(impl_ta_BETA_lookback, 3), - CALLDEF(impl_ta_BETA, 4), - CALLDEF(impl_ta_BOP_lookback, 4), - CALLDEF(impl_ta_BOP, 5), - CALLDEF(impl_ta_CCI_lookback, 4), - CALLDEF(impl_ta_CCI, 5), - CALLDEF(impl_ta_CDL2CROWS_lookback, 4), - CALLDEF(impl_ta_CDL2CROWS, 6), - CALLDEF(impl_ta_CDL3BLACKCROWS_lookback, 4), - CALLDEF(impl_ta_CDL3BLACKCROWS, 6), - CALLDEF(impl_ta_CDL3INSIDE_lookback, 4), - CALLDEF(impl_ta_CDL3INSIDE, 6), - CALLDEF(impl_ta_CDL3LINESTRIKE_lookback, 4), - CALLDEF(impl_ta_CDL3LINESTRIKE, 6), - CALLDEF(impl_ta_CDL3OUTSIDE_lookback, 4), - CALLDEF(impl_ta_CDL3OUTSIDE, 6), - CALLDEF(impl_ta_CDL3STARSINSOUTH_lookback, 4), - CALLDEF(impl_ta_CDL3STARSINSOUTH, 6), - CALLDEF(impl_ta_CDL3WHITESOLDIERS_lookback, 4), - CALLDEF(impl_ta_CDL3WHITESOLDIERS, 6), - CALLDEF(impl_ta_CDLABANDONEDBABY_lookback, 5), - CALLDEF(impl_ta_CDLABANDONEDBABY, 7), - CALLDEF(impl_ta_CDLADVANCEBLOCK_lookback, 4), - CALLDEF(impl_ta_CDLADVANCEBLOCK, 6), - CALLDEF(impl_ta_CDLBELTHOLD_lookback, 4), - CALLDEF(impl_ta_CDLBELTHOLD, 6), - CALLDEF(impl_ta_CDLBREAKAWAY_lookback, 4), - CALLDEF(impl_ta_CDLBREAKAWAY, 6), - CALLDEF(impl_ta_CDLCLOSINGMARUBOZU_lookback, 4), - CALLDEF(impl_ta_CDLCLOSINGMARUBOZU, 6), - CALLDEF(impl_ta_CDLCONCEALBABYSWALL_lookback, 4), - CALLDEF(impl_ta_CDLCONCEALBABYSWALL, 6), - CALLDEF(impl_ta_CDLCOUNTERATTACK_lookback, 4), - CALLDEF(impl_ta_CDLCOUNTERATTACK, 6), - CALLDEF(impl_ta_CDLDARKCLOUDCOVER_lookback, 5), - CALLDEF(impl_ta_CDLDARKCLOUDCOVER, 7), - CALLDEF(impl_ta_CDLDOJI_lookback, 4), - CALLDEF(impl_ta_CDLDOJI, 6), - CALLDEF(impl_ta_CDLDOJISTAR_lookback, 4), - CALLDEF(impl_ta_CDLDOJISTAR, 6), - CALLDEF(impl_ta_CDLDRAGONFLYDOJI_lookback, 4), - CALLDEF(impl_ta_CDLDRAGONFLYDOJI, 6), - CALLDEF(impl_ta_CDLENGULFING_lookback, 4), - CALLDEF(impl_ta_CDLENGULFING, 6), - CALLDEF(impl_ta_CDLEVENINGDOJISTAR_lookback, 5), - CALLDEF(impl_ta_CDLEVENINGDOJISTAR, 7), - CALLDEF(impl_ta_CDLEVENINGSTAR_lookback, 5), - CALLDEF(impl_ta_CDLEVENINGSTAR, 7), - CALLDEF(impl_ta_CDLGAPSIDESIDEWHITE_lookback, 4), - CALLDEF(impl_ta_CDLGAPSIDESIDEWHITE, 6), - CALLDEF(impl_ta_CDLGRAVESTONEDOJI_lookback, 4), - CALLDEF(impl_ta_CDLGRAVESTONEDOJI, 6), - CALLDEF(impl_ta_CDLHAMMER_lookback, 4), - CALLDEF(impl_ta_CDLHAMMER, 6), - CALLDEF(impl_ta_CDLHANGINGMAN_lookback, 4), - CALLDEF(impl_ta_CDLHANGINGMAN, 6), - CALLDEF(impl_ta_CDLHARAMICROSS_lookback, 4), - CALLDEF(impl_ta_CDLHARAMICROSS, 6), - CALLDEF(impl_ta_CDLHARAMI_lookback, 4), - CALLDEF(impl_ta_CDLHARAMI, 6), - CALLDEF(impl_ta_CDLHIGHWAVE_lookback, 4), - CALLDEF(impl_ta_CDLHIGHWAVE, 6), - CALLDEF(impl_ta_CDLHIKKAKE_lookback, 4), - CALLDEF(impl_ta_CDLHIKKAKEMOD_lookback, 4), - CALLDEF(impl_ta_CDLHIKKAKEMOD, 6), - CALLDEF(impl_ta_CDLHIKKAKE, 6), - CALLDEF(impl_ta_CDLHOMINGPIGEON_lookback, 4), - CALLDEF(impl_ta_CDLHOMINGPIGEON, 6), - CALLDEF(impl_ta_CDLIDENTICAL3CROWS_lookback, 4), - CALLDEF(impl_ta_CDLIDENTICAL3CROWS, 6), - CALLDEF(impl_ta_CDLINNECK_lookback, 4), - CALLDEF(impl_ta_CDLINNECK, 6), - CALLDEF(impl_ta_CDLINVERTEDHAMMER_lookback, 4), - CALLDEF(impl_ta_CDLINVERTEDHAMMER, 6), - CALLDEF(impl_ta_CDLKICKINGBYLENGTH_lookback, 4), - CALLDEF(impl_ta_CDLKICKINGBYLENGTH, 6), - CALLDEF(impl_ta_CDLKICKING_lookback, 4), - CALLDEF(impl_ta_CDLKICKING, 6), - CALLDEF(impl_ta_CDLLADDERBOTTOM_lookback, 4), - CALLDEF(impl_ta_CDLLADDERBOTTOM, 6), - CALLDEF(impl_ta_CDLLONGLEGGEDDOJI_lookback, 4), - CALLDEF(impl_ta_CDLLONGLEGGEDDOJI, 6), - CALLDEF(impl_ta_CDLLONGLINE_lookback, 4), - CALLDEF(impl_ta_CDLLONGLINE, 6), - CALLDEF(impl_ta_CDLMARUBOZU_lookback, 4), - CALLDEF(impl_ta_CDLMARUBOZU, 6), - CALLDEF(impl_ta_CDLMATCHINGLOW_lookback, 4), - CALLDEF(impl_ta_CDLMATCHINGLOW, 6), - CALLDEF(impl_ta_CDLMATHOLD_lookback, 5), - CALLDEF(impl_ta_CDLMATHOLD, 7), - CALLDEF(impl_ta_CDLMORNINGDOJISTAR_lookback, 5), - CALLDEF(impl_ta_CDLMORNINGDOJISTAR, 7), - CALLDEF(impl_ta_CDLMORNINGSTAR_lookback, 5), - CALLDEF(impl_ta_CDLMORNINGSTAR, 7), - CALLDEF(impl_ta_CDLONNECK_lookback, 4), - CALLDEF(impl_ta_CDLONNECK, 6), - CALLDEF(impl_ta_CDLPIERCING_lookback, 4), - CALLDEF(impl_ta_CDLPIERCING, 6), - CALLDEF(impl_ta_CDLRICKSHAWMAN_lookback, 4), - CALLDEF(impl_ta_CDLRICKSHAWMAN, 6), - CALLDEF(impl_ta_CDLRISEFALL3METHODS_lookback, 4), - CALLDEF(impl_ta_CDLRISEFALL3METHODS, 6), - CALLDEF(impl_ta_CDLSEPARATINGLINES_lookback, 4), - CALLDEF(impl_ta_CDLSEPARATINGLINES, 6), - CALLDEF(impl_ta_CDLSHOOTINGSTAR_lookback, 4), - CALLDEF(impl_ta_CDLSHOOTINGSTAR, 6), - CALLDEF(impl_ta_CDLSHORTLINE_lookback, 4), - CALLDEF(impl_ta_CDLSHORTLINE, 6), - CALLDEF(impl_ta_CDLSPINNINGTOP_lookback, 4), - CALLDEF(impl_ta_CDLSPINNINGTOP, 6), - CALLDEF(impl_ta_CDLSTALLEDPATTERN_lookback, 4), - CALLDEF(impl_ta_CDLSTALLEDPATTERN, 6), - CALLDEF(impl_ta_CDLSTICKSANDWICH_lookback, 4), - CALLDEF(impl_ta_CDLSTICKSANDWICH, 6), - CALLDEF(impl_ta_CDLTAKURI_lookback, 4), - CALLDEF(impl_ta_CDLTAKURI, 6), - CALLDEF(impl_ta_CDLTASUKIGAP_lookback, 4), - CALLDEF(impl_ta_CDLTASUKIGAP, 6), - CALLDEF(impl_ta_CDLTHRUSTING_lookback, 4), - CALLDEF(impl_ta_CDLTHRUSTING, 6), - CALLDEF(impl_ta_CDLTRISTAR_lookback, 4), - CALLDEF(impl_ta_CDLTRISTAR, 6), - CALLDEF(impl_ta_CDLUNIQUE3RIVER_lookback, 4), - CALLDEF(impl_ta_CDLUNIQUE3RIVER, 6), - CALLDEF(impl_ta_CDLUPSIDEGAP2CROWS_lookback, 4), - CALLDEF(impl_ta_CDLUPSIDEGAP2CROWS, 6), - CALLDEF(impl_ta_CDLXSIDEGAP3METHODS_lookback, 4), - CALLDEF(impl_ta_CDLXSIDEGAP3METHODS, 6), - CALLDEF(impl_ta_CMO_lookback, 2), - CALLDEF(impl_ta_CMO, 3), - CALLDEF(impl_ta_CORREL_lookback, 3), - CALLDEF(impl_ta_CORREL, 4), - CALLDEF(impl_ta_DEMA_lookback, 2), - CALLDEF(impl_ta_DEMA, 3), - CALLDEF(impl_ta_DX_lookback, 4), - CALLDEF(impl_ta_DX, 5), - CALLDEF(impl_ta_EMA_lookback, 2), - CALLDEF(impl_ta_EMA, 3), - CALLDEF(impl_ta_HT_DCPERIOD_lookback, 1), - CALLDEF(impl_ta_HT_DCPERIOD, 2), - CALLDEF(impl_ta_HT_DCPHASE_lookback, 1), - CALLDEF(impl_ta_HT_DCPHASE, 2), - CALLDEF(impl_ta_HT_PHASOR_lookback, 1), - CALLDEF(impl_ta_HT_PHASOR, 2), - CALLDEF(impl_ta_HT_SINE_lookback, 1), - CALLDEF(impl_ta_HT_SINE, 2), - CALLDEF(impl_ta_HT_TRENDLINE_lookback, 1), - CALLDEF(impl_ta_HT_TRENDLINE, 2), - CALLDEF(impl_ta_HT_TRENDMODE_lookback, 1), - CALLDEF(impl_ta_HT_TRENDMODE, 2), - CALLDEF(impl_ta_IMI_lookback, 3), - CALLDEF(impl_ta_IMI, 4), - CALLDEF(impl_ta_KAMA_lookback, 2), - CALLDEF(impl_ta_KAMA, 3), - CALLDEF(impl_ta_MACDEXT_lookback, 7), - CALLDEF(impl_ta_MACDEXT, 8), - CALLDEF(impl_ta_MACDFIX_lookback, 2), - CALLDEF(impl_ta_MACDFIX, 3), - CALLDEF(impl_ta_MACD_lookback, 4), - CALLDEF(impl_ta_MACD, 5), - CALLDEF(impl_ta_MAMA_lookback, 3), - CALLDEF(impl_ta_MAMA, 4), - CALLDEF(impl_ta_MAX_lookback, 2), - CALLDEF(impl_ta_MAX, 3), - CALLDEF(impl_ta_MEDPRICE_lookback, 2), - CALLDEF(impl_ta_MEDPRICE, 3), - CALLDEF(impl_ta_MFI_lookback, 5), - CALLDEF(impl_ta_MFI, 6), - CALLDEF(impl_ta_MIDPRICE_lookback, 3), - CALLDEF(impl_ta_MIDPRICE, 4), - CALLDEF(impl_ta_MIN_lookback, 2), - CALLDEF(impl_ta_MIN, 3), - CALLDEF(impl_ta_MINUS_DI_lookback, 4), - CALLDEF(impl_ta_MINUS_DI, 5), - CALLDEF(impl_ta_MINUS_DM_lookback, 3), - CALLDEF(impl_ta_MINUS_DM, 4), - CALLDEF(impl_ta_MOM_lookback, 2), - CALLDEF(impl_ta_MOM, 3), - CALLDEF(impl_ta_NATR_lookback, 4), - CALLDEF(impl_ta_NATR, 5), - CALLDEF(impl_ta_OBV_lookback, 2), - CALLDEF(impl_ta_OBV, 3), - CALLDEF(impl_ta_PLUS_DI_lookback, 4), - CALLDEF(impl_ta_PLUS_DI, 5), - CALLDEF(impl_ta_PLUS_DM_lookback, 3), - CALLDEF(impl_ta_PLUS_DM, 4), - CALLDEF(impl_ta_PPO_lookback, 4), - CALLDEF(impl_ta_PPO, 5), - CALLDEF(impl_ta_ROC_lookback, 2), - CALLDEF(impl_ta_ROCR_lookback, 2), - CALLDEF(impl_ta_ROCR, 3), - CALLDEF(impl_ta_ROC, 3), - CALLDEF(impl_ta_RSI_lookback, 2), - CALLDEF(impl_ta_RSI, 3), - CALLDEF(impl_ta_SAREXT_lookback, 10), - CALLDEF(impl_ta_SAREXT, 11), - CALLDEF(impl_ta_SAR_lookback, 4), - CALLDEF(impl_ta_SAR, 5), - CALLDEF(impl_ta_SMA_lookback, 2), - CALLDEF(impl_ta_SMA, 3), - CALLDEF(impl_ta_STDDEV_lookback, 3), - CALLDEF(impl_ta_STDDEV, 4), - CALLDEF(impl_ta_STOCHF_lookback, 6), - CALLDEF(impl_ta_STOCHF, 7), - CALLDEF(impl_ta_STOCH_lookback, 8), - CALLDEF(impl_ta_STOCHRSI_lookback, 5), - CALLDEF(impl_ta_STOCHRSI, 6), - CALLDEF(impl_ta_STOCH, 9), - CALLDEF(impl_ta_SUM_lookback, 2), - CALLDEF(impl_ta_SUM, 3), - CALLDEF(impl_ta_T3_lookback, 3), - CALLDEF(impl_ta_T3, 4), - CALLDEF(impl_ta_TEMA_lookback, 2), - CALLDEF(impl_ta_TEMA, 3), - CALLDEF(impl_ta_TRANGE_lookback, 3), - CALLDEF(impl_ta_TRANGE, 4), - CALLDEF(impl_ta_TRIMA_lookback, 2), - CALLDEF(impl_ta_TRIMA, 3), - CALLDEF(impl_ta_TRIX_lookback, 2), - CALLDEF(impl_ta_TRIX, 3), - CALLDEF(impl_ta_TYPPRICE_lookback, 3), - CALLDEF(impl_ta_TYPPRICE, 4), - CALLDEF(impl_ta_ULTOSC_lookback, 6), - CALLDEF(impl_ta_ULTOSC, 7), - CALLDEF(impl_ta_VAR_lookback, 3), - CALLDEF(impl_ta_VAR, 4), - CALLDEF(impl_ta_VOLUME_lookback, 2), - CALLDEF(impl_ta_VOLUME, 3), - CALLDEF(impl_ta_WCLPRICE_lookback, 3), - CALLDEF(impl_ta_WCLPRICE, 4), - CALLDEF(impl_ta_WILLR_lookback, 4), - CALLDEF(impl_ta_WILLR, 5), - CALLDEF(impl_ta_WMA_lookback, 2), - CALLDEF(impl_ta_WMA, 3), - CALLDEF(initialize_ta_lib, 0), - CALLDEF(map_dfr_double, 1), - CALLDEF(map_dfr_integer, 1), - CALLDEF(reset_candle_setting, 0), - CALLDEF(rownames_data_frame, 2), - CALLDEF(rownames_matrix, 3), - CALLDEF(set_candle_setting, 4), - CALLDEF(shutdown_ta_lib, 0), +#define TA_INDICATOR(...) TA_REG(__VA_ARGS__) +#define TA_LOOKBACK(...) TA_LB_REG(__VA_ARGS__) +#include "TA-Lib.h" +#undef TA_INDICATOR +#undef TA_LOOKBACK + {"impl_ta_VOLUME", (DL_FUNC)&impl_ta_VOLUME, 3}, + {"impl_ta_VOLUME_lookback", (DL_FUNC)&impl_ta_VOLUME_lookback, 2}, + {"ta_set_unstable_period", (DL_FUNC)&ta_set_unstable_period, 2}, + {"ta_set_compatibility", (DL_FUNC)&ta_set_compatibility, 1}, + {"set_candle_setting", (DL_FUNC)&set_candle_setting, 4}, + {"reset_candle_setting", (DL_FUNC)&reset_candle_setting, 1}, + {"rownames_data_frame", (DL_FUNC)&rownames_data_frame, 2}, + {"rownames_matrix", (DL_FUNC)&rownames_matrix, 3}, + {"map_dfr_double", (DL_FUNC)&map_dfr_double, 1}, + {"map_dfr_integer", (DL_FUNC)&map_dfr_integer, 1}, + {"initialize_ta_lib", (DL_FUNC)&initialize_ta_lib, 0}, + {"shutdown_ta_lib", (DL_FUNC)&shutdown_ta_lib, 0}, {NULL, NULL, 0}}; +// Initialize/Unload {talib} +// +// This section corresponds to zzz.R regarding load()/library() +// and unload() and it will initialize/shutdown TA-Lib when needed +// +// void R_init_talib(DllInfo *dll) { + + if (TA_Initialize() != TA_SUCCESS) { + Rf_error("TA_Initialize() failed"); + } + R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); R_useDynamicSymbols(dll, FALSE); R_forceSymbols(dll, TRUE); } + +void R_unload_talib(DllInfo *dll) { + (void)dll; + TA_Shutdown(); +} diff --git a/src/lib.h b/src/lib.h deleted file mode 100644 index b1b7a29de..000000000 --- a/src/lib.h +++ /dev/null @@ -1,29 +0,0 @@ -// lib.h -// -// Description -// Common high-level TA-lib agnostic functionality -// and other implementations -#ifndef _LIB_H_ -#define _LIB_H_ - -#define R_RANDOM_H -// R Headers -#include -#include -#include - -#undef R_RANDOM_H - -// C Headers -#include "shift.h" -#include - -// Redifne integers to avoid -// R definition clashes -// clang-format off -#define Int32 TA_Lib_Int32 - #include -#undef Int32 -// clang-format on - -#endif // _LIB_H_ \ No newline at end of file diff --git a/src/na.h b/src/na.h deleted file mode 100644 index 23541b250..000000000 --- a/src/na.h +++ /dev/null @@ -1,187 +0,0 @@ -// na.h -// -// C-level NA handling for the na.ignore parameter. -// -// Provides: -// build_na_mask - scan input arrays, build boolean mask, return clean count -// compact_array - copy non-masked elements into a compact buffer -// reexpand_double_matrix - re-expand compact double output to full size -// reexpand_int_matrix - re-expand compact int output to full size -// reexpand_matrix - generic dispatch via _Generic -// -#ifndef _NA_H -#define _NA_H - -#include -#include -#include - -// Build NA mask from multiple double input arrays. -// mask[i] = 1 if any array has NA/NaN at position i. -// Returns count of non-NA rows. -// clang-format off -static inline int build_na_mask( - int *mask, - int n, - int n_arrays, - const double *const *arrays -) { - // clang-format on - int clean = 0; - for (int i = 0; i < n; i++) { - mask[i] = 0; - for (int j = 0; j < n_arrays; j++) { - if (ISNAN(arrays[j][i])) { - mask[i] = 1; - break; - } - } - if (!mask[i]) - clean++; - } - return clean; -} - -// Copy non-masked elements from src to dest. -// clang-format off -static inline void compact_array( - double *restrict dest, - const double *restrict src, - const int *mask, - int n -) { - // clang-format on - int j = 0; - for (int i = 0; i < n; i++) { - if (!mask[i]) - dest[j++] = src[i]; - } -} - -// Compact multiple input arrays in-place. -// For each pointer in ptrs[], allocates a clean buffer via R_alloc, -// copies non-masked elements into it, and replaces the pointer. -// clang-format off -static inline void compact_arrays( - const double **ptrs, - int n_arrays, - const int *mask, - int n_original, - int n_clean -) { - // clang-format on - for (int j = 0; j < n_arrays; j++) { - double *buf = (double *)R_alloc(n_clean, sizeof(double)); - compact_array(buf, ptrs[j], mask, n_original); - ptrs[j] = buf; - } -} - -// Re-expand a compact double matrix to full size, -// inserting NA_REAL at masked positions. -// Returns new PROTECTed SEXP; increments protection_count. -// clang-format off -static inline SEXP reexpand_double_matrix( - SEXP compact, - const int *mask, - int n_full, - int *protection_count -) { - // clang-format on - const int ncol = Rf_ncols(compact); - const int n_compact = Rf_nrows(compact); - - SEXP full = PROTECT(allocMatrix(REALSXP, n_full, ncol)); - (*protection_count)++; - - const double *src = REAL(compact); - double *dest = REAL(full); - - for (int col = 0; col < ncol; col++) { - const double *s = src + col * n_compact; - double *d = dest + col * n_full; - int j = 0; - for (int i = 0; i < n_full; i++) { - d[i] = mask[i] ? NA_REAL : s[j++]; - } - } - - // copy dimnames (column names) - SEXP dn = Rf_getAttrib(compact, R_DimNamesSymbol); - if (dn != R_NilValue) { - SEXP new_dn = PROTECT(Rf_allocVector(VECSXP, 2)); - (*protection_count)++; - SET_VECTOR_ELT(new_dn, 0, R_NilValue); - SET_VECTOR_ELT(new_dn, 1, VECTOR_ELT(dn, 1)); - Rf_dimnamesgets(full, new_dn); - } - - // copy lookback attribute - SEXP lb = Rf_getAttrib(compact, Rf_install("lookback")); - if (lb != R_NilValue) { - Rf_setAttrib(full, Rf_install("lookback"), lb); - } - - return full; -} - -// Re-expand a compact integer matrix to full size, -// inserting NA_INTEGER at masked positions. -// Returns new PROTECTed SEXP; increments protection_count. -// clang-format off -static inline SEXP reexpand_int_matrix( - SEXP compact, - const int *mask, - int n_full, - int *protection_count -) { - // clang-format on - const int ncol = Rf_ncols(compact); - const int n_compact = Rf_nrows(compact); - - SEXP full = PROTECT(allocMatrix(INTSXP, n_full, ncol)); - (*protection_count)++; - - const int *src = INTEGER(compact); - int *dest = INTEGER(full); - - for (int col = 0; col < ncol; col++) { - const int *s = src + col * n_compact; - int *d = dest + col * n_full; - int j = 0; - for (int i = 0; i < n_full; i++) { - d[i] = mask[i] ? NA_INTEGER : s[j++]; - } - } - - // copy dimnames (column names) - SEXP dn = Rf_getAttrib(compact, R_DimNamesSymbol); - if (dn != R_NilValue) { - SEXP new_dn = PROTECT(Rf_allocVector(VECSXP, 2)); - (*protection_count)++; - SET_VECTOR_ELT(new_dn, 0, R_NilValue); - SET_VECTOR_ELT(new_dn, 1, VECTOR_ELT(dn, 1)); - Rf_dimnamesgets(full, new_dn); - } - - // copy lookback attribute - SEXP lb = Rf_getAttrib(compact, Rf_install("lookback")); - if (lb != R_NilValue) { - Rf_setAttrib(full, Rf_install("lookback"), lb); - } - - return full; -} - -// Generic re-expand dispatch based on output pointer type. -// Usage: output = reexpand_matrix(output, output_ptr, na_mask, n_original, -// &protection_count); -// clang-format off -#define reexpand_matrix(compact, out_ptr, mask, n_full, pcount) \ - _Generic(*(out_ptr), \ - double: reexpand_double_matrix, \ - int: reexpand_int_matrix \ - )((compact), (mask), (n_full), (pcount)) -// clang-format on - -#endif /* _NA_H */ diff --git a/src/names.c b/src/names.c index 018991319..afea23cdb 100644 --- a/src/names.c +++ b/src/names.c @@ -1,3 +1,46 @@ +#include "names.h" + +// Column Names +// +// Description: +// Set the column names of the -object +// clang-format off +void set_colnames( + SEXP x, // assumed to be a matrix + const char *const *names, + int k // columns +) +// clang-format on +{ + // protection counter + int protection_counter = 0; + + // clang-format off + SEXP dimensions = PROTECT( + Rf_allocVector(VECSXP, 2) + ); + protection_counter++; + + SEXP colnames = PROTECT( + Rf_allocVector(STRSXP, k) + ); + protection_counter++; + // clang-format on + + for (int j = 0; j < k; j++) { + SET_STRING_ELT(colnames, j, Rf_mkChar(names[j])); + } + + SET_VECTOR_ELT(dimensions, 0, R_NilValue); + SET_VECTOR_ELT(dimensions, 1, colnames); + + // set attributes of + // the underlying + Rf_setAttrib(x, R_DimNamesSymbol, dimensions); + + UNPROTECT(protection_counter); +} + // names.c // // When using rownames(x) <- x_names from R @@ -17,23 +60,21 @@ // // NOTE: If colnames is NOT passed in matrix methods // it will crash. -#include -#include -#include // clang-format off -SEXP rownames_data_frame( +void rownames_data_frame( SEXP x, SEXP rownames ) // clang-format on { - setAttrib(x, R_RowNamesSymbol, rownames); - return R_NilValue; + Rf_setAttrib(x, R_RowNamesSymbol, rownames); + + return; } // clang-format off -SEXP rownames_matrix( +void rownames_matrix( SEXP x, SEXP rownames, SEXP colnames @@ -42,15 +83,16 @@ SEXP rownames_matrix( { // clang-format off SEXP container = PROTECT( - allocVector(VECSXP, 2) + Rf_allocVector(VECSXP, 2) ); // clang-format on SET_VECTOR_ELT(container, 0, rownames); SET_VECTOR_ELT(container, 1, colnames); - setAttrib(x, R_DimNamesSymbol, container); + Rf_setAttrib(x, R_DimNamesSymbol, container); UNPROTECT(1); - return R_NilValue; -} + + return; +} \ No newline at end of file diff --git a/src/names.h b/src/names.h index 1ebcc42eb..3c9d04916 100644 --- a/src/names.h +++ b/src/names.h @@ -1,34 +1,10 @@ -// names -// -// Description -// Set names of matrices -#ifndef _names_h -#define _names_h +#ifndef NAMES_H +#define NAMES_H -#include #include -static inline void -column_names(SEXP x, int n_cols, const char *const *colnames) { +void set_colnames(SEXP x, const char *const *names, int k); +void rownames_data_frame(SEXP x, SEXP rownames); +void rownames_matrix(SEXP x, SEXP rownames, SEXP colnames); - SEXP dn = PROTECT(Rf_allocVector(VECSXP, 2)); - SEXP cn = PROTECT(Rf_allocVector(STRSXP, n_cols)); - for (int j = 0; j < n_cols; ++j) { - SET_STRING_ELT(cn, j, Rf_mkCharCE(colnames[j], CE_UTF8)); - } - - SET_VECTOR_ELT(dn, 0, R_NilValue); - SET_VECTOR_ELT(dn, 1, cn); - Rf_dimnamesgets(x, dn); - UNPROTECT(2); -} - -// clang-format off -#define set_colnames(x, ...) \ - do { \ - const char *_cn_[] = {__VA_ARGS__}; \ - column_names((x), (int) (sizeof _cn_ / sizeof *_cn_), _cn_); \ - } while (0) -// clang-format on - -#endif // _names_h \ No newline at end of file +#endif /* NAMES_H */ diff --git a/src/normalize.h b/src/normalize.h index 1277bcb62..dba9616b3 100644 --- a/src/normalize.h +++ b/src/normalize.h @@ -1,4 +1,4 @@ -// normalize +// normalize.h // // Parameters // arr: The array to be normalized. Double or int pointer @@ -11,7 +11,7 @@ // This function modifies the array in-place by scaling with // a factor. The shifting parameter sets the starting point // of the iterator. -// Its necesseary because the ta_CDL*.c programs returns -100, 0, 100 +// Its necessary because the ta_CDL*.c programs returns -100, 0, 100 // which is not R agnostic. // // Note @@ -42,82 +42,4 @@ static inline void normalize_int(int *arr, int n, int factor, int shift) { #define normalize(arr, n, factor, shift) _Generic((arr), double*: normalize_double, int*: normalize_int)((arr),(n),(factor), (shift)) // clang-format on -// normalize_int_to_real -// -// Parameters -// integer_matrix: INTSXP matrix (candlestick output after shift and reexpand) -// divisor: The factor to divide by (typically 100.0) -// has_scattered_na: Whether NA values exist beyond the lookback -// region. Set to 1 when na_ignore reexpansion was -// performed, 0 otherwise. -// protection_count: Pointer to the PROTECT counter -// -// Description -// Converts an INTSXP matrix to REALSXP by dividing each element -// by divisor. The leading lookback region is filled with NA_REAL -// directly (no division). When has_scattered_na is 0 (the common -// path), the data region is divided unconditionally with no -// per-element NA check. When has_scattered_na is 1, elements -// equal to NA_INTEGER are mapped to NA_REAL. -// -// Returns a PROTECTed REALSXP matrix with dimnames and -// lookback attribute copied from the input. -static inline SEXP normalize_int_to_real( - SEXP integer_matrix, - double divisor, - int has_scattered_na, - int *protection_count) { - const int num_rows = Rf_nrows(integer_matrix); - const int num_cols = Rf_ncols(integer_matrix); - const int total_elements = num_rows * num_cols; - - SEXP lookback_sexp = Rf_getAttrib(integer_matrix, Rf_install("lookback")); - const int lookback_length = - (lookback_sexp != R_NilValue) ? INTEGER(lookback_sexp)[0] : 0; - - SEXP real_matrix = PROTECT(allocMatrix(REALSXP, num_rows, num_cols)); - (*protection_count)++; - - const int *source_values = INTEGER(integer_matrix); - double *destination_values = REAL(real_matrix); - - // leading NA region: write NA_REAL directly - for (int i = 0; i < lookback_length; i++) { - destination_values[i] = NA_REAL; - } - - // data region - if (has_scattered_na) { - // safe path: check each element for NA_INTEGER - // (needed after na_ignore reexpansion inserts scattered NAs) - for (int i = lookback_length; i < total_elements; i++) { - destination_values[i] = (source_values[i] == NA_INTEGER) - ? NA_REAL - : (double)source_values[i] / divisor; - } - } else { - // fast path: no scattered NAs, unconditional division - for (int i = lookback_length; i < total_elements; i++) { - destination_values[i] = (double)source_values[i] / divisor; - } - } - - // copy dimnames (column names) - SEXP dimnames_sexp = Rf_getAttrib(integer_matrix, R_DimNamesSymbol); - if (dimnames_sexp != R_NilValue) { - SEXP new_dimnames = PROTECT(Rf_allocVector(VECSXP, 2)); - (*protection_count)++; - SET_VECTOR_ELT(new_dimnames, 0, R_NilValue); - SET_VECTOR_ELT(new_dimnames, 1, VECTOR_ELT(dimnames_sexp, 1)); - Rf_dimnamesgets(real_matrix, new_dimnames); - } - - // copy lookback attribute - if (lookback_sexp != R_NilValue) { - Rf_setAttrib(real_matrix, Rf_install("lookback"), lookback_sexp); - } - - return real_matrix; -} - -#endif /* _NORMALIZE_H */ \ No newline at end of file +#endif /* _NORMALIZE_H */ diff --git a/src/preprocessor.h b/src/preprocessor.h new file mode 100644 index 000000000..e08a63e15 --- /dev/null +++ b/src/preprocessor.h @@ -0,0 +1,64 @@ +// preprocessor.h +// +// Generic preprocessor metaprogramming primitives +// (token paste, arg count, list map/join) used to +// drive the TA_WRAPPER X-macros. +#ifndef PREPROCESSOR_H +#define PREPROCESSOR_H + +// Token pasting with argument pre-expansion. +#define TA_CAT(a, b) TA_CAT_(a, b) +#define TA_CAT_(a, b) a##b + +// Strip parenthesis from an expression - +// can be used as follows: TA_STRIP_PARENTHESIS (a,b) -> a, b +#define TA_STRIP_PARENTHESIS(...) __VA_ARGS__ + +// HEAD, used via juxtaposition against a parenthesised group to pull the +// first element: TA_HEAD (a,b,c) -> a ; TA_HEAD (a) -> a +#define TA_HEAD(a, ...) a + +// Count the number of arguments given +// an expression - can be used as follows: +// #define FOO(SOME_MACRO_VALUE_) (TA_COUNT_ARGUMENTS SOME_MACRO_VALUE_) +#define TA_COUNT_ARGUMENTS(...) \ + TA_COUNT_ARGUMENTS_(0 __VA_OPT__(, ) __VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1, 0) +#define TA_COUNT_ARGUMENTS_(_0, _1, _2, _3, _4, _5, _6, _7, _8, N, ...) N + +// Apply worker m(x) to each element of a PARENTHESISED group (0..8 elements), +// results space-separated. The two indirections (TA_APPLY_D/_D_) let +// TA_COUNT_ARGUMENTS and TA_STRIP_PARENTHESIS of the group expand — revealing +// the element commas — before the TA_APPLY_ dispatcher enumerates them. +#define TA_APPLY(m, group) \ + TA_APPLY_D(m, TA_COUNT_ARGUMENTS group, TA_STRIP_PARENTHESIS group) +#define TA_APPLY_D(m, n, ...) TA_APPLY_D_(m, n, __VA_ARGS__) +#define TA_APPLY_D_(m, n, ...) TA_CAT(TA_APPLY_, n)(m, __VA_ARGS__) +#define TA_APPLY_0(m, ...) +#define TA_APPLY_1(m, a) m(a) +#define TA_APPLY_2(m, a, ...) m(a) TA_APPLY_1(m, __VA_ARGS__) +#define TA_APPLY_3(m, a, ...) m(a) TA_APPLY_2(m, __VA_ARGS__) +#define TA_APPLY_4(m, a, ...) m(a) TA_APPLY_3(m, __VA_ARGS__) +#define TA_APPLY_5(m, a, ...) m(a) TA_APPLY_4(m, __VA_ARGS__) +#define TA_APPLY_6(m, a, ...) m(a) TA_APPLY_5(m, __VA_ARGS__) +#define TA_APPLY_7(m, a, ...) m(a) TA_APPLY_6(m, __VA_ARGS__) +#define TA_APPLY_8(m, a, ...) m(a) TA_APPLY_7(m, __VA_ARGS__) + +// Like TA_APPLY, but the worker results are separated by commas (not +// juxtaposed) and there is no trailing comma - i.e. a valid function-call +// argument list. Used to synthesise TA__Lookback() in wrapper.h. +// An empty group expands to nothing (the (void) lookbacks). +#define TA_JOIN(m, group) \ + TA_JOIN_D(m, TA_COUNT_ARGUMENTS group, TA_STRIP_PARENTHESIS group) +#define TA_JOIN_D(m, n, ...) TA_JOIN_D_(m, n, __VA_ARGS__) +#define TA_JOIN_D_(m, n, ...) TA_CAT(TA_JOIN_, n)(m, __VA_ARGS__) +#define TA_JOIN_0(m, ...) +#define TA_JOIN_1(m, a) m(a) +#define TA_JOIN_2(m, a, ...) m(a), TA_JOIN_1(m, __VA_ARGS__) +#define TA_JOIN_3(m, a, ...) m(a), TA_JOIN_2(m, __VA_ARGS__) +#define TA_JOIN_4(m, a, ...) m(a), TA_JOIN_3(m, __VA_ARGS__) +#define TA_JOIN_5(m, a, ...) m(a), TA_JOIN_4(m, __VA_ARGS__) +#define TA_JOIN_6(m, a, ...) m(a), TA_JOIN_5(m, __VA_ARGS__) +#define TA_JOIN_7(m, a, ...) m(a), TA_JOIN_6(m, __VA_ARGS__) +#define TA_JOIN_8(m, a, ...) m(a), TA_JOIN_7(m, __VA_ARGS__) + +#endif /* PREPROCESSOR_H */ diff --git a/src/shift.c b/src/shift.c new file mode 100644 index 000000000..f03ea47da --- /dev/null +++ b/src/shift.c @@ -0,0 +1,112 @@ + +// Shift array +// +// Parameters +// col: the array to be shifted. Double or int pointer +// n: the size of the input array. Int. +// begIdx: the amount of shifting. Int. +// nbElement: +// +// Description +// This function shifts an array to the right, or down in memory, and adds +// leading NAs from 0 to the shift value. +// +// Details +// arr + shift advances pointer, ie. shifts +// the entire array in memory. So an array of +// {0,1,2} shifted with 1 does {garbage value, 1, +// 2}, a shift by 0 just returns the {0,1,2} array +// +// Generic +// It has a generic version shift_array(...) +// +// Note +// See: https://gist.github.com/barosl/e0af4a92b2b8cabd05a7 +// See: +// https://stackoverflow.com/questions/479207/how-to-achieve-function-overloading-in-c +// See: +// https://stackoverflow.com/questions/479207/how-to-achieve-function-overloading-in-c/25026358#25026358 +#include "shift.h" +#include +// clang-format off +#define MAX(x, y) (((x) < (y)) ? (y) : (x)) +#define MIN(x, y) (((x) < (y)) ? (x) : (y)) +void shift_double_array( + double *col, + R_xlen_t n, + int begIdx, + int nbElement +) +// clang-format on +{ + // clip begIdx between 0 and n + begIdx = MIN(MAX(begIdx, 0), (int)n); + + // clip nbElement between 0 and n - begIdx + // clang-format off + nbElement = MAX(nbElement, 0); + nbElement = (int) MIN( + (R_xlen_t) nbElement, + n - (R_xlen_t) begIdx + ); + // clang-format on + + // clang-format off + memmove( + col + begIdx, + col, + (size_t)nbElement * sizeof(double) + ); + // clang-format on + + // padding + for (R_xlen_t i = 0; i < begIdx; i++) { + col[i] = NA_REAL; + } + + for (R_xlen_t i = (R_xlen_t)begIdx + nbElement; i < n; i++) { + col[i] = NA_REAL; + } +} + +// clang-format off +void shift_integer_array( + int *col, + R_xlen_t n, + int begIdx, + int nbElement +) +// clang-format on +{ + + // clip begIdx between 0 and n + begIdx = MIN(MAX(begIdx, 0), (int)n); + + // clip nbElement between 0 and n - begIdx + // clang-format off + nbElement = MAX(nbElement, 0); + nbElement = (int) MIN( + (R_xlen_t) nbElement, + n - (R_xlen_t) begIdx + ); + // clang-format on + + // clang-format off + memmove( + col + begIdx, + col, + (size_t)nbElement * sizeof(int) + ); + // clang-format on + + // padding + for (R_xlen_t i = 0; i < begIdx; i++) { + col[i] = NA_INTEGER; + } + for (R_xlen_t i = (R_xlen_t)begIdx + nbElement; i < n; i++) { + col[i] = NA_INTEGER; + } +} +#undef MAX +#undef MIN +// shift array end \ No newline at end of file diff --git a/src/shift.h b/src/shift.h index 7ceedf348..f80040d13 100644 --- a/src/shift.h +++ b/src/shift.h @@ -1,113 +1,20 @@ -// shift_array -// -// Parameters -// arr: the array to be shifted. Double or int pointer -// len: the size of the input array. Int. -// shift: the amount of shifting. Int. -// -// Description -// This function shifts an array to the right, or down in memory, and adds -// leading NAs from 0 to the shift value. -// -// Details -// arr + shift advances pointer, ie. shifts -// the entire array in memory. So an array of -// {0,1,2} shifted with 1 does {garbage value, 1, -// 2}, a shift by 0 just returns the {0,1,2} array -// -// Note -// See: https://gist.github.com/barosl/e0af4a92b2b8cabd05a7 -// See: -// https://stackoverflow.com/questions/479207/how-to-achieve-function-overloading-in-c -// See: -// https://stackoverflow.com/questions/479207/how-to-achieve-function-overloading-in-c/25026358#25026358 -// -// -// shift each array -// -// NOTE: There is most likely a better -// way to do this. But as it is, -// this move costs 3 x 5.33 ms for a -// normally distributed double vector of -// of length 1e7; the SMA costs 57ms -// its 10% overhead, which is alot. But -// if anyone is doing calculations on 1e7 -// they probably have bigger thing to worry -// about. -#ifndef _SHIFT_H -#define _SHIFT_H +#ifndef SHIFT_H +#define SHIFT_H -#include "R_ext/Arith.h" -#include +#include -static void shift_double_array(double *arr, int len, int shift) { - // 0) edge-case: - // If the shift is greater than - // the length of the array, or the shift - // is lte 0, everything is NA. - // - // **NOTE:** this is highly unlikely but - // added just in case to avoid crashes. - // - // It could probably be a better idea just - // terminate the function instead. - if (shift < 0 || shift >= len) { - for (int i = 0; i < len; ++i) { - arr[i] = NA_REAL; - } - return; - } - - // 1) shift the arrayy - // in place - memmove( - /*dest:*/ arr + shift, - /*src*/ arr, - /*n*/ (size_t)(len - shift) * sizeof(double)); - - // 2) add leading NAs - // as NA_REAL for - // type compatibility - for (int i = 0; i < shift; ++i) { - arr[i] = NA_REAL; - } -} - -static void shift_int_array(int *arr, int len, int shift) { - // 0) edge-case: - // If the shift is greater than - // the length of the array, or the shift - // is lte 0, everything is NA. - // - // **NOTE:** this is highly unlikely but - // added just in case to avoid crashes. - // - // It could probably be a better idea just - // terminate the function instead. - if (shift < 0 || shift >= len) { - for (int i = 0; i < len; ++i) { - arr[i] = NA_INTEGER; - } - return; - } - - // 1) shift the arrayy - // in place - memmove( - /*dest:*/ arr + shift, - /*src*/ arr, - /*n*/ (size_t)(len - shift) * sizeof(int)); - - // 2) add leading NAs - // as NA_REAL for - // type compatibility - for (int i = 0; i < shift; ++i) { - arr[i] = NA_INTEGER; - } -} +void shift_double_array(double *col, R_xlen_t n, int begIdx, int nbElement); +void shift_integer_array(int *col, R_xlen_t n, int begIdx, int nbElement); // clang-format off -#define shift_array(arr, len, shift) _Generic((arr), int*: shift_int_array, double*: shift_double_array)(arr, len, shift) +// Generic shift_array +// +// Description +// Works similar to S3 functions in R +// _Generic( (x), type: dispatch ) ( signature ) +#define shift_array(col, n, begIdx, nbElement) \ + _Generic((col), double*: shift_double_array, int*: shift_integer_array) \ + ((col), (n), (begIdx), (nbElement)) // clang-format on -#endif // _SHIFT_H \ No newline at end of file +#endif /* SHIFT_H */ \ No newline at end of file diff --git a/src/ta_ACCBANDS.c b/src/ta_ACCBANDS.c deleted file mode 100644 index 651c76657..000000000 --- a/src/ta_ACCBANDS.c +++ /dev/null @@ -1,172 +0,0 @@ -// interface to ta_ACCBANDS.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// integer optInTimePeriod -// -// Returns -// matrix (n x 3) with colum: -// "UpperBand", "MiddleBand", "LowerBand" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_ACCBANDS.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_ACCBANDS_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_ACCBANDS_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_ACCBANDS( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 3, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 3, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_ACCBANDS_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 3, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *realupperband = output_ptr; - double *realmiddleband = output_ptr + 1 * n; - double *reallowerband = output_ptr + 2 * n; - - // TA_ACCBANDS returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_ACCBANDS( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - realupperband, - realmiddleband, - reallowerband); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(realupperband, n, start_idx); - shift_array(realmiddleband, n, start_idx); - shift_array(reallowerband, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "UpperBand", "MiddleBand", "LowerBand"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_AD.c b/src/ta_AD.c deleted file mode 100644 index 4a09c6cdc..000000000 --- a/src/ta_AD.c +++ /dev/null @@ -1,165 +0,0 @@ -// interface to ta_AD.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// double inVolume -// -// Returns -// matrix (n x 1) with colum: -// "AD" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_AD.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_AD_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP inVolume -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_AD_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_AD( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP inVolume, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - const double *inVolume_ptr = REAL(inVolume); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inHigh_ptr, inLow_ptr, inClose_ptr, inVolume_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - inVolume_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_AD_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_AD returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_AD( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - inVolume_ptr, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "AD"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_ADOSC.c b/src/ta_ADOSC.c deleted file mode 100644 index 386815a4e..000000000 --- a/src/ta_ADOSC.c +++ /dev/null @@ -1,181 +0,0 @@ -// interface to ta_ADOSC.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// double inVolume -// integer optInFastPeriod -// integer optInSlowPeriod -// -// Returns -// matrix (n x 1) with colum: -// "ADOSC" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_ADOSC.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_ADOSC_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP inVolume, - SEXP optInFastPeriod, - SEXP optInSlowPeriod -) -// clang-format on -{ - // values - const int optInFastPeriod_value = INTEGER(optInFastPeriod)[0]; - const int optInSlowPeriod_value = INTEGER(optInSlowPeriod)[0]; - - // calculate lookback - const int lookback = - TA_ADOSC_Lookback(optInFastPeriod_value, optInSlowPeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_ADOSC( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP inVolume, - SEXP optInFastPeriod, - SEXP optInSlowPeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - const double *inVolume_ptr = REAL(inVolume); - - // extract input values - const int optInFastPeriod_value = INTEGER(optInFastPeriod)[0]; - const int optInSlowPeriod_value = INTEGER(optInSlowPeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inHigh_ptr, inLow_ptr, inClose_ptr, inVolume_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - inVolume_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = - TA_ADOSC_Lookback(optInFastPeriod_value, optInSlowPeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_ADOSC returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_ADOSC( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - inVolume_ptr, - optInFastPeriod_value, - optInSlowPeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "ADOSC"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_ADX.c b/src/ta_ADX.c deleted file mode 100644 index 509d4fbfa..000000000 --- a/src/ta_ADX.c +++ /dev/null @@ -1,166 +0,0 @@ -// interface to ta_ADX.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "ADX" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_ADX.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_ADX_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_ADX_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_ADX( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 3, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 3, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_ADX_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_ADX returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_ADX( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "ADX"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_ADXR.c b/src/ta_ADXR.c deleted file mode 100644 index 84fcd31bf..000000000 --- a/src/ta_ADXR.c +++ /dev/null @@ -1,166 +0,0 @@ -// interface to ta_ADXR.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "ADXR" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_ADXR.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_ADXR_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_ADXR_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_ADXR( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 3, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 3, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_ADXR_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_ADXR returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_ADXR( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "ADXR"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_APO.c b/src/ta_APO.c deleted file mode 100644 index d16240541..000000000 --- a/src/ta_APO.c +++ /dev/null @@ -1,172 +0,0 @@ -// interface to ta_APO.c -// -// Parameters -// double inReal -// integer optInFastPeriod -// integer optInSlowPeriod -// integer optInMAType (MAType) -// -// Returns -// matrix (n x 1) with colum: -// "APO" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_APO.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_APO_lookback( - SEXP inReal, - SEXP optInFastPeriod, - SEXP optInSlowPeriod, - SEXP optInMAType -) -// clang-format on -{ - // values - const int optInFastPeriod_value = INTEGER(optInFastPeriod)[0]; - const int optInSlowPeriod_value = INTEGER(optInSlowPeriod)[0]; - const TA_MAType optInMAType_value = as_MAType(optInMAType); - - // calculate lookback - const int lookback = TA_APO_Lookback( - optInFastPeriod_value, - optInSlowPeriod_value, - optInMAType_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_APO( - SEXP inReal, - SEXP optInFastPeriod, - SEXP optInSlowPeriod, - SEXP optInMAType, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInFastPeriod_value = INTEGER(optInFastPeriod)[0]; - const int optInSlowPeriod_value = INTEGER(optInSlowPeriod)[0]; - const TA_MAType optInMAType_value = as_MAType(optInMAType); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_APO_Lookback( - optInFastPeriod_value, - optInSlowPeriod_value, - optInMAType_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_APO returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_APO( - 0, - n - 1, - inReal_ptr, - optInFastPeriod_value, - optInSlowPeriod_value, - optInMAType_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "APO"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_AROON.c b/src/ta_AROON.c deleted file mode 100644 index 74939b75a..000000000 --- a/src/ta_AROON.c +++ /dev/null @@ -1,163 +0,0 @@ -// interface to ta_AROON.c -// -// Parameters -// double inHigh -// double inLow -// integer optInTimePeriod -// -// Returns -// matrix (n x 2) with colum: -// "AroonDown", "AroonUp" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_AROON.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_AROON_lookback( - SEXP inHigh, - SEXP inLow, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_AROON_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_AROON( - SEXP inHigh, - SEXP inLow, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr}; - n = build_na_mask(na_mask, n, 2, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 2, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_AROON_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 2, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *aroondown = output_ptr; - double *aroonup = output_ptr + 1 * n; - - // TA_AROON returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_AROON( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - aroondown, - aroonup); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(aroondown, n, start_idx); - shift_array(aroonup, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "AroonDown", "AroonUp"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_AROONOSC.c b/src/ta_AROONOSC.c deleted file mode 100644 index 528a60e84..000000000 --- a/src/ta_AROONOSC.c +++ /dev/null @@ -1,160 +0,0 @@ -// interface to ta_AROONOSC.c -// -// Parameters -// double inHigh -// double inLow -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "AROONOSC" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_AROONOSC.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_AROONOSC_lookback( - SEXP inHigh, - SEXP inLow, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_AROONOSC_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_AROONOSC( - SEXP inHigh, - SEXP inLow, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr}; - n = build_na_mask(na_mask, n, 2, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 2, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_AROONOSC_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_AROONOSC returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_AROONOSC( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "AROONOSC"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_ATR.c b/src/ta_ATR.c deleted file mode 100644 index 580706ff2..000000000 --- a/src/ta_ATR.c +++ /dev/null @@ -1,166 +0,0 @@ -// interface to ta_ATR.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "ATR" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_ATR.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_ATR_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_ATR_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_ATR( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 3, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 3, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_ATR_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_ATR returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_ATR( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "ATR"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_AVGPRICE.c b/src/ta_AVGPRICE.c deleted file mode 100644 index b2149dd09..000000000 --- a/src/ta_AVGPRICE.c +++ /dev/null @@ -1,165 +0,0 @@ -// interface to ta_AVGPRICE.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "AVGPRICE" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_AVGPRICE.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_AVGPRICE_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_AVGPRICE_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_AVGPRICE( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_AVGPRICE_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_AVGPRICE returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_AVGPRICE( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "AVGPRICE"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_BBANDS.c b/src/ta_BBANDS.c deleted file mode 100644 index f43421368..000000000 --- a/src/ta_BBANDS.c +++ /dev/null @@ -1,186 +0,0 @@ -// interface to ta_BBANDS.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// double optInNbDevUp -// double optInNbDevDn -// integer optInMAType (MAType) -// -// Returns -// matrix (n x 3) with colum: -// "UpperBand", "MiddleBand", "LowerBand" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_BBANDS.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_BBANDS_lookback( - SEXP inReal, - SEXP optInTimePeriod, - SEXP optInNbDevUp, - SEXP optInNbDevDn, - SEXP optInMAType -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - const double optInNbDevUp_value = REAL(optInNbDevUp)[0]; - const double optInNbDevDn_value = REAL(optInNbDevDn)[0]; - const TA_MAType optInMAType_value = as_MAType(optInMAType); - - // calculate lookback - const int lookback = TA_BBANDS_Lookback( - optInTimePeriod_value, - optInNbDevUp_value, - optInNbDevDn_value, - optInMAType_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_BBANDS( - SEXP inReal, - SEXP optInTimePeriod, - SEXP optInNbDevUp, - SEXP optInNbDevDn, - SEXP optInMAType, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - const double optInNbDevUp_value = REAL(optInNbDevUp)[0]; - const double optInNbDevDn_value = REAL(optInNbDevDn)[0]; - const TA_MAType optInMAType_value = as_MAType(optInMAType); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_BBANDS_Lookback( - optInTimePeriod_value, - optInNbDevUp_value, - optInNbDevDn_value, - optInMAType_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 3, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *realupperband = output_ptr; - double *realmiddleband = output_ptr + 1 * n; - double *reallowerband = output_ptr + 2 * n; - - // TA_BBANDS returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_BBANDS( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - optInNbDevUp_value, - optInNbDevDn_value, - optInMAType_value, - &start_idx, - &end_idx, - realupperband, - realmiddleband, - reallowerband); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(realupperband, n, start_idx); - shift_array(realmiddleband, n, start_idx); - shift_array(reallowerband, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "UpperBand", "MiddleBand", "LowerBand"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_BETA.c b/src/ta_BETA.c deleted file mode 100644 index 2f8665b4a..000000000 --- a/src/ta_BETA.c +++ /dev/null @@ -1,160 +0,0 @@ -// interface to ta_BETA.c -// -// Parameters -// double inReal0 -// double inReal1 -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "BETA" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_BETA.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_BETA_lookback( - SEXP inReal0, - SEXP inReal1, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_BETA_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_BETA( - SEXP inReal0, - SEXP inReal1, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal0' (assumes equal length across input) - int n = LENGTH(inReal0); - - // pointers to input arrays - const double *inReal0_ptr = REAL(inReal0); - const double *inReal1_ptr = REAL(inReal1); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal0_ptr, inReal1_ptr}; - n = build_na_mask(na_mask, n, 2, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 2, na_mask, n_original, n); - inReal0_ptr = na_arrays[0]; - inReal1_ptr = na_arrays[1]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_BETA_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_BETA returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_BETA( - 0, - n - 1, - inReal0_ptr, - inReal1_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "BETA"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_BOP.c b/src/ta_BOP.c deleted file mode 100644 index 90e69247e..000000000 --- a/src/ta_BOP.c +++ /dev/null @@ -1,165 +0,0 @@ -// interface to ta_BOP.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "BOP" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_BOP.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_BOP_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_BOP_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_BOP( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_BOP_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_BOP returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_BOP( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "BOP"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CCI.c b/src/ta_CCI.c deleted file mode 100644 index 29c69ddd0..000000000 --- a/src/ta_CCI.c +++ /dev/null @@ -1,166 +0,0 @@ -// interface to ta_CCI.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "CCI" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CCI.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CCI_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_CCI_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CCI( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 3, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 3, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CCI_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_CCI returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CCI( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CCI"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDL2CROWS.c b/src/ta_CDL2CROWS.c deleted file mode 100644 index bfeb7ceed..000000000 --- a/src/ta_CDL2CROWS.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDL2CROWS.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDL2CROWS" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDL2CROWS.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDL2CROWS_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDL2CROWS_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDL2CROWS( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDL2CROWS_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDL2CROWS returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDL2CROWS( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDL2CROWS"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDL2CROWS returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDL3BLACKCROWS.c b/src/ta_CDL3BLACKCROWS.c deleted file mode 100644 index 0b96fc49b..000000000 --- a/src/ta_CDL3BLACKCROWS.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDL3BLACKCROWS.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDL3BLACKCROWS" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDL3BLACKCROWS.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDL3BLACKCROWS_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDL3BLACKCROWS_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDL3BLACKCROWS( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDL3BLACKCROWS_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDL3BLACKCROWS returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDL3BLACKCROWS( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDL3BLACKCROWS"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDL3BLACKCROWS returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDL3INSIDE.c b/src/ta_CDL3INSIDE.c deleted file mode 100644 index f4ba2a99c..000000000 --- a/src/ta_CDL3INSIDE.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDL3INSIDE.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDL3INSIDE" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDL3INSIDE.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDL3INSIDE_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDL3INSIDE_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDL3INSIDE( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDL3INSIDE_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDL3INSIDE returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDL3INSIDE( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDL3INSIDE"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDL3INSIDE returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDL3LINESTRIKE.c b/src/ta_CDL3LINESTRIKE.c deleted file mode 100644 index 6c05014ce..000000000 --- a/src/ta_CDL3LINESTRIKE.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDL3LINESTRIKE.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDL3LINESTRIKE" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDL3LINESTRIKE.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDL3LINESTRIKE_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDL3LINESTRIKE_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDL3LINESTRIKE( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDL3LINESTRIKE_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDL3LINESTRIKE returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDL3LINESTRIKE( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDL3LINESTRIKE"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDL3LINESTRIKE returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDL3OUTSIDE.c b/src/ta_CDL3OUTSIDE.c deleted file mode 100644 index 268d611bb..000000000 --- a/src/ta_CDL3OUTSIDE.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDL3OUTSIDE.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDL3OUTSIDE" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDL3OUTSIDE.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDL3OUTSIDE_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDL3OUTSIDE_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDL3OUTSIDE( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDL3OUTSIDE_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDL3OUTSIDE returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDL3OUTSIDE( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDL3OUTSIDE"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDL3OUTSIDE returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDL3STARSINSOUTH.c b/src/ta_CDL3STARSINSOUTH.c deleted file mode 100644 index 2bd55407e..000000000 --- a/src/ta_CDL3STARSINSOUTH.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDL3STARSINSOUTH.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDL3STARSINSOUTH" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDL3STARSINSOUTH.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDL3STARSINSOUTH_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDL3STARSINSOUTH_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDL3STARSINSOUTH( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDL3STARSINSOUTH_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDL3STARSINSOUTH returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDL3STARSINSOUTH( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDL3STARSINSOUTH"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDL3STARSINSOUTH returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDL3WHITESOLDIERS.c b/src/ta_CDL3WHITESOLDIERS.c deleted file mode 100644 index 1404b8c86..000000000 --- a/src/ta_CDL3WHITESOLDIERS.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDL3WHITESOLDIERS.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDL3WHITESOLDIERS" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDL3WHITESOLDIERS.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDL3WHITESOLDIERS_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDL3WHITESOLDIERS_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDL3WHITESOLDIERS( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDL3WHITESOLDIERS_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDL3WHITESOLDIERS returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDL3WHITESOLDIERS( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDL3WHITESOLDIERS"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDL3WHITESOLDIERS returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLABANDONEDBABY.c b/src/ta_CDLABANDONEDBABY.c deleted file mode 100644 index 759655ada..000000000 --- a/src/ta_CDLABANDONEDBABY.c +++ /dev/null @@ -1,187 +0,0 @@ -// interface to ta_CDLABANDONEDBABY.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// double optInPenetration -// -// Returns -// matrix (n x 1) with colum: -// "CDLABANDONEDBABY" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLABANDONEDBABY.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLABANDONEDBABY_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInPenetration -) -// clang-format on -{ - // values - const double optInPenetration_value = REAL(optInPenetration)[0]; - - // calculate lookback - const int lookback = TA_CDLABANDONEDBABY_Lookback(optInPenetration_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLABANDONEDBABY( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInPenetration, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const double optInPenetration_value = REAL(optInPenetration)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLABANDONEDBABY_Lookback(optInPenetration_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLABANDONEDBABY returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLABANDONEDBABY( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInPenetration_value, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLABANDONEDBABY"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLABANDONEDBABY returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLADVANCEBLOCK.c b/src/ta_CDLADVANCEBLOCK.c deleted file mode 100644 index e73e0975f..000000000 --- a/src/ta_CDLADVANCEBLOCK.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLADVANCEBLOCK.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLADVANCEBLOCK" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLADVANCEBLOCK.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLADVANCEBLOCK_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLADVANCEBLOCK_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLADVANCEBLOCK( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLADVANCEBLOCK_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLADVANCEBLOCK returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLADVANCEBLOCK( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLADVANCEBLOCK"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLADVANCEBLOCK returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLBELTHOLD.c b/src/ta_CDLBELTHOLD.c deleted file mode 100644 index 2964e0a76..000000000 --- a/src/ta_CDLBELTHOLD.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLBELTHOLD.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLBELTHOLD" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLBELTHOLD.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLBELTHOLD_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLBELTHOLD_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLBELTHOLD( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLBELTHOLD_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLBELTHOLD returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLBELTHOLD( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLBELTHOLD"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLBELTHOLD returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLBREAKAWAY.c b/src/ta_CDLBREAKAWAY.c deleted file mode 100644 index 91e69060d..000000000 --- a/src/ta_CDLBREAKAWAY.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLBREAKAWAY.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLBREAKAWAY" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLBREAKAWAY.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLBREAKAWAY_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLBREAKAWAY_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLBREAKAWAY( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLBREAKAWAY_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLBREAKAWAY returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLBREAKAWAY( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLBREAKAWAY"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLBREAKAWAY returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLCLOSINGMARUBOZU.c b/src/ta_CDLCLOSINGMARUBOZU.c deleted file mode 100644 index 6bf49384c..000000000 --- a/src/ta_CDLCLOSINGMARUBOZU.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLCLOSINGMARUBOZU.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLCLOSINGMARUBOZU" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLCLOSINGMARUBOZU.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLCLOSINGMARUBOZU_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLCLOSINGMARUBOZU_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLCLOSINGMARUBOZU( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLCLOSINGMARUBOZU_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLCLOSINGMARUBOZU returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLCLOSINGMARUBOZU( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLCLOSINGMARUBOZU"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLCLOSINGMARUBOZU returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLCONCEALBABYSWALL.c b/src/ta_CDLCONCEALBABYSWALL.c deleted file mode 100644 index 098b89b49..000000000 --- a/src/ta_CDLCONCEALBABYSWALL.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLCONCEALBABYSWALL.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLCONCEALBABYSWALL" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLCONCEALBABYSWALL.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLCONCEALBABYSWALL_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLCONCEALBABYSWALL_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLCONCEALBABYSWALL( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLCONCEALBABYSWALL_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLCONCEALBABYSWALL returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLCONCEALBABYSWALL( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLCONCEALBABYSWALL"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLCONCEALBABYSWALL returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLCOUNTERATTACK.c b/src/ta_CDLCOUNTERATTACK.c deleted file mode 100644 index bc19be72c..000000000 --- a/src/ta_CDLCOUNTERATTACK.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLCOUNTERATTACK.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLCOUNTERATTACK" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLCOUNTERATTACK.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLCOUNTERATTACK_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLCOUNTERATTACK_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLCOUNTERATTACK( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLCOUNTERATTACK_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLCOUNTERATTACK returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLCOUNTERATTACK( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLCOUNTERATTACK"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLCOUNTERATTACK returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLDARKCLOUDCOVER.c b/src/ta_CDLDARKCLOUDCOVER.c deleted file mode 100644 index 767d33856..000000000 --- a/src/ta_CDLDARKCLOUDCOVER.c +++ /dev/null @@ -1,187 +0,0 @@ -// interface to ta_CDLDARKCLOUDCOVER.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// double optInPenetration -// -// Returns -// matrix (n x 1) with colum: -// "CDLDARKCLOUDCOVER" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLDARKCLOUDCOVER.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLDARKCLOUDCOVER_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInPenetration -) -// clang-format on -{ - // values - const double optInPenetration_value = REAL(optInPenetration)[0]; - - // calculate lookback - const int lookback = TA_CDLDARKCLOUDCOVER_Lookback(optInPenetration_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLDARKCLOUDCOVER( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInPenetration, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const double optInPenetration_value = REAL(optInPenetration)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLDARKCLOUDCOVER_Lookback(optInPenetration_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLDARKCLOUDCOVER returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLDARKCLOUDCOVER( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInPenetration_value, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLDARKCLOUDCOVER"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLDARKCLOUDCOVER returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLDOJI.c b/src/ta_CDLDOJI.c deleted file mode 100644 index 4a4a16453..000000000 --- a/src/ta_CDLDOJI.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLDOJI.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLDOJI" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLDOJI.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLDOJI_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLDOJI_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLDOJI( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLDOJI_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLDOJI returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLDOJI( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLDOJI"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLDOJI returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLDOJISTAR.c b/src/ta_CDLDOJISTAR.c deleted file mode 100644 index 093a3f137..000000000 --- a/src/ta_CDLDOJISTAR.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLDOJISTAR.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLDOJISTAR" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLDOJISTAR.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLDOJISTAR_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLDOJISTAR_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLDOJISTAR( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLDOJISTAR_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLDOJISTAR returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLDOJISTAR( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLDOJISTAR"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLDOJISTAR returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLDRAGONFLYDOJI.c b/src/ta_CDLDRAGONFLYDOJI.c deleted file mode 100644 index 346f386b5..000000000 --- a/src/ta_CDLDRAGONFLYDOJI.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLDRAGONFLYDOJI.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLDRAGONFLYDOJI" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLDRAGONFLYDOJI.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLDRAGONFLYDOJI_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLDRAGONFLYDOJI_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLDRAGONFLYDOJI( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLDRAGONFLYDOJI_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLDRAGONFLYDOJI returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLDRAGONFLYDOJI( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLDRAGONFLYDOJI"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLDRAGONFLYDOJI returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLENGULFING.c b/src/ta_CDLENGULFING.c deleted file mode 100644 index 47920ccda..000000000 --- a/src/ta_CDLENGULFING.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLENGULFING.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLENGULFING" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLENGULFING.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLENGULFING_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLENGULFING_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLENGULFING( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLENGULFING_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLENGULFING returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLENGULFING( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLENGULFING"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLENGULFING returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLEVENINGDOJISTAR.c b/src/ta_CDLEVENINGDOJISTAR.c deleted file mode 100644 index 8a46074f9..000000000 --- a/src/ta_CDLEVENINGDOJISTAR.c +++ /dev/null @@ -1,187 +0,0 @@ -// interface to ta_CDLEVENINGDOJISTAR.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// double optInPenetration -// -// Returns -// matrix (n x 1) with colum: -// "CDLEVENINGDOJISTAR" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLEVENINGDOJISTAR.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLEVENINGDOJISTAR_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInPenetration -) -// clang-format on -{ - // values - const double optInPenetration_value = REAL(optInPenetration)[0]; - - // calculate lookback - const int lookback = TA_CDLEVENINGDOJISTAR_Lookback(optInPenetration_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLEVENINGDOJISTAR( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInPenetration, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const double optInPenetration_value = REAL(optInPenetration)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLEVENINGDOJISTAR_Lookback(optInPenetration_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLEVENINGDOJISTAR returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLEVENINGDOJISTAR( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInPenetration_value, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLEVENINGDOJISTAR"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLEVENINGDOJISTAR returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLEVENINGSTAR.c b/src/ta_CDLEVENINGSTAR.c deleted file mode 100644 index 34461dfd9..000000000 --- a/src/ta_CDLEVENINGSTAR.c +++ /dev/null @@ -1,187 +0,0 @@ -// interface to ta_CDLEVENINGSTAR.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// double optInPenetration -// -// Returns -// matrix (n x 1) with colum: -// "CDLEVENINGSTAR" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLEVENINGSTAR.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLEVENINGSTAR_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInPenetration -) -// clang-format on -{ - // values - const double optInPenetration_value = REAL(optInPenetration)[0]; - - // calculate lookback - const int lookback = TA_CDLEVENINGSTAR_Lookback(optInPenetration_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLEVENINGSTAR( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInPenetration, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const double optInPenetration_value = REAL(optInPenetration)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLEVENINGSTAR_Lookback(optInPenetration_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLEVENINGSTAR returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLEVENINGSTAR( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInPenetration_value, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLEVENINGSTAR"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLEVENINGSTAR returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLGAPSIDESIDEWHITE.c b/src/ta_CDLGAPSIDESIDEWHITE.c deleted file mode 100644 index 52d78a58d..000000000 --- a/src/ta_CDLGAPSIDESIDEWHITE.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLGAPSIDESIDEWHITE.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLGAPSIDESIDEWHITE" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLGAPSIDESIDEWHITE.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLGAPSIDESIDEWHITE_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLGAPSIDESIDEWHITE_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLGAPSIDESIDEWHITE( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLGAPSIDESIDEWHITE_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLGAPSIDESIDEWHITE returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLGAPSIDESIDEWHITE( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLGAPSIDESIDEWHITE"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLGAPSIDESIDEWHITE returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLGRAVESTONEDOJI.c b/src/ta_CDLGRAVESTONEDOJI.c deleted file mode 100644 index 8f9467599..000000000 --- a/src/ta_CDLGRAVESTONEDOJI.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLGRAVESTONEDOJI.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLGRAVESTONEDOJI" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLGRAVESTONEDOJI.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLGRAVESTONEDOJI_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLGRAVESTONEDOJI_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLGRAVESTONEDOJI( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLGRAVESTONEDOJI_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLGRAVESTONEDOJI returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLGRAVESTONEDOJI( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLGRAVESTONEDOJI"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLGRAVESTONEDOJI returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLHAMMER.c b/src/ta_CDLHAMMER.c deleted file mode 100644 index c18d08feb..000000000 --- a/src/ta_CDLHAMMER.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLHAMMER.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLHAMMER" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLHAMMER.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLHAMMER_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLHAMMER_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLHAMMER( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLHAMMER_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLHAMMER returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLHAMMER( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLHAMMER"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLHAMMER returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLHANGINGMAN.c b/src/ta_CDLHANGINGMAN.c deleted file mode 100644 index ebd24acb5..000000000 --- a/src/ta_CDLHANGINGMAN.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLHANGINGMAN.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLHANGINGMAN" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLHANGINGMAN.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLHANGINGMAN_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLHANGINGMAN_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLHANGINGMAN( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLHANGINGMAN_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLHANGINGMAN returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLHANGINGMAN( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLHANGINGMAN"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLHANGINGMAN returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLHARAMI.c b/src/ta_CDLHARAMI.c deleted file mode 100644 index 92b86388d..000000000 --- a/src/ta_CDLHARAMI.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLHARAMI.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLHARAMI" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLHARAMI.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLHARAMI_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLHARAMI_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLHARAMI( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLHARAMI_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLHARAMI returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLHARAMI( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLHARAMI"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLHARAMI returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLHARAMICROSS.c b/src/ta_CDLHARAMICROSS.c deleted file mode 100644 index 8561807fe..000000000 --- a/src/ta_CDLHARAMICROSS.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLHARAMICROSS.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLHARAMICROSS" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLHARAMICROSS.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLHARAMICROSS_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLHARAMICROSS_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLHARAMICROSS( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLHARAMICROSS_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLHARAMICROSS returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLHARAMICROSS( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLHARAMICROSS"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLHARAMICROSS returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLHIGHWAVE.c b/src/ta_CDLHIGHWAVE.c deleted file mode 100644 index 37d862831..000000000 --- a/src/ta_CDLHIGHWAVE.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLHIGHWAVE.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLHIGHWAVE" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLHIGHWAVE.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLHIGHWAVE_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLHIGHWAVE_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLHIGHWAVE( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLHIGHWAVE_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLHIGHWAVE returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLHIGHWAVE( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLHIGHWAVE"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLHIGHWAVE returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLHIKKAKE.c b/src/ta_CDLHIKKAKE.c deleted file mode 100644 index 92a48838c..000000000 --- a/src/ta_CDLHIKKAKE.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLHIKKAKE.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLHIKKAKE" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLHIKKAKE.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLHIKKAKE_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLHIKKAKE_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLHIKKAKE( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLHIKKAKE_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLHIKKAKE returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLHIKKAKE( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLHIKKAKE"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLHIKKAKE returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLHIKKAKEMOD.c b/src/ta_CDLHIKKAKEMOD.c deleted file mode 100644 index 32923c941..000000000 --- a/src/ta_CDLHIKKAKEMOD.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLHIKKAKEMOD.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLHIKKAKEMOD" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLHIKKAKEMOD.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLHIKKAKEMOD_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLHIKKAKEMOD_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLHIKKAKEMOD( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLHIKKAKEMOD_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLHIKKAKEMOD returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLHIKKAKEMOD( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLHIKKAKEMOD"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLHIKKAKEMOD returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLHOMINGPIGEON.c b/src/ta_CDLHOMINGPIGEON.c deleted file mode 100644 index dacf7025f..000000000 --- a/src/ta_CDLHOMINGPIGEON.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLHOMINGPIGEON.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLHOMINGPIGEON" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLHOMINGPIGEON.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLHOMINGPIGEON_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLHOMINGPIGEON_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLHOMINGPIGEON( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLHOMINGPIGEON_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLHOMINGPIGEON returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLHOMINGPIGEON( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLHOMINGPIGEON"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLHOMINGPIGEON returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLIDENTICAL3CROWS.c b/src/ta_CDLIDENTICAL3CROWS.c deleted file mode 100644 index 2882d9f76..000000000 --- a/src/ta_CDLIDENTICAL3CROWS.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLIDENTICAL3CROWS.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLIDENTICAL3CROWS" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLIDENTICAL3CROWS.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLIDENTICAL3CROWS_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLIDENTICAL3CROWS_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLIDENTICAL3CROWS( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLIDENTICAL3CROWS_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLIDENTICAL3CROWS returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLIDENTICAL3CROWS( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLIDENTICAL3CROWS"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLIDENTICAL3CROWS returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLINNECK.c b/src/ta_CDLINNECK.c deleted file mode 100644 index 32e12cd31..000000000 --- a/src/ta_CDLINNECK.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLINNECK.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLINNECK" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLINNECK.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLINNECK_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLINNECK_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLINNECK( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLINNECK_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLINNECK returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLINNECK( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLINNECK"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLINNECK returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLINVERTEDHAMMER.c b/src/ta_CDLINVERTEDHAMMER.c deleted file mode 100644 index 5fe263bcd..000000000 --- a/src/ta_CDLINVERTEDHAMMER.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLINVERTEDHAMMER.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLINVERTEDHAMMER" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLINVERTEDHAMMER.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLINVERTEDHAMMER_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLINVERTEDHAMMER_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLINVERTEDHAMMER( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLINVERTEDHAMMER_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLINVERTEDHAMMER returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLINVERTEDHAMMER( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLINVERTEDHAMMER"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLINVERTEDHAMMER returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLKICKING.c b/src/ta_CDLKICKING.c deleted file mode 100644 index 06d10c8a1..000000000 --- a/src/ta_CDLKICKING.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLKICKING.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLKICKING" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLKICKING.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLKICKING_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLKICKING_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLKICKING( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLKICKING_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLKICKING returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLKICKING( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLKICKING"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLKICKING returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLKICKINGBYLENGTH.c b/src/ta_CDLKICKINGBYLENGTH.c deleted file mode 100644 index 645b1464b..000000000 --- a/src/ta_CDLKICKINGBYLENGTH.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLKICKINGBYLENGTH.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLKICKINGBYLENGTH" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLKICKINGBYLENGTH.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLKICKINGBYLENGTH_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLKICKINGBYLENGTH_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLKICKINGBYLENGTH( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLKICKINGBYLENGTH_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLKICKINGBYLENGTH returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLKICKINGBYLENGTH( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLKICKINGBYLENGTH"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLKICKINGBYLENGTH returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLLADDERBOTTOM.c b/src/ta_CDLLADDERBOTTOM.c deleted file mode 100644 index 63337a1c1..000000000 --- a/src/ta_CDLLADDERBOTTOM.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLLADDERBOTTOM.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLLADDERBOTTOM" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLLADDERBOTTOM.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLLADDERBOTTOM_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLLADDERBOTTOM_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLLADDERBOTTOM( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLLADDERBOTTOM_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLLADDERBOTTOM returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLLADDERBOTTOM( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLLADDERBOTTOM"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLLADDERBOTTOM returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLLONGLEGGEDDOJI.c b/src/ta_CDLLONGLEGGEDDOJI.c deleted file mode 100644 index e012fa57f..000000000 --- a/src/ta_CDLLONGLEGGEDDOJI.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLLONGLEGGEDDOJI.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLLONGLEGGEDDOJI" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLLONGLEGGEDDOJI.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLLONGLEGGEDDOJI_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLLONGLEGGEDDOJI_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLLONGLEGGEDDOJI( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLLONGLEGGEDDOJI_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLLONGLEGGEDDOJI returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLLONGLEGGEDDOJI( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLLONGLEGGEDDOJI"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLLONGLEGGEDDOJI returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLLONGLINE.c b/src/ta_CDLLONGLINE.c deleted file mode 100644 index ac63d936f..000000000 --- a/src/ta_CDLLONGLINE.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLLONGLINE.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLLONGLINE" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLLONGLINE.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLLONGLINE_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLLONGLINE_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLLONGLINE( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLLONGLINE_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLLONGLINE returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLLONGLINE( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLLONGLINE"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLLONGLINE returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLMARUBOZU.c b/src/ta_CDLMARUBOZU.c deleted file mode 100644 index fc25c6388..000000000 --- a/src/ta_CDLMARUBOZU.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLMARUBOZU.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLMARUBOZU" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLMARUBOZU.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLMARUBOZU_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLMARUBOZU_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLMARUBOZU( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLMARUBOZU_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLMARUBOZU returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLMARUBOZU( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLMARUBOZU"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLMARUBOZU returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLMATCHINGLOW.c b/src/ta_CDLMATCHINGLOW.c deleted file mode 100644 index d660a5c3a..000000000 --- a/src/ta_CDLMATCHINGLOW.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLMATCHINGLOW.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLMATCHINGLOW" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLMATCHINGLOW.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLMATCHINGLOW_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLMATCHINGLOW_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLMATCHINGLOW( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLMATCHINGLOW_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLMATCHINGLOW returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLMATCHINGLOW( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLMATCHINGLOW"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLMATCHINGLOW returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLMATHOLD.c b/src/ta_CDLMATHOLD.c deleted file mode 100644 index 348ec51df..000000000 --- a/src/ta_CDLMATHOLD.c +++ /dev/null @@ -1,187 +0,0 @@ -// interface to ta_CDLMATHOLD.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// double optInPenetration -// -// Returns -// matrix (n x 1) with colum: -// "CDLMATHOLD" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLMATHOLD.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLMATHOLD_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInPenetration -) -// clang-format on -{ - // values - const double optInPenetration_value = REAL(optInPenetration)[0]; - - // calculate lookback - const int lookback = TA_CDLMATHOLD_Lookback(optInPenetration_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLMATHOLD( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInPenetration, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const double optInPenetration_value = REAL(optInPenetration)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLMATHOLD_Lookback(optInPenetration_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLMATHOLD returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLMATHOLD( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInPenetration_value, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLMATHOLD"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLMATHOLD returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLMORNINGDOJISTAR.c b/src/ta_CDLMORNINGDOJISTAR.c deleted file mode 100644 index 960c3530a..000000000 --- a/src/ta_CDLMORNINGDOJISTAR.c +++ /dev/null @@ -1,187 +0,0 @@ -// interface to ta_CDLMORNINGDOJISTAR.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// double optInPenetration -// -// Returns -// matrix (n x 1) with colum: -// "CDLMORNINGDOJISTAR" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLMORNINGDOJISTAR.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLMORNINGDOJISTAR_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInPenetration -) -// clang-format on -{ - // values - const double optInPenetration_value = REAL(optInPenetration)[0]; - - // calculate lookback - const int lookback = TA_CDLMORNINGDOJISTAR_Lookback(optInPenetration_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLMORNINGDOJISTAR( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInPenetration, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const double optInPenetration_value = REAL(optInPenetration)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLMORNINGDOJISTAR_Lookback(optInPenetration_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLMORNINGDOJISTAR returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLMORNINGDOJISTAR( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInPenetration_value, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLMORNINGDOJISTAR"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLMORNINGDOJISTAR returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLMORNINGSTAR.c b/src/ta_CDLMORNINGSTAR.c deleted file mode 100644 index c82375e05..000000000 --- a/src/ta_CDLMORNINGSTAR.c +++ /dev/null @@ -1,187 +0,0 @@ -// interface to ta_CDLMORNINGSTAR.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// double optInPenetration -// -// Returns -// matrix (n x 1) with colum: -// "CDLMORNINGSTAR" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLMORNINGSTAR.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLMORNINGSTAR_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInPenetration -) -// clang-format on -{ - // values - const double optInPenetration_value = REAL(optInPenetration)[0]; - - // calculate lookback - const int lookback = TA_CDLMORNINGSTAR_Lookback(optInPenetration_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLMORNINGSTAR( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInPenetration, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const double optInPenetration_value = REAL(optInPenetration)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLMORNINGSTAR_Lookback(optInPenetration_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLMORNINGSTAR returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLMORNINGSTAR( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInPenetration_value, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLMORNINGSTAR"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLMORNINGSTAR returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLONNECK.c b/src/ta_CDLONNECK.c deleted file mode 100644 index 00d5f90be..000000000 --- a/src/ta_CDLONNECK.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLONNECK.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLONNECK" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLONNECK.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLONNECK_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLONNECK_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLONNECK( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLONNECK_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLONNECK returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLONNECK( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLONNECK"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLONNECK returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLPIERCING.c b/src/ta_CDLPIERCING.c deleted file mode 100644 index 24ee36e43..000000000 --- a/src/ta_CDLPIERCING.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLPIERCING.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLPIERCING" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLPIERCING.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLPIERCING_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLPIERCING_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLPIERCING( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLPIERCING_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLPIERCING returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLPIERCING( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLPIERCING"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLPIERCING returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLRICKSHAWMAN.c b/src/ta_CDLRICKSHAWMAN.c deleted file mode 100644 index fe6d37e73..000000000 --- a/src/ta_CDLRICKSHAWMAN.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLRICKSHAWMAN.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLRICKSHAWMAN" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLRICKSHAWMAN.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLRICKSHAWMAN_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLRICKSHAWMAN_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLRICKSHAWMAN( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLRICKSHAWMAN_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLRICKSHAWMAN returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLRICKSHAWMAN( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLRICKSHAWMAN"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLRICKSHAWMAN returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLRISEFALL3METHODS.c b/src/ta_CDLRISEFALL3METHODS.c deleted file mode 100644 index d0633030d..000000000 --- a/src/ta_CDLRISEFALL3METHODS.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLRISEFALL3METHODS.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLRISEFALL3METHODS" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLRISEFALL3METHODS.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLRISEFALL3METHODS_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLRISEFALL3METHODS_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLRISEFALL3METHODS( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLRISEFALL3METHODS_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLRISEFALL3METHODS returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLRISEFALL3METHODS( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLRISEFALL3METHODS"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLRISEFALL3METHODS returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLSEPARATINGLINES.c b/src/ta_CDLSEPARATINGLINES.c deleted file mode 100644 index d3a7fd076..000000000 --- a/src/ta_CDLSEPARATINGLINES.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLSEPARATINGLINES.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLSEPARATINGLINES" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLSEPARATINGLINES.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLSEPARATINGLINES_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLSEPARATINGLINES_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLSEPARATINGLINES( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLSEPARATINGLINES_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLSEPARATINGLINES returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLSEPARATINGLINES( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLSEPARATINGLINES"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLSEPARATINGLINES returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLSHOOTINGSTAR.c b/src/ta_CDLSHOOTINGSTAR.c deleted file mode 100644 index 4c442edfa..000000000 --- a/src/ta_CDLSHOOTINGSTAR.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLSHOOTINGSTAR.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLSHOOTINGSTAR" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLSHOOTINGSTAR.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLSHOOTINGSTAR_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLSHOOTINGSTAR_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLSHOOTINGSTAR( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLSHOOTINGSTAR_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLSHOOTINGSTAR returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLSHOOTINGSTAR( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLSHOOTINGSTAR"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLSHOOTINGSTAR returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLSHORTLINE.c b/src/ta_CDLSHORTLINE.c deleted file mode 100644 index 734a2a7eb..000000000 --- a/src/ta_CDLSHORTLINE.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLSHORTLINE.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLSHORTLINE" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLSHORTLINE.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLSHORTLINE_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLSHORTLINE_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLSHORTLINE( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLSHORTLINE_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLSHORTLINE returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLSHORTLINE( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLSHORTLINE"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLSHORTLINE returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLSPINNINGTOP.c b/src/ta_CDLSPINNINGTOP.c deleted file mode 100644 index 08858782a..000000000 --- a/src/ta_CDLSPINNINGTOP.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLSPINNINGTOP.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLSPINNINGTOP" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLSPINNINGTOP.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLSPINNINGTOP_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLSPINNINGTOP_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLSPINNINGTOP( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLSPINNINGTOP_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLSPINNINGTOP returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLSPINNINGTOP( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLSPINNINGTOP"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLSPINNINGTOP returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLSTALLEDPATTERN.c b/src/ta_CDLSTALLEDPATTERN.c deleted file mode 100644 index 98869bee2..000000000 --- a/src/ta_CDLSTALLEDPATTERN.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLSTALLEDPATTERN.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLSTALLEDPATTERN" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLSTALLEDPATTERN.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLSTALLEDPATTERN_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLSTALLEDPATTERN_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLSTALLEDPATTERN( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLSTALLEDPATTERN_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLSTALLEDPATTERN returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLSTALLEDPATTERN( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLSTALLEDPATTERN"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLSTALLEDPATTERN returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLSTICKSANDWICH.c b/src/ta_CDLSTICKSANDWICH.c deleted file mode 100644 index 847917a1b..000000000 --- a/src/ta_CDLSTICKSANDWICH.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLSTICKSANDWICH.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLSTICKSANDWICH" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLSTICKSANDWICH.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLSTICKSANDWICH_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLSTICKSANDWICH_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLSTICKSANDWICH( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLSTICKSANDWICH_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLSTICKSANDWICH returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLSTICKSANDWICH( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLSTICKSANDWICH"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLSTICKSANDWICH returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLTAKURI.c b/src/ta_CDLTAKURI.c deleted file mode 100644 index cac9253b8..000000000 --- a/src/ta_CDLTAKURI.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLTAKURI.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLTAKURI" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLTAKURI.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLTAKURI_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLTAKURI_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLTAKURI( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLTAKURI_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLTAKURI returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLTAKURI( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLTAKURI"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLTAKURI returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLTASUKIGAP.c b/src/ta_CDLTASUKIGAP.c deleted file mode 100644 index 0325f6314..000000000 --- a/src/ta_CDLTASUKIGAP.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLTASUKIGAP.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLTASUKIGAP" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLTASUKIGAP.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLTASUKIGAP_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLTASUKIGAP_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLTASUKIGAP( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLTASUKIGAP_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLTASUKIGAP returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLTASUKIGAP( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLTASUKIGAP"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLTASUKIGAP returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLTHRUSTING.c b/src/ta_CDLTHRUSTING.c deleted file mode 100644 index df0cc363e..000000000 --- a/src/ta_CDLTHRUSTING.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLTHRUSTING.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLTHRUSTING" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLTHRUSTING.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLTHRUSTING_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLTHRUSTING_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLTHRUSTING( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLTHRUSTING_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLTHRUSTING returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLTHRUSTING( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLTHRUSTING"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLTHRUSTING returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLTRISTAR.c b/src/ta_CDLTRISTAR.c deleted file mode 100644 index c6147d7b8..000000000 --- a/src/ta_CDLTRISTAR.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLTRISTAR.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLTRISTAR" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLTRISTAR.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLTRISTAR_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLTRISTAR_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLTRISTAR( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLTRISTAR_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLTRISTAR returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLTRISTAR( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLTRISTAR"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLTRISTAR returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLUNIQUE3RIVER.c b/src/ta_CDLUNIQUE3RIVER.c deleted file mode 100644 index 476244254..000000000 --- a/src/ta_CDLUNIQUE3RIVER.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLUNIQUE3RIVER.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLUNIQUE3RIVER" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLUNIQUE3RIVER.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLUNIQUE3RIVER_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLUNIQUE3RIVER_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLUNIQUE3RIVER( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLUNIQUE3RIVER_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLUNIQUE3RIVER returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLUNIQUE3RIVER( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLUNIQUE3RIVER"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLUNIQUE3RIVER returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLUPSIDEGAP2CROWS.c b/src/ta_CDLUPSIDEGAP2CROWS.c deleted file mode 100644 index 14f720a86..000000000 --- a/src/ta_CDLUPSIDEGAP2CROWS.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLUPSIDEGAP2CROWS.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLUPSIDEGAP2CROWS" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLUPSIDEGAP2CROWS.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLUPSIDEGAP2CROWS_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLUPSIDEGAP2CROWS_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLUPSIDEGAP2CROWS( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLUPSIDEGAP2CROWS_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLUPSIDEGAP2CROWS returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLUPSIDEGAP2CROWS( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLUPSIDEGAP2CROWS"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLUPSIDEGAP2CROWS returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CDLXSIDEGAP3METHODS.c b/src/ta_CDLXSIDEGAP3METHODS.c deleted file mode 100644 index bf72c0a20..000000000 --- a/src/ta_CDLXSIDEGAP3METHODS.c +++ /dev/null @@ -1,179 +0,0 @@ -// interface to ta_CDLXSIDEGAP3METHODS.c -// -// Parameters -// double inOpen -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "CDLXSIDEGAP3METHODS" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CDLXSIDEGAP3METHODS.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "normalize.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CDLXSIDEGAP3METHODS_lookback( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_CDLXSIDEGAP3METHODS_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CDLXSIDEGAP3METHODS( - SEXP inOpen, - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP flag, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inOpen_ptr, inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inHigh_ptr = na_arrays[1]; - inLow_ptr = na_arrays[2]; - inClose_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CDLXSIDEGAP3METHODS_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_CDLXSIDEGAP3METHODS returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CDLXSIDEGAP3METHODS( - 0, - n - 1, - inOpen_ptr, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CDLXSIDEGAP3METHODS"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - // ta_CDLXSIDEGAP3METHODS returns values in the range [-200, 200] - // if flag is TRUE the output is converted from INTSXP - // to REALSXP and divided by 100, preserving pattern strength - // see normalize.h for more details - if (LOGICAL_ELT(flag, 0)) { - output = normalize_int_to_real( - output, - 100.0, - (na_mask != NULL), - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CMO.c b/src/ta_CMO.c deleted file mode 100644 index c99da2861..000000000 --- a/src/ta_CMO.c +++ /dev/null @@ -1,154 +0,0 @@ -// interface to ta_CMO.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "CMO" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CMO.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CMO_lookback( - SEXP inReal, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_CMO_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CMO( - SEXP inReal, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CMO_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_CMO returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CMO( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CMO"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_CORREL.c b/src/ta_CORREL.c deleted file mode 100644 index b636e5984..000000000 --- a/src/ta_CORREL.c +++ /dev/null @@ -1,160 +0,0 @@ -// interface to ta_CORREL.c -// -// Parameters -// double inReal0 -// double inReal1 -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "CORREL" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_CORREL.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_CORREL_lookback( - SEXP inReal0, - SEXP inReal1, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_CORREL_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_CORREL( - SEXP inReal0, - SEXP inReal1, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal0' (assumes equal length across input) - int n = LENGTH(inReal0); - - // pointers to input arrays - const double *inReal0_ptr = REAL(inReal0); - const double *inReal1_ptr = REAL(inReal1); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal0_ptr, inReal1_ptr}; - n = build_na_mask(na_mask, n, 2, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 2, na_mask, n_original, n); - inReal0_ptr = na_arrays[0]; - inReal1_ptr = na_arrays[1]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_CORREL_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_CORREL returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_CORREL( - 0, - n - 1, - inReal0_ptr, - inReal1_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "CORREL"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_DEMA.c b/src/ta_DEMA.c deleted file mode 100644 index cf75d7b24..000000000 --- a/src/ta_DEMA.c +++ /dev/null @@ -1,154 +0,0 @@ -// interface to ta_DEMA.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "DEMA" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_DEMA.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_DEMA_lookback( - SEXP inReal, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_DEMA_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_DEMA( - SEXP inReal, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_DEMA_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_DEMA returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_DEMA( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "DEMA"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_DX.c b/src/ta_DX.c deleted file mode 100644 index 36689e8da..000000000 --- a/src/ta_DX.c +++ /dev/null @@ -1,166 +0,0 @@ -// interface to ta_DX.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "DX" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_DX.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_DX_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_DX_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_DX( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 3, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 3, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_DX_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_DX returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_DX( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "DX"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_EMA.c b/src/ta_EMA.c deleted file mode 100644 index bcb9cacf1..000000000 --- a/src/ta_EMA.c +++ /dev/null @@ -1,154 +0,0 @@ -// interface to ta_EMA.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "EMA" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_EMA.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_EMA_lookback( - SEXP inReal, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_EMA_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_EMA( - SEXP inReal, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_EMA_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_EMA returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_EMA( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "EMA"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_HT_DCPERIOD.c b/src/ta_HT_DCPERIOD.c deleted file mode 100644 index 169c1a468..000000000 --- a/src/ta_HT_DCPERIOD.c +++ /dev/null @@ -1,141 +0,0 @@ -// interface to ta_HT_DCPERIOD.c -// -// Parameters -// double inReal -// -// Returns -// matrix (n x 1) with colum: -// "HT_DCPERIOD" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_HT_DCPERIOD.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_HT_DCPERIOD_lookback( - SEXP inReal -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_HT_DCPERIOD_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_HT_DCPERIOD( - SEXP inReal, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_HT_DCPERIOD_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_HT_DCPERIOD returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = - TA_HT_DCPERIOD(0, n - 1, inReal_ptr, &start_idx, &end_idx, real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "HT_DCPERIOD"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_HT_DCPHASE.c b/src/ta_HT_DCPHASE.c deleted file mode 100644 index 2533fbd03..000000000 --- a/src/ta_HT_DCPHASE.c +++ /dev/null @@ -1,141 +0,0 @@ -// interface to ta_HT_DCPHASE.c -// -// Parameters -// double inReal -// -// Returns -// matrix (n x 1) with colum: -// "HT_DCPHASE" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_HT_DCPHASE.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_HT_DCPHASE_lookback( - SEXP inReal -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_HT_DCPHASE_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_HT_DCPHASE( - SEXP inReal, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_HT_DCPHASE_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_HT_DCPHASE returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = - TA_HT_DCPHASE(0, n - 1, inReal_ptr, &start_idx, &end_idx, real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "HT_DCPHASE"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_HT_PHASOR.c b/src/ta_HT_PHASOR.c deleted file mode 100644 index 2939614da..000000000 --- a/src/ta_HT_PHASOR.c +++ /dev/null @@ -1,149 +0,0 @@ -// interface to ta_HT_PHASOR.c -// -// Parameters -// double inReal -// -// Returns -// matrix (n x 2) with colum: -// "InPhase", "Quadrature" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_HT_PHASOR.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_HT_PHASOR_lookback( - SEXP inReal -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_HT_PHASOR_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_HT_PHASOR( - SEXP inReal, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_HT_PHASOR_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 2, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *inphase = output_ptr; - double *quadrature = output_ptr + 1 * n; - - // TA_HT_PHASOR returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_HT_PHASOR( - 0, - n - 1, - inReal_ptr, - &start_idx, - &end_idx, - inphase, - quadrature); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(inphase, n, start_idx); - shift_array(quadrature, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "InPhase", "Quadrature"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_HT_SINE.c b/src/ta_HT_SINE.c deleted file mode 100644 index 99982bc96..000000000 --- a/src/ta_HT_SINE.c +++ /dev/null @@ -1,143 +0,0 @@ -// interface to ta_HT_SINE.c -// -// Parameters -// double inReal -// -// Returns -// matrix (n x 2) with colum: -// "Sine", "LeadSine" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_HT_SINE.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_HT_SINE_lookback( - SEXP inReal -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_HT_SINE_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_HT_SINE( - SEXP inReal, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_HT_SINE_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 2, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *sine = output_ptr; - double *leadsine = output_ptr + 1 * n; - - // TA_HT_SINE returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = - TA_HT_SINE(0, n - 1, inReal_ptr, &start_idx, &end_idx, sine, leadsine); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(sine, n, start_idx); - shift_array(leadsine, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "Sine", "LeadSine"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_HT_TRENDLINE.c b/src/ta_HT_TRENDLINE.c deleted file mode 100644 index 30f5268cc..000000000 --- a/src/ta_HT_TRENDLINE.c +++ /dev/null @@ -1,141 +0,0 @@ -// interface to ta_HT_TRENDLINE.c -// -// Parameters -// double inReal -// -// Returns -// matrix (n x 1) with colum: -// "HT_TRENDLINE" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_HT_TRENDLINE.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_HT_TRENDLINE_lookback( - SEXP inReal -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_HT_TRENDLINE_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_HT_TRENDLINE( - SEXP inReal, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_HT_TRENDLINE_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_HT_TRENDLINE returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = - TA_HT_TRENDLINE(0, n - 1, inReal_ptr, &start_idx, &end_idx, real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "HT_TRENDLINE"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_HT_TRENDMODE.c b/src/ta_HT_TRENDMODE.c deleted file mode 100644 index 8acef3c33..000000000 --- a/src/ta_HT_TRENDMODE.c +++ /dev/null @@ -1,141 +0,0 @@ -// interface to ta_HT_TRENDMODE.c -// -// Parameters -// double inReal -// -// Returns -// matrix (n x 1) with colum: -// "HT_TRENDMODE" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_HT_TRENDMODE.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_HT_TRENDMODE_lookback( - SEXP inReal -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_HT_TRENDMODE_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_HT_TRENDMODE( - SEXP inReal, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - int *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_HT_TRENDMODE_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - int *integer = output_ptr; - - // TA_HT_TRENDMODE returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = - TA_HT_TRENDMODE(0, n - 1, inReal_ptr, &start_idx, &end_idx, integer); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(integer, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "HT_TRENDMODE"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_IMI.c b/src/ta_IMI.c deleted file mode 100644 index 01c3afa6e..000000000 --- a/src/ta_IMI.c +++ /dev/null @@ -1,160 +0,0 @@ -// interface to ta_IMI.c -// -// Parameters -// double inOpen -// double inClose -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "IMI" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_IMI.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_IMI_lookback( - SEXP inOpen, - SEXP inClose, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_IMI_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_IMI( - SEXP inOpen, - SEXP inClose, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inOpen' (assumes equal length across input) - int n = LENGTH(inOpen); - - // pointers to input arrays - const double *inOpen_ptr = REAL(inOpen); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inOpen_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 2, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 2, na_mask, n_original, n); - inOpen_ptr = na_arrays[0]; - inClose_ptr = na_arrays[1]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_IMI_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_IMI returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_IMI( - 0, - n - 1, - inOpen_ptr, - inClose_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "IMI"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_KAMA.c b/src/ta_KAMA.c deleted file mode 100644 index 0825f9b4f..000000000 --- a/src/ta_KAMA.c +++ /dev/null @@ -1,154 +0,0 @@ -// interface to ta_KAMA.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "KAMA" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_KAMA.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_KAMA_lookback( - SEXP inReal, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_KAMA_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_KAMA( - SEXP inReal, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_KAMA_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_KAMA returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_KAMA( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "KAMA"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_MACD.c b/src/ta_MACD.c deleted file mode 100644 index 0138015c9..000000000 --- a/src/ta_MACD.c +++ /dev/null @@ -1,178 +0,0 @@ -// interface to ta_MACD.c -// -// Parameters -// double inReal -// integer optInFastPeriod -// integer optInSlowPeriod -// integer optInSignalPeriod -// -// Returns -// matrix (n x 3) with colum: -// "MACD", "MACDSignal", "MACDHist" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_MACD.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_MACD_lookback( - SEXP inReal, - SEXP optInFastPeriod, - SEXP optInSlowPeriod, - SEXP optInSignalPeriod -) -// clang-format on -{ - // values - const int optInFastPeriod_value = INTEGER(optInFastPeriod)[0]; - const int optInSlowPeriod_value = INTEGER(optInSlowPeriod)[0]; - const int optInSignalPeriod_value = INTEGER(optInSignalPeriod)[0]; - - // calculate lookback - const int lookback = TA_MACD_Lookback( - optInFastPeriod_value, - optInSlowPeriod_value, - optInSignalPeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_MACD( - SEXP inReal, - SEXP optInFastPeriod, - SEXP optInSlowPeriod, - SEXP optInSignalPeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInFastPeriod_value = INTEGER(optInFastPeriod)[0]; - const int optInSlowPeriod_value = INTEGER(optInSlowPeriod)[0]; - const int optInSignalPeriod_value = INTEGER(optInSignalPeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_MACD_Lookback( - optInFastPeriod_value, - optInSlowPeriod_value, - optInSignalPeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 3, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *macd = output_ptr; - double *macdsignal = output_ptr + 1 * n; - double *macdhist = output_ptr + 2 * n; - - // TA_MACD returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_MACD( - 0, - n - 1, - inReal_ptr, - optInFastPeriod_value, - optInSlowPeriod_value, - optInSignalPeriod_value, - &start_idx, - &end_idx, - macd, - macdsignal, - macdhist); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(macd, n, start_idx); - shift_array(macdsignal, n, start_idx); - shift_array(macdhist, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "MACD", "MACDSignal", "MACDHist"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_MACDEXT.c b/src/ta_MACDEXT.c deleted file mode 100644 index 850bc93c3..000000000 --- a/src/ta_MACDEXT.c +++ /dev/null @@ -1,202 +0,0 @@ -// interface to ta_MACDEXT.c -// -// Parameters -// double inReal -// integer optInFastPeriod -// integer optInFastMAType (MAType) -// integer optInSlowPeriod -// integer optInSlowMAType (MAType) -// integer optInSignalPeriod -// integer optInSignalMAType (MAType) -// -// Returns -// matrix (n x 3) with colum: -// "MACD", "MACDSignal", "MACDHist" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_MACDEXT.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_MACDEXT_lookback( - SEXP inReal, - SEXP optInFastPeriod, - SEXP optInFastMAType, - SEXP optInSlowPeriod, - SEXP optInSlowMAType, - SEXP optInSignalPeriod, - SEXP optInSignalMAType -) -// clang-format on -{ - // values - const int optInFastPeriod_value = INTEGER(optInFastPeriod)[0]; - const TA_MAType optInFastMAType_value = as_MAType(optInFastMAType); - const int optInSlowPeriod_value = INTEGER(optInSlowPeriod)[0]; - const TA_MAType optInSlowMAType_value = as_MAType(optInSlowMAType); - const int optInSignalPeriod_value = INTEGER(optInSignalPeriod)[0]; - const TA_MAType optInSignalMAType_value = as_MAType(optInSignalMAType); - - // calculate lookback - const int lookback = TA_MACDEXT_Lookback( - optInFastPeriod_value, - optInFastMAType_value, - optInSlowPeriod_value, - optInSlowMAType_value, - optInSignalPeriod_value, - optInSignalMAType_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_MACDEXT( - SEXP inReal, - SEXP optInFastPeriod, - SEXP optInFastMAType, - SEXP optInSlowPeriod, - SEXP optInSlowMAType, - SEXP optInSignalPeriod, - SEXP optInSignalMAType, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInFastPeriod_value = INTEGER(optInFastPeriod)[0]; - const TA_MAType optInFastMAType_value = as_MAType(optInFastMAType); - const int optInSlowPeriod_value = INTEGER(optInSlowPeriod)[0]; - const TA_MAType optInSlowMAType_value = as_MAType(optInSlowMAType); - const int optInSignalPeriod_value = INTEGER(optInSignalPeriod)[0]; - const TA_MAType optInSignalMAType_value = as_MAType(optInSignalMAType); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_MACDEXT_Lookback( - optInFastPeriod_value, - optInFastMAType_value, - optInSlowPeriod_value, - optInSlowMAType_value, - optInSignalPeriod_value, - optInSignalMAType_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 3, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *macd = output_ptr; - double *macdsignal = output_ptr + 1 * n; - double *macdhist = output_ptr + 2 * n; - - // TA_MACDEXT returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_MACDEXT( - 0, - n - 1, - inReal_ptr, - optInFastPeriod_value, - optInFastMAType_value, - optInSlowPeriod_value, - optInSlowMAType_value, - optInSignalPeriod_value, - optInSignalMAType_value, - &start_idx, - &end_idx, - macd, - macdsignal, - macdhist); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(macd, n, start_idx); - shift_array(macdsignal, n, start_idx); - shift_array(macdhist, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "MACD", "MACDSignal", "MACDHist"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_MACDFIX.c b/src/ta_MACDFIX.c deleted file mode 100644 index 7d0d92261..000000000 --- a/src/ta_MACDFIX.c +++ /dev/null @@ -1,160 +0,0 @@ -// interface to ta_MACDFIX.c -// -// Parameters -// double inReal -// integer optInSignalPeriod -// -// Returns -// matrix (n x 3) with colum: -// "MACD", "MACDSignal", "MACDHist" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_MACDFIX.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_MACDFIX_lookback( - SEXP inReal, - SEXP optInSignalPeriod -) -// clang-format on -{ - // values - const int optInSignalPeriod_value = INTEGER(optInSignalPeriod)[0]; - - // calculate lookback - const int lookback = TA_MACDFIX_Lookback(optInSignalPeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_MACDFIX( - SEXP inReal, - SEXP optInSignalPeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInSignalPeriod_value = INTEGER(optInSignalPeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_MACDFIX_Lookback(optInSignalPeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 3, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *macd = output_ptr; - double *macdsignal = output_ptr + 1 * n; - double *macdhist = output_ptr + 2 * n; - - // TA_MACDFIX returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_MACDFIX( - 0, - n - 1, - inReal_ptr, - optInSignalPeriod_value, - &start_idx, - &end_idx, - macd, - macdsignal, - macdhist); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(macd, n, start_idx); - shift_array(macdsignal, n, start_idx); - shift_array(macdhist, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "MACD", "MACDSignal", "MACDHist"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_MAMA.c b/src/ta_MAMA.c deleted file mode 100644 index 712d67242..000000000 --- a/src/ta_MAMA.c +++ /dev/null @@ -1,165 +0,0 @@ -// interface to ta_MAMA.c -// -// Parameters -// double inReal -// double optInFastLimit -// double optInSlowLimit -// -// Returns -// matrix (n x 2) with colum: -// "MAMA", "FAMA" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_MAMA.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_MAMA_lookback( - SEXP inReal, - SEXP optInFastLimit, - SEXP optInSlowLimit -) -// clang-format on -{ - // values - const double optInFastLimit_value = REAL(optInFastLimit)[0]; - const double optInSlowLimit_value = REAL(optInSlowLimit)[0]; - - // calculate lookback - const int lookback = - TA_MAMA_Lookback(optInFastLimit_value, optInSlowLimit_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_MAMA( - SEXP inReal, - SEXP optInFastLimit, - SEXP optInSlowLimit, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const double optInFastLimit_value = REAL(optInFastLimit)[0]; - const double optInSlowLimit_value = REAL(optInSlowLimit)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = - TA_MAMA_Lookback(optInFastLimit_value, optInSlowLimit_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 2, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *mama = output_ptr; - double *fama = output_ptr + 1 * n; - - // TA_MAMA returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_MAMA( - 0, - n - 1, - inReal_ptr, - optInFastLimit_value, - optInSlowLimit_value, - &start_idx, - &end_idx, - mama, - fama); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(mama, n, start_idx); - shift_array(fama, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "MAMA", "FAMA"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_MAX.c b/src/ta_MAX.c deleted file mode 100644 index 578f32331..000000000 --- a/src/ta_MAX.c +++ /dev/null @@ -1,154 +0,0 @@ -// interface to ta_MAX.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "MAX" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_MAX.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_MAX_lookback( - SEXP inReal, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_MAX_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_MAX( - SEXP inReal, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_MAX_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_MAX returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_MAX( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "MAX"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_MEDPRICE.c b/src/ta_MEDPRICE.c deleted file mode 100644 index 9738f663d..000000000 --- a/src/ta_MEDPRICE.c +++ /dev/null @@ -1,146 +0,0 @@ -// interface to ta_MEDPRICE.c -// -// Parameters -// double inHigh -// double inLow -// -// Returns -// matrix (n x 1) with colum: -// "MEDPRICE" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_MEDPRICE.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_MEDPRICE_lookback( - SEXP inHigh, - SEXP inLow -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_MEDPRICE_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_MEDPRICE( - SEXP inHigh, - SEXP inLow, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr}; - n = build_na_mask(na_mask, n, 2, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 2, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_MEDPRICE_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_MEDPRICE returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = - TA_MEDPRICE(0, n - 1, inHigh_ptr, inLow_ptr, &start_idx, &end_idx, real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "MEDPRICE"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_MFI.c b/src/ta_MFI.c deleted file mode 100644 index 94f6ec09a..000000000 --- a/src/ta_MFI.c +++ /dev/null @@ -1,173 +0,0 @@ -// interface to ta_MFI.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// double inVolume -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "MFI" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_MFI.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_MFI_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP inVolume, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_MFI_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_MFI( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP inVolume, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - const double *inVolume_ptr = REAL(inVolume); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = - {inHigh_ptr, inLow_ptr, inClose_ptr, inVolume_ptr}; - n = build_na_mask(na_mask, n, 4, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 4, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - inVolume_ptr = na_arrays[3]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_MFI_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_MFI returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_MFI( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - inVolume_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "MFI"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_MIDPRICE.c b/src/ta_MIDPRICE.c deleted file mode 100644 index b2518784f..000000000 --- a/src/ta_MIDPRICE.c +++ /dev/null @@ -1,160 +0,0 @@ -// interface to ta_MIDPRICE.c -// -// Parameters -// double inHigh -// double inLow -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "MIDPRICE" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_MIDPRICE.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_MIDPRICE_lookback( - SEXP inHigh, - SEXP inLow, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_MIDPRICE_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_MIDPRICE( - SEXP inHigh, - SEXP inLow, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr}; - n = build_na_mask(na_mask, n, 2, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 2, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_MIDPRICE_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_MIDPRICE returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_MIDPRICE( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "MIDPRICE"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_MIN.c b/src/ta_MIN.c deleted file mode 100644 index d47eae058..000000000 --- a/src/ta_MIN.c +++ /dev/null @@ -1,154 +0,0 @@ -// interface to ta_MIN.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "MIN" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_MIN.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_MIN_lookback( - SEXP inReal, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_MIN_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_MIN( - SEXP inReal, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_MIN_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_MIN returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_MIN( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "MIN"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_MINUS_DI.c b/src/ta_MINUS_DI.c deleted file mode 100644 index 77853b374..000000000 --- a/src/ta_MINUS_DI.c +++ /dev/null @@ -1,166 +0,0 @@ -// interface to ta_MINUS_DI.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "MINUS_DI" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_MINUS_DI.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_MINUS_DI_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_MINUS_DI_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_MINUS_DI( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 3, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 3, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_MINUS_DI_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_MINUS_DI returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_MINUS_DI( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "MINUS_DI"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_MINUS_DM.c b/src/ta_MINUS_DM.c deleted file mode 100644 index 8b4bb8bf2..000000000 --- a/src/ta_MINUS_DM.c +++ /dev/null @@ -1,160 +0,0 @@ -// interface to ta_MINUS_DM.c -// -// Parameters -// double inHigh -// double inLow -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "MINUS_DM" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_MINUS_DM.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_MINUS_DM_lookback( - SEXP inHigh, - SEXP inLow, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_MINUS_DM_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_MINUS_DM( - SEXP inHigh, - SEXP inLow, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr}; - n = build_na_mask(na_mask, n, 2, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 2, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_MINUS_DM_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_MINUS_DM returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_MINUS_DM( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "MINUS_DM"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_MOM.c b/src/ta_MOM.c deleted file mode 100644 index eeb0fad85..000000000 --- a/src/ta_MOM.c +++ /dev/null @@ -1,154 +0,0 @@ -// interface to ta_MOM.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "MOM" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_MOM.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_MOM_lookback( - SEXP inReal, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_MOM_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_MOM( - SEXP inReal, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_MOM_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_MOM returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_MOM( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "MOM"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_NATR.c b/src/ta_NATR.c deleted file mode 100644 index 04d5b0424..000000000 --- a/src/ta_NATR.c +++ /dev/null @@ -1,166 +0,0 @@ -// interface to ta_NATR.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "NATR" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_NATR.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_NATR_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_NATR_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_NATR( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 3, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 3, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_NATR_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_NATR returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_NATR( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "NATR"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_OBV.c b/src/ta_OBV.c deleted file mode 100644 index b2975d83d..000000000 --- a/src/ta_OBV.c +++ /dev/null @@ -1,146 +0,0 @@ -// interface to ta_OBV.c -// -// Parameters -// double inReal -// double inVolume -// -// Returns -// matrix (n x 1) with colum: -// "OBV" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_OBV.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_OBV_lookback( - SEXP inReal, - SEXP inVolume -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_OBV_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_OBV( - SEXP inReal, - SEXP inVolume, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - const double *inVolume_ptr = REAL(inVolume); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr, inVolume_ptr}; - n = build_na_mask(na_mask, n, 2, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 2, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - inVolume_ptr = na_arrays[1]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_OBV_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_OBV returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = - TA_OBV(0, n - 1, inReal_ptr, inVolume_ptr, &start_idx, &end_idx, real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "OBV"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_PLUS_DI.c b/src/ta_PLUS_DI.c deleted file mode 100644 index ac8e504bb..000000000 --- a/src/ta_PLUS_DI.c +++ /dev/null @@ -1,166 +0,0 @@ -// interface to ta_PLUS_DI.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "PLUS_DI" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_PLUS_DI.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_PLUS_DI_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_PLUS_DI_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_PLUS_DI( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 3, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 3, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_PLUS_DI_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_PLUS_DI returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_PLUS_DI( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "PLUS_DI"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_PLUS_DM.c b/src/ta_PLUS_DM.c deleted file mode 100644 index f6521911c..000000000 --- a/src/ta_PLUS_DM.c +++ /dev/null @@ -1,160 +0,0 @@ -// interface to ta_PLUS_DM.c -// -// Parameters -// double inHigh -// double inLow -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "PLUS_DM" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_PLUS_DM.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_PLUS_DM_lookback( - SEXP inHigh, - SEXP inLow, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_PLUS_DM_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_PLUS_DM( - SEXP inHigh, - SEXP inLow, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr}; - n = build_na_mask(na_mask, n, 2, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 2, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_PLUS_DM_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_PLUS_DM returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_PLUS_DM( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "PLUS_DM"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_PPO.c b/src/ta_PPO.c deleted file mode 100644 index 67a12ae55..000000000 --- a/src/ta_PPO.c +++ /dev/null @@ -1,172 +0,0 @@ -// interface to ta_PPO.c -// -// Parameters -// double inReal -// integer optInFastPeriod -// integer optInSlowPeriod -// integer optInMAType (MAType) -// -// Returns -// matrix (n x 1) with colum: -// "PPO" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_PPO.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_PPO_lookback( - SEXP inReal, - SEXP optInFastPeriod, - SEXP optInSlowPeriod, - SEXP optInMAType -) -// clang-format on -{ - // values - const int optInFastPeriod_value = INTEGER(optInFastPeriod)[0]; - const int optInSlowPeriod_value = INTEGER(optInSlowPeriod)[0]; - const TA_MAType optInMAType_value = as_MAType(optInMAType); - - // calculate lookback - const int lookback = TA_PPO_Lookback( - optInFastPeriod_value, - optInSlowPeriod_value, - optInMAType_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_PPO( - SEXP inReal, - SEXP optInFastPeriod, - SEXP optInSlowPeriod, - SEXP optInMAType, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInFastPeriod_value = INTEGER(optInFastPeriod)[0]; - const int optInSlowPeriod_value = INTEGER(optInSlowPeriod)[0]; - const TA_MAType optInMAType_value = as_MAType(optInMAType); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_PPO_Lookback( - optInFastPeriod_value, - optInSlowPeriod_value, - optInMAType_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_PPO returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_PPO( - 0, - n - 1, - inReal_ptr, - optInFastPeriod_value, - optInSlowPeriod_value, - optInMAType_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "PPO"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_ROC.c b/src/ta_ROC.c deleted file mode 100644 index 70f7f3cc4..000000000 --- a/src/ta_ROC.c +++ /dev/null @@ -1,154 +0,0 @@ -// interface to ta_ROC.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "ROC" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_ROC.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_ROC_lookback( - SEXP inReal, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_ROC_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_ROC( - SEXP inReal, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_ROC_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_ROC returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_ROC( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "ROC"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_ROCR.c b/src/ta_ROCR.c deleted file mode 100644 index abcc45e35..000000000 --- a/src/ta_ROCR.c +++ /dev/null @@ -1,154 +0,0 @@ -// interface to ta_ROCR.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "ROCR" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_ROCR.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_ROCR_lookback( - SEXP inReal, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_ROCR_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_ROCR( - SEXP inReal, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_ROCR_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_ROCR returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_ROCR( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "ROCR"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_RSI.c b/src/ta_RSI.c deleted file mode 100644 index 31d76dfe7..000000000 --- a/src/ta_RSI.c +++ /dev/null @@ -1,154 +0,0 @@ -// interface to ta_RSI.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "RSI" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_RSI.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_RSI_lookback( - SEXP inReal, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_RSI_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_RSI( - SEXP inReal, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_RSI_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_RSI returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_RSI( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "RSI"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_SAR.c b/src/ta_SAR.c deleted file mode 100644 index 8553a7747..000000000 --- a/src/ta_SAR.c +++ /dev/null @@ -1,168 +0,0 @@ -// interface to ta_SAR.c -// -// Parameters -// double inHigh -// double inLow -// double optInAcceleration -// double optInMaximum -// -// Returns -// matrix (n x 1) with colum: -// "SAR" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_SAR.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_SAR_lookback( - SEXP inHigh, - SEXP inLow, - SEXP optInAcceleration, - SEXP optInMaximum -) -// clang-format on -{ - // values - const double optInAcceleration_value = REAL(optInAcceleration)[0]; - const double optInMaximum_value = REAL(optInMaximum)[0]; - - // calculate lookback - const int lookback = - TA_SAR_Lookback(optInAcceleration_value, optInMaximum_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_SAR( - SEXP inHigh, - SEXP inLow, - SEXP optInAcceleration, - SEXP optInMaximum, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - - // extract input values - const double optInAcceleration_value = REAL(optInAcceleration)[0]; - const double optInMaximum_value = REAL(optInMaximum)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr}; - n = build_na_mask(na_mask, n, 2, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 2, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = - TA_SAR_Lookback(optInAcceleration_value, optInMaximum_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_SAR returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_SAR( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - optInAcceleration_value, - optInMaximum_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "SAR"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_SAREXT.c b/src/ta_SAREXT.c deleted file mode 100644 index baecce1f1..000000000 --- a/src/ta_SAREXT.c +++ /dev/null @@ -1,226 +0,0 @@ -// interface to ta_SAREXT.c -// -// Parameters -// double inHigh -// double inLow -// double optInStartValue -// double optInOffsetOnReverse -// double optInAccelerationInitLong -// double optInAccelerationLong -// double optInAccelerationMaxLong -// double optInAccelerationInitShort -// double optInAccelerationShort -// double optInAccelerationMaxShort -// -// Returns -// matrix (n x 1) with colum: -// "SAREXT" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_SAREXT.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_SAREXT_lookback( - SEXP inHigh, - SEXP inLow, - SEXP optInStartValue, - SEXP optInOffsetOnReverse, - SEXP optInAccelerationInitLong, - SEXP optInAccelerationLong, - SEXP optInAccelerationMaxLong, - SEXP optInAccelerationInitShort, - SEXP optInAccelerationShort, - SEXP optInAccelerationMaxShort -) -// clang-format on -{ - // values - const double optInStartValue_value = REAL(optInStartValue)[0]; - const double optInOffsetOnReverse_value = REAL(optInOffsetOnReverse)[0]; - const double optInAccelerationInitLong_value = - REAL(optInAccelerationInitLong)[0]; - const double optInAccelerationLong_value = REAL(optInAccelerationLong)[0]; - const double optInAccelerationMaxLong_value = - REAL(optInAccelerationMaxLong)[0]; - const double optInAccelerationInitShort_value = - REAL(optInAccelerationInitShort)[0]; - const double optInAccelerationShort_value = REAL(optInAccelerationShort)[0]; - const double optInAccelerationMaxShort_value = - REAL(optInAccelerationMaxShort)[0]; - - // calculate lookback - const int lookback = TA_SAREXT_Lookback( - optInStartValue_value, - optInOffsetOnReverse_value, - optInAccelerationInitLong_value, - optInAccelerationLong_value, - optInAccelerationMaxLong_value, - optInAccelerationInitShort_value, - optInAccelerationShort_value, - optInAccelerationMaxShort_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_SAREXT( - SEXP inHigh, - SEXP inLow, - SEXP optInStartValue, - SEXP optInOffsetOnReverse, - SEXP optInAccelerationInitLong, - SEXP optInAccelerationLong, - SEXP optInAccelerationMaxLong, - SEXP optInAccelerationInitShort, - SEXP optInAccelerationShort, - SEXP optInAccelerationMaxShort, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - - // extract input values - const double optInStartValue_value = REAL(optInStartValue)[0]; - const double optInOffsetOnReverse_value = REAL(optInOffsetOnReverse)[0]; - const double optInAccelerationInitLong_value = - REAL(optInAccelerationInitLong)[0]; - const double optInAccelerationLong_value = REAL(optInAccelerationLong)[0]; - const double optInAccelerationMaxLong_value = - REAL(optInAccelerationMaxLong)[0]; - const double optInAccelerationInitShort_value = - REAL(optInAccelerationInitShort)[0]; - const double optInAccelerationShort_value = REAL(optInAccelerationShort)[0]; - const double optInAccelerationMaxShort_value = - REAL(optInAccelerationMaxShort)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr}; - n = build_na_mask(na_mask, n, 2, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 2, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_SAREXT_Lookback( - optInStartValue_value, - optInOffsetOnReverse_value, - optInAccelerationInitLong_value, - optInAccelerationLong_value, - optInAccelerationMaxLong_value, - optInAccelerationInitShort_value, - optInAccelerationShort_value, - optInAccelerationMaxShort_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_SAREXT returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_SAREXT( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - optInStartValue_value, - optInOffsetOnReverse_value, - optInAccelerationInitLong_value, - optInAccelerationLong_value, - optInAccelerationMaxLong_value, - optInAccelerationInitShort_value, - optInAccelerationShort_value, - optInAccelerationMaxShort_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "SAREXT"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_SMA.c b/src/ta_SMA.c deleted file mode 100644 index 8fec2d424..000000000 --- a/src/ta_SMA.c +++ /dev/null @@ -1,154 +0,0 @@ -// interface to ta_SMA.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "SMA" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_SMA.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_SMA_lookback( - SEXP inReal, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_SMA_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_SMA( - SEXP inReal, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_SMA_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_SMA returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_SMA( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "SMA"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_STDDEV.c b/src/ta_STDDEV.c deleted file mode 100644 index 0fb1966d2..000000000 --- a/src/ta_STDDEV.c +++ /dev/null @@ -1,162 +0,0 @@ -// interface to ta_STDDEV.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// double optInNbDev -// -// Returns -// matrix (n x 1) with colum: -// "STDDEV" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_STDDEV.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_STDDEV_lookback( - SEXP inReal, - SEXP optInTimePeriod, - SEXP optInNbDev -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - const double optInNbDev_value = REAL(optInNbDev)[0]; - - // calculate lookback - const int lookback = - TA_STDDEV_Lookback(optInTimePeriod_value, optInNbDev_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_STDDEV( - SEXP inReal, - SEXP optInTimePeriod, - SEXP optInNbDev, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - const double optInNbDev_value = REAL(optInNbDev)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = - TA_STDDEV_Lookback(optInTimePeriod_value, optInNbDev_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_STDDEV returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_STDDEV( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - optInNbDev_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "STDDEV"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_STOCH.c b/src/ta_STOCH.c deleted file mode 100644 index e7cd319a7..000000000 --- a/src/ta_STOCH.c +++ /dev/null @@ -1,203 +0,0 @@ -// interface to ta_STOCH.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// integer optInFastK_Period -// integer optInSlowK_Period -// integer optInSlowK_MAType (MAType) -// integer optInSlowD_Period -// integer optInSlowD_MAType (MAType) -// -// Returns -// matrix (n x 2) with colum: -// "SlowK", "SlowD" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_STOCH.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_STOCH_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInFastK_Period, - SEXP optInSlowK_Period, - SEXP optInSlowK_MAType, - SEXP optInSlowD_Period, - SEXP optInSlowD_MAType -) -// clang-format on -{ - // values - const int optInFastK_Period_value = INTEGER(optInFastK_Period)[0]; - const int optInSlowK_Period_value = INTEGER(optInSlowK_Period)[0]; - const TA_MAType optInSlowK_MAType_value = as_MAType(optInSlowK_MAType); - const int optInSlowD_Period_value = INTEGER(optInSlowD_Period)[0]; - const TA_MAType optInSlowD_MAType_value = as_MAType(optInSlowD_MAType); - - // calculate lookback - const int lookback = TA_STOCH_Lookback( - optInFastK_Period_value, - optInSlowK_Period_value, - optInSlowK_MAType_value, - optInSlowD_Period_value, - optInSlowD_MAType_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_STOCH( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInFastK_Period, - SEXP optInSlowK_Period, - SEXP optInSlowK_MAType, - SEXP optInSlowD_Period, - SEXP optInSlowD_MAType, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const int optInFastK_Period_value = INTEGER(optInFastK_Period)[0]; - const int optInSlowK_Period_value = INTEGER(optInSlowK_Period)[0]; - const TA_MAType optInSlowK_MAType_value = as_MAType(optInSlowK_MAType); - const int optInSlowD_Period_value = INTEGER(optInSlowD_Period)[0]; - const TA_MAType optInSlowD_MAType_value = as_MAType(optInSlowD_MAType); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 3, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 3, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_STOCH_Lookback( - optInFastK_Period_value, - optInSlowK_Period_value, - optInSlowK_MAType_value, - optInSlowD_Period_value, - optInSlowD_MAType_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 2, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *slowk = output_ptr; - double *slowd = output_ptr + 1 * n; - - // TA_STOCH returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_STOCH( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInFastK_Period_value, - optInSlowK_Period_value, - optInSlowK_MAType_value, - optInSlowD_Period_value, - optInSlowD_MAType_value, - &start_idx, - &end_idx, - slowk, - slowd); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(slowk, n, start_idx); - shift_array(slowd, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "SlowK", "SlowD"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_STOCHF.c b/src/ta_STOCHF.c deleted file mode 100644 index f015864db..000000000 --- a/src/ta_STOCHF.c +++ /dev/null @@ -1,187 +0,0 @@ -// interface to ta_STOCHF.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// integer optInFastK_Period -// integer optInFastD_Period -// integer optInFastD_MAType (MAType) -// -// Returns -// matrix (n x 2) with colum: -// "FastK", "FastD" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_STOCHF.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_STOCHF_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInFastK_Period, - SEXP optInFastD_Period, - SEXP optInFastD_MAType -) -// clang-format on -{ - // values - const int optInFastK_Period_value = INTEGER(optInFastK_Period)[0]; - const int optInFastD_Period_value = INTEGER(optInFastD_Period)[0]; - const TA_MAType optInFastD_MAType_value = as_MAType(optInFastD_MAType); - - // calculate lookback - const int lookback = TA_STOCHF_Lookback( - optInFastK_Period_value, - optInFastD_Period_value, - optInFastD_MAType_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_STOCHF( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInFastK_Period, - SEXP optInFastD_Period, - SEXP optInFastD_MAType, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const int optInFastK_Period_value = INTEGER(optInFastK_Period)[0]; - const int optInFastD_Period_value = INTEGER(optInFastD_Period)[0]; - const TA_MAType optInFastD_MAType_value = as_MAType(optInFastD_MAType); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 3, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 3, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_STOCHF_Lookback( - optInFastK_Period_value, - optInFastD_Period_value, - optInFastD_MAType_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 2, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *fastk = output_ptr; - double *fastd = output_ptr + 1 * n; - - // TA_STOCHF returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_STOCHF( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInFastK_Period_value, - optInFastD_Period_value, - optInFastD_MAType_value, - &start_idx, - &end_idx, - fastk, - fastd); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(fastk, n, start_idx); - shift_array(fastd, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "FastK", "FastD"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_STOCHRSI.c b/src/ta_STOCHRSI.c deleted file mode 100644 index 6d5c55a37..000000000 --- a/src/ta_STOCHRSI.c +++ /dev/null @@ -1,183 +0,0 @@ -// interface to ta_STOCHRSI.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// integer optInFastK_Period -// integer optInFastD_Period -// integer optInFastD_MAType (MAType) -// -// Returns -// matrix (n x 2) with colum: -// "FastK", "FastD" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_STOCHRSI.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_STOCHRSI_lookback( - SEXP inReal, - SEXP optInTimePeriod, - SEXP optInFastK_Period, - SEXP optInFastD_Period, - SEXP optInFastD_MAType -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - const int optInFastK_Period_value = INTEGER(optInFastK_Period)[0]; - const int optInFastD_Period_value = INTEGER(optInFastD_Period)[0]; - const TA_MAType optInFastD_MAType_value = as_MAType(optInFastD_MAType); - - // calculate lookback - const int lookback = TA_STOCHRSI_Lookback( - optInTimePeriod_value, - optInFastK_Period_value, - optInFastD_Period_value, - optInFastD_MAType_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_STOCHRSI( - SEXP inReal, - SEXP optInTimePeriod, - SEXP optInFastK_Period, - SEXP optInFastD_Period, - SEXP optInFastD_MAType, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - const int optInFastK_Period_value = INTEGER(optInFastK_Period)[0]; - const int optInFastD_Period_value = INTEGER(optInFastD_Period)[0]; - const TA_MAType optInFastD_MAType_value = as_MAType(optInFastD_MAType); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_STOCHRSI_Lookback( - optInTimePeriod_value, - optInFastK_Period_value, - optInFastD_Period_value, - optInFastD_MAType_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 2, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *fastk = output_ptr; - double *fastd = output_ptr + 1 * n; - - // TA_STOCHRSI returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_STOCHRSI( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - optInFastK_Period_value, - optInFastD_Period_value, - optInFastD_MAType_value, - &start_idx, - &end_idx, - fastk, - fastd); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(fastk, n, start_idx); - shift_array(fastd, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "FastK", "FastD"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_SUM.c b/src/ta_SUM.c deleted file mode 100644 index b1d1782ce..000000000 --- a/src/ta_SUM.c +++ /dev/null @@ -1,154 +0,0 @@ -// interface to ta_SUM.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "SUM" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_SUM.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_SUM_lookback( - SEXP inReal, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_SUM_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_SUM( - SEXP inReal, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_SUM_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_SUM returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_SUM( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "SUM"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_T3.c b/src/ta_T3.c deleted file mode 100644 index 22d1c25f8..000000000 --- a/src/ta_T3.c +++ /dev/null @@ -1,162 +0,0 @@ -// interface to ta_T3.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// double optInVFactor -// -// Returns -// matrix (n x 1) with colum: -// "T3" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_T3.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_T3_lookback( - SEXP inReal, - SEXP optInTimePeriod, - SEXP optInVFactor -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - const double optInVFactor_value = REAL(optInVFactor)[0]; - - // calculate lookback - const int lookback = - TA_T3_Lookback(optInTimePeriod_value, optInVFactor_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_T3( - SEXP inReal, - SEXP optInTimePeriod, - SEXP optInVFactor, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - const double optInVFactor_value = REAL(optInVFactor)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = - TA_T3_Lookback(optInTimePeriod_value, optInVFactor_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_T3 returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_T3( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - optInVFactor_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "T3"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_TEMA.c b/src/ta_TEMA.c deleted file mode 100644 index 43c1298f4..000000000 --- a/src/ta_TEMA.c +++ /dev/null @@ -1,154 +0,0 @@ -// interface to ta_TEMA.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "TEMA" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_TEMA.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_TEMA_lookback( - SEXP inReal, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_TEMA_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_TEMA( - SEXP inReal, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_TEMA_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_TEMA returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_TEMA( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "TEMA"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_TRANGE.c b/src/ta_TRANGE.c deleted file mode 100644 index f6a4738d1..000000000 --- a/src/ta_TRANGE.c +++ /dev/null @@ -1,158 +0,0 @@ -// interface to ta_TRANGE.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "TRANGE" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_TRANGE.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_TRANGE_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_TRANGE_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_TRANGE( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 3, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 3, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_TRANGE_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_TRANGE returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_TRANGE( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "TRANGE"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_TRIMA.c b/src/ta_TRIMA.c deleted file mode 100644 index 5e9f6fcd0..000000000 --- a/src/ta_TRIMA.c +++ /dev/null @@ -1,154 +0,0 @@ -// interface to ta_TRIMA.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "TRIMA" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_TRIMA.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_TRIMA_lookback( - SEXP inReal, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_TRIMA_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_TRIMA( - SEXP inReal, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_TRIMA_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_TRIMA returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_TRIMA( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "TRIMA"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_TRIX.c b/src/ta_TRIX.c deleted file mode 100644 index 99e5d143c..000000000 --- a/src/ta_TRIX.c +++ /dev/null @@ -1,154 +0,0 @@ -// interface to ta_TRIX.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "TRIX" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_TRIX.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_TRIX_lookback( - SEXP inReal, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_TRIX_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_TRIX( - SEXP inReal, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_TRIX_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_TRIX returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_TRIX( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "TRIX"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_TYPPRICE.c b/src/ta_TYPPRICE.c deleted file mode 100644 index 4f127b4c3..000000000 --- a/src/ta_TYPPRICE.c +++ /dev/null @@ -1,158 +0,0 @@ -// interface to ta_TYPPRICE.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "TYPPRICE" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_TYPPRICE.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_TYPPRICE_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_TYPPRICE_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_TYPPRICE( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 3, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 3, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_TYPPRICE_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_TYPPRICE returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_TYPPRICE( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "TYPPRICE"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_ULTOSC.c b/src/ta_ULTOSC.c deleted file mode 100644 index 6d851da35..000000000 --- a/src/ta_ULTOSC.c +++ /dev/null @@ -1,184 +0,0 @@ -// interface to ta_ULTOSC.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// integer optInTimePeriod1 -// integer optInTimePeriod2 -// integer optInTimePeriod3 -// -// Returns -// matrix (n x 1) with colum: -// "ULTOSC" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_ULTOSC.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_ULTOSC_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod1, - SEXP optInTimePeriod2, - SEXP optInTimePeriod3 -) -// clang-format on -{ - // values - const int optInTimePeriod1_value = INTEGER(optInTimePeriod1)[0]; - const int optInTimePeriod2_value = INTEGER(optInTimePeriod2)[0]; - const int optInTimePeriod3_value = INTEGER(optInTimePeriod3)[0]; - - // calculate lookback - const int lookback = TA_ULTOSC_Lookback( - optInTimePeriod1_value, - optInTimePeriod2_value, - optInTimePeriod3_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_ULTOSC( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod1, - SEXP optInTimePeriod2, - SEXP optInTimePeriod3, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const int optInTimePeriod1_value = INTEGER(optInTimePeriod1)[0]; - const int optInTimePeriod2_value = INTEGER(optInTimePeriod2)[0]; - const int optInTimePeriod3_value = INTEGER(optInTimePeriod3)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 3, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 3, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_ULTOSC_Lookback( - optInTimePeriod1_value, - optInTimePeriod2_value, - optInTimePeriod3_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_ULTOSC returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_ULTOSC( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInTimePeriod1_value, - optInTimePeriod2_value, - optInTimePeriod3_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "ULTOSC"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_VAR.c b/src/ta_VAR.c deleted file mode 100644 index f5f3db363..000000000 --- a/src/ta_VAR.c +++ /dev/null @@ -1,160 +0,0 @@ -// interface to ta_VAR.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// double optInNbDev -// -// Returns -// matrix (n x 1) with colum: -// "VAR" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_VAR.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_VAR_lookback( - SEXP inReal, - SEXP optInTimePeriod, - SEXP optInNbDev -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - const double optInNbDev_value = REAL(optInNbDev)[0]; - - // calculate lookback - const int lookback = TA_VAR_Lookback(optInTimePeriod_value, optInNbDev_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_VAR( - SEXP inReal, - SEXP optInTimePeriod, - SEXP optInNbDev, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - const double optInNbDev_value = REAL(optInNbDev)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_VAR_Lookback(optInTimePeriod_value, optInNbDev_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_VAR returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_VAR( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - optInNbDev_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "VAR"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_VOLUME.c b/src/ta_VOLUME.c deleted file mode 100644 index 21591773a..000000000 --- a/src/ta_VOLUME.c +++ /dev/null @@ -1,170 +0,0 @@ -// ta_VOLUME.c -// -// Parameters -// double inReal -// list maSpec (each element is integer(2): c(period, maType)) -// logical na_rm -// -// Returns -// matrix (n x (1 + length(maSpec))) with columns: -// "VOLUME", "" e.g. "SMA7" -// -// The "lookback" attribute is the maximum lookback across all maSpec -// entries, and 0 when no maSpec is supplied. The "VOLUME" column itself -// always has a lookback of 0. -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include -#include -#include - -// the lookback function is exported as a standalone function for downstream -// wrappers. 'inReal' is unused but kept for call-signature parity with -// impl_ta_VOLUME -// clang-format off -SEXP impl_ta_VOLUME_lookback( - SEXP inReal, - SEXP maSpec -) -// clang-format on -{ - (void)inReal; - - const int n_ma = isNull(maSpec) ? 0 : LENGTH(maSpec); - - // maximum lookback across all maSpec entries (stays 0 when none supplied) - int lookback = 0; - for (int j = 0; j < n_ma; ++j) { - // each specification is integer(2): c(period, maType) - const int *spec = INTEGER(VECTOR_ELT(maSpec, j)); - const int ma_lookback = TA_MA_Lookback(spec[0], (TA_MAType)spec[1]); - if (ma_lookback > lookback) { - lookback = ma_lookback; - } - } - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_VOLUME( - SEXP inReal, - SEXP maSpec, - SEXP na_rm -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - const double *x = REAL(inReal); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_rm)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {x}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - x = na_arrays[0]; - } else { - na_mask = NULL; - } - } - - // one column for 'VOLUME' plus one per moving average - const int n_ma = isNull(maSpec) ? 0 : LENGTH(maSpec); - const int n_cols = 1 + n_ma; - - // the output container is either an INTSXP or REALSXP and returns a - // matrix of on a lookback mismatch - the 'VOLUME' column is always - // valid, so the container lookback is 0 - // see container.h for more details - SEXP output; - double *output_ptr; - output_container(n, 0, n_cols, &output, &output_ptr, &protection_count); - - // first column is the (NA-compacted) volume itself - memcpy(output_ptr, x, (size_t)n * sizeof(double)); - - // column names: "VOLUME" followed by "" - const char **colname = - (const char **)R_alloc((size_t)n_cols, sizeof(*colname)); - colname[0] = "VOLUME"; - - // maximum lookback across all maSpec entries (stays 0 when none supplied) - int lookback = 0; - - for (int j = 0; j < n_ma; ++j) { - // each specification is integer(2): c(period, maType) - const int *spec = INTEGER(VECTOR_ELT(maSpec, j)); - const int period = spec[0]; - const TA_MAType ma_type = (TA_MAType)spec[1]; - - // track the largest lookback seen so far - const int ma_lookback = TA_MA_Lookback(period, ma_type); - if (ma_lookback > lookback) { - lookback = ma_lookback; - } - - // moving average is written into column (j + 1) - double *restrict ma = output_ptr + (size_t)(j + 1) * (size_t)n; - - int start_idx = 0; - int end_idx = 0; - - // clang-format off - TA_RetCode return_value = TA_MA( - 0, - n - 1, - x, - period, - ma_type, - &start_idx, - &end_idx, - ma - ); - // clang-format on - check_output(return_value, protection_count); - - // pad the leading 'start_idx' rows with so the column has 'n' rows - // see shift.h for more details - shift_array(ma, n, start_idx); - - char *buffer = (char *)R_alloc(32, sizeof(char)); - snprintf(buffer, 32, "%s%d", _MAType_(ma_type), period); - colname[j + 1] = buffer; - } - - // set the column names and the (maximum) lookback attribute - // see names.h and attributes.h for more details - column_names(output, n_cols, colname); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = - reexpand_double_matrix(output, na_mask, n_original, &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_WCLPRICE.c b/src/ta_WCLPRICE.c deleted file mode 100644 index 168775eaa..000000000 --- a/src/ta_WCLPRICE.c +++ /dev/null @@ -1,158 +0,0 @@ -// interface to ta_WCLPRICE.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// -// Returns -// matrix (n x 1) with colum: -// "WCLPRICE" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_WCLPRICE.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_WCLPRICE_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose -) -// clang-format on -{ - // values - - // calculate lookback - const int lookback = TA_WCLPRICE_Lookback(); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_WCLPRICE( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 3, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 3, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_WCLPRICE_Lookback(); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_WCLPRICE returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_WCLPRICE( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "WCLPRICE"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_WILLR.c b/src/ta_WILLR.c deleted file mode 100644 index a333dfad1..000000000 --- a/src/ta_WILLR.c +++ /dev/null @@ -1,166 +0,0 @@ -// interface to ta_WILLR.c -// -// Parameters -// double inHigh -// double inLow -// double inClose -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "WILLR" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_WILLR.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_WILLR_lookback( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_WILLR_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_WILLR( - SEXP inHigh, - SEXP inLow, - SEXP inClose, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inHigh' (assumes equal length across input) - int n = LENGTH(inHigh); - - // pointers to input arrays - const double *inHigh_ptr = REAL(inHigh); - const double *inLow_ptr = REAL(inLow); - const double *inClose_ptr = REAL(inClose); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inHigh_ptr, inLow_ptr, inClose_ptr}; - n = build_na_mask(na_mask, n, 3, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 3, na_mask, n_original, n); - inHigh_ptr = na_arrays[0]; - inLow_ptr = na_arrays[1]; - inClose_ptr = na_arrays[2]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_WILLR_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_WILLR returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_WILLR( - 0, - n - 1, - inHigh_ptr, - inLow_ptr, - inClose_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "WILLR"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/ta_WMA.c b/src/ta_WMA.c deleted file mode 100644 index e16d9c6b0..000000000 --- a/src/ta_WMA.c +++ /dev/null @@ -1,154 +0,0 @@ -// interface to ta_WMA.c -// -// Parameters -// double inReal -// integer optInTimePeriod -// -// Returns -// matrix (n x 1) with colum: -// "WMA" -// -// Source -// https://github.com/TA-Lib/ta-lib/blob/main/src/ta_func/ta_WMA.c -// -#include "MAType.h" -#include "attributes.h" -#include "container.h" -#include "lib.h" -#include "na.h" -#include "names.h" -#include "shift.h" -#include -#include -#include - -// the lookback function -// is exported as a standalone -// function for downstream wrappers -// clang-format off -SEXP impl_ta_WMA_lookback( - SEXP inReal, - SEXP optInTimePeriod -) -// clang-format on -{ - // values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // calculate lookback - const int lookback = TA_WMA_Lookback(optInTimePeriod_value); - - SEXP output = PROTECT(Rf_ScalarInteger(lookback)); - - // unprotect output - UNPROTECT(1); - return output; -} - -// clang-format off -SEXP impl_ta_WMA( - SEXP inReal, - SEXP optInTimePeriod, - SEXP na_bridge -) -// clang-format on -{ - // protection counter - int protection_count = 0; - - // get length of 'inReal' (assumes equal length across input) - int n = LENGTH(inReal); - - // pointers to input arrays - const double *inReal_ptr = REAL(inReal); - - // extract input values - const int optInTimePeriod_value = INTEGER(optInTimePeriod)[0]; - - // NA handling - // see na.h for more details - int *na_mask = NULL; - const int n_original = n; - - if (LOGICAL(na_bridge)[0]) { - na_mask = (int *)R_alloc(n, sizeof(int)); - const double *na_arrays[] = {inReal_ptr}; - n = build_na_mask(na_mask, n, 1, na_arrays); - if (n < n_original) { - compact_arrays(na_arrays, 1, na_mask, n_original, n); - inReal_ptr = na_arrays[0]; - - } else { - na_mask = NULL; - } - } - - // output - SEXP output; - double *output_ptr; - - // calculate look back and exit - // the function function early if - // there is a mismatch - const int lookback = TA_WMA_Lookback(optInTimePeriod_value); - - // the output container is either a INTSXP or - // REALSXP depending on the type and will - // return a matrix with if there is a mismatch - // between lookback and n - // - // see container.h for more details - const int proceed = - output_container(n, lookback, 1, &output, &output_ptr, &protection_count); - - if (proceed) { - int start_idx = 0; - int end_idx = 0; - - double *real = output_ptr; - - // TA_WMA returns an TA_RetCode - // which is TA_SUCCESS if it succeeds - // values in output_ptr gets populated - // by pointers - TA_RetCode return_code = TA_WMA( - 0, - n - 1, - inReal_ptr, - optInTimePeriod_value, - &start_idx, - &end_idx, - real); - - // check if the output is valid - // and stop function with the TA_RetCode - // see container.h for more details - check_output(return_code, protection_count); - - // shift the array so it has the same number - // of rows as 'n' - shifted values is replaced - // with - // see shift.h for more details - shift_array(real, n, start_idx); - } - - // set the column names and lookback attribute - // of the output container - // see names.h and attributes.h for more details - set_colnames(output, "WMA"); - set_attribute(output, lookback, &protection_count); - - // re-expand output if NAs were stripped - // see na.h for more details - if (na_mask != NULL) { - output = reexpand_matrix( - output, - output_ptr, - na_mask, - n_original, - &protection_count); - } - - UNPROTECT(protection_count); - return output; -} diff --git a/src/utils.c b/src/utils.c new file mode 100644 index 000000000..1a2d81b34 --- /dev/null +++ b/src/utils.c @@ -0,0 +1,27 @@ +#include "utils.h" +#include // ISNAN, NA_REAL, NA_INTEGER +#include // R_alloc +#include +#include + +const double *ta_real(SEXP s, R_xlen_t n, int *nprot, const char *name) { + if (XLENGTH(s) != n) + Rf_error( + "input '%s' has length %lld, expected %lld", + name, + (long long)XLENGTH(s), + (long long)n); + SEXP c = PROTECT(Rf_coerceVector(s, REALSXP)); + (*nprot)++; + return REAL(c); +} + +// NA-bridge helpers for the `na.bridge` path now live in NA-handling.{h,c}. + +void ta_check(TA_RetCode rc, const char *fn) { + if (rc == TA_SUCCESS) + return; + TA_RetCodeInfo info; + TA_SetRetCodeInfo(rc, &info); + Rf_error("%s: %s (%s)", fn, info.infoStr, info.enumStr); +} diff --git a/src/utils.h b/src/utils.h new file mode 100644 index 000000000..ec81bf4fb --- /dev/null +++ b/src/utils.h @@ -0,0 +1,22 @@ +// utils.h +// +// Description +// All functions are implemented in utils.c, and includes +// helper functions that ease the process in porting indicators +// to R. +// +#ifndef UTILS_H +#define UTILS_H + +#include "ta_libc.h" +#include + +/* Coerce s to a REAL buffer, PROTECT it (++*nprot), verify length == n. */ +const double *ta_real(SEXP s, R_xlen_t n, int *nprot, const char *name); + +/* NA-bridge helpers for the `na.bridge` path live in NA-handling.{h,c}. */ + +/* rc != TA_SUCCESS -> Rf_error(": ()"). */ +void ta_check(TA_RetCode rc, const char *fn); + +#endif /* UTILS_H */ diff --git a/src/volume.c b/src/volume.c new file mode 100644 index 000000000..5f4dd1987 --- /dev/null +++ b/src/volume.c @@ -0,0 +1,197 @@ +// Trading Volume +// +// Description: +// Trading volume is not an officially exported TA-Lib indicator, so this +// wrapper is hand-written instead of being generated by the TA_WRAPPER +// X-macro in wrapper.h. It returns the volume series alongside one moving +// average column per 'ma' specification. +// +// Parameters +// inReal REALSXP the volume series +// maSpec VECSXP list of integer(2) specs: c(period, maType); may be +// NULL na_bridge LGLSXP drop NA rows, compute on the dense series, scatter +// back +// +// Returns +// REALSXP matrix (n x (1 + length(maSpec))) with columns: +// "VOLUME", "" e.g. "SMA7" +// +// The "lookback" attribute is the (normalized) maximum lookback across all +// maSpec entries; the "VOLUME" column itself always has a lookback of 0. +// +#include "NA-handling.h" +#include "attributes.h" +#include "names.h" +#include "shift.h" +#include "utils.h" +#include +#include +#include +#include +#include + +// MAType names mapped by indices +// clang-format off +static const char *const MATypeNames[] = { + "SMA", + "EMA", + "WMA", + "DEMA", + "TEMA", + "TRIMA", + "KAMA", + "MAMA", + "T3" +}; +// clang-format on + +// Trading Volume lookback +// clang-format off +SEXP impl_ta_VOLUME_lookback( + SEXP maSpec +) +// clang-format on +{ + + const int n_ma = Rf_isNull(maSpec) ? 0 : LENGTH(maSpec); + int lookback = 0; + + if (n_ma > 0) { + + for (int j = 0; j < n_ma; ++j) { + // each specification is integer(2): c(period, maType) + const int *spec = INTEGER(VECTOR_ELT(maSpec, j)); + const int ma_lookback = TA_MA_Lookback(spec[0], (TA_MAType)spec[1]); + if (ma_lookback > lookback) { + lookback = ma_lookback; + } + } + } else { + lookback += 1; + } + + return Rf_ScalarInteger(normalize_lookback(lookback)); +} + +// clang-format off +SEXP impl_ta_VOLUME( + SEXP inReal, + SEXP maSpec, + SEXP na_bridge +) +// clang-format on +{ + // protection counter + int protection_counter = 0; + + // extract length of the + // input vector + R_xlen_t ta_n = XLENGTH(inReal); + + // throw error if the length + // is larger than the allowed + if (ta_n > INT_MAX) { + Rf_error("TA_VOLUME: series length exceeds INT_MAX"); + } + + // clang-format off + const double *volume = ta_real( + inReal, + ta_n, + &protection_counter, + "inReal" + ); + // clang-format on + + // get number of moving averages + // with the number of columns + // NOTE: There is always one column (volume column) + const int n_ma = Rf_isNull(maSpec) ? 0 : LENGTH(maSpec); + const int n_cols = 1 + n_ma; + + // identify and extract missing values + // from the input + // + // see NA-handling.h for more details + int ta_bridge = (Rf_asLogical(na_bridge) == TRUE); + R_xlen_t ta_calc = ta_n; + unsigned char *ta_mask = NULL; + if (ta_bridge && ta_n > 0) { + + const double *ta_ins[] = {volume}; + ta_calc = build_presence_mask(ta_ins, 1, ta_n, &ta_mask); + if (ta_calc > 0) { + double *ta_dense = dense_array(ta_calc, 1); + volume = compact_array(ta_dense, volume, ta_mask, ta_n); + } + } + + // construct output matrix + // and copy data + SEXP out = PROTECT(Rf_allocMatrix(REALSXP, (int)ta_n, n_cols)); + protection_counter++; + double *out_ptr = REAL(out); + + memcpy(out_ptr, volume, (size_t)ta_calc * sizeof(double)); + + const char **colname = + (const char **)R_alloc((size_t)n_cols, sizeof(*colname)); + colname[0] = "VOLUME"; + + int lookback = 0; + for (int j = 0; j < n_ma; ++j) { + + const int *spec = INTEGER(VECTOR_ELT(maSpec, j)); + const int period = spec[0]; + const TA_MAType ma_type = (TA_MAType)spec[1]; + + // track the largest lookback seen so far + const int ma_lookback = TA_MA_Lookback(period, ma_type); + if (ma_lookback > lookback) { + lookback = ma_lookback; + } + + // moving average is written into column (j + 1) + double *ma = out_ptr + (size_t)(j + 1) * (size_t)ta_n; + + int begIdx = 0; + int nbElement = 0; + if (ta_calc > 0) { + // clang-format off + TA_RetCode return_value = TA_MA( + 0, + (int)ta_calc - 1, + volume, + period, + ma_type, + &begIdx, + &nbElement, + ma + ); + // clang-format on + ta_check(return_value, "TA_MA"); + } + + if (ta_bridge) { + scatter_array(ma, ta_n, ta_mask, ta_calc, begIdx, nbElement); + } else { + shift_array(ma, ta_n, begIdx, nbElement); + } + + char *buffer = (char *)R_alloc(32, sizeof(char)); + snprintf(buffer, 32, "%s%d", MATypeNames[ma_type], period); + colname[j + 1] = buffer; + } + + if (ta_bridge) { + scatter_array(out_ptr, ta_n, ta_mask, ta_calc, 0, (int)ta_calc); + } + + // set the column names and the (normalized, maximum) lookback attribute + // see names.h and attributes.h for more details + set_colnames(out, colname, n_cols); + set_attribute(out, LOOKBACK, Rf_ScalarInteger(lookback), &protection_counter); + + UNPROTECT(protection_counter); + return out; +} diff --git a/src/wrapper.h b/src/wrapper.h new file mode 100644 index 000000000..8a32a55a2 --- /dev/null +++ b/src/wrapper.h @@ -0,0 +1,256 @@ +// wrapper.h +// +// Description: +// This header file extracts and parses +// all arguments from each TA_INDICATOR located +// in TA-Lib.h using X-Macros +#ifndef WRAPPER_H +#define WRAPPER_H + +#include "NA-handling.h" +#include "attributes.h" +#include "names.h" +#include "normalize.h" +#include "preprocessor.h" +#include "shift.h" +#include "utils.h" + +// Extract nested expressions from each +// TA_INDICATOR(...) +#define TA_INPUT(...) (__VA_ARGS__) +#define TA_OPTIONS(...) (__VA_ARGS__) +#define TA_OUTPUT(...) (__VA_ARGS__) +#define TA_OUTPUT_NAME(...) (__VA_ARGS__) + +// Optional parameter(s) mapped to +// their R counterpart +#define OPTIONAL_INTEGER(n) (int, Rf_asInteger, n, ) +#define OPTIONAL_DOUBLE(n) (double, Rf_asReal, n, ) +#define OPTIONAL_MATYPE(n) (int, Rf_asInteger, n, (TA_MAType)) + +// output element type tag (TA_DOUBLE|TA_INTEGER) -> R type/accessor +#define TA_SXP(RT) TA_CAT(TA_SXP_, RT) +#define TA_SXP_TA_DOUBLE REALSXP +#define TA_SXP_TA_INTEGER INTSXP +#define TA_ACC(RT) TA_CAT(TA_ACC_, RT) +#define TA_ACC_TA_DOUBLE REAL +#define TA_ACC_TA_INTEGER INTEGER + +// per-input workers +// TA_IN_ARG / TA_OPT_ARG emit trailing-comma parameters; the fixed final +// s_na_bridge parameter absorbs the last comma, so no first-argument special +// case is needed (same trick as the TA_IN_PASS call list below). +#define TA_IN_ARG(name) SEXP s_##name, +#define TA_IN_COERCE(name) \ + const double *name = ta_real(s_##name, ta_n, &protection_counter, #name); +#define TA_IN_PASS(name) name, +// na.bridge workers: TA_IN_PTR builds the input-pointer array for mask +// construction; TA_IN_COMPACT gathers each input into its dense column and +// repoints the local pointer at it so the TA-Lib call below sees the dense +// series unchanged. +#define TA_IN_PTR(name) name, +#define TA_IN_COMPACT(name) \ + name = compact_array(ta_dense + ta_dcol * ta_calc, name, ta_mask, ta_n); \ + ta_dcol++; + +// per-opt workers (consume the tuple) +#define TA_OPT_ARG(t) TA_OPT_ARG_ t +#define TA_OPT_ARG_(c, r, n, k) SEXP s_##n, +#define TA_OPT_READ(t) TA_OPT_READ_ t +#define TA_OPT_READ_(c, r, n, k) c n = r(s_##n); +#define TA_OPT_PASS(t) TA_OPT_PASS_ t +#define TA_OPT_PASS_(c, r, n, k) k n, +// lookback-arg variant of TA_OPT_PASS: same casted value but WITHOUT a trailing +// comma, so TA_JOIN can build the TA__Lookback(...) call list. +#define TA_LB_PASS(t) TA_LB_PASS_ t +#define TA_LB_PASS_(c, r, n, k) k n + +// no-comma sibling of TA_OPT_ARG: one SEXP parameter per opt, comma-joined via +// TA_JOIN to form the impl_ta__lookback(...) signature. +#define TA_LB_ARG(t) TA_LB_ARG_ t +#define TA_LB_ARG_(c, r, n, k) SEXP s_##n + +// parameter list for impl_ta__lookback: (void) when the indicator takes +// no options (keeps -Wstrict-prototypes happy), otherwise the joined opts. +#define TA_LB_PARAMS(OPTS_) \ + TA_CAT(TA_LB_PARAMS_, TA_COUNT_ARGUMENTS OPTS_)(OPTS_) +#define TA_LB_PARAMS_0(OPTS_) void +#define TA_LB_PARAMS_1(OPTS_) TA_JOIN(TA_LB_ARG, OPTS_) +#define TA_LB_PARAMS_2(OPTS_) TA_JOIN(TA_LB_ARG, OPTS_) +#define TA_LB_PARAMS_3(OPTS_) TA_JOIN(TA_LB_ARG, OPTS_) +#define TA_LB_PARAMS_4(OPTS_) TA_JOIN(TA_LB_ARG, OPTS_) +#define TA_LB_PARAMS_5(OPTS_) TA_JOIN(TA_LB_ARG, OPTS_) +#define TA_LB_PARAMS_6(OPTS_) TA_JOIN(TA_LB_ARG, OPTS_) +#define TA_LB_PARAMS_7(OPTS_) TA_JOIN(TA_LB_ARG, OPTS_) +#define TA_LB_PARAMS_8(OPTS_) TA_JOIN(TA_LB_ARG, OPTS_) + +// +#define TA_ALLOC(RT, OUTS_) \ + Rf_allocMatrix(TA_SXP(RT), (int)ta_n, (TA_COUNT_ARGUMENTS OUTS_)) + +#define TA_OUT_PTRS(RT, OUTS_) \ + TA_CAT(TA_OUT_PTRS_, TA_COUNT_ARGUMENTS OUTS_)(RT) +#define TA_OUT_PTRS_1(RT) TA_ACC(RT)(out) +#define TA_OUT_PTRS_2(RT) TA_ACC(RT)(out) + 0 * ta_n, TA_ACC(RT)(out) + 1 * ta_n +#define TA_OUT_PTRS_3(RT) \ + TA_ACC(RT)(out) + 0 * ta_n, TA_ACC(RT)(out) + 1 * ta_n, \ + TA_ACC(RT)(out) + 2 * ta_n + +// One shift per output column; column count is a compile-time literal. +#define TA_OUT_PAD(RT, OUTS_) \ + for (int ta_col = 0; ta_col < (TA_COUNT_ARGUMENTS OUTS_); ta_col++) \ + shift_array(TA_ACC(RT)(out) + ta_col * ta_n, ta_n, begIdx, nbElement); + +// na.bridge counterpart of TA_OUT_PAD: expand each dense output column back +// to full length, scattering NA into dropped rows and lookback slots. +#define TA_OUT_SCATTER(RT, OUTS_) \ + for (int ta_col = 0; ta_col < (TA_COUNT_ARGUMENTS OUTS_); ta_col++) \ + scatter_array( \ + TA_ACC(RT)(out) + ta_col * ta_n, \ + ta_n, \ + ta_mask, \ + ta_calc, \ + begIdx, \ + nbElement); + +// colnames for the output matrix. Every indicator returns a matrix (single +// output included), so stringize every name into the array and label the +// matrix regardless of column count. +#define TA_OUT_COLNAME(a) #a, +#define TA_OUT_COLNAMES(NAMES_) \ + TA_CAT(TA_OUT_COLNAMES_, TA_COUNT_ARGUMENTS NAMES_)(NAMES_) +#define TA_OUT_COLNAMES_1(NAMES_) TA_OUT_COLNAMES_MANY(NAMES_) +#define TA_OUT_COLNAMES_2(NAMES_) TA_OUT_COLNAMES_MANY(NAMES_) +#define TA_OUT_COLNAMES_3(NAMES_) TA_OUT_COLNAMES_MANY(NAMES_) +#define TA_OUT_COLNAMES_MANY(NAMES_) \ + { \ + static const char *ta_cn[] = {TA_APPLY(TA_OUT_COLNAME, NAMES_)}; \ + set_colnames(out, ta_cn, TA_COUNT_ARGUMENTS NAMES_); \ + } + +// candlestick normalization seam +// Only CANDLESTICK indicators carry the extra SEXP s_normalize control arg. +// TA_NORM_ARG appends it to the signature; TA_NORM_APPLY divides the dense +// computed region by 100 (before padding, so NA slots are never touched); +// TA_NORM_ARITY bumps the registered .Call arity. NOT_CANDLESTICK -> nothing. +#define TA_NORM_ARG_CANDLESTICK , SEXP s_normalize +#define TA_NORM_ARG_NOT_CANDLESTICK + +#define TA_NORM_APPLY_CANDLESTICK(RT) \ + if (Rf_asLogical(s_normalize) == TRUE) \ + normalize(TA_ACC(RT)(out), nbElement, 100, 0); +#define TA_NORM_APPLY_NOT_CANDLESTICK(RT) + +#define TA_NORM_ARITY_CANDLESTICK 1 +#define TA_NORM_ARITY_NOT_CANDLESTICK 0 + +// TA-Lib wrapper +// +// Description +// This is the X-macro that writes the actual +// underlying C-code that ports TA-Lib to R. +// Before the migrating to X-Macros the code below +// were autogenerated via BASH which produced the ta_.c files +// clang-format off +#define TA_WRAPPER(NAME, RT, INS_, OPTS_, OUTS_, TA_OUTPUT_NAME_, KIND) \ + /* signature start */ \ + SEXP impl_ta_##NAME( \ + TA_APPLY(TA_IN_ARG, INS_) \ + TA_APPLY(TA_OPT_ARG, OPTS_) \ + SEXP s_na_bridge \ + TA_CAT(TA_NORM_ARG_, KIND) \ + ) \ + /* signature end*/ \ + /* logic start*/ \ + { \ + /* protection counter */ \ + int protection_counter = 0; \ + R_xlen_t ta_n = XLENGTH(TA_CAT(s_, TA_HEAD INS_)); \ + \ + if (ta_n > INT_MAX) { \ + Rf_error("TA_" #NAME ": series length exceeds INT_MAX"); \ + } \ + \ + /* convert input to type aware pointers */ \ + TA_APPLY(TA_IN_COERCE, INS_) \ + TA_APPLY(TA_OPT_READ, OPTS_) \ + \ + /* na.bridge: drop NA rows, compute on the dense series, scatter back. */ \ + int ta_bridge = (Rf_asLogical(s_na_bridge) == TRUE); \ + R_xlen_t ta_calc = ta_n; \ + unsigned char *ta_mask = NULL; \ + if (ta_bridge && ta_n > 0) { \ + \ + const double *ta_ins[] = {TA_APPLY(TA_IN_PTR, INS_)}; \ + \ + ta_calc = build_presence_mask( \ + ta_ins, \ + (int)(TA_COUNT_ARGUMENTS INS_), \ + ta_n, \ + &ta_mask \ + ); \ + \ + if (ta_calc > 0) { \ + double *ta_dense = dense_array( \ + ta_calc, \ + (int)(TA_COUNT_ARGUMENTS INS_) \ + ); \ + \ + int ta_dcol = 0; \ + \ + TA_APPLY(TA_IN_COMPACT, INS_) \ + } \ + } \ + SEXP out = PROTECT(TA_ALLOC(RT, OUTS_)); \ + protection_counter++; \ + int begIdx = 0, nbElement = 0; \ + if (ta_calc > 0) { \ + TA_RetCode return_value = TA_##NAME( \ + 0, \ + (int) ta_calc - 1, \ + TA_APPLY(TA_IN_PASS, INS_) TA_APPLY(TA_OPT_PASS, OPTS_) & begIdx, \ + &nbElement, \ + TA_OUT_PTRS(RT, OUTS_) \ + ); \ + \ + ta_check(return_value, "TA_" #NAME); \ + \ + TA_CAT(TA_NORM_APPLY_, KIND)(RT) \ + } \ + if (ta_bridge) { \ + TA_OUT_SCATTER(RT, OUTS_) \ + } else if (ta_calc > 0) { \ + TA_OUT_PAD(RT, OUTS_) \ + } \ + TA_OUT_COLNAMES(TA_OUTPUT_NAME_) \ + \ + /* lookback attributes */ \ + int lookback_value = TA_##NAME##_Lookback(TA_JOIN(TA_LB_PASS, OPTS_)); \ + \ + set_attribute( \ + out, \ + LOOKBACK, \ + Rf_ScalarInteger(lookback_value), \ + &protection_counter \ + ); \ + \ + UNPROTECT(protection_counter); \ + return out; \ + } \ + /* logic end*/ +// clang-format on + +// TA__Lookback wrapper +// Driven by the TA_LOOKBACK(NAME, TA_OPTIONS(...)) lines in TA-Lib.h. The +// R-callable impl_ta__lookback() reads the optional inputs from +// their SEXPs, calls the pure TA__Lookback(), and returns the +// (normalized) lookback - the same value set_attribute() attaches to the +// indicator output. +#define TA_LB_WRAPPER(NAME, OPTS_) \ + SEXP impl_ta_##NAME##_lookback(TA_LB_PARAMS(OPTS_)) { \ + TA_APPLY(TA_OPT_READ, OPTS_) \ + return Rf_ScalarInteger( \ + normalize_lookback(TA_##NAME##_Lookback(TA_JOIN(TA_LB_PASS, OPTS_)))); \ + } + +#endif /* WRAPPER_H */ From 749e242cf551b11a193b0834defea4d1f083fd9c Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Tue, 14 Jul 2026 23:06:43 +0200 Subject: [PATCH 7/8] :hammer: Added cargo commands and removed obsolete scripts * fmt target now also runs cargo fmt on the crate * gen-code target now includes cargo run * Deleted old script runners --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 687f4028a..aefae403a 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,6 @@ document: ## Build R documentation @Rscript --verbose -e "devtools::document()" build: clean fmt ## Build the R package - @codegen/generate_API.sh src/ src/api.h && codegen/generate_FFI.sh src/api.h src/init.c && $(MAKE) fmt @$(MAKE) document @R CMD build . --no-build-vignettes && R CMD INSTALL $(tarball_location) @rm -rf README.md @@ -69,6 +68,7 @@ fmt: ## Format code @air format R @air format tests/testthat @rm -rf ./.clang-format + @cargo fmt --manifest-path codegen/Cargo.toml pkgdown-build: ## Build {pkgdown} documentation @$(MAKE) document @@ -133,5 +133,6 @@ parity-clean: ## Remove parity build artifacts and the generated test file @rm -rf tests/parity/snapshot gen-code: ## Generate R wrappers and unit-tests + @cargo run --manifest-path codegen/Cargo.toml @Rscript --verbose ./codegen/gen_code/generate.R $(MAKE) fmt \ No newline at end of file From 0010b8907d19bc2d16ba7ad3a194b1c858440a58 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Tue, 14 Jul 2026 23:08:48 +0200 Subject: [PATCH 8/8] :broom: Formatted .rs-files --- codegen/src/main.rs | 17 ++++++++++++----- codegen/src/parser.rs | 36 ++++++++++++++++++++---------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/codegen/src/main.rs b/codegen/src/main.rs index 0cfcd24f9..b79e67bc3 100644 --- a/codegen/src/main.rs +++ b/codegen/src/main.rs @@ -1,12 +1,12 @@ // load the parser mod parser; use parser::purge_comments; -use std::{fs}; +use std::fs; use crate::parser::{TA_Lib, extract_signature}; /// BATCH_INDICATOR_MACRO -/// +/// /// TA_INDICATOR: The indicator function of TA-Lib, e.g. TA_SMA() and its type /// TA_INPUT: The input to the TA-Lib indicator, e.g. inReal /// TA_OPTIONS: The optional input in the TA-Lib indicator, e.g. optInWindow @@ -22,7 +22,11 @@ fn BATCH_INDICATOR_MACRO(function: &TA_Lib) -> String { function.optional_input.join(", "), function.output_indicators.join(", "), function.output_names.join(", "), - if function.indicator.starts_with("CDL") { "CANDLESTICK" } else {"NOT_CANDLESTICK"} + if function.indicator.starts_with("CDL") { + "CANDLESTICK" + } else { + "NOT_CANDLESTICK" + } ) } @@ -40,7 +44,7 @@ fn LOOKBACK_MACRO(function: &TA_Lib) -> String { ) } -/// +/// fn main() { // The goal is to write two files (I think) let list = fs::read_to_string("src/ta-lib/ta_func_list.txt").expect("read ta_func_list.txt"); @@ -54,7 +58,10 @@ fn main() { .map(str::to_string) .collect(); - let funcs: Vec = names.iter().map(|n| extract_signature(n, &header)).collect(); + let funcs: Vec = names + .iter() + .map(|n| extract_signature(n, &header)) + .collect(); // populate the src/TA-Lib.h file // with decorative headers that only diff --git a/codegen/src/parser.rs b/codegen/src/parser.rs index 7d2a06537..8eefbc6dd 100644 --- a/codegen/src/parser.rs +++ b/codegen/src/parser.rs @@ -1,10 +1,10 @@ /// TA-Lib header parser -/// +/// /// Functions are parsed from 'src/ta-lib/include/ta_func.h' /// deterministically - All functions follows the same structure /// TA_foo(InputIdx, Input, OptionalArguments, OutputIdx, Output) /// which means that the entire header can just be mined directly. -/// +/// /// Prior to this Rust parser, a BASH script were used to achieve the /// same thing - however, it introduced a significant overhead when new /// arguments were introduced on the R side and the BASH script kept @@ -17,7 +17,7 @@ pub struct TA_Lib { pub input: Vec, pub optional_input: Vec, pub output_indicators: Vec, - pub output_names: Vec + pub output_names: Vec, } /// Each TA_Lib function defined in the header @@ -25,18 +25,18 @@ pub struct TA_Lib { /// /// /* /// * TA_ACCBANDS - Acceleration Bands -/// * +/// * /// * Input = High, Low, Close /// * Output = double, double, double -/// * +/// * /// * Optional Parameters /// * ------------------- /// * optInTimePeriod:(From 2 to 100000) /// * Number of period -/// * -/// * +/// * +/// * /// */ -/// +/// /// TA_LIB_API TA_RetCode TA_ACCBANDS( /// int startIdx, /// int endIdx, @@ -53,7 +53,7 @@ pub struct TA_Lib { /// /// So each function can be easily identified /// and parsed accordingly -/// +/// /// The goal is to build a X-Macro on the C-side /// that is variadic to reduce the amount of code /// in the wrapper @@ -65,9 +65,7 @@ pub fn purge_comments(TA: &str) -> String { // the function outputs // a string - let mut output = String::with_capacity( - TA.len() - ); + let mut output = String::with_capacity(TA.len()); // strip all comments let mut i = 0; @@ -156,7 +154,11 @@ pub fn extract_signature(indicator: &str, header: &str) -> TA_Lib { // determine the type of the array // if its an output arrays and set // output indicator arrays (e.g outReal) - f.argument_type = if p.contains("double") { "TA_DOUBLE" } else { "TA_INTEGER" }; + f.argument_type = if p.contains("double") { + "TA_DOUBLE" + } else { + "TA_INTEGER" + }; f.output_indicators.push(nm); } } else { @@ -182,7 +184,6 @@ pub fn extract_signature(indicator: &str, header: &str) -> TA_Lib { // from the outputs the indicator name is replaced so // outReal becomes SMA for TA_SMA() for output in &f.output_indicators { - // strip the following strings // from the output: 'out', 'Real' and 'Integer' let bare = output.strip_prefix("out").unwrap_or(output); @@ -265,7 +266,10 @@ mod tests { "OPT_MA(optInMAType)" ] ); - assert_eq!(f.output_indicators, ["outRealUpperBand", "outRealMiddleBand", "outRealLowerBand"]); + assert_eq!( + f.output_indicators, + ["outRealUpperBand", "outRealMiddleBand", "outRealLowerBand"] + ); assert_eq!(f.output_names, ["UpperBand", "MiddleBand", "LowerBand"]); } @@ -283,4 +287,4 @@ mod tests { fn strips_comments() { assert_eq!(purge_comments("a /* x */ b"), "a b"); } -} \ No newline at end of file +}