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 01/37] :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 02/37] :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 03/37] :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 04/37] :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 05/37] :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 06/37] :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 07/37] :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 08/37] :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 +} From 0769baff244511eec1175fb6c14544547a3440dc Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 10:46:51 +0200 Subject: [PATCH 09/37] :fire: Refactored R codegen * This commit mainly brings a new backend to the codegeneration on the R side - the old generation were handled by a mix of R and BASH which were harder to maintain than first expected. shQuote() or was it paste()? And how does BASH recieve these arguments? These were questions and debugging the code generation were riddled with. Using Rust unifies the headache in a uniform way, which seems to be easier maintainable. * The code generation is mainly handled by mining the .xml file that TA-Lib constructs without any modifications to the input arguments. This means two things: (1) breaking changes in R signatures and (2) bug-fixes where MATypes were mixed with multiple indicators (See ta_APO.R) where the MAType's role were ambigious. {talib} is still in pre 1.0.0 and the download counts are so low that there should not be any breakage in dependencies downstream. * The code generation on the R side is (at this stage) a brute attempt which means that some of the exported functions are either broken or incorrectly named. These will be fixed in the subsequent commits to avoid too many changes in a single commit. This squash commit contains 24 (ish) commits, which makes the development flow non-transparent, which is also why the bugs are kept as-is at this stage. --- CLAUDE.md | 20 +- R/ta_ACCBANDS.R | 48 +- R/ta_AD.R | 22 +- R/ta_ADOSC.R | 76 +- R/ta_ADX.R | 50 +- R/ta_ADXR.R | 50 +- R/ta_APO.R | 116 +-- R/ta_AROON.R | 50 +- R/ta_AROONOSC.R | 50 +- R/ta_ATR.R | 48 +- R/ta_AVGDEV.R | 167 +++++ R/ta_AVGPRICE.R | 14 +- R/ta_BBANDS.R | 159 +++-- R/ta_BETA.R | 21 +- R/ta_BOP.R | 30 +- R/ta_CCI.R | 129 ++-- R/ta_CDL2CROWS.R | 21 +- R/ta_CDL3BLACKCROWS.R | 21 +- R/ta_CDL3INSIDE.R | 25 +- R/ta_CDL3LINESTRIKE.R | 21 +- R/ta_CDL3OUTSIDE.R | 25 +- R/ta_CDL3STARSINSOUTH.R | 25 +- R/ta_CDL3WHITESOLDIERS.R | 25 +- R/ta_CDLABANDONEDBABY.R | 37 +- R/ta_CDLADVANCEBLOCK.R | 21 +- R/ta_CDLBELTHOLD.R | 25 +- R/ta_CDLBREAKAWAY.R | 25 +- R/ta_CDLCLOSINGMARUBOZU.R | 21 +- R/ta_CDLCONCEALBABYSWALL.R | 21 +- R/ta_CDLCOUNTERATTACK.R | 25 +- R/ta_CDLDARKCLOUDCOVER.R | 37 +- R/ta_CDLDOJI.R | 21 +- R/ta_CDLDOJISTAR.R | 21 +- R/ta_CDLDRAGONFLYDOJI.R | 21 +- R/ta_CDLENGULFING.R | 25 +- R/ta_CDLEVENINGDOJISTAR.R | 37 +- R/ta_CDLEVENINGSTAR.R | 37 +- R/ta_CDLGAPSIDESIDEWHITE.R | 21 +- R/ta_CDLGRAVESTONEDOJI.R | 21 +- R/ta_CDLHAMMER.R | 21 +- R/ta_CDLHANGINGMAN.R | 21 +- R/ta_CDLHARAMI.R | 25 +- R/ta_CDLHARAMICROSS.R | 25 +- R/ta_CDLHIGHWAVE.R | 25 +- R/ta_CDLHIKKAKE.R | 25 +- R/ta_CDLHIKKAKEMOD.R | 25 +- R/ta_CDLHOMINGPIGEON.R | 21 +- R/ta_CDLIDENTICAL3CROWS.R | 21 +- R/ta_CDLINNECK.R | 25 +- R/ta_CDLINVERTEDHAMMER.R | 21 +- R/ta_CDLKICKING.R | 21 +- R/ta_CDLKICKINGBYLENGTH.R | 25 +- R/ta_CDLLADDERBOTTOM.R | 21 +- R/ta_CDLLONGLEGGEDDOJI.R | 21 +- R/ta_CDLLONGLINE.R | 25 +- R/ta_CDLMARUBOZU.R | 21 +- R/ta_CDLMATCHINGLOW.R | 21 +- R/ta_CDLMATHOLD.R | 37 +- R/ta_CDLMORNINGDOJISTAR.R | 37 +- R/ta_CDLMORNINGSTAR.R | 37 +- R/ta_CDLONNECK.R | 25 +- R/ta_CDLPIERCING.R | 25 +- R/ta_CDLRICKSHAWMAN.R | 21 +- R/ta_CDLRISEFALL3METHODS.R | 21 +- R/ta_CDLSEPARATINGLINES.R | 21 +- R/ta_CDLSHOOTINGSTAR.R | 21 +- R/ta_CDLSHORTLINE.R | 21 +- R/ta_CDLSPINNINGTOP.R | 21 +- R/ta_CDLSTALLEDPATTERN.R | 21 +- R/ta_CDLSTICKSANDWICH.R | 21 +- R/ta_CDLTAKURI.R | 25 +- R/ta_CDLTASUKIGAP.R | 21 +- R/ta_CDLTHRUSTING.R | 25 +- R/ta_CDLTRISTAR.R | 25 +- R/ta_CDLUNIQUE3RIVER.R | 25 +- R/ta_CDLUPSIDEGAP2CROWS.R | 21 +- R/ta_CDLXSIDEGAP3METHODS.R | 21 +- R/ta_CMO.R | 57 +- R/ta_CORREL.R | 21 +- R/ta_DEMA.R | 58 +- R/ta_DX.R | 48 +- R/ta_EMA.R | 58 +- R/ta_HT_DCPERIOD.R | 23 +- R/ta_HT_DCPHASE.R | 25 +- R/ta_HT_PHASOR.R | 23 +- R/ta_HT_SINE.R | 23 +- R/ta_HT_TRENDLINE.R | 21 +- R/ta_HT_TRENDMODE.R | 23 +- R/ta_IMI.R | 56 +- R/ta_KAMA.R | 58 +- R/ta_MACD.R | 138 ++-- R/ta_MACDEXT.R | 207 +++--- R/ta_MACDFIX.R | 81 ++- R/ta_MAMA.R | 119 ++-- R/ta_MAVP.R | 152 ++++ R/ta_MEDPRICE.R | 14 +- R/ta_MFI.R | 50 +- R/ta_MIDPOINT.R | 167 +++++ R/ta_MIDPRICE.R | 38 +- R/ta_MIN.R | 82 --- R/ta_MINUS_DI.R | 48 +- R/ta_MINUS_DM.R | 48 +- R/ta_MOM.R | 57 +- R/ta_NATR.R | 48 +- R/ta_OBV.R | 30 +- R/ta_PLUS_DI.R | 48 +- R/ta_PLUS_DM.R | 48 +- R/ta_PPO.R | 116 +-- R/ta_ROC.R | 351 ---------- R/ta_ROCR.R | 351 ---------- R/ta_RSI.R | 55 +- R/ta_SAR.R | 74 +- R/ta_SAREXT.R | 224 +++--- R/ta_SMA.R | 58 +- R/ta_STDDEV.R | 27 +- R/ta_STOCH.R | 129 ++-- R/ta_STOCHF.R | 98 ++- R/ta_STOCHRSI.R | 126 ++-- R/ta_SUM.R | 82 --- R/ta_T3.R | 90 ++- R/ta_TEMA.R | 58 +- R/ta_TRANGE.R | 20 +- R/ta_TRIMA.R | 58 +- R/ta_TRIX.R | 63 +- R/{ta_MAX.R => ta_TSF.R} | 40 +- R/ta_TYPPRICE.R | 14 +- R/ta_ULTOSC.R | 87 ++- R/ta_VAR.R | 27 +- R/ta_VOLUME.R | 2 +- R/ta_WCLPRICE.R | 14 +- R/ta_WILLR.R | 58 +- R/ta_WMA.R | 58 +- _pkgdown.yml | 12 +- codegen/README.md | 501 +++++++------ codegen/gen_code/generate.R | 61 -- codegen/gen_code/indicators.R | 309 -------- codegen/gen_code/utils.R | 93 --- codegen/generate_indicator.sh | 211 ------ codegen/src/c_header.rs | 344 +++++++++ codegen/src/main.rs | 125 ++-- codegen/src/metadata.rs | 317 +++++++++ codegen/src/parser.rs | 290 -------- codegen/src/render.rs | 660 ++++++++++++++++++ codegen/src/tables.rs | 355 ++++++++++ .../testthat.rs} | 206 ++++-- codegen/templates/candlestick_template.R | 146 ++++ codegen/templates/candlestick_template.R.in | 188 ----- ...late.R.in => chart_candlestick_template.R} | 39 +- codegen/templates/chart_main_template.R | 86 +++ .../templates/chart_moving_average_template.R | 74 ++ codegen/templates/chart_subchart_template.R | 109 +++ codegen/templates/ggplot_main_template.R.in | 70 -- .../templates/ggplot_subchart_template.R.in | 87 --- ...tor_template.R.in => indicator_template.R} | 41 +- .../moving_average_ggplot_template.R.in | 59 -- codegen/templates/moving_average_template.R | 174 +++++ .../templates/moving_average_template.R.in | 227 ------ codegen/templates/numeric_template.R | 33 + codegen/templates/numeric_template.R.in | 34 - codegen/templates/plotly_main_template.R.in | 67 -- .../templates/plotly_subchart_template.R.in | 83 --- ...lling_template.R.in => rolling_template.R} | 32 +- src/TA-Lib.h | 70 -- tests/testthat/test-ta_ACCBANDS.R | 3 +- tests/testthat/test-ta_AD.R | 3 +- tests/testthat/test-ta_ADOSC.R | 3 +- tests/testthat/test-ta_ADX.R | 3 +- tests/testthat/test-ta_ADXR.R | 3 +- tests/testthat/test-ta_APO.R | 3 +- tests/testthat/test-ta_AROON.R | 3 +- tests/testthat/test-ta_AROONOSC.R | 3 +- tests/testthat/test-ta_ATR.R | 3 +- .../{test-ta_ROC.R => test-ta_AVGDEV.R} | 117 +--- tests/testthat/test-ta_AVGPRICE.R | 2 +- tests/testthat/test-ta_BBANDS.R | 3 +- tests/testthat/test-ta_BETA.R | 2 +- tests/testthat/test-ta_BOP.R | 3 +- tests/testthat/test-ta_CCI.R | 3 +- tests/testthat/test-ta_CDL2CROWS.R | 3 +- tests/testthat/test-ta_CDL3BLACKCROWS.R | 3 +- tests/testthat/test-ta_CDL3INSIDE.R | 3 +- tests/testthat/test-ta_CDL3LINESTRIKE.R | 3 +- tests/testthat/test-ta_CDL3OUTSIDE.R | 3 +- tests/testthat/test-ta_CDL3STARSINSOUTH.R | 3 +- tests/testthat/test-ta_CDL3WHITESOLDIERS.R | 3 +- tests/testthat/test-ta_CDLABANDONEDBABY.R | 3 +- tests/testthat/test-ta_CDLADVANCEBLOCK.R | 3 +- tests/testthat/test-ta_CDLBELTHOLD.R | 3 +- tests/testthat/test-ta_CDLBREAKAWAY.R | 3 +- tests/testthat/test-ta_CDLCLOSINGMARUBOZU.R | 3 +- tests/testthat/test-ta_CDLCONCEALBABYSWALL.R | 3 +- tests/testthat/test-ta_CDLCOUNTERATTACK.R | 3 +- tests/testthat/test-ta_CDLDARKCLOUDCOVER.R | 3 +- tests/testthat/test-ta_CDLDOJI.R | 3 +- tests/testthat/test-ta_CDLDOJISTAR.R | 3 +- tests/testthat/test-ta_CDLDRAGONFLYDOJI.R | 3 +- tests/testthat/test-ta_CDLENGULFING.R | 3 +- tests/testthat/test-ta_CDLEVENINGDOJISTAR.R | 3 +- tests/testthat/test-ta_CDLEVENINGSTAR.R | 3 +- tests/testthat/test-ta_CDLGAPSIDESIDEWHITE.R | 3 +- tests/testthat/test-ta_CDLGRAVESTONEDOJI.R | 3 +- tests/testthat/test-ta_CDLHAMMER.R | 3 +- tests/testthat/test-ta_CDLHANGINGMAN.R | 3 +- tests/testthat/test-ta_CDLHARAMI.R | 3 +- tests/testthat/test-ta_CDLHARAMICROSS.R | 3 +- tests/testthat/test-ta_CDLHIGHWAVE.R | 3 +- tests/testthat/test-ta_CDLHIKKAKE.R | 3 +- tests/testthat/test-ta_CDLHIKKAKEMOD.R | 3 +- tests/testthat/test-ta_CDLHOMINGPIGEON.R | 3 +- tests/testthat/test-ta_CDLIDENTICAL3CROWS.R | 3 +- tests/testthat/test-ta_CDLINNECK.R | 3 +- tests/testthat/test-ta_CDLINVERTEDHAMMER.R | 3 +- tests/testthat/test-ta_CDLKICKING.R | 3 +- tests/testthat/test-ta_CDLKICKINGBYLENGTH.R | 3 +- tests/testthat/test-ta_CDLLADDERBOTTOM.R | 3 +- tests/testthat/test-ta_CDLLONGLEGGEDDOJI.R | 3 +- tests/testthat/test-ta_CDLLONGLINE.R | 3 +- tests/testthat/test-ta_CDLMARUBOZU.R | 3 +- tests/testthat/test-ta_CDLMATCHINGLOW.R | 3 +- tests/testthat/test-ta_CDLMATHOLD.R | 3 +- tests/testthat/test-ta_CDLMORNINGDOJISTAR.R | 3 +- tests/testthat/test-ta_CDLMORNINGSTAR.R | 3 +- tests/testthat/test-ta_CDLONNECK.R | 3 +- tests/testthat/test-ta_CDLPIERCING.R | 3 +- tests/testthat/test-ta_CDLRICKSHAWMAN.R | 3 +- tests/testthat/test-ta_CDLRISEFALL3METHODS.R | 3 +- tests/testthat/test-ta_CDLSEPARATINGLINES.R | 3 +- tests/testthat/test-ta_CDLSHOOTINGSTAR.R | 3 +- tests/testthat/test-ta_CDLSHORTLINE.R | 3 +- tests/testthat/test-ta_CDLSPINNINGTOP.R | 3 +- tests/testthat/test-ta_CDLSTALLEDPATTERN.R | 3 +- tests/testthat/test-ta_CDLSTICKSANDWICH.R | 3 +- tests/testthat/test-ta_CDLTAKURI.R | 3 +- tests/testthat/test-ta_CDLTASUKIGAP.R | 3 +- tests/testthat/test-ta_CDLTHRUSTING.R | 3 +- tests/testthat/test-ta_CDLTRISTAR.R | 3 +- tests/testthat/test-ta_CDLUNIQUE3RIVER.R | 3 +- tests/testthat/test-ta_CDLUPSIDEGAP2CROWS.R | 3 +- tests/testthat/test-ta_CDLXSIDEGAP3METHODS.R | 3 +- tests/testthat/test-ta_CMO.R | 3 +- tests/testthat/test-ta_CORREL.R | 2 +- tests/testthat/test-ta_DEMA.R | 3 +- tests/testthat/test-ta_DX.R | 3 +- tests/testthat/test-ta_EMA.R | 3 +- tests/testthat/test-ta_HT_DCPERIOD.R | 3 +- tests/testthat/test-ta_HT_DCPHASE.R | 3 +- tests/testthat/test-ta_HT_PHASOR.R | 3 +- tests/testthat/test-ta_HT_SINE.R | 3 +- tests/testthat/test-ta_HT_TRENDLINE.R | 3 +- tests/testthat/test-ta_HT_TRENDMODE.R | 3 +- tests/testthat/test-ta_IMI.R | 3 +- tests/testthat/test-ta_KAMA.R | 3 +- tests/testthat/test-ta_MACD.R | 3 +- tests/testthat/test-ta_MACDEXT.R | 3 +- tests/testthat/test-ta_MACDFIX.R | 3 +- tests/testthat/test-ta_MAMA.R | 3 +- tests/testthat/test-ta_MAVP.R | 145 ++++ tests/testthat/test-ta_MEDPRICE.R | 2 +- tests/testthat/test-ta_MFI.R | 3 +- .../{test-ta_ROCR.R => test-ta_MIDPOINT.R} | 117 +--- tests/testthat/test-ta_MIDPRICE.R | 2 +- tests/testthat/test-ta_MIN.R | 45 -- tests/testthat/test-ta_MINUS_DI.R | 3 +- tests/testthat/test-ta_MINUS_DM.R | 3 +- tests/testthat/test-ta_MOM.R | 3 +- tests/testthat/test-ta_NATR.R | 3 +- tests/testthat/test-ta_OBV.R | 3 +- tests/testthat/test-ta_PLUS_DI.R | 3 +- tests/testthat/test-ta_PLUS_DM.R | 3 +- tests/testthat/test-ta_PPO.R | 3 +- tests/testthat/test-ta_RSI.R | 3 +- tests/testthat/test-ta_SAR.R | 3 +- tests/testthat/test-ta_SAREXT.R | 3 +- tests/testthat/test-ta_SMA.R | 3 +- tests/testthat/test-ta_STDDEV.R | 2 +- tests/testthat/test-ta_STOCH.R | 3 +- tests/testthat/test-ta_STOCHF.R | 3 +- tests/testthat/test-ta_STOCHRSI.R | 3 +- tests/testthat/test-ta_SUM.R | 45 -- tests/testthat/test-ta_T3.R | 3 +- tests/testthat/test-ta_TEMA.R | 3 +- tests/testthat/test-ta_TRANGE.R | 3 +- tests/testthat/test-ta_TRIMA.R | 3 +- tests/testthat/test-ta_TRIX.R | 3 +- .../testthat/{test-ta_MAX.R => test-ta_TSF.R} | 8 +- tests/testthat/test-ta_TYPPRICE.R | 2 +- tests/testthat/test-ta_ULTOSC.R | 3 +- tests/testthat/test-ta_VAR.R | 2 +- tests/testthat/test-ta_WCLPRICE.R | 2 +- tests/testthat/test-ta_WILLR.R | 3 +- tests/testthat/test-ta_WMA.R | 3 +- 291 files changed, 6953 insertions(+), 5664 deletions(-) create mode 100644 R/ta_AVGDEV.R create mode 100644 R/ta_MAVP.R create mode 100644 R/ta_MIDPOINT.R delete mode 100644 R/ta_MIN.R delete mode 100644 R/ta_ROC.R delete mode 100644 R/ta_ROCR.R delete mode 100644 R/ta_SUM.R rename R/{ta_MAX.R => ta_TSF.R} (64%) delete mode 100644 codegen/gen_code/generate.R delete mode 100644 codegen/gen_code/indicators.R delete mode 100644 codegen/gen_code/utils.R delete mode 100755 codegen/generate_indicator.sh create mode 100644 codegen/src/c_header.rs create mode 100644 codegen/src/metadata.rs delete mode 100644 codegen/src/parser.rs create mode 100644 codegen/src/render.rs create mode 100644 codegen/src/tables.rs rename codegen/{generate_unit-tests.sh => src/testthat.rs} (59%) mode change 100755 => 100644 create mode 100644 codegen/templates/candlestick_template.R delete mode 100644 codegen/templates/candlestick_template.R.in rename codegen/templates/{candlestick_ggplot_template.R.in => chart_candlestick_template.R} (53%) create mode 100644 codegen/templates/chart_main_template.R create mode 100644 codegen/templates/chart_moving_average_template.R create mode 100644 codegen/templates/chart_subchart_template.R delete mode 100644 codegen/templates/ggplot_main_template.R.in delete mode 100644 codegen/templates/ggplot_subchart_template.R.in rename codegen/templates/{indicator_template.R.in => indicator_template.R} (81%) delete mode 100644 codegen/templates/moving_average_ggplot_template.R.in create mode 100644 codegen/templates/moving_average_template.R delete mode 100644 codegen/templates/moving_average_template.R.in create mode 100644 codegen/templates/numeric_template.R delete mode 100644 codegen/templates/numeric_template.R.in delete mode 100644 codegen/templates/plotly_main_template.R.in delete mode 100644 codegen/templates/plotly_subchart_template.R.in rename codegen/templates/{rolling_template.R.in => rolling_template.R} (78%) rename tests/testthat/{test-ta_ROC.R => test-ta_AVGDEV.R} (58%) create mode 100644 tests/testthat/test-ta_MAVP.R rename tests/testthat/{test-ta_ROCR.R => test-ta_MIDPOINT.R} (58%) delete mode 100644 tests/testthat/test-ta_MIN.R delete mode 100644 tests/testthat/test-ta_SUM.R rename tests/testthat/{test-ta_MAX.R => test-ta_TSF.R} (89%) diff --git a/CLAUDE.md b/CLAUDE.md index 6ab74b093..99795d10c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -9,7 +9,7 @@ R package (`talib`) providing an interface to the TA-Lib C library for technical ## Build Commands ```bash -make build # Full build: gen-code → document → install +make build # Full build: clean → fmt → document → install (does NOT run gen-code) make check # R CMD check --as-cran make check-full # R CMD check with valgrind make test # Run testthat suite @@ -25,21 +25,19 @@ Single test file: `Rscript -e "testthat::test_file('tests/testthat/test-ta_APO.R ### Code Generation (Most Source Files Are Generated) -Most R wrappers (`R/ta_*.R`), C wrappers (`src/ta_*.c`), and tests (`tests/testthat/test-ta_*.R`) are **auto-generated**. Do not edit these directly — modify the generation infrastructure in `codegen/` instead: +Most R wrappers (`R/ta_*.R`), the C X-macro header (`src/TA-Lib.h`), and tests (`tests/testthat/test-ta_*.R`) are **auto-generated** by the zero-dependency Rust crate in `codegen/` — see `codegen/README.md` for the full architecture. Do not edit generated files directly — modify the generation infrastructure instead: -- `codegen/gen_code/indicators.R` — Unified metadata for all 128 indicators -- `codegen/gen_code/generate.R` — Single driver script that generates R, C, and test files -- `codegen/gen_code/utils.R` — `impl_generate_indicator()` and `impl_generate_test()` helpers -- `codegen/generate_indicator.sh`, `generate_API.sh`, `generate_FFI.sh` — Shell scripts for template-driven generation -- `src/api.h` and `src/init.c` — Auto-generated (function prototypes and R registration) +- `codegen/src/` — `main.rs` (driver), `c_header.rs` (C X-macro lines from ta_func.h), `metadata.rs` (XML mining), `render.rs` (template rendering + splice preservation), `testthat.rs` (test files), `tables.rs` (the hand-maintained per-indicator lookup tables: names, chart types, classifications, exclusions) +- `codegen/templates/` — plain R files with `${...}` placeholders; the `chart_*` templates are dual-backend (one file renders both the `.plotly` and `.ggplot` method) +- Hand-edited content between `## splice::start` / `## splice::end` markers in generated files survives regeneration -Run `make gen-code` after changing any generation logic. +Run `make gen-code` after changing any generation logic (`cargo test` inside `codegen/` tests the generator itself). ### R ↔ C Binding Uses `.Call()` (R's native C interface), not Rcpp. Each indicator has: -1. **C wrapper** (`src/ta_*.c`): Converts R SEXP → C arrays, calls TA-Lib, returns SEXP matrix +1. **C wrapper**: one X-macro line in the generated `src/TA-Lib.h`, expanded by the hand-written `src/wrapper.h`/`src/init.c` macros into a function that converts R SEXP → C arrays, calls TA-Lib, and returns a SEXP matrix (there are no per-indicator `.c` files) 2. **R wrapper** (`R/ta_*.R`): S3 generic with methods for `default`, `data.frame`, and `plotly` C memory management uses manual `PROTECT`/`UNPROTECT` with protection counters. @@ -87,8 +85,8 @@ isolated without depending on those packages. `chart()` and its - `R/helper.R` — Operators (`%nn%`, `%or%`), chart helpers (`plotly_init`, `plotly_line`, `ggplot_init`, `ggplot_line`, `modify_traces`, `add_idx`, `rebuild_formula`) - `R/BTC.R`, `R/NVDA.R`, `R/SPY.R`, `R/ATOM.R` — Built-in OHLCV datasets (docs only; `.rda` files in `data/`) - `R/talib-package.R` — `generate_returns_section()` used at roxygen-render time by `man-roxygen/returns.R` -- `src/dataframe.c` — Matrix↔data.frame conversion (`map_dfr`) -- `src/container.h`, `src/shift.h`, `src/names.h` — Shared C utilities +- `src/data-frame.c` — Matrix↔data.frame conversion (`map_dfr`) +- `src/shift.h`, `src/names.h` — Shared C utilities ### TA-Lib Submodule diff --git a/R/ta_ACCBANDS.R b/R/ta_ACCBANDS.R index 82a7d53ff..2e344ecb6 100644 --- a/R/ta_ACCBANDS.R +++ b/R/ta_ACCBANDS.R @@ -1,12 +1,12 @@ #' @export -#' @family Overlap Study +#' @family Overlap Studies #' #' @title Acceleration Bands #' @templateVar .title Acceleration Bands #' @templateVar .author Serkan Korkmaz #' @templateVar .fun acceleration_bands -#' @templateVar .family Overlap Study -#' @templateVar .formula ~ high + low + close +#' @templateVar .family Overlap Studies +#' @templateVar .formula ~high + low + close #' ## splice:documentation:start ## splice:documentation:end @@ -16,7 +16,7 @@ acceleration_bands <- function( x, cols, - n = 20, + timePeriod = 20, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ ACCBANDS <- acceleration_bands acceleration_bands.default <- function( x, cols, - n = 20, + timePeriod = 20, na.bridge = FALSE, ... ) { @@ -64,12 +64,10 @@ acceleration_bands.default <- function( ## return as data.frame x <- .Call( C_impl_ta_ACCBANDS, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -87,7 +85,7 @@ acceleration_bands.default <- function( acceleration_bands.data.frame <- function( x, cols, - n = 20, + timePeriod = 20, na.bridge = FALSE, ... ) { @@ -95,7 +93,7 @@ acceleration_bands.data.frame <- function( acceleration_bands.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -109,20 +107,32 @@ acceleration_bands.data.frame <- function( acceleration_bands.matrix <- function( x, cols, - n = 20, + timePeriod = 20, na.bridge = FALSE, ... ) { acceleration_bands.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +acceleration_bands_lookback <- function( + x, + cols, + timePeriod = 20, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_ACCBANDS_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases acceleration_bands #' @@ -130,7 +140,7 @@ acceleration_bands.matrix <- function( acceleration_bands.plotly <- function( x, cols, - n = 20, + timePeriod = 20, na.bridge = FALSE, ## splice:optional-plotly:start color = "steelblue", @@ -164,7 +174,7 @@ acceleration_bands.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -177,7 +187,7 @@ acceleration_bands.plotly <- function( ## splice:plotly-assembly:start name <- label( "Acceleration Bands", - n + timePeriod ) traces <- list( @@ -235,7 +245,7 @@ acceleration_bands.plotly <- function( acceleration_bands.ggplot <- function( x, cols, - n = 20, + timePeriod = 20, na.bridge = FALSE, ## splice:optional-ggplot:start ## splice:optional-ggplot:end @@ -266,7 +276,7 @@ acceleration_bands.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -288,7 +298,7 @@ acceleration_bands.ggplot <- function( y_lower = "LowerBand" ) ) - name <- label("ACCBANDS", n) + name <- label("ACCBANDS", timePeriod) ## splice:ggplot-assembly:end state <- .chart_state() diff --git a/R/ta_AD.R b/R/ta_AD.R index e0198b404..c0d439301 100644 --- a/R/ta_AD.R +++ b/R/ta_AD.R @@ -1,12 +1,12 @@ #' @export -#' @family Volume Indicator +#' @family Volume Indicators #' #' @title Chaikin A/D Line #' @templateVar .title Chaikin A/D Line #' @templateVar .author Serkan Korkmaz #' @templateVar .fun chaikin_accumulation_distribution_line -#' @templateVar .family Volume Indicator -#' @templateVar .formula ~high+low+close+volume +#' @templateVar .family Volume Indicators +#' @templateVar .formula ~high + low + close + volume #' ## splice:documentation:start ## splice:documentation:end @@ -62,12 +62,10 @@ chaikin_accumulation_distribution_line.default <- function( ## return as data.frame x <- .Call( C_impl_ta_AD, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], constructed_series[[4]], - ## splice:call:end as.logical(na.bridge) ) @@ -116,7 +114,17 @@ chaikin_accumulation_distribution_line.matrix <- function( ) } - +#' @usage NULL +chaikin_accumulation_distribution_line_lookback <- function( + x, + cols, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_AD_lookback + ) +} #' @usage NULL #' @aliases chaikin_accumulation_distribution_line #' @@ -216,9 +224,9 @@ chaikin_accumulation_distribution_line.ggplot <- function( x, cols, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability diff --git a/R/ta_ADOSC.R b/R/ta_ADOSC.R index 953c06a71..6f8861cb6 100644 --- a/R/ta_ADOSC.R +++ b/R/ta_ADOSC.R @@ -1,16 +1,14 @@ #' @export -#' @family Volume Indicator +#' @family Volume Indicators #' #' @title Chaikin A/D Oscillator #' @templateVar .title Chaikin A/D Oscillator #' @templateVar .author Serkan Korkmaz #' @templateVar .fun chaikin_accumulation_distribution_oscillator -#' @templateVar .family Volume Indicator -#' @templateVar .formula ~high+low+close+volume +#' @templateVar .family Volume Indicators +#' @templateVar .formula ~high + low + close + volume #' ## splice:documentation:start -#' @param fast ([integer]). Period for the fast Moving Average (MA). -#' @param slow ([integer]). Period for the slow Moving Average (MA). ## splice:documentation:end #' #' @template description @@ -18,8 +16,8 @@ chaikin_accumulation_distribution_oscillator <- function( x, cols, - fast = 3, - slow = 10, + fastPeriod = 3, + slowPeriod = 10, na.bridge = FALSE, ... ) { @@ -40,8 +38,8 @@ ADOSC <- chaikin_accumulation_distribution_oscillator chaikin_accumulation_distribution_oscillator.default <- function( x, cols, - fast = 3, - slow = 10, + fastPeriod = 3, + slowPeriod = 10, na.bridge = FALSE, ... ) { @@ -68,14 +66,12 @@ chaikin_accumulation_distribution_oscillator.default <- function( ## return as data.frame x <- .Call( C_impl_ta_ADOSC, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], constructed_series[[4]], - as.integer(fast), - as.integer(slow), - ## splice:call:end + as.integer(fastPeriod), + as.integer(slowPeriod), as.logical(na.bridge) ) @@ -93,8 +89,8 @@ chaikin_accumulation_distribution_oscillator.default <- function( chaikin_accumulation_distribution_oscillator.data.frame <- function( x, cols, - fast = 3, - slow = 10, + fastPeriod = 3, + slowPeriod = 10, na.bridge = FALSE, ... ) { @@ -102,8 +98,8 @@ chaikin_accumulation_distribution_oscillator.data.frame <- function( chaikin_accumulation_distribution_oscillator.default( x = x, cols = cols, - fast = fast, - slow = slow, + fastPeriod = fastPeriod, + slowPeriod = slowPeriod, na.bridge = na.bridge, ... ) @@ -117,22 +113,36 @@ chaikin_accumulation_distribution_oscillator.data.frame <- function( chaikin_accumulation_distribution_oscillator.matrix <- function( x, cols, - fast = 3, - slow = 10, + fastPeriod = 3, + slowPeriod = 10, na.bridge = FALSE, ... ) { chaikin_accumulation_distribution_oscillator.default( x = x, cols = cols, - fast = fast, - slow = slow, + fastPeriod = fastPeriod, + slowPeriod = slowPeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +chaikin_accumulation_distribution_oscillator_lookback <- function( + x, + cols, + fastPeriod = 3, + slowPeriod = 10, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_ADOSC_lookback, + as.integer(fastPeriod), + as.integer(slowPeriod) + ) +} #' @usage NULL #' @aliases chaikin_accumulation_distribution_oscillator #' @@ -140,8 +150,8 @@ chaikin_accumulation_distribution_oscillator.matrix <- function( chaikin_accumulation_distribution_oscillator.plotly <- function( x, cols, - fast = 3, - slow = 10, + fastPeriod = 3, + slowPeriod = 10, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -174,8 +184,8 @@ chaikin_accumulation_distribution_oscillator.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - fast = fast, - slow = slow, + fastPeriod = fastPeriod, + slowPeriod = slowPeriod, na.bridge = TRUE ) @@ -192,7 +202,7 @@ chaikin_accumulation_distribution_oscillator.plotly <- function( ## construct {plotly}-object ## splice:plotly-assembly:start - name <- sprintf("ADOSC(%d, %d)", fast, slow) + name <- sprintf("ADOSC(%d, %d)", fastPeriod, slowPeriod) decorators <- list() traces <- list( list(y = ~ADOSC) @@ -235,12 +245,12 @@ chaikin_accumulation_distribution_oscillator.plotly <- function( chaikin_accumulation_distribution_oscillator.ggplot <- function( x, cols, - fast = 3, - slow = 10, + fastPeriod = 3, + slowPeriod = 10, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -268,8 +278,8 @@ chaikin_accumulation_distribution_oscillator.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - fast = fast, - slow = slow, + fastPeriod = fastPeriod, + slowPeriod = slowPeriod, na.bridge = TRUE ) @@ -290,7 +300,7 @@ chaikin_accumulation_distribution_oscillator.ggplot <- function( setdiff(colnames(constructed_indicator), "idx"), function(col) list(y = col) ) - name <- sprintf("ADOSC(%d, %d)", fast, slow) + name <- sprintf("ADOSC(%d, %d)", fastPeriod, slowPeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_ADX.R b/R/ta_ADX.R index 9e0b41026..04b2ddc47 100644 --- a/R/ta_ADX.R +++ b/R/ta_ADX.R @@ -1,12 +1,12 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Average Directional Movement Index #' @templateVar .title Average Directional Movement Index #' @templateVar .author Serkan Korkmaz #' @templateVar .fun average_directional_movement_index -#' @templateVar .family Momentum Indicator -#' @templateVar .formula ~ high + low + close +#' @templateVar .family Momentum Indicators +#' @templateVar .formula ~high + low + close #' ## splice:documentation:start ## splice:documentation:end @@ -16,7 +16,7 @@ average_directional_movement_index <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ ADX <- average_directional_movement_index average_directional_movement_index.default <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -64,12 +64,10 @@ average_directional_movement_index.default <- function( ## return as data.frame x <- .Call( C_impl_ta_ADX, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -87,7 +85,7 @@ average_directional_movement_index.default <- function( average_directional_movement_index.data.frame <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -95,7 +93,7 @@ average_directional_movement_index.data.frame <- function( average_directional_movement_index.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -109,20 +107,32 @@ average_directional_movement_index.data.frame <- function( average_directional_movement_index.matrix <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { average_directional_movement_index.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +average_directional_movement_index_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_ADX_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases average_directional_movement_index #' @@ -130,7 +140,7 @@ average_directional_movement_index.matrix <- function( average_directional_movement_index.plotly <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ## splice:optional-plotly:start lower_bound = 25, @@ -166,7 +176,7 @@ average_directional_movement_index.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -185,7 +195,7 @@ average_directional_movement_index.plotly <- function( ## splice:plotly-assembly:start name <- sprintf( "ADX(%d)", - n + timePeriod ) decorators <- list( @@ -236,11 +246,11 @@ average_directional_movement_index.plotly <- function( average_directional_movement_index.ggplot <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -268,7 +278,7 @@ average_directional_movement_index.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -294,7 +304,7 @@ average_directional_movement_index.ggplot <- function( ggplot_line(75), list(y = "ADX") ) - name <- sprintf("ADX(%d)", n) + name <- sprintf("ADX(%d)", timePeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_ADXR.R b/R/ta_ADXR.R index 1022b36c4..484d2f24f 100644 --- a/R/ta_ADXR.R +++ b/R/ta_ADXR.R @@ -1,12 +1,12 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Average Directional Movement Index Rating #' @templateVar .title Average Directional Movement Index Rating #' @templateVar .author Serkan Korkmaz #' @templateVar .fun average_directional_movement_index_rating -#' @templateVar .family Momentum Indicator -#' @templateVar .formula ~ high + low + close +#' @templateVar .family Momentum Indicators +#' @templateVar .formula ~high + low + close #' ## splice:documentation:start ## splice:documentation:end @@ -16,7 +16,7 @@ average_directional_movement_index_rating <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ ADXR <- average_directional_movement_index_rating average_directional_movement_index_rating.default <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -64,12 +64,10 @@ average_directional_movement_index_rating.default <- function( ## return as data.frame x <- .Call( C_impl_ta_ADXR, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -87,7 +85,7 @@ average_directional_movement_index_rating.default <- function( average_directional_movement_index_rating.data.frame <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -95,7 +93,7 @@ average_directional_movement_index_rating.data.frame <- function( average_directional_movement_index_rating.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -109,20 +107,32 @@ average_directional_movement_index_rating.data.frame <- function( average_directional_movement_index_rating.matrix <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { average_directional_movement_index_rating.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +average_directional_movement_index_rating_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_ADXR_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases average_directional_movement_index_rating #' @@ -130,7 +140,7 @@ average_directional_movement_index_rating.matrix <- function( average_directional_movement_index_rating.plotly <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ## splice:optional-plotly:start lower_bound = 25, @@ -166,7 +176,7 @@ average_directional_movement_index_rating.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -185,7 +195,7 @@ average_directional_movement_index_rating.plotly <- function( ## splice:plotly-assembly:start name <- sprintf( "ADXR(%d)", - n + timePeriod ) decorators <- list( @@ -236,11 +246,11 @@ average_directional_movement_index_rating.plotly <- function( average_directional_movement_index_rating.ggplot <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -268,7 +278,7 @@ average_directional_movement_index_rating.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -294,7 +304,7 @@ average_directional_movement_index_rating.ggplot <- function( ggplot_line(75), list(y = "ADXR") ) - name <- sprintf("ADXR(%d)", n) + name <- sprintf("ADXR(%d)", timePeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_APO.R b/R/ta_APO.R index 1b1fd1f3e..3e4255ff4 100644 --- a/R/ta_APO.R +++ b/R/ta_APO.R @@ -1,17 +1,14 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Absolute Price Oscillator #' @templateVar .title Absolute Price Oscillator #' @templateVar .author Serkan Korkmaz #' @templateVar .fun absolute_price_oscillator -#' @templateVar .family Momentum Indicator +#' @templateVar .family Momentum Indicators #' @templateVar .formula ~close #' ## splice:documentation:start -#' @param fast ([integer]). Period for the fast Moving Average (MA). -#' @param slow ([integer]). Period for the slow Moving Average (MA). -#' @param ma ([list]). The type of Moving Average (MA) used for the `fast` and `slow` MA. [SMA] by default. ## splice:documentation:end #' #' @template description @@ -19,9 +16,9 @@ absolute_price_oscillator <- function( x, cols, - fast = 12, - slow = 26, - ma = SMA(n = 9), + fastPeriod = 12, + slowPeriod = 26, + maType = 0, na.bridge = FALSE, ... ) { @@ -42,9 +39,9 @@ APO <- absolute_price_oscillator absolute_price_oscillator.default <- function( x, cols, - fast = 12, - slow = 26, - ma = SMA(n = 9), + fastPeriod = 12, + slowPeriod = 26, + maType = 0, na.bridge = FALSE, ... ) { @@ -71,12 +68,10 @@ absolute_price_oscillator.default <- function( ## return as data.frame x <- .Call( C_impl_ta_APO, - ## splice:call:start constructed_series[[1]], - as.integer(fast), - as.integer(slow), - ma$maType, - ## splice:call:end + as.integer(fastPeriod), + as.integer(slowPeriod), + as.integer(maType), as.logical(na.bridge) ) @@ -94,9 +89,9 @@ absolute_price_oscillator.default <- function( absolute_price_oscillator.data.frame <- function( x, cols, - fast = 12, - slow = 26, - ma = SMA(n = 9), + fastPeriod = 12, + slowPeriod = 26, + maType = 0, na.bridge = FALSE, ... ) { @@ -104,9 +99,9 @@ absolute_price_oscillator.data.frame <- function( absolute_price_oscillator.default( x = x, cols = cols, - fast = fast, - slow = slow, - ma = ma, + fastPeriod = fastPeriod, + slowPeriod = slowPeriod, + maType = maType, na.bridge = na.bridge, ... ) @@ -120,24 +115,40 @@ absolute_price_oscillator.data.frame <- function( absolute_price_oscillator.matrix <- function( x, cols, - fast = 12, - slow = 26, - ma = SMA(n = 9), + fastPeriod = 12, + slowPeriod = 26, + maType = 0, na.bridge = FALSE, ... ) { absolute_price_oscillator.default( x = x, cols = cols, - fast = fast, - slow = slow, - ma = ma, + fastPeriod = fastPeriod, + slowPeriod = slowPeriod, + maType = maType, na.bridge = na.bridge, ... ) } - +#' @usage NULL +absolute_price_oscillator_lookback <- function( + x, + cols, + fastPeriod = 12, + slowPeriod = 26, + maType = 0, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_APO_lookback, + as.integer(fastPeriod), + as.integer(slowPeriod), + as.integer(maType) + ) +} #' @usage NULL #' @aliases absolute_price_oscillator #' @@ -145,9 +156,9 @@ absolute_price_oscillator.matrix <- function( absolute_price_oscillator.numeric <- function( x, cols, - fast = 12, - slow = 26, - ma = SMA(n = 9), + fastPeriod = 12, + slowPeriod = 26, + maType = 0, na.bridge = FALSE, ... ) { @@ -163,12 +174,10 @@ absolute_price_oscillator.numeric <- function( ## to 'C' x <- .Call( C_impl_ta_APO, - ## splice:numeric:start as.double(x), - as.integer(fast), - as.integer(slow), - ma$maType, - ## splice:numeric:end + as.integer(fastPeriod), + as.integer(slowPeriod), + as.integer(maType), as.logical(na.bridge) ) @@ -179,7 +188,6 @@ absolute_price_oscillator.numeric <- function( x } - #' @usage NULL #' @aliases absolute_price_oscillator #' @@ -187,9 +195,9 @@ absolute_price_oscillator.numeric <- function( absolute_price_oscillator.plotly <- function( x, cols, - fast = 12, - slow = 26, - ma = SMA(n = 9), + fastPeriod = 12, + slowPeriod = 26, + maType = 0, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -222,9 +230,9 @@ absolute_price_oscillator.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - fast = fast, - slow = slow, - ma = ma, + fastPeriod = fastPeriod, + slowPeriod = slowPeriod, + maType = maType, na.bridge = TRUE ) @@ -243,8 +251,8 @@ absolute_price_oscillator.plotly <- function( ## splice:plotly-assembly:start name <- sprintf( "APO(%d, %d)", - slow, - fast + slowPeriod, + fastPeriod ) decorators <- list() @@ -291,13 +299,13 @@ absolute_price_oscillator.plotly <- function( absolute_price_oscillator.ggplot <- function( x, cols, - fast = 12, - slow = 26, - ma = SMA(n = 9), + fastPeriod = 12, + slowPeriod = 26, + maType = 0, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -325,9 +333,9 @@ absolute_price_oscillator.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - fast = fast, - slow = slow, - ma = ma, + fastPeriod = fastPeriod, + slowPeriod = slowPeriod, + maType = maType, na.bridge = TRUE ) @@ -348,7 +356,7 @@ absolute_price_oscillator.ggplot <- function( ggplot_line(0), list(y = "APO") ) - name <- sprintf("APO(%d, %d)", slow, fast) + name <- sprintf("APO(%d, %d)", slowPeriod, fastPeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_AROON.R b/R/ta_AROON.R index 0cedc7c0f..2ee51324b 100644 --- a/R/ta_AROON.R +++ b/R/ta_AROON.R @@ -1,12 +1,12 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Aroon #' @templateVar .title Aroon #' @templateVar .author Serkan Korkmaz #' @templateVar .fun aroon -#' @templateVar .family Momentum Indicator -#' @templateVar .formula ~ high + low +#' @templateVar .family Momentum Indicators +#' @templateVar .formula ~high + low #' ## splice:documentation:start ## splice:documentation:end @@ -16,7 +16,7 @@ aroon <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ AROON <- aroon aroon.default <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -64,11 +64,9 @@ aroon.default <- function( ## return as data.frame x <- .Call( C_impl_ta_AROON, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -86,7 +84,7 @@ aroon.default <- function( aroon.data.frame <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -94,7 +92,7 @@ aroon.data.frame <- function( aroon.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -108,20 +106,32 @@ aroon.data.frame <- function( aroon.matrix <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { aroon.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +aroon_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_AROON_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases aroon #' @@ -129,7 +139,7 @@ aroon.matrix <- function( aroon.plotly <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -162,7 +172,7 @@ aroon.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -181,7 +191,7 @@ aroon.plotly <- function( ## splice:plotly-assembly:start name <- sprintf( "Aroon(%d)", - n + timePeriod ) decorators <- list( @@ -241,11 +251,11 @@ aroon.plotly <- function( aroon.ggplot <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -273,7 +283,7 @@ aroon.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -297,7 +307,7 @@ aroon.ggplot <- function( list(y = "AroonDown", name = "AroonDown"), list(y = "AroonUp", name = "AroonUp") ) - name <- sprintf("Aroon(%d)", n) + name <- sprintf("Aroon(%d)", timePeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_AROONOSC.R b/R/ta_AROONOSC.R index 81452a9d0..644e4b980 100644 --- a/R/ta_AROONOSC.R +++ b/R/ta_AROONOSC.R @@ -1,12 +1,12 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Aroon Oscillator #' @templateVar .title Aroon Oscillator #' @templateVar .author Serkan Korkmaz #' @templateVar .fun aroon_oscillator -#' @templateVar .family Momentum Indicator -#' @templateVar .formula ~ high + low +#' @templateVar .family Momentum Indicators +#' @templateVar .formula ~high + low #' ## splice:documentation:start ## splice:documentation:end @@ -16,7 +16,7 @@ aroon_oscillator <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ AROONOSC <- aroon_oscillator aroon_oscillator.default <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -64,11 +64,9 @@ aroon_oscillator.default <- function( ## return as data.frame x <- .Call( C_impl_ta_AROONOSC, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -86,7 +84,7 @@ aroon_oscillator.default <- function( aroon_oscillator.data.frame <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -94,7 +92,7 @@ aroon_oscillator.data.frame <- function( aroon_oscillator.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -108,20 +106,32 @@ aroon_oscillator.data.frame <- function( aroon_oscillator.matrix <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { aroon_oscillator.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +aroon_oscillator_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_AROONOSC_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases aroon_oscillator #' @@ -129,7 +139,7 @@ aroon_oscillator.matrix <- function( aroon_oscillator.plotly <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -162,7 +172,7 @@ aroon_oscillator.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -179,7 +189,7 @@ aroon_oscillator.plotly <- function( ## construct {plotly}-object ## splice:plotly-assembly:start - name <- sprintf("AroonOsc(%d)", n) + name <- sprintf("AroonOsc(%d)", timePeriod) decorators <- list( function(p) add_limit_ly(p, y_range = c(0, 100)) @@ -227,11 +237,11 @@ aroon_oscillator.plotly <- function( aroon_oscillator.ggplot <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -259,7 +269,7 @@ aroon_oscillator.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -283,7 +293,7 @@ aroon_oscillator.ggplot <- function( ggplot_line(0), list(y = "AROONOSC") ) - name <- sprintf("AroonOsc(%d)", n) + name <- sprintf("AroonOsc(%d)", timePeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_ATR.R b/R/ta_ATR.R index 9c1dbbd60..498f2d633 100644 --- a/R/ta_ATR.R +++ b/R/ta_ATR.R @@ -1,11 +1,11 @@ #' @export -#' @family Volatility Indicator +#' @family Volatility Indicators #' #' @title Average True Range #' @templateVar .title Average True Range #' @templateVar .author Serkan Korkmaz #' @templateVar .fun average_true_range -#' @templateVar .family Volatility Indicator +#' @templateVar .family Volatility Indicators #' @templateVar .formula ~high + low + close #' ## splice:documentation:start @@ -16,7 +16,7 @@ average_true_range <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ ATR <- average_true_range average_true_range.default <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -64,12 +64,10 @@ average_true_range.default <- function( ## return as data.frame x <- .Call( C_impl_ta_ATR, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -87,7 +85,7 @@ average_true_range.default <- function( average_true_range.data.frame <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -95,7 +93,7 @@ average_true_range.data.frame <- function( average_true_range.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -109,20 +107,32 @@ average_true_range.data.frame <- function( average_true_range.matrix <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { average_true_range.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +average_true_range_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_ATR_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases average_true_range #' @@ -130,7 +140,7 @@ average_true_range.matrix <- function( average_true_range.plotly <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -163,7 +173,7 @@ average_true_range.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -180,7 +190,7 @@ average_true_range.plotly <- function( ## construct {plotly}-object ## splice:plotly-assembly:start - name <- sprintf("ATR(%d)", n) + name <- sprintf("ATR(%d)", timePeriod) decorators <- list() traces <- list( list(y = ~ATR) @@ -223,11 +233,11 @@ average_true_range.plotly <- function( average_true_range.ggplot <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -255,7 +265,7 @@ average_true_range.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -276,7 +286,7 @@ average_true_range.ggplot <- function( setdiff(colnames(constructed_indicator), "idx"), function(col) list(y = col) ) - name <- sprintf("ATR(%d)", n) + name <- sprintf("ATR(%d)", timePeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_AVGDEV.R b/R/ta_AVGDEV.R new file mode 100644 index 000000000..c8b34dbc8 --- /dev/null +++ b/R/ta_AVGDEV.R @@ -0,0 +1,167 @@ +#' @export +#' @family Price Transform +#' +#' @title Average Deviation +#' @templateVar .title Average Deviation +#' @templateVar .author Serkan Korkmaz +#' @templateVar .fun AVGDEV +#' @templateVar .family Price Transform +#' @templateVar .formula ~close +#' +## splice:documentation:start +## splice:documentation:end +#' +#' @template description +#' @template returns +AVGDEV <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + UseMethod("AVGDEV") +} + +#' @export +#' @usage NULL +#' @rdname AVGDEV +#' +#' @aliases AVGDEV +AVGDEV <- AVGDEV + +#' @usage NULL +#' @aliases AVGDEV +#' +#' @export +AVGDEV.default <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + ## 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, + ... + ) + + ## extract rownames + ## for later attachment + x_names <- rownames(constructed_series) + + ## calculate indicator and + ## return as data.frame + x <- .Call( + C_impl_ta_AVGDEV, + constructed_series[[1]], + as.integer(timePeriod), + as.logical(na.bridge) + ) + + ## readd rownames + set_rownames(x, x_names) + + ## return indicator + x +} + +#' @usage NULL +#' @aliases AVGDEV +#' +#' @export +AVGDEV.data.frame <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + map_dfr( + AVGDEV.default( + x = x, + cols = cols, + timePeriod = timePeriod, + na.bridge = na.bridge, + ... + ) + ) +} + +#' @usage NULL +#' @aliases AVGDEV +#' +#' @export +AVGDEV.matrix <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + AVGDEV.default( + x = x, + cols = cols, + timePeriod = timePeriod, + na.bridge = na.bridge, + ... + ) +} + +#' @usage NULL +AVGDEV_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_AVGDEV_lookback, + as.integer(timePeriod) + ) +} +#' @usage NULL +#' @aliases AVGDEV +#' +#' @export +AVGDEV.numeric <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + ## warn if 'cols' have been + ## passed just to make sure + ## the user knows its not possible + ## or relevant + if (!missing(cols)) { + warning("'cols' is passed but is unused for vectors.") + } + + ## pass the argument directly + ## to 'C' + x <- .Call( + C_impl_ta_AVGDEV, + as.double(x), + as.integer(timePeriod), + as.logical(na.bridge) + ) + + if (dim(x)[2] == 1L) { + dim(x) <- NULL + } + + x +} diff --git a/R/ta_AVGPRICE.R b/R/ta_AVGPRICE.R index 666fd0c66..9bce754c9 100644 --- a/R/ta_AVGPRICE.R +++ b/R/ta_AVGPRICE.R @@ -62,12 +62,10 @@ average_price.default <- function( ## return as data.frame x <- .Call( C_impl_ta_AVGPRICE, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], constructed_series[[4]], - ## splice:call:end as.logical(na.bridge) ) @@ -115,3 +113,15 @@ average_price.matrix <- function( ... ) } + +#' @usage NULL +average_price_lookback <- function( + x, + cols, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_AVGPRICE_lookback + ) +} diff --git a/R/ta_BBANDS.R b/R/ta_BBANDS.R index d1187f3b1..87b370543 100644 --- a/R/ta_BBANDS.R +++ b/R/ta_BBANDS.R @@ -1,18 +1,14 @@ #' @export -#' @family Overlap Study +#' @family Overlap Studies #' #' @title Bollinger Bands #' @templateVar .title Bollinger Bands #' @templateVar .author Serkan Korkmaz #' @templateVar .fun bollinger_bands -#' @templateVar .family Overlap Study +#' @templateVar .family Overlap Studies #' @templateVar .formula ~close #' ## splice:documentation:start -#' @param ma ([list]). The type of Moving Average (MA) used for the `MiddleBand`. [SMA] by default. -#' @param sd ([double]). Deviation multiplier for the upper and lower band. -#' @param sd_up ([double]). Optional. Deviation multiplier for upper band -#' @param sd_down ([double]). Optional. Deviation multiplier for lower band ## splice:documentation:end #' #' @template description @@ -20,10 +16,10 @@ bollinger_bands <- function( x, cols, - ma = SMA(n = 5), - sd = 2, - sd_down, - sd_up, + timePeriod = 5, + deviationsUp = 2, + deviationsDown = 2, + maType = 0, na.bridge = FALSE, ... ) { @@ -44,10 +40,10 @@ BBANDS <- bollinger_bands bollinger_bands.default <- function( x, cols, - ma = SMA(n = 5), - sd = 2, - sd_down, - sd_up, + timePeriod = 5, + deviationsUp = 2, + deviationsDown = 2, + maType = 0, na.bridge = FALSE, ... ) { @@ -74,13 +70,11 @@ bollinger_bands.default <- function( ## return as data.frame x <- .Call( C_impl_ta_BBANDS, - ## splice:call:start constructed_series[[1]], - ma$n, - as.double(sd_up %or% sd), - as.double(sd_down %or% sd), - ma$maType, - ## splice:call:end + as.integer(timePeriod), + as.double(deviationsUp), + as.double(deviationsDown), + as.integer(maType), as.logical(na.bridge) ) @@ -98,10 +92,10 @@ bollinger_bands.default <- function( bollinger_bands.data.frame <- function( x, cols, - ma = SMA(n = 5), - sd = 2, - sd_down, - sd_up, + timePeriod = 5, + deviationsUp = 2, + deviationsDown = 2, + maType = 0, na.bridge = FALSE, ... ) { @@ -109,10 +103,10 @@ bollinger_bands.data.frame <- function( bollinger_bands.default( x = x, cols = cols, - ma = ma, - sd = sd, - sd_down = sd_down, - sd_up = sd_up, + timePeriod = timePeriod, + deviationsUp = deviationsUp, + deviationsDown = deviationsDown, + maType = maType, na.bridge = na.bridge, ... ) @@ -126,26 +120,44 @@ bollinger_bands.data.frame <- function( bollinger_bands.matrix <- function( x, cols, - ma = SMA(n = 5), - sd = 2, - sd_down, - sd_up, + timePeriod = 5, + deviationsUp = 2, + deviationsDown = 2, + maType = 0, na.bridge = FALSE, ... ) { bollinger_bands.default( x = x, cols = cols, - ma = ma, - sd = sd, - sd_down = sd_down, - sd_up = sd_up, + timePeriod = timePeriod, + deviationsUp = deviationsUp, + deviationsDown = deviationsDown, + maType = maType, na.bridge = na.bridge, ... ) } - +#' @usage NULL +bollinger_bands_lookback <- function( + x, + cols, + timePeriod = 5, + deviationsUp = 2, + deviationsDown = 2, + maType = 0, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_BBANDS_lookback, + as.integer(timePeriod), + as.double(deviationsUp), + as.double(deviationsDown), + as.integer(maType) + ) +} #' @usage NULL #' @aliases bollinger_bands #' @@ -153,10 +165,10 @@ bollinger_bands.matrix <- function( bollinger_bands.numeric <- function( x, cols, - ma = SMA(n = 5), - sd = 2, - sd_down, - sd_up, + timePeriod = 5, + deviationsUp = 2, + deviationsDown = 2, + maType = 0, na.bridge = FALSE, ... ) { @@ -172,13 +184,11 @@ bollinger_bands.numeric <- function( ## to 'C' x <- .Call( C_impl_ta_BBANDS, - ## splice:numeric:start as.double(x), - ma$n, - as.double(sd_up %or% sd), - as.double(sd_down %or% sd), - ma$maType, - ## splice:numeric:end + as.integer(timePeriod), + as.double(deviationsUp), + as.double(deviationsDown), + as.integer(maType), as.logical(na.bridge) ) @@ -189,7 +199,6 @@ bollinger_bands.numeric <- function( x } - #' @usage NULL #' @aliases bollinger_bands #' @@ -197,10 +206,10 @@ bollinger_bands.numeric <- function( bollinger_bands.plotly <- function( x, cols, - ma = SMA(n = 5), - sd = 2, - sd_down, - sd_up, + timePeriod = 5, + deviationsUp = 2, + deviationsDown = 2, + maType = 0, na.bridge = FALSE, ## splice:optional-plotly:start color = "steelblue", @@ -234,10 +243,10 @@ bollinger_bands.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - ma = ma, - sd = sd, - sd_down = sd_down, - sd_up = sd_up, + timePeriod = timePeriod, + deviationsUp = deviationsUp, + deviationsDown = deviationsDown, + maType = maType, na.bridge = TRUE ) @@ -250,19 +259,19 @@ bollinger_bands.plotly <- function( ## splice:plotly-assembly:start ## standard deviations - sd_down <- as.double(sd_down %or% sd) - sd_up <- as.double(sd_up %or% sd) + sd_down <- as.double(deviationsDown) + sd_up <- as.double(deviationsUp) if (sd_down == sd_up) { name <- label( "Bollinger Bands", - ma$n, + timePeriod, sd_up ) } else { name <- label( "Bollinger Bands", - ma$n, + timePeriod, sd_up, sd_down ) @@ -276,7 +285,17 @@ bollinger_bands.plotly <- function( ), list( y = ~MiddleBand, - name = sub("\\(.*$", "", input_name(substitute(ma)), perl = TRUE), + name = c( + "SMA", + "EMA", + "WMA", + "DEMA", + "TEMA", + "TRIMA", + "KAMA", + "MAMA", + "T3" + )[maType + 1], fill = "tonexty" ), list( @@ -322,10 +341,10 @@ bollinger_bands.plotly <- function( bollinger_bands.ggplot <- function( x, cols, - ma = SMA(n = 5), - sd = 2, - sd_down, - sd_up, + timePeriod = 5, + deviationsUp = 2, + deviationsDown = 2, + maType = 0, na.bridge = FALSE, ## splice:optional-ggplot:start ## splice:optional-ggplot:end @@ -356,10 +375,10 @@ bollinger_bands.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - ma = ma, - sd = sd, - sd_down = sd_down, - sd_up = sd_up, + timePeriod = timePeriod, + deviationsUp = deviationsUp, + deviationsDown = deviationsDown, + maType = maType, na.bridge = TRUE ) @@ -381,7 +400,7 @@ bollinger_bands.ggplot <- function( y_lower = "LowerBand" ) ) - name <- label("Bollinger Bands", ma$n, sd) + name <- label("Bollinger Bands", timePeriod, deviationsUp) ## splice:ggplot-assembly:end state <- .chart_state() diff --git a/R/ta_BETA.R b/R/ta_BETA.R index 430918d6c..edf439921 100644 --- a/R/ta_BETA.R +++ b/R/ta_BETA.R @@ -1,8 +1,8 @@ #' @export -#' @family Rolling Statistic +#' @family Statistic Functions #' -#' @title Rolling Beta -#' @templateVar .title Rolling Beta +#' @title Beta +#' @templateVar .title Beta #' @templateVar .author Serkan Korkmaz #' @templateVar .fun rolling_beta #' @@ -13,8 +13,7 @@ #' @template rolling_returns rolling_beta <- function( x, - y, - n = 5, + timePeriod = 5, na.bridge = FALSE ) { UseMethod("rolling_beta") @@ -33,8 +32,7 @@ BETA <- rolling_beta #' @export rolling_beta.default <- function( x, - y, - n = 5, + timePeriod = 5, na.bridge = FALSE ) { ## calculate indicator and @@ -43,8 +41,7 @@ rolling_beta.default <- function( C_impl_ta_BETA, ## splice:call:start as.double(x), - as.double(y), - as.integer(n), + as.integer(timePeriod), ## splice:call:end as.logical(na.bridge) ) @@ -64,16 +61,14 @@ rolling_beta.default <- function( #' @export rolling_beta.numeric <- function( x, - y, - n = 5, + timePeriod = 5, na.bridge = FALSE ) { ## calculate indicator and ## return as data.frame x <- rolling_beta.default( x = x, - y = y, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge ) diff --git a/R/ta_BOP.R b/R/ta_BOP.R index 2e313da83..4dcc833d1 100644 --- a/R/ta_BOP.R +++ b/R/ta_BOP.R @@ -1,12 +1,12 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' -#' @title Balance of Power -#' @templateVar .title Balance of Power +#' @title Balance Of Power +#' @templateVar .title Balance Of Power #' @templateVar .author Serkan Korkmaz #' @templateVar .fun balance_of_power -#' @templateVar .family Momentum Indicator -#' @templateVar .formula ~ open + high + low + close +#' @templateVar .family Momentum Indicators +#' @templateVar .formula ~open + high + low + close #' ## splice:documentation:start ## splice:documentation:end @@ -62,12 +62,10 @@ balance_of_power.default <- function( ## return as data.frame x <- .Call( C_impl_ta_BOP, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], constructed_series[[4]], - ## splice:call:end as.logical(na.bridge) ) @@ -116,7 +114,17 @@ balance_of_power.matrix <- function( ) } - +#' @usage NULL +balance_of_power_lookback <- function( + x, + cols, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_BOP_lookback + ) +} #' @usage NULL #' @aliases balance_of_power #' @@ -204,7 +212,7 @@ balance_of_power.plotly <- function( ), data = constructed_indicator, title = if (missing(title)) { - "Balance of Power" + "Balance Of Power" } else { title } @@ -227,9 +235,9 @@ balance_of_power.ggplot <- function( x, cols, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -296,7 +304,7 @@ balance_of_power.ggplot <- function( ), data = constructed_indicator, title = if (missing(title)) { - "Balance of Power" + "Balance Of Power" } else { title } diff --git a/R/ta_CCI.R b/R/ta_CCI.R index e4b93a9f3..43344dadc 100644 --- a/R/ta_CCI.R +++ b/R/ta_CCI.R @@ -1,12 +1,12 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Commodity Channel Index #' @templateVar .title Commodity Channel Index #' @templateVar .author Serkan Korkmaz #' @templateVar .fun commodity_channel_index -#' @templateVar .family Momentum Indicator -#' @templateVar .formula ~ high + low + close +#' @templateVar .family Momentum Indicators +#' @templateVar .formula ~high + low + close #' ## splice:documentation:start ## splice:documentation:end @@ -16,7 +16,7 @@ commodity_channel_index <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ CCI <- commodity_channel_index commodity_channel_index.default <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -64,12 +64,10 @@ commodity_channel_index.default <- function( ## return as data.frame x <- .Call( C_impl_ta_CCI, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -87,7 +85,7 @@ commodity_channel_index.default <- function( commodity_channel_index.data.frame <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -95,7 +93,7 @@ commodity_channel_index.data.frame <- function( commodity_channel_index.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -109,20 +107,32 @@ commodity_channel_index.data.frame <- function( commodity_channel_index.matrix <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { commodity_channel_index.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +commodity_channel_index_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_CCI_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases commodity_channel_index #' @@ -130,12 +140,13 @@ commodity_channel_index.matrix <- function( commodity_channel_index.plotly <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ## splice:optional-plotly:start lower_bound = -100, upper_bound = 100, ## splice:optional-plotly:end + title, ... ) { ## check that input value @@ -164,10 +175,16 @@ commodity_channel_index.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) + ## the constructed indicator + ## always returns excpected + ## columns which can be passed + ## down to add_last_values() + values_to_extract <- colnames(constructed_indicator) + ## add conditional idx constructed_indicator[["idx"]] <- add_idx( constructed_series @@ -177,7 +194,7 @@ commodity_channel_index.plotly <- function( ## splice:plotly-assembly:start name <- sprintf( "CCI(%d)", - n + timePeriod ) traces <- list( plotly_line(lower_bound, nrow(constructed_indicator)), @@ -186,18 +203,31 @@ commodity_channel_index.plotly <- function( ) ## splice:plotly-assembly:end - state <- .chart_state() - plotly_object <- build_plotly( - init = state[["main"]], - traces = traces, - decorators = list(), - name = get0( - x = "name", - ifnotfound = NULL + plotly_object <- add_last_value_ly( + build_plotly( + init = plotly_init(), + traces = traces, + decorators = get0( + x = "decorators", + ifnotfound = list() + ), + name = get0( + x = "name", + ifnotfound = NULL + ), + data = constructed_indicator, + title = if (missing(title)) { + "Commodity Channel Index" + } else { + title + } ), - data = constructed_indicator + data = constructed_indicator[, values_to_extract, drop = FALSE], + values_to_extract = values_to_extract ) - state[["main"]] <- plotly_object + + state <- .chart_state() + state$sub <- c(state$sub, list(plotly_object)) plotly_object } @@ -209,8 +239,9 @@ commodity_channel_index.plotly <- function( commodity_channel_index.ggplot <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end ... @@ -240,10 +271,16 @@ commodity_channel_index.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) + ## the constructed indicator + ## always returns expected + ## columns which can be passed + ## down to add_last_value_gg() + values_to_extract <- colnames(constructed_indicator) + ## add conditional idx constructed_indicator[["idx"]] <- add_idx( constructed_series @@ -256,21 +293,35 @@ commodity_channel_index.ggplot <- function( ggplot_line(100), list(y = "CCI") ) - name <- sprintf("CCI(%d)", n) + name <- sprintf("CCI(%d)", timePeriod) ## splice:ggplot-assembly:end - state <- .chart_state() - ggplot_object <- build_ggplot( - init = state[["main"]], - layers = layers, - decorators = list(), - name = get0( - x = "name", - ifnotfound = NULL + ggplot_object <- add_last_value_gg( + build_ggplot( + init = ggplot_init(), + layers = layers, + decorators = get0( + x = "decorators", + ifnotfound = list() + ), + name = get0( + x = "name", + ifnotfound = NULL + ), + data = constructed_indicator, + title = if (missing(title)) { + "Commodity Channel Index" + } else { + title + } ), - data = constructed_indicator + data = constructed_indicator[, values_to_extract, drop = FALSE], + values_to_extract = values_to_extract, + name = get0(x = "name", ifnotfound = NULL) ) - state[["main"]] <- ggplot_object + + state <- .chart_state() + state$sub <- c(state$sub, list(ggplot_object)) ggplot_object } diff --git a/R/ta_CDL2CROWS.R b/R/ta_CDL2CROWS.R index 1697f99c1..b43e315ee 100644 --- a/R/ta_CDL2CROWS.R +++ b/R/ta_CDL2CROWS.R @@ -115,7 +115,12 @@ two_crows.data.frame <- function( ... ) { map_dfr( - NextMethod() + two_crows.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ two_crows.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + two_crows.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ two_crows.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ two_crows.plotly <- function( plotly_object } - #' @usage NULL #' @aliases two_crows #' @@ -225,7 +235,8 @@ two_crows.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDL3BLACKCROWS.R b/R/ta_CDL3BLACKCROWS.R index a3f46cea1..06e8cbff6 100644 --- a/R/ta_CDL3BLACKCROWS.R +++ b/R/ta_CDL3BLACKCROWS.R @@ -115,7 +115,12 @@ three_black_crows.data.frame <- function( ... ) { map_dfr( - NextMethod() + three_black_crows.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ three_black_crows.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + three_black_crows.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ three_black_crows.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ three_black_crows.plotly <- function( plotly_object } - #' @usage NULL #' @aliases three_black_crows #' @@ -225,7 +235,8 @@ three_black_crows.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDL3INSIDE.R b/R/ta_CDL3INSIDE.R index cd46e3309..22ed3836a 100644 --- a/R/ta_CDL3INSIDE.R +++ b/R/ta_CDL3INSIDE.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Three Inside -#' @templateVar .title Three Inside +#' @title Three Inside Up/Down +#' @templateVar .title Three Inside Up/Down #' @templateVar .author Serkan Korkmaz #' @templateVar .fun three_inside #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ three_inside.data.frame <- function( ... ) { map_dfr( - NextMethod() + three_inside.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ three_inside.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + three_inside.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ three_inside.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ three_inside.plotly <- function( plotly_object } - #' @usage NULL #' @aliases three_inside #' @@ -225,7 +235,8 @@ three_inside.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDL3LINESTRIKE.R b/R/ta_CDL3LINESTRIKE.R index ac54cdbbf..9a75f6539 100644 --- a/R/ta_CDL3LINESTRIKE.R +++ b/R/ta_CDL3LINESTRIKE.R @@ -115,7 +115,12 @@ three_line_strike.data.frame <- function( ... ) { map_dfr( - NextMethod() + three_line_strike.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ three_line_strike.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + three_line_strike.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ three_line_strike.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ three_line_strike.plotly <- function( plotly_object } - #' @usage NULL #' @aliases three_line_strike #' @@ -225,7 +235,8 @@ three_line_strike.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDL3OUTSIDE.R b/R/ta_CDL3OUTSIDE.R index 872ce706b..1e027a177 100644 --- a/R/ta_CDL3OUTSIDE.R +++ b/R/ta_CDL3OUTSIDE.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Three Outside -#' @templateVar .title Three Outside +#' @title Three Outside Up/Down +#' @templateVar .title Three Outside Up/Down #' @templateVar .author Serkan Korkmaz #' @templateVar .fun three_outside #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ three_outside.data.frame <- function( ... ) { map_dfr( - NextMethod() + three_outside.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ three_outside.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + three_outside.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ three_outside.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ three_outside.plotly <- function( plotly_object } - #' @usage NULL #' @aliases three_outside #' @@ -225,7 +235,8 @@ three_outside.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDL3STARSINSOUTH.R b/R/ta_CDL3STARSINSOUTH.R index bf6fbc1ec..e1f8dd69b 100644 --- a/R/ta_CDL3STARSINSOUTH.R +++ b/R/ta_CDL3STARSINSOUTH.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Three Stars in the South -#' @templateVar .title Three Stars in the South +#' @title Three Stars In The South +#' @templateVar .title Three Stars In The South #' @templateVar .author Serkan Korkmaz #' @templateVar .fun three_stars_in_the_south #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ three_stars_in_the_south.data.frame <- function( ... ) { map_dfr( - NextMethod() + three_stars_in_the_south.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ three_stars_in_the_south.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + three_stars_in_the_south.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ three_stars_in_the_south.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ three_stars_in_the_south.plotly <- function( plotly_object } - #' @usage NULL #' @aliases three_stars_in_the_south #' @@ -225,7 +235,8 @@ three_stars_in_the_south.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDL3WHITESOLDIERS.R b/R/ta_CDL3WHITESOLDIERS.R index 3d800b3f7..c2278c45d 100644 --- a/R/ta_CDL3WHITESOLDIERS.R +++ b/R/ta_CDL3WHITESOLDIERS.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Three White Soldiers -#' @templateVar .title Three White Soldiers +#' @title Three Advancing White Soldiers +#' @templateVar .title Three Advancing White Soldiers #' @templateVar .author Serkan Korkmaz #' @templateVar .fun three_white_soldiers #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ three_white_soldiers.data.frame <- function( ... ) { map_dfr( - NextMethod() + three_white_soldiers.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ three_white_soldiers.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + three_white_soldiers.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ three_white_soldiers.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ three_white_soldiers.plotly <- function( plotly_object } - #' @usage NULL #' @aliases three_white_soldiers #' @@ -225,7 +235,8 @@ three_white_soldiers.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLABANDONEDBABY.R b/R/ta_CDLABANDONEDBABY.R index 5decd6880..d07a35a01 100644 --- a/R/ta_CDLABANDONEDBABY.R +++ b/R/ta_CDLABANDONEDBABY.R @@ -26,7 +26,7 @@ abandoned_baby <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -47,7 +47,7 @@ CDLABANDONEDBABY <- abandoned_baby abandoned_baby.default <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -91,7 +91,7 @@ abandoned_baby.default <- function( constructed_series[[2]], constructed_series[[3]], constructed_series[[4]], - eps, + as.double(penetration), normalize, as.logical(na.bridge) ) @@ -114,12 +114,18 @@ abandoned_baby.default <- function( abandoned_baby.data.frame <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { map_dfr( - NextMethod() + abandoned_baby.default( + x = x, + cols = cols, + penetration = penetration, + na.bridge = na.bridge, + ... + ) ) } @@ -130,11 +136,17 @@ abandoned_baby.data.frame <- function( abandoned_baby.matrix <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { - NextMethod() + abandoned_baby.default( + x = x, + cols = cols, + penetration = penetration, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -144,7 +156,7 @@ abandoned_baby.matrix <- function( abandoned_baby.plotly <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -174,7 +186,8 @@ abandoned_baby.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - eps = eps + penetration = penetration, + na.bridge = na.bridge ) ## add conditional idx @@ -197,7 +210,6 @@ abandoned_baby.plotly <- function( plotly_object } - #' @usage NULL #' @aliases abandoned_baby #' @@ -205,7 +217,7 @@ abandoned_baby.plotly <- function( abandoned_baby.ggplot <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -234,7 +246,8 @@ abandoned_baby.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - eps = eps + penetration = penetration, + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLADVANCEBLOCK.R b/R/ta_CDLADVANCEBLOCK.R index 7ffa59eb0..cb961092f 100644 --- a/R/ta_CDLADVANCEBLOCK.R +++ b/R/ta_CDLADVANCEBLOCK.R @@ -115,7 +115,12 @@ advance_block.data.frame <- function( ... ) { map_dfr( - NextMethod() + advance_block.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ advance_block.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + advance_block.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ advance_block.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ advance_block.plotly <- function( plotly_object } - #' @usage NULL #' @aliases advance_block #' @@ -225,7 +235,8 @@ advance_block.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLBELTHOLD.R b/R/ta_CDLBELTHOLD.R index d241985d7..5535af547 100644 --- a/R/ta_CDLBELTHOLD.R +++ b/R/ta_CDLBELTHOLD.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Belt Hold -#' @templateVar .title Belt Hold +#' @title Belt-hold +#' @templateVar .title Belt-hold #' @templateVar .author Serkan Korkmaz #' @templateVar .fun belt_hold #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ belt_hold.data.frame <- function( ... ) { map_dfr( - NextMethod() + belt_hold.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ belt_hold.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + belt_hold.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ belt_hold.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ belt_hold.plotly <- function( plotly_object } - #' @usage NULL #' @aliases belt_hold #' @@ -225,7 +235,8 @@ belt_hold.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLBREAKAWAY.R b/R/ta_CDLBREAKAWAY.R index 05fd11f8b..242eea99b 100644 --- a/R/ta_CDLBREAKAWAY.R +++ b/R/ta_CDLBREAKAWAY.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Break Away -#' @templateVar .title Break Away +#' @title Breakaway +#' @templateVar .title Breakaway #' @templateVar .author Serkan Korkmaz #' @templateVar .fun break_away #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ break_away.data.frame <- function( ... ) { map_dfr( - NextMethod() + break_away.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ break_away.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + break_away.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ break_away.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ break_away.plotly <- function( plotly_object } - #' @usage NULL #' @aliases break_away #' @@ -225,7 +235,8 @@ break_away.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLCLOSINGMARUBOZU.R b/R/ta_CDLCLOSINGMARUBOZU.R index 8c12755f5..ac9ba27e1 100644 --- a/R/ta_CDLCLOSINGMARUBOZU.R +++ b/R/ta_CDLCLOSINGMARUBOZU.R @@ -115,7 +115,12 @@ closing_marubozu.data.frame <- function( ... ) { map_dfr( - NextMethod() + closing_marubozu.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ closing_marubozu.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + closing_marubozu.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ closing_marubozu.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ closing_marubozu.plotly <- function( plotly_object } - #' @usage NULL #' @aliases closing_marubozu #' @@ -225,7 +235,8 @@ closing_marubozu.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLCONCEALBABYSWALL.R b/R/ta_CDLCONCEALBABYSWALL.R index 1abe77544..f9b97bcd3 100644 --- a/R/ta_CDLCONCEALBABYSWALL.R +++ b/R/ta_CDLCONCEALBABYSWALL.R @@ -115,7 +115,12 @@ concealing_baby_swallow.data.frame <- function( ... ) { map_dfr( - NextMethod() + concealing_baby_swallow.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ concealing_baby_swallow.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + concealing_baby_swallow.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ concealing_baby_swallow.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ concealing_baby_swallow.plotly <- function( plotly_object } - #' @usage NULL #' @aliases concealing_baby_swallow #' @@ -225,7 +235,8 @@ concealing_baby_swallow.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLCOUNTERATTACK.R b/R/ta_CDLCOUNTERATTACK.R index 3fb8660c4..6f4027bef 100644 --- a/R/ta_CDLCOUNTERATTACK.R +++ b/R/ta_CDLCOUNTERATTACK.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Counter Attack -#' @templateVar .title Counter Attack +#' @title Counterattack +#' @templateVar .title Counterattack #' @templateVar .author Serkan Korkmaz #' @templateVar .fun counter_attack #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ counter_attack.data.frame <- function( ... ) { map_dfr( - NextMethod() + counter_attack.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ counter_attack.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + counter_attack.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ counter_attack.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ counter_attack.plotly <- function( plotly_object } - #' @usage NULL #' @aliases counter_attack #' @@ -225,7 +235,8 @@ counter_attack.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLDARKCLOUDCOVER.R b/R/ta_CDLDARKCLOUDCOVER.R index b56bd5113..31850cf6b 100644 --- a/R/ta_CDLDARKCLOUDCOVER.R +++ b/R/ta_CDLDARKCLOUDCOVER.R @@ -26,7 +26,7 @@ dark_cloud_cover <- function( x, cols, - eps = 0, + penetration = 0.5, na.bridge = FALSE, ... ) { @@ -47,7 +47,7 @@ CDLDARKCLOUDCOVER <- dark_cloud_cover dark_cloud_cover.default <- function( x, cols, - eps = 0, + penetration = 0.5, na.bridge = FALSE, ... ) { @@ -91,7 +91,7 @@ dark_cloud_cover.default <- function( constructed_series[[2]], constructed_series[[3]], constructed_series[[4]], - eps, + as.double(penetration), normalize, as.logical(na.bridge) ) @@ -114,12 +114,18 @@ dark_cloud_cover.default <- function( dark_cloud_cover.data.frame <- function( x, cols, - eps = 0, + penetration = 0.5, na.bridge = FALSE, ... ) { map_dfr( - NextMethod() + dark_cloud_cover.default( + x = x, + cols = cols, + penetration = penetration, + na.bridge = na.bridge, + ... + ) ) } @@ -130,11 +136,17 @@ dark_cloud_cover.data.frame <- function( dark_cloud_cover.matrix <- function( x, cols, - eps = 0, + penetration = 0.5, na.bridge = FALSE, ... ) { - NextMethod() + dark_cloud_cover.default( + x = x, + cols = cols, + penetration = penetration, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -144,7 +156,7 @@ dark_cloud_cover.matrix <- function( dark_cloud_cover.plotly <- function( x, cols, - eps = 0, + penetration = 0.5, na.bridge = FALSE, ... ) { @@ -174,7 +186,8 @@ dark_cloud_cover.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - eps = eps + penetration = penetration, + na.bridge = na.bridge ) ## add conditional idx @@ -197,7 +210,6 @@ dark_cloud_cover.plotly <- function( plotly_object } - #' @usage NULL #' @aliases dark_cloud_cover #' @@ -205,7 +217,7 @@ dark_cloud_cover.plotly <- function( dark_cloud_cover.ggplot <- function( x, cols, - eps = 0, + penetration = 0.5, na.bridge = FALSE, ... ) { @@ -234,7 +246,8 @@ dark_cloud_cover.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - eps = eps + penetration = penetration, + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLDOJI.R b/R/ta_CDLDOJI.R index 2ca3a5002..76093b735 100644 --- a/R/ta_CDLDOJI.R +++ b/R/ta_CDLDOJI.R @@ -115,7 +115,12 @@ doji.data.frame <- function( ... ) { map_dfr( - NextMethod() + doji.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ doji.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + doji.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ doji.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ doji.plotly <- function( plotly_object } - #' @usage NULL #' @aliases doji #' @@ -225,7 +235,8 @@ doji.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLDOJISTAR.R b/R/ta_CDLDOJISTAR.R index 9691c0ef6..b5f191e04 100644 --- a/R/ta_CDLDOJISTAR.R +++ b/R/ta_CDLDOJISTAR.R @@ -115,7 +115,12 @@ doji_star.data.frame <- function( ... ) { map_dfr( - NextMethod() + doji_star.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ doji_star.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + doji_star.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ doji_star.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ doji_star.plotly <- function( plotly_object } - #' @usage NULL #' @aliases doji_star #' @@ -225,7 +235,8 @@ doji_star.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLDRAGONFLYDOJI.R b/R/ta_CDLDRAGONFLYDOJI.R index 602530860..d96143d82 100644 --- a/R/ta_CDLDRAGONFLYDOJI.R +++ b/R/ta_CDLDRAGONFLYDOJI.R @@ -115,7 +115,12 @@ dragonfly_doji.data.frame <- function( ... ) { map_dfr( - NextMethod() + dragonfly_doji.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ dragonfly_doji.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + dragonfly_doji.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ dragonfly_doji.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ dragonfly_doji.plotly <- function( plotly_object } - #' @usage NULL #' @aliases dragonfly_doji #' @@ -225,7 +235,8 @@ dragonfly_doji.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLENGULFING.R b/R/ta_CDLENGULFING.R index 24038dd37..d91641fe8 100644 --- a/R/ta_CDLENGULFING.R +++ b/R/ta_CDLENGULFING.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Engulfing -#' @templateVar .title Engulfing +#' @title Engulfing Pattern +#' @templateVar .title Engulfing Pattern #' @templateVar .author Serkan Korkmaz #' @templateVar .fun engulfing #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ engulfing.data.frame <- function( ... ) { map_dfr( - NextMethod() + engulfing.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ engulfing.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + engulfing.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ engulfing.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ engulfing.plotly <- function( plotly_object } - #' @usage NULL #' @aliases engulfing #' @@ -225,7 +235,8 @@ engulfing.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLEVENINGDOJISTAR.R b/R/ta_CDLEVENINGDOJISTAR.R index 907656aa7..ddd3e88c2 100644 --- a/R/ta_CDLEVENINGDOJISTAR.R +++ b/R/ta_CDLEVENINGDOJISTAR.R @@ -26,7 +26,7 @@ evening_doji_star <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -47,7 +47,7 @@ CDLEVENINGDOJISTAR <- evening_doji_star evening_doji_star.default <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -91,7 +91,7 @@ evening_doji_star.default <- function( constructed_series[[2]], constructed_series[[3]], constructed_series[[4]], - eps, + as.double(penetration), normalize, as.logical(na.bridge) ) @@ -114,12 +114,18 @@ evening_doji_star.default <- function( evening_doji_star.data.frame <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { map_dfr( - NextMethod() + evening_doji_star.default( + x = x, + cols = cols, + penetration = penetration, + na.bridge = na.bridge, + ... + ) ) } @@ -130,11 +136,17 @@ evening_doji_star.data.frame <- function( evening_doji_star.matrix <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { - NextMethod() + evening_doji_star.default( + x = x, + cols = cols, + penetration = penetration, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -144,7 +156,7 @@ evening_doji_star.matrix <- function( evening_doji_star.plotly <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -174,7 +186,8 @@ evening_doji_star.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - eps = eps + penetration = penetration, + na.bridge = na.bridge ) ## add conditional idx @@ -197,7 +210,6 @@ evening_doji_star.plotly <- function( plotly_object } - #' @usage NULL #' @aliases evening_doji_star #' @@ -205,7 +217,7 @@ evening_doji_star.plotly <- function( evening_doji_star.ggplot <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -234,7 +246,8 @@ evening_doji_star.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - eps = eps + penetration = penetration, + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLEVENINGSTAR.R b/R/ta_CDLEVENINGSTAR.R index 944020248..a30393056 100644 --- a/R/ta_CDLEVENINGSTAR.R +++ b/R/ta_CDLEVENINGSTAR.R @@ -26,7 +26,7 @@ evening_star <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -47,7 +47,7 @@ CDLEVENINGSTAR <- evening_star evening_star.default <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -91,7 +91,7 @@ evening_star.default <- function( constructed_series[[2]], constructed_series[[3]], constructed_series[[4]], - eps, + as.double(penetration), normalize, as.logical(na.bridge) ) @@ -114,12 +114,18 @@ evening_star.default <- function( evening_star.data.frame <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { map_dfr( - NextMethod() + evening_star.default( + x = x, + cols = cols, + penetration = penetration, + na.bridge = na.bridge, + ... + ) ) } @@ -130,11 +136,17 @@ evening_star.data.frame <- function( evening_star.matrix <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { - NextMethod() + evening_star.default( + x = x, + cols = cols, + penetration = penetration, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -144,7 +156,7 @@ evening_star.matrix <- function( evening_star.plotly <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -174,7 +186,8 @@ evening_star.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - eps = eps + penetration = penetration, + na.bridge = na.bridge ) ## add conditional idx @@ -197,7 +210,6 @@ evening_star.plotly <- function( plotly_object } - #' @usage NULL #' @aliases evening_star #' @@ -205,7 +217,7 @@ evening_star.plotly <- function( evening_star.ggplot <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -234,7 +246,8 @@ evening_star.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - eps = eps + penetration = penetration, + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLGAPSIDESIDEWHITE.R b/R/ta_CDLGAPSIDESIDEWHITE.R index 50410f78b..b8823b7d3 100644 --- a/R/ta_CDLGAPSIDESIDEWHITE.R +++ b/R/ta_CDLGAPSIDESIDEWHITE.R @@ -115,7 +115,12 @@ gaps_side_white.data.frame <- function( ... ) { map_dfr( - NextMethod() + gaps_side_white.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ gaps_side_white.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + gaps_side_white.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ gaps_side_white.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ gaps_side_white.plotly <- function( plotly_object } - #' @usage NULL #' @aliases gaps_side_white #' @@ -225,7 +235,8 @@ gaps_side_white.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLGRAVESTONEDOJI.R b/R/ta_CDLGRAVESTONEDOJI.R index 931163072..51eb21004 100644 --- a/R/ta_CDLGRAVESTONEDOJI.R +++ b/R/ta_CDLGRAVESTONEDOJI.R @@ -115,7 +115,12 @@ gravestone_doji.data.frame <- function( ... ) { map_dfr( - NextMethod() + gravestone_doji.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ gravestone_doji.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + gravestone_doji.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ gravestone_doji.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ gravestone_doji.plotly <- function( plotly_object } - #' @usage NULL #' @aliases gravestone_doji #' @@ -225,7 +235,8 @@ gravestone_doji.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLHAMMER.R b/R/ta_CDLHAMMER.R index bf74d0411..3fd128af7 100644 --- a/R/ta_CDLHAMMER.R +++ b/R/ta_CDLHAMMER.R @@ -115,7 +115,12 @@ hammer.data.frame <- function( ... ) { map_dfr( - NextMethod() + hammer.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ hammer.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + hammer.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ hammer.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ hammer.plotly <- function( plotly_object } - #' @usage NULL #' @aliases hammer #' @@ -225,7 +235,8 @@ hammer.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLHANGINGMAN.R b/R/ta_CDLHANGINGMAN.R index 427325177..65a8a0106 100644 --- a/R/ta_CDLHANGINGMAN.R +++ b/R/ta_CDLHANGINGMAN.R @@ -115,7 +115,12 @@ hanging_man.data.frame <- function( ... ) { map_dfr( - NextMethod() + hanging_man.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ hanging_man.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + hanging_man.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ hanging_man.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ hanging_man.plotly <- function( plotly_object } - #' @usage NULL #' @aliases hanging_man #' @@ -225,7 +235,8 @@ hanging_man.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLHARAMI.R b/R/ta_CDLHARAMI.R index 0e1a5403f..b6e6f147c 100644 --- a/R/ta_CDLHARAMI.R +++ b/R/ta_CDLHARAMI.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Harami -#' @templateVar .title Harami +#' @title Harami Pattern +#' @templateVar .title Harami Pattern #' @templateVar .author Serkan Korkmaz #' @templateVar .fun harami #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ harami.data.frame <- function( ... ) { map_dfr( - NextMethod() + harami.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ harami.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + harami.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ harami.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ harami.plotly <- function( plotly_object } - #' @usage NULL #' @aliases harami #' @@ -225,7 +235,8 @@ harami.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLHARAMICROSS.R b/R/ta_CDLHARAMICROSS.R index 749141b97..13a9a6137 100644 --- a/R/ta_CDLHARAMICROSS.R +++ b/R/ta_CDLHARAMICROSS.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Harami Cross -#' @templateVar .title Harami Cross +#' @title Harami Cross Pattern +#' @templateVar .title Harami Cross Pattern #' @templateVar .author Serkan Korkmaz #' @templateVar .fun harami_cross #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ harami_cross.data.frame <- function( ... ) { map_dfr( - NextMethod() + harami_cross.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ harami_cross.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + harami_cross.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ harami_cross.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ harami_cross.plotly <- function( plotly_object } - #' @usage NULL #' @aliases harami_cross #' @@ -225,7 +235,8 @@ harami_cross.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLHIGHWAVE.R b/R/ta_CDLHIGHWAVE.R index 17100b4e3..317ed401d 100644 --- a/R/ta_CDLHIGHWAVE.R +++ b/R/ta_CDLHIGHWAVE.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title High Wave -#' @templateVar .title High Wave +#' @title High-Wave Candle +#' @templateVar .title High-Wave Candle #' @templateVar .author Serkan Korkmaz #' @templateVar .fun high_wave #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ high_wave.data.frame <- function( ... ) { map_dfr( - NextMethod() + high_wave.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ high_wave.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + high_wave.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ high_wave.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ high_wave.plotly <- function( plotly_object } - #' @usage NULL #' @aliases high_wave #' @@ -225,7 +235,8 @@ high_wave.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLHIKKAKE.R b/R/ta_CDLHIKKAKE.R index f5e218e47..3848fc068 100644 --- a/R/ta_CDLHIKKAKE.R +++ b/R/ta_CDLHIKKAKE.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Hikkake -#' @templateVar .title Hikkake +#' @title Hikkake Pattern +#' @templateVar .title Hikkake Pattern #' @templateVar .author Serkan Korkmaz #' @templateVar .fun hikakke #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ hikakke.data.frame <- function( ... ) { map_dfr( - NextMethod() + hikakke.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ hikakke.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + hikakke.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ hikakke.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ hikakke.plotly <- function( plotly_object } - #' @usage NULL #' @aliases hikakke #' @@ -225,7 +235,8 @@ hikakke.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLHIKKAKEMOD.R b/R/ta_CDLHIKKAKEMOD.R index 43fdab5ee..a68d4f2a1 100644 --- a/R/ta_CDLHIKKAKEMOD.R +++ b/R/ta_CDLHIKKAKEMOD.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Hikkake Modified -#' @templateVar .title Hikkake Modified +#' @title Modified Hikkake Pattern +#' @templateVar .title Modified Hikkake Pattern #' @templateVar .author Serkan Korkmaz #' @templateVar .fun hikakke_mod #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ hikakke_mod.data.frame <- function( ... ) { map_dfr( - NextMethod() + hikakke_mod.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ hikakke_mod.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + hikakke_mod.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ hikakke_mod.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ hikakke_mod.plotly <- function( plotly_object } - #' @usage NULL #' @aliases hikakke_mod #' @@ -225,7 +235,8 @@ hikakke_mod.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLHOMINGPIGEON.R b/R/ta_CDLHOMINGPIGEON.R index 82566f6b6..b0c78e3c9 100644 --- a/R/ta_CDLHOMINGPIGEON.R +++ b/R/ta_CDLHOMINGPIGEON.R @@ -115,7 +115,12 @@ homing_pigeon.data.frame <- function( ... ) { map_dfr( - NextMethod() + homing_pigeon.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ homing_pigeon.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + homing_pigeon.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ homing_pigeon.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ homing_pigeon.plotly <- function( plotly_object } - #' @usage NULL #' @aliases homing_pigeon #' @@ -225,7 +235,8 @@ homing_pigeon.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLIDENTICAL3CROWS.R b/R/ta_CDLIDENTICAL3CROWS.R index 6d53e8b46..7c6c57cbc 100644 --- a/R/ta_CDLIDENTICAL3CROWS.R +++ b/R/ta_CDLIDENTICAL3CROWS.R @@ -115,7 +115,12 @@ three_identical_crows.data.frame <- function( ... ) { map_dfr( - NextMethod() + three_identical_crows.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ three_identical_crows.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + three_identical_crows.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ three_identical_crows.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ three_identical_crows.plotly <- function( plotly_object } - #' @usage NULL #' @aliases three_identical_crows #' @@ -225,7 +235,8 @@ three_identical_crows.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLINNECK.R b/R/ta_CDLINNECK.R index 0ad45078d..3a434dedc 100644 --- a/R/ta_CDLINNECK.R +++ b/R/ta_CDLINNECK.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title In Neck -#' @templateVar .title In Neck +#' @title In-Neck Pattern +#' @templateVar .title In-Neck Pattern #' @templateVar .author Serkan Korkmaz #' @templateVar .fun in_neck #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ in_neck.data.frame <- function( ... ) { map_dfr( - NextMethod() + in_neck.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ in_neck.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + in_neck.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ in_neck.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ in_neck.plotly <- function( plotly_object } - #' @usage NULL #' @aliases in_neck #' @@ -225,7 +235,8 @@ in_neck.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLINVERTEDHAMMER.R b/R/ta_CDLINVERTEDHAMMER.R index 46b28e3a1..508b7c8e5 100644 --- a/R/ta_CDLINVERTEDHAMMER.R +++ b/R/ta_CDLINVERTEDHAMMER.R @@ -115,7 +115,12 @@ inverted_hammer.data.frame <- function( ... ) { map_dfr( - NextMethod() + inverted_hammer.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ inverted_hammer.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + inverted_hammer.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ inverted_hammer.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ inverted_hammer.plotly <- function( plotly_object } - #' @usage NULL #' @aliases inverted_hammer #' @@ -225,7 +235,8 @@ inverted_hammer.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLKICKING.R b/R/ta_CDLKICKING.R index 079feb387..18c0a1dca 100644 --- a/R/ta_CDLKICKING.R +++ b/R/ta_CDLKICKING.R @@ -115,7 +115,12 @@ kicking.data.frame <- function( ... ) { map_dfr( - NextMethod() + kicking.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ kicking.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + kicking.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ kicking.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ kicking.plotly <- function( plotly_object } - #' @usage NULL #' @aliases kicking #' @@ -225,7 +235,8 @@ kicking.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLKICKINGBYLENGTH.R b/R/ta_CDLKICKINGBYLENGTH.R index 9e60f5a56..ec27b2be8 100644 --- a/R/ta_CDLKICKINGBYLENGTH.R +++ b/R/ta_CDLKICKINGBYLENGTH.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Kicking Baby Length -#' @templateVar .title Kicking Baby Length +#' @title Kicking - bull/bear determined by the longer marubozu +#' @templateVar .title Kicking - bull/bear determined by the longer marubozu #' @templateVar .author Serkan Korkmaz #' @templateVar .fun kicking_baby_length #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ kicking_baby_length.data.frame <- function( ... ) { map_dfr( - NextMethod() + kicking_baby_length.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ kicking_baby_length.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + kicking_baby_length.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ kicking_baby_length.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ kicking_baby_length.plotly <- function( plotly_object } - #' @usage NULL #' @aliases kicking_baby_length #' @@ -225,7 +235,8 @@ kicking_baby_length.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLLADDERBOTTOM.R b/R/ta_CDLLADDERBOTTOM.R index a43a9cf41..75ba947d4 100644 --- a/R/ta_CDLLADDERBOTTOM.R +++ b/R/ta_CDLLADDERBOTTOM.R @@ -115,7 +115,12 @@ ladder_bottom.data.frame <- function( ... ) { map_dfr( - NextMethod() + ladder_bottom.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ ladder_bottom.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + ladder_bottom.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ ladder_bottom.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ ladder_bottom.plotly <- function( plotly_object } - #' @usage NULL #' @aliases ladder_bottom #' @@ -225,7 +235,8 @@ ladder_bottom.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLLONGLEGGEDDOJI.R b/R/ta_CDLLONGLEGGEDDOJI.R index 342e5c135..84b4969b9 100644 --- a/R/ta_CDLLONGLEGGEDDOJI.R +++ b/R/ta_CDLLONGLEGGEDDOJI.R @@ -115,7 +115,12 @@ long_legged_doji.data.frame <- function( ... ) { map_dfr( - NextMethod() + long_legged_doji.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ long_legged_doji.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + long_legged_doji.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ long_legged_doji.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ long_legged_doji.plotly <- function( plotly_object } - #' @usage NULL #' @aliases long_legged_doji #' @@ -225,7 +235,8 @@ long_legged_doji.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLLONGLINE.R b/R/ta_CDLLONGLINE.R index 7c907f73c..95559f435 100644 --- a/R/ta_CDLLONGLINE.R +++ b/R/ta_CDLLONGLINE.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Long Line -#' @templateVar .title Long Line +#' @title Long Line Candle +#' @templateVar .title Long Line Candle #' @templateVar .author Serkan Korkmaz #' @templateVar .fun long_line #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ long_line.data.frame <- function( ... ) { map_dfr( - NextMethod() + long_line.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ long_line.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + long_line.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ long_line.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ long_line.plotly <- function( plotly_object } - #' @usage NULL #' @aliases long_line #' @@ -225,7 +235,8 @@ long_line.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLMARUBOZU.R b/R/ta_CDLMARUBOZU.R index fe592ac37..55b262f6a 100644 --- a/R/ta_CDLMARUBOZU.R +++ b/R/ta_CDLMARUBOZU.R @@ -115,7 +115,12 @@ marubozu.data.frame <- function( ... ) { map_dfr( - NextMethod() + marubozu.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ marubozu.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + marubozu.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ marubozu.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ marubozu.plotly <- function( plotly_object } - #' @usage NULL #' @aliases marubozu #' @@ -225,7 +235,8 @@ marubozu.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLMATCHINGLOW.R b/R/ta_CDLMATCHINGLOW.R index c1aab57d1..f80c5d0b7 100644 --- a/R/ta_CDLMATCHINGLOW.R +++ b/R/ta_CDLMATCHINGLOW.R @@ -115,7 +115,12 @@ matching_low.data.frame <- function( ... ) { map_dfr( - NextMethod() + matching_low.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ matching_low.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + matching_low.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ matching_low.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ matching_low.plotly <- function( plotly_object } - #' @usage NULL #' @aliases matching_low #' @@ -225,7 +235,8 @@ matching_low.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLMATHOLD.R b/R/ta_CDLMATHOLD.R index afe98eabf..22e8b0411 100644 --- a/R/ta_CDLMATHOLD.R +++ b/R/ta_CDLMATHOLD.R @@ -26,7 +26,7 @@ mat_hold <- function( x, cols, - eps = 0, + penetration = 0.5, na.bridge = FALSE, ... ) { @@ -47,7 +47,7 @@ CDLMATHOLD <- mat_hold mat_hold.default <- function( x, cols, - eps = 0, + penetration = 0.5, na.bridge = FALSE, ... ) { @@ -91,7 +91,7 @@ mat_hold.default <- function( constructed_series[[2]], constructed_series[[3]], constructed_series[[4]], - eps, + as.double(penetration), normalize, as.logical(na.bridge) ) @@ -114,12 +114,18 @@ mat_hold.default <- function( mat_hold.data.frame <- function( x, cols, - eps = 0, + penetration = 0.5, na.bridge = FALSE, ... ) { map_dfr( - NextMethod() + mat_hold.default( + x = x, + cols = cols, + penetration = penetration, + na.bridge = na.bridge, + ... + ) ) } @@ -130,11 +136,17 @@ mat_hold.data.frame <- function( mat_hold.matrix <- function( x, cols, - eps = 0, + penetration = 0.5, na.bridge = FALSE, ... ) { - NextMethod() + mat_hold.default( + x = x, + cols = cols, + penetration = penetration, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -144,7 +156,7 @@ mat_hold.matrix <- function( mat_hold.plotly <- function( x, cols, - eps = 0, + penetration = 0.5, na.bridge = FALSE, ... ) { @@ -174,7 +186,8 @@ mat_hold.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - eps = eps + penetration = penetration, + na.bridge = na.bridge ) ## add conditional idx @@ -197,7 +210,6 @@ mat_hold.plotly <- function( plotly_object } - #' @usage NULL #' @aliases mat_hold #' @@ -205,7 +217,7 @@ mat_hold.plotly <- function( mat_hold.ggplot <- function( x, cols, - eps = 0, + penetration = 0.5, na.bridge = FALSE, ... ) { @@ -234,7 +246,8 @@ mat_hold.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - eps = eps + penetration = penetration, + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLMORNINGDOJISTAR.R b/R/ta_CDLMORNINGDOJISTAR.R index 5aa05cb81..4930cf91c 100644 --- a/R/ta_CDLMORNINGDOJISTAR.R +++ b/R/ta_CDLMORNINGDOJISTAR.R @@ -26,7 +26,7 @@ morning_doji_star <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -47,7 +47,7 @@ CDLMORNINGDOJISTAR <- morning_doji_star morning_doji_star.default <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -91,7 +91,7 @@ morning_doji_star.default <- function( constructed_series[[2]], constructed_series[[3]], constructed_series[[4]], - eps, + as.double(penetration), normalize, as.logical(na.bridge) ) @@ -114,12 +114,18 @@ morning_doji_star.default <- function( morning_doji_star.data.frame <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { map_dfr( - NextMethod() + morning_doji_star.default( + x = x, + cols = cols, + penetration = penetration, + na.bridge = na.bridge, + ... + ) ) } @@ -130,11 +136,17 @@ morning_doji_star.data.frame <- function( morning_doji_star.matrix <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { - NextMethod() + morning_doji_star.default( + x = x, + cols = cols, + penetration = penetration, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -144,7 +156,7 @@ morning_doji_star.matrix <- function( morning_doji_star.plotly <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -174,7 +186,8 @@ morning_doji_star.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - eps = eps + penetration = penetration, + na.bridge = na.bridge ) ## add conditional idx @@ -197,7 +210,6 @@ morning_doji_star.plotly <- function( plotly_object } - #' @usage NULL #' @aliases morning_doji_star #' @@ -205,7 +217,7 @@ morning_doji_star.plotly <- function( morning_doji_star.ggplot <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -234,7 +246,8 @@ morning_doji_star.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - eps = eps + penetration = penetration, + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLMORNINGSTAR.R b/R/ta_CDLMORNINGSTAR.R index d2fd17206..dc6a84c17 100644 --- a/R/ta_CDLMORNINGSTAR.R +++ b/R/ta_CDLMORNINGSTAR.R @@ -26,7 +26,7 @@ morning_star <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -47,7 +47,7 @@ CDLMORNINGSTAR <- morning_star morning_star.default <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -91,7 +91,7 @@ morning_star.default <- function( constructed_series[[2]], constructed_series[[3]], constructed_series[[4]], - eps, + as.double(penetration), normalize, as.logical(na.bridge) ) @@ -114,12 +114,18 @@ morning_star.default <- function( morning_star.data.frame <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { map_dfr( - NextMethod() + morning_star.default( + x = x, + cols = cols, + penetration = penetration, + na.bridge = na.bridge, + ... + ) ) } @@ -130,11 +136,17 @@ morning_star.data.frame <- function( morning_star.matrix <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { - NextMethod() + morning_star.default( + x = x, + cols = cols, + penetration = penetration, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -144,7 +156,7 @@ morning_star.matrix <- function( morning_star.plotly <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -174,7 +186,8 @@ morning_star.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - eps = eps + penetration = penetration, + na.bridge = na.bridge ) ## add conditional idx @@ -197,7 +210,6 @@ morning_star.plotly <- function( plotly_object } - #' @usage NULL #' @aliases morning_star #' @@ -205,7 +217,7 @@ morning_star.plotly <- function( morning_star.ggplot <- function( x, cols, - eps = 0, + penetration = 0.3, na.bridge = FALSE, ... ) { @@ -234,7 +246,8 @@ morning_star.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - eps = eps + penetration = penetration, + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLONNECK.R b/R/ta_CDLONNECK.R index 4d9ed7fe6..4b63d2274 100644 --- a/R/ta_CDLONNECK.R +++ b/R/ta_CDLONNECK.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title On-Neck -#' @templateVar .title On-Neck +#' @title On-Neck Pattern +#' @templateVar .title On-Neck Pattern #' @templateVar .author Serkan Korkmaz #' @templateVar .fun on_neck #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ on_neck.data.frame <- function( ... ) { map_dfr( - NextMethod() + on_neck.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ on_neck.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + on_neck.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ on_neck.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ on_neck.plotly <- function( plotly_object } - #' @usage NULL #' @aliases on_neck #' @@ -225,7 +235,8 @@ on_neck.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLPIERCING.R b/R/ta_CDLPIERCING.R index 5df9f1330..db63ab158 100644 --- a/R/ta_CDLPIERCING.R +++ b/R/ta_CDLPIERCING.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Piercing -#' @templateVar .title Piercing +#' @title Piercing Pattern +#' @templateVar .title Piercing Pattern #' @templateVar .author Serkan Korkmaz #' @templateVar .fun piercing #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ piercing.data.frame <- function( ... ) { map_dfr( - NextMethod() + piercing.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ piercing.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + piercing.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ piercing.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ piercing.plotly <- function( plotly_object } - #' @usage NULL #' @aliases piercing #' @@ -225,7 +235,8 @@ piercing.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLRICKSHAWMAN.R b/R/ta_CDLRICKSHAWMAN.R index f96e13579..7c3293fa0 100644 --- a/R/ta_CDLRICKSHAWMAN.R +++ b/R/ta_CDLRICKSHAWMAN.R @@ -115,7 +115,12 @@ rickshaw_man.data.frame <- function( ... ) { map_dfr( - NextMethod() + rickshaw_man.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ rickshaw_man.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + rickshaw_man.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ rickshaw_man.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ rickshaw_man.plotly <- function( plotly_object } - #' @usage NULL #' @aliases rickshaw_man #' @@ -225,7 +235,8 @@ rickshaw_man.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLRISEFALL3METHODS.R b/R/ta_CDLRISEFALL3METHODS.R index 116fa14ee..2c1fbe7d2 100644 --- a/R/ta_CDLRISEFALL3METHODS.R +++ b/R/ta_CDLRISEFALL3METHODS.R @@ -115,7 +115,12 @@ rise_fall_3_methods.data.frame <- function( ... ) { map_dfr( - NextMethod() + rise_fall_3_methods.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ rise_fall_3_methods.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + rise_fall_3_methods.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ rise_fall_3_methods.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ rise_fall_3_methods.plotly <- function( plotly_object } - #' @usage NULL #' @aliases rise_fall_3_methods #' @@ -225,7 +235,8 @@ rise_fall_3_methods.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLSEPARATINGLINES.R b/R/ta_CDLSEPARATINGLINES.R index e0ff5f769..b42c25688 100644 --- a/R/ta_CDLSEPARATINGLINES.R +++ b/R/ta_CDLSEPARATINGLINES.R @@ -115,7 +115,12 @@ separating_lines.data.frame <- function( ... ) { map_dfr( - NextMethod() + separating_lines.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ separating_lines.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + separating_lines.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ separating_lines.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ separating_lines.plotly <- function( plotly_object } - #' @usage NULL #' @aliases separating_lines #' @@ -225,7 +235,8 @@ separating_lines.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLSHOOTINGSTAR.R b/R/ta_CDLSHOOTINGSTAR.R index a99cea3f1..09a44ef59 100644 --- a/R/ta_CDLSHOOTINGSTAR.R +++ b/R/ta_CDLSHOOTINGSTAR.R @@ -115,7 +115,12 @@ shooting_star.data.frame <- function( ... ) { map_dfr( - NextMethod() + shooting_star.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ shooting_star.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + shooting_star.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ shooting_star.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ shooting_star.plotly <- function( plotly_object } - #' @usage NULL #' @aliases shooting_star #' @@ -225,7 +235,8 @@ shooting_star.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLSHORTLINE.R b/R/ta_CDLSHORTLINE.R index c5dd4c8bf..4c2d2f5e0 100644 --- a/R/ta_CDLSHORTLINE.R +++ b/R/ta_CDLSHORTLINE.R @@ -115,7 +115,12 @@ short_line.data.frame <- function( ... ) { map_dfr( - NextMethod() + short_line.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ short_line.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + short_line.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ short_line.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ short_line.plotly <- function( plotly_object } - #' @usage NULL #' @aliases short_line #' @@ -225,7 +235,8 @@ short_line.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLSPINNINGTOP.R b/R/ta_CDLSPINNINGTOP.R index cfb3609dd..7ffe08060 100644 --- a/R/ta_CDLSPINNINGTOP.R +++ b/R/ta_CDLSPINNINGTOP.R @@ -115,7 +115,12 @@ spinning_top.data.frame <- function( ... ) { map_dfr( - NextMethod() + spinning_top.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ spinning_top.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + spinning_top.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ spinning_top.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ spinning_top.plotly <- function( plotly_object } - #' @usage NULL #' @aliases spinning_top #' @@ -225,7 +235,8 @@ spinning_top.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLSTALLEDPATTERN.R b/R/ta_CDLSTALLEDPATTERN.R index 472c88d01..063c0845e 100644 --- a/R/ta_CDLSTALLEDPATTERN.R +++ b/R/ta_CDLSTALLEDPATTERN.R @@ -115,7 +115,12 @@ stalled_pattern.data.frame <- function( ... ) { map_dfr( - NextMethod() + stalled_pattern.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ stalled_pattern.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + stalled_pattern.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ stalled_pattern.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ stalled_pattern.plotly <- function( plotly_object } - #' @usage NULL #' @aliases stalled_pattern #' @@ -225,7 +235,8 @@ stalled_pattern.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLSTICKSANDWICH.R b/R/ta_CDLSTICKSANDWICH.R index 75b91ed4c..16f366927 100644 --- a/R/ta_CDLSTICKSANDWICH.R +++ b/R/ta_CDLSTICKSANDWICH.R @@ -115,7 +115,12 @@ stick_sandwich.data.frame <- function( ... ) { map_dfr( - NextMethod() + stick_sandwich.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ stick_sandwich.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + stick_sandwich.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ stick_sandwich.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ stick_sandwich.plotly <- function( plotly_object } - #' @usage NULL #' @aliases stick_sandwich #' @@ -225,7 +235,8 @@ stick_sandwich.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLTAKURI.R b/R/ta_CDLTAKURI.R index da480fd62..11bf822a6 100644 --- a/R/ta_CDLTAKURI.R +++ b/R/ta_CDLTAKURI.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Takuri -#' @templateVar .title Takuri +#' @title Takuri (Dragonfly Doji with very long lower shadow) +#' @templateVar .title Takuri (Dragonfly Doji with very long lower shadow) #' @templateVar .author Serkan Korkmaz #' @templateVar .fun takuri #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ takuri.data.frame <- function( ... ) { map_dfr( - NextMethod() + takuri.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ takuri.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + takuri.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ takuri.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ takuri.plotly <- function( plotly_object } - #' @usage NULL #' @aliases takuri #' @@ -225,7 +235,8 @@ takuri.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLTASUKIGAP.R b/R/ta_CDLTASUKIGAP.R index 5ecd06cad..b8522f466 100644 --- a/R/ta_CDLTASUKIGAP.R +++ b/R/ta_CDLTASUKIGAP.R @@ -115,7 +115,12 @@ tasuki_gap.data.frame <- function( ... ) { map_dfr( - NextMethod() + tasuki_gap.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ tasuki_gap.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + tasuki_gap.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ tasuki_gap.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ tasuki_gap.plotly <- function( plotly_object } - #' @usage NULL #' @aliases tasuki_gap #' @@ -225,7 +235,8 @@ tasuki_gap.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLTHRUSTING.R b/R/ta_CDLTHRUSTING.R index 08b496e3e..a21d99c67 100644 --- a/R/ta_CDLTHRUSTING.R +++ b/R/ta_CDLTHRUSTING.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Thrusting -#' @templateVar .title Thrusting +#' @title Thrusting Pattern +#' @templateVar .title Thrusting Pattern #' @templateVar .author Serkan Korkmaz #' @templateVar .fun thrusting #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ thrusting.data.frame <- function( ... ) { map_dfr( - NextMethod() + thrusting.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ thrusting.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + thrusting.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ thrusting.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ thrusting.plotly <- function( plotly_object } - #' @usage NULL #' @aliases thrusting #' @@ -225,7 +235,8 @@ thrusting.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLTRISTAR.R b/R/ta_CDLTRISTAR.R index fb99feeef..76a5155dd 100644 --- a/R/ta_CDLTRISTAR.R +++ b/R/ta_CDLTRISTAR.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Tristar -#' @templateVar .title Tristar +#' @title Tristar Pattern +#' @templateVar .title Tristar Pattern #' @templateVar .author Serkan Korkmaz #' @templateVar .fun tristar #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ tristar.data.frame <- function( ... ) { map_dfr( - NextMethod() + tristar.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ tristar.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + tristar.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ tristar.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ tristar.plotly <- function( plotly_object } - #' @usage NULL #' @aliases tristar #' @@ -225,7 +235,8 @@ tristar.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLUNIQUE3RIVER.R b/R/ta_CDLUNIQUE3RIVER.R index ee608e3ce..7d800a89f 100644 --- a/R/ta_CDLUNIQUE3RIVER.R +++ b/R/ta_CDLUNIQUE3RIVER.R @@ -1,8 +1,8 @@ #' @export #' @family Pattern Recognition #' -#' @title Unique Three River -#' @templateVar .title Unique Three River +#' @title Unique 3 River +#' @templateVar .title Unique 3 River #' @templateVar .author Serkan Korkmaz #' @templateVar .fun unique_3_river #' @templateVar .family Pattern Recognition @@ -115,7 +115,12 @@ unique_3_river.data.frame <- function( ... ) { map_dfr( - NextMethod() + unique_3_river.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ unique_3_river.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + unique_3_river.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ unique_3_river.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ unique_3_river.plotly <- function( plotly_object } - #' @usage NULL #' @aliases unique_3_river #' @@ -225,7 +235,8 @@ unique_3_river.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLUPSIDEGAP2CROWS.R b/R/ta_CDLUPSIDEGAP2CROWS.R index 977c2b4e0..c87f85b9d 100644 --- a/R/ta_CDLUPSIDEGAP2CROWS.R +++ b/R/ta_CDLUPSIDEGAP2CROWS.R @@ -115,7 +115,12 @@ upside_gap_2_crows.data.frame <- function( ... ) { map_dfr( - NextMethod() + upside_gap_2_crows.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ upside_gap_2_crows.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + upside_gap_2_crows.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ upside_gap_2_crows.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ upside_gap_2_crows.plotly <- function( plotly_object } - #' @usage NULL #' @aliases upside_gap_2_crows #' @@ -225,7 +235,8 @@ upside_gap_2_crows.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CDLXSIDEGAP3METHODS.R b/R/ta_CDLXSIDEGAP3METHODS.R index ee6fa3088..21e11578e 100644 --- a/R/ta_CDLXSIDEGAP3METHODS.R +++ b/R/ta_CDLXSIDEGAP3METHODS.R @@ -115,7 +115,12 @@ xside_gap_3_methods.data.frame <- function( ... ) { map_dfr( - NextMethod() + xside_gap_3_methods.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) ) } @@ -129,7 +134,12 @@ xside_gap_3_methods.matrix <- function( na.bridge = FALSE, ... ) { - NextMethod() + xside_gap_3_methods.default( + x = x, + cols = cols, + na.bridge = na.bridge, + ... + ) } #' @usage NULL @@ -167,7 +177,8 @@ xside_gap_3_methods.plotly <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx @@ -190,7 +201,6 @@ xside_gap_3_methods.plotly <- function( plotly_object } - #' @usage NULL #' @aliases xside_gap_3_methods #' @@ -225,7 +235,8 @@ xside_gap_3_methods.ggplot <- function( x = constructed_series, cols = rebuild_formula( names(constructed_series) - ) + ), + na.bridge = na.bridge ) ## add conditional idx diff --git a/R/ta_CMO.R b/R/ta_CMO.R index 5acfe81e9..21d706834 100644 --- a/R/ta_CMO.R +++ b/R/ta_CMO.R @@ -1,12 +1,12 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Chande Momentum Oscillator #' @templateVar .title Chande Momentum Oscillator #' @templateVar .author Serkan Korkmaz #' @templateVar .fun chande_momentum_oscillator -#' @templateVar .family Momentum Indicator -#' @templateVar .formula ~ close +#' @templateVar .family Momentum Indicators +#' @templateVar .formula ~close #' ## splice:documentation:start ## splice:documentation:end @@ -16,7 +16,7 @@ chande_momentum_oscillator <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ CMO <- chande_momentum_oscillator chande_momentum_oscillator.default <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -64,10 +64,8 @@ chande_momentum_oscillator.default <- function( ## return as data.frame x <- .Call( C_impl_ta_CMO, - ## splice:call:start constructed_series[[1]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -85,7 +83,7 @@ chande_momentum_oscillator.default <- function( chande_momentum_oscillator.data.frame <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -93,7 +91,7 @@ chande_momentum_oscillator.data.frame <- function( chande_momentum_oscillator.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -107,20 +105,32 @@ chande_momentum_oscillator.data.frame <- function( chande_momentum_oscillator.matrix <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { chande_momentum_oscillator.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +chande_momentum_oscillator_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_CMO_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases chande_momentum_oscillator #' @@ -128,7 +138,7 @@ chande_momentum_oscillator.matrix <- function( chande_momentum_oscillator.numeric <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -144,10 +154,8 @@ chande_momentum_oscillator.numeric <- function( ## to 'C' x <- .Call( C_impl_ta_CMO, - ## splice:numeric:start as.double(x), - as.integer(n), - ## splice:numeric:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -158,7 +166,6 @@ chande_momentum_oscillator.numeric <- function( x } - #' @usage NULL #' @aliases chande_momentum_oscillator #' @@ -166,7 +173,7 @@ chande_momentum_oscillator.numeric <- function( chande_momentum_oscillator.plotly <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ## splice:optional-plotly:start lower_bound = -50, @@ -201,7 +208,7 @@ chande_momentum_oscillator.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -219,7 +226,7 @@ chande_momentum_oscillator.plotly <- function( ## construct {plotly}-object ## splice:plotly-assembly:start - name <- sprintf("CMO(%d)", n) + name <- sprintf("CMO(%d)", timePeriod) decorators <- list( function(p) add_limit_ly(p, y_range = c(-100, 100)) @@ -275,11 +282,11 @@ chande_momentum_oscillator.plotly <- function( chande_momentum_oscillator.ggplot <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -307,7 +314,7 @@ chande_momentum_oscillator.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -332,7 +339,7 @@ chande_momentum_oscillator.ggplot <- function( ggplot_line(50), list(y = "CMO") ) - name <- sprintf("CMO(%d)", n) + name <- sprintf("CMO(%d)", timePeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_CORREL.R b/R/ta_CORREL.R index 8ff959924..3af561a26 100644 --- a/R/ta_CORREL.R +++ b/R/ta_CORREL.R @@ -1,8 +1,8 @@ #' @export -#' @family Rolling Statistic +#' @family Statistic Functions #' -#' @title Rolling Correlation -#' @templateVar .title Rolling Correlation +#' @title Pearson's Correlation Coefficient (r) +#' @templateVar .title Pearson's Correlation Coefficient (r) #' @templateVar .author Serkan Korkmaz #' @templateVar .fun rolling_correlation #' @@ -13,8 +13,7 @@ #' @template rolling_returns rolling_correlation <- function( x, - y, - n = 30, + timePeriod = 30, na.bridge = FALSE ) { UseMethod("rolling_correlation") @@ -33,8 +32,7 @@ CORREL <- rolling_correlation #' @export rolling_correlation.default <- function( x, - y, - n = 30, + timePeriod = 30, na.bridge = FALSE ) { ## calculate indicator and @@ -43,8 +41,7 @@ rolling_correlation.default <- function( C_impl_ta_CORREL, ## splice:call:start as.double(x), - as.double(y), - as.integer(n), + as.integer(timePeriod), ## splice:call:end as.logical(na.bridge) ) @@ -64,16 +61,14 @@ rolling_correlation.default <- function( #' @export rolling_correlation.numeric <- function( x, - y, - n = 30, + timePeriod = 30, na.bridge = FALSE ) { ## calculate indicator and ## return as data.frame x <- rolling_correlation.default( x = x, - y = y, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge ) diff --git a/R/ta_DEMA.R b/R/ta_DEMA.R index c992315fc..9e633b227 100644 --- a/R/ta_DEMA.R +++ b/R/ta_DEMA.R @@ -1,11 +1,11 @@ #' @export -#' @family Overlap Study +#' @family Overlap Studies #' #' @title Double Exponential Moving Average #' @templateVar .title Double Exponential Moving Average #' @templateVar .author Serkan Korkmaz #' @templateVar .fun double_exponential_moving_average -#' @templateVar .family Overlap Study +#' @templateVar .family Overlap Studies #' @templateVar .formula ~close #' ## splice:documentation:start @@ -22,7 +22,7 @@ double_exponential_moving_average <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -33,13 +33,18 @@ double_exponential_moving_average <- function( ## from call x <- structure( list( - n = if (missing(n)) 30L else as.integer(n), + timePeriod = if (missing(timePeriod)) { + 30L + } else { + as.integer(timePeriod) + }, maType = 3L ) ) return(x) } + UseMethod("double_exponential_moving_average") } @@ -57,7 +62,7 @@ DEMA <- double_exponential_moving_average double_exponential_moving_average.default <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -84,8 +89,8 @@ double_exponential_moving_average.default <- function( ## return as data.frame x <- .Call( C_impl_ta_DEMA, - as.double(constructed_series[[1]]), - as.integer(n), + constructed_series[[1]], + as.integer(timePeriod), as.logical(na.bridge) ) @@ -103,12 +108,18 @@ double_exponential_moving_average.default <- function( double_exponential_moving_average.data.frame <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { map_dfr( - NextMethod() + double_exponential_moving_average.default( + x = x, + cols = cols, + timePeriod = timePeriod, + na.bridge = na.bridge, + ... + ) ) } @@ -119,17 +130,14 @@ double_exponential_moving_average.data.frame <- function( double_exponential_moving_average.matrix <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { - ## pass directly to - ## double_exponential_moving_average.default to avoid - ## shenanigans with NextMethod() double_exponential_moving_average.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -142,7 +150,7 @@ double_exponential_moving_average.matrix <- function( double_exponential_moving_average.numeric <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -159,7 +167,7 @@ double_exponential_moving_average.numeric <- function( x <- .Call( C_impl_ta_DEMA, as.double(x), - as.integer(n), + as.integer(timePeriod), as.logical(na.bridge) ) @@ -177,7 +185,7 @@ double_exponential_moving_average.numeric <- function( double_exponential_moving_average.plotly <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -207,7 +215,8 @@ double_exponential_moving_average.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n + timePeriod = timePeriod, + na.bridge = TRUE ) ## add conditional idx @@ -230,15 +239,15 @@ double_exponential_moving_average.plotly <- function( ) ) ), - name = label("DEMA", n), - decorators = list() + name = label("DEMA", timePeriod), + decorators = list(), + data = constructed_indicator ) state[["main"]] <- plotly_object plotly_object } - #' @usage NULL #' @aliases double_exponential_moving_average #' @@ -246,7 +255,7 @@ double_exponential_moving_average.plotly <- function( double_exponential_moving_average.ggplot <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -275,7 +284,8 @@ double_exponential_moving_average.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n + timePeriod = timePeriod, + na.bridge = TRUE ) ## add conditional idx @@ -292,7 +302,7 @@ double_exponential_moving_average.ggplot <- function( y = "DEMA" ) ), - name = label("DEMA", n), + name = label("DEMA", timePeriod), decorators = list(), data = constructed_indicator ) diff --git a/R/ta_DX.R b/R/ta_DX.R index 1db4d604a..663b50bb1 100644 --- a/R/ta_DX.R +++ b/R/ta_DX.R @@ -1,11 +1,11 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Directional Movement Index #' @templateVar .title Directional Movement Index #' @templateVar .author Serkan Korkmaz #' @templateVar .fun directional_movement_index -#' @templateVar .family Momentum Indicator +#' @templateVar .family Momentum Indicators #' @templateVar .formula ~high + low + close #' ## splice:documentation:start @@ -16,7 +16,7 @@ directional_movement_index <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ DX <- directional_movement_index directional_movement_index.default <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -64,12 +64,10 @@ directional_movement_index.default <- function( ## return as data.frame x <- .Call( C_impl_ta_DX, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -87,7 +85,7 @@ directional_movement_index.default <- function( directional_movement_index.data.frame <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -95,7 +93,7 @@ directional_movement_index.data.frame <- function( directional_movement_index.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -109,20 +107,32 @@ directional_movement_index.data.frame <- function( directional_movement_index.matrix <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { directional_movement_index.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +directional_movement_index_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_DX_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases directional_movement_index #' @@ -130,7 +140,7 @@ directional_movement_index.matrix <- function( directional_movement_index.plotly <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -163,7 +173,7 @@ directional_movement_index.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -182,7 +192,7 @@ directional_movement_index.plotly <- function( ## splice:plotly-assembly:start name <- sprintf( "DX(%d)", - n + timePeriod ) decorators <- list( @@ -232,11 +242,11 @@ directional_movement_index.plotly <- function( directional_movement_index.ggplot <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -264,7 +274,7 @@ directional_movement_index.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -287,7 +297,7 @@ directional_movement_index.ggplot <- function( layers <- list( list(y = "DX") ) - name <- sprintf("DX(%d)", n) + name <- sprintf("DX(%d)", timePeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_EMA.R b/R/ta_EMA.R index bbef8a6c9..adffb6d18 100644 --- a/R/ta_EMA.R +++ b/R/ta_EMA.R @@ -1,11 +1,11 @@ #' @export -#' @family Overlap Study +#' @family Overlap Studies #' #' @title Exponential Moving Average #' @templateVar .title Exponential Moving Average #' @templateVar .author Serkan Korkmaz #' @templateVar .fun exponential_moving_average -#' @templateVar .family Overlap Study +#' @templateVar .family Overlap Studies #' @templateVar .formula ~close #' ## splice:documentation:start @@ -22,7 +22,7 @@ exponential_moving_average <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -33,13 +33,18 @@ exponential_moving_average <- function( ## from call x <- structure( list( - n = if (missing(n)) 30L else as.integer(n), + timePeriod = if (missing(timePeriod)) { + 30L + } else { + as.integer(timePeriod) + }, maType = 1L ) ) return(x) } + UseMethod("exponential_moving_average") } @@ -57,7 +62,7 @@ EMA <- exponential_moving_average exponential_moving_average.default <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -84,8 +89,8 @@ exponential_moving_average.default <- function( ## return as data.frame x <- .Call( C_impl_ta_EMA, - as.double(constructed_series[[1]]), - as.integer(n), + constructed_series[[1]], + as.integer(timePeriod), as.logical(na.bridge) ) @@ -103,12 +108,18 @@ exponential_moving_average.default <- function( exponential_moving_average.data.frame <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { map_dfr( - NextMethod() + exponential_moving_average.default( + x = x, + cols = cols, + timePeriod = timePeriod, + na.bridge = na.bridge, + ... + ) ) } @@ -119,17 +130,14 @@ exponential_moving_average.data.frame <- function( exponential_moving_average.matrix <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { - ## pass directly to - ## exponential_moving_average.default to avoid - ## shenanigans with NextMethod() exponential_moving_average.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -142,7 +150,7 @@ exponential_moving_average.matrix <- function( exponential_moving_average.numeric <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -159,7 +167,7 @@ exponential_moving_average.numeric <- function( x <- .Call( C_impl_ta_EMA, as.double(x), - as.integer(n), + as.integer(timePeriod), as.logical(na.bridge) ) @@ -177,7 +185,7 @@ exponential_moving_average.numeric <- function( exponential_moving_average.plotly <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -207,7 +215,8 @@ exponential_moving_average.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n + timePeriod = timePeriod, + na.bridge = TRUE ) ## add conditional idx @@ -230,15 +239,15 @@ exponential_moving_average.plotly <- function( ) ) ), - name = label("EMA", n), - decorators = list() + name = label("EMA", timePeriod), + decorators = list(), + data = constructed_indicator ) state[["main"]] <- plotly_object plotly_object } - #' @usage NULL #' @aliases exponential_moving_average #' @@ -246,7 +255,7 @@ exponential_moving_average.plotly <- function( exponential_moving_average.ggplot <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -275,7 +284,8 @@ exponential_moving_average.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n + timePeriod = timePeriod, + na.bridge = TRUE ) ## add conditional idx @@ -292,7 +302,7 @@ exponential_moving_average.ggplot <- function( y = "EMA" ) ), - name = label("EMA", n), + name = label("EMA", timePeriod), decorators = list(), data = constructed_indicator ) diff --git a/R/ta_HT_DCPERIOD.R b/R/ta_HT_DCPERIOD.R index 610582833..13c9796e7 100644 --- a/R/ta_HT_DCPERIOD.R +++ b/R/ta_HT_DCPERIOD.R @@ -1,11 +1,11 @@ #' @export -#' @family Cycle Indicator +#' @family Cycle Indicators #' #' @title Hilbert Transform - Dominant Cycle Period #' @templateVar .title Hilbert Transform - Dominant Cycle Period #' @templateVar .author Serkan Korkmaz #' @templateVar .fun dominant_cycle_period -#' @templateVar .family Cycle Indicator +#' @templateVar .family Cycle Indicators #' @templateVar .formula ~close #' ## splice:documentation:start @@ -62,9 +62,7 @@ dominant_cycle_period.default <- function( ## return as data.frame x <- .Call( C_impl_ta_HT_DCPERIOD, - ## splice:call:start constructed_series[[1]], - ## splice:call:end as.logical(na.bridge) ) @@ -113,7 +111,17 @@ dominant_cycle_period.matrix <- function( ) } - +#' @usage NULL +dominant_cycle_period_lookback <- function( + x, + cols, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_HT_DCPERIOD_lookback + ) +} #' @usage NULL #' @aliases dominant_cycle_period #' @@ -136,9 +144,7 @@ dominant_cycle_period.numeric <- function( ## to 'C' x <- .Call( C_impl_ta_HT_DCPERIOD, - ## splice:numeric:start as.double(x), - ## splice:numeric:end as.logical(na.bridge) ) @@ -149,7 +155,6 @@ dominant_cycle_period.numeric <- function( x } - #' @usage NULL #' @aliases dominant_cycle_period #' @@ -258,9 +263,9 @@ dominant_cycle_period.ggplot <- function( x, cols, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability diff --git a/R/ta_HT_DCPHASE.R b/R/ta_HT_DCPHASE.R index 9ff769ecd..1428acdb1 100644 --- a/R/ta_HT_DCPHASE.R +++ b/R/ta_HT_DCPHASE.R @@ -1,11 +1,11 @@ #' @export -#' @family Cycle Indicator +#' @family Cycle Indicators #' #' @title Hilbert Transform - Dominant Cycle Phase #' @templateVar .title Hilbert Transform - Dominant Cycle Phase #' @templateVar .author Serkan Korkmaz #' @templateVar .fun dominant_cycle_phase -#' @templateVar .family Cycle Indicator +#' @templateVar .family Cycle Indicators #' @templateVar .formula ~close #' ## splice:documentation:start @@ -62,9 +62,7 @@ dominant_cycle_phase.default <- function( ## return as data.frame x <- .Call( C_impl_ta_HT_DCPHASE, - ## splice:call:start constructed_series[[1]], - ## splice:call:end as.logical(na.bridge) ) @@ -113,7 +111,17 @@ dominant_cycle_phase.matrix <- function( ) } - +#' @usage NULL +dominant_cycle_phase_lookback <- function( + x, + cols, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_HT_DCPHASE_lookback + ) +} #' @usage NULL #' @aliases dominant_cycle_phase #' @@ -136,9 +144,7 @@ dominant_cycle_phase.numeric <- function( ## to 'C' x <- .Call( C_impl_ta_HT_DCPHASE, - ## splice:numeric:start as.double(x), - ## splice:numeric:end as.logical(na.bridge) ) @@ -149,7 +155,6 @@ dominant_cycle_phase.numeric <- function( x } - #' @usage NULL #' @aliases dominant_cycle_phase #' @@ -205,7 +210,7 @@ dominant_cycle_phase.plotly <- function( ## construct {plotly}-object ## splice:plotly-assembly:start - name <- sprintf("DCPeriod") + name <- "DCPhase" decorators <- list() @@ -258,9 +263,9 @@ dominant_cycle_phase.ggplot <- function( x, cols, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability diff --git a/R/ta_HT_PHASOR.R b/R/ta_HT_PHASOR.R index 2a0ad0f3f..877e94761 100644 --- a/R/ta_HT_PHASOR.R +++ b/R/ta_HT_PHASOR.R @@ -1,11 +1,11 @@ #' @export -#' @family Cycle Indicator +#' @family Cycle Indicators #' #' @title Hilbert Transform - Phasor Components #' @templateVar .title Hilbert Transform - Phasor Components #' @templateVar .author Serkan Korkmaz #' @templateVar .fun phasor_components -#' @templateVar .family Cycle Indicator +#' @templateVar .family Cycle Indicators #' @templateVar .formula ~close #' ## splice:documentation:start @@ -62,9 +62,7 @@ phasor_components.default <- function( ## return as data.frame x <- .Call( C_impl_ta_HT_PHASOR, - ## splice:call:start constructed_series[[1]], - ## splice:call:end as.logical(na.bridge) ) @@ -113,7 +111,17 @@ phasor_components.matrix <- function( ) } - +#' @usage NULL +phasor_components_lookback <- function( + x, + cols, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_HT_PHASOR_lookback + ) +} #' @usage NULL #' @aliases phasor_components #' @@ -136,9 +144,7 @@ phasor_components.numeric <- function( ## to 'C' x <- .Call( C_impl_ta_HT_PHASOR, - ## splice:numeric:start as.double(x), - ## splice:numeric:end as.logical(na.bridge) ) @@ -149,7 +155,6 @@ phasor_components.numeric <- function( x } - #' @usage NULL #' @aliases phasor_components #' @@ -266,9 +271,9 @@ phasor_components.ggplot <- function( x, cols, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability diff --git a/R/ta_HT_SINE.R b/R/ta_HT_SINE.R index 6e821b0ef..4eac57d90 100644 --- a/R/ta_HT_SINE.R +++ b/R/ta_HT_SINE.R @@ -1,11 +1,11 @@ #' @export -#' @family Cycle Indicator +#' @family Cycle Indicators #' #' @title Hilbert Transform - SineWave #' @templateVar .title Hilbert Transform - SineWave #' @templateVar .author Serkan Korkmaz #' @templateVar .fun sine_wave -#' @templateVar .family Cycle Indicator +#' @templateVar .family Cycle Indicators #' @templateVar .formula ~close #' ## splice:documentation:start @@ -62,9 +62,7 @@ sine_wave.default <- function( ## return as data.frame x <- .Call( C_impl_ta_HT_SINE, - ## splice:call:start constructed_series[[1]], - ## splice:call:end as.logical(na.bridge) ) @@ -113,7 +111,17 @@ sine_wave.matrix <- function( ) } - +#' @usage NULL +sine_wave_lookback <- function( + x, + cols, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_HT_SINE_lookback + ) +} #' @usage NULL #' @aliases sine_wave #' @@ -136,9 +144,7 @@ sine_wave.numeric <- function( ## to 'C' x <- .Call( C_impl_ta_HT_SINE, - ## splice:numeric:start as.double(x), - ## splice:numeric:end as.logical(na.bridge) ) @@ -149,7 +155,6 @@ sine_wave.numeric <- function( x } - #' @usage NULL #' @aliases sine_wave #' @@ -264,9 +269,9 @@ sine_wave.ggplot <- function( x, cols, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability diff --git a/R/ta_HT_TRENDLINE.R b/R/ta_HT_TRENDLINE.R index 33d308fab..43f7e06b4 100644 --- a/R/ta_HT_TRENDLINE.R +++ b/R/ta_HT_TRENDLINE.R @@ -1,11 +1,11 @@ #' @export -#' @family Overlap Study +#' @family Overlap Studies #' #' @title Hilbert Transform - Instantaneous Trendline #' @templateVar .title Hilbert Transform - Instantaneous Trendline #' @templateVar .author Serkan Korkmaz #' @templateVar .fun trendline -#' @templateVar .family Overlap Study +#' @templateVar .family Overlap Studies #' @templateVar .formula ~close #' ## splice:documentation:start @@ -62,9 +62,7 @@ trendline.default <- function( ## return as data.frame x <- .Call( C_impl_ta_HT_TRENDLINE, - ## splice:call:start constructed_series[[1]], - ## splice:call:end as.logical(na.bridge) ) @@ -113,7 +111,17 @@ trendline.matrix <- function( ) } - +#' @usage NULL +trendline_lookback <- function( + x, + cols, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_HT_TRENDLINE_lookback + ) +} #' @usage NULL #' @aliases trendline #' @@ -136,9 +144,7 @@ trendline.numeric <- function( ## to 'C' x <- .Call( C_impl_ta_HT_TRENDLINE, - ## splice:numeric:start as.double(x), - ## splice:numeric:end as.logical(na.bridge) ) @@ -149,7 +155,6 @@ trendline.numeric <- function( x } - #' @usage NULL #' @aliases trendline #' diff --git a/R/ta_HT_TRENDMODE.R b/R/ta_HT_TRENDMODE.R index 522cd1d8f..70942acde 100644 --- a/R/ta_HT_TRENDMODE.R +++ b/R/ta_HT_TRENDMODE.R @@ -1,11 +1,11 @@ #' @export -#' @family Cycle Indicator +#' @family Cycle Indicators #' #' @title Hilbert Transform - Trend vs Cycle Mode #' @templateVar .title Hilbert Transform - Trend vs Cycle Mode #' @templateVar .author Serkan Korkmaz #' @templateVar .fun trend_cycle_mode -#' @templateVar .family Cycle Indicator +#' @templateVar .family Cycle Indicators #' @templateVar .formula ~close #' ## splice:documentation:start @@ -62,9 +62,7 @@ trend_cycle_mode.default <- function( ## return as data.frame x <- .Call( C_impl_ta_HT_TRENDMODE, - ## splice:call:start constructed_series[[1]], - ## splice:call:end as.logical(na.bridge) ) @@ -113,7 +111,17 @@ trend_cycle_mode.matrix <- function( ) } - +#' @usage NULL +trend_cycle_mode_lookback <- function( + x, + cols, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_HT_TRENDMODE_lookback + ) +} #' @usage NULL #' @aliases trend_cycle_mode #' @@ -136,9 +144,7 @@ trend_cycle_mode.numeric <- function( ## to 'C' x <- .Call( C_impl_ta_HT_TRENDMODE, - ## splice:numeric:start as.double(x), - ## splice:numeric:end as.logical(na.bridge) ) @@ -149,7 +155,6 @@ trend_cycle_mode.numeric <- function( x } - #' @usage NULL #' @aliases trend_cycle_mode #' @@ -257,9 +262,9 @@ trend_cycle_mode.ggplot <- function( x, cols, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability diff --git a/R/ta_IMI.R b/R/ta_IMI.R index 753987df7..2d800921d 100644 --- a/R/ta_IMI.R +++ b/R/ta_IMI.R @@ -1,11 +1,11 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' -#' @title Intraday Movement Index -#' @templateVar .title Intraday Movement Index +#' @title Intraday Momentum Index +#' @templateVar .title Intraday Momentum Index #' @templateVar .author Serkan Korkmaz #' @templateVar .fun intraday_movement_index -#' @templateVar .family Momentum Indicator +#' @templateVar .family Momentum Indicators #' @templateVar .formula ~open + close #' ## splice:documentation:start @@ -16,7 +16,7 @@ intraday_movement_index <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ IMI <- intraday_movement_index intraday_movement_index.default <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -64,11 +64,9 @@ intraday_movement_index.default <- function( ## return as data.frame x <- .Call( C_impl_ta_IMI, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -86,7 +84,7 @@ intraday_movement_index.default <- function( intraday_movement_index.data.frame <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -94,7 +92,7 @@ intraday_movement_index.data.frame <- function( intraday_movement_index.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -108,20 +106,32 @@ intraday_movement_index.data.frame <- function( intraday_movement_index.matrix <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { intraday_movement_index.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +intraday_movement_index_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_IMI_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases intraday_movement_index #' @@ -129,7 +139,7 @@ intraday_movement_index.matrix <- function( intraday_movement_index.plotly <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -162,7 +172,7 @@ intraday_movement_index.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -181,7 +191,7 @@ intraday_movement_index.plotly <- function( ## splice:plotly-assembly:start name <- sprintf( "IMI(%d)", - n + timePeriod ) decorators <- list() @@ -205,7 +215,7 @@ intraday_movement_index.plotly <- function( ), data = constructed_indicator, title = if (missing(title)) { - "Intraday Movement Index" + "Intraday Momentum Index" } else { title } @@ -227,11 +237,11 @@ intraday_movement_index.plotly <- function( intraday_movement_index.ggplot <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -259,7 +269,7 @@ intraday_movement_index.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -282,7 +292,7 @@ intraday_movement_index.ggplot <- function( layers <- list( list(y = "IMI") ) - name <- sprintf("IMI(%d)", n) + name <- sprintf("IMI(%d)", timePeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( @@ -299,7 +309,7 @@ intraday_movement_index.ggplot <- function( ), data = constructed_indicator, title = if (missing(title)) { - "Intraday Movement Index" + "Intraday Momentum Index" } else { title } diff --git a/R/ta_KAMA.R b/R/ta_KAMA.R index 927e1ded1..8d244a2cd 100644 --- a/R/ta_KAMA.R +++ b/R/ta_KAMA.R @@ -1,11 +1,11 @@ #' @export -#' @family Overlap Study +#' @family Overlap Studies #' #' @title Kaufman Adaptive Moving Average #' @templateVar .title Kaufman Adaptive Moving Average #' @templateVar .author Serkan Korkmaz #' @templateVar .fun kaufman_adaptive_moving_average -#' @templateVar .family Overlap Study +#' @templateVar .family Overlap Studies #' @templateVar .formula ~close #' ## splice:documentation:start @@ -22,7 +22,7 @@ kaufman_adaptive_moving_average <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -33,13 +33,18 @@ kaufman_adaptive_moving_average <- function( ## from call x <- structure( list( - n = if (missing(n)) 30L else as.integer(n), + timePeriod = if (missing(timePeriod)) { + 30L + } else { + as.integer(timePeriod) + }, maType = 6L ) ) return(x) } + UseMethod("kaufman_adaptive_moving_average") } @@ -57,7 +62,7 @@ KAMA <- kaufman_adaptive_moving_average kaufman_adaptive_moving_average.default <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -84,8 +89,8 @@ kaufman_adaptive_moving_average.default <- function( ## return as data.frame x <- .Call( C_impl_ta_KAMA, - as.double(constructed_series[[1]]), - as.integer(n), + constructed_series[[1]], + as.integer(timePeriod), as.logical(na.bridge) ) @@ -103,12 +108,18 @@ kaufman_adaptive_moving_average.default <- function( kaufman_adaptive_moving_average.data.frame <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { map_dfr( - NextMethod() + kaufman_adaptive_moving_average.default( + x = x, + cols = cols, + timePeriod = timePeriod, + na.bridge = na.bridge, + ... + ) ) } @@ -119,17 +130,14 @@ kaufman_adaptive_moving_average.data.frame <- function( kaufman_adaptive_moving_average.matrix <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { - ## pass directly to - ## kaufman_adaptive_moving_average.default to avoid - ## shenanigans with NextMethod() kaufman_adaptive_moving_average.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -142,7 +150,7 @@ kaufman_adaptive_moving_average.matrix <- function( kaufman_adaptive_moving_average.numeric <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -159,7 +167,7 @@ kaufman_adaptive_moving_average.numeric <- function( x <- .Call( C_impl_ta_KAMA, as.double(x), - as.integer(n), + as.integer(timePeriod), as.logical(na.bridge) ) @@ -177,7 +185,7 @@ kaufman_adaptive_moving_average.numeric <- function( kaufman_adaptive_moving_average.plotly <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -207,7 +215,8 @@ kaufman_adaptive_moving_average.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n + timePeriod = timePeriod, + na.bridge = TRUE ) ## add conditional idx @@ -230,15 +239,15 @@ kaufman_adaptive_moving_average.plotly <- function( ) ) ), - name = label("KAMA", n), - decorators = list() + name = label("KAMA", timePeriod), + decorators = list(), + data = constructed_indicator ) state[["main"]] <- plotly_object plotly_object } - #' @usage NULL #' @aliases kaufman_adaptive_moving_average #' @@ -246,7 +255,7 @@ kaufman_adaptive_moving_average.plotly <- function( kaufman_adaptive_moving_average.ggplot <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -275,7 +284,8 @@ kaufman_adaptive_moving_average.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n + timePeriod = timePeriod, + na.bridge = TRUE ) ## add conditional idx @@ -292,7 +302,7 @@ kaufman_adaptive_moving_average.ggplot <- function( y = "KAMA" ) ), - name = label("KAMA", n), + name = label("KAMA", timePeriod), decorators = list(), data = constructed_indicator ) diff --git a/R/ta_MACD.R b/R/ta_MACD.R index 538d7639c..0655ba9a2 100644 --- a/R/ta_MACD.R +++ b/R/ta_MACD.R @@ -1,17 +1,14 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' -#' @title Moving Average Convergence Divergence -#' @templateVar .title Moving Average Convergence Divergence +#' @title Moving Average Convergence/Divergence +#' @templateVar .title Moving Average Convergence/Divergence #' @templateVar .author Serkan Korkmaz #' @templateVar .fun moving_average_convergence_divergence -#' @templateVar .family Momentum Indicator +#' @templateVar .family Momentum Indicators #' @templateVar .formula ~close #' ## splice:documentation:start -#' @param fast ([integer]). Period for the fast Moving Average (MA). -#' @param slow ([integer]). Period for the slow Moving Average (MA). -#' @param signal ([integer]). Period for the signal Moving Average (MA). ## splice:documentation:end #' #' @template description @@ -19,9 +16,9 @@ moving_average_convergence_divergence <- function( x, cols, - fast = 12, - slow = 26, - signal = 9, + fastPeriod = 12, + slowPeriod = 26, + signalPeriod = 9, na.bridge = FALSE, ... ) { @@ -42,9 +39,9 @@ MACD <- moving_average_convergence_divergence moving_average_convergence_divergence.default <- function( x, cols, - fast = 12, - slow = 26, - signal = 9, + fastPeriod = 12, + slowPeriod = 26, + signalPeriod = 9, na.bridge = FALSE, ... ) { @@ -71,12 +68,10 @@ moving_average_convergence_divergence.default <- function( ## return as data.frame x <- .Call( C_impl_ta_MACD, - ## splice:call:start constructed_series[[1]], - as.integer(fast), - as.integer(slow), - as.integer(signal), - ## splice:call:end + as.integer(fastPeriod), + as.integer(slowPeriod), + as.integer(signalPeriod), as.logical(na.bridge) ) @@ -94,9 +89,9 @@ moving_average_convergence_divergence.default <- function( moving_average_convergence_divergence.data.frame <- function( x, cols, - fast = 12, - slow = 26, - signal = 9, + fastPeriod = 12, + slowPeriod = 26, + signalPeriod = 9, na.bridge = FALSE, ... ) { @@ -104,9 +99,9 @@ moving_average_convergence_divergence.data.frame <- function( moving_average_convergence_divergence.default( x = x, cols = cols, - fast = fast, - slow = slow, - signal = signal, + fastPeriod = fastPeriod, + slowPeriod = slowPeriod, + signalPeriod = signalPeriod, na.bridge = na.bridge, ... ) @@ -120,24 +115,40 @@ moving_average_convergence_divergence.data.frame <- function( moving_average_convergence_divergence.matrix <- function( x, cols, - fast = 12, - slow = 26, - signal = 9, + fastPeriod = 12, + slowPeriod = 26, + signalPeriod = 9, na.bridge = FALSE, ... ) { moving_average_convergence_divergence.default( x = x, cols = cols, - fast = fast, - slow = slow, - signal = signal, + fastPeriod = fastPeriod, + slowPeriod = slowPeriod, + signalPeriod = signalPeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +moving_average_convergence_divergence_lookback <- function( + x, + cols, + fastPeriod = 12, + slowPeriod = 26, + signalPeriod = 9, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_MACD_lookback, + as.integer(fastPeriod), + as.integer(slowPeriod), + as.integer(signalPeriod) + ) +} #' @usage NULL #' @aliases moving_average_convergence_divergence #' @@ -145,9 +156,9 @@ moving_average_convergence_divergence.matrix <- function( moving_average_convergence_divergence.numeric <- function( x, cols, - fast = 12, - slow = 26, - signal = 9, + fastPeriod = 12, + slowPeriod = 26, + signalPeriod = 9, na.bridge = FALSE, ... ) { @@ -163,12 +174,10 @@ moving_average_convergence_divergence.numeric <- function( ## to 'C' x <- .Call( C_impl_ta_MACD, - ## splice:numeric:start as.double(x), - as.integer(fast), - as.integer(slow), - as.integer(signal), - ## splice:numeric:end + as.integer(fastPeriod), + as.integer(slowPeriod), + as.integer(signalPeriod), as.logical(na.bridge) ) @@ -179,7 +188,6 @@ moving_average_convergence_divergence.numeric <- function( x } - #' @usage NULL #' @aliases moving_average_convergence_divergence #' @@ -187,9 +195,9 @@ moving_average_convergence_divergence.numeric <- function( moving_average_convergence_divergence.plotly <- function( x, cols, - fast = 12, - slow = 26, - signal = 9, + fastPeriod = 12, + slowPeriod = 26, + signalPeriod = 9, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -222,9 +230,9 @@ moving_average_convergence_divergence.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - fast = fast, - slow = slow, - signal = signal, + fastPeriod = fastPeriod, + slowPeriod = slowPeriod, + signalPeriod = signalPeriod, na.bridge = TRUE ) @@ -249,9 +257,9 @@ moving_average_convergence_divergence.plotly <- function( ## construct plotly object name <- sprintf( "MACD(%d, %d, %d)", - fast, - slow, - signal + fastPeriod, + slowPeriod, + signalPeriod ) traces <- list( @@ -271,7 +279,7 @@ moving_average_convergence_divergence.plotly <- function( inherit = FALSE, name = sprintf( fmt = "Signal(%d)", - if (is.list(signal)) signal$n else signal + signalPeriod ) ), list( @@ -279,8 +287,8 @@ moving_average_convergence_divergence.plotly <- function( inherit = FALSE, name = sprintf( fmt = "MACD(%d, %d)", - if (is.list(fast)) fast$n else fast, - if (is.list(slow)) slow$n else slow + fastPeriod, + slowPeriod ) ) ) @@ -300,7 +308,7 @@ moving_average_convergence_divergence.plotly <- function( ), data = constructed_indicator, title = if (missing(title)) { - "Moving Average Convergence Divergence" + "Moving Average Convergence/Divergence" } else { title } @@ -322,13 +330,13 @@ moving_average_convergence_divergence.plotly <- function( moving_average_convergence_divergence.ggplot <- function( x, cols, - fast = 12, - slow = 26, - signal = 9, + fastPeriod = 12, + slowPeriod = 26, + signalPeriod = 9, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -356,9 +364,9 @@ moving_average_convergence_divergence.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - fast = fast, - slow = slow, - signal = signal, + fastPeriod = fastPeriod, + slowPeriod = slowPeriod, + signalPeriod = signalPeriod, na.bridge = TRUE ) @@ -375,6 +383,8 @@ moving_average_convergence_divergence.ggplot <- function( ## construct {ggplot2}-object ## splice:ggplot-assembly:start + ## calculate directions for bull + ## and bear candles constructed_indicator$direction <- constructed_indicator$MACDSignal >= constructed_indicator$MACD layers <- list( @@ -387,10 +397,10 @@ moving_average_convergence_divergence.ggplot <- function( .chart_variables$bearish_body ) ), - list(y = "MACDSignal", name = sprintf("Signal(%d)", signal)), - list(y = "MACD", name = sprintf("MACD(%d, %d)", fast, slow)) + list(y = "MACDSignal", name = sprintf("Signal(%d)", signalPeriod)), + list(y = "MACD", name = sprintf("MACD(%d, %d)", fastPeriod, slowPeriod)) ) - name <- sprintf("MACD(%d, %d, %d)", fast, slow, signal) + name <- sprintf("MACD(%d, %d, %d)", fastPeriod, slowPeriod, signalPeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( @@ -407,7 +417,7 @@ moving_average_convergence_divergence.ggplot <- function( ), data = constructed_indicator, title = if (missing(title)) { - "Moving Average Convergence Divergence" + "Moving Average Convergence/Divergence" } else { title } diff --git a/R/ta_MACDEXT.R b/R/ta_MACDEXT.R index da7d543b4..f022e3695 100644 --- a/R/ta_MACDEXT.R +++ b/R/ta_MACDEXT.R @@ -1,17 +1,14 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' -#' @title Moving Average Convergence Divergence (Extended) -#' @templateVar .title Moving Average Convergence Divergence (Extended) +#' @title MACD with controllable MA type +#' @templateVar .title MACD with controllable MA type #' @templateVar .author Serkan Korkmaz #' @templateVar .fun extended_moving_average_convergence_divergence -#' @templateVar .family Momentum Indicator +#' @templateVar .family Momentum Indicators #' @templateVar .formula ~close #' ## splice:documentation:start -#' @param fast ([list]). Period and Moving Average (MA) type for the fast MA. [EMA] by default. -#' @param slow ([list]). Period and Moving Average (MA) type for the slow MA. [EMA] by default. -#' @param signal ([list]). Period and Moving Average (MA) type for the signal MA. [EMA] by default. ## splice:documentation:end #' #' @template description @@ -19,9 +16,12 @@ extended_moving_average_convergence_divergence <- function( x, cols, - fast = SMA(n = 12), - slow = SMA(n = 26), - signal = SMA(n = 9), + fastPeriod = 12, + fastMa = 0, + slowPeriod = 26, + slowMa = 0, + signalPeriod = 9, + signalMa = 0, na.bridge = FALSE, ... ) { @@ -42,9 +42,12 @@ MACDEXT <- extended_moving_average_convergence_divergence extended_moving_average_convergence_divergence.default <- function( x, cols, - fast = SMA(n = 12), - slow = SMA(n = 26), - signal = SMA(n = 9), + fastPeriod = 12, + fastMa = 0, + slowPeriod = 26, + slowMa = 0, + signalPeriod = 9, + signalMa = 0, na.bridge = FALSE, ... ) { @@ -71,15 +74,13 @@ extended_moving_average_convergence_divergence.default <- function( ## return as data.frame x <- .Call( C_impl_ta_MACDEXT, - ## splice:call:start constructed_series[[1]], - fast$n, - fast$maType, - slow$n, - slow$maType, - signal$n, - signal$maType, - ## splice:call:end + as.integer(fastPeriod), + as.integer(fastMa), + as.integer(slowPeriod), + as.integer(slowMa), + as.integer(signalPeriod), + as.integer(signalMa), as.logical(na.bridge) ) @@ -97,9 +98,12 @@ extended_moving_average_convergence_divergence.default <- function( extended_moving_average_convergence_divergence.data.frame <- function( x, cols, - fast = SMA(n = 12), - slow = SMA(n = 26), - signal = SMA(n = 9), + fastPeriod = 12, + fastMa = 0, + slowPeriod = 26, + slowMa = 0, + signalPeriod = 9, + signalMa = 0, na.bridge = FALSE, ... ) { @@ -107,9 +111,12 @@ extended_moving_average_convergence_divergence.data.frame <- function( extended_moving_average_convergence_divergence.default( x = x, cols = cols, - fast = fast, - slow = slow, - signal = signal, + fastPeriod = fastPeriod, + fastMa = fastMa, + slowPeriod = slowPeriod, + slowMa = slowMa, + signalPeriod = signalPeriod, + signalMa = signalMa, na.bridge = na.bridge, ... ) @@ -123,24 +130,52 @@ extended_moving_average_convergence_divergence.data.frame <- function( extended_moving_average_convergence_divergence.matrix <- function( x, cols, - fast = SMA(n = 12), - slow = SMA(n = 26), - signal = SMA(n = 9), + fastPeriod = 12, + fastMa = 0, + slowPeriod = 26, + slowMa = 0, + signalPeriod = 9, + signalMa = 0, na.bridge = FALSE, ... ) { extended_moving_average_convergence_divergence.default( x = x, cols = cols, - fast = fast, - slow = slow, - signal = signal, + fastPeriod = fastPeriod, + fastMa = fastMa, + slowPeriod = slowPeriod, + slowMa = slowMa, + signalPeriod = signalPeriod, + signalMa = signalMa, na.bridge = na.bridge, ... ) } - +#' @usage NULL +extended_moving_average_convergence_divergence_lookback <- function( + x, + cols, + fastPeriod = 12, + fastMa = 0, + slowPeriod = 26, + slowMa = 0, + signalPeriod = 9, + signalMa = 0, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_MACDEXT_lookback, + as.integer(fastPeriod), + as.integer(fastMa), + as.integer(slowPeriod), + as.integer(slowMa), + as.integer(signalPeriod), + as.integer(signalMa) + ) +} #' @usage NULL #' @aliases extended_moving_average_convergence_divergence #' @@ -148,9 +183,12 @@ extended_moving_average_convergence_divergence.matrix <- function( extended_moving_average_convergence_divergence.numeric <- function( x, cols, - fast = SMA(n = 12), - slow = SMA(n = 26), - signal = SMA(n = 9), + fastPeriod = 12, + fastMa = 0, + slowPeriod = 26, + slowMa = 0, + signalPeriod = 9, + signalMa = 0, na.bridge = FALSE, ... ) { @@ -166,15 +204,13 @@ extended_moving_average_convergence_divergence.numeric <- function( ## to 'C' x <- .Call( C_impl_ta_MACDEXT, - ## splice:numeric:start as.double(x), - fast$n, - fast$maType, - slow$n, - slow$maType, - signal$n, - signal$maType, - ## splice:numeric:end + as.integer(fastPeriod), + as.integer(fastMa), + as.integer(slowPeriod), + as.integer(slowMa), + as.integer(signalPeriod), + as.integer(signalMa), as.logical(na.bridge) ) @@ -185,7 +221,6 @@ extended_moving_average_convergence_divergence.numeric <- function( x } - #' @usage NULL #' @aliases extended_moving_average_convergence_divergence #' @@ -193,9 +228,12 @@ extended_moving_average_convergence_divergence.numeric <- function( extended_moving_average_convergence_divergence.plotly <- function( x, cols, - fast = SMA(n = 12), - slow = SMA(n = 26), - signal = SMA(n = 9), + fastPeriod = 12, + fastMa = 0, + slowPeriod = 26, + slowMa = 0, + signalPeriod = 9, + signalMa = 0, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -228,9 +266,12 @@ extended_moving_average_convergence_divergence.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - fast = fast, - slow = slow, - signal = signal, + fastPeriod = fastPeriod, + fastMa = fastMa, + slowPeriod = slowPeriod, + slowMa = slowMa, + signalPeriod = signalPeriod, + signalMa = signalMa, na.bridge = TRUE ) @@ -255,9 +296,9 @@ extended_moving_average_convergence_divergence.plotly <- function( ## construct plotly object name <- sprintf( "MACD(%d, %d, %d)", - if (is.list(fast)) fast$n else fast, - if (is.list(slow)) slow$n else slow, - if (is.list(signal)) signal$n else signal + fastPeriod, + slowPeriod, + signalPeriod ) traces <- list( @@ -277,7 +318,7 @@ extended_moving_average_convergence_divergence.plotly <- function( inherit = FALSE, name = sprintf( fmt = "Signal(%d)", - if (is.list(signal)) signal$n else signal + signalPeriod ) ), list( @@ -285,8 +326,8 @@ extended_moving_average_convergence_divergence.plotly <- function( inherit = FALSE, name = sprintf( fmt = "MACD(%d, %d)", - if (is.list(fast)) fast$n else fast, - if (is.list(slow)) slow$n else slow + fastPeriod, + slowPeriod ) ) ) @@ -306,7 +347,7 @@ extended_moving_average_convergence_divergence.plotly <- function( ), data = constructed_indicator, title = if (missing(title)) { - "Moving Average Convergence Divergence (Extended)" + "MACD with controllable MA type" } else { title } @@ -328,13 +369,16 @@ extended_moving_average_convergence_divergence.plotly <- function( extended_moving_average_convergence_divergence.ggplot <- function( x, cols, - fast = SMA(n = 12), - slow = SMA(n = 26), - signal = SMA(n = 9), + fastPeriod = 12, + fastMa = 0, + slowPeriod = 26, + slowMa = 0, + signalPeriod = 9, + signalMa = 0, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -362,9 +406,12 @@ extended_moving_average_convergence_divergence.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - fast = fast, - slow = slow, - signal = signal, + fastPeriod = fastPeriod, + fastMa = fastMa, + slowPeriod = slowPeriod, + slowMa = slowMa, + signalPeriod = signalPeriod, + signalMa = signalMa, na.bridge = TRUE ) @@ -381,6 +428,8 @@ extended_moving_average_convergence_divergence.ggplot <- function( ## construct {ggplot2}-object ## splice:ggplot-assembly:start + ## calculate directions for bull + ## and bear candles constructed_indicator$direction <- constructed_indicator$MACDSignal >= constructed_indicator$MACD layers <- list( @@ -393,28 +442,10 @@ extended_moving_average_convergence_divergence.ggplot <- function( .chart_variables$bearish_body ) ), - list( - y = "MACDSignal", - name = sprintf( - "Signal(%d)", - if (is.list(signal)) signal$n else signal - ) - ), - list( - y = "MACD", - name = sprintf( - "MACD(%d, %d)", - if (is.list(fast)) fast$n else fast, - if (is.list(slow)) slow$n else slow - ) - ) - ) - name <- sprintf( - "MACD(%d, %d, %d)", - if (is.list(fast)) fast$n else fast, - if (is.list(slow)) slow$n else slow, - if (is.list(signal)) signal$n else signal + list(y = "MACDSignal", name = sprintf("Signal(%d)", signalPeriod)), + list(y = "MACD", name = sprintf("MACD(%d, %d)", fastPeriod, slowPeriod)) ) + name <- sprintf("MACD(%d, %d, %d)", fastPeriod, slowPeriod, signalPeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( @@ -431,7 +462,7 @@ extended_moving_average_convergence_divergence.ggplot <- function( ), data = constructed_indicator, title = if (missing(title)) { - "Moving Average Convergence Divergence (Extended)" + "MACD with controllable MA type" } else { title } diff --git a/R/ta_MACDFIX.R b/R/ta_MACDFIX.R index 3db61d57b..43b4f9286 100644 --- a/R/ta_MACDFIX.R +++ b/R/ta_MACDFIX.R @@ -1,15 +1,14 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' -#' @title Moving Average Convergence Divergence (Fixed) -#' @templateVar .title Moving Average Convergence Divergence (Fixed) +#' @title Moving Average Convergence/Divergence Fix 12/26 +#' @templateVar .title Moving Average Convergence/Divergence Fix 12/26 #' @templateVar .author Serkan Korkmaz #' @templateVar .fun fixed_moving_average_convergence_divergence -#' @templateVar .family Momentum Indicator +#' @templateVar .family Momentum Indicators #' @templateVar .formula ~close #' ## splice:documentation:start -#' @param signal ([integer]). Period for the signal Moving Average (MA). ## splice:documentation:end #' #' @template description @@ -17,7 +16,7 @@ fixed_moving_average_convergence_divergence <- function( x, cols, - signal = 9, + signalPeriod = 9, na.bridge = FALSE, ... ) { @@ -38,7 +37,7 @@ MACDFIX <- fixed_moving_average_convergence_divergence fixed_moving_average_convergence_divergence.default <- function( x, cols, - signal = 9, + signalPeriod = 9, na.bridge = FALSE, ... ) { @@ -65,10 +64,8 @@ fixed_moving_average_convergence_divergence.default <- function( ## return as data.frame x <- .Call( C_impl_ta_MACDFIX, - ## splice:call:start constructed_series[[1]], - as.integer(signal), - ## splice:call:end + as.integer(signalPeriod), as.logical(na.bridge) ) @@ -86,7 +83,7 @@ fixed_moving_average_convergence_divergence.default <- function( fixed_moving_average_convergence_divergence.data.frame <- function( x, cols, - signal = 9, + signalPeriod = 9, na.bridge = FALSE, ... ) { @@ -94,7 +91,7 @@ fixed_moving_average_convergence_divergence.data.frame <- function( fixed_moving_average_convergence_divergence.default( x = x, cols = cols, - signal = signal, + signalPeriod = signalPeriod, na.bridge = na.bridge, ... ) @@ -108,20 +105,32 @@ fixed_moving_average_convergence_divergence.data.frame <- function( fixed_moving_average_convergence_divergence.matrix <- function( x, cols, - signal = 9, + signalPeriod = 9, na.bridge = FALSE, ... ) { fixed_moving_average_convergence_divergence.default( x = x, cols = cols, - signal = signal, + signalPeriod = signalPeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +fixed_moving_average_convergence_divergence_lookback <- function( + x, + cols, + signalPeriod = 9, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_MACDFIX_lookback, + as.integer(signalPeriod) + ) +} #' @usage NULL #' @aliases fixed_moving_average_convergence_divergence #' @@ -129,7 +138,7 @@ fixed_moving_average_convergence_divergence.matrix <- function( fixed_moving_average_convergence_divergence.numeric <- function( x, cols, - signal = 9, + signalPeriod = 9, na.bridge = FALSE, ... ) { @@ -145,10 +154,8 @@ fixed_moving_average_convergence_divergence.numeric <- function( ## to 'C' x <- .Call( C_impl_ta_MACDFIX, - ## splice:numeric:start as.double(x), - as.integer(signal), - ## splice:numeric:end + as.integer(signalPeriod), as.logical(na.bridge) ) @@ -159,7 +166,6 @@ fixed_moving_average_convergence_divergence.numeric <- function( x } - #' @usage NULL #' @aliases fixed_moving_average_convergence_divergence #' @@ -167,7 +173,7 @@ fixed_moving_average_convergence_divergence.numeric <- function( fixed_moving_average_convergence_divergence.plotly <- function( x, cols, - signal = 9, + signalPeriod = 9, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -200,7 +206,7 @@ fixed_moving_average_convergence_divergence.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - signal = signal, + signalPeriod = signalPeriod, na.bridge = TRUE ) @@ -225,7 +231,7 @@ fixed_moving_average_convergence_divergence.plotly <- function( ## construct plotly object name <- sprintf( "MACD(%d)", - if (is.list(signal)) signal$n else signal + signalPeriod ) traces <- list( @@ -245,7 +251,7 @@ fixed_moving_average_convergence_divergence.plotly <- function( inherit = FALSE, name = sprintf( fmt = "Signal(%d)", - if (is.list(signal)) signal$n else signal + signalPeriod ) ), list( @@ -274,7 +280,7 @@ fixed_moving_average_convergence_divergence.plotly <- function( ), data = constructed_indicator, title = if (missing(title)) { - "Moving Average Convergence Divergence (Fixed)" + "Moving Average Convergence/Divergence Fix 12/26" } else { title } @@ -296,11 +302,11 @@ fixed_moving_average_convergence_divergence.plotly <- function( fixed_moving_average_convergence_divergence.ggplot <- function( x, cols, - signal = 9, + signalPeriod = 9, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -328,7 +334,7 @@ fixed_moving_average_convergence_divergence.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - signal = signal, + signalPeriod = signalPeriod, na.bridge = TRUE ) @@ -345,6 +351,8 @@ fixed_moving_average_convergence_divergence.ggplot <- function( ## construct {ggplot2}-object ## splice:ggplot-assembly:start + ## calculate directions for bull + ## and bear candles constructed_indicator$direction <- constructed_indicator$MACDSignal >= constructed_indicator$MACD layers <- list( @@ -357,19 +365,10 @@ fixed_moving_average_convergence_divergence.ggplot <- function( .chart_variables$bearish_body ) ), - list( - y = "MACDSignal", - name = sprintf( - "Signal(%d)", - if (is.list(signal)) signal$n else signal - ) - ), - list( - y = "MACD", - name = sprintf("MACD(%d, %d)", 12, 26) - ) + list(y = "MACDSignal", name = sprintf("Signal(%d)", signalPeriod)), + list(y = "MACD", name = sprintf("MACD(%d, %d)", 12, 26)) ) - name <- sprintf("MACD(%d)", if (is.list(signal)) signal$n else signal) + name <- sprintf("MACD(%d)", signalPeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( @@ -386,7 +385,7 @@ fixed_moving_average_convergence_divergence.ggplot <- function( ), data = constructed_indicator, title = if (missing(title)) { - "Moving Average Convergence Divergence (Fixed)" + "Moving Average Convergence/Divergence Fix 12/26" } else { title } diff --git a/R/ta_MAMA.R b/R/ta_MAMA.R index a1fea810a..4a3e58f92 100644 --- a/R/ta_MAMA.R +++ b/R/ta_MAMA.R @@ -1,17 +1,14 @@ #' @export -#' @family Overlap Study +#' @family Overlap Studies #' #' @title MESA Adaptive Moving Average #' @templateVar .title MESA Adaptive Moving Average #' @templateVar .author Serkan Korkmaz #' @templateVar .fun mesa_adaptive_moving_average -#' @templateVar .family Overlap Study +#' @templateVar .family Overlap Studies #' @templateVar .formula ~close #' ## splice:documentation:start -#' @param n ([integer]). Present only for interface uniformity with the other Moving Average specifications (see e.g. [simple_moving_average]) so that every MA spec exposes a uniform `n` field to downstream consumers (e.g. [bollinger_bands], [stochastic], [extended_moving_average_convergence_divergence]). **`n` has no effect on the standalone calculation of [mesa_adaptive_moving_average]** - the actual smoothing is controlled entirely by `fast` and `slow`. -#' @param fast ([double]). Upper limit of the adaptive smoothing factor (alpha) used in the MESA algorithm. A [double] in `[0.01, 0.99]`. `0.5` by default. -#' @param slow ([double]). Lower limit of the adaptive smoothing factor (alpha) used in the MESA algorithm. A [double] in `[0.01, 0.99]`. `0.05` by default. ## splice:documentation:end #' #' @details @@ -25,9 +22,9 @@ mesa_adaptive_moving_average <- function( x, cols, - n = 30, - fast = 0.5, - slow = 0.05, + timePeriod = 30, + fastLimit = 0.5, + slowLimit = 0.05, na.bridge = FALSE, ... ) { @@ -38,15 +35,28 @@ mesa_adaptive_moving_average <- function( ## from call x <- structure( list( - n = if (missing(n)) 30L else as.integer(n), - fast = if (missing(fast)) 0.5 else as.double(fast), - slow = if (missing(slow)) 0.05 else as.double(slow), + timePeriod = if (missing(timePeriod)) { + 30L + } else { + as.integer(timePeriod) + }, + fastLimit = if (missing(fastLimit)) { + 0.5 + } else { + as.double(fastLimit) + }, + slowLimit = if (missing(slowLimit)) { + 0.05 + } else { + as.double(slowLimit) + }, maType = 7L ) ) return(x) } + UseMethod("mesa_adaptive_moving_average") } @@ -64,9 +74,9 @@ MAMA <- mesa_adaptive_moving_average mesa_adaptive_moving_average.default <- function( x, cols, - n = 30, - fast = 0.5, - slow = 0.05, + timePeriod = 30, + fastLimit = 0.5, + slowLimit = 0.05, na.bridge = FALSE, ... ) { @@ -93,9 +103,9 @@ mesa_adaptive_moving_average.default <- function( ## return as data.frame x <- .Call( C_impl_ta_MAMA, - as.double(constructed_series[[1]]), - as.double(fast), - as.double(slow), + constructed_series[[1]], + as.double(fastLimit), + as.double(slowLimit), as.logical(na.bridge) ) @@ -113,14 +123,22 @@ mesa_adaptive_moving_average.default <- function( mesa_adaptive_moving_average.data.frame <- function( x, cols, - n = 30, - fast = 0.5, - slow = 0.05, + timePeriod = 30, + fastLimit = 0.5, + slowLimit = 0.05, na.bridge = FALSE, ... ) { map_dfr( - NextMethod() + mesa_adaptive_moving_average.default( + x = x, + cols = cols, + timePeriod = timePeriod, + fastLimit = fastLimit, + slowLimit = slowLimit, + na.bridge = na.bridge, + ... + ) ) } @@ -131,21 +149,18 @@ mesa_adaptive_moving_average.data.frame <- function( mesa_adaptive_moving_average.matrix <- function( x, cols, - n = 30, - fast = 0.5, - slow = 0.05, + timePeriod = 30, + fastLimit = 0.5, + slowLimit = 0.05, na.bridge = FALSE, ... ) { - ## pass directly to - ## mesa_adaptive_moving_average.default to avoid - ## shenanigans with NextMethod() mesa_adaptive_moving_average.default( x = x, cols = cols, - n = n, - fast = fast, - slow = slow, + timePeriod = timePeriod, + fastLimit = fastLimit, + slowLimit = slowLimit, na.bridge = na.bridge, ... ) @@ -158,9 +173,9 @@ mesa_adaptive_moving_average.matrix <- function( mesa_adaptive_moving_average.numeric <- function( x, cols, - n = 30, - fast = 0.5, - slow = 0.05, + timePeriod = 30, + fastLimit = 0.5, + slowLimit = 0.05, na.bridge = FALSE, ... ) { @@ -177,8 +192,8 @@ mesa_adaptive_moving_average.numeric <- function( x <- .Call( C_impl_ta_MAMA, as.double(x), - as.double(fast), - as.double(slow), + as.double(fastLimit), + as.double(slowLimit), as.logical(na.bridge) ) @@ -196,9 +211,9 @@ mesa_adaptive_moving_average.numeric <- function( mesa_adaptive_moving_average.plotly <- function( x, cols, - n = 30, - fast = 0.5, - slow = 0.05, + timePeriod = 30, + fastLimit = 0.5, + slowLimit = 0.05, na.bridge = FALSE, ... ) { @@ -228,9 +243,10 @@ mesa_adaptive_moving_average.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, - fast = fast, - slow = slow + timePeriod = timePeriod, + fastLimit = fastLimit, + slowLimit = slowLimit, + na.bridge = TRUE ) ## add conditional idx @@ -253,15 +269,15 @@ mesa_adaptive_moving_average.plotly <- function( ) ) ), - name = label("MAMA", fast, slow), - decorators = list() + name = label("MAMA", fastLimit, slowLimit), + decorators = list(), + data = constructed_indicator ) state[["main"]] <- plotly_object plotly_object } - #' @usage NULL #' @aliases mesa_adaptive_moving_average #' @@ -269,9 +285,9 @@ mesa_adaptive_moving_average.plotly <- function( mesa_adaptive_moving_average.ggplot <- function( x, cols, - n = 30, - fast = 0.5, - slow = 0.05, + timePeriod = 30, + fastLimit = 0.5, + slowLimit = 0.05, na.bridge = FALSE, ... ) { @@ -300,9 +316,10 @@ mesa_adaptive_moving_average.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, - fast = fast, - slow = slow + timePeriod = timePeriod, + fastLimit = fastLimit, + slowLimit = slowLimit, + na.bridge = TRUE ) ## add conditional idx @@ -319,7 +336,7 @@ mesa_adaptive_moving_average.ggplot <- function( y = "MAMA" ) ), - name = label("MAMA", fast, slow), + name = label("MAMA", fastLimit, slowLimit), decorators = list(), data = constructed_indicator ) diff --git a/R/ta_MAVP.R b/R/ta_MAVP.R new file mode 100644 index 000000000..5d522133c --- /dev/null +++ b/R/ta_MAVP.R @@ -0,0 +1,152 @@ +#' @export +#' @family Overlap Studies +#' +#' @title Moving average with variable period +#' @templateVar .title Moving average with variable period +#' @templateVar .author Serkan Korkmaz +#' @templateVar .fun MAVP +#' @templateVar .family Overlap Studies +#' @templateVar .formula ~close +#' +## splice:documentation:start +## splice:documentation:end +#' +#' @template description +#' @template returns +MAVP <- function( + x, + cols, + minimumPeriod = 2, + maximumPeriod = 30, + maType = 0, + na.bridge = FALSE, + ... +) { + UseMethod("MAVP") +} + +#' @export +#' @usage NULL +#' @rdname MAVP +#' +#' @aliases MAVP +MAVP <- MAVP + +#' @usage NULL +#' @aliases MAVP +#' +#' @export +MAVP.default <- function( + x, + cols, + minimumPeriod = 2, + maximumPeriod = 30, + maType = 0, + na.bridge = FALSE, + ... +) { + ## 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, + ... + ) + + ## extract rownames + ## for later attachment + x_names <- rownames(constructed_series) + + ## calculate indicator and + ## return as data.frame + x <- .Call( + C_impl_ta_MAVP, + constructed_series[[1]], + constructed_series[[2]], + as.integer(minimumPeriod), + as.integer(maximumPeriod), + as.integer(maType), + as.logical(na.bridge) + ) + + ## readd rownames + set_rownames(x, x_names) + + ## return indicator + x +} + +#' @usage NULL +#' @aliases MAVP +#' +#' @export +MAVP.data.frame <- function( + x, + cols, + minimumPeriod = 2, + maximumPeriod = 30, + maType = 0, + na.bridge = FALSE, + ... +) { + map_dfr( + MAVP.default( + x = x, + cols = cols, + minimumPeriod = minimumPeriod, + maximumPeriod = maximumPeriod, + maType = maType, + na.bridge = na.bridge, + ... + ) + ) +} + +#' @usage NULL +#' @aliases MAVP +#' +#' @export +MAVP.matrix <- function( + x, + cols, + minimumPeriod = 2, + maximumPeriod = 30, + maType = 0, + na.bridge = FALSE, + ... +) { + MAVP.default( + x = x, + cols = cols, + minimumPeriod = minimumPeriod, + maximumPeriod = maximumPeriod, + maType = maType, + na.bridge = na.bridge, + ... + ) +} + +#' @usage NULL +MAVP_lookback <- function( + x, + cols, + minimumPeriod = 2, + maximumPeriod = 30, + maType = 0, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_MAVP_lookback, + as.integer(minimumPeriod), + as.integer(maximumPeriod), + as.integer(maType) + ) +} diff --git a/R/ta_MEDPRICE.R b/R/ta_MEDPRICE.R index d3dbb04dc..501e1c307 100644 --- a/R/ta_MEDPRICE.R +++ b/R/ta_MEDPRICE.R @@ -62,10 +62,8 @@ median_price.default <- function( ## return as data.frame x <- .Call( C_impl_ta_MEDPRICE, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], - ## splice:call:end as.logical(na.bridge) ) @@ -113,3 +111,15 @@ median_price.matrix <- function( ... ) } + +#' @usage NULL +median_price_lookback <- function( + x, + cols, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_MEDPRICE_lookback + ) +} diff --git a/R/ta_MFI.R b/R/ta_MFI.R index 7849841d2..434cdea89 100644 --- a/R/ta_MFI.R +++ b/R/ta_MFI.R @@ -1,12 +1,12 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Money Flow Index #' @templateVar .title Money Flow Index #' @templateVar .author Serkan Korkmaz #' @templateVar .fun money_flow_index -#' @templateVar .family Momentum Indicator -#' @templateVar .formula ~ high + low + close + volume +#' @templateVar .family Momentum Indicators +#' @templateVar .formula ~high + low + close + volume #' ## splice:documentation:start ## splice:documentation:end @@ -16,7 +16,7 @@ money_flow_index <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ MFI <- money_flow_index money_flow_index.default <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -64,13 +64,11 @@ money_flow_index.default <- function( ## return as data.frame x <- .Call( C_impl_ta_MFI, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], constructed_series[[4]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -88,7 +86,7 @@ money_flow_index.default <- function( money_flow_index.data.frame <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -96,7 +94,7 @@ money_flow_index.data.frame <- function( money_flow_index.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -110,20 +108,32 @@ money_flow_index.data.frame <- function( money_flow_index.matrix <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { money_flow_index.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +money_flow_index_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_MFI_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases money_flow_index #' @@ -131,7 +141,7 @@ money_flow_index.matrix <- function( money_flow_index.plotly <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ## splice:optional-plotly:start lower_bound = -20, @@ -166,7 +176,7 @@ money_flow_index.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -185,7 +195,7 @@ money_flow_index.plotly <- function( ## splice:plotly-assembly:start name <- sprintf( "MFI(%d)", - n + timePeriod ) traces <- list( @@ -231,11 +241,11 @@ money_flow_index.plotly <- function( money_flow_index.ggplot <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -263,7 +273,7 @@ money_flow_index.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -285,7 +295,7 @@ money_flow_index.ggplot <- function( ggplot_line(80), list(y = "MFI") ) - name <- sprintf("MFI(%d)", n) + name <- sprintf("MFI(%d)", timePeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_MIDPOINT.R b/R/ta_MIDPOINT.R new file mode 100644 index 000000000..a4c036038 --- /dev/null +++ b/R/ta_MIDPOINT.R @@ -0,0 +1,167 @@ +#' @export +#' @family Overlap Studies +#' +#' @title MidPoint over period +#' @templateVar .title MidPoint over period +#' @templateVar .author Serkan Korkmaz +#' @templateVar .fun MIDPOINT +#' @templateVar .family Overlap Studies +#' @templateVar .formula ~close +#' +## splice:documentation:start +## splice:documentation:end +#' +#' @template description +#' @template returns +MIDPOINT <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + UseMethod("MIDPOINT") +} + +#' @export +#' @usage NULL +#' @rdname MIDPOINT +#' +#' @aliases MIDPOINT +MIDPOINT <- MIDPOINT + +#' @usage NULL +#' @aliases MIDPOINT +#' +#' @export +MIDPOINT.default <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + ## 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, + ... + ) + + ## extract rownames + ## for later attachment + x_names <- rownames(constructed_series) + + ## calculate indicator and + ## return as data.frame + x <- .Call( + C_impl_ta_MIDPOINT, + constructed_series[[1]], + as.integer(timePeriod), + as.logical(na.bridge) + ) + + ## readd rownames + set_rownames(x, x_names) + + ## return indicator + x +} + +#' @usage NULL +#' @aliases MIDPOINT +#' +#' @export +MIDPOINT.data.frame <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + map_dfr( + MIDPOINT.default( + x = x, + cols = cols, + timePeriod = timePeriod, + na.bridge = na.bridge, + ... + ) + ) +} + +#' @usage NULL +#' @aliases MIDPOINT +#' +#' @export +MIDPOINT.matrix <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + MIDPOINT.default( + x = x, + cols = cols, + timePeriod = timePeriod, + na.bridge = na.bridge, + ... + ) +} + +#' @usage NULL +MIDPOINT_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_MIDPOINT_lookback, + as.integer(timePeriod) + ) +} +#' @usage NULL +#' @aliases MIDPOINT +#' +#' @export +MIDPOINT.numeric <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + ## warn if 'cols' have been + ## passed just to make sure + ## the user knows its not possible + ## or relevant + if (!missing(cols)) { + warning("'cols' is passed but is unused for vectors.") + } + + ## pass the argument directly + ## to 'C' + x <- .Call( + C_impl_ta_MIDPOINT, + as.double(x), + as.integer(timePeriod), + as.logical(na.bridge) + ) + + if (dim(x)[2] == 1L) { + dim(x) <- NULL + } + + x +} diff --git a/R/ta_MIDPRICE.R b/R/ta_MIDPRICE.R index ef6a798fe..2a90eb7af 100644 --- a/R/ta_MIDPRICE.R +++ b/R/ta_MIDPRICE.R @@ -1,11 +1,11 @@ #' @export -#' @family Price Transform +#' @family Overlap Studies #' -#' @title Midpoint Price -#' @templateVar .title Midpoint Price +#' @title Midpoint Price over period +#' @templateVar .title Midpoint Price over period #' @templateVar .author Serkan Korkmaz #' @templateVar .fun midpoint_price -#' @templateVar .family Price Transform +#' @templateVar .family Overlap Studies #' @templateVar .formula ~high + low #' ## splice:documentation:start @@ -16,7 +16,7 @@ midpoint_price <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ MIDPRICE <- midpoint_price midpoint_price.default <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -64,11 +64,9 @@ midpoint_price.default <- function( ## return as data.frame x <- .Call( C_impl_ta_MIDPRICE, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -86,7 +84,7 @@ midpoint_price.default <- function( midpoint_price.data.frame <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -94,7 +92,7 @@ midpoint_price.data.frame <- function( midpoint_price.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -108,15 +106,29 @@ midpoint_price.data.frame <- function( midpoint_price.matrix <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { midpoint_price.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } + +#' @usage NULL +midpoint_price_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_MIDPRICE_lookback, + as.integer(timePeriod) + ) +} diff --git a/R/ta_MIN.R b/R/ta_MIN.R deleted file mode 100644 index 1a0864833..000000000 --- a/R/ta_MIN.R +++ /dev/null @@ -1,82 +0,0 @@ -#' @export -#' @family Rolling Statistic -#' -#' @title Rolling Min -#' @templateVar .title Rolling Min -#' @templateVar .author Serkan Korkmaz -#' @templateVar .fun rolling_min -#' -## splice:documentation:start -## splice:documentation:end -#' -#' @template rolling_description -#' @template rolling_returns -rolling_min <- function( - x, - n = 30, - na.bridge = FALSE -) { - UseMethod("rolling_min") -} - -#' @export -#' @usage NULL -#' @rdname rolling_min -#' -#' @aliases rolling_min -MIN <- rolling_min - -#' @usage NULL -#' @aliases rolling_min -#' -#' @export -rolling_min.default <- function( - x, - n = 30, - na.bridge = FALSE -) { - ## calculate indicator and - ## return as data.frame - x <- .Call( - C_impl_ta_MIN, - ## splice:call:start - as.double(x), - as.integer(n), - ## splice:call:end - as.logical(na.bridge) - ) - - ## strip dimensions - ## while preserving - ## attributes - dim(x) <- NULL - - ## return indicator - x -} - -#' @usage NULL -#' @aliases rolling_min -#' -#' @export -rolling_min.numeric <- function( - x, - n = 30, - na.bridge = FALSE -) { - ## calculate indicator and - ## return as data.frame - x <- rolling_min.default( - x = x, - n = n, - na.bridge = na.bridge - ) - - ## strip dimensions - ## while preserving - ## attributes - dim(x) <- NULL - - ## return indicator - x -} diff --git a/R/ta_MINUS_DI.R b/R/ta_MINUS_DI.R index 22dcea0d3..e57a6e8f7 100644 --- a/R/ta_MINUS_DI.R +++ b/R/ta_MINUS_DI.R @@ -1,11 +1,11 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Minus Directional Indicator #' @templateVar .title Minus Directional Indicator #' @templateVar .author Serkan Korkmaz #' @templateVar .fun minus_directional_indicator -#' @templateVar .family Momentum Indicator +#' @templateVar .family Momentum Indicators #' @templateVar .formula ~high + low + close #' ## splice:documentation:start @@ -16,7 +16,7 @@ minus_directional_indicator <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ MINUS_DI <- minus_directional_indicator minus_directional_indicator.default <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -64,12 +64,10 @@ minus_directional_indicator.default <- function( ## return as data.frame x <- .Call( C_impl_ta_MINUS_DI, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -87,7 +85,7 @@ minus_directional_indicator.default <- function( minus_directional_indicator.data.frame <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -95,7 +93,7 @@ minus_directional_indicator.data.frame <- function( minus_directional_indicator.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -109,20 +107,32 @@ minus_directional_indicator.data.frame <- function( minus_directional_indicator.matrix <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { minus_directional_indicator.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +minus_directional_indicator_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_MINUS_DI_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases minus_directional_indicator #' @@ -130,7 +140,7 @@ minus_directional_indicator.matrix <- function( minus_directional_indicator.plotly <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -163,7 +173,7 @@ minus_directional_indicator.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -180,7 +190,7 @@ minus_directional_indicator.plotly <- function( ## construct {plotly}-object ## splice:plotly-assembly:start - name <- sprintf("-DI(%d)", n) + name <- sprintf("-DI(%d)", timePeriod) traces <- list( list(y = ~MINUS_DI) @@ -223,11 +233,11 @@ minus_directional_indicator.plotly <- function( minus_directional_indicator.ggplot <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -255,7 +265,7 @@ minus_directional_indicator.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -276,7 +286,7 @@ minus_directional_indicator.ggplot <- function( setdiff(colnames(constructed_indicator), "idx"), function(col) list(y = col) ) - name <- sprintf("-DI(%d)", n) + name <- sprintf("-DI(%d)", timePeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_MINUS_DM.R b/R/ta_MINUS_DM.R index c46367eee..f0cde79db 100644 --- a/R/ta_MINUS_DM.R +++ b/R/ta_MINUS_DM.R @@ -1,11 +1,11 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Minus Directional Movement #' @templateVar .title Minus Directional Movement #' @templateVar .author Serkan Korkmaz #' @templateVar .fun minus_directional_movement -#' @templateVar .family Momentum Indicator +#' @templateVar .family Momentum Indicators #' @templateVar .formula ~high + low #' ## splice:documentation:start @@ -16,7 +16,7 @@ minus_directional_movement <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ MINUS_DM <- minus_directional_movement minus_directional_movement.default <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -64,11 +64,9 @@ minus_directional_movement.default <- function( ## return as data.frame x <- .Call( C_impl_ta_MINUS_DM, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -86,7 +84,7 @@ minus_directional_movement.default <- function( minus_directional_movement.data.frame <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -94,7 +92,7 @@ minus_directional_movement.data.frame <- function( minus_directional_movement.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -108,20 +106,32 @@ minus_directional_movement.data.frame <- function( minus_directional_movement.matrix <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { minus_directional_movement.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +minus_directional_movement_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_MINUS_DM_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases minus_directional_movement #' @@ -129,7 +139,7 @@ minus_directional_movement.matrix <- function( minus_directional_movement.plotly <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -162,7 +172,7 @@ minus_directional_movement.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -179,7 +189,7 @@ minus_directional_movement.plotly <- function( ## construct {plotly}-object ## splice:plotly-assembly:start - name <- sprintf("-DM(%d)", n) + name <- sprintf("-DM(%d)", timePeriod) traces <- list( list(y = ~MINUS_DM) @@ -222,11 +232,11 @@ minus_directional_movement.plotly <- function( minus_directional_movement.ggplot <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -254,7 +264,7 @@ minus_directional_movement.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -275,7 +285,7 @@ minus_directional_movement.ggplot <- function( setdiff(colnames(constructed_indicator), "idx"), function(col) list(y = col) ) - name <- sprintf("-DM(%d)", n) + name <- sprintf("-DM(%d)", timePeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_MOM.R b/R/ta_MOM.R index 8a881ab4f..0534aece0 100644 --- a/R/ta_MOM.R +++ b/R/ta_MOM.R @@ -1,12 +1,12 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Momentum #' @templateVar .title Momentum #' @templateVar .author Serkan Korkmaz #' @templateVar .fun momentum -#' @templateVar .family Momentum Indicator -#' @templateVar .formula ~ close +#' @templateVar .family Momentum Indicators +#' @templateVar .formula ~close #' ## splice:documentation:start ## splice:documentation:end @@ -16,7 +16,7 @@ momentum <- function( x, cols, - n = 10, + timePeriod = 10, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ MOM <- momentum momentum.default <- function( x, cols, - n = 10, + timePeriod = 10, na.bridge = FALSE, ... ) { @@ -64,10 +64,8 @@ momentum.default <- function( ## return as data.frame x <- .Call( C_impl_ta_MOM, - ## splice:call:start constructed_series[[1]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -85,7 +83,7 @@ momentum.default <- function( momentum.data.frame <- function( x, cols, - n = 10, + timePeriod = 10, na.bridge = FALSE, ... ) { @@ -93,7 +91,7 @@ momentum.data.frame <- function( momentum.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -107,20 +105,32 @@ momentum.data.frame <- function( momentum.matrix <- function( x, cols, - n = 10, + timePeriod = 10, na.bridge = FALSE, ... ) { momentum.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +momentum_lookback <- function( + x, + cols, + timePeriod = 10, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_MOM_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases momentum #' @@ -128,7 +138,7 @@ momentum.matrix <- function( momentum.numeric <- function( x, cols, - n = 10, + timePeriod = 10, na.bridge = FALSE, ... ) { @@ -144,10 +154,8 @@ momentum.numeric <- function( ## to 'C' x <- .Call( C_impl_ta_MOM, - ## splice:numeric:start as.double(x), - as.integer(n), - ## splice:numeric:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -158,7 +166,6 @@ momentum.numeric <- function( x } - #' @usage NULL #' @aliases momentum #' @@ -166,7 +173,7 @@ momentum.numeric <- function( momentum.plotly <- function( x, cols, - n = 10, + timePeriod = 10, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -199,7 +206,7 @@ momentum.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -218,7 +225,7 @@ momentum.plotly <- function( ## splice:plotly-assembly:start name <- sprintf( "MOM(%d)", - n + timePeriod ) traces <- list( @@ -262,11 +269,11 @@ momentum.plotly <- function( momentum.ggplot <- function( x, cols, - n = 10, + timePeriod = 10, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -294,7 +301,7 @@ momentum.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -315,7 +322,7 @@ momentum.ggplot <- function( setdiff(colnames(constructed_indicator), "idx"), function(col) list(y = col) ) - name <- sprintf("MOM(%d)", n) + name <- sprintf("MOM(%d)", timePeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_NATR.R b/R/ta_NATR.R index aaa630e4a..57e8a1420 100644 --- a/R/ta_NATR.R +++ b/R/ta_NATR.R @@ -1,11 +1,11 @@ #' @export -#' @family Volatility Indicator +#' @family Volatility Indicators #' #' @title Normalized Average True Range #' @templateVar .title Normalized Average True Range #' @templateVar .author Serkan Korkmaz #' @templateVar .fun normalized_average_true_range -#' @templateVar .family Volatility Indicator +#' @templateVar .family Volatility Indicators #' @templateVar .formula ~high + low + close #' ## splice:documentation:start @@ -16,7 +16,7 @@ normalized_average_true_range <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ NATR <- normalized_average_true_range normalized_average_true_range.default <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -64,12 +64,10 @@ normalized_average_true_range.default <- function( ## return as data.frame x <- .Call( C_impl_ta_NATR, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -87,7 +85,7 @@ normalized_average_true_range.default <- function( normalized_average_true_range.data.frame <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -95,7 +93,7 @@ normalized_average_true_range.data.frame <- function( normalized_average_true_range.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -109,20 +107,32 @@ normalized_average_true_range.data.frame <- function( normalized_average_true_range.matrix <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { normalized_average_true_range.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +normalized_average_true_range_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_NATR_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases normalized_average_true_range #' @@ -130,7 +140,7 @@ normalized_average_true_range.matrix <- function( normalized_average_true_range.plotly <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -163,7 +173,7 @@ normalized_average_true_range.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -180,7 +190,7 @@ normalized_average_true_range.plotly <- function( ## construct {plotly}-object ## splice:plotly-assembly:start - name <- sprintf("NATR(%d)", n) + name <- sprintf("NATR(%d)", timePeriod) traces <- list( list(y = ~NATR) ) @@ -222,11 +232,11 @@ normalized_average_true_range.plotly <- function( normalized_average_true_range.ggplot <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -254,7 +264,7 @@ normalized_average_true_range.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -275,7 +285,7 @@ normalized_average_true_range.ggplot <- function( setdiff(colnames(constructed_indicator), "idx"), function(col) list(y = col) ) - name <- sprintf("NATR(%d)", n) + name <- sprintf("NATR(%d)", timePeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_OBV.R b/R/ta_OBV.R index 829fb3365..b7debfc0a 100644 --- a/R/ta_OBV.R +++ b/R/ta_OBV.R @@ -1,12 +1,12 @@ #' @export -#' @family Volume Indicator +#' @family Volume Indicators #' -#' @title On-Balance Volume -#' @templateVar .title On-Balance Volume +#' @title On Balance Volume +#' @templateVar .title On Balance Volume #' @templateVar .author Serkan Korkmaz #' @templateVar .fun on_balance_volume -#' @templateVar .family Volume Indicator -#' @templateVar .formula ~close+volume +#' @templateVar .family Volume Indicators +#' @templateVar .formula ~close + volume #' ## splice:documentation:start ## splice:documentation:end @@ -62,10 +62,8 @@ on_balance_volume.default <- function( ## return as data.frame x <- .Call( C_impl_ta_OBV, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], - ## splice:call:end as.logical(na.bridge) ) @@ -114,7 +112,17 @@ on_balance_volume.matrix <- function( ) } - +#' @usage NULL +on_balance_volume_lookback <- function( + x, + cols, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_OBV_lookback + ) +} #' @usage NULL #' @aliases on_balance_volume #' @@ -188,7 +196,7 @@ on_balance_volume.plotly <- function( ), data = constructed_indicator, title = if (missing(title)) { - "On-Balance Volume" + "On Balance Volume" } else { title } @@ -211,9 +219,9 @@ on_balance_volume.ggplot <- function( x, cols, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -278,7 +286,7 @@ on_balance_volume.ggplot <- function( ), data = constructed_indicator, title = if (missing(title)) { - "On-Balance Volume" + "On Balance Volume" } else { title } diff --git a/R/ta_PLUS_DI.R b/R/ta_PLUS_DI.R index 98563a504..69310bf2c 100644 --- a/R/ta_PLUS_DI.R +++ b/R/ta_PLUS_DI.R @@ -1,11 +1,11 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Plus Directional Indicator #' @templateVar .title Plus Directional Indicator #' @templateVar .author Serkan Korkmaz #' @templateVar .fun plus_directional_indicator -#' @templateVar .family Momentum Indicator +#' @templateVar .family Momentum Indicators #' @templateVar .formula ~high + low + close #' ## splice:documentation:start @@ -16,7 +16,7 @@ plus_directional_indicator <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ PLUS_DI <- plus_directional_indicator plus_directional_indicator.default <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -64,12 +64,10 @@ plus_directional_indicator.default <- function( ## return as data.frame x <- .Call( C_impl_ta_PLUS_DI, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -87,7 +85,7 @@ plus_directional_indicator.default <- function( plus_directional_indicator.data.frame <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -95,7 +93,7 @@ plus_directional_indicator.data.frame <- function( plus_directional_indicator.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -109,20 +107,32 @@ plus_directional_indicator.data.frame <- function( plus_directional_indicator.matrix <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { plus_directional_indicator.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +plus_directional_indicator_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_PLUS_DI_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases plus_directional_indicator #' @@ -130,7 +140,7 @@ plus_directional_indicator.matrix <- function( plus_directional_indicator.plotly <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -163,7 +173,7 @@ plus_directional_indicator.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -180,7 +190,7 @@ plus_directional_indicator.plotly <- function( ## construct {plotly}-object ## splice:plotly-assembly:start - name <- sprintf("+DI(%d)", n) + name <- sprintf("+DI(%d)", timePeriod) traces <- list( list(y = ~PLUS_DI) @@ -223,11 +233,11 @@ plus_directional_indicator.plotly <- function( plus_directional_indicator.ggplot <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -255,7 +265,7 @@ plus_directional_indicator.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -276,7 +286,7 @@ plus_directional_indicator.ggplot <- function( setdiff(colnames(constructed_indicator), "idx"), function(col) list(y = col) ) - name <- sprintf("+DI(%d)", n) + name <- sprintf("+DI(%d)", timePeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_PLUS_DM.R b/R/ta_PLUS_DM.R index b24dd5c7e..e11625493 100644 --- a/R/ta_PLUS_DM.R +++ b/R/ta_PLUS_DM.R @@ -1,11 +1,11 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Plus Directional Movement #' @templateVar .title Plus Directional Movement #' @templateVar .author Serkan Korkmaz #' @templateVar .fun plus_directional_movement -#' @templateVar .family Momentum Indicator +#' @templateVar .family Momentum Indicators #' @templateVar .formula ~high + low #' ## splice:documentation:start @@ -16,7 +16,7 @@ plus_directional_movement <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ PLUS_DM <- plus_directional_movement plus_directional_movement.default <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -64,11 +64,9 @@ plus_directional_movement.default <- function( ## return as data.frame x <- .Call( C_impl_ta_PLUS_DM, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -86,7 +84,7 @@ plus_directional_movement.default <- function( plus_directional_movement.data.frame <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -94,7 +92,7 @@ plus_directional_movement.data.frame <- function( plus_directional_movement.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -108,20 +106,32 @@ plus_directional_movement.data.frame <- function( plus_directional_movement.matrix <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { plus_directional_movement.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +plus_directional_movement_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_PLUS_DM_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases plus_directional_movement #' @@ -129,7 +139,7 @@ plus_directional_movement.matrix <- function( plus_directional_movement.plotly <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -162,7 +172,7 @@ plus_directional_movement.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -179,7 +189,7 @@ plus_directional_movement.plotly <- function( ## construct {plotly}-object ## splice:plotly-assembly:start - name <- sprintf("+DM(%d)", n) + name <- sprintf("+DM(%d)", timePeriod) traces <- list( list(y = ~PLUS_DM) @@ -222,11 +232,11 @@ plus_directional_movement.plotly <- function( plus_directional_movement.ggplot <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -254,7 +264,7 @@ plus_directional_movement.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -275,7 +285,7 @@ plus_directional_movement.ggplot <- function( setdiff(colnames(constructed_indicator), "idx"), function(col) list(y = col) ) - name <- sprintf("+DM(%d)", n) + name <- sprintf("+DM(%d)", timePeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_PPO.R b/R/ta_PPO.R index 5082d351b..13c9fc52d 100644 --- a/R/ta_PPO.R +++ b/R/ta_PPO.R @@ -1,17 +1,14 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Percentage Price Oscillator #' @templateVar .title Percentage Price Oscillator #' @templateVar .author Serkan Korkmaz #' @templateVar .fun percentage_price_oscillator -#' @templateVar .family Momentum Indicator +#' @templateVar .family Momentum Indicators #' @templateVar .formula ~close #' ## splice:documentation:start -#' @param fast ([integer]). Period for the fast Moving Average (MA). -#' @param slow ([integer]). Period for the slow Moving Average (MA). -#' @param ma ([list]). The type of Moving Average (MA) used for the `fast` and `slow` MA. [SMA] by default. ## splice:documentation:end #' #' @template description @@ -19,9 +16,9 @@ percentage_price_oscillator <- function( x, cols, - fast = 12, - slow = 26, - ma = SMA(n = 9), + fastPeriod = 12, + slowPeriod = 26, + maType = 0, na.bridge = FALSE, ... ) { @@ -42,9 +39,9 @@ PPO <- percentage_price_oscillator percentage_price_oscillator.default <- function( x, cols, - fast = 12, - slow = 26, - ma = SMA(n = 9), + fastPeriod = 12, + slowPeriod = 26, + maType = 0, na.bridge = FALSE, ... ) { @@ -71,12 +68,10 @@ percentage_price_oscillator.default <- function( ## return as data.frame x <- .Call( C_impl_ta_PPO, - ## splice:call:start constructed_series[[1]], - as.integer(fast), - as.integer(slow), - ma$maType, - ## splice:call:end + as.integer(fastPeriod), + as.integer(slowPeriod), + as.integer(maType), as.logical(na.bridge) ) @@ -94,9 +89,9 @@ percentage_price_oscillator.default <- function( percentage_price_oscillator.data.frame <- function( x, cols, - fast = 12, - slow = 26, - ma = SMA(n = 9), + fastPeriod = 12, + slowPeriod = 26, + maType = 0, na.bridge = FALSE, ... ) { @@ -104,9 +99,9 @@ percentage_price_oscillator.data.frame <- function( percentage_price_oscillator.default( x = x, cols = cols, - fast = fast, - slow = slow, - ma = ma, + fastPeriod = fastPeriod, + slowPeriod = slowPeriod, + maType = maType, na.bridge = na.bridge, ... ) @@ -120,24 +115,40 @@ percentage_price_oscillator.data.frame <- function( percentage_price_oscillator.matrix <- function( x, cols, - fast = 12, - slow = 26, - ma = SMA(n = 9), + fastPeriod = 12, + slowPeriod = 26, + maType = 0, na.bridge = FALSE, ... ) { percentage_price_oscillator.default( x = x, cols = cols, - fast = fast, - slow = slow, - ma = ma, + fastPeriod = fastPeriod, + slowPeriod = slowPeriod, + maType = maType, na.bridge = na.bridge, ... ) } - +#' @usage NULL +percentage_price_oscillator_lookback <- function( + x, + cols, + fastPeriod = 12, + slowPeriod = 26, + maType = 0, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_PPO_lookback, + as.integer(fastPeriod), + as.integer(slowPeriod), + as.integer(maType) + ) +} #' @usage NULL #' @aliases percentage_price_oscillator #' @@ -145,9 +156,9 @@ percentage_price_oscillator.matrix <- function( percentage_price_oscillator.numeric <- function( x, cols, - fast = 12, - slow = 26, - ma = SMA(n = 9), + fastPeriod = 12, + slowPeriod = 26, + maType = 0, na.bridge = FALSE, ... ) { @@ -163,12 +174,10 @@ percentage_price_oscillator.numeric <- function( ## to 'C' x <- .Call( C_impl_ta_PPO, - ## splice:numeric:start as.double(x), - as.integer(fast), - as.integer(slow), - ma$maType, - ## splice:numeric:end + as.integer(fastPeriod), + as.integer(slowPeriod), + as.integer(maType), as.logical(na.bridge) ) @@ -179,7 +188,6 @@ percentage_price_oscillator.numeric <- function( x } - #' @usage NULL #' @aliases percentage_price_oscillator #' @@ -187,9 +195,9 @@ percentage_price_oscillator.numeric <- function( percentage_price_oscillator.plotly <- function( x, cols, - fast = 12, - slow = 26, - ma = SMA(n = 9), + fastPeriod = 12, + slowPeriod = 26, + maType = 0, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -222,9 +230,9 @@ percentage_price_oscillator.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - fast = fast, - slow = slow, - ma = ma, + fastPeriod = fastPeriod, + slowPeriod = slowPeriod, + maType = maType, na.bridge = TRUE ) @@ -243,8 +251,8 @@ percentage_price_oscillator.plotly <- function( ## splice:plotly-assembly:start name <- sprintf( "PPO(%d, %d)", - fast, - slow + fastPeriod, + slowPeriod ) traces <- list( @@ -288,13 +296,13 @@ percentage_price_oscillator.plotly <- function( percentage_price_oscillator.ggplot <- function( x, cols, - fast = 12, - slow = 26, - ma = SMA(n = 9), + fastPeriod = 12, + slowPeriod = 26, + maType = 0, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -322,9 +330,9 @@ percentage_price_oscillator.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - fast = fast, - slow = slow, - ma = ma, + fastPeriod = fastPeriod, + slowPeriod = slowPeriod, + maType = maType, na.bridge = TRUE ) @@ -345,7 +353,7 @@ percentage_price_oscillator.ggplot <- function( ggplot_line(0), list(y = "PPO") ) - name <- sprintf("PPO(%d, %d)", fast, slow) + name <- sprintf("PPO(%d, %d)", fastPeriod, slowPeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_ROC.R b/R/ta_ROC.R deleted file mode 100644 index e125bc39a..000000000 --- a/R/ta_ROC.R +++ /dev/null @@ -1,351 +0,0 @@ -#' @export -#' @family Momentum Indicator -#' -#' @title Rate of Change -#' @templateVar .title Rate of Change -#' @templateVar .author Serkan Korkmaz -#' @templateVar .fun rate_of_change -#' @templateVar .family Momentum Indicator -#' @templateVar .formula ~close -#' -## splice:documentation:start -## splice:documentation:end -#' -#' @template description -#' @template returns -rate_of_change <- function( - x, - cols, - n = 10, - na.bridge = FALSE, - ... -) { - UseMethod("rate_of_change") -} - -#' @export -#' @usage NULL -#' @rdname rate_of_change -#' -#' @aliases rate_of_change -ROC <- rate_of_change - -#' @usage NULL -#' @aliases rate_of_change -#' -#' @export -rate_of_change.default <- function( - x, - cols, - n = 10, - na.bridge = FALSE, - ... -) { - ## 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, - ... - ) - - ## extract rownames - ## for later attachment - x_names <- rownames(constructed_series) - - ## calculate indicator and - ## return as data.frame - x <- .Call( - C_impl_ta_ROC, - ## splice:call:start - constructed_series[[1]], - as.integer(n), - ## splice:call:end - as.logical(na.bridge) - ) - - ## readd rownames - set_rownames(x, x_names) - - ## return indicator - x -} - -#' @usage NULL -#' @aliases rate_of_change -#' -#' @export -rate_of_change.data.frame <- function( - x, - cols, - n = 10, - na.bridge = FALSE, - ... -) { - map_dfr( - rate_of_change.default( - x = x, - cols = cols, - n = n, - na.bridge = na.bridge, - ... - ) - ) -} - -#' @usage NULL -#' @aliases rate_of_change -#' -#' @export -rate_of_change.matrix <- function( - x, - cols, - n = 10, - na.bridge = FALSE, - ... -) { - rate_of_change.default( - x = x, - cols = cols, - n = n, - na.bridge = na.bridge, - ... - ) -} - - -#' @usage NULL -#' @aliases rate_of_change -#' -#' @export -rate_of_change.numeric <- function( - x, - cols, - n = 10, - na.bridge = FALSE, - ... -) { - ## warn if 'cols' have been - ## passed just to make sure - ## the user knows its not possible - ## or relevant - if (!missing(cols)) { - warning("'cols' is passed but is unused for vectors.") - } - - ## pass the argument directly - ## to 'C' - x <- .Call( - C_impl_ta_ROC, - ## splice:numeric:start - as.double(x), - as.integer(n), - ## splice:numeric:end - as.logical(na.bridge) - ) - - if (dim(x)[2] == 1L) { - dim(x) <- NULL - } - - x -} - - -#' @usage NULL -#' @aliases rate_of_change -#' -#' @export -rate_of_change.plotly <- function( - x, - cols, - n = 10, - na.bridge = FALSE, - ## splice:optional-plotly:start - ## splice:optional-plotly:end - title, - ... -) { - ## check that input value - ## 'x' is -object - assert_plotly_object(x) - - ## check that input value - ## 'cols' is a -objet - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series from - ## {plotly}-object - constructed_series <- series( - x = x, - formula = cols, - default_formula = ~close, - ... - ) - - ## construct indicator - ## from the series - constructed_indicator <- rate_of_change( - x = constructed_series, - cols = rebuild_formula( - names(constructed_series) - ), - n = n, - na.bridge = TRUE - ) - - ## the constructed indicator - ## always returns excpected - ## columns which can be passed - ## down to add_last_values() - values_to_extract <- colnames(constructed_indicator) - - ## add conditional idx - constructed_indicator[["idx"]] <- add_idx( - constructed_series - ) - - ## construct {plotly}-object - ## splice:plotly-assembly:start - name <- sprintf( - "ROC(%d)", - n - ) - - traces <- list( - list( - y = ~ROC - ) - ) - ## splice:plotly-assembly:end - - plotly_object <- add_last_value_ly( - build_plotly( - init = plotly_init(), - traces = traces, - decorators = get0( - x = "decorators", - ifnotfound = list() - ), - name = get0( - x = "name", - ifnotfound = NULL - ), - data = constructed_indicator, - title = if (missing(title)) { - "Rate of Change" - } else { - title - } - ), - data = constructed_indicator[, values_to_extract, drop = FALSE], - values_to_extract = values_to_extract - ) - - state <- .chart_state() - state$sub <- c(state$sub, list(plotly_object)) - - plotly_object -} - -#' @usage NULL -#' @aliases rate_of_change -#' -#' @export -rate_of_change.ggplot <- function( - x, - cols, - n = 10, - na.bridge = FALSE, - ## splice:optional-ggplot:start - ## splice:optional-ggplot:end - title, - ... -) { - ## check ggplot2 availability - assert_ggplot2() - - ## check that input value - ## 'cols' is a -objet - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series from - ## {ggplot}-object - constructed_series <- series( - x = x, - formula = cols, - default_formula = ~close, - ... - ) - - ## construct indicator - ## from the series - constructed_indicator <- rate_of_change( - x = constructed_series, - cols = rebuild_formula( - names(constructed_series) - ), - n = n, - na.bridge = TRUE - ) - - ## the constructed indicator - ## always returns expected - ## columns which can be passed - ## down to add_last_value_gg() - values_to_extract <- colnames(constructed_indicator) - - ## add conditional idx - constructed_indicator[["idx"]] <- add_idx( - constructed_series - ) - - ## construct {ggplot2}-object - ## splice:ggplot-assembly:start - layers <- lapply( - setdiff(colnames(constructed_indicator), "idx"), - function(col) list(y = col) - ) - name <- sprintf("ROC(%d)", n) - ## splice:ggplot-assembly:end - - ggplot_object <- add_last_value_gg( - build_ggplot( - init = ggplot_init(), - layers = layers, - decorators = get0( - x = "decorators", - ifnotfound = list() - ), - name = get0( - x = "name", - ifnotfound = NULL - ), - data = constructed_indicator, - title = if (missing(title)) { - "Rate of Change" - } else { - title - } - ), - data = constructed_indicator[, values_to_extract, drop = FALSE], - values_to_extract = values_to_extract, - name = get0(x = "name", ifnotfound = NULL) - ) - - state <- .chart_state() - state$sub <- c(state$sub, list(ggplot_object)) - - ggplot_object -} diff --git a/R/ta_ROCR.R b/R/ta_ROCR.R deleted file mode 100644 index 1c6b91ebb..000000000 --- a/R/ta_ROCR.R +++ /dev/null @@ -1,351 +0,0 @@ -#' @export -#' @family Momentum Indicator -#' -#' @title Ratio of Change -#' @templateVar .title Ratio of Change -#' @templateVar .author Serkan Korkmaz -#' @templateVar .fun ratio_of_change -#' @templateVar .family Momentum Indicator -#' @templateVar .formula ~close -#' -## splice:documentation:start -## splice:documentation:end -#' -#' @template description -#' @template returns -ratio_of_change <- function( - x, - cols, - n = 10, - na.bridge = FALSE, - ... -) { - UseMethod("ratio_of_change") -} - -#' @export -#' @usage NULL -#' @rdname ratio_of_change -#' -#' @aliases ratio_of_change -ROCR <- ratio_of_change - -#' @usage NULL -#' @aliases ratio_of_change -#' -#' @export -ratio_of_change.default <- function( - x, - cols, - n = 10, - na.bridge = FALSE, - ... -) { - ## 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, - ... - ) - - ## extract rownames - ## for later attachment - x_names <- rownames(constructed_series) - - ## calculate indicator and - ## return as data.frame - x <- .Call( - C_impl_ta_ROCR, - ## splice:call:start - constructed_series[[1]], - as.integer(n), - ## splice:call:end - as.logical(na.bridge) - ) - - ## readd rownames - set_rownames(x, x_names) - - ## return indicator - x -} - -#' @usage NULL -#' @aliases ratio_of_change -#' -#' @export -ratio_of_change.data.frame <- function( - x, - cols, - n = 10, - na.bridge = FALSE, - ... -) { - map_dfr( - ratio_of_change.default( - x = x, - cols = cols, - n = n, - na.bridge = na.bridge, - ... - ) - ) -} - -#' @usage NULL -#' @aliases ratio_of_change -#' -#' @export -ratio_of_change.matrix <- function( - x, - cols, - n = 10, - na.bridge = FALSE, - ... -) { - ratio_of_change.default( - x = x, - cols = cols, - n = n, - na.bridge = na.bridge, - ... - ) -} - - -#' @usage NULL -#' @aliases ratio_of_change -#' -#' @export -ratio_of_change.numeric <- function( - x, - cols, - n = 10, - na.bridge = FALSE, - ... -) { - ## warn if 'cols' have been - ## passed just to make sure - ## the user knows its not possible - ## or relevant - if (!missing(cols)) { - warning("'cols' is passed but is unused for vectors.") - } - - ## pass the argument directly - ## to 'C' - x <- .Call( - C_impl_ta_ROCR, - ## splice:numeric:start - as.double(x), - as.integer(n), - ## splice:numeric:end - as.logical(na.bridge) - ) - - if (dim(x)[2] == 1L) { - dim(x) <- NULL - } - - x -} - - -#' @usage NULL -#' @aliases ratio_of_change -#' -#' @export -ratio_of_change.plotly <- function( - x, - cols, - n = 10, - na.bridge = FALSE, - ## splice:optional-plotly:start - ## splice:optional-plotly:end - title, - ... -) { - ## check that input value - ## 'x' is -object - assert_plotly_object(x) - - ## check that input value - ## 'cols' is a -objet - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series from - ## {plotly}-object - constructed_series <- series( - x = x, - formula = cols, - default_formula = ~close, - ... - ) - - ## construct indicator - ## from the series - constructed_indicator <- ratio_of_change( - x = constructed_series, - cols = rebuild_formula( - names(constructed_series) - ), - n = n, - na.bridge = TRUE - ) - - ## the constructed indicator - ## always returns excpected - ## columns which can be passed - ## down to add_last_values() - values_to_extract <- colnames(constructed_indicator) - - ## add conditional idx - constructed_indicator[["idx"]] <- add_idx( - constructed_series - ) - - ## construct {plotly}-object - ## splice:plotly-assembly:start - name <- sprintf( - "ROCR(%d)", - n - ) - - traces <- list( - list( - y = ~ROCR - ) - ) - ## splice:plotly-assembly:end - - plotly_object <- add_last_value_ly( - build_plotly( - init = plotly_init(), - traces = traces, - decorators = get0( - x = "decorators", - ifnotfound = list() - ), - name = get0( - x = "name", - ifnotfound = NULL - ), - data = constructed_indicator, - title = if (missing(title)) { - "Ratio of Change" - } else { - title - } - ), - data = constructed_indicator[, values_to_extract, drop = FALSE], - values_to_extract = values_to_extract - ) - - state <- .chart_state() - state$sub <- c(state$sub, list(plotly_object)) - - plotly_object -} - -#' @usage NULL -#' @aliases ratio_of_change -#' -#' @export -ratio_of_change.ggplot <- function( - x, - cols, - n = 10, - na.bridge = FALSE, - ## splice:optional-ggplot:start - ## splice:optional-ggplot:end - title, - ... -) { - ## check ggplot2 availability - assert_ggplot2() - - ## check that input value - ## 'cols' is a -objet - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series from - ## {ggplot}-object - constructed_series <- series( - x = x, - formula = cols, - default_formula = ~close, - ... - ) - - ## construct indicator - ## from the series - constructed_indicator <- ratio_of_change( - x = constructed_series, - cols = rebuild_formula( - names(constructed_series) - ), - n = n, - na.bridge = TRUE - ) - - ## the constructed indicator - ## always returns expected - ## columns which can be passed - ## down to add_last_value_gg() - values_to_extract <- colnames(constructed_indicator) - - ## add conditional idx - constructed_indicator[["idx"]] <- add_idx( - constructed_series - ) - - ## construct {ggplot2}-object - ## splice:ggplot-assembly:start - layers <- lapply( - setdiff(colnames(constructed_indicator), "idx"), - function(col) list(y = col) - ) - name <- sprintf("ROCR(%d)", n) - ## splice:ggplot-assembly:end - - ggplot_object <- add_last_value_gg( - build_ggplot( - init = ggplot_init(), - layers = layers, - decorators = get0( - x = "decorators", - ifnotfound = list() - ), - name = get0( - x = "name", - ifnotfound = NULL - ), - data = constructed_indicator, - title = if (missing(title)) { - "Ratio of Change" - } else { - title - } - ), - data = constructed_indicator[, values_to_extract, drop = FALSE], - values_to_extract = values_to_extract, - name = get0(x = "name", ifnotfound = NULL) - ) - - state <- .chart_state() - state$sub <- c(state$sub, list(ggplot_object)) - - ggplot_object -} diff --git a/R/ta_RSI.R b/R/ta_RSI.R index bae394305..39151f6dd 100644 --- a/R/ta_RSI.R +++ b/R/ta_RSI.R @@ -1,11 +1,11 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Relative Strength Index #' @templateVar .title Relative Strength Index #' @templateVar .author Serkan Korkmaz #' @templateVar .fun relative_strength_index -#' @templateVar .family Momentum Indicator +#' @templateVar .family Momentum Indicators #' @templateVar .formula ~close #' ## splice:documentation:start @@ -16,7 +16,7 @@ relative_strength_index <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ RSI <- relative_strength_index relative_strength_index.default <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -64,10 +64,8 @@ relative_strength_index.default <- function( ## return as data.frame x <- .Call( C_impl_ta_RSI, - ## splice:call:start constructed_series[[1]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -85,7 +83,7 @@ relative_strength_index.default <- function( relative_strength_index.data.frame <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -93,7 +91,7 @@ relative_strength_index.data.frame <- function( relative_strength_index.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -107,20 +105,32 @@ relative_strength_index.data.frame <- function( relative_strength_index.matrix <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { relative_strength_index.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +relative_strength_index_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_RSI_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases relative_strength_index #' @@ -128,7 +138,7 @@ relative_strength_index.matrix <- function( relative_strength_index.numeric <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -144,10 +154,8 @@ relative_strength_index.numeric <- function( ## to 'C' x <- .Call( C_impl_ta_RSI, - ## splice:numeric:start as.double(x), - as.integer(n), - ## splice:numeric:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -158,7 +166,6 @@ relative_strength_index.numeric <- function( x } - #' @usage NULL #' @aliases relative_strength_index #' @@ -166,7 +173,7 @@ relative_strength_index.numeric <- function( relative_strength_index.plotly <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ## splice:optional-plotly:start lower_bound = 20, @@ -201,7 +208,7 @@ relative_strength_index.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -220,7 +227,7 @@ relative_strength_index.plotly <- function( ## splice:plotly-assembly:start name <- sprintf( "RSI(%d)", - n + timePeriod ) decorators <- list( @@ -270,11 +277,11 @@ relative_strength_index.plotly <- function( relative_strength_index.ggplot <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -302,7 +309,7 @@ relative_strength_index.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -327,7 +334,7 @@ relative_strength_index.ggplot <- function( ggplot_line(80), list(y = "RSI") ) - name <- sprintf("RSI(%d)", n) + name <- sprintf("RSI(%d)", timePeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_SAR.R b/R/ta_SAR.R index 948915275..465124901 100644 --- a/R/ta_SAR.R +++ b/R/ta_SAR.R @@ -1,16 +1,14 @@ #' @export -#' @family Overlap Study +#' @family Overlap Studies #' -#' @title Parabolic Stop and Reverse (SAR) -#' @templateVar .title Parabolic Stop and Reverse (SAR) +#' @title Parabolic SAR +#' @templateVar .title Parabolic SAR #' @templateVar .author Serkan Korkmaz #' @templateVar .fun parabolic_stop_and_reverse -#' @templateVar .family Overlap Study -#' @templateVar .formula ~high+low +#' @templateVar .family Overlap Studies +#' @templateVar .formula ~high + low #' ## splice:documentation:start -#' @param acceleration ([double]). Acceleration factor used up to the maximum value. -#' @param maximum ([double]). Acceleration factor maximum value. ## splice:documentation:end #' #' @template description @@ -18,8 +16,8 @@ parabolic_stop_and_reverse <- function( x, cols, - acceleration = 0.02, - maximum = 0.2, + accelerationFactor = 0.02, + afMaximum = 0.2, na.bridge = FALSE, ... ) { @@ -40,8 +38,8 @@ SAR <- parabolic_stop_and_reverse parabolic_stop_and_reverse.default <- function( x, cols, - acceleration = 0.02, - maximum = 0.2, + accelerationFactor = 0.02, + afMaximum = 0.2, na.bridge = FALSE, ... ) { @@ -68,12 +66,10 @@ parabolic_stop_and_reverse.default <- function( ## return as data.frame x <- .Call( C_impl_ta_SAR, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], - as.double(acceleration), - as.double(maximum), - ## splice:call:end + as.double(accelerationFactor), + as.double(afMaximum), as.logical(na.bridge) ) @@ -91,8 +87,8 @@ parabolic_stop_and_reverse.default <- function( parabolic_stop_and_reverse.data.frame <- function( x, cols, - acceleration = 0.02, - maximum = 0.2, + accelerationFactor = 0.02, + afMaximum = 0.2, na.bridge = FALSE, ... ) { @@ -100,8 +96,8 @@ parabolic_stop_and_reverse.data.frame <- function( parabolic_stop_and_reverse.default( x = x, cols = cols, - acceleration = acceleration, - maximum = maximum, + accelerationFactor = accelerationFactor, + afMaximum = afMaximum, na.bridge = na.bridge, ... ) @@ -115,22 +111,36 @@ parabolic_stop_and_reverse.data.frame <- function( parabolic_stop_and_reverse.matrix <- function( x, cols, - acceleration = 0.02, - maximum = 0.2, + accelerationFactor = 0.02, + afMaximum = 0.2, na.bridge = FALSE, ... ) { parabolic_stop_and_reverse.default( x = x, cols = cols, - acceleration = acceleration, - maximum = maximum, + accelerationFactor = accelerationFactor, + afMaximum = afMaximum, na.bridge = na.bridge, ... ) } - +#' @usage NULL +parabolic_stop_and_reverse_lookback <- function( + x, + cols, + accelerationFactor = 0.02, + afMaximum = 0.2, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_SAR_lookback, + as.double(accelerationFactor), + as.double(afMaximum) + ) +} #' @usage NULL #' @aliases parabolic_stop_and_reverse #' @@ -138,8 +148,8 @@ parabolic_stop_and_reverse.matrix <- function( parabolic_stop_and_reverse.plotly <- function( x, cols, - acceleration = 0.02, - maximum = 0.2, + accelerationFactor = 0.02, + afMaximum = 0.2, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -171,8 +181,8 @@ parabolic_stop_and_reverse.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - acceleration = acceleration, - maximum = maximum, + accelerationFactor = accelerationFactor, + afMaximum = afMaximum, na.bridge = TRUE ) @@ -245,8 +255,8 @@ parabolic_stop_and_reverse.plotly <- function( parabolic_stop_and_reverse.ggplot <- function( x, cols, - acceleration = 0.02, - maximum = 0.2, + accelerationFactor = 0.02, + afMaximum = 0.2, na.bridge = FALSE, ## splice:optional-ggplot:start ## splice:optional-ggplot:end @@ -277,8 +287,8 @@ parabolic_stop_and_reverse.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - acceleration = acceleration, - maximum = maximum, + accelerationFactor = accelerationFactor, + afMaximum = afMaximum, na.bridge = TRUE ) diff --git a/R/ta_SAREXT.R b/R/ta_SAREXT.R index 36b24f643..6a137ba54 100644 --- a/R/ta_SAREXT.R +++ b/R/ta_SAREXT.R @@ -1,22 +1,14 @@ #' @export -#' @family Overlap Study +#' @family Overlap Studies #' -#' @title Parabolic Stop and Reverse (SAR) - Extended -#' @templateVar .title Parabolic Stop and Reverse (SAR) - Extended +#' @title Parabolic SAR - Extended +#' @templateVar .title Parabolic SAR - Extended #' @templateVar .author Serkan Korkmaz #' @templateVar .fun extended_parabolic_stop_and_reverse -#' @templateVar .family Overlap Study -#' @templateVar .formula ~high+low +#' @templateVar .family Overlap Studies +#' @templateVar .formula ~high + low #' ## splice:documentation:start -#' @param init ([double]). Start value and direction. 0 for Auto, >0 for Long, <0 for Short. -#' @param offset ([double]). Offset added/removed to initial stop on short/long reversal. -#' @param init_long ([double]). Acceleration factor initial value for the Long direction. -#' @param long ([double]). Acceleration factor for the Long direction. -#' @param max_long ([double]). Acceleration factor maximum value for the Long direction. -#' @param init_short ([double]). Acceleration factor initial value for the Short direction. -#' @param short ([double]). Acceleration factor for the Short direction. -#' @param max_short ([double]). Acceleration factor maximum value for the Short direction. ## splice:documentation:end #' #' @template description @@ -24,14 +16,14 @@ extended_parabolic_stop_and_reverse <- 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, + startValue = 0, + offsetOnReverse = 0, + afInitLong = 0.02, + afLong = 0.02, + afMaxLong = 0.2, + afInitShort = 0.02, + afShort = 0.02, + afMaxShort = 0.2, na.bridge = FALSE, ... ) { @@ -52,14 +44,14 @@ SAREXT <- extended_parabolic_stop_and_reverse extended_parabolic_stop_and_reverse.default <- 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, + startValue = 0, + offsetOnReverse = 0, + afInitLong = 0.02, + afLong = 0.02, + afMaxLong = 0.2, + afInitShort = 0.02, + afShort = 0.02, + afMaxShort = 0.2, na.bridge = FALSE, ... ) { @@ -86,18 +78,16 @@ extended_parabolic_stop_and_reverse.default <- function( ## return as data.frame x <- .Call( C_impl_ta_SAREXT, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], - init, - offset, - init_long, - long, - max_long, - init_short, - short, - max_short, - ## splice:call:end + as.double(startValue), + as.double(offsetOnReverse), + as.double(afInitLong), + as.double(afLong), + as.double(afMaxLong), + as.double(afInitShort), + as.double(afShort), + as.double(afMaxShort), as.logical(na.bridge) ) @@ -115,14 +105,14 @@ extended_parabolic_stop_and_reverse.default <- function( extended_parabolic_stop_and_reverse.data.frame <- 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, + startValue = 0, + offsetOnReverse = 0, + afInitLong = 0.02, + afLong = 0.02, + afMaxLong = 0.2, + afInitShort = 0.02, + afShort = 0.02, + afMaxShort = 0.2, na.bridge = FALSE, ... ) { @@ -130,14 +120,14 @@ extended_parabolic_stop_and_reverse.data.frame <- function( extended_parabolic_stop_and_reverse.default( x = x, cols = cols, - init = init, - offset = offset, - init_long = init_long, - long = long, - max_long = max_long, - init_short = init_short, - short = short, - max_short = max_short, + startValue = startValue, + offsetOnReverse = offsetOnReverse, + afInitLong = afInitLong, + afLong = afLong, + afMaxLong = afMaxLong, + afInitShort = afInitShort, + afShort = afShort, + afMaxShort = afMaxShort, na.bridge = na.bridge, ... ) @@ -151,34 +141,60 @@ extended_parabolic_stop_and_reverse.data.frame <- function( extended_parabolic_stop_and_reverse.matrix <- 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, + startValue = 0, + offsetOnReverse = 0, + afInitLong = 0.02, + afLong = 0.02, + afMaxLong = 0.2, + afInitShort = 0.02, + afShort = 0.02, + afMaxShort = 0.2, na.bridge = FALSE, ... ) { extended_parabolic_stop_and_reverse.default( x = x, cols = cols, - init = init, - offset = offset, - init_long = init_long, - long = long, - max_long = max_long, - init_short = init_short, - short = short, - max_short = max_short, + startValue = startValue, + offsetOnReverse = offsetOnReverse, + afInitLong = afInitLong, + afLong = afLong, + afMaxLong = afMaxLong, + afInitShort = afInitShort, + afShort = afShort, + afMaxShort = afMaxShort, na.bridge = na.bridge, ... ) } - +#' @usage NULL +extended_parabolic_stop_and_reverse_lookback <- function( + x, + cols, + startValue = 0, + offsetOnReverse = 0, + afInitLong = 0.02, + afLong = 0.02, + afMaxLong = 0.2, + afInitShort = 0.02, + afShort = 0.02, + afMaxShort = 0.2, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_SAREXT_lookback, + as.double(startValue), + as.double(offsetOnReverse), + as.double(afInitLong), + as.double(afLong), + as.double(afMaxLong), + as.double(afInitShort), + as.double(afShort), + as.double(afMaxShort) + ) +} #' @usage NULL #' @aliases extended_parabolic_stop_and_reverse #' @@ -186,14 +202,14 @@ extended_parabolic_stop_and_reverse.matrix <- function( extended_parabolic_stop_and_reverse.plotly <- 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, + startValue = 0, + offsetOnReverse = 0, + afInitLong = 0.02, + afLong = 0.02, + afMaxLong = 0.2, + afInitShort = 0.02, + afShort = 0.02, + afMaxShort = 0.2, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -225,14 +241,14 @@ extended_parabolic_stop_and_reverse.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - init = init, - offset = offset, - init_long = init_long, - long = long, - max_long = max_long, - init_short = init_short, - short = short, - max_short = max_short, + startValue = startValue, + offsetOnReverse = offsetOnReverse, + afInitLong = afInitLong, + afLong = afLong, + afMaxLong = afMaxLong, + afInitShort = afInitShort, + afShort = afShort, + afMaxShort = afMaxShort, na.bridge = TRUE ) @@ -305,14 +321,14 @@ extended_parabolic_stop_and_reverse.plotly <- function( extended_parabolic_stop_and_reverse.ggplot <- 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, + startValue = 0, + offsetOnReverse = 0, + afInitLong = 0.02, + afLong = 0.02, + afMaxLong = 0.2, + afInitShort = 0.02, + afShort = 0.02, + afMaxShort = 0.2, na.bridge = FALSE, ## splice:optional-ggplot:start ## splice:optional-ggplot:end @@ -343,14 +359,14 @@ extended_parabolic_stop_and_reverse.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - init = init, - offset = offset, - init_long = init_long, - long = long, - max_long = max_long, - init_short = init_short, - short = short, - max_short = max_short, + startValue = startValue, + offsetOnReverse = offsetOnReverse, + afInitLong = afInitLong, + afLong = afLong, + afMaxLong = afMaxLong, + afInitShort = afInitShort, + afShort = afShort, + afMaxShort = afMaxShort, na.bridge = TRUE ) diff --git a/R/ta_SMA.R b/R/ta_SMA.R index 6ae50eb3a..57ecbcfc1 100644 --- a/R/ta_SMA.R +++ b/R/ta_SMA.R @@ -1,11 +1,11 @@ #' @export -#' @family Overlap Study +#' @family Overlap Studies #' #' @title Simple Moving Average #' @templateVar .title Simple Moving Average #' @templateVar .author Serkan Korkmaz #' @templateVar .fun simple_moving_average -#' @templateVar .family Overlap Study +#' @templateVar .family Overlap Studies #' @templateVar .formula ~close #' ## splice:documentation:start @@ -22,7 +22,7 @@ simple_moving_average <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -33,13 +33,18 @@ simple_moving_average <- function( ## from call x <- structure( list( - n = if (missing(n)) 30L else as.integer(n), + timePeriod = if (missing(timePeriod)) { + 30L + } else { + as.integer(timePeriod) + }, maType = 0L ) ) return(x) } + UseMethod("simple_moving_average") } @@ -57,7 +62,7 @@ SMA <- simple_moving_average simple_moving_average.default <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -84,8 +89,8 @@ simple_moving_average.default <- function( ## return as data.frame x <- .Call( C_impl_ta_SMA, - as.double(constructed_series[[1]]), - as.integer(n), + constructed_series[[1]], + as.integer(timePeriod), as.logical(na.bridge) ) @@ -103,12 +108,18 @@ simple_moving_average.default <- function( simple_moving_average.data.frame <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { map_dfr( - NextMethod() + simple_moving_average.default( + x = x, + cols = cols, + timePeriod = timePeriod, + na.bridge = na.bridge, + ... + ) ) } @@ -119,17 +130,14 @@ simple_moving_average.data.frame <- function( simple_moving_average.matrix <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { - ## pass directly to - ## simple_moving_average.default to avoid - ## shenanigans with NextMethod() simple_moving_average.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -142,7 +150,7 @@ simple_moving_average.matrix <- function( simple_moving_average.numeric <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -159,7 +167,7 @@ simple_moving_average.numeric <- function( x <- .Call( C_impl_ta_SMA, as.double(x), - as.integer(n), + as.integer(timePeriod), as.logical(na.bridge) ) @@ -177,7 +185,7 @@ simple_moving_average.numeric <- function( simple_moving_average.plotly <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -207,7 +215,8 @@ simple_moving_average.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n + timePeriod = timePeriod, + na.bridge = TRUE ) ## add conditional idx @@ -230,15 +239,15 @@ simple_moving_average.plotly <- function( ) ) ), - name = label("SMA", n), - decorators = list() + name = label("SMA", timePeriod), + decorators = list(), + data = constructed_indicator ) state[["main"]] <- plotly_object plotly_object } - #' @usage NULL #' @aliases simple_moving_average #' @@ -246,7 +255,7 @@ simple_moving_average.plotly <- function( simple_moving_average.ggplot <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -275,7 +284,8 @@ simple_moving_average.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n + timePeriod = timePeriod, + na.bridge = TRUE ) ## add conditional idx @@ -292,7 +302,7 @@ simple_moving_average.ggplot <- function( y = "SMA" ) ), - name = label("SMA", n), + name = label("SMA", timePeriod), decorators = list(), data = constructed_indicator ) diff --git a/R/ta_STDDEV.R b/R/ta_STDDEV.R index 00288162a..838912306 100644 --- a/R/ta_STDDEV.R +++ b/R/ta_STDDEV.R @@ -1,21 +1,20 @@ #' @export -#' @family Rolling Statistic +#' @family Statistic Functions #' -#' @title Rolling Standard Deviation -#' @templateVar .title Rolling Standard Deviation +#' @title Standard Deviation +#' @templateVar .title Standard Deviation #' @templateVar .author Serkan Korkmaz #' @templateVar .fun rolling_standard_deviation #' ## splice:documentation:start -#' @param k ([double]). Multiplier for the standard deviation. ## splice:documentation:end #' #' @template rolling_description #' @template rolling_returns rolling_standard_deviation <- function( x, - n = 5, - k = 1, + timePeriod = 5, + deviations = 1, na.bridge = FALSE ) { UseMethod("rolling_standard_deviation") @@ -34,8 +33,8 @@ STDDEV <- rolling_standard_deviation #' @export rolling_standard_deviation.default <- function( x, - n = 5, - k = 1, + timePeriod = 5, + deviations = 1, na.bridge = FALSE ) { ## calculate indicator and @@ -44,8 +43,8 @@ rolling_standard_deviation.default <- function( C_impl_ta_STDDEV, ## splice:call:start as.double(x), - as.integer(n), - as.double(k), + as.integer(timePeriod), + as.double(deviations), ## splice:call:end as.logical(na.bridge) ) @@ -65,16 +64,16 @@ rolling_standard_deviation.default <- function( #' @export rolling_standard_deviation.numeric <- function( x, - n = 5, - k = 1, + timePeriod = 5, + deviations = 1, na.bridge = FALSE ) { ## calculate indicator and ## return as data.frame x <- rolling_standard_deviation.default( x = x, - n = n, - k = k, + timePeriod = timePeriod, + deviations = deviations, na.bridge = na.bridge ) diff --git a/R/ta_STOCH.R b/R/ta_STOCH.R index 735c6aa5d..0c9bfd3b5 100644 --- a/R/ta_STOCH.R +++ b/R/ta_STOCH.R @@ -1,17 +1,14 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Stochastic #' @templateVar .title Stochastic #' @templateVar .author Serkan Korkmaz #' @templateVar .fun stochastic -#' @templateVar .family Momentum Indicator -#' @templateVar .formula ~ high + low + close +#' @templateVar .family Momentum Indicators +#' @templateVar .formula ~high + low + close #' ## splice:documentation:start -#' @param fastk ([integer]). Period for the fast-k line. -#' @param slowk ([list]). Period and Moving Average (MA) type for the slow-k line. [SMA] by default. -#' @param slowd ([list]). Period and Moving Average (MA) type for the slow-d line. [SMA] by default. ## splice:documentation:end #' #' @template description @@ -19,9 +16,11 @@ stochastic <- function( x, cols, - fastk = 5, - slowk = SMA(n = 3), - slowd = SMA(n = 3), + fastKPeriod = 5, + slowKPeriod = 3, + slowKMa = 0, + slowDPeriod = 3, + slowDMa = 0, na.bridge = FALSE, ... ) { @@ -42,9 +41,11 @@ STOCH <- stochastic stochastic.default <- function( x, cols, - fastk = 5, - slowk = SMA(n = 3), - slowd = SMA(n = 3), + fastKPeriod = 5, + slowKPeriod = 3, + slowKMa = 0, + slowDPeriod = 3, + slowDMa = 0, na.bridge = FALSE, ... ) { @@ -71,16 +72,14 @@ stochastic.default <- function( ## return as data.frame x <- .Call( C_impl_ta_STOCH, - ## splice:call: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:call:end + as.integer(fastKPeriod), + as.integer(slowKPeriod), + as.integer(slowKMa), + as.integer(slowDPeriod), + as.integer(slowDMa), as.logical(na.bridge) ) @@ -98,9 +97,11 @@ stochastic.default <- function( stochastic.data.frame <- function( x, cols, - fastk = 5, - slowk = SMA(n = 3), - slowd = SMA(n = 3), + fastKPeriod = 5, + slowKPeriod = 3, + slowKMa = 0, + slowDPeriod = 3, + slowDMa = 0, na.bridge = FALSE, ... ) { @@ -108,9 +109,11 @@ stochastic.data.frame <- function( stochastic.default( x = x, cols = cols, - fastk = fastk, - slowk = slowk, - slowd = slowd, + fastKPeriod = fastKPeriod, + slowKPeriod = slowKPeriod, + slowKMa = slowKMa, + slowDPeriod = slowDPeriod, + slowDMa = slowDMa, na.bridge = na.bridge, ... ) @@ -124,24 +127,48 @@ stochastic.data.frame <- function( stochastic.matrix <- function( x, cols, - fastk = 5, - slowk = SMA(n = 3), - slowd = SMA(n = 3), + fastKPeriod = 5, + slowKPeriod = 3, + slowKMa = 0, + slowDPeriod = 3, + slowDMa = 0, na.bridge = FALSE, ... ) { stochastic.default( x = x, cols = cols, - fastk = fastk, - slowk = slowk, - slowd = slowd, + fastKPeriod = fastKPeriod, + slowKPeriod = slowKPeriod, + slowKMa = slowKMa, + slowDPeriod = slowDPeriod, + slowDMa = slowDMa, na.bridge = na.bridge, ... ) } - +#' @usage NULL +stochastic_lookback <- function( + x, + cols, + fastKPeriod = 5, + slowKPeriod = 3, + slowKMa = 0, + slowDPeriod = 3, + slowDMa = 0, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_STOCH_lookback, + as.integer(fastKPeriod), + as.integer(slowKPeriod), + as.integer(slowKMa), + as.integer(slowDPeriod), + as.integer(slowDMa) + ) +} #' @usage NULL #' @aliases stochastic #' @@ -149,9 +176,11 @@ stochastic.matrix <- function( stochastic.plotly <- function( x, cols, - fastk = 5, - slowk = SMA(n = 3), - slowd = SMA(n = 3), + fastKPeriod = 5, + slowKPeriod = 3, + slowKMa = 0, + slowDPeriod = 3, + slowDMa = 0, na.bridge = FALSE, ## splice:optional-plotly:start lower_bound = 20, @@ -186,9 +215,11 @@ stochastic.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - fastk = fastk, - slowk = slowk, - slowd = slowd, + fastKPeriod = fastKPeriod, + slowKPeriod = slowKPeriod, + slowKMa = slowKMa, + slowDPeriod = slowDPeriod, + slowDMa = slowDMa, na.bridge = TRUE ) @@ -207,7 +238,7 @@ stochastic.plotly <- function( ## splice:plotly-assembly:start name <- sprintf( "Stochastic(%d)", - fastk + fastKPeriod ) decorators <- list( @@ -258,13 +289,15 @@ stochastic.plotly <- function( stochastic.ggplot <- function( x, cols, - fastk = 5, - slowk = SMA(n = 3), - slowd = SMA(n = 3), + fastKPeriod = 5, + slowKPeriod = 3, + slowKMa = 0, + slowDPeriod = 3, + slowDMa = 0, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -292,9 +325,11 @@ stochastic.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - fastk = fastk, - slowk = slowk, - slowd = slowd, + fastKPeriod = fastKPeriod, + slowKPeriod = slowKPeriod, + slowKMa = slowKMa, + slowDPeriod = slowDPeriod, + slowDMa = slowDMa, na.bridge = TRUE ) @@ -320,7 +355,7 @@ stochastic.ggplot <- function( list(y = "SlowK"), list(y = "SlowD") ) - name <- sprintf("Stochastic(%d)", fastk) + name <- sprintf("Stochastic(%d)", fastKPeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_STOCHF.R b/R/ta_STOCHF.R index 77fe43ad0..e27d3adac 100644 --- a/R/ta_STOCHF.R +++ b/R/ta_STOCHF.R @@ -1,16 +1,14 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' -#' @title Fast Stochastic -#' @templateVar .title Fast Stochastic +#' @title Stochastic Fast +#' @templateVar .title Stochastic Fast #' @templateVar .author Serkan Korkmaz #' @templateVar .fun fast_stochastic -#' @templateVar .family Momentum Indicator -#' @templateVar .formula ~ high + low + close +#' @templateVar .family Momentum Indicators +#' @templateVar .formula ~high + low + close #' ## splice:documentation:start -#' @param fastk ([integer]). Period for the fast-k line. -#' @param fastd ([list]). Period and Moving Average (MA) type for the fast-d line. [SMA] by default. ## splice:documentation:end #' #' @template description @@ -18,8 +16,9 @@ fast_stochastic <- function( x, cols, - fastk = 5, - fastd = SMA(n = 3), + fastKPeriod = 5, + fastDPeriod = 3, + fastDMa = 0, na.bridge = FALSE, ... ) { @@ -40,8 +39,9 @@ STOCHF <- fast_stochastic fast_stochastic.default <- function( x, cols, - fastk = 5, - fastd = SMA(n = 3), + fastKPeriod = 5, + fastDPeriod = 3, + fastDMa = 0, na.bridge = FALSE, ... ) { @@ -68,14 +68,12 @@ fast_stochastic.default <- function( ## return as data.frame x <- .Call( C_impl_ta_STOCHF, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], - as.integer(fastk), - as.integer(fastd$n), - as.integer(fastd$maType), - ## splice:call:end + as.integer(fastKPeriod), + as.integer(fastDPeriod), + as.integer(fastDMa), as.logical(na.bridge) ) @@ -93,8 +91,9 @@ fast_stochastic.default <- function( fast_stochastic.data.frame <- function( x, cols, - fastk = 5, - fastd = SMA(n = 3), + fastKPeriod = 5, + fastDPeriod = 3, + fastDMa = 0, na.bridge = FALSE, ... ) { @@ -102,8 +101,9 @@ fast_stochastic.data.frame <- function( fast_stochastic.default( x = x, cols = cols, - fastk = fastk, - fastd = fastd, + fastKPeriod = fastKPeriod, + fastDPeriod = fastDPeriod, + fastDMa = fastDMa, na.bridge = na.bridge, ... ) @@ -117,22 +117,40 @@ fast_stochastic.data.frame <- function( fast_stochastic.matrix <- function( x, cols, - fastk = 5, - fastd = SMA(n = 3), + fastKPeriod = 5, + fastDPeriod = 3, + fastDMa = 0, na.bridge = FALSE, ... ) { fast_stochastic.default( x = x, cols = cols, - fastk = fastk, - fastd = fastd, + fastKPeriod = fastKPeriod, + fastDPeriod = fastDPeriod, + fastDMa = fastDMa, na.bridge = na.bridge, ... ) } - +#' @usage NULL +fast_stochastic_lookback <- function( + x, + cols, + fastKPeriod = 5, + fastDPeriod = 3, + fastDMa = 0, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_STOCHF_lookback, + as.integer(fastKPeriod), + as.integer(fastDPeriod), + as.integer(fastDMa) + ) +} #' @usage NULL #' @aliases fast_stochastic #' @@ -140,8 +158,9 @@ fast_stochastic.matrix <- function( fast_stochastic.plotly <- function( x, cols, - fastk = 5, - fastd = SMA(n = 3), + fastKPeriod = 5, + fastDPeriod = 3, + fastDMa = 0, na.bridge = FALSE, ## splice:optional-plotly:start lower_bound = 20, @@ -176,8 +195,9 @@ fast_stochastic.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - fastk = fastk, - fastd = fastd, + fastKPeriod = fastKPeriod, + fastDPeriod = fastDPeriod, + fastDMa = fastDMa, na.bridge = TRUE ) @@ -195,7 +215,7 @@ fast_stochastic.plotly <- function( ## construct {plotly}-object ## splice:plotly-assembly:start - name <- "" + name <- sprintf("StochF(%d)", fastKPeriod) decorators <- list( function(p) add_limit_ly(p, y_range = c(0, 100)) @@ -223,7 +243,7 @@ fast_stochastic.plotly <- function( ), data = constructed_indicator, title = if (missing(title)) { - "Fast Stochastic" + "Stochastic Fast" } else { title } @@ -245,12 +265,13 @@ fast_stochastic.plotly <- function( fast_stochastic.ggplot <- function( x, cols, - fastk = 5, - fastd = SMA(n = 3), + fastKPeriod = 5, + fastDPeriod = 3, + fastDMa = 0, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -278,8 +299,9 @@ fast_stochastic.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - fastk = fastk, - fastd = fastd, + fastKPeriod = fastKPeriod, + fastDPeriod = fastDPeriod, + fastDMa = fastDMa, na.bridge = TRUE ) @@ -305,7 +327,7 @@ fast_stochastic.ggplot <- function( list(y = "FastK"), list(y = "FastD") ) - name <- sprintf("StochF(%d)", fastk) + name <- sprintf("StochF(%d)", fastKPeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( @@ -322,7 +344,7 @@ fast_stochastic.ggplot <- function( ), data = constructed_indicator, title = if (missing(title)) { - "Fast Stochastic" + "Stochastic Fast" } else { title } diff --git a/R/ta_STOCHRSI.R b/R/ta_STOCHRSI.R index 0a92ac8a7..d25886bef 100644 --- a/R/ta_STOCHRSI.R +++ b/R/ta_STOCHRSI.R @@ -1,16 +1,14 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Stochastic Relative Strength Index #' @templateVar .title Stochastic Relative Strength Index #' @templateVar .author Serkan Korkmaz #' @templateVar .fun stochastic_relative_strength_index -#' @templateVar .family Momentum Indicator +#' @templateVar .family Momentum Indicators #' @templateVar .formula ~close #' ## splice:documentation:start -#' @param fastk ([integer]). Period for the fast-k line. -#' @param fastd ([list]). Period and Moving Average (MA) type for the fast-d line. [SMA] by default. ## splice:documentation:end #' #' @template description @@ -18,9 +16,10 @@ stochastic_relative_strength_index <- function( x, cols, - n = 14, - fastk = 5, - fastd = SMA(n = 3), + timePeriod = 14, + fastKPeriod = 5, + fastDPeriod = 3, + fastDMa = 0, na.bridge = FALSE, ... ) { @@ -41,9 +40,10 @@ STOCHRSI <- stochastic_relative_strength_index stochastic_relative_strength_index.default <- function( x, cols, - n = 14, - fastk = 5, - fastd = SMA(n = 3), + timePeriod = 14, + fastKPeriod = 5, + fastDPeriod = 3, + fastDMa = 0, na.bridge = FALSE, ... ) { @@ -70,13 +70,11 @@ stochastic_relative_strength_index.default <- function( ## return as data.frame x <- .Call( C_impl_ta_STOCHRSI, - ## splice:call:start constructed_series[[1]], - as.integer(n), - as.integer(fastk), - as.integer(fastd$n), - as.integer(fastd$maType), - ## splice:call:end + as.integer(timePeriod), + as.integer(fastKPeriod), + as.integer(fastDPeriod), + as.integer(fastDMa), as.logical(na.bridge) ) @@ -94,9 +92,10 @@ stochastic_relative_strength_index.default <- function( stochastic_relative_strength_index.data.frame <- function( x, cols, - n = 14, - fastk = 5, - fastd = SMA(n = 3), + timePeriod = 14, + fastKPeriod = 5, + fastDPeriod = 3, + fastDMa = 0, na.bridge = FALSE, ... ) { @@ -104,9 +103,10 @@ stochastic_relative_strength_index.data.frame <- function( stochastic_relative_strength_index.default( x = x, cols = cols, - n = n, - fastk = fastk, - fastd = fastd, + timePeriod = timePeriod, + fastKPeriod = fastKPeriod, + fastDPeriod = fastDPeriod, + fastDMa = fastDMa, na.bridge = na.bridge, ... ) @@ -120,24 +120,44 @@ stochastic_relative_strength_index.data.frame <- function( stochastic_relative_strength_index.matrix <- function( x, cols, - n = 14, - fastk = 5, - fastd = SMA(n = 3), + timePeriod = 14, + fastKPeriod = 5, + fastDPeriod = 3, + fastDMa = 0, na.bridge = FALSE, ... ) { stochastic_relative_strength_index.default( x = x, cols = cols, - n = n, - fastk = fastk, - fastd = fastd, + timePeriod = timePeriod, + fastKPeriod = fastKPeriod, + fastDPeriod = fastDPeriod, + fastDMa = fastDMa, na.bridge = na.bridge, ... ) } - +#' @usage NULL +stochastic_relative_strength_index_lookback <- function( + x, + cols, + timePeriod = 14, + fastKPeriod = 5, + fastDPeriod = 3, + fastDMa = 0, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_STOCHRSI_lookback, + as.integer(timePeriod), + as.integer(fastKPeriod), + as.integer(fastDPeriod), + as.integer(fastDMa) + ) +} #' @usage NULL #' @aliases stochastic_relative_strength_index #' @@ -145,9 +165,10 @@ stochastic_relative_strength_index.matrix <- function( stochastic_relative_strength_index.numeric <- function( x, cols, - n = 14, - fastk = 5, - fastd = SMA(n = 3), + timePeriod = 14, + fastKPeriod = 5, + fastDPeriod = 3, + fastDMa = 0, na.bridge = FALSE, ... ) { @@ -163,13 +184,11 @@ stochastic_relative_strength_index.numeric <- function( ## to 'C' x <- .Call( C_impl_ta_STOCHRSI, - ## splice:numeric:start as.double(x), - as.integer(n), - as.integer(fastk), - as.integer(fastd$n), - as.integer(fastd$maType), - ## splice:numeric:end + as.integer(timePeriod), + as.integer(fastKPeriod), + as.integer(fastDPeriod), + as.integer(fastDMa), as.logical(na.bridge) ) @@ -180,7 +199,6 @@ stochastic_relative_strength_index.numeric <- function( x } - #' @usage NULL #' @aliases stochastic_relative_strength_index #' @@ -188,9 +206,10 @@ stochastic_relative_strength_index.numeric <- function( stochastic_relative_strength_index.plotly <- function( x, cols, - n = 14, - fastk = 5, - fastd = SMA(n = 3), + timePeriod = 14, + fastKPeriod = 5, + fastDPeriod = 3, + fastDMa = 0, na.bridge = FALSE, ## splice:optional-plotly:start lower_bound = 20, @@ -225,9 +244,10 @@ stochastic_relative_strength_index.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, - fastk = fastk, - fastd = fastd, + timePeriod = timePeriod, + fastKPeriod = fastKPeriod, + fastDPeriod = fastDPeriod, + fastDMa = fastDMa, na.bridge = TRUE ) @@ -294,13 +314,14 @@ stochastic_relative_strength_index.plotly <- function( stochastic_relative_strength_index.ggplot <- function( x, cols, - n = 14, - fastk = 5, - fastd = SMA(n = 3), + timePeriod = 14, + fastKPeriod = 5, + fastDPeriod = 3, + fastDMa = 0, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -328,9 +349,10 @@ stochastic_relative_strength_index.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, - fastk = fastk, - fastd = fastd, + timePeriod = timePeriod, + fastKPeriod = fastKPeriod, + fastDPeriod = fastDPeriod, + fastDMa = fastDMa, na.bridge = TRUE ) diff --git a/R/ta_SUM.R b/R/ta_SUM.R deleted file mode 100644 index a80cfa32b..000000000 --- a/R/ta_SUM.R +++ /dev/null @@ -1,82 +0,0 @@ -#' @export -#' @family Rolling Statistic -#' -#' @title Rolling Sum -#' @templateVar .title Rolling Sum -#' @templateVar .author Serkan Korkmaz -#' @templateVar .fun rolling_sum -#' -## splice:documentation:start -## splice:documentation:end -#' -#' @template rolling_description -#' @template rolling_returns -rolling_sum <- function( - x, - n = 30, - na.bridge = FALSE -) { - UseMethod("rolling_sum") -} - -#' @export -#' @usage NULL -#' @rdname rolling_sum -#' -#' @aliases rolling_sum -SUM <- rolling_sum - -#' @usage NULL -#' @aliases rolling_sum -#' -#' @export -rolling_sum.default <- function( - x, - n = 30, - na.bridge = FALSE -) { - ## calculate indicator and - ## return as data.frame - x <- .Call( - C_impl_ta_SUM, - ## splice:call:start - as.double(x), - as.integer(n), - ## splice:call:end - as.logical(na.bridge) - ) - - ## strip dimensions - ## while preserving - ## attributes - dim(x) <- NULL - - ## return indicator - x -} - -#' @usage NULL -#' @aliases rolling_sum -#' -#' @export -rolling_sum.numeric <- function( - x, - n = 30, - na.bridge = FALSE -) { - ## calculate indicator and - ## return as data.frame - x <- rolling_sum.default( - x = x, - n = n, - na.bridge = na.bridge - ) - - ## strip dimensions - ## while preserving - ## attributes - dim(x) <- NULL - - ## return indicator - x -} diff --git a/R/ta_T3.R b/R/ta_T3.R index 8759ee27f..5ba155506 100644 --- a/R/ta_T3.R +++ b/R/ta_T3.R @@ -1,15 +1,14 @@ #' @export -#' @family Overlap Study +#' @family Overlap Studies #' #' @title Triple Exponential Moving Average (T3) #' @templateVar .title Triple Exponential Moving Average (T3) #' @templateVar .author Serkan Korkmaz #' @templateVar .fun t3_exponential_moving_average -#' @templateVar .family Overlap Study +#' @templateVar .family Overlap Studies #' @templateVar .formula ~close #' ## splice:documentation:start -#' @param vfactor ([double]). Volume Factor controlling the smoothing weight of the T3 curve. A [double] in `[0, 1]`: `0` collapses T3 to a standard triple EMA, larger values shift the curve closer to a DEMA. `0.7` by default, following Tillson (1998). ## splice:documentation:end #' #' @details @@ -23,8 +22,8 @@ t3_exponential_moving_average <- function( x, cols, - n = 5, - vfactor = 0.7, + timePeriod = 5, + volumeFactor = 0.7, na.bridge = FALSE, ... ) { @@ -35,14 +34,23 @@ t3_exponential_moving_average <- function( ## from call x <- structure( list( - n = if (missing(n)) 5L else as.integer(n), - vfactor = if (missing(vfactor)) 0.7 else as.double(vfactor), + timePeriod = if (missing(timePeriod)) { + 5L + } else { + as.integer(timePeriod) + }, + volumeFactor = if (missing(volumeFactor)) { + 0.7 + } else { + as.double(volumeFactor) + }, maType = 8L ) ) return(x) } + UseMethod("t3_exponential_moving_average") } @@ -60,8 +68,8 @@ T3 <- t3_exponential_moving_average t3_exponential_moving_average.default <- function( x, cols, - n = 5, - vfactor = 0.7, + timePeriod = 5, + volumeFactor = 0.7, na.bridge = FALSE, ... ) { @@ -88,9 +96,9 @@ t3_exponential_moving_average.default <- function( ## return as data.frame x <- .Call( C_impl_ta_T3, - as.double(constructed_series[[1]]), - as.integer(n), - as.double(vfactor), + constructed_series[[1]], + as.integer(timePeriod), + as.double(volumeFactor), as.logical(na.bridge) ) @@ -108,13 +116,20 @@ t3_exponential_moving_average.default <- function( t3_exponential_moving_average.data.frame <- function( x, cols, - n = 5, - vfactor = 0.7, + timePeriod = 5, + volumeFactor = 0.7, na.bridge = FALSE, ... ) { map_dfr( - NextMethod() + t3_exponential_moving_average.default( + x = x, + cols = cols, + timePeriod = timePeriod, + volumeFactor = volumeFactor, + na.bridge = na.bridge, + ... + ) ) } @@ -125,19 +140,16 @@ t3_exponential_moving_average.data.frame <- function( t3_exponential_moving_average.matrix <- function( x, cols, - n = 5, - vfactor = 0.7, + timePeriod = 5, + volumeFactor = 0.7, na.bridge = FALSE, ... ) { - ## pass directly to - ## t3_exponential_moving_average.default to avoid - ## shenanigans with NextMethod() t3_exponential_moving_average.default( x = x, cols = cols, - n = n, - vfactor = vfactor, + timePeriod = timePeriod, + volumeFactor = volumeFactor, na.bridge = na.bridge, ... ) @@ -150,8 +162,8 @@ t3_exponential_moving_average.matrix <- function( t3_exponential_moving_average.numeric <- function( x, cols, - n = 5, - vfactor = 0.7, + timePeriod = 5, + volumeFactor = 0.7, na.bridge = FALSE, ... ) { @@ -168,8 +180,8 @@ t3_exponential_moving_average.numeric <- function( x <- .Call( C_impl_ta_T3, as.double(x), - as.integer(n), - as.double(vfactor), + as.integer(timePeriod), + as.double(volumeFactor), as.logical(na.bridge) ) @@ -187,8 +199,8 @@ t3_exponential_moving_average.numeric <- function( t3_exponential_moving_average.plotly <- function( x, cols, - n = 5, - vfactor = 0.7, + timePeriod = 5, + volumeFactor = 0.7, na.bridge = FALSE, ... ) { @@ -218,8 +230,9 @@ t3_exponential_moving_average.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, - vfactor = vfactor + timePeriod = timePeriod, + volumeFactor = volumeFactor, + na.bridge = TRUE ) ## add conditional idx @@ -242,15 +255,15 @@ t3_exponential_moving_average.plotly <- function( ) ) ), - name = label("T3", n, vfactor), - decorators = list() + name = label("T3", timePeriod, volumeFactor), + decorators = list(), + data = constructed_indicator ) state[["main"]] <- plotly_object plotly_object } - #' @usage NULL #' @aliases t3_exponential_moving_average #' @@ -258,8 +271,8 @@ t3_exponential_moving_average.plotly <- function( t3_exponential_moving_average.ggplot <- function( x, cols, - n = 5, - vfactor = 0.7, + timePeriod = 5, + volumeFactor = 0.7, na.bridge = FALSE, ... ) { @@ -288,8 +301,9 @@ t3_exponential_moving_average.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, - vfactor = vfactor + timePeriod = timePeriod, + volumeFactor = volumeFactor, + na.bridge = TRUE ) ## add conditional idx @@ -306,7 +320,7 @@ t3_exponential_moving_average.ggplot <- function( y = "T3" ) ), - name = label("T3", n, vfactor), + name = label("T3", timePeriod, volumeFactor), decorators = list(), data = constructed_indicator ) diff --git a/R/ta_TEMA.R b/R/ta_TEMA.R index 31ee465cd..e5cc430ce 100644 --- a/R/ta_TEMA.R +++ b/R/ta_TEMA.R @@ -1,11 +1,11 @@ #' @export -#' @family Overlap Study +#' @family Overlap Studies #' #' @title Triple Exponential Moving Average #' @templateVar .title Triple Exponential Moving Average #' @templateVar .author Serkan Korkmaz #' @templateVar .fun triple_exponential_moving_average -#' @templateVar .family Overlap Study +#' @templateVar .family Overlap Studies #' @templateVar .formula ~close #' ## splice:documentation:start @@ -22,7 +22,7 @@ triple_exponential_moving_average <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -33,13 +33,18 @@ triple_exponential_moving_average <- function( ## from call x <- structure( list( - n = if (missing(n)) 30L else as.integer(n), + timePeriod = if (missing(timePeriod)) { + 30L + } else { + as.integer(timePeriod) + }, maType = 4L ) ) return(x) } + UseMethod("triple_exponential_moving_average") } @@ -57,7 +62,7 @@ TEMA <- triple_exponential_moving_average triple_exponential_moving_average.default <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -84,8 +89,8 @@ triple_exponential_moving_average.default <- function( ## return as data.frame x <- .Call( C_impl_ta_TEMA, - as.double(constructed_series[[1]]), - as.integer(n), + constructed_series[[1]], + as.integer(timePeriod), as.logical(na.bridge) ) @@ -103,12 +108,18 @@ triple_exponential_moving_average.default <- function( triple_exponential_moving_average.data.frame <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { map_dfr( - NextMethod() + triple_exponential_moving_average.default( + x = x, + cols = cols, + timePeriod = timePeriod, + na.bridge = na.bridge, + ... + ) ) } @@ -119,17 +130,14 @@ triple_exponential_moving_average.data.frame <- function( triple_exponential_moving_average.matrix <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { - ## pass directly to - ## triple_exponential_moving_average.default to avoid - ## shenanigans with NextMethod() triple_exponential_moving_average.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -142,7 +150,7 @@ triple_exponential_moving_average.matrix <- function( triple_exponential_moving_average.numeric <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -159,7 +167,7 @@ triple_exponential_moving_average.numeric <- function( x <- .Call( C_impl_ta_TEMA, as.double(x), - as.integer(n), + as.integer(timePeriod), as.logical(na.bridge) ) @@ -177,7 +185,7 @@ triple_exponential_moving_average.numeric <- function( triple_exponential_moving_average.plotly <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -207,7 +215,8 @@ triple_exponential_moving_average.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n + timePeriod = timePeriod, + na.bridge = TRUE ) ## add conditional idx @@ -230,15 +239,15 @@ triple_exponential_moving_average.plotly <- function( ) ) ), - name = label("TEMA", n), - decorators = list() + name = label("TEMA", timePeriod), + decorators = list(), + data = constructed_indicator ) state[["main"]] <- plotly_object plotly_object } - #' @usage NULL #' @aliases triple_exponential_moving_average #' @@ -246,7 +255,7 @@ triple_exponential_moving_average.plotly <- function( triple_exponential_moving_average.ggplot <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -275,7 +284,8 @@ triple_exponential_moving_average.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n + timePeriod = timePeriod, + na.bridge = TRUE ) ## add conditional idx @@ -292,7 +302,7 @@ triple_exponential_moving_average.ggplot <- function( y = "TEMA" ) ), - name = label("TEMA", n), + name = label("TEMA", timePeriod), decorators = list(), data = constructed_indicator ) diff --git a/R/ta_TRANGE.R b/R/ta_TRANGE.R index 943ca796c..8d50cde8b 100644 --- a/R/ta_TRANGE.R +++ b/R/ta_TRANGE.R @@ -1,11 +1,11 @@ #' @export -#' @family Volatility Indicator +#' @family Volatility Indicators #' #' @title True Range #' @templateVar .title True Range #' @templateVar .author Serkan Korkmaz #' @templateVar .fun true_range -#' @templateVar .family Volatility Indicator +#' @templateVar .family Volatility Indicators #' @templateVar .formula ~high + low + close #' ## splice:documentation:start @@ -62,11 +62,9 @@ true_range.default <- function( ## return as data.frame x <- .Call( C_impl_ta_TRANGE, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], - ## splice:call:end as.logical(na.bridge) ) @@ -115,7 +113,17 @@ true_range.matrix <- function( ) } - +#' @usage NULL +true_range_lookback <- function( + x, + cols, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_TRANGE_lookback + ) +} #' @usage NULL #' @aliases true_range #' @@ -215,9 +223,9 @@ true_range.ggplot <- function( x, cols, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability diff --git a/R/ta_TRIMA.R b/R/ta_TRIMA.R index 17b855f23..0d0eca7ce 100644 --- a/R/ta_TRIMA.R +++ b/R/ta_TRIMA.R @@ -1,11 +1,11 @@ #' @export -#' @family Overlap Study +#' @family Overlap Studies #' #' @title Triangular Moving Average #' @templateVar .title Triangular Moving Average #' @templateVar .author Serkan Korkmaz #' @templateVar .fun triangular_moving_average -#' @templateVar .family Overlap Study +#' @templateVar .family Overlap Studies #' @templateVar .formula ~close #' ## splice:documentation:start @@ -22,7 +22,7 @@ triangular_moving_average <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -33,13 +33,18 @@ triangular_moving_average <- function( ## from call x <- structure( list( - n = if (missing(n)) 30L else as.integer(n), + timePeriod = if (missing(timePeriod)) { + 30L + } else { + as.integer(timePeriod) + }, maType = 5L ) ) return(x) } + UseMethod("triangular_moving_average") } @@ -57,7 +62,7 @@ TRIMA <- triangular_moving_average triangular_moving_average.default <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -84,8 +89,8 @@ triangular_moving_average.default <- function( ## return as data.frame x <- .Call( C_impl_ta_TRIMA, - as.double(constructed_series[[1]]), - as.integer(n), + constructed_series[[1]], + as.integer(timePeriod), as.logical(na.bridge) ) @@ -103,12 +108,18 @@ triangular_moving_average.default <- function( triangular_moving_average.data.frame <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { map_dfr( - NextMethod() + triangular_moving_average.default( + x = x, + cols = cols, + timePeriod = timePeriod, + na.bridge = na.bridge, + ... + ) ) } @@ -119,17 +130,14 @@ triangular_moving_average.data.frame <- function( triangular_moving_average.matrix <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { - ## pass directly to - ## triangular_moving_average.default to avoid - ## shenanigans with NextMethod() triangular_moving_average.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -142,7 +150,7 @@ triangular_moving_average.matrix <- function( triangular_moving_average.numeric <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -159,7 +167,7 @@ triangular_moving_average.numeric <- function( x <- .Call( C_impl_ta_TRIMA, as.double(x), - as.integer(n), + as.integer(timePeriod), as.logical(na.bridge) ) @@ -177,7 +185,7 @@ triangular_moving_average.numeric <- function( triangular_moving_average.plotly <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -207,7 +215,8 @@ triangular_moving_average.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n + timePeriod = timePeriod, + na.bridge = TRUE ) ## add conditional idx @@ -230,15 +239,15 @@ triangular_moving_average.plotly <- function( ) ) ), - name = label("TRIMA", n), - decorators = list() + name = label("TRIMA", timePeriod), + decorators = list(), + data = constructed_indicator ) state[["main"]] <- plotly_object plotly_object } - #' @usage NULL #' @aliases triangular_moving_average #' @@ -246,7 +255,7 @@ triangular_moving_average.plotly <- function( triangular_moving_average.ggplot <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -275,7 +284,8 @@ triangular_moving_average.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n + timePeriod = timePeriod, + na.bridge = TRUE ) ## add conditional idx @@ -292,7 +302,7 @@ triangular_moving_average.ggplot <- function( y = "TRIMA" ) ), - name = label("TRIMA", n), + name = label("TRIMA", timePeriod), decorators = list(), data = constructed_indicator ) diff --git a/R/ta_TRIX.R b/R/ta_TRIX.R index 425cdc49a..a6c4a8fca 100644 --- a/R/ta_TRIX.R +++ b/R/ta_TRIX.R @@ -1,11 +1,11 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' -#' @title Triple Exponential Average -#' @templateVar .title Triple Exponential Average +#' @title 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA +#' @templateVar .title 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA #' @templateVar .author Serkan Korkmaz #' @templateVar .fun triple_exponential_average -#' @templateVar .family Momentum Indicator +#' @templateVar .family Momentum Indicators #' @templateVar .formula ~close #' ## splice:documentation:start @@ -16,7 +16,7 @@ triple_exponential_average <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ TRIX <- triple_exponential_average triple_exponential_average.default <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -64,10 +64,8 @@ triple_exponential_average.default <- function( ## return as data.frame x <- .Call( C_impl_ta_TRIX, - ## splice:call:start constructed_series[[1]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -85,7 +83,7 @@ triple_exponential_average.default <- function( triple_exponential_average.data.frame <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -93,7 +91,7 @@ triple_exponential_average.data.frame <- function( triple_exponential_average.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -107,20 +105,32 @@ triple_exponential_average.data.frame <- function( triple_exponential_average.matrix <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { triple_exponential_average.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +triple_exponential_average_lookback <- function( + x, + cols, + timePeriod = 30, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_TRIX_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases triple_exponential_average #' @@ -128,7 +138,7 @@ triple_exponential_average.matrix <- function( triple_exponential_average.numeric <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -144,10 +154,8 @@ triple_exponential_average.numeric <- function( ## to 'C' x <- .Call( C_impl_ta_TRIX, - ## splice:numeric:start as.double(x), - as.integer(n), - ## splice:numeric:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -158,7 +166,6 @@ triple_exponential_average.numeric <- function( x } - #' @usage NULL #' @aliases triple_exponential_average #' @@ -166,7 +173,7 @@ triple_exponential_average.numeric <- function( triple_exponential_average.plotly <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -199,7 +206,7 @@ triple_exponential_average.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -216,7 +223,7 @@ triple_exponential_average.plotly <- function( ## construct {plotly}-object ## splice:plotly-assembly:start - name <- sprintf("TRIX(%d)", n) + name <- sprintf("TRIX(%d)", timePeriod) decorators <- list() traces <- list( list(y = ~TRIX) @@ -237,7 +244,7 @@ triple_exponential_average.plotly <- function( ), data = constructed_indicator, title = if (missing(title)) { - "Triple Exponential Average" + "1-day Rate-Of-Change (ROC) of a Triple Smooth EMA" } else { title } @@ -259,11 +266,11 @@ triple_exponential_average.plotly <- function( triple_exponential_average.ggplot <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -291,7 +298,7 @@ triple_exponential_average.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -312,7 +319,7 @@ triple_exponential_average.ggplot <- function( setdiff(colnames(constructed_indicator), "idx"), function(col) list(y = col) ) - name <- sprintf("TRIX(%d)", n) + name <- sprintf("TRIX(%d)", timePeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( @@ -329,7 +336,7 @@ triple_exponential_average.ggplot <- function( ), data = constructed_indicator, title = if (missing(title)) { - "Triple Exponential Average" + "1-day Rate-Of-Change (ROC) of a Triple Smooth EMA" } else { title } diff --git a/R/ta_MAX.R b/R/ta_TSF.R similarity index 64% rename from R/ta_MAX.R rename to R/ta_TSF.R index 6545e8596..186b3e83f 100644 --- a/R/ta_MAX.R +++ b/R/ta_TSF.R @@ -1,47 +1,47 @@ #' @export -#' @family Rolling Statistic +#' @family Statistic Functions #' -#' @title Rolling Max -#' @templateVar .title Rolling Max +#' @title Time Series Forecast +#' @templateVar .title Time Series Forecast #' @templateVar .author Serkan Korkmaz -#' @templateVar .fun rolling_max +#' @templateVar .fun TSF #' ## splice:documentation:start ## splice:documentation:end #' #' @template rolling_description #' @template rolling_returns -rolling_max <- function( +TSF <- function( x, - n = 30, + timePeriod = 14, na.bridge = FALSE ) { - UseMethod("rolling_max") + UseMethod("TSF") } #' @export #' @usage NULL -#' @rdname rolling_max +#' @rdname TSF #' -#' @aliases rolling_max -MAX <- rolling_max +#' @aliases TSF +TSF <- TSF #' @usage NULL -#' @aliases rolling_max +#' @aliases TSF #' #' @export -rolling_max.default <- function( +TSF.default <- function( x, - n = 30, + timePeriod = 14, na.bridge = FALSE ) { ## calculate indicator and ## return as data.frame x <- .Call( - C_impl_ta_MAX, + C_impl_ta_TSF, ## splice:call:start as.double(x), - as.integer(n), + as.integer(timePeriod), ## splice:call:end as.logical(na.bridge) ) @@ -56,19 +56,19 @@ rolling_max.default <- function( } #' @usage NULL -#' @aliases rolling_max +#' @aliases TSF #' #' @export -rolling_max.numeric <- function( +TSF.numeric <- function( x, - n = 30, + timePeriod = 14, na.bridge = FALSE ) { ## calculate indicator and ## return as data.frame - x <- rolling_max.default( + x <- TSF.default( x = x, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge ) diff --git a/R/ta_TYPPRICE.R b/R/ta_TYPPRICE.R index a1628d57f..f090a98a8 100644 --- a/R/ta_TYPPRICE.R +++ b/R/ta_TYPPRICE.R @@ -62,11 +62,9 @@ typical_price.default <- function( ## return as data.frame x <- .Call( C_impl_ta_TYPPRICE, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], - ## splice:call:end as.logical(na.bridge) ) @@ -114,3 +112,15 @@ typical_price.matrix <- function( ... ) } + +#' @usage NULL +typical_price_lookback <- function( + x, + cols, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_TYPPRICE_lookback + ) +} diff --git a/R/ta_ULTOSC.R b/R/ta_ULTOSC.R index b9792b5b9..7032ef124 100644 --- a/R/ta_ULTOSC.R +++ b/R/ta_ULTOSC.R @@ -1,12 +1,12 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' #' @title Ultimate Oscillator #' @templateVar .title Ultimate Oscillator #' @templateVar .author Serkan Korkmaz #' @templateVar .fun ultimate_oscillator -#' @templateVar .family Momentum Indicator -#' @templateVar .formula ~ high + low + close +#' @templateVar .family Momentum Indicators +#' @templateVar .formula ~high + low + close #' ## splice:documentation:start ## splice:documentation:end @@ -16,7 +16,9 @@ ultimate_oscillator <- function( x, cols, - n = c(7, 14, 28), + firstPeriod = 7, + secondPeriod = 14, + thirdPeriod = 28, na.bridge = FALSE, ... ) { @@ -37,7 +39,9 @@ ULTOSC <- ultimate_oscillator ultimate_oscillator.default <- function( x, cols, - n = c(7, 14, 28), + firstPeriod = 7, + secondPeriod = 14, + thirdPeriod = 28, na.bridge = FALSE, ... ) { @@ -64,14 +68,12 @@ ultimate_oscillator.default <- function( ## return as data.frame x <- .Call( C_impl_ta_ULTOSC, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], - as.integer(n[1]), - as.integer(n[2]), - as.integer(n[3]), - ## splice:call:end + as.integer(firstPeriod), + as.integer(secondPeriod), + as.integer(thirdPeriod), as.logical(na.bridge) ) @@ -89,7 +91,9 @@ ultimate_oscillator.default <- function( ultimate_oscillator.data.frame <- function( x, cols, - n = c(7, 14, 28), + firstPeriod = 7, + secondPeriod = 14, + thirdPeriod = 28, na.bridge = FALSE, ... ) { @@ -97,7 +101,9 @@ ultimate_oscillator.data.frame <- function( ultimate_oscillator.default( x = x, cols = cols, - n = n, + firstPeriod = firstPeriod, + secondPeriod = secondPeriod, + thirdPeriod = thirdPeriod, na.bridge = na.bridge, ... ) @@ -111,20 +117,40 @@ ultimate_oscillator.data.frame <- function( ultimate_oscillator.matrix <- function( x, cols, - n = c(7, 14, 28), + firstPeriod = 7, + secondPeriod = 14, + thirdPeriod = 28, na.bridge = FALSE, ... ) { ultimate_oscillator.default( x = x, cols = cols, - n = n, + firstPeriod = firstPeriod, + secondPeriod = secondPeriod, + thirdPeriod = thirdPeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +ultimate_oscillator_lookback <- function( + x, + cols, + firstPeriod = 7, + secondPeriod = 14, + thirdPeriod = 28, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_ULTOSC_lookback, + as.integer(firstPeriod), + as.integer(secondPeriod), + as.integer(thirdPeriod) + ) +} #' @usage NULL #' @aliases ultimate_oscillator #' @@ -132,7 +158,9 @@ ultimate_oscillator.matrix <- function( ultimate_oscillator.plotly <- function( x, cols, - n = c(7, 14, 28), + firstPeriod = 7, + secondPeriod = 14, + thirdPeriod = 28, na.bridge = FALSE, ## splice:optional-plotly:start lower_bound = 30, @@ -167,7 +195,9 @@ ultimate_oscillator.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + firstPeriod = firstPeriod, + secondPeriod = secondPeriod, + thirdPeriod = thirdPeriod, na.bridge = TRUE ) @@ -186,9 +216,9 @@ ultimate_oscillator.plotly <- function( ## splice:plotly-assembly:start name <- sprintf( "UltOsc(%d, %d, %d)", - n[1], - n[2], - n[3] + firstPeriod, + secondPeriod, + thirdPeriod ) decorators <- list( @@ -238,11 +268,13 @@ ultimate_oscillator.plotly <- function( ultimate_oscillator.ggplot <- function( x, cols, - n = c(7, 14, 28), + firstPeriod = 7, + secondPeriod = 14, + thirdPeriod = 28, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -270,7 +302,9 @@ ultimate_oscillator.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + firstPeriod = firstPeriod, + secondPeriod = secondPeriod, + thirdPeriod = thirdPeriod, na.bridge = TRUE ) @@ -291,7 +325,12 @@ ultimate_oscillator.ggplot <- function( setdiff(colnames(constructed_indicator), "idx"), function(col) list(y = col) ) - name <- sprintf("UltOsc(%d, %d, %d)", n[1], n[2], n[3]) + name <- sprintf( + "UltOsc(%d, %d, %d)", + firstPeriod, + secondPeriod, + thirdPeriod + ) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( diff --git a/R/ta_VAR.R b/R/ta_VAR.R index c6b435430..21ad4d1ab 100644 --- a/R/ta_VAR.R +++ b/R/ta_VAR.R @@ -1,21 +1,20 @@ #' @export -#' @family Rolling Statistic +#' @family Statistic Functions #' -#' @title Rolling Standard Deviation -#' @templateVar .title Rolling Standard Deviation +#' @title Variance +#' @templateVar .title Variance #' @templateVar .author Serkan Korkmaz #' @templateVar .fun rolling_variance #' ## splice:documentation:start -#' @param k multiplier ## splice:documentation:end #' #' @template rolling_description #' @template rolling_returns rolling_variance <- function( x, - n = 5, - k = 1, + timePeriod = 5, + deviations = 1, na.bridge = FALSE ) { UseMethod("rolling_variance") @@ -34,8 +33,8 @@ VAR <- rolling_variance #' @export rolling_variance.default <- function( x, - n = 5, - k = 1, + timePeriod = 5, + deviations = 1, na.bridge = FALSE ) { ## calculate indicator and @@ -44,8 +43,8 @@ rolling_variance.default <- function( C_impl_ta_VAR, ## splice:call:start as.double(x), - as.integer(n), - as.double(k), + as.integer(timePeriod), + as.double(deviations), ## splice:call:end as.logical(na.bridge) ) @@ -65,16 +64,16 @@ rolling_variance.default <- function( #' @export rolling_variance.numeric <- function( x, - n = 5, - k = 1, + timePeriod = 5, + deviations = 1, na.bridge = FALSE ) { ## calculate indicator and ## return as data.frame x <- rolling_variance.default( x = x, - n = n, - k = k, + timePeriod = timePeriod, + deviations = deviations, na.bridge = na.bridge ) diff --git a/R/ta_VOLUME.R b/R/ta_VOLUME.R index bff358c05..2ffa45799 100644 --- a/R/ta_VOLUME.R +++ b/R/ta_VOLUME.R @@ -1,5 +1,5 @@ #' @export -#' @family Volume Indicator +#' @family Volume Indicators #' #' @title Trading Volume #' @templateVar .title Trading Volume diff --git a/R/ta_WCLPRICE.R b/R/ta_WCLPRICE.R index f0e20bbfe..a77e712f1 100644 --- a/R/ta_WCLPRICE.R +++ b/R/ta_WCLPRICE.R @@ -62,11 +62,9 @@ weighted_close_price.default <- function( ## return as data.frame x <- .Call( C_impl_ta_WCLPRICE, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], - ## splice:call:end as.logical(na.bridge) ) @@ -114,3 +112,15 @@ weighted_close_price.matrix <- function( ... ) } + +#' @usage NULL +weighted_close_price_lookback <- function( + x, + cols, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_WCLPRICE_lookback + ) +} diff --git a/R/ta_WILLR.R b/R/ta_WILLR.R index 21c0a78de..11c4759b0 100644 --- a/R/ta_WILLR.R +++ b/R/ta_WILLR.R @@ -1,12 +1,12 @@ #' @export -#' @family Momentum Indicator +#' @family Momentum Indicators #' -#' @title Williams %R -#' @templateVar .title Williams %R +#' @title Williams' %R +#' @templateVar .title Williams' %R #' @templateVar .author Serkan Korkmaz #' @templateVar .fun williams_oscillator -#' @templateVar .family Momentum Indicator -#' @templateVar .formula ~ high + low + close +#' @templateVar .family Momentum Indicators +#' @templateVar .formula ~high + low + close #' ## splice:documentation:start ## splice:documentation:end @@ -16,7 +16,7 @@ williams_oscillator <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -37,7 +37,7 @@ WILLR <- williams_oscillator williams_oscillator.default <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -64,12 +64,10 @@ williams_oscillator.default <- function( ## return as data.frame x <- .Call( C_impl_ta_WILLR, - ## splice:call:start constructed_series[[1]], constructed_series[[2]], constructed_series[[3]], - as.integer(n), - ## splice:call:end + as.integer(timePeriod), as.logical(na.bridge) ) @@ -87,7 +85,7 @@ williams_oscillator.default <- function( williams_oscillator.data.frame <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { @@ -95,7 +93,7 @@ williams_oscillator.data.frame <- function( williams_oscillator.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -109,20 +107,32 @@ williams_oscillator.data.frame <- function( williams_oscillator.matrix <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ... ) { williams_oscillator.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) } - +#' @usage NULL +williams_oscillator_lookback <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ... +) { + .Call( + C_impl_ta_WILLR_lookback, + as.integer(timePeriod) + ) +} #' @usage NULL #' @aliases williams_oscillator #' @@ -130,7 +140,7 @@ williams_oscillator.matrix <- function( williams_oscillator.plotly <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, ## splice:optional-plotly:start lower_bound = -20, @@ -165,7 +175,7 @@ williams_oscillator.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -182,7 +192,7 @@ williams_oscillator.plotly <- function( ## construct {plotly}-object ## splice:plotly-assembly:start - name <- paste0("Will %R(", n, ")") + name <- paste0("Will %R(", timePeriod, ")") decorators <- list( function(p) add_limit_ly(p, y_range = c(0, -100)) @@ -209,7 +219,7 @@ williams_oscillator.plotly <- function( ), data = constructed_indicator, title = if (missing(title)) { - "Williams %R" + "Williams' %R" } else { title } @@ -231,11 +241,11 @@ williams_oscillator.plotly <- function( williams_oscillator.ggplot <- function( x, cols, - n = 14, + timePeriod = 14, na.bridge = FALSE, + title, ## splice:optional-ggplot:start ## splice:optional-ggplot:end - title, ... ) { ## check ggplot2 availability @@ -263,7 +273,7 @@ williams_oscillator.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n, + timePeriod = timePeriod, na.bridge = TRUE ) @@ -288,7 +298,7 @@ williams_oscillator.ggplot <- function( ggplot_line(-80), list(y = "WILLR") ) - name <- sprintf("Will %%R(%d)", n) + name <- sprintf("Will %%R(%d)", timePeriod) ## splice:ggplot-assembly:end ggplot_object <- add_last_value_gg( @@ -305,7 +315,7 @@ williams_oscillator.ggplot <- function( ), data = constructed_indicator, title = if (missing(title)) { - "Williams %R" + "Williams' %R" } else { title } diff --git a/R/ta_WMA.R b/R/ta_WMA.R index 4a95fbe26..23da0abf8 100644 --- a/R/ta_WMA.R +++ b/R/ta_WMA.R @@ -1,11 +1,11 @@ #' @export -#' @family Overlap Study +#' @family Overlap Studies #' #' @title Weighted Moving Average #' @templateVar .title Weighted Moving Average #' @templateVar .author Serkan Korkmaz #' @templateVar .fun weighted_moving_average -#' @templateVar .family Overlap Study +#' @templateVar .family Overlap Studies #' @templateVar .formula ~close #' ## splice:documentation:start @@ -22,7 +22,7 @@ weighted_moving_average <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -33,13 +33,18 @@ weighted_moving_average <- function( ## from call x <- structure( list( - n = if (missing(n)) 30L else as.integer(n), + timePeriod = if (missing(timePeriod)) { + 30L + } else { + as.integer(timePeriod) + }, maType = 2L ) ) return(x) } + UseMethod("weighted_moving_average") } @@ -57,7 +62,7 @@ WMA <- weighted_moving_average weighted_moving_average.default <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -84,8 +89,8 @@ weighted_moving_average.default <- function( ## return as data.frame x <- .Call( C_impl_ta_WMA, - as.double(constructed_series[[1]]), - as.integer(n), + constructed_series[[1]], + as.integer(timePeriod), as.logical(na.bridge) ) @@ -103,12 +108,18 @@ weighted_moving_average.default <- function( weighted_moving_average.data.frame <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { map_dfr( - NextMethod() + weighted_moving_average.default( + x = x, + cols = cols, + timePeriod = timePeriod, + na.bridge = na.bridge, + ... + ) ) } @@ -119,17 +130,14 @@ weighted_moving_average.data.frame <- function( weighted_moving_average.matrix <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { - ## pass directly to - ## weighted_moving_average.default to avoid - ## shenanigans with NextMethod() weighted_moving_average.default( x = x, cols = cols, - n = n, + timePeriod = timePeriod, na.bridge = na.bridge, ... ) @@ -142,7 +150,7 @@ weighted_moving_average.matrix <- function( weighted_moving_average.numeric <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -159,7 +167,7 @@ weighted_moving_average.numeric <- function( x <- .Call( C_impl_ta_WMA, as.double(x), - as.integer(n), + as.integer(timePeriod), as.logical(na.bridge) ) @@ -177,7 +185,7 @@ weighted_moving_average.numeric <- function( weighted_moving_average.plotly <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -207,7 +215,8 @@ weighted_moving_average.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - n = n + timePeriod = timePeriod, + na.bridge = TRUE ) ## add conditional idx @@ -230,15 +239,15 @@ weighted_moving_average.plotly <- function( ) ) ), - name = label("WMA", n), - decorators = list() + name = label("WMA", timePeriod), + decorators = list(), + data = constructed_indicator ) state[["main"]] <- plotly_object plotly_object } - #' @usage NULL #' @aliases weighted_moving_average #' @@ -246,7 +255,7 @@ weighted_moving_average.plotly <- function( weighted_moving_average.ggplot <- function( x, cols, - n = 30, + timePeriod = 30, na.bridge = FALSE, ... ) { @@ -275,7 +284,8 @@ weighted_moving_average.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - n = n + timePeriod = timePeriod, + na.bridge = TRUE ) ## add conditional idx @@ -292,7 +302,7 @@ weighted_moving_average.ggplot <- function( y = "WMA" ) ), - name = label("WMA", n), + name = label("WMA", timePeriod), decorators = list(), data = constructed_indicator ) diff --git a/_pkgdown.yml b/_pkgdown.yml index 9725b704f..2f8a4f4f9 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -34,31 +34,31 @@ reference: Measure the speed and strength of price movements. Includes oscillators and rate-of-change indicators such as RSI, MACD, Stochastic, CCI, Williams %R, and ADX. -- contents: has_concept('Momentum Indicator') +- contents: has_concept('Momentum Indicators') - title: Overlap Studies desc: > Indicators plotted directly on the price chart. Moving averages (SMA, EMA, WMA, DEMA, TEMA, KAMA), Bollinger Bands, Parabolic SAR, and other trend-following overlays. -- contents: has_concept('Overlap Study') +- contents: has_concept('Overlap Studies') - title: Cycle Indicators desc: > Detect dominant market cycles in price data using Hilbert Transform methods. Estimate cycle period, phase, and the in-phase / quadrature components of the analytic signal. -- contents: has_concept('Cycle Indicator') +- contents: has_concept('Cycle Indicators') - title: Volume Indicators desc: > Analyze trading volume to confirm price trends and spot divergences. Includes On-Balance Volume (OBV), Chaikin A/D Line, and A/D Oscillator. -- contents: has_concept('Volume Indicator') +- contents: has_concept('Volume Indicators') - title: Volatility Indicators desc: > Quantify the degree of price variation over a given period. Includes Average True Range (ATR), Normalized ATR (NATR), and True Range (TRANGE). -- contents: has_concept('Volatility Indicator') +- contents: has_concept('Volatility Indicators') - title: Financial Charts desc: > Build interactive candlestick and OHLC charts with plotly. Layer @@ -70,7 +70,7 @@ reference: Compute rolling (moving-window) descriptive statistics over price or return series. Includes rolling variance, standard deviation, linear regression, and time series forecast. -- contents: has_concept('Rolling Statistic') +- contents: has_concept('Statistic Functions') - title: Price Transformations desc: > Transform raw OHLC prices into derived series. Average Price, diff --git a/codegen/README.md b/codegen/README.md index 9ae1858f6..2b8e20dfd 100644 --- a/codegen/README.md +++ b/codegen/README.md @@ -1,275 +1,322 @@ # codegen/ — Code Generation System -This directory contains the meta-programming infrastructure that generates -most of the R wrappers, C wrappers, and unit tests in the package. If you are -reading this because something broke, start at [Quick reference](#quick-reference) +This directory contains the Rust crate that generates most of the R wrappers, +the C binding header, and the unit tests in the package. If you are reading +this because something broke, start at [Quick reference](#quick-reference) and work backwards. ## Quick reference ``` -make gen-code # regenerate R/, src/ta_*.c, and tests/ from metadata -make build # also runs generate_API.sh + generate_FFI.sh -make fmt # format everything (air for R, clang-format for C) +make gen-code # cargo run: regenerate src/TA-Lib.h, R/ta_*.R, tests/ — then make fmt +make build # document + build + install the package +cargo test # unit tests of the generator itself (run from codegen/) ``` +The crate has **zero dependencies** and is driven entirely by three files +from the TA-Lib submodule: + +- `src/ta-lib/ta_func_api.xml` — machine-generated metadata for every + TA-Lib function (names, groups, inputs, optional inputs, outputs) +- `src/ta-lib/include/ta_func.h` + `src/ta-lib/ta_func_list.txt` — the C + prototypes, mined for the binding header + ## How the pieces fit together ``` -indicators.R All 128 indicator definitions (one list) - | - v -generate.R Loops over indicators, calls: - | - +---> utils.R impl_generate_indicator() - | | - | +---> generate_indicator.sh (envsubst on R templates) - | - +---> utils.R impl_generate_test() - | | - | +---> generate_unit-tests.sh (heredoc test files) - | - +---> generate_indicator_core.sh (parses ta_func.h, envsubst on C template; - candlesticks pass CANDLESTICK=1) +ta_func_list.txt + ta_func.h ta_func_api.xml + | | + v v + c_header.rs metadata.rs parse_api() -> Vec + | | + v v + src/TA-Lib.h render.rs render_indicator() + (TA_INDICATOR / TA_LOOKBACK | template dispatch + placeholder fill + X-macro lines, expanded by +--> preserve_regions() (splice) + src/wrapper.h and src/init.c) | + v + R/ta_.R + | + testthat.rs render_test() + | + v + tests/testthat/test-ta_.R ``` -After generation, `make fmt` runs `air format` (R) and `clang-format` (C) to -normalize style. +The exclusions in `tables.rs` filter both paths: excluded indicators get +neither a C wrapper nor an R wrapper. After generation, `make fmt` runs +`air format` (R) and `clang-format` (C) to normalize style. ## Directory layout ``` codegen/ - gen_code/ - indicators.R <- THE metadata: every indicator in one place - generate.R <- driver script (make gen-code calls this) - utils.R <- impl_generate_indicator(), impl_generate_test() + src/ + main.rs Driver: writes src/TA-Lib.h, then runs the + R + test generation loop (with splice preservation) + c_header.rs Mines TA_() / TA__Lookback() prototypes + from ta_func.h and renders the X-macro lines + metadata.rs XML mining: parse_api() -> Vec + render.rs The Templates struct, render_indicator(), the + dual-backend chart rendering (render_backend) + and preserve_regions() (splice) + testthat.rs testthat file generation + tables.rs The hand-maintained lookup tables: FUNCTION_NAMES + (BBANDS -> bollinger_bands), CHART_TYPES (Main + overlay vs Sub panel; absent = not chartable), + MOVING_AVERAGES (TA_MAType index, SMA = 0L), + AGNOSTIC_PATTERNS (fills ${AGNOSTIC}) and + EXCLUDED_INDICATORS / EXCLUDED_GROUPS templates/ - indicator_template.R.in Standard R wrapper (most indicators) - indicator_template.c.in Standard C wrapper (most indicators) - candlestick_template.R.in Candlestick pattern R wrapper - moving_average_template.R.in Moving average R wrapper (includes numeric + plotly) - rolling_template.R.in Rolling statistic R wrapper (simplified) - numeric_template.R.in Appended for univariate .numeric method - plotly_main_template.R.in Plotly method — main chart overlay - plotly_subchart_template.R.in Plotly method — subchart panel - ggplot_main_template.R.in ggplot2 method — main chart overlay - ggplot_subchart_template.R.in ggplot2 method — subchart panel - candlestick_ggplot_template.R.in ggplot2 method for candlesticks - moving_average_ggplot_template.R.in ggplot2 method for moving averages - generate_indicator.sh R template assembler (envsubst + splice) - generate_indicator_core.sh C code generator (parses ta_func.h headers; - candlesticks via CANDLESTICK=1) - generate_unit-tests.sh Test file generator - generate_API.sh Extracts SEXP prototypes → src/api.h - generate_FFI.sh Builds R_CallMethodDef table → src/init.c - validation/ - validate.R Smoke-tests: compares R output vs raw TA-Lib C calls - validate.c Reference C implementations for validation + indicator_template.R Standard R wrapper (most indicators) + numeric_template.R Appended .numeric method (univariate) + rolling_template.R Rolling statistics (Statistic Functions, + .numeric baked in, not plotable) + moving_average_template.R Moving averages (spec-mode, + .numeric baked in) + candlestick_template.R Candlestick patterns + chart_main_template.R Chart methods — main chart overlay + chart_subchart_template.R Chart methods — own subchart panel + chart_moving_average_template.R Chart methods — moving averages + chart_candlestick_template.R Chart methods — candlestick markers + parity/ + btc_to_csv.R, parity_gen.c, csv_to_rds.R, test_parity_template.R + Parity snapshots: R output vs raw TA-Lib C calls + (make parity-prepare; runs in make test / check) ``` -## Adding a new indicator - -1. **Add one line to `gen_code/indicators.R`** using the appropriate - constructor. Pick the constructor that matches the indicator family: - - | Constructor | Family | Notes | - |-----------------|----------------------|---------------------------------| - | `momentum()` | Momentum Indicator | Most common | - | `candlestick()` | Pattern Recognition | OHLC patterns, boolean output | - | `moving_avg()` | Overlap Study | Each MA gets its own `src/ta_.c` | - | `overlap()` | Overlap Study | Non-MA overlays (BBANDS, SAR) | - | `cycle()` | Cycle Indicator | Hilbert transforms | - | `price_xform()` | Price Transform | No charting, no subchart | - | `volume()` | Volume Indicator | | - | `volatility()` | Volatility Indicator | | - | `rolling()` | Rolling Statistic | Simplified template, no NA handling | +Each `chart_*_template.R` is **dual-backend**: one file describes both the +`.plotly` and the `.ggplot` method and is rendered once per backend (see +[Dual-backend chart templates](#dual-backend-chart-templates)). - Example — adding a new momentum indicator: +## The metadata source - ```r - momentum("Awesome Oscillator", "awesome_oscillator", "AO", - "~high + low", c("fast=5", "slow=34")) - ``` +`metadata::parse_api()` mines `ta_func_api.xml` into one `MetaData` per +``: -2. **Run `make gen-code`**. This generates: - - `R/ta_AO.R` — R wrapper with S3 methods - - `src/ta_AO.c` — C wrapper calling TA-Lib - - `tests/testthat/test-ta_AO.R` — unit tests +- **Required inputs** become column names: price types map to their OHLCV + column (`High` -> `high`), plain double arrays (`inReal`) default to + `close`. The deduplicated columns form `${FORMULA}` + (`~high + low + close`). +- **Optional inputs** become camelCase formals (`Fast-K Period` -> + `fastKPeriod`) with their XML defaults; doubles are reformatted from + scientific notation (`2.000000e-2` -> `0.02`). -3. **Check the splice regions** in the generated R file. If the indicator - needs custom `.Call()` arguments (e.g. constructed series columns), edit the - content between `## splice:call:start` and `## splice:call:end`. This - content is preserved across regenerations. +The outputs are not mined from the XML: the C side gets them from the +header prototypes (see [How C generation works](#how-c-generation-works)) +and the R side does not need them. -4. **Run `make build`** to rebuild (also regenerates `api.h` and `init.c`). +The XML is attribute-free and machine-generated, so the crate uses +hand-rolled `tag_blocks()`/`tag_text()` mining instead of an XML library. ## How R wrapper generation works -`generate_indicator.sh` is the core R assembler. It: - -1. **Receives metadata** as environment variables (`FUN`, `TA_FUN`, `FORMULA`, - `ARGS`, `PLOTLY`, `SUBCHART`, `CANDLESTICK`, `maType`, `ROLLING`, etc.) - and function arguments as positional parameters. - -2. **Selects the main template** based on flags: - - `CANDLESTICK=1` → `candlestick_template.R.in` - - `maType != -1` → `moving_average_template.R.in` - - `ROLLING != 0` → `rolling_template.R.in` - - Otherwise → `indicator_template.R.in` - -3. **Runs `envsubst`** to replace `${VAR}` placeholders in the template. - -4. **Appends optional templates** (if the indicator supports them): - - `numeric_template.R.in` — when `NUMERIC=1` (univariate formula) - - `plotly_*_template.R.in` — when `PLOTLY=1` - - `ggplot_*_template.R.in` — for charting support - -5. **Splices preserved content** from the existing output file. Any code - between `## splice:LABEL:start` and `## splice:LABEL:end` markers in the - current file on disk is re-inserted into the freshly generated version. - This is how hand-written `.Call()` arguments and documentation survive - regeneration. - -### Template variables - -The shell script constructs several argument-related variables from the -positional parameters (the `signature` field in the metadata): - -| Variable | Description | Example (`n=10,vfactor=0.7`) | -|-------------------|-----------------------------------------------|------------------------------------------| -| `${ARGS}` | Signature args with trailing comma | `n=10,vfactor=0.7,` | -| `${PARGS}` | Named forwarding: `key=key,` | `,n=n ,vfactor=vfactor ,` | -| `${CARGS}` | Bare names for `.Call()`: `,key` | `,n ,vfactor` | -| `${CARGS_TYPED}` | Type-coerced names (`as.integer`/`as.double`) | `,as.integer(n) ,as.double(vfactor)` | -| `${PPARGS}` | Named forwarding, no trailing comma (plotly) | `,n=n ,vfactor=vfactor` | -| `${SPEC_FIELDS}` | MA spec-mode list fields, one per signature arg | `n = if (missing(n)) 10L else as.integer(n),\n\t\t\t\tvfactor = if (missing(vfactor)) 0.7 else as.double(vfactor)` | - -## How C wrapper generation works - -### Standard indicators — `generate_indicator_core.sh` - -This 420-line bash script: - -1. **Locates `ta_func.h`** in the TA-Lib submodule headers. -2. **Extracts the `TA_(...)` prototype** using awk (skipping `TA__*` variants). -3. **Classifies each parameter** via regex: - - Input arrays (`const double inArray[]`) → `REAL()` extraction - - Input scalars (`int`, `double`, `TA_MAType`) → `INTEGER()[0]` / `REAL()[0]` - - Output arrays (`double outArray[]`) → allocated in output container - - Skip: `startIdx`, `endIdx`, `outBegIdx`, `outNBElement` (TA-Lib internals) -4. **Extracts the lookback function** `TA__Lookback(...)` parameters and - emits `$LOOKBACK_VALUES` — declarations for *only* the scalars that lookback - consumes (a subset of the main signature). The standalone - `impl_ta__lookback` therefore declares nothing it does not use, so it - compiles clean under `-Wall`/`-Wextra` (the unused input-array SEXP arguments - are tolerated by `-Wno-unused-parameter`). -5. **Exports 16+ environment variables** and runs `envsubst` on - `indicator_template.c.in`. -6. **Writes to stdout** — the caller redirects to `src/ta_.c`. - -### Candlestick patterns — `CANDLESTICK=1` - -Candlestick patterns (`TA_CDL*`) share the same generator and template. They -are ordinary indicators — four `double` OHLC inputs, an `int` output, an -optional `optInPenetration` scalar — plus two extras gated on the `CANDLESTICK` -env var (set by `generate.R` for entries whose `c_generator` is `"candlestick"`): - -1. a `flag` SEXP argument appended to the main signature, and -2. a post-processing block that normalizes the `[-200, 200]` integer output to - real values divided by `100` when `flag` is `TRUE` (`normalize_int_to_real`). - -### Moving averages - -Each MA type (SMA, EMA, WMA, DEMA, TEMA, TRIMA, KAMA, MAMA, T3) uses the -standard `generate_indicator_core.sh` path and gets its own per-function -`src/ta_.c` calling the TA-Lib entry point directly (e.g. `TA_SMA`, -`TA_MAMA`). The `moving_avg()` helper wires per-MA signatures and routes R -wrappers through `moving_average_template.R.in`, which retains the spec-mode -`missing(x)` branch so `SMA(n = 5)` still returns `list(n, maType)` for -downstream consumers (BBANDS, APO, PPO, MACDEXT, STOCH*). - -## How test generation works - -`generate_unit-tests.sh` writes test files using bash heredocs. Two paths: - -- **Rolling statistics** (`ROLLING=1`): 3 quick tests — runs without error, - length preservation, output type. -- **Everything else**: 10+ tests covering alias equivalence, class - preservation (matrix/data.frame), default formula, row names, NA handling, - and optionally plotly/ggplot/numeric methods. - -The `NUMERIC` environment variable controls whether a numeric-method test -block is appended. It is derived from the formula: if the formula references -exactly one column (e.g. `~close`), `NUMERIC=1`. +`render_indicator()` picks the templates per indicator: + +| Condition | Main template | Chart template | +|----------------------------------|-----------------------------|-----------------------------------| +| Abbreviation starts with `CDL` | `candlestick_template.R` | `chart_candlestick_template.R` | +| Listed in `MOVING_AVERAGES` | `moving_average_template.R` | `chart_moving_average_template.R` | +| GroupId `Statistic Functions` | `rolling_template.R` | — (not plotable) | +| Otherwise | `indicator_template.R` | `chart_main_template.R` or `chart_subchart_template.R` for indicators in `CHART_TYPES` | + +The standard path additionally appends `numeric_template.R` for univariate +indicators (a single input series); moving averages and rolling statistics +carry their own `.numeric` method inside their main template. + +The rendered output ends with **`strip_blank_indentation()`** — dropping +whitespace-only lines left behind by empty multi-entry placeholders (e.g. +the gap between `cols,` and `na.bridge` for argument-less indicators), +which `air` does not reformat away; truly empty separator lines are kept. +`main.rs` then applies **`preserve_regions()`** — splicing hand-edited +content from the existing file on disk back into the fresh render (see +[The splice mechanism](#the-splice-mechanism)). + +### Dual-backend chart templates + +Every chart method exists in a `.plotly` and a `.ggplot` variant that share +almost all of their body. Each `chart_*_template.R` therefore describes +both variants in one file; `render_backend()` renders it once per backend +(`.plotly` first). Backend divergences are expressed two ways: + +- **Backend placeholders**, filled per render: + + | Placeholder | plotly | ggplot | Used for | + |-------------|----------|----------|---------------------------------------------------| + | `${METHOD}` | `plotly` | `ggplot` | S3 class, `build_*`/`*_init` helpers, `*_object` locals, splice-region names | + | `${PKG}` | `plotly` | `ggplot2`| the package name in comments | + | `${SUFFIX}` | `ly` | `gg` | helper suffixes (`add_last_value_ly`, `pattern_gg`) | + +- **Conditional lines** for structurally different code: a line starting + with `#plotly#` or `#ggplot#` (column 0) is kept only when rendering + that backend, with the prefix stripped: + + ```r + #plotly# assert_plotly_object(x) + #ggplot# assert_ggplot2() + ``` + + A marker-shaped line that survives filtering (a typo'd prefix, an + unknown backend name) makes the render panic instead of shipping as a + do-nothing R comment. Note the subchart template's optional-formals + splice region is itself backend-conditional (the two backends order + `title` and the region differently), so template lines placed inside + those markers must carry the backend prefix too. + +### Template placeholders + +| Placeholder | Description | Example (BBANDS) | +|---------------------------|----------------------------------------------------|-----------------------------------------| +| `${FUN}` | snake_case R name (via `FUNCTION_NAMES`) | `bollinger_bands` | +| `${ALIAS}` | TA-Lib abbreviation (uppercase alias, C symbol) | `BBANDS` | +| `${TITLE}` | `` | `Bollinger Bands` | +| `${FAMILY}` | `` | `Overlap Studies` | +| `${FORMULA}` | Default column formula | `~close` | +| `${ARGS}` | Formals, one per line, trailing comma per entry | `timePeriod = 5,` | +| `${PARGS}` | Named forwarding, trailing comma per entry | `timePeriod = timePeriod,` | +| `${C_SIGNATURE}` | `.Call()` args: series columns + coerced formals | `constructed_series[[1]],\n as.integer(timePeriod), ...` | +| `${C_NUMERIC}` | `.Call()` args of the numeric/rolling path | `as.double(x),\n as.integer(timePeriod), ...` | +| `${C_SIGNATURE_LOOKBACK}` | Lookback `.Call()` args, **leading** comma per entry | `,\n as.integer(timePeriod)` | +| `${SPEC_FIELDS}` | MA spec-mode list fields | `timePeriod = if (missing(timePeriod)) 5L else as.integer(timePeriod)` | +| `${MA_TYPE}` | TA_MAType index literal (MAs only) | `0L` | +| `${CARGS}` | Bare formals for `label()`, leading comma per entry | `, timePeriod` | +| `${AGNOSTIC}` | OHLC-order agnosticism (candlesticks only) | `TRUE` / `FALSE` | + +The comma conventions matter: `${ARGS}`/`${PARGS}` entries carry their own +**trailing** comma so empty renders leave no dangling comma (the leftover +blank line is removed by `strip_blank_indentation()`), while the lookback +entries carry a **leading** comma because the lookback `.Call()` has no +fixed trailing argument to absorb one. + +**MAMA quirk**: moving averages whose C signature has no period get a +spec-only `timePeriod = 30` formal injected — it appears in `${ARGS}`, +`${PARGS}` and `${SPEC_FIELDS}` so every MA spec carries a period for its +downstream consumers, but it is deliberately absent from the `.Call()` +coercions. + +## Customizing an indicator + +Everything is mined from the XML, so new TA-Lib functions appear +automatically on `make gen-code`. The lookup tables in `tables.rs` tune +the result: + +1. **`FUNCTION_NAMES`** — add the `("ABBREV", "snake_case_name")` + pair. Unmapped abbreviations fall back to the abbreviation itself, + which renders a degenerate `X <- X` alias line. +2. **`CHART_TYPES`** — add `("ABBREV", ChartType::Main | Sub)` to give the + indicator `.plotly`/`.ggplot` methods (and chart-method unit tests). +3. **`MOVING_AVERAGES` / `AGNOSTIC_PATTERNS`** — family classification for + the dedicated templates. +4. **`EXCLUDED_INDICATORS` / `EXCLUDED_GROUPS`** — add the abbreviation + (or its GroupId) to skip generation entirely, in both C and R. + +After `make gen-code`, fill the protected regions of the generated file +(documentation, chart assembly) — the content survives every regeneration. + +## How C generation works + +There are no per-indicator `.c` files. `c_header.rs` mines each +`TA_(...)` prototype (and its `TA__Lookback(...)` companion) +from `ta_func.h` — the output names are stripped of their +`out`/`Real`/`Integer` prefixes (`outRealUpperBand` -> `UpperBand`, a bare +`outReal` takes the indicator name) and an integer output array flags the +indicator as `TA_INTEGER` — and renders one X-macro line per indicator +into `src/TA-Lib.h`: + +```c +TA_INDICATOR(BBANDS, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(...), TA_OUTPUT(...), TA_OUTPUT_NAME(...), NOT_CANDLESTICK) +... +TA_LOOKBACK(BBANDS, TA_OPTIONS(...)) +``` -## How API registration works (build-time) +The hand-written `src/init.c` `#include`s `"TA-Lib.h"` several times with +different `TA_INDICATOR`/`TA_LOOKBACK` macro definitions — composed from +the argument-shape helpers in `src/wrapper.h` — to expand declarations, +`impl_ta_` wrapper definitions and the `.Call()` registration table. Candlesticks (`CANDLESTICK` kind) additionally +take a normalization flag that maps the `[-200, 200]` integer output onto +`[-2, 2]`. -These run during `make build`, not `make gen-code`: +## How test generation works -1. **`generate_API.sh`** scans all `src/*.c` files for `SEXP` function - definitions, extracts their signatures, and writes `src/api.h` - (a header with all C function prototypes). +`testthat.rs` writes `tests/testthat/test-ta_.R` for every +generated indicator (no protected regions — the files are overwritten on +every run). What a file contains follows from the metadata: -2. **`generate_FFI.sh`** reads `api.h`, counts each function's arguments, - and writes `src/init.c` with `R_CallMethodDef` entries so R's `.Call()` - interface can find them. +- **Rolling statistics** (GroupId `Statistic Functions`): a short + fast-track file — runs without condition, length preservation, output + type — on `SPY[,1]`, with `,y=SPY[,2]` appended for the bivariate + BETA/CORREL. +- **Everything else**: alias equivalence, class preservation + (matrix/data.frame), default formula, row names, and `na.bridge` length + checks; plus `.plotly`/`.ggplot` method tests for chartable indicators + (including candlesticks and moving averages, which are always + chartable) and a `.numeric` test for univariate indicators. ## The splice mechanism -The splice mechanism in `generate_indicator.sh` lets you keep hand-written -code inside generated files. Any content between matched markers is preserved -across regenerations: +`preserve_regions()` keeps hand-written code inside generated files. Any +content between matched markers in the file **on disk** replaces the +template's default content in the fresh render: ```r -## splice:call:start -constructed_series[, 1], -constructed_series[, 2], -## splice:call:end +## splice:documentation:start +#' @param timePeriod [integer] rolling window +## splice:documentation:end ``` -The awk script (lines 158-207 of `generate_indicator.sh`) does a two-pass -process: -- **Pass 1**: Read the existing output file and harvest the body of each - labeled splice region. -- **Pass 2**: Write the newly generated template, but when a splice region - is encountered, substitute the harvested content from pass 1 instead of - the template's default content. +It is name-generic: every `## splice::start` / `## splice::end` +pair discovered in the rendered output is preserved, so new region names +added to a template work without generator changes. Regions absent from the +existing file (first generation) keep the template default. -Current splice labels used: -- `documentation` — custom roxygen2 `@param` documentation -- `call` — arguments passed to `.Call()` in the `.default` method -- `numeric` — arguments passed to `.Call()` in the `.numeric` method +Current labels: -**Warning**: If a generation run produces a file without a splice region that -previously existed (e.g. due to a bug removing the numeric method), the -splice content is lost permanently. There is no recovery other than git. +- `documentation` — custom roxygen2 documentation (indicator, MA, rolling) +- `call` — the `.Call()` arguments of the rolling `.default` method + (prefilled with the univariate default; BETA/CORREL hand-add their `y`) +- `optional-plotly` / `optional-ggplot` — extra chart-only formals + (e.g. `lower_bound = 20,` in RSI) +- `plotly-assembly` / `ggplot-assembly` — the per-indicator `name` / + `decorators` / `traces` (or `layers`) construction -## Validation +**Warning**: if a generation run produces a file without a region that +previously existed, the spliced content is lost. There is no recovery +other than git. -`make validate` compiles `validation/validate.c` against the TA-Lib static -library and runs `validation/validate.R`, which compares the package's R -output against direct C calls for a few key indicators (SMA, RSI, BBANDS, ATR). -This catches regressions where the R↔C binding produces different results -than calling TA-Lib directly. +## Parity testing -## Key design decisions +`make parity-prepare` (run by `make test` / `make check`) compiles +`parity/parity_gen.c` against the TA-Lib static library, snapshots raw C +outputs for the BTC dataset, and stages `tests/testthat/test-parity.R` from +`parity/test_parity_template.R`. The testthat run then compares the +package's R output against those snapshots, catching regressions where the +R↔C binding diverges from calling TA-Lib directly. -- **`envsubst` over R templating**: The templates use `${VAR}` substitution - via the system `envsubst` command rather than R-based templating (whisker, - glue, etc.). This keeps templates as plain R/C files that editors can - syntax-highlight, and avoids escaping issues with R string literals. - -- **Bash for C header parsing**: `generate_indicator_core.sh` parses - `ta_func.h` in bash rather than R. This was a pragmatic choice — the regex - classification of C parameter types is direct in bash. The tradeoff is that - the script is hard to modify (420 lines of careful bash regex). - -- **Formatting as a separate step**: Generated code is intentionally not - pretty. `make fmt` (air + clang-format) handles all formatting as a - post-processing step, so templates don't need to worry about indentation. +## Key design decisions -- **Moving averages share one C file**: TA-Lib's `TA_MA()` accepts a - `TA_MAType` enum, so all 9 MA variants call the same C function. The R - wrappers differ (each sets a different `maType` default) but the C wrapper - is shared. +- **Rust, zero dependencies**: the generator is one `cargo run` with no + crates.io footprint. Templates stay plain R files that editors can + syntax-highlight; placeholders are filled with simple string replacement + rather than a templating engine. +- **Hand-rolled XML mining**: `ta_func_api.xml` is machine-generated and + attribute-free, so `tag_blocks()`/`tag_text()` string scanning is + sufficient and keeps the crate dependency-free. +- **The XML is the metadata**: there is no hand-maintained indicator list; + the lookup tables in `tables.rs` (names, chart types, classifications, + exclusions) are small Rust consts layered on top of what the XML + provides. +- **One template per chart method, not per backend**: the `.plotly` and + `.ggplot` variants of a chart method live in one dual-backend template, + so a change to the shared body is made once instead of twice. +- **X-macros over generated C**: one generated header (`src/TA-Lib.h`) + expanded by hand-written macros replaces per-indicator `.c` files, so C + binding logic lives in exactly one place (`src/wrapper.h`). +- **Formatting as a separate step**: generated code is intentionally not + pretty. `make gen-code` ends with `make fmt` (air + clang-format); + the only whitespace the generator itself fixes is the blank-indentation + lines air would leave behind. +- **Generator is unit-tested**: `cargo test` covers the header and XML + mining, the dual-backend line filtering, every template family render + (including the full-API sweep asserting no unreplaced `${` placeholders + and no unstripped backend prefixes), region preservation, and test-file + rendering. diff --git a/codegen/gen_code/generate.R b/codegen/gen_code/generate.R deleted file mode 100644 index 241fb104a..000000000 --- a/codegen/gen_code/generate.R +++ /dev/null @@ -1,61 +0,0 @@ -## script: Unified code generator -## objective: -## Single entry point that reads indicators.R metadata -## and generates R wrappers, C wrappers, and unit tests -## for every indicator. -## -## usage: -## Rscript ./codegen/gen_code/generate.R - -## 1) load helpers and metadata -source("codegen/gen_code/utils.R") -source("codegen/gen_code/indicators.R") - -## 2) field accessor with defaults -`%||%` <- function(a, b) if (is.null(a)) b else a - -## 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, - candlestick = x$candlestick %||% 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) {} - -## 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, - formula = x$formula, - plotly = test_plotly, - rolling = x$rolling %||% 0, - args = x$signature - ) -} - -## 6) run generation for all indicators -for (x in indicators) { - generate_R(x) - generate_C(x) - generate_test(x) -} - -## end script; diff --git a/codegen/gen_code/indicators.R b/codegen/gen_code/indicators.R deleted file mode 100644 index d4aa6d11f..000000000 --- a/codegen/gen_code/indicators.R +++ /dev/null @@ -1,309 +0,0 @@ -## Unified indicator metadata -## -## All indicator definitions in one place. -## Each entry feeds into generate.R which calls -## impl_generate_indicator(), impl_generate_test(), -## and the appropriate C generator. -## -## Fields: -## title - Human-readable indicator name -## fun - R function name (snake_case) -## alias - TA-Lib alias / uppercase short name -## family - Category for roxygen2 grouping -## formula - Default column formula (default: "~close") -## signature - Character vector of function arguments (default: NULL = none) -## subchart - 0 = main chart overlay, 1 = subchart (default: 1) -## plotly - Append plotly template to R wrapper? (default: 1) -## test_plotly - Test plotly/ggplot methods? (default: inherits plotly) -## candlestick - Use candlestick template? (default: 0) -## agnostic - OHLC order agnostic? (default: NULL) -## maType - Moving average type index (default: -1 = not MA) -## rolling - Use rolling template? (default: 0) -## univariate - Force univariate numeric method? (default: NULL) -## c_generator - C generation strategy: -## NULL = standard (generate_indicator_core.sh → stdout) -## "candlestick" = generate_indicator_core.sh with CANDLESTICK=1 -## "skip" = do not generate C - -## ----------------------------------------------------------- -## Constructor helpers — set per-family defaults so each -## entry only specifies what differs. -## ----------------------------------------------------------- - -momentum <- function( - title, fun, alias, formula, signature, - subchart = 1L, c_generator = NULL -) { - list( - title = title, fun = fun, alias = alias, - family = "Momentum Indicator", - formula = formula, signature = signature, - subchart = subchart, c_generator = c_generator - ) -} - -candlestick <- function(title, fun, alias, signature = "", agnostic = FALSE) { - list( - title = title, fun = fun, alias = alias, - family = "Pattern Recognition", - formula = "~open + high + low + close", - signature = signature, - candlestick = 1, plotly = 0, test_plotly = 1, - c_generator = "candlestick", - agnostic = agnostic - ) -} - -moving_avg <- function(title, fun, alias, ma_type, n_default = 30L, signature = NULL) { - if (is.null(signature)) { - signature <- sprintf("n=%d", as.integer(n_default)) - } - list( - title = title, fun = fun, alias = alias, - family = "Overlap Study", - formula = "~close", - maType = ma_type, - n_default = as.integer(n_default), - signature = signature, - plotly = 0, test_plotly = 1, - univariate = 0, # MA template has built-in numeric method - c_generator = NULL - ) -} - -overlap <- function(title, fun, alias, formula, signature, subchart = 0L) { - list( - title = title, fun = fun, alias = alias, - family = "Overlap Study", - formula = formula, signature = signature, - subchart = subchart - ) -} - -cycle <- function(title, fun, alias, subchart = 1L) { - list( - title = title, fun = fun, alias = alias, - family = "Cycle Indicator", - formula = "~close", - subchart = subchart - ) -} - -price_xform <- function(title, fun, alias, formula, signature = NULL) { - list( - title = title, fun = fun, alias = alias, - family = "Price Transform", - formula = formula, signature = signature, - plotly = 0, rolling = 0 - ) -} - -volume <- function( - title, fun, alias, formula, signature = "", - subchart = 1L, univariate = NULL, c_generator = NULL -) { - list( - title = title, fun = fun, alias = alias, - family = "Volume Indicator", - formula = formula, signature = signature, - subchart = subchart, univariate = univariate, - c_generator = c_generator - ) -} - -volatility <- function(title, fun, alias, formula, signature = "", subchart = 1L) { - list( - title = title, fun = fun, alias = alias, - family = "Volatility Indicator", - formula = formula, signature = signature, - subchart = subchart - ) -} - -rolling <- function(title, fun, alias, signature) { - list( - title = title, fun = fun, alias = alias, - family = "Rolling Statistic", - plotly = 0, rolling = 1, - signature = signature - ) -} - - -## ----------------------------------------------------------- -## Indicator metadata -## ----------------------------------------------------------- - -indicators <- list( - - ## ======================== - ## Cycle Indicators - ## ======================== - cycle("Hilbert Transform - Dominant Cycle Period", "dominant_cycle_period", "HT_DCPERIOD"), - cycle("Hilbert Transform - Dominant Cycle Phase", "dominant_cycle_phase", "HT_DCPHASE"), - cycle("Hilbert Transform - Phasor Components", "phasor_components", "HT_PHASOR"), - cycle("Hilbert Transform - SineWave", "sine_wave", "HT_SINE"), - cycle("Hilbert Transform - Trend vs Cycle Mode", "trend_cycle_mode", "HT_TRENDMODE"), - - ## ======================== - ## Candlestick Patterns - ## ======================== - candlestick("Abandoned Baby", "abandoned_baby", "CDLABANDONEDBABY", signature = "eps = 0"), - candlestick("Advance Block", "advance_block", "CDLADVANCEBLOCK"), - candlestick("Belt Hold", "belt_hold", "CDLBELTHOLD"), - candlestick("Break Away", "break_away", "CDLBREAKAWAY"), - candlestick("Closing Marubozu", "closing_marubozu", "CDLCLOSINGMARUBOZU", agnostic = TRUE), - candlestick("Concealing Baby Swallow", "concealing_baby_swallow", "CDLCONCEALBABYSWALL"), - candlestick("Counter Attack", "counter_attack", "CDLCOUNTERATTACK"), - candlestick("Dark Cloud Cover", "dark_cloud_cover", "CDLDARKCLOUDCOVER", signature = "eps = 0"), - candlestick("Doji", "doji", "CDLDOJI", agnostic = TRUE), - candlestick("Doji Star", "doji_star", "CDLDOJISTAR"), - candlestick("Dragonfly Doji", "dragonfly_doji", "CDLDRAGONFLYDOJI"), - candlestick("Engulfing", "engulfing", "CDLENGULFING"), - candlestick("Evening Doji Star", "evening_doji_star", "CDLEVENINGDOJISTAR", signature = "eps = 0"), - candlestick("Up/Down-gap side-by-side white lines", "gaps_side_white", "CDLGAPSIDESIDEWHITE"), - candlestick("Gravestone Doji", "gravestone_doji", "CDLGRAVESTONEDOJI"), - candlestick("Hammer", "hammer", "CDLHAMMER"), - candlestick("Hanging Man", "hanging_man", "CDLHANGINGMAN"), - candlestick("Harami", "harami", "CDLHARAMI"), - candlestick("Harami Cross", "harami_cross", "CDLHARAMICROSS"), - candlestick("High Wave", "high_wave", "CDLHIGHWAVE", agnostic = TRUE), - candlestick("Hikkake", "hikakke", "CDLHIKKAKE"), - candlestick("Hikkake Modified", "hikakke_mod", "CDLHIKKAKEMOD"), - candlestick("Homing Pigeon", "homing_pigeon", "CDLHOMINGPIGEON"), - candlestick("In Neck", "in_neck", "CDLINNECK"), - candlestick("Inverted Hammer", "inverted_hammer", "CDLINVERTEDHAMMER"), - candlestick("Kicking", "kicking", "CDLKICKING"), - candlestick("Kicking Baby Length", "kicking_baby_length", "CDLKICKINGBYLENGTH", agnostic = TRUE), - candlestick("Long Legged Doji", "long_legged_doji", "CDLLONGLEGGEDDOJI", agnostic = TRUE), - candlestick("Long Line", "long_line", "CDLLONGLINE", agnostic = TRUE), - candlestick("Marubozu", "marubozu", "CDLMARUBOZU"), - candlestick("Mat Hold", "mat_hold", "CDLMATHOLD", signature = "eps=0"), - candlestick("Matching Low", "matching_low", "CDLMATCHINGLOW"), - candlestick("Morning Doji Star", "morning_doji_star", "CDLMORNINGDOJISTAR", signature = "eps=0"), - candlestick("Morning Star", "morning_star", "CDLMORNINGSTAR", signature = "eps = 0"), - candlestick("On-Neck", "on_neck", "CDLONNECK"), - candlestick("Piercing", "piercing", "CDLPIERCING", agnostic = TRUE), - candlestick("Rickshaw Man", "rickshaw_man", "CDLRICKSHAWMAN"), - candlestick("Rising/Falling Three Methods", "rise_fall_3_methods", "CDLRISEFALL3METHODS"), - candlestick("Separating Lines", "separating_lines", "CDLSEPARATINGLINES"), - candlestick("Shooting Star", "shooting_star", "CDLSHOOTINGSTAR", agnostic = TRUE), - candlestick("Short Line Candle", "short_line", "CDLSHORTLINE", agnostic = TRUE), - candlestick("Spinning Top", "spinning_top", "CDLSPINNINGTOP"), - candlestick("Stalled Pattern", "stalled_pattern", "CDLSTALLEDPATTERN"), - candlestick("Stick Sandwich", "stick_sandwich", "CDLSTICKSANDWICH"), - candlestick("Takuri", "takuri", "CDLTAKURI"), - candlestick("Tasuki Gap", "tasuki_gap", "CDLTASUKIGAP"), - candlestick("Three Black Crows", "three_black_crows", "CDL3BLACKCROWS"), - candlestick("Identical Three Crows", "three_identical_crows", "CDLIDENTICAL3CROWS"), - candlestick("Three Inside", "three_inside", "CDL3INSIDE"), - candlestick("Three-Line Strike", "three_line_strike", "CDL3LINESTRIKE"), - candlestick("Three Outside", "three_outside", "CDL3OUTSIDE"), - candlestick("Three Stars in the South", "three_stars_in_the_south", "CDL3STARSINSOUTH"), - candlestick("Three White Soldiers", "three_white_soldiers", "CDL3WHITESOLDIERS"), - candlestick("Thrusting", "thrusting", "CDLTHRUSTING"), - candlestick("Tristar", "tristar", "CDLTRISTAR"), - candlestick("Two Crows", "two_crows", "CDL2CROWS"), - candlestick("Unique Three River", "unique_3_river", "CDLUNIQUE3RIVER"), - candlestick("Upside Gap Two Crows", "upside_gap_2_crows", "CDLUPSIDEGAP2CROWS"), - candlestick("Upside/Downside Gap Three Methods", "xside_gap_3_methods", "CDLXSIDEGAP3METHODS"), - candlestick("Ladder Bottom", "ladder_bottom", "CDLLADDERBOTTOM"), - candlestick("Evening Star", "evening_star", "CDLEVENINGSTAR", signature = "eps = 0"), - - ## ======================== - ## Momentum Indicators - ## ======================== - momentum("Aroon", "aroon", "AROON", "~ high + low", c("n=14")), - momentum("Aroon Oscillator", "aroon_oscillator", "AROONOSC", "~ high + low", c("n=14")), - momentum("Chande Momentum Oscillator", "chande_momentum_oscillator", "CMO", "~ close", c("n=14")), - momentum("Commodity Channel Index", "commodity_channel_index", "CCI", "~ high + low + close", c("n=14"), subchart = 0L), - momentum("Fast Stochastic", "fast_stochastic", "STOCHF", "~ high + low + close", c("fastk=5", "fastd=SMA(n=3)")), - momentum("Money Flow Index", "money_flow_index", "MFI", "~ high + low + close + volume", c("n = 14")), - momentum("Moving Average Convergence Divergence", "moving_average_convergence_divergence", "MACD", "~close", c("fast = 12", "slow = 26", "signal = 9")), - momentum("Moving Average Convergence Divergence (Extended)", "extended_moving_average_convergence_divergence", "MACDEXT", "~close", c("fast = SMA(n = 12)", "slow = SMA(n = 26)", "signal = SMA(n = 9)")), - momentum("Moving Average Convergence Divergence (Fixed)", "fixed_moving_average_convergence_divergence", "MACDFIX", "~close", c("signal=9")), - momentum("Relative Strength Index", "relative_strength_index", "RSI", "~close", c("n=14")), - momentum("Stochastic", "stochastic", "STOCH", "~ high + low + close", c("fastk = 5", "slowk = SMA(n = 3)", "slowd = SMA(n = 3)")), - momentum("Stochastic Relative Strength Index", "stochastic_relative_strength_index", "STOCHRSI", "~close", c("n=14", "fastk=5", "fastd=SMA(n=3)")), - momentum("Ultimate Oscillator", "ultimate_oscillator", "ULTOSC", "~ high + low + close", c("n=c(7, 14, 28)")), - momentum("Average Directional Movement Index", "average_directional_movement_index", "ADX", "~ high + low + close", c("n=14")), - momentum("Average Directional Movement Index Rating", "average_directional_movement_index_rating", "ADXR", "~ high + low + close", c("n=14")), - momentum("Balance of Power", "balance_of_power", "BOP", "~ open + high + low + close", c(character(0))), - momentum("Momentum", "momentum", "MOM", "~ close", c("n=10")), - momentum("Williams %R", "williams_oscillator", "WILLR", "~ high + low + close", c("n=14")), - momentum("Percentage Price Oscillator", "percentage_price_oscillator", "PPO", "~close", c("fast=12", "slow=26", "ma=SMA(n=9)")), - momentum("Triple Exponential Average", "triple_exponential_average", "TRIX", "~close", c("n=30")), - momentum("Directional Movement Index", "directional_movement_index", "DX", "~high + low + close", c("n=14")), - momentum("Intraday Movement Index", "intraday_movement_index", "IMI", "~open + close", c("n=14")), - momentum("Minus Directional Indicator", "minus_directional_indicator", "MINUS_DI", "~high + low + close", c("n=14")), - momentum("Minus Directional Movement", "minus_directional_movement", "MINUS_DM", "~high + low", c("n=14")), - momentum("Plus Directional Indicator", "plus_directional_indicator", "PLUS_DI", "~high + low + close", c("n=14")), - momentum("Plus Directional Movement", "plus_directional_movement", "PLUS_DM", "~high + low", c("n=14")), - momentum("Rate of Change", "rate_of_change", "ROC", "~close", c("n=10")), - momentum("Ratio of Change", "ratio_of_change", "ROCR", "~close", c("n=10")), - momentum("Absolute Price Oscillator", "absolute_price_oscillator", "APO", "~close", c("fast=12", "slow=26", "ma=SMA(n=9)")), - - ## ======================== - ## Moving Averages - ## ======================== - moving_avg("Simple Moving Average", "simple_moving_average", "SMA", "0L"), - moving_avg("Exponential Moving Average", "exponential_moving_average", "EMA", "1L"), - moving_avg("Weighted Moving Average", "weighted_moving_average", "WMA", "2L"), - moving_avg("Double Exponential Moving Average", "double_exponential_moving_average", "DEMA", "3L"), - moving_avg("Triple Exponential Moving Average", "triple_exponential_moving_average", "TEMA", "4L"), - moving_avg("Triangular Moving Average", "triangular_moving_average", "TRIMA", "5L"), - moving_avg("Kaufman Adaptive Moving Average", "kaufman_adaptive_moving_average", "KAMA", "6L"), - moving_avg( - "MESA Adaptive Moving Average", "mesa_adaptive_moving_average", "MAMA", "7L", - signature = c("fast=0.5", "slow=0.05") - ), - moving_avg( - "Triple Exponential Moving Average (T3)", "t3_exponential_moving_average", "T3", "8L", - n_default = 5L, - signature = c("n=5", "vfactor=0.7") - ), - - ## ======================== - ## Overlap Studies - ## ======================== - overlap("Bollinger Bands", "bollinger_bands", "BBANDS", "~close", c("ma=SMA(n=5)", "sd=2", "sd_down", "sd_up")), - overlap("Hilbert Transform - Instantaneous Trendline", "trendline", "HT_TRENDLINE", "~close", ""), - overlap("Parabolic Stop and Reverse (SAR)", "parabolic_stop_and_reverse", "SAR", "~high+low", c("acceleration=0.02", "maximum=0.2")), - overlap("Parabolic Stop and Reverse (SAR) - Extended", "extended_parabolic_stop_and_reverse", "SAREXT", "~high+low", c("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")), - overlap("Acceleration Bands", "acceleration_bands", "ACCBANDS", "~ high + low + close", c("n=20")), - - ## ======================== - ## Volume Indicators - ## ======================== - volume("Chaikin A/D Line", "chaikin_accumulation_distribution_line", "AD", "~high+low+close+volume"), - volume("Chaikin A/D Oscillator", "chaikin_accumulation_distribution_oscillator", "ADOSC", "~high+low+close+volume", signature = c("fast=3", "slow=10")), - volume("On-Balance Volume", "on_balance_volume", "OBV", "~close+volume"), - volume("Trading Volume", "trading_volume", "VOLUME", "~volume + open + close", signature = c("ma = list(SMA(n = 7), SMA(n = 15))"), univariate = 1, c_generator = "skip"), - - ## ======================== - ## Volatility Indicators - ## ======================== - volatility("True Range", "true_range", "TRANGE", "~high + low + close"), - volatility("Average True Range", "average_true_range", "ATR", "~high + low + close", signature = "n=14"), - volatility("Normalized Average True Range", "normalized_average_true_range", "NATR", "~high + low + close", signature = "n=14"), - - ## ======================== - ## Price Transforms - ## ======================== - price_xform("Average Price", "average_price", "AVGPRICE", "~open + high + low + close"), - price_xform("Median Price", "median_price", "MEDPRICE", "~high + low"), - price_xform("Typical Price", "typical_price", "TYPPRICE", "~high + low + close"), - price_xform("Weighted Close Price", "weighted_close_price", "WCLPRICE", "~high + low + close"), - price_xform("Midpoint Price", "midpoint_price", "MIDPRICE", "~high + low", signature = c("n=14")), - - ## ======================== - ## Rolling Statistics - ## ======================== - rolling("Rolling Sum", "rolling_sum", "SUM", "n = 30"), - rolling("Rolling Standard Deviation", "rolling_standard_deviation", "STDDEV", c("n=5", "k = 1")), - rolling("Rolling Standard Deviation", "rolling_variance", "VAR", c("n=5", "k = 1")), - rolling("Rolling Beta", "rolling_beta", "BETA", c("y", "n=5")), - rolling("Rolling Correlation", "rolling_correlation", "CORREL", c("y", "n=30")), - rolling("Rolling Max", "rolling_max", "MAX", c("n=30")), - rolling("Rolling Min", "rolling_min", "MIN", c("n=30")) -) diff --git a/codegen/gen_code/utils.R b/codegen/gen_code/utils.R deleted file mode 100644 index c35be6693..000000000 --- a/codegen/gen_code/utils.R +++ /dev/null @@ -1,93 +0,0 @@ -## script: Generate Functions -## objective: -## Consolidate functions -## for generators -## -## -## 1) main generator function -impl_generate_indicator <- function( - title, - fun, - family, - ta_fun, - formula = "~close", - plotly = 1L, - subchart = 1L, - args, - agnostic = NULL, - candlestick = 0, - maType = -1, - rolling = 0, - univariate = NULL, - n_default = 30L -) { - if (is.null(formula)) formula <- "~close" - if (missing(univariate) | is.null(univariate)) { - has_numeric <- as.integer( - as.logical( - length(all.vars(as.formula(formula))) == 1 - ) - ) - } else { - has_numeric <- univariate - } - - args <- gsub("([()])", "\\\\\\1", args, perl = TRUE) - args <- gsub("\\s+", "", args, perl = TRUE) - system2( - command = "bash", - args = c("./codegen/generate_indicator.sh", args), - env = c( - sprintf("TITLE='%s'", title), - sprintf("FUN='%s'", fun), - sprintf("FAMILY='%s'", family), - sprintf("TA_FUN='%s'", ta_fun), - sprintf("FORMULA='%s'", formula), - sprintf("PLOTLY='%s'", plotly), - sprintf("AGNOSTIC='%s'", agnostic), - sprintf("CANDLESTICK='%s'", candlestick), - sprintf("maType='%s'", maType), - sprintf("ROLLING='%s'", rolling), - sprintf("SUBCHART='%s'", subchart), - sprintf( - "NUMERIC='%s'", - has_numeric - ), - sprintf("N_DEFAULT='%s'", as.integer(n_default)) - ) - ) -} - -impl_generate_test <- function( - fun, - ta_fun, - formula = "~close", - plotly = 1, - rolling = 0, - args = NULL -) { - if (is.null(formula)) formula <- "~close" - args <- gsub("([()])", "\\\\\\1", args, perl = TRUE) - args <- gsub("\\s+", "", args, perl = TRUE) - - system2( - command = "bash", - args = c("./codegen/generate_unit-tests.sh", args), - env = c( - sprintf("FUN='%s'", fun), - sprintf("TA_FUN='%s'", ta_fun), - sprintf("FORMULA='%s'", formula), - sprintf("PLOTLY='%s'", plotly), - sprintf("ROLLING='%s'", rolling), - sprintf( - "NUMERIC='%s'", - as.integer( - as.logical( - length(all.vars(as.formula(formula))) == 1 - ) - ) - ) - ) - ) -} - diff --git a/codegen/generate_indicator.sh b/codegen/generate_indicator.sh deleted file mode 100755 index c6d69b120..000000000 --- a/codegen/generate_indicator.sh +++ /dev/null @@ -1,211 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -## 1) inputs (env vars set by the R caller) and template selection -FAMILY=${FAMILY:-} -TITLE=${TITLE:-} -FUN=${FUN:?} -TA_FUN=${TA_FUN:?} -ALIAS=$TA_FUN -FORMULA=${FORMULA:-"~close"} -PLOTLY=${PLOTLY:-0} -SUBCHART=${SUBCHART:-0} -NUMERIC=${NUMERIC:-1} -AGNOSTIC=${AGNOSTIC:-"TRUE"} -CANDLESTICK=${CANDLESTICK:-0} -maType=${maType:--1} # -1 == not a moving average -ROLLING=${ROLLING:-0} -OUTPUTFILE="R/ta_${TA_FUN}.R" - -## main template — one per indicator family (mutually exclusive) -TEMPLATE_MAIN="codegen/templates/indicator_template.R.in" -if [[ $CANDLESTICK -eq 1 ]]; then TEMPLATE_MAIN="codegen/templates/candlestick_template.R.in" -elif [[ "$maType" != "-1" ]]; then TEMPLATE_MAIN="codegen/templates/moving_average_template.R.in" -elif [[ "$ROLLING" != "0" ]]; then TEMPLATE_MAIN="codegen/templates/rolling_template.R.in" -fi - -## 2) arguments passed into -## each function is constructed -## as an array. Has to be passed as -## a vector from R -ARGS_ARRAY=( "$@" ) - -## 2.1) split the arguments by the first -## '=' to avoid using awk -PARGS_ARR=() # arguments inside calls, becomes n = n, or k = k -CARGS_ARR=() # arguments inside .Call, becomes n, k -CARGS_TYPED_ARR=() # arguments inside .Call, type-coerced (as.integer/as.double) -SPEC_FIELDS_ARR=() # fields for MA spec-mode list(...) (key = coerced-or-default) -HAS_N=0 # track whether 'n' is already a formal signature arg -for a in "${ARGS_ARRAY[@]}"; do - if [[ $a == *=* ]]; then - k=${a%%=*} - v=${a#*=} - else - k=$a - v="" - fi - [[ "$k" == "n" ]] && HAS_N=1 - PARGS_ARR+=( ",$k=$k" ) - CARGS_ARR+=( ",$k" ) - ## decide coercion by default-value shape: dot => double, else integer - if [[ "$v" == *.* ]]; then - CARGS_TYPED_ARR+=( ",as.double($k)" ) - SPEC_FIELDS_ARR+=( "$k = if (missing($k)) $v else as.double($k)" ) - else - CARGS_TYPED_ARR+=( ",as.integer($k)" ) - SPEC_FIELDS_ARR+=( "$k = if (missing($k)) ${v}L else as.integer($k)" ) - fi -done - -## 2.1.1) inject 'n' as a spec-only field for MAs whose signature -## lacks it (today: MAMA). Every MA spec carries 'n' so that -## downstream consumers (BBANDS, STOCH, MACDEXT, ...) can -## read ma$n uniformly to drive their calculation period. -## The R function accepts 'n' as a formal arg so MAMA(n = 14) -## parses in spec-mode, but it is NOT forwarded to .Call() -## (TA_MAMA's C signature takes no period). -if [[ "$maType" != "-1" && $HAS_N -eq 0 ]]; then - _n_default=${N_DEFAULT:-30} - ## prepend so 'n' is the first spec field and first forwarding arg, - ## matching the ordering used by the n-bearing MAs. - SPEC_FIELDS_ARR=( "n = if (missing(n)) ${_n_default}L else as.integer(n)" "${SPEC_FIELDS_ARR[@]}" ) - PARGS_ARR=( ",n=n" "${PARGS_ARR[@]}" ) - ARGS_ARRAY=( "n=${_n_default}" "${ARGS_ARRAY[@]}" ) - ## NOTE: deliberately NOT adding to CARGS_ARR / CARGS_TYPED_ARR - - ## the C wrapper for MAMA has no period parameter. -fi - -## 2.2) construct arguments -## a la paste + collapse -PARGS=$(printf '%s ' "${PARGS_ARR[@]}"); PARGS=${PARGS%, } -if [[ "$ROLLING" != "1" ]]; then - if [[ -n ${PARGS} ]]; then PARGS+=','; fi -fi - -printf -v ARGS '%s, ' "${ARGS_ARRAY[@]}"; ARGS=${ARGS%, } -if [[ "$ROLLING" != "1" ]]; then - if [[ -n ${ARGS} ]]; then ARGS+=','; fi -fi -## NOTE: this is passed down to -## the {plotly} template -PPARGS=$(printf '%s ' "${PARGS_ARR[@]}"); -CARGS=$(printf '%s ' "${CARGS_ARR[@]}"); -CARGS_TYPED=$(printf '%s ' "${CARGS_TYPED_ARR[@]}"); - -## 2.3) spec-mode list fields for the moving_average template. -## Each signature argument becomes a round-tripped entry in -## the list returned when the MA is called without 'x'. -## Joined with ',' + newline + indent so 'air' can reformat. -SPEC_FIELDS="" -for ((_i=0; _i<${#SPEC_FIELDS_ARR[@]}; _i++)); do - if [[ $_i -eq 0 ]]; then - SPEC_FIELDS="${SPEC_FIELDS_ARR[$_i]}" - else - SPEC_FIELDS="${SPEC_FIELDS},"$'\n\t\t\t\t'"${SPEC_FIELDS_ARR[$_i]}" - fi -done - -## 3) export placeholders and restrict envsubst to exactly these names, so the -## templates' own '$' usage (e.g. `state$sub`, `x$n`) is left untouched. -export FUN TITLE TA_FUN ALIAS FAMILY FORMULA ARGS PARGS CARGS CARGS_TYPED PPARGS AGNOSTIC maType SPEC_FIELDS -REPLACE='${FUN}${TITLE}${TA_FUN}${ALIAS}${FAMILY}${FORMULA}${ARGS}${PARGS}${CARGS}${CARGS_TYPED}${PPARGS}${AGNOSTIC}${maType}${SPEC_FIELDS}' - -## 4) render the templates onto one accumulator, then splice (section 5). -## Optional methods are appended with a blank-line separator; envsubst -## writes straight onto the accumulator, so no per-template temp files. -tmp_render="$(mktemp)"; tmp_splice="$(mktemp)" -trap 'rm -f "$tmp_render" "$tmp_splice"' EXIT - -## 4.1) main template -envsubst "$REPLACE" < "$TEMPLATE_MAIN" > "$tmp_render" - -## 4.2) .numeric method — univariate, non-rolling indicators -if [[ $NUMERIC -eq 1 && $ROLLING -ne 1 ]]; then - printf '\n\n' >> "$tmp_render" - envsubst "$REPLACE" < codegen/templates/numeric_template.R.in >> "$tmp_render" -fi - -## 4.3) .plotly method — standard indicators only -## (candlestick/MA bake their plotly into the main template) -if [[ $PLOTLY -eq 1 ]]; then - if [[ $SUBCHART -eq 1 ]]; then plotly=plotly_subchart_template.R.in - else plotly=plotly_main_template.R.in; fi - printf '\n\n' >> "$tmp_render" - envsubst "$REPLACE" < "codegen/templates/$plotly" >> "$tmp_render" -fi - -## 4.4) .ggplot method — appended for each charted family -ggplot= -if [[ $CANDLESTICK -eq 1 ]]; then ggplot=candlestick_ggplot_template.R.in -elif [[ "$maType" != "-1" ]]; then ggplot=moving_average_ggplot_template.R.in -elif [[ $PLOTLY -eq 1 && $SUBCHART -eq 1 ]]; then ggplot=ggplot_subchart_template.R.in -elif [[ $PLOTLY -eq 1 ]]; then ggplot=ggplot_main_template.R.in -fi -if [[ -n "$ggplot" ]]; then - printf '\n\n' >> "$tmp_render" - envsubst "$REPLACE" < "codegen/templates/$ggplot" >> "$tmp_render" -fi - - -## 5) splice protected code regions -## (this is the old code, it works) -## NOTE: use -s (exists AND non-empty). If the file exists but is -## 0 bytes, awk's FNR==NR pass-1 trick misfires: no records from -## pass 1 means `tmp_render` gets consumed as pass 1 (harvest-only), -## pass 2 never runs, and the output is empty. -s routes 0-byte -## files through the `else` branch which copies the rendered template. -if [[ -s "$OUTPUTFILE" ]]; then - awk ' - function rtrim(s){ sub(/[[:space:]]+$/,"",s); return s } - function label_from(line, part, pos,rest,needle) { - needle = "splice:" - pos = index(line, needle) - if (!pos) return "" - rest = substr(line, pos + length(needle)) # LABEL:part - needle = ":" part - pos = index(rest, needle) - if (!pos) return "" - return rtrim(substr(rest, 1, pos-1)) - } - - ## pass 1: harvest preserved bodies from existing OUTPUTFILE - FNR==NR { - lbl = label_from($0, "start") - if (lbl != "") { cur = lbl; inside = 1; next } - if (inside) { - if (label_from($0, "end") == cur) { inside = 0; next } - blocks[cur] = blocks[cur] $0 ORS - next - } - next - } - - ## pass 2: write new file from staged template with preserved inserts - { - lbl = label_from($0, "start") - if (lbl != "") { - print # print the start marker - end_lbl = lbl - if (lbl in blocks) { - printf "%s", blocks[lbl] - preserve = 1 - } else { - preserve = 0 - } - while ( (getline line) > 0 ) { - if (label_from(line,"end") == end_lbl) { print line; break } - if (!preserve) print line - } - next - } - print - } - ' "$OUTPUTFILE" "$tmp_render" > "$tmp_splice" -else - cp "$tmp_render" "$tmp_splice" -fi - -## 6) commit the code -## to R/ -mv "$tmp_splice" "$OUTPUTFILE" diff --git a/codegen/src/c_header.rs b/codegen/src/c_header.rs new file mode 100644 index 000000000..3c5e3c0d1 --- /dev/null +++ b/codegen/src/c_header.rs @@ -0,0 +1,344 @@ +//! src/TA-Lib.h generation +//! +//! Each TA-Lib function is defined in 'src/ta-lib/include/ta_func.h' +//! on the following form: +//! +//! ```c +//! 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 every prototype can be mined directly and rewritten as one +//! variadic X-macro line per indicator (plus one for its +//! TA__Lookback() companion). The hand-written src/init.c +//! #includes the generated header several times, expanding those +//! lines via the macro helpers of src/wrapper.h into wrapper +//! definitions and the .Call() registration table, keeping the C +//! binding logic in exactly one place. + +/// One TA-Lib function mined from ta_func.h, reduced to what the +/// X-macro lines need +#[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, +} + +/// The full src/TA-Lib.h: one TA_INDICATOR line per function, +/// then one TA_LOOKBACK line per function +pub fn render_header(names: &[String], header: &str) -> String { + let header = purge_comments(header); + let funcs: Vec = names + .iter() + .map(|n| extract_signature(n, &header)) + .collect(); + + let mut out = String::from(concat!( + "// TA-Lib.h - Autogenerated via codegen/\n", + "// Description:\n", + "//\n", + "// \t\tTA_INDICATOR: TA-Lib indicator.\n", + "// \t\tTA_INPUT: Indicator input.\n", + "// \t\tTA_OPTIONS: Indicator input.\n", + "// \t\tTA_OUTPUT: Indicator input.\n", + "// \t\tTA_OUTPUT_NAMES: Indicator input.\n", + "// \t\tTA_LOOKBACK: Indicator lookback (name + optional inputs).\n", + "//\n", + "// clang-format off\n", + )); + + for f in &funcs { + out.push_str(&indicator_macro(f)); + out.push('\n'); + } + + out.push('\n'); + out.push_str("// Lookback\n"); + for f in &funcs { + out.push_str(&lookback_macro(f)); + out.push('\n'); + } + + out.push_str("// clang-format on\n"); + out +} + +/// 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. +fn indicator_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(", "), + if function.indicator.starts_with("CDL") { + "CANDLESTICK" + } else { + "NOT_CANDLESTICK" + } + ) +} + +/// 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() +fn lookback_macro(function: &TA_Lib) -> String { + format!( + "TA_LOOKBACK({}, TA_OPTIONS({}))", + function.indicator, + function.optional_input.join(", "), + ) +} + +/// Drop every '/* ... */' block comment (each replaced by a single +/// space) so prototype mining never matches commented-out code +fn purge_comments(header: &str) -> String { + let mut out = String::with_capacity(header.len()); + let mut rest = header; + + while let Some(start) = rest.find("/*") { + out.push_str(&rest[..start]); + out.push(' '); + rest = match rest[start + 2..].find("*/") { + Some(end) => &rest[start + 2 + end + 2..], + None => "", + }; + } + + out.push_str(rest); + out +} + +/// 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() +} + +/// Mine the TA_() prototype from the (comment-purged) +/// header; panics if the prototype is not found +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_DOUBLE", + ..Default::default() + }; + + for p in ¶ms { + // 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; + } + + // 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("[]") { + let nm = parameter_identifier(p); + + if p.contains("const") { + f.input.push(nm); + } else { + 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); + + 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 { + 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); + + 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_DOUBLE"); + assert_eq!(f.input, ["inReal"]); + assert_eq!(f.optional_input, ["OPTIONAL_INTEGER(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, + [ + "OPTIONAL_INTEGER(optInTimePeriod)", + "OPTIONAL_DOUBLE(optInNbDevUp)", + "OPTIONAL_DOUBLE(optInNbDevDn)", + "OPTIONAL_MATYPE(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_INTEGER"); + 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 renders_macro_lines() { + let purged = purge_comments(SAMPLE); + + assert_eq!( + indicator_macro(&extract_signature("RSI", &purged)), + "TA_INDICATOR(RSI, TA_DOUBLE, TA_INPUT(inReal), \ + TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)), TA_OUTPUT(outReal), \ + TA_OUTPUT_NAME(RSI), NOT_CANDLESTICK)" + ); + assert_eq!( + lookback_macro(&extract_signature("RSI", &purged)), + "TA_LOOKBACK(RSI, TA_OPTIONS(OPTIONAL_INTEGER(optInTimePeriod)))" + ); + + // candlesticks carry the CANDLESTICK kind (normalization flag) + // and an empty TA_OPTIONS() + assert_eq!( + indicator_macro(&extract_signature("CDLDOJI", &purged)), + "TA_INDICATOR(CDLDOJI, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), \ + TA_OPTIONS(), TA_OUTPUT(outInteger), TA_OUTPUT_NAME(CDLDOJI), CANDLESTICK)" + ); + } + + #[test] + fn strips_comments() { + assert_eq!(purge_comments("a /* x */ b"), "a b"); + } +} diff --git a/codegen/src/main.rs b/codegen/src/main.rs index b79e67bc3..d249f3b1a 100644 --- a/codegen/src/main.rs +++ b/codegen/src/main.rs @@ -1,96 +1,63 @@ -// load the parser -mod parser; -use parser::purge_comments; -use std::fs; - -use crate::parser::{TA_Lib, extract_signature}; +//! Driver +//! +//! One `cargo run` regenerates everything the codegen owns: +//! +//! 1. `src/TA-Lib.h` — the C X-macro lines (see c_header.rs) +//! 2. `R/ta_.R` — the R wrappers (see render.rs), with +//! hand-edited splice regions of the existing files preserved +//! 3. `tests/testthat/test-ta_.R` — the unit tests +//! (see testthat.rs), overwritten on every run + +mod c_header; +mod metadata; +mod render; +mod tables; +mod testthat; -/// 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 -/// 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 BATCH_INDICATOR_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(", "), - if function.indicator.starts_with("CDL") { - "CANDLESTICK" - } else { - "NOT_CANDLESTICK" - } - ) -} - -/// 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(", "), - ) -} +use std::fs; -/// 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 header = fs::read_to_string("src/ta-lib/include/ta_func.h").expect("read ta_func.h"); + let xml = fs::read_to_string("src/ta-lib/ta_func_api.xml").expect("read ta_func_api.xml"); + + // excluded by name or GroupId; applies to both + // the C and R generation below + let excluded = tables::excluded_indicators(&xml); let names: Vec = list .lines() .filter_map(|l| l.split_whitespace().next()) + .filter(|n| !excluded.iter().any(|e| e == n)) .map(str::to_string) .collect(); - let funcs: Vec = names - .iter() - .map(|n| extract_signature(n, &header)) - .collect(); + fs::write("src/TA-Lib.h", c_header::render_header(&names, &header)) + .expect("write src/TA-Lib.h"); - // 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("// \t\tTA_LOOKBACK: Indicator lookback (name + optional inputs).\n"); - output.push_str("//\n"); - output.push_str("// clang-format off\n"); + let templates = render::Templates::load("codegen/templates"); - for f in &funcs { - output.push_str(&BATCH_INDICATOR_MACRO(f)); - output.push('\n'); - } + for f in metadata::parse_api(&xml) { + let path = format!("R/ta_{}.R", f.indicator); + let mut rendered = render::render_indicator(&f, &templates); - output.push('\n'); - output.push_str("// Lookback\n"); - for f in &funcs { - output.push_str(&LOOKBACK_MACRO(f)); - output.push('\n'); - } + // protected regions: hand-edited splice content in the + // existing wrapper survives regeneration. Only a missing + // file (first generation) may skip the splice — any other + // read error must not silently overwrite the hand edits + // with template defaults + match fs::read_to_string(&path) { + Ok(existing) => rendered = render::preserve_regions(&rendered, &existing), + Err(e) if e.kind() == std::io::ErrorKind::NotFound => {} + Err(e) => panic!("read {path}: {e}"), + } - output.push_str("// clang-format on\n"); + fs::write(path, rendered).expect("write R wrapper"); - fs::write("src/TA-Lib.h", output).expect("msg") + fs::write( + format!("tests/testthat/test-ta_{}.R", f.indicator), + testthat::render_test(&f), + ) + .expect("write unit test"); + } } diff --git a/codegen/src/metadata.rs b/codegen/src/metadata.rs new file mode 100644 index 000000000..5e1d34d5c --- /dev/null +++ b/codegen/src/metadata.rs @@ -0,0 +1,317 @@ +//! ta_func_api.xml mining +//! +//! The metadata driving the R side is mined from +//! 'src/ta-lib/ta_func_api.xml' where each indicator is described +//! as a block: +//! +//! ```xml +//! +//! BBANDS +//! Bollinger Bands +//! Overlap Studies +//! ... +//! ... +//! ... +//! +//! ``` +//! +//! The XML is attribute-free and machine-generated, so the +//! hand-rolled tag_blocks()/tag_text() mining below is sufficient +//! and keeps the crate dependency-free. + +use crate::tables::{EXCLUDED_GROUPS, is_excluded}; + +/// A reduced to what the R generation needs +#[derive(Debug, Default, PartialEq)] +pub struct MetaData { + pub title: String, + pub indicator: String, + pub family: String, + pub input: Vec, + pub optional_input: Vec, +} + +impl MetaData { + /// Default column formula, deduplicated in input order, + /// e.g. [high, low, close] -> ~high + low + close + pub fn default_formula(&self) -> String { + let mut cols: Vec<&str> = Vec::new(); + for col in &self.input { + if !cols.contains(&col.as_str()) { + cols.push(col); + } + } + format!("~{}", cols.join(" + ")) + } +} + +/// An reduced to what the +/// R signature needs: an argument name, its type +/// (for the .Call() coercion) and its default value +#[derive(Clone, Debug, PartialEq)] +pub struct OptionalArg { + pub name: String, + pub kind: OptionalType, + pub default: String, +} + +#[derive(Clone, Debug, PartialEq)] +pub enum OptionalType { + Integer, + Double, + MAType, +} + +/// All ... contents in document order +pub(crate) fn tag_blocks<'a>(xml: &'a str, tag: &str) -> Vec<&'a str> { + let open = format!("<{tag}>"); + let close = format!(""); + + let mut blocks = Vec::new(); + let mut rest = xml; + + while let Some(start) = rest.find(&open) { + let after = &rest[start + open.len()..]; + let end = after + .find(&close) + .unwrap_or_else(|| panic!("unclosed <{tag}>")); + + blocks.push(after[..end].trim()); + rest = &after[end + close.len()..]; + } + + blocks +} + +/// First ... content, if any +pub(crate) fn tag_text<'a>(xml: &'a str, tag: &str) -> Option<&'a str> { + let open = format!("<{tag}>"); + let close = format!(""); + + let start = xml.find(&open)?; + let after = &xml[start + open.len()..]; + let end = after.find(&close)?; + + Some(after[..end].trim()) +} + +/// 'Fast-K Period' -> fastKPeriod, 'Bollinger Bands' -> bollingerBands +fn camel_case(s: &str) -> String { + let mut out = String::new(); + let mut boundary = false; + + for c in s.chars() { + if c.is_ascii_alphanumeric() { + if boundary && !out.is_empty() { + out.push(c.to_ascii_uppercase()); + } else { + out.push(c.to_ascii_lowercase()); + } + boundary = false; + } else { + boundary = true; + } + } + + out +} + +/// Parse 'src/ta-lib/ta_func_api.xml' into one MetaData +/// per , skipping the exclusions +pub fn parse_api(xml: &str) -> Vec { + tag_blocks(xml, "FinancialFunction") + .iter() + .map(|block| { + let mut f = MetaData { + indicator: tag_text(block, "Abbreviation") + .expect("Abbreviation") + .to_string(), + title: tag_text(block, "ShortDescription") + .expect("ShortDescription") + .to_string(), + family: tag_text(block, "GroupId").expect("GroupId").to_string(), + ..Default::default() + }; + + // Required inputs become R column names; price series + // map to their OHLCV column while plain double arrays + // (inReal) default to the 'close' column + for arg in tag_blocks(block, "RequiredInputArgument") { + let input_type = tag_text(arg, "Type").expect("input Type"); + + f.input.push(match input_type { + "Open" | "High" | "Low" | "Close" | "Volume" => input_type.to_lowercase(), + _ => "close".to_string(), + }); + } + + // Optional inputs; the DefaultValue of doubles is stored + // in scientific notation (2.000000e-2) and is reformatted + // as a plain R literal (0.02) + for arg in tag_blocks(block, "OptionalInputArgument") { + let name = camel_case(tag_text(arg, "Name").expect("optional Name")); + let default = tag_text(arg, "DefaultValue").expect("DefaultValue"); + + let (kind, default) = match tag_text(arg, "Type").expect("optional Type") { + "Integer" => (OptionalType::Integer, default.to_string()), + "MA Type" => (OptionalType::MAType, default.to_string()), + "Double" => ( + OptionalType::Double, + format!("{}", default.parse::().expect("double default")), + ), + unknown => panic!("unknown optional type: {unknown}"), + }; + + f.optional_input.push(OptionalArg { + name, + kind, + default, + }); + } + + f + }) + .filter(|f| !EXCLUDED_GROUPS.contains(&f.family.as_str())) + .filter(|f| !is_excluded(&f.indicator)) + .collect() +} + +#[cfg(test)] +pub(crate) const SAMPLE: &str = r#" + + + BBANDS + Bbands + Bollinger Bands + Overlap Studies + + + Double Array + inReal + + + + + Time Period + Integer + + 2 + 100000 + + 5 + + + Deviations up + Double + 2.000000e+0 + + + MA Type + MA Type + 0 + + + + + Double Array + outRealUpperBand + + + Double Array + outRealLowerBand + + + + + CDLDOJI + Doji + Pattern Recognition + + + Open + Open + + + High + High + + + Low + Low + + + Close + Close + + + + + Integer Array + outInteger + + + + + "#; + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parses_optional_inputs() { + let f = &parse_api(SAMPLE)[0]; + + assert_eq!(f.indicator, "BBANDS"); + assert_eq!(f.title, "Bollinger Bands"); + assert_eq!(f.family, "Overlap Studies"); + assert_eq!(f.input, ["close"]); + assert_eq!(f.default_formula(), "~close"); + assert_eq!( + f.optional_input, + [ + OptionalArg { + name: "timePeriod".to_string(), + kind: OptionalType::Integer, + default: "5".to_string() + }, + OptionalArg { + name: "deviationsUp".to_string(), + kind: OptionalType::Double, + default: "2".to_string() + }, + OptionalArg { + name: "maType".to_string(), + kind: OptionalType::MAType, + default: "0".to_string() + } + ] + ); + } + + #[test] + fn parses_ohlc_inputs() { + let f = &parse_api(SAMPLE)[1]; + + assert_eq!(f.input, ["open", "high", "low", "close"]); + assert_eq!(f.default_formula(), "~open + high + low + close"); + assert!(f.optional_input.is_empty()); + } + + #[test] + fn parses_full_api() { + let xml = std::fs::read_to_string(concat!( + env!("CARGO_MANIFEST_DIR"), + "/../src/ta-lib/ta_func_api.xml" + )) + .expect("read ta_func_api.xml"); + + // 161 functions minus the 15 Math Transforms, the + // 11 Math Operators and the 9 EXCLUDED_INDICATORS + let funcs = parse_api(&xml); + assert_eq!(funcs.len(), 126); + assert!(funcs.iter().all(|f| f.family != "Math Transform")); + assert!(!funcs.iter().any(|f| f.indicator == "ACOS")); + assert!(!funcs.iter().any(|f| f.indicator == "MA")); + } +} diff --git a/codegen/src/parser.rs b/codegen/src/parser.rs deleted file mode 100644 index 8eefbc6dd..000000000 --- a/codegen/src/parser.rs +++ /dev/null @@ -1,290 +0,0 @@ -/// 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_DOUBLE", - ..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"); - } -} diff --git a/codegen/src/render.rs b/codegen/src/render.rs new file mode 100644 index 000000000..246994e3b --- /dev/null +++ b/codegen/src/render.rs @@ -0,0 +1,660 @@ +//! R wrapper rendering +//! +//! Templates are plain R files with ${...} placeholders filled by +//! simple string replacement (see the README for the placeholder +//! table). The chart-method templates are *dual-backend*: one file +//! describes both the .plotly and the .ggplot method, and +//! render_backend() renders it once per backend by +//! +//! - keeping '#plotly#'/'#ggplot#'-prefixed lines only for their +//! backend (prefix stripped), and +//! - filling ${METHOD} (plotly|ggplot), ${PKG} (plotly|ggplot2) +//! and ${SUFFIX} (ly|gg) +//! +//! After rendering, hand-edited splice regions of the existing file +//! on disk are preserved by preserve_regions() (see main.rs). + +use crate::metadata::{MetaData, OptionalArg, OptionalType}; +use crate::tables::{ChartType, agnostic, chart_type, function_name, is_candlestick, ma_type}; + +/// The template files rendered by render_indicator(), +/// loaded once from 'codegen/templates/' +pub struct Templates { + pub indicator: String, + pub numeric: String, + pub rolling: String, + pub moving_average: String, + pub candlestick: String, + pub chart_main: String, + pub chart_subchart: String, + pub chart_moving_average: String, + pub chart_candlestick: String, +} + +impl Templates { + pub fn load(dir: &str) -> Templates { + let read = |name: &str| { + std::fs::read_to_string(format!("{dir}/{name}")) + .unwrap_or_else(|e| panic!("read {dir}/{name}: {e}")) + }; + + Templates { + indicator: read("indicator_template.R"), + numeric: read("numeric_template.R"), + rolling: read("rolling_template.R"), + moving_average: read("moving_average_template.R"), + candlestick: read("candlestick_template.R"), + chart_main: read("chart_main_template.R"), + chart_subchart: read("chart_subchart_template.R"), + chart_moving_average: read("chart_moving_average_template.R"), + chart_candlestick: read("chart_candlestick_template.R"), + } + } +} + +/// One chart backend of a dual-backend template +struct Backend { + /// ${METHOD}: the S3 class, and by convention also the builder + /// (build_plotly), the init helper (plotly_init), the local + /// object (plotly_object) and the splice-region names + /// (optional-plotly, plotly-assembly) + method: &'static str, + /// ${PKG}: the package name in comments ({ggplot2}-object) + pkg: &'static str, + /// ${SUFFIX}: the chart-helper suffix (add_last_value_ly, + /// pattern_gg) + suffix: &'static str, +} + +const PLOTLY: Backend = Backend { + method: "plotly", + pkg: "plotly", + suffix: "ly", +}; + +const GGPLOT: Backend = Backend { + method: "ggplot", + pkg: "ggplot2", + suffix: "gg", +}; + +/// Render a dual-backend chart template for one backend: keep +/// '#plotly#'/'#ggplot#'-prefixed lines only for their backend +/// (prefix stripped), then fill the backend placeholders +fn render_backend(template: &str, backend: &Backend) -> String { + let own = format!("#{}#", backend.method); + + let mut out = template + .lines() + .filter_map(|line| { + if let Some(rest) = line.strip_prefix(&own) { + Some(rest) + } else if line.starts_with("#plotly#") || line.starts_with("#ggplot#") { + None + } else { + Some(line) + } + }) + .collect::>() + .join("\n"); + + if template.ends_with('\n') { + out.push('\n'); + } + + // a marker-shaped line ('#word#...') surviving the filter is a + // typo'd or unknown backend prefix; left alone it would ship as + // a plain R comment, silently disabling the line in both + // backends + for line in out.lines() { + if let Some(rest) = line.trim_start().strip_prefix('#') { + if let Some(end) = rest.find('#') { + if end > 0 && rest[..end].chars().all(|c| c.is_ascii_alphanumeric()) { + panic!("unknown backend prefix in template line: {line}"); + } + } + } + } + + out.replace("${METHOD}", backend.method) + .replace("${PKG}", backend.pkg) + .replace("${SUFFIX}", backend.suffix) +} + +/// Render the R wrapper of an indicator from its family's main +/// template plus the conditional methods: +/// +/// - candlestick patterns (CDL*): 'candlestick_template.R' with +/// the chart methods from 'chart_candlestick_template.R' +/// - moving averages (see MOVING_AVERAGES): the spec-mode +/// 'moving_average_template.R' (.numeric baked in) with the +/// chart methods from 'chart_moving_average_template.R' +/// - rolling statistics (GroupId 'Statistic Functions'): +/// 'rolling_template.R', not plotable, .numeric baked in +/// - everything else: 'indicator_template.R'; univariate +/// indicators (a single input series) get the appended +/// .numeric method, chartable indicators (see CHART_TYPES) +/// the methods from 'chart_main_template.R' or +/// 'chart_subchart_template.R' +/// +/// Multi-entry placeholders (ARGS, PARGS) carry their own trailing +/// comma per entry so that indicators without optional inputs +/// render an empty line instead of a dangling comma +pub fn render_indicator(f: &MetaData, t: &Templates) -> String { + // the R function name, e.g. BBANDS -> bollinger_bands + let fun = function_name(&f.indicator); + + // the TA_MAType index literal, Some for the nine + // moving averages rendered in spec-mode + let ma_index = ma_type(&f.indicator); + + // default column formula, e.g. ~high + low + close + let formula = f.default_formula(); + + // the generic's formal arguments: the XML optional inputs, + // plus a spec-only timePeriod injected for moving averages + // whose C signature has no period (MAMA) so that every MA + // spec carries one for its downstream consumers. The injected + // formal is deliberately absent from the .Call() coercions + let mut formals = f.optional_input.clone(); + if ma_index.is_some() && !formals.iter().any(|a| a.name == "timePeriod") { + formals.insert( + 0, + OptionalArg { + name: "timePeriod".to_string(), + kind: OptionalType::Integer, + default: "30".to_string(), + }, + ); + } + + // formals and pass-through arguments, + // e.g. 'timePeriod = 14,' and 'timePeriod = timePeriod,' + let args = formals + .iter() + .map(|a| format!("{} = {},", a.name, a.default)) + .collect::>() + .join("\n\t"); + + let pargs = formals + .iter() + .map(|a| format!("{} = {},", a.name, a.name)) + .collect::>() + .join("\n\t\t\t"); + + // the spec-mode list fields of the moving_average template: + // each formal round-trips as 'name = if (missing(name)) + // else as.(name)' in the list returned without 'x' + let spec_fields = formals + .iter() + .map(|a| match a.kind { + OptionalType::Double => format!( + "{name} = if (missing({name})) {} else as.double({name})", + a.default, + name = a.name + ), + _ => format!( + "{name} = if (missing({name})) {}L else as.integer({name})", + a.default, + name = a.name + ), + }) + .collect::>() + .join(",\n\t\t\t\t"); + + // the bare argument names of the chart label(), + // each with a leading comma: label("SMA", timePeriod) + let cargs = f + .optional_input + .iter() + .map(|a| format!(", {}", a.name)) + .collect::(); + + // the coerced optional inputs of the .Call() arguments + let coercions: Vec = f + .optional_input + .iter() + .map(|a| match a.kind { + OptionalType::Double => format!("as.double({})", a.name), + _ => format!("as.integer({})", a.name), + }) + .collect(); + + // the .Call() arguments: one constructed_series column per + // required input (the raw vector for the numeric method) + // followed by the coerced optional inputs + let c_signature = (1..=f.input.len()) + .map(|i| format!("constructed_series[[{i}]]")) + .chain(coercions.iter().cloned()) + .collect::>() + .join(",\n\t\t"); + + let c_numeric = std::iter::once("as.double(x)".to_string()) + .chain(coercions.iter().cloned()) + .collect::>() + .join(",\n\t\t"); + + // the .Call() arguments of the lookback wrapper: only the + // coerced optional inputs (see TA_LB_WRAPPER in src/wrapper.h). + // Each entry carries a *leading* comma so that indicators + // without optional inputs render .Call(C_impl_ta_X_lookback) + // without a dangling empty argument + let c_lookback = coercions + .iter() + .map(|c| format!(",\n\t\t{c}")) + .collect::(); + + let fill = |template: &str| { + template + .replace("${FUN}", fun) + .replace("${ALIAS}", &f.indicator) + .replace("${TITLE}", &f.title) + .replace("${FAMILY}", &f.family) + .replace("${FORMULA}", &formula) + .replace("${ARGS}", &args) + .replace("${PARGS}", &pargs) + .replace("${C_SIGNATURE_LOOKBACK}", &c_lookback) + .replace("${C_SIGNATURE}", &c_signature) + .replace("${C_NUMERIC}", &c_numeric) + .replace("${SPEC_FIELDS}", &spec_fields) + .replace("${MA_TYPE}", ma_index.unwrap_or("-1L")) + .replace("${CARGS}", &cargs) + .replace("${AGNOSTIC}", agnostic(&f.indicator)) + }; + + // both chart methods from one dual-backend template, + // .plotly before .ggplot, matching the existing wrappers + let chart = |template: &str| { + format!( + "{}\n{}", + fill(&render_backend(template, &PLOTLY)), + fill(&render_backend(template, &GGPLOT)) + ) + }; + + let out = if is_candlestick(&f.indicator) { + format!("{}\n{}", fill(&t.candlestick), chart(&t.chart_candlestick)) + } else if ma_index.is_some() { + format!( + "{}\n{}", + fill(&t.moving_average), + chart(&t.chart_moving_average) + ) + } else if f.family == "Statistic Functions" { + fill(&t.rolling) + } else { + let mut out = fill(&t.indicator); + + // univariate indicators (a single input series) + // carry a .numeric method + if f.input.len() == 1 { + out.push('\n'); + out.push_str(&fill(&t.numeric)); + } + + if let Some(kind) = chart_type(&f.indicator) { + out.push('\n'); + out.push_str(&chart(match kind { + ChartType::Main => &t.chart_main, + ChartType::Sub => &t.chart_subchart, + })); + } + + out + }; + + strip_blank_indentation(&out) +} + +/// Empty multi-entry placeholders (${ARGS}, ${PARGS}) leave their +/// line's bare indentation behind, e.g. a whitespace-only line +/// between 'cols,' and 'na.bridge = FALSE,' for indicators without +/// optional inputs, which air does not reformat away. Drop those +/// lines; truly empty lines (paragraph separators) are kept +fn strip_blank_indentation(rendered: &str) -> String { + let mut out: String = rendered + .lines() + .filter(|line| line.is_empty() || !line.trim().is_empty()) + .collect::>() + .join("\n"); + + if rendered.ends_with('\n') { + out.push('\n'); + } + + out +} + +/// Protected regions +/// +/// Content between '## splice::start' and '## splice::end' +/// marker lines survives regeneration: for every region present in +/// both the freshly rendered output and the previously generated +/// file, the rendered default is replaced by the existing content. +/// Regions absent from the existing file keep the rendered default +pub fn preserve_regions(rendered: &str, existing: &str) -> String { + let mut out = rendered.to_string(); + + // the regions of the rendered output, in order + let names: Vec = rendered + .lines() + .filter_map(|line| { + line.trim() + .strip_prefix("## splice:")? + .strip_suffix(":start") + .map(str::to_string) + }) + .collect(); + + // region_span() only ever matches the first occurrence of a + // name, so a duplicated name would silently lose the hand + // edits of every later occurrence + for (i, name) in names.iter().enumerate() { + if names[..i].contains(name) { + panic!("duplicate splice region '{name}' in rendered output"); + } + } + + // spans are recomputed per region since each + // replacement shifts the offsets after it + for name in names { + if let (Some((out_start, out_end)), Some((existing_start, existing_end))) = + (region_span(&out, &name), region_span(existing, &name)) + { + out.replace_range(out_start..out_end, &existing[existing_start..existing_end]); + } + } + + out +} + +/// The content span between a region's marker lines: starts on +/// the line after '## splice::start' and ends at the +/// beginning of the '## splice::end' line +fn region_span(text: &str, name: &str) -> Option<(usize, usize)> { + let start_marker = format!("## splice:{name}:start"); + let end_marker = format!("## splice:{name}:end"); + + let start = text.find(&start_marker)?; + let content_start = start + start_marker.len(); + let content_start = content_start + text[content_start..].find('\n')? + 1; + + let end = content_start + text[content_start..].find(&end_marker)?; + let content_end = text[..end].rfind('\n').map_or(0, |i| i + 1); + + Some((content_start, content_end)) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::metadata::{SAMPLE, parse_api}; + + #[test] + fn strips_blank_indentation() { + let rendered = "\ +stick_sandwich <- function( +\tx, +\tcols, +\t +\tna.bridge = FALSE, +\t...) { +} + +next_function\n"; + + // the whitespace-only argument line vanishes, + // the empty separator line stays + assert_eq!( + strip_blank_indentation(rendered), + "\ +stick_sandwich <- function( +\tx, +\tcols, +\tna.bridge = FALSE, +\t...) { +} + +next_function\n" + ); + } + + #[test] + fn renders_backend_variants() { + let template = "\ +${FUN}.${METHOD} <- function(x) { +#plotly#\tassert_plotly_object(x) +#ggplot#\tassert_ggplot2() +\t## construct {${PKG}}-object +\tadd_last_value_${SUFFIX}(x) +} +"; + + // each backend keeps its own conditional lines (prefix + // stripped) and fills the backend placeholders; the + // indicator placeholders are left for fill() + assert_eq!( + render_backend(template, &PLOTLY), + "\ +${FUN}.plotly <- function(x) { +\tassert_plotly_object(x) +\t## construct {plotly}-object +\tadd_last_value_ly(x) +} +" + ); + assert_eq!( + render_backend(template, &GGPLOT), + "\ +${FUN}.ggplot <- function(x) { +\tassert_ggplot2() +\t## construct {ggplot2}-object +\tadd_last_value_gg(x) +} +" + ); + } + + #[test] + fn preserves_protected_regions() { + let rendered = "\ +head +\t## splice:documentation:start +\tdefault docs +\t## splice:documentation:end +mid +\t## splice:plotly-assembly:start +\tdefault traces +\t## splice:plotly-assembly:end +tail +"; + let existing = "\ +old head +\t## splice:documentation:start +\tcustom docs +\tsecond line +\t## splice:documentation:end +old mid +\t## splice:plotly-assembly:start +\tcustom traces +\t## splice:plotly-assembly:end +old tail +"; + + // both regions carry over their existing content while + // everything outside the markers is regenerated + let preserved = preserve_regions(rendered, existing); + assert_eq!( + preserved, + "\ +head +\t## splice:documentation:start +\tcustom docs +\tsecond line +\t## splice:documentation:end +mid +\t## splice:plotly-assembly:start +\tcustom traces +\t## splice:plotly-assembly:end +tail +" + ); + + // no regions in the existing file: + // the rendered default is kept + assert_eq!(preserve_regions(rendered, "plain old file"), rendered); + + // emptied-out region in the existing + // file stays empty after regeneration + let emptied = "\ +\t## splice:documentation:start +\t## splice:documentation:end +"; + let preserved = preserve_regions(rendered, emptied); + assert!( + preserved.contains("\t## splice:documentation:start\n\t## splice:documentation:end") + ); + assert!(preserved.contains("default traces")); + } + + #[test] + fn renders_template() { + let funcs = parse_api(SAMPLE); + let templates = Templates::load(concat!(env!("CARGO_MANIFEST_DIR"), "/templates")); + + let rendered = render_indicator(&funcs[0], &templates); + + assert!(rendered.contains("bollinger_bands <- function(")); + assert!(rendered.contains("BBANDS <- bollinger_bands")); + assert!(rendered.contains("timePeriod = 5,")); + assert!(rendered.contains("deviationsUp = 2,")); + assert!(rendered.contains("default_formula = ~close,")); + assert!(rendered.contains("C_impl_ta_BBANDS,")); + assert!(rendered.contains("constructed_series[[1]]")); + assert!(rendered.contains("as.integer(timePeriod)")); + assert!(rendered.contains("as.double(deviationsUp)")); + assert!(!rendered.contains("${"), "unreplaced placeholder"); + + // univariate: the numeric method is appended + // after the matrix method with the raw vector + assert!(rendered.contains("bollinger_bands.numeric <- function(")); + assert!(rendered.contains("as.double(x)")); + + // the lookback wrapper passes only the + // coerced optional inputs to C + assert!(rendered.contains("bollinger_bands_lookback <- function(")); + assert!(rendered.contains( + "C_impl_ta_BBANDS_lookback,\n\t\tas.integer(timePeriod),\n\t\tas.double(deviationsUp),\n\t\tas.integer(maType)\n\t)" + )); + + // BBANDS is a Main chart indicator: the plotly and ggplot + // methods are rendered from the dual-backend template and + // draw onto the main chart state + assert!(rendered.contains("bollinger_bands.plotly <- function(")); + assert!(rendered.contains("bollinger_bands.ggplot <- function(")); + assert!(rendered.contains("## splice:optional-plotly:start")); + assert!(rendered.contains("## splice:ggplot-assembly:start")); + assert!(rendered.contains("state[[\"main\"]]")); + assert!(!rendered.contains("#plotly#"), "unstripped backend prefix"); + assert!(!rendered.contains("#ggplot#"), "unstripped backend prefix"); + + // CDL* renders from the candlestick template: normalized + // pattern codes, the named output column and the chart + // methods with pattern markers + let rendered = render_indicator(&funcs[1], &templates); + + assert!(rendered.contains("doji <- function(")); + assert!(rendered.contains("CDLDOJI <- doji")); + assert!(rendered.contains("candlestick_setting()")); + assert!(rendered.contains("default_formula = ~open + high + low + close,")); + assert!(rendered.contains("colnames(x) <- \"CDLDOJI\"")); + assert!(!rendered.contains(",,")); + assert!(!rendered.contains("${"), "unreplaced placeholder"); + + // CDLDOJI is OHLC order agnostic + assert!(rendered.contains("doji.plotly <- function(")); + assert!(rendered.contains("doji.ggplot <- function(")); + assert!(rendered.contains("pattern_ly(")); + assert!(rendered.contains("pattern_gg(")); + assert!(rendered.contains("agnostic = TRUE")); + + // the candlestick template carries + // no lookback and no numeric method + assert!(!rendered.contains("_lookback")); + assert!(!rendered.contains(".numeric")); + } + + #[test] + fn renders_full_api() { + let xml = std::fs::read_to_string(concat!( + env!("CARGO_MANIFEST_DIR"), + "/../src/ta-lib/ta_func_api.xml" + )) + .expect("read ta_func_api.xml"); + let templates = Templates::load(concat!(env!("CARGO_MANIFEST_DIR"), "/templates")); + + let funcs = parse_api(&xml); + + for f in &funcs { + let rendered = render_indicator(f, &templates); + assert!( + !rendered.contains("${"), + "unreplaced placeholder in {}", + f.indicator + ); + assert!( + !rendered.contains("#plotly#") && !rendered.contains("#ggplot#"), + "unstripped backend prefix in {}", + f.indicator + ); + } + + let render = |abbreviation: &str| { + render_indicator( + funcs + .iter() + .find(|f| f.indicator == abbreviation) + .unwrap_or_else(|| panic!("{abbreviation} not parsed")), + &templates, + ) + }; + + // moving averages: spec-mode list with the TA_MAType + // index and the main-chart methods + let sma = render("SMA"); + assert!(sma.contains("simple_moving_average <- function(")); + assert!(sma.contains("maType = 0L")); + assert!( + sma.contains("timePeriod = if (missing(timePeriod)) 30L else as.integer(timePeriod)") + ); + assert!(sma.contains("legendgroup = \"MovingAverage\"")); + assert!(sma.contains("label(\"SMA\", timePeriod)")); + assert!(sma.contains("simple_moving_average.plotly <- function(")); + assert!(sma.contains("simple_moving_average.ggplot <- function(")); + + // MAMA: the injected spec-only timePeriod is a formal and + // a spec field but is absent from the .Call() arguments + let mama = render("MAMA"); + assert!( + mama.contains("timePeriod = if (missing(timePeriod)) 30L else as.integer(timePeriod)") + ); + assert!(mama.contains( + "constructed_series[[1]],\n\t\tas.double(fastLimit),\n\t\tas.double(slowLimit)" + )); + + // rolling statistics: protected .Call() region, + // no chart methods + let stddev = render("STDDEV"); + assert!(stddev.contains("rolling_standard_deviation <- function(")); + assert!(stddev.contains("@template rolling_returns")); + assert!(stddev.contains("## splice:call:start")); + assert!(stddev.contains("as.double(x),")); + assert!(!stddev.contains(".plotly")); + assert!(!stddev.contains(".ggplot")); + + // candlesticks: the agnostic flag comes + // from AGNOSTIC_PATTERNS + assert!(render("CDLDOJI").contains("agnostic = TRUE")); + assert!(render("CDLHAMMER").contains("agnostic = FALSE")); + } +} diff --git a/codegen/src/tables.rs b/codegen/src/tables.rs new file mode 100644 index 000000000..8dd60fcf2 --- /dev/null +++ b/codegen/src/tables.rs @@ -0,0 +1,355 @@ +//! The hand-maintained lookup tables +//! +//! Everything else is mined from the TA-Lib sources; these tables +//! layer the per-indicator knowledge the sources cannot provide on +//! top: the R function name, the chart type, the family +//! classifications and the exclusions. This is the one file to +//! touch when customizing how an indicator is generated. + +use crate::metadata::{tag_blocks, tag_text}; + +/// Maps to snake_case indicator names +/// and defaults to +pub const FUNCTION_NAMES: &[(&str, &str)] = &[ + ("ACCBANDS", "acceleration_bands"), + ("AD", "chaikin_accumulation_distribution_line"), + ("ADOSC", "chaikin_accumulation_distribution_oscillator"), + ("ADX", "average_directional_movement_index"), + ("ADXR", "average_directional_movement_index_rating"), + ("APO", "absolute_price_oscillator"), + ("AROON", "aroon"), + ("AROONOSC", "aroon_oscillator"), + ("ATR", "average_true_range"), + ("AVGPRICE", "average_price"), + ("BBANDS", "bollinger_bands"), + ("BETA", "rolling_beta"), + ("BOP", "balance_of_power"), + ("CCI", "commodity_channel_index"), + ("CDL2CROWS", "two_crows"), + ("CDL3BLACKCROWS", "three_black_crows"), + ("CDL3INSIDE", "three_inside"), + ("CDL3LINESTRIKE", "three_line_strike"), + ("CDL3OUTSIDE", "three_outside"), + ("CDL3STARSINSOUTH", "three_stars_in_the_south"), + ("CDL3WHITESOLDIERS", "three_white_soldiers"), + ("CDLABANDONEDBABY", "abandoned_baby"), + ("CDLADVANCEBLOCK", "advance_block"), + ("CDLBELTHOLD", "belt_hold"), + ("CDLBREAKAWAY", "break_away"), + ("CDLCLOSINGMARUBOZU", "closing_marubozu"), + ("CDLCONCEALBABYSWALL", "concealing_baby_swallow"), + ("CDLCOUNTERATTACK", "counter_attack"), + ("CDLDARKCLOUDCOVER", "dark_cloud_cover"), + ("CDLDOJI", "doji"), + ("CDLDOJISTAR", "doji_star"), + ("CDLDRAGONFLYDOJI", "dragonfly_doji"), + ("CDLENGULFING", "engulfing"), + ("CDLEVENINGDOJISTAR", "evening_doji_star"), + ("CDLEVENINGSTAR", "evening_star"), + ("CDLGAPSIDESIDEWHITE", "gaps_side_white"), + ("CDLGRAVESTONEDOJI", "gravestone_doji"), + ("CDLHAMMER", "hammer"), + ("CDLHANGINGMAN", "hanging_man"), + ("CDLHARAMI", "harami"), + ("CDLHARAMICROSS", "harami_cross"), + ("CDLHIGHWAVE", "high_wave"), + ("CDLHIKKAKE", "hikakke"), + ("CDLHIKKAKEMOD", "hikakke_mod"), + ("CDLHOMINGPIGEON", "homing_pigeon"), + ("CDLIDENTICAL3CROWS", "three_identical_crows"), + ("CDLINNECK", "in_neck"), + ("CDLINVERTEDHAMMER", "inverted_hammer"), + ("CDLKICKING", "kicking"), + ("CDLKICKINGBYLENGTH", "kicking_baby_length"), + ("CDLLADDERBOTTOM", "ladder_bottom"), + ("CDLLONGLEGGEDDOJI", "long_legged_doji"), + ("CDLLONGLINE", "long_line"), + ("CDLMARUBOZU", "marubozu"), + ("CDLMATCHINGLOW", "matching_low"), + ("CDLMATHOLD", "mat_hold"), + ("CDLMORNINGDOJISTAR", "morning_doji_star"), + ("CDLMORNINGSTAR", "morning_star"), + ("CDLONNECK", "on_neck"), + ("CDLPIERCING", "piercing"), + ("CDLRICKSHAWMAN", "rickshaw_man"), + ("CDLRISEFALL3METHODS", "rise_fall_3_methods"), + ("CDLSEPARATINGLINES", "separating_lines"), + ("CDLSHOOTINGSTAR", "shooting_star"), + ("CDLSHORTLINE", "short_line"), + ("CDLSPINNINGTOP", "spinning_top"), + ("CDLSTALLEDPATTERN", "stalled_pattern"), + ("CDLSTICKSANDWICH", "stick_sandwich"), + ("CDLTAKURI", "takuri"), + ("CDLTASUKIGAP", "tasuki_gap"), + ("CDLTHRUSTING", "thrusting"), + ("CDLTRISTAR", "tristar"), + ("CDLUNIQUE3RIVER", "unique_3_river"), + ("CDLUPSIDEGAP2CROWS", "upside_gap_2_crows"), + ("CDLXSIDEGAP3METHODS", "xside_gap_3_methods"), + ("CMO", "chande_momentum_oscillator"), + ("CORREL", "rolling_correlation"), + ("DEMA", "double_exponential_moving_average"), + ("DX", "directional_movement_index"), + ("EMA", "exponential_moving_average"), + ("HT_DCPERIOD", "dominant_cycle_period"), + ("HT_DCPHASE", "dominant_cycle_phase"), + ("HT_PHASOR", "phasor_components"), + ("HT_SINE", "sine_wave"), + ("HT_TRENDLINE", "trendline"), + ("HT_TRENDMODE", "trend_cycle_mode"), + ("IMI", "intraday_movement_index"), + ("KAMA", "kaufman_adaptive_moving_average"), + ("MACD", "moving_average_convergence_divergence"), + ("MACDEXT", "extended_moving_average_convergence_divergence"), + ("MACDFIX", "fixed_moving_average_convergence_divergence"), + ("MAMA", "mesa_adaptive_moving_average"), + ("MAX", "rolling_max"), + ("MEDPRICE", "median_price"), + ("MFI", "money_flow_index"), + ("MIDPRICE", "midpoint_price"), + ("MIN", "rolling_min"), + ("MINUS_DI", "minus_directional_indicator"), + ("MINUS_DM", "minus_directional_movement"), + ("MOM", "momentum"), + ("NATR", "normalized_average_true_range"), + ("OBV", "on_balance_volume"), + ("PLUS_DI", "plus_directional_indicator"), + ("PLUS_DM", "plus_directional_movement"), + ("PPO", "percentage_price_oscillator"), + ("ROC", "rate_of_change"), + ("ROCR", "ratio_of_change"), + ("RSI", "relative_strength_index"), + ("SAR", "parabolic_stop_and_reverse"), + ("SAREXT", "extended_parabolic_stop_and_reverse"), + ("SMA", "simple_moving_average"), + ("STDDEV", "rolling_standard_deviation"), + ("STOCH", "stochastic"), + ("STOCHF", "fast_stochastic"), + ("STOCHRSI", "stochastic_relative_strength_index"), + ("SUM", "rolling_sum"), + ("T3", "t3_exponential_moving_average"), + ("TEMA", "triple_exponential_moving_average"), + ("TRANGE", "true_range"), + ("TRIMA", "triangular_moving_average"), + ("TRIX", "triple_exponential_average"), + ("TYPPRICE", "typical_price"), + ("ULTOSC", "ultimate_oscillator"), + ("VAR", "rolling_variance"), + ("VOLUME", "trading_volume"), + ("WCLPRICE", "weighted_close_price"), + ("WILLR", "williams_oscillator"), + ("WMA", "weighted_moving_average"), +]; + +/// The snake_case R name of an indicator, +/// e.g. BBANDS -> bollinger_bands +pub fn function_name(abbreviation: &str) -> &str { + FUNCTION_NAMES + .iter() + .find(|(alias, _)| *alias == abbreviation) + .map(|(_, fun)| *fun) + .unwrap_or(abbreviation) +} + +/// Main indicators overlay the candlestick chart itself while +/// Sub indicators get their own panel below it. Indicators absent +/// from CHART_TYPES are not chartable and get no chart methods +#[derive(Debug, PartialEq)] +pub enum ChartType { + Main, + Sub, +} + +pub const CHART_TYPES: &[(&str, ChartType)] = &[ + ("ACCBANDS", ChartType::Main), + ("AD", ChartType::Sub), + ("ADOSC", ChartType::Sub), + ("ADX", ChartType::Sub), + ("ADXR", ChartType::Sub), + ("APO", ChartType::Sub), + ("AROON", ChartType::Sub), + ("AROONOSC", ChartType::Sub), + ("ATR", ChartType::Sub), + ("BBANDS", ChartType::Main), + ("BOP", ChartType::Sub), + ("CCI", ChartType::Sub), + ("CMO", ChartType::Sub), + ("DX", ChartType::Sub), + ("HT_DCPERIOD", ChartType::Sub), + ("HT_DCPHASE", ChartType::Sub), + ("HT_PHASOR", ChartType::Sub), + ("HT_SINE", ChartType::Sub), + ("HT_TRENDLINE", ChartType::Main), + ("HT_TRENDMODE", ChartType::Sub), + ("IMI", ChartType::Sub), + ("MACD", ChartType::Sub), + ("MACDEXT", ChartType::Sub), + ("MACDFIX", ChartType::Sub), + ("MFI", ChartType::Sub), + ("MINUS_DI", ChartType::Sub), + ("MINUS_DM", ChartType::Sub), + ("MOM", ChartType::Sub), + ("NATR", ChartType::Sub), + ("OBV", ChartType::Sub), + ("PLUS_DI", ChartType::Sub), + ("PLUS_DM", ChartType::Sub), + ("PPO", ChartType::Sub), + ("ROC", ChartType::Sub), + ("ROCR", ChartType::Sub), + ("RSI", ChartType::Sub), + ("SAR", ChartType::Main), + ("SAREXT", ChartType::Main), + ("STOCH", ChartType::Sub), + ("STOCHF", ChartType::Sub), + ("STOCHRSI", ChartType::Sub), + ("TRANGE", ChartType::Sub), + ("TRIX", ChartType::Sub), + ("ULTOSC", ChartType::Sub), + ("VOLUME", ChartType::Sub), + ("WILLR", ChartType::Sub), +]; + +pub fn chart_type(abbreviation: &str) -> Option<&'static ChartType> { + CHART_TYPES + .iter() + .find(|(alias, _)| *alias == abbreviation) + .map(|(_, kind)| kind) +} + +/// The TA-Lib moving averages and their TA_MAType index, +/// rendered via 'codegen/templates/moving_average_template.R'. +/// The index fills ${MA_TYPE} in the spec-mode list returned +/// when the MA is called without 'x' (used by e.g. stochastic() +/// to construct its smoothing lines) +pub const MOVING_AVERAGES: &[(&str, &str)] = &[ + ("SMA", "0L"), + ("EMA", "1L"), + ("WMA", "2L"), + ("DEMA", "3L"), + ("TEMA", "4L"), + ("TRIMA", "5L"), + ("KAMA", "6L"), + ("MAMA", "7L"), + ("T3", "8L"), +]; + +/// The TA_MAType index literal of a moving average; +/// None for everything that is not a moving average +pub fn ma_type(indicator: &str) -> Option<&'static str> { + MOVING_AVERAGES + .iter() + .find(|(abbreviation, _)| *abbreviation == indicator) + .map(|(_, index)| *index) +} + +/// The candlestick patterns (Abbreviation starting with "CDL") +/// that are OHLC order agnostic; fills ${AGNOSTIC} with TRUE in +/// the pattern_ly()/pattern_gg() chart markers +pub const AGNOSTIC_PATTERNS: &[&str] = &[ + "CDLCLOSINGMARUBOZU", + "CDLDOJI", + "CDLHIGHWAVE", + "CDLKICKINGBYLENGTH", + "CDLLONGLEGGEDDOJI", + "CDLLONGLINE", + "CDLPIERCING", + "CDLSHOOTINGSTAR", + "CDLSHORTLINE", +]; + +/// Returns true if the indicator is +/// a candlestick pattern +pub fn is_candlestick(indicator: &str) -> bool { + indicator.starts_with("CDL") +} + +/// The R literal for the pattern's OHLC order agnosticism +pub fn agnostic(indicator: &str) -> &'static str { + if AGNOSTIC_PATTERNS.contains(&indicator) { + "TRUE" + } else { + "FALSE" + } +} + +/// Indicators excluded from porting altogether, by TA-Lib +/// abbreviation: filtered out of both the C wrapper generation +/// (src/TA-Lib.h) and the R wrapper generation (R/ta_*.R) +pub const EXCLUDED_INDICATORS: &[&str] = &[ + "MA", + "ROC", + "ROCP", + "ROCR", + "ROCR100", + "LINEARREG", + "LINEARREG_ANGLE", + "LINEARREG_SLOPE", + "LINEARREG_INTERCEPT", +]; + +/// GroupIds excluded from generation altogether; +/// R already ships vectorized math (sqrt, log, sin, ...) +/// so the Math Transform indicators are redundant +pub const EXCLUDED_GROUPS: &[&str] = &["Math Transform", "Math Operators"]; + +/// Returns true if the indicator should be +/// skipped by the generators +pub fn is_excluded(indicator: &str) -> bool { + EXCLUDED_INDICATORS.contains(&indicator) +} + +/// All excluded abbreviations, listed directly or via their GroupId; +/// mined from 'src/ta-lib/ta_func_api.xml' since the C generation +/// inputs (ta_func_list.txt, ta_func.h) carry no group information +pub fn excluded_indicators(xml: &str) -> Vec { + tag_blocks(xml, "FinancialFunction") + .iter() + .filter(|block| EXCLUDED_GROUPS.contains(&tag_text(block, "GroupId").expect("GroupId"))) + .map(|block| { + tag_text(block, "Abbreviation") + .expect("Abbreviation") + .to_string() + }) + .chain(EXCLUDED_INDICATORS.iter().map(|s| s.to_string())) + .collect() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn function_name_falls_back_to_abbreviation() { + assert_eq!(function_name("BBANDS"), "bollinger_bands"); + assert_eq!(function_name("NOT_A_REAL_FUNC"), "NOT_A_REAL_FUNC"); + } + + #[test] + fn excludes_by_group() { + let xml = "\ + + ACOS + Math Transform + + + ADD + Math Operators + + + BBANDS + Overlap Studies +"; + + let excluded = excluded_indicators(xml); + + // group-mined abbreviations are in, the rest are not + assert!(excluded.contains(&"ACOS".to_string())); + assert!(excluded.contains(&"ADD".to_string())); + assert!(!excluded.contains(&"BBANDS".to_string())); + + // the name-based list is chained in + for name in EXCLUDED_INDICATORS { + assert!(excluded.contains(&name.to_string())); + } + } +} diff --git a/codegen/generate_unit-tests.sh b/codegen/src/testthat.rs old mode 100755 new mode 100644 similarity index 59% rename from codegen/generate_unit-tests.sh rename to codegen/src/testthat.rs index f03f83c80..ad98b2a40 --- a/codegen/generate_unit-tests.sh +++ b/codegen/src/testthat.rs @@ -1,37 +1,31 @@ -#!/usr/bin/env bash -set -euo pipefail - -## 1) environment variables -## to determine unit-tests -FUN=${FUN:?} -TA_FUN=${TA_FUN:?} -ALIAS=${ALIAS:-$TA_FUN} -FORMULA=${FORMULA:-"~close"} -PLOTLY=${PLOTLY:-0} -NUMERIC=${NUMERIC:-1} -OUTPUTFILE=${OUTPUTFILE:-"tests/testthat/test-ta_${TA_FUN}.R"} -ROLLING=${ROLLING:-0} - -## 2) fast-track exiting of the -## program for rolling statistics -if [[ $ROLLING -eq 1 ]]; then - -## 2.2) check if the signature includes -## a 'y' and set it to SPY[[2]] -ADDITIONAL='' - for a in "$@"; do - case "$a" in - y|y=*) ADDITIONAL=',y=SPY[,2]'; break ;; - esac -done - -cat > ${OUTPUTFILE} << EOF +//! testthat file generation +//! +//! Renders one testthat file per indicator, written to +//! 'tests/testthat/test-ta_.R' by main() and overwritten on +//! every run (no protected regions). What a file contains follows +//! from the metadata: +//! +//! - rolling statistics (GroupId 'Statistic Functions'): a short +//! fast-track file (',y=SPY[,2]' appended for the bivariate +//! BETA/CORREL) +//! - chartable indicators: .plotly/.ggplot method tests, including +//! candlesticks and moving averages whose chart methods render +//! from their own templates +//! - univariate indicators (a single input series): a .numeric +//! method test + +use crate::metadata::MetaData; +use crate::tables::{chart_type, function_name, is_candlestick, ma_type}; + +const HEADER: &str = "\ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration -## +## ## author: Serkan Korkmaz +"; +const ROLLING_TESTS: &str = r#" ## test that the function runs without ## any conditions testthat::test_that(desc = 'Runs without *any* conditions', code = { @@ -40,7 +34,7 @@ testthat::test_that(desc = 'Runs without *any* conditions', code = { { ${FUN}( x = SPY[,1]${ADDITIONAL} - ) + ) } ) }) @@ -74,28 +68,15 @@ testthat::expect_true( ) }) +"#; - -EOF - -exit 0; -fi - -## 1) populate test file -## with standard stuff -cat > ${OUTPUTFILE} <> ${OUTPUTFILE} <-method checks for ## and -## +## ## checks testthat::test_that(desc = '-methods for ', code = { ## check that ${FUN} can @@ -277,13 +254,9 @@ testthat::test_that(desc = '-methods for ', code = { inherits(output, "plotly") ) }) -EOF -fi - -## Add ggplot2 methods -if [[ $PLOTLY -eq 1 ]]; then - cat >> ${OUTPUTFILE} <-method checks for ## and ## @@ -330,13 +303,9 @@ testthat::test_that(desc = '-methods for ', code = { inherits(output, "gg") || inherits(output, "talib_chart") ) }) -EOF -fi - -## add methods -if [[ $NUMERIC -eq 1 ]]; then - cat >> ${OUTPUTFILE} < methods runs without ## issues and returns proper lengths testthat::test_that(desc = ' methods', code = { @@ -357,5 +326,104 @@ testthat::test_that(desc = ' methods', code = { testthat::expect_equal(nrow(x), target_length) } }) -EOF -fi +"#; + +/// Render the testthat file of an indicator +pub fn render_test(f: &MetaData) -> String { + let fun = function_name(&f.indicator); + + // rolling statistics fast-track: a short univariate file, + // with the second input series of BETA/CORREL passed as 'y' + if f.family == "Statistic Functions" { + let additional = if f.input.len() > 1 { ",y=SPY[,2]" } else { "" }; + + return format!( + "{HEADER}{}", + ROLLING_TESTS + .replace("${FUN}", fun) + .replace("${ADDITIONAL}", additional) + ); + } + + let fill = |template: &str| { + template + .replace("${FUN}", fun) + .replace("${ALIAS}", &f.indicator) + .replace("${FORMULA}", &f.default_formula()) + }; + + let mut out = format!("{HEADER}{}", fill(STANDARD_TESTS)); + + // chartable indicators: candlesticks and moving averages carry + // their chart methods regardless of CHART_TYPES + let chartable = chart_type(&f.indicator).is_some() + || is_candlestick(&f.indicator) + || ma_type(&f.indicator).is_some(); + + if chartable { + out.push_str(&fill(PLOTLY_TESTS)); + out.push_str(&fill(GGPLOT_TESTS)); + } + + // univariate indicators carry a .numeric method + if f.input.len() == 1 { + out.push_str(&fill(NUMERIC_TESTS)); + } + + out +} + +#[cfg(test)] +mod tests { + use super::*; + + fn meta(indicator: &str, family: &str, input: &[&str]) -> MetaData { + MetaData { + indicator: indicator.to_string(), + family: family.to_string(), + input: input.iter().map(|s| s.to_string()).collect(), + ..Default::default() + } + } + + #[test] + fn renders_standard_chartable_test() { + let rendered = render_test(&meta("BBANDS", "Overlap Studies", &["close"])); + + assert!(rendered.contains("output <- bollinger_bands(SPY)")); + assert!(rendered.contains("alias <- BBANDS(SPY)")); + assert!(rendered.contains("cols = ~close")); + assert!(rendered.contains("-methods for ")); + assert!(rendered.contains("-methods for ")); + assert!(rendered.contains(" methods")); + assert!(!rendered.contains("${"), "unreplaced placeholder"); + } + + #[test] + fn renders_candlestick_test_without_numeric() { + let rendered = render_test(&meta( + "CDLDOJI", + "Pattern Recognition", + &["open", "high", "low", "close"], + )); + + assert!(rendered.contains("cols = ~open + high + low + close")); + assert!(rendered.contains("-methods for ")); + assert!(!rendered.contains(" methods")); + } + + #[test] + fn renders_rolling_tests() { + let rendered = render_test(&meta("STDDEV", "Statistic Functions", &["close"])); + + assert!(rendered.contains("Runs without *any* conditions")); + assert!(rendered.contains("x = SPY[,1]\n")); + assert!(!rendered.contains("y=SPY[,2]")); + assert!(!rendered.contains("Alias and function similarity")); + + // the bivariate rolling statistics pass + // the second column as 'y' + let rendered = render_test(&meta("BETA", "Statistic Functions", &["close", "close"])); + assert!(rendered.contains("x = SPY[,1],y=SPY[,2]")); + } +} diff --git a/codegen/templates/candlestick_template.R b/codegen/templates/candlestick_template.R new file mode 100644 index 000000000..5ff29ac06 --- /dev/null +++ b/codegen/templates/candlestick_template.R @@ -0,0 +1,146 @@ +#' @export +#' @family ${FAMILY} +#' +#' @title ${TITLE} +#' @templateVar .title ${TITLE} +#' @templateVar .author Serkan Korkmaz +#' @templateVar .fun ${FUN} +#' @templateVar .family ${FAMILY} +#' @templateVar .formula ${FORMULA} +#' +#' @returns +#' An object of same [class] and [length] of `x`: +#' +#' \describe{ +#' \item{${ALIAS}}{[integer]} +#' } +#' +#' Pattern codes depend on `options(talib.normalize)`: +#' +#' * If `TRUE`: `1` = identified pattern; `-1` = identified bearish pattern. +#' * If `FALSE`: `100` = identified pattern; `-100` = identified bearish pattern. +#' * `0` = no pattern. +#' +#' @template description +#' @template candlestick +${FUN} <- function( + x, + cols, + ${ARGS} + na.bridge = FALSE, + ...) { + UseMethod("${FUN}") +} + +#' @export +#' @usage NULL +#' @rdname ${FUN} +#' +#' @aliases ${FUN} +${ALIAS} <- ${FUN} + +#' @usage NULL +#' @aliases ${FUN} +#' +#' @export +${FUN}.default <- function( + x, + cols, + ${ARGS} + na.bridge = FALSE, + ...) { + + ## get candlestick pattern + ## options + ## + ## NOTE: this adds an overhead + ## of ~60% (from 50 microseconds to 80 microseconds) it needs to be set outside of the function without bloating the number of functions + candlestick_setting() + + ## get normalization option + normalize <- as.logical( + getOption("talib.normalize", TRUE) + ) + + ## 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, + ... + ) + + ## extract rownames + ## for later attachment + x_names <- rownames(constructed_series) + + ## calculate indicator and + ## return as data.frame + x <- as.matrix( + .Call( + C_impl_ta_${ALIAS}, + ${C_SIGNATURE}, + normalize, + as.logical(na.bridge) + ) + ) + + ## add column name + colnames(x) <- "${ALIAS}" + + ## readd rownames + set_rownames(x, x_names) + + ## return indicator + x +} + +#' @usage NULL +#' @aliases ${FUN} +#' +#' @export +${FUN}.data.frame <- function( + x, + cols, + ${ARGS} + na.bridge = FALSE, + ... +) { + map_dfr( + ${FUN}.default( + x = x, + cols = cols, + ${PARGS} + na.bridge = na.bridge, + ... + ) + ) + +} + +#' @usage NULL +#' @aliases ${FUN} +#' +#' @export +${FUN}.matrix <- function( + x, + cols, + ${ARGS} + na.bridge = FALSE, + ...) { + + ${FUN}.default( + x = x, + cols = cols , + ${PARGS} + na.bridge = na.bridge, + ... + ) +} diff --git a/codegen/templates/candlestick_template.R.in b/codegen/templates/candlestick_template.R.in deleted file mode 100644 index a1d685cb1..000000000 --- a/codegen/templates/candlestick_template.R.in +++ /dev/null @@ -1,188 +0,0 @@ -#' @export -#' @family Pattern Recognition -#' -#' @title $TITLE -#' @templateVar .title $TITLE -#' @templateVar .author Serkan Korkmaz -#' @templateVar .fun $FUN -#' @templateVar .family ${FAMILY} -#' @templateVar .formula ${FORMULA} -#' -#' @returns -#' An object of same [class] and [length] of `x`: -#' -#' \describe{ -#' \item{$ALIAS}{[integer]} -#' } -#' -#' Pattern codes depend on `options(talib.normalize)`: -#' -#' * If `TRUE`: `1` = identified pattern; `-1` = identified bearish pattern. -#' * If `FALSE`: `100` = identified pattern; `-100` = identified bearish pattern. -#' * `0` = no pattern. -#' -#' @template description -#' @template candlestick -$FUN <- function( - x, - cols, ${ARGS} - na.bridge = FALSE, - ...) { - UseMethod("$FUN") -} - -#' @export -#' @usage NULL -#' @rdname $FUN -#' -#' @aliases $FUN -$ALIAS <- $FUN - -#' @usage NULL -#' @aliases $FUN -#' -#' @export -$FUN.default <- function( - x, - cols, ${ARGS} - na.bridge = FALSE, - ...) { - - ## get candlestick pattern - ## options - ## - ## NOTE: this adds an overhead - ## of ~60% (from 50 microseconds to 80 microseconds) it needs to be set outside of the function without bloating the number of functions - candlestick_setting() - - ## get normalization option - normalize <- as.logical( - getOption("talib.normalize", TRUE) - ) - - ## 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, - ... - ) - - ## extract rownames - ## for later attachment - x_names <- rownames(constructed_series) - - ## calculate indicator and - ## return as data.frame - x <- as.matrix( - .Call( - C_impl_ta_$ALIAS, - constructed_series[[1]], - constructed_series[[2]], - constructed_series[[3]], - constructed_series[[4]] ${CARGS}, - normalize, - as.logical(na.bridge) - ) - ) - - ## add column name - colnames(x) <- "$ALIAS" - - ## readd rownames - set_rownames(x, x_names) - - ## return indicator - x -} - -#' @usage NULL -#' @aliases $FUN -#' -#' @export -$FUN.data.frame <- function( - x, - cols, ${ARGS} - na.bridge = FALSE, - ...) { - - map_dfr( - NextMethod() - ) -} - -#' @usage NULL -#' @aliases $FUN -#' -#' @export -$FUN.matrix <- function( - x, - cols,${ARGS} - na.bridge = FALSE, - ...) { - NextMethod() -} - -#' @usage NULL -#' @aliases $FUN -#' -#' @export -$FUN.plotly <- function( - x, - cols, ${ARGS} - na.bridge = FALSE, - ...) { - - ## check that input value - ## 'x' is -object - assert_plotly_object(x) - - ## check that input value - ## 'cols' is a -objet - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series from - ## {plotly}-object - constructed_series <- series( - x = x, - formula = cols, - default_formula = ~open + high + low + close, - ... - ) - - ## construct indicator - ## from the series - constructed_indicator <- $FUN( - x = constructed_series, - cols = rebuild_formula( - names(constructed_series) - )${PPARGS} - ) - - ## add conditional idx - constructed_indicator[["idx"]] <- add_idx( - constructed_series - ) - - ## construct {plotly}-object - state <- .chart_state() - plotly_object <- pattern_ly( - p = state[["main"]], - x = constructed_indicator, - high = constructed_series[[2]], - low = constructed_series[[3]], - pattern_name = "$FUN", - agnostic = $AGNOSTIC ) - state[["main"]] <- plotly_object - - plotly_object - } diff --git a/codegen/templates/candlestick_ggplot_template.R.in b/codegen/templates/chart_candlestick_template.R similarity index 53% rename from codegen/templates/candlestick_ggplot_template.R.in rename to codegen/templates/chart_candlestick_template.R index b87c0ed64..7d05e32dc 100644 --- a/codegen/templates/candlestick_ggplot_template.R.in +++ b/codegen/templates/chart_candlestick_template.R @@ -1,15 +1,19 @@ #' @usage NULL -#' @aliases $FUN +#' @aliases ${FUN} #' #' @export -$FUN.ggplot <- function( +${FUN}.${METHOD} <- function( x, - cols, ${ARGS} + cols, + ${ARGS} na.bridge = FALSE, ...) { - ## check ggplot2 availability - assert_ggplot2() +#plotly# ## check that input value +#plotly# ## 'x' is -object +#plotly# assert_plotly_object(x) +#ggplot# ## check ggplot2 availability +#ggplot# assert_ggplot2() ## check that input value ## 'cols' is a -objet @@ -18,21 +22,23 @@ $FUN.ggplot <- function( } ## construct series from - ## {ggplot}-object + ## {${METHOD}}-object constructed_series <- series( x = x, formula = cols, - default_formula = ~open + high + low + close, + default_formula = ${FORMULA}, ... ) ## construct indicator ## from the series - constructed_indicator <- $FUN( + constructed_indicator <- ${FUN}( x = constructed_series, cols = rebuild_formula( names(constructed_series) - )${PPARGS} + ), + ${PARGS} + na.bridge = na.bridge ) ## add conditional idx @@ -40,16 +46,17 @@ $FUN.ggplot <- function( constructed_series ) - ## construct {ggplot2}-object + ## construct {${PKG}}-object state <- .chart_state() - ggplot_object <- pattern_gg( + ${METHOD}_object <- pattern_${SUFFIX}( p = state[["main"]], x = constructed_indicator, high = constructed_series[[2]], low = constructed_series[[3]], - pattern_name = "$FUN", - agnostic = $AGNOSTIC ) - state[["main"]] <- ggplot_object + pattern_name = "${FUN}", + agnostic = ${AGNOSTIC} + ) + state[["main"]] <- ${METHOD}_object - ggplot_object - } \ No newline at end of file + ${METHOD}_object +} diff --git a/codegen/templates/chart_main_template.R b/codegen/templates/chart_main_template.R new file mode 100644 index 000000000..3d1eda9b1 --- /dev/null +++ b/codegen/templates/chart_main_template.R @@ -0,0 +1,86 @@ +#' @usage NULL +#' @aliases ${FUN} +#' +#' @export +${FUN}.${METHOD} <- function( + x, + cols, + ${ARGS} + na.bridge = FALSE, + ## splice:optional-${METHOD}:start + ## splice:optional-${METHOD}:end + ...) { + +#plotly# ## check that input value +#plotly# ## 'x' is -object +#plotly# assert_plotly_object(x) +#ggplot# ## check ggplot2 availability +#ggplot# assert_ggplot2() + + ## check that input value + ## 'cols' is a -objet + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series from + ## {${METHOD}}-object + constructed_series <- series( + x = x, + formula = cols, + default_formula = ${FORMULA}, + ... + ) + + ## construct indicator + ## from the series + constructed_indicator <- ${FUN}( + x = constructed_series, + cols = rebuild_formula( + names(constructed_series) + ), + ${PARGS} + na.bridge = TRUE + ) + + ## add conditional idx + constructed_indicator[["idx"]] <- add_idx( + constructed_series + ) + + ## construct {${PKG}}-object + ## splice:${METHOD}-assembly:start +#plotly# traces <- lapply( +#plotly# setdiff(colnames(constructed_indicator), "idx"), +#plotly# function(col) { +#plotly# list( +#plotly# y = stats::as.formula( +#plotly# paste0("~", col) +#plotly# ), +#plotly# name = col +#plotly# ) +#plotly# } +#plotly# ) +#ggplot# layers <- lapply( +#ggplot# setdiff(colnames(constructed_indicator), "idx"), +#ggplot# function(col) list(y = col) +#ggplot# ) + name <- "${ALIAS}" + ## splice:${METHOD}-assembly:end + + state <- .chart_state() + ${METHOD}_object <- build_${METHOD}( + init = state[["main"]], +#plotly# traces = traces, +#ggplot# layers = layers, + decorators = list(), + name = get0( + x = "name", + ifnotfound = NULL + ), + data = constructed_indicator + ) + state[["main"]] <- ${METHOD}_object + + ${METHOD}_object +} diff --git a/codegen/templates/chart_moving_average_template.R b/codegen/templates/chart_moving_average_template.R new file mode 100644 index 000000000..977f9de4d --- /dev/null +++ b/codegen/templates/chart_moving_average_template.R @@ -0,0 +1,74 @@ +#' @usage NULL +#' @aliases ${FUN} +#' +#' @export +${FUN}.${METHOD} <- function( + x, + cols, + ${ARGS} + na.bridge = FALSE, + ...) { + +#plotly# ## check that input value +#plotly# ## 'x' is -object +#plotly# assert_plotly_object(x) +#ggplot# ## check ggplot2 availability +#ggplot# assert_ggplot2() + + ## check that input value + ## 'cols' is a -objet + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series from + ## {${METHOD}}-object + constructed_series <- series( + x = x, + formula = cols, + default_formula = ${FORMULA}, + ... + ) + + ## construct indicator + ## from the series + constructed_indicator <- ${FUN}( + x = constructed_series, + cols = rebuild_formula( + names(constructed_series) + ), + ${PARGS} + na.bridge = TRUE + ) + + ## add conditional idx + constructed_indicator[["idx"]] <- add_idx( + constructed_series + ) + + ## construct {${PKG}}-object + state <- .chart_state() + ${METHOD}_object <- build_${METHOD}( + init = state[["main"]], +#plotly# traces = list( +#plotly# list( +#plotly# y = ~constructed_indicator[["${ALIAS}"]][-(1:attr(constructed_indicator, "lookback", TRUE))], +#plotly# legendgroup = "MovingAverage", +#plotly# legendgrouptitle = list( +#plotly# text = "Moving Averages" +#plotly# ) +#plotly# ) +#plotly# ), +#ggplot# layers = list( +#ggplot# list( +#ggplot# y = "${ALIAS}" +#ggplot# ) +#ggplot# ), + name = label("${ALIAS}"${CARGS}), + decorators = list(), + data = constructed_indicator + ) + state[["main"]] <- ${METHOD}_object + + ${METHOD}_object +} diff --git a/codegen/templates/chart_subchart_template.R b/codegen/templates/chart_subchart_template.R new file mode 100644 index 000000000..684984088 --- /dev/null +++ b/codegen/templates/chart_subchart_template.R @@ -0,0 +1,109 @@ +#' @usage NULL +#' @aliases ${FUN} +#' +#' @export +${FUN}.${METHOD} <- function( + x, + cols, + ${ARGS} + na.bridge = FALSE, +#plotly# ## splice:optional-${METHOD}:start +#plotly# ## splice:optional-${METHOD}:end +#plotly# title, +#ggplot# title, +#ggplot# ## splice:optional-${METHOD}:start +#ggplot# ## splice:optional-${METHOD}:end + ...) { + +#plotly# ## check that input value +#plotly# ## 'x' is -object +#plotly# assert_plotly_object(x) +#ggplot# ## check ggplot2 availability +#ggplot# assert_ggplot2() + + ## check that input value + ## 'cols' is a -objet + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series from + ## {${METHOD}}-object + constructed_series <- series( + x = x, + formula = cols, + default_formula = ${FORMULA}, + ... + ) + + ## construct indicator + ## from the series + constructed_indicator <- ${FUN}( + x = constructed_series, + cols = rebuild_formula( + names(constructed_series) + ), + ${PARGS} + na.bridge = TRUE + ) + + ## the constructed indicator +#plotly# ## always returns excpected +#ggplot# ## always returns expected + ## columns which can be passed +#plotly# ## down to add_last_values() +#ggplot# ## down to add_last_value_gg() + values_to_extract <- colnames(constructed_indicator) + + ## add conditional idx + constructed_indicator[["idx"]] <- add_idx( + constructed_series + ) + + ## construct {${PKG}}-object + ## splice:${METHOD}-assembly:start +#plotly# traces <- lapply( +#plotly# setdiff(colnames(constructed_indicator), "idx"), +#plotly# function(col) { +#plotly# list( +#plotly# y = stats::as.formula( +#plotly# paste0("~", col) +#plotly# ), +#plotly# name = col +#plotly# ) +#plotly# } +#plotly# ) +#ggplot# layers <- lapply( +#ggplot# setdiff(colnames(constructed_indicator), "idx"), +#ggplot# function(col) list(y = col) +#ggplot# ) + name <- "${ALIAS}" + ## splice:${METHOD}-assembly:end + + ${METHOD}_object <- add_last_value_${SUFFIX}( + build_${METHOD}( + init = ${METHOD}_init(), +#plotly# traces = traces, +#ggplot# layers = layers, + decorators = get0( + x = "decorators", + ifnotfound = list() + ), + name = get0( + x = "name", + ifnotfound = NULL + ), + data = constructed_indicator, + title = if (missing(title)) {"${TITLE}"} else {title} + ), + data = constructed_indicator[,values_to_extract, drop = FALSE], +#plotly# values_to_extract = values_to_extract +#ggplot# values_to_extract = values_to_extract, +#ggplot# name = get0(x = "name", ifnotfound = NULL) + ) + + state <- .chart_state() + state$sub <- c(state$sub, list(${METHOD}_object)) + + ${METHOD}_object +} diff --git a/codegen/templates/ggplot_main_template.R.in b/codegen/templates/ggplot_main_template.R.in deleted file mode 100644 index d93152ef4..000000000 --- a/codegen/templates/ggplot_main_template.R.in +++ /dev/null @@ -1,70 +0,0 @@ -#' @usage NULL -#' @aliases ${FUN} -#' -#' @export -${FUN}.ggplot <- function( - x, - cols,${ARGS} - na.bridge = FALSE, - ## splice:optional-ggplot:start - ## splice:optional-ggplot:end - ...) { - - ## check ggplot2 availability - assert_ggplot2() - - ## check that input value - ## 'cols' is a -objet - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series from - ## {ggplot}-object - constructed_series <- series( - x = x, - formula = cols, - default_formula = ${FORMULA}, - ... - ) - - ## construct indicator - ## from the series - constructed_indicator <- ${FUN}( - x = constructed_series, - cols = rebuild_formula( - names(constructed_series) - ) - ${PPARGS}, - na.bridge = TRUE - ) - - ## add conditional idx - constructed_indicator[["idx"]] <- add_idx( - constructed_series - ) - - ## construct {ggplot2}-object - ## splice:ggplot-assembly:start - layers <- lapply( - setdiff(colnames(constructed_indicator), "idx"), - function(col) list(y = col) - ) - name <- "${ALIAS}" - ## splice:ggplot-assembly:end - - state <- .chart_state() - ggplot_object <- build_ggplot( - init = state[["main"]], - layers = layers, - decorators = list(), - name = get0( - x = "name", - ifnotfound = NULL - ), - data = constructed_indicator - ) - state[["main"]] <- ggplot_object - - ggplot_object - } \ No newline at end of file diff --git a/codegen/templates/ggplot_subchart_template.R.in b/codegen/templates/ggplot_subchart_template.R.in deleted file mode 100644 index f9197df0d..000000000 --- a/codegen/templates/ggplot_subchart_template.R.in +++ /dev/null @@ -1,87 +0,0 @@ -#' @usage NULL -#' @aliases ${FUN} -#' -#' @export -${FUN}.ggplot <- function( - x, - cols,${ARGS} - na.bridge = FALSE, - ## splice:optional-ggplot:start - ## splice:optional-ggplot:end - title, - ...) { - - ## check ggplot2 availability - assert_ggplot2() - - ## check that input value - ## 'cols' is a -objet - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series from - ## {ggplot}-object - constructed_series <- series( - x = x, - formula = cols, - default_formula = ${FORMULA}, - ... - ) - - ## construct indicator - ## from the series - constructed_indicator <- ${FUN}( - x = constructed_series, - cols = rebuild_formula( - names(constructed_series) - ) - ${PPARGS}, - na.bridge = TRUE - ) - - ## the constructed indicator - ## always returns expected - ## columns which can be passed - ## down to add_last_value_gg() - values_to_extract <- colnames(constructed_indicator) - - ## add conditional idx - constructed_indicator[["idx"]] <- add_idx( - constructed_series - ) - - ## construct {ggplot2}-object - ## splice:ggplot-assembly:start - layers <- lapply( - setdiff(colnames(constructed_indicator), "idx"), - function(col) list(y = col) - ) - name <- "${ALIAS}" - ## splice:ggplot-assembly:end - - ggplot_object <- add_last_value_gg( - build_ggplot( - init = ggplot_init(), - layers = layers, - decorators = get0( - x = "decorators", - ifnotfound = list() - ), - name = get0( - x = "name", - ifnotfound = NULL - ), - data = constructed_indicator, - title = if (missing(title)) {"${TITLE}"} else {title} - ), - data = constructed_indicator[,values_to_extract, drop = FALSE], - values_to_extract = values_to_extract, - name = get0(x = "name", ifnotfound = NULL) - ) - - state <- .chart_state() - state$sub <- c(state$sub, list(ggplot_object)) - - ggplot_object - } \ No newline at end of file diff --git a/codegen/templates/indicator_template.R.in b/codegen/templates/indicator_template.R similarity index 81% rename from codegen/templates/indicator_template.R.in rename to codegen/templates/indicator_template.R index 0abd895ba..1d1e5fe71 100644 --- a/codegen/templates/indicator_template.R.in +++ b/codegen/templates/indicator_template.R @@ -15,7 +15,8 @@ #' @template returns ${FUN} <- function( x, - cols,${ARGS} + cols, + ${ARGS} na.bridge = FALSE, ...) { UseMethod("${FUN}") @@ -34,7 +35,8 @@ ${ALIAS} <- ${FUN} #' @export ${FUN}.default <- function( x, - cols,${ARGS} + cols, + ${ARGS} na.bridge = FALSE, ...) { @@ -60,9 +62,8 @@ ${FUN}.default <- function( ## calculate indicator and ## return as data.frame x <- .Call( - C_impl_ta_${TA_FUN}, - ## splice:call:start - ## splice:call:end + C_impl_ta_${ALIAS}, + ${C_SIGNATURE}, as.logical(na.bridge) ) @@ -79,13 +80,16 @@ ${FUN}.default <- function( #' @export ${FUN}.data.frame <- function( x, - cols,${ARGS} + cols, + ${ARGS} na.bridge = FALSE, - ...) { + ... +) { map_dfr( ${FUN}.default( x = x, - cols = cols ${PARGS} + cols = cols, + ${PARGS} na.bridge = na.bridge, ... ) @@ -99,14 +103,31 @@ ${FUN}.data.frame <- function( #' @export ${FUN}.matrix <- function( x, - cols,${ARGS} + cols, + ${ARGS} na.bridge = FALSE, ...) { ${FUN}.default( x = x, - cols = cols ${PARGS} + cols = cols , + ${PARGS} na.bridge = na.bridge, ... ) } + +#' @usage NULL +${FUN}_lookback <- function( + x, + cols, + ${ARGS} + na.bridge = FALSE, + ... +) { + + .Call( + C_impl_ta_${ALIAS}_lookback${C_SIGNATURE_LOOKBACK} + ) + +} \ No newline at end of file diff --git a/codegen/templates/moving_average_ggplot_template.R.in b/codegen/templates/moving_average_ggplot_template.R.in deleted file mode 100644 index 35aa587e5..000000000 --- a/codegen/templates/moving_average_ggplot_template.R.in +++ /dev/null @@ -1,59 +0,0 @@ -#' @usage NULL -#' @aliases $FUN -#' -#' @export -$FUN.ggplot <- function( - x, - cols,${ARGS} - na.bridge = FALSE, - ...) { - - ## check ggplot2 availability - assert_ggplot2() - - ## check that input value - ## 'cols' is a -objet - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series from - ## {ggplot}-object - constructed_series <- series( - x = x, - formula = cols, - default_formula = ~close, - ... - ) - - ## construct indicator - ## from the series - constructed_indicator <- $FUN( - x = constructed_series, - cols = rebuild_formula( - names(constructed_series) - ) ${PPARGS} - ) - - ## add conditional idx - constructed_indicator[["idx"]] <- add_idx( - constructed_series - ) - - ## construct {ggplot2}-object - state <- .chart_state() - ggplot_object <- build_ggplot( - init = state[["main"]], - layers = list( - list( - y = "$ALIAS" - ) - ), - name = label("$ALIAS" ${CARGS}), - decorators = list(), - data = constructed_indicator - ) - state[["main"]] <- ggplot_object - - ggplot_object - } diff --git a/codegen/templates/moving_average_template.R b/codegen/templates/moving_average_template.R new file mode 100644 index 000000000..44fb5e40e --- /dev/null +++ b/codegen/templates/moving_average_template.R @@ -0,0 +1,174 @@ +#' @export +#' @family ${FAMILY} +#' +#' @title ${TITLE} +#' @templateVar .title ${TITLE} +#' @templateVar .author Serkan Korkmaz +#' @templateVar .fun ${FUN} +#' @templateVar .family ${FAMILY} +#' @templateVar .formula ${FORMULA} +#' +## splice:documentation:start +## splice:documentation:end +#' +#' @details +#' When passed without 'x', [${FUN}] functions as an 'Moving Average'-specification which is used in, for example, [stochastic] when constructing the smoothing lines. +#' +#' When called without 'x' it will return a named list which is used for the +#' indicators that supports various Moving Average specifications. +#' +#' @template description +#' @template returns +${FUN} <- function( + x, + cols, + ${ARGS} + na.bridge = FALSE, + ...) { + + ## if 'x' is missing ${FUN} functions + ## as a Moving Average Specification + if (missing(x)) { + ## construct Moving Average specification + ## from call + x <- structure( + list( + ${SPEC_FIELDS}, + maType = ${MA_TYPE} + ) + ) + + return(x) + } + + UseMethod("${FUN}") +} + +#' @export +#' @usage NULL +#' @rdname ${FUN} +#' +#' @aliases ${FUN} +${ALIAS} <- ${FUN} + +#' @usage NULL +#' @aliases ${FUN} +#' +#' @export +${FUN}.default <- function( + x, + cols, + ${ARGS} + na.bridge = FALSE, + ...) { + + ## 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, + ... + ) + + ## extract rownames + ## for later attachment + x_names <- rownames(constructed_series) + + ## calculate indicator and + ## return as data.frame + x <- .Call( + C_impl_ta_${ALIAS}, + ${C_SIGNATURE}, + as.logical(na.bridge) + ) + + ## readd rownames + set_rownames(x, x_names) + + ## return indicator + x +} + +#' @usage NULL +#' @aliases ${FUN} +#' +#' @export +${FUN}.data.frame <- function( + x, + cols, + ${ARGS} + na.bridge = FALSE, + ... +) { + map_dfr( + ${FUN}.default( + x = x, + cols = cols, + ${PARGS} + na.bridge = na.bridge, + ... + ) + ) + +} + +#' @usage NULL +#' @aliases ${FUN} +#' +#' @export +${FUN}.matrix <- function( + x, + cols, + ${ARGS} + na.bridge = FALSE, + ...) { + + ${FUN}.default( + x = x, + cols = cols , + ${PARGS} + na.bridge = na.bridge, + ... + ) +} + +#' @usage NULL +#' @aliases ${FUN} +#' +#' @export +${FUN}.numeric <- function( + x, + cols, + ${ARGS} + na.bridge = FALSE, + ...) { + + ## warn if 'cols' have been + ## passed just to make sure + ## the user knows its not possible + ## or relevant + if (!missing(cols)) { + warning("'cols' is passed but is unused for vectors.") + } + + ## pass to 'C' directly + ## with the input vector + x <- .Call( + C_impl_ta_${ALIAS}, + ${C_NUMERIC}, + as.logical(na.bridge) + ) + + if (dim(x)[2] == 1L) { + dim(x) <- NULL + } + + x +} diff --git a/codegen/templates/moving_average_template.R.in b/codegen/templates/moving_average_template.R.in deleted file mode 100644 index f67bae0d9..000000000 --- a/codegen/templates/moving_average_template.R.in +++ /dev/null @@ -1,227 +0,0 @@ -#' @export -#' @family $FAMILY -#' -#' @title $TITLE -#' @templateVar .title $TITLE -#' @templateVar .author Serkan Korkmaz -#' @templateVar .fun $FUN -#' @templateVar .family ${FAMILY} -#' @templateVar .formula ${FORMULA} -#' -## splice:documentation:start -## splice:documentation:end -#' -#' @details -#' When passed without 'x', [$FUN] functions as an 'Moving Average'-specification which is used in, for example, [stochastic] when constructing the smoothing lines. -#' -#' When called without 'x' it will return a named list which is used for the -#' indicators that supports various Moving Average specifications. -#' -#' @template description -#' @template returns -$FUN <- function( - x, - cols,${ARGS} - na.bridge = FALSE, - ...) { - - ## if 'x' is missing $FUN functions - ## as a Moving Average Specification - if (missing(x)) { - ## construct Moving Average specification - ## from call - x <- structure( - list( - ${SPEC_FIELDS}, - maType = ${maType} - ) - ) - - return(x) - } - UseMethod("$FUN") -} - -#' @export -#' @usage NULL -#' @rdname $FUN -#' -#' @aliases $FUN -$ALIAS <- $FUN - -#' @usage NULL -#' @aliases $FUN -#' -#' @export -$FUN.default <- function( - x, - cols,${ARGS} - na.bridge = FALSE, - ...) { - - ## 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, - ... - ) - - ## extract rownames - ## for later attachment - x_names <- rownames(constructed_series) - - ## calculate indicator and - ## return as data.frame - x <- .Call( - C_impl_ta_${TA_FUN}, - as.double(constructed_series[[1]])${CARGS_TYPED}, - as.logical(na.bridge) - ) - - ## readd rownames - set_rownames(x, x_names) - - ## return indicator - x -} - -#' @usage NULL -#' @aliases $FUN -#' -#' @export -$FUN.data.frame <- function( - x, - cols,${ARGS} - na.bridge = FALSE, - ...) { - - map_dfr( - NextMethod() - ) -} - -#' @usage NULL -#' @aliases $FUN -#' -#' @export -$FUN.matrix <- function( - x, - cols,${ARGS} - na.bridge = FALSE, - ...) { - - ## pass directly to - ## $FUN.default to avoid - ## shenanigans with NextMethod() - $FUN.default( - x = x, - cols = cols ${PARGS} - na.bridge = na.bridge, - ... - ) -} - -#' @usage NULL -#' @aliases $FUN -#' -#' @export -$FUN.numeric <- function( - x, - cols,${ARGS} - na.bridge = FALSE, - ...) { - - ## warn if 'cols' have been - ## passed just to make sure - ## the user knows its not possible - ## or relevant - if (!missing(cols)) { - warning("'cols' is passed but is unused for vectors.") - } - - ## pass to 'C' directly - ## with the input vector - x <- .Call( - C_impl_ta_${TA_FUN}, - as.double(x)${CARGS_TYPED}, - as.logical(na.bridge) - ) - - if (dim(x)[2] == 1L) { - dim(x) <- NULL - } - - x - -} - -#' @usage NULL -#' @aliases $FUN -#' -#' @export -$FUN.plotly <- function( - x, - cols,${ARGS} - na.bridge = FALSE, - ...) { - - ## check that input value - ## 'x' is -object - assert_plotly_object(x) - - ## check that input value - ## 'cols' is a -objet - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series from - ## {plotly}-object - constructed_series <- series( - x = x, - formula = cols, - default_formula = ~close, - ... - ) - - ## construct indicator - ## from the series - constructed_indicator <- $FUN( - x = constructed_series, - cols = rebuild_formula( - names(constructed_series) - ) ${PPARGS} - ) - - ## add conditional idx - constructed_indicator[["idx"]] <- add_idx( - constructed_series - ) - - ## construct {plotly}-object - state <- .chart_state() - plotly_object <- build_plotly( - init = state[["main"]], - traces = list( - list(y = ~constructed_indicator[["$ALIAS"]][-(1:attr(constructed_indicator, "lookback", TRUE))], - legendgroup = "MovingAverage", - legendgrouptitle = list( - text = "Moving Averages" - ) - ) - ), - name = label("$ALIAS" ${CARGS}), - decorators = list() - ) - state[["main"]] <- plotly_object - - plotly_object - } diff --git a/codegen/templates/numeric_template.R b/codegen/templates/numeric_template.R new file mode 100644 index 000000000..f96709b0d --- /dev/null +++ b/codegen/templates/numeric_template.R @@ -0,0 +1,33 @@ +#' @usage NULL +#' @aliases ${FUN} +#' +#' @export +${FUN}.numeric <- function( + x, + cols, + ${ARGS} + na.bridge = FALSE, + ...) { + + ## warn if 'cols' have been + ## passed just to make sure + ## the user knows its not possible + ## or relevant + if (!missing(cols)) { + warning("'cols' is passed but is unused for vectors.") + } + + ## pass the argument directly + ## to 'C' + x <- .Call( + C_impl_ta_${ALIAS}, + ${C_NUMERIC}, + as.logical(na.bridge) + ) + + if (dim(x)[2] == 1L) { + dim(x) <- NULL + } + + x +} diff --git a/codegen/templates/numeric_template.R.in b/codegen/templates/numeric_template.R.in deleted file mode 100644 index 755b20b27..000000000 --- a/codegen/templates/numeric_template.R.in +++ /dev/null @@ -1,34 +0,0 @@ -#' @usage NULL -#' @aliases ${FUN} -#' -#' @export -${FUN}.numeric <- function( - x, - cols,${ARGS} - na.bridge = FALSE, - ...) { - - ## warn if 'cols' have been - ## passed just to make sure - ## the user knows its not possible - ## or relevant - if (!missing(cols)) { - warning("'cols' is passed but is unused for vectors.") - } - - ## pass the argument directly - ## to 'C' - x <- .Call( - C_impl_ta_${TA_FUN}, - ## splice:numeric:start - ${CARGS} - ## splice:numeric:end - as.logical(na.bridge) - ) - - if (dim(x)[2] == 1L) { - dim(x) <- NULL - } - - x -} diff --git a/codegen/templates/plotly_main_template.R.in b/codegen/templates/plotly_main_template.R.in deleted file mode 100644 index 92056163a..000000000 --- a/codegen/templates/plotly_main_template.R.in +++ /dev/null @@ -1,67 +0,0 @@ -#' @usage NULL -#' @aliases ${FUN} -#' -#' @export -${FUN}.plotly <- function( - x, - cols,${ARGS} - na.bridge = FALSE, - ## splice:optional-plotly:start - ## splice:optional-plotly:end - ...) { - - ## check that input value - ## 'x' is -object - assert_plotly_object(x) - - ## check that input value - ## 'cols' is a -objet - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series from - ## {plotly}-object - constructed_series <- series( - x = x, - formula = cols, - default_formula = ${FORMULA}, - ... - ) - - ## construct indicator - ## from the series - constructed_indicator <- ${FUN}( - x = constructed_series, - cols = rebuild_formula( - names(constructed_series) - ) - ${PPARGS}, - na.bridge = TRUE - ) - - ## add conditional idx - constructed_indicator[["idx"]] <- add_idx( - constructed_series - ) - - ## construct {plotly}-object - ## splice:plotly-assembly:start - ## initial scaffold - ## splice:plotly-assembly:end - - state <- .chart_state() - plotly_object <- build_plotly( - init = state[["main"]], - traces = traces, - decorators = list(), - name = get0( - x = "name", - ifnotfound = NULL - ), - data = constructed_indicator - ) - state[["main"]] <- plotly_object - - plotly_object - } \ No newline at end of file diff --git a/codegen/templates/plotly_subchart_template.R.in b/codegen/templates/plotly_subchart_template.R.in deleted file mode 100644 index 7b0b142c5..000000000 --- a/codegen/templates/plotly_subchart_template.R.in +++ /dev/null @@ -1,83 +0,0 @@ -#' @usage NULL -#' @aliases ${FUN} -#' -#' @export -${FUN}.plotly <- function( - x, - cols,${ARGS} - na.bridge = FALSE, - ## splice:optional-plotly:start - ## splice:optional-plotly:end - title, - ...) { - - ## check that input value - ## 'x' is -object - assert_plotly_object(x) - - ## check that input value - ## 'cols' is a -objet - if (!missing(cols)) { - assert_formula(cols) - } - - ## construct series from - ## {plotly}-object - constructed_series <- series( - x = x, - formula = cols, - default_formula = ${FORMULA}, - ... - ) - - ## construct indicator - ## from the series - constructed_indicator <- ${FUN}( - x = constructed_series, - cols = rebuild_formula( - names(constructed_series) - ) - ${PPARGS}, - na.bridge = TRUE - ) - - ## the constructed indicator - ## always returns excpected - ## columns which can be passed - ## down to add_last_values() - values_to_extract <- colnames(constructed_indicator) - - ## add conditional idx - constructed_indicator[["idx"]] <- add_idx( - constructed_series - ) - - ## construct {plotly}-object - ## splice:plotly-assembly:start - ## initial scaffold - ## splice:plotly-assembly:end - - plotly_object <- add_last_value_ly( - build_plotly( - init = plotly_init(), - traces = traces, - decorators = get0( - x = "decorators", - ifnotfound = list() - ), - name = get0( - x = "name", - ifnotfound = NULL - ), - data = constructed_indicator, - title = if (missing(title)) {"${TITLE}"} else {title} - ), - data = constructed_indicator[,values_to_extract, drop = FALSE], - values_to_extract = values_to_extract - ) - - state <- .chart_state() - state$sub <- c(state$sub, list(plotly_object)) - - plotly_object - } \ No newline at end of file diff --git a/codegen/templates/rolling_template.R.in b/codegen/templates/rolling_template.R similarity index 78% rename from codegen/templates/rolling_template.R.in rename to codegen/templates/rolling_template.R index 29bfa7cb0..f1858d845 100644 --- a/codegen/templates/rolling_template.R.in +++ b/codegen/templates/rolling_template.R @@ -13,9 +13,8 @@ #' @template rolling_returns ${FUN} <- function( x, - ${ARGS}, - na.bridge = FALSE - ) { + ${ARGS} + na.bridge = FALSE) { UseMethod("${FUN}") } @@ -32,21 +31,21 @@ ${ALIAS} <- ${FUN} #' @export ${FUN}.default <- function( x, - ${ARGS}, - na.bridge = FALSE - ) { + ${ARGS} + na.bridge = FALSE) { ## calculate indicator and ## return as data.frame x <- .Call( - C_impl_ta_${TA_FUN}, - ## splice:call:start + C_impl_ta_${ALIAS}, + ## splice:call:start + ${C_NUMERIC}, ## splice:call:end as.logical(na.bridge) ) ## strip dimensions - ## while preserving + ## while preserving ## attributes dim(x) <- NULL @@ -60,23 +59,22 @@ ${FUN}.default <- function( #' @export ${FUN}.numeric <- function( x, - ${ARGS}, - na.bridge = FALSE - ) { + ${ARGS} + na.bridge = FALSE) { ## calculate indicator and ## return as data.frame x <- ${FUN}.default( - x = x ${PARGS}, - na.bridge = na.bridge - + x = x, + ${PARGS} + na.bridge = na.bridge ) ## strip dimensions - ## while preserving + ## while preserving ## attributes dim(x) <- NULL ## return indicator x -} \ No newline at end of file +} diff --git a/src/TA-Lib.h b/src/TA-Lib.h index 5c9b4fb99..3e5fb4138 100644 --- a/src/TA-Lib.h +++ b/src/TA-Lib.h @@ -10,17 +10,13 @@ // // 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) @@ -89,17 +85,11 @@ TA_INDICATOR(CDLTRISTAR, TA_INTEGER, TA_INPUT(inOpen, inHigh, inLow, inClose), T 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) @@ -108,57 +98,32 @@ TA_INDICATOR(HT_TRENDLINE, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(), TA_OUTPUT( 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) @@ -173,17 +138,13 @@ TA_INDICATOR(WMA, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optIn // 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()) @@ -252,17 +213,11 @@ 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()) @@ -271,57 +226,32 @@ 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))) diff --git a/tests/testthat/test-ta_ACCBANDS.R b/tests/testthat/test-ta_ACCBANDS.R index 2bce7be98..013f1f172 100644 --- a/tests/testthat/test-ta_ACCBANDS.R +++ b/tests/testthat/test-ta_ACCBANDS.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_AD.R b/tests/testthat/test-ta_AD.R index 28d61d694..77b625774 100644 --- a/tests/testthat/test-ta_AD.R +++ b/tests/testthat/test-ta_AD.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_ADOSC.R b/tests/testthat/test-ta_ADOSC.R index 9ed88a8d0..6a4700c6a 100644 --- a/tests/testthat/test-ta_ADOSC.R +++ b/tests/testthat/test-ta_ADOSC.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -147,7 +147,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_ADX.R b/tests/testthat/test-ta_ADX.R index aa0e9f651..fc642ecf8 100644 --- a/tests/testthat/test-ta_ADX.R +++ b/tests/testthat/test-ta_ADX.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_ADXR.R b/tests/testthat/test-ta_ADXR.R index ce5f58cbd..a114884f2 100644 --- a/tests/testthat/test-ta_ADXR.R +++ b/tests/testthat/test-ta_ADXR.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -147,7 +147,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_APO.R b/tests/testthat/test-ta_APO.R index 6a7db8ae0..8689e3455 100644 --- a/tests/testthat/test-ta_APO.R +++ b/tests/testthat/test-ta_APO.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_AROON.R b/tests/testthat/test-ta_AROON.R index adfbecc4e..cef80cbac 100644 --- a/tests/testthat/test-ta_AROON.R +++ b/tests/testthat/test-ta_AROON.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_AROONOSC.R b/tests/testthat/test-ta_AROONOSC.R index 6c96b785b..d5fa160f1 100644 --- a/tests/testthat/test-ta_AROONOSC.R +++ b/tests/testthat/test-ta_AROONOSC.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_ATR.R b/tests/testthat/test-ta_ATR.R index 4745c6a89..27b5125c0 100644 --- a/tests/testthat/test-ta_ATR.R +++ b/tests/testthat/test-ta_ATR.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_ROC.R b/tests/testthat/test-ta_AVGDEV.R similarity index 58% rename from tests/testthat/test-ta_ROC.R rename to tests/testthat/test-ta_AVGDEV.R index 027cf91dc..1da02754b 100644 --- a/tests/testthat/test-ta_ROC.R +++ b/tests/testthat/test-ta_AVGDEV.R @@ -1,17 +1,17 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz ## alias and function similarity ## checks this ensures that -## rate_of_change and ROC produces the same results +## AVGDEV and AVGDEV produces the same results testthat::test_that(desc = 'Alias and function similarity', code = { ## 1) test that the alias and ## function returns the same values - output <- rate_of_change(SPY) - alias <- ROC(SPY) + output <- AVGDEV(SPY) + alias <- AVGDEV(SPY) ## 1.1) check if the values ## are equal @@ -29,7 +29,7 @@ testthat::test_that(desc = 'Class in, class out ()', code = { ## 1) check that the output class ## matches the input class testthat::expect_true( - inherits(rate_of_change(SPY), class(SPY)) + inherits(AVGDEV(SPY), class(SPY)) ) }) @@ -38,7 +38,7 @@ testthat::test_that(desc = 'Class in, class out ()', code = { ## 1) check that the output class ## matches the input class testthat::expect_true( - inherits(rate_of_change(BTC), class(BTC)) + inherits(AVGDEV(BTC), class(BTC)) ) }) @@ -50,10 +50,10 @@ testthat::test_that(desc = 'Class in, class out ()', code = { ## series() function testthat::test_that(desc = 'Default calls', code = { testthat::expect_equal( - object = rate_of_change( + object = AVGDEV( BTC ), - expected = rate_of_change( + expected = AVGDEV( BTC, cols = ~close ) @@ -66,7 +66,7 @@ testthat::test_that(desc = 'Default calls', code = { ## object testthat::test_that(desc = 'Equal length of input and output for with na.bridge = TRUE', code = { testthat::expect_equal( - object = nrow(rate_of_change( + object = nrow(AVGDEV( ATOM, na.bridge = TRUE )), @@ -81,7 +81,7 @@ testthat::test_that(desc = 'Row names are respected for , na.bridge x_names <- row.names(ATOM) ## calculate indicator - indicator <- rate_of_change(ATOM, na.bridge = TRUE) + indicator <- AVGDEV(ATOM, na.bridge = TRUE) testthat::expect_equal( object = x_names, @@ -95,7 +95,7 @@ testthat::test_that(desc = 'Row names are respected for , na.bridge ## object testthat::test_that(desc = 'Equal length of input and output for ', code = { testthat::expect_equal( - object = nrow(rate_of_change( + object = nrow(AVGDEV( BTC )), expected = nrow(BTC) @@ -109,7 +109,7 @@ testthat::test_that(desc = 'Row names are respected for ', code = { x_names <- row.names(BTC) ## calculate indicator - indicator <- rate_of_change(BTC) + indicator <- AVGDEV(BTC) testthat::expect_equal( object = x_names, @@ -120,7 +120,7 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ## object testthat::test_that(desc = 'Equal length of input and output for ', code = { testthat::expect_equal( - object = nrow(rate_of_change( + object = nrow(AVGDEV( SPY )), expected = nrow(SPY) @@ -136,7 +136,7 @@ testthat::test_that(desc = 'Row names are respected for ', code = { rownames(SPY) <- paste0("row", 1:nrow(SPY)) ## calculate indicator - indicator <- rate_of_change(SPY) + indicator <- AVGDEV(SPY) testthat::expect_equal( object = paste0("row", 1:nrow(SPY)), @@ -144,100 +144,13 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - -## -method checks for -## and -## -## checks -testthat::test_that(desc = '-methods for ', code = { - ## check that rate_of_change can - ## use without any issues - output <- testthat::expect_no_error( - { - chart(BTC) - indicator(rate_of_change) - } - ) - - ## check that the output - ## is a -object - testthat::expect_true( - inherits(output, "plotly") - ) -}) - -## checks -testthat::test_that(desc = '-methods for ', code = { - ## check that rate_of_change can - ## use without any issues - output <- testthat::expect_no_error( - { - chart(SPY) - indicator(rate_of_change) - } - ) - - ## check that the output - ## is a -object - testthat::expect_true( - inherits(output, "plotly") - ) -}) - -## -method checks for -## and -## -## checks -testthat::test_that(desc = '-methods for ', code = { - testthat::skip_if_not_installed("ggplot2") - - ## check that rate_of_change can - ## use without any issues - output <- testthat::expect_no_error( - { - options(talib.chart.backend = "ggplot2") - on.exit(options(talib.chart.backend = "plotly")) - chart(BTC) - indicator(rate_of_change) - } - ) - - ## check that the output - ## is a -object or - testthat::expect_true( - inherits(output, "gg") || inherits(output, "talib_chart") - ) -}) - -## checks -testthat::test_that(desc = '-methods for ', code = { - testthat::skip_if_not_installed("ggplot2") - - ## check that rate_of_change can - ## use without any issues - output <- testthat::expect_no_error( - { - options(talib.chart.backend = "ggplot2") - on.exit(options(talib.chart.backend = "plotly")) - chart(SPY) - indicator(rate_of_change) - } - ) - - ## check that the output - ## is a -object or - testthat::expect_true( - inherits(output, "gg") || inherits(output, "talib_chart") - ) -}) - ## check that methods runs without ## issues and returns proper lengths testthat::test_that(desc = ' methods', code = { ## check that the method ## runs x <- testthat::expect_no_condition( - rate_of_change(BTC[[1]]) + AVGDEV(BTC[[1]]) ) target_length <- length(BTC[[1]]) diff --git a/tests/testthat/test-ta_AVGPRICE.R b/tests/testthat/test-ta_AVGPRICE.R index a6ae729b2..6d1e26922 100644 --- a/tests/testthat/test-ta_AVGPRICE.R +++ b/tests/testthat/test-ta_AVGPRICE.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz diff --git a/tests/testthat/test-ta_BBANDS.R b/tests/testthat/test-ta_BBANDS.R index 7ac8d3f53..6cf90c8e7 100644 --- a/tests/testthat/test-ta_BBANDS.R +++ b/tests/testthat/test-ta_BBANDS.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_BETA.R b/tests/testthat/test-ta_BETA.R index 055c4cb84..0333481a7 100644 --- a/tests/testthat/test-ta_BETA.R +++ b/tests/testthat/test-ta_BETA.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz diff --git a/tests/testthat/test-ta_BOP.R b/tests/testthat/test-ta_BOP.R index 55707da8f..3c8951118 100644 --- a/tests/testthat/test-ta_BOP.R +++ b/tests/testthat/test-ta_BOP.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CCI.R b/tests/testthat/test-ta_CCI.R index 00ae8c3d0..5307a3e73 100644 --- a/tests/testthat/test-ta_CCI.R +++ b/tests/testthat/test-ta_CCI.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL2CROWS.R b/tests/testthat/test-ta_CDL2CROWS.R index be0fcce24..3c9623010 100644 --- a/tests/testthat/test-ta_CDL2CROWS.R +++ b/tests/testthat/test-ta_CDL2CROWS.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL3BLACKCROWS.R b/tests/testthat/test-ta_CDL3BLACKCROWS.R index 3ffbd29c2..2d8a34894 100644 --- a/tests/testthat/test-ta_CDL3BLACKCROWS.R +++ b/tests/testthat/test-ta_CDL3BLACKCROWS.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL3INSIDE.R b/tests/testthat/test-ta_CDL3INSIDE.R index 904d06ff1..72d9204bc 100644 --- a/tests/testthat/test-ta_CDL3INSIDE.R +++ b/tests/testthat/test-ta_CDL3INSIDE.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL3LINESTRIKE.R b/tests/testthat/test-ta_CDL3LINESTRIKE.R index 52f5f28ae..88aa3e435 100644 --- a/tests/testthat/test-ta_CDL3LINESTRIKE.R +++ b/tests/testthat/test-ta_CDL3LINESTRIKE.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL3OUTSIDE.R b/tests/testthat/test-ta_CDL3OUTSIDE.R index 1e0d888a8..9e98dff6d 100644 --- a/tests/testthat/test-ta_CDL3OUTSIDE.R +++ b/tests/testthat/test-ta_CDL3OUTSIDE.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL3STARSINSOUTH.R b/tests/testthat/test-ta_CDL3STARSINSOUTH.R index 4949a6f17..55500ead4 100644 --- a/tests/testthat/test-ta_CDL3STARSINSOUTH.R +++ b/tests/testthat/test-ta_CDL3STARSINSOUTH.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDL3WHITESOLDIERS.R b/tests/testthat/test-ta_CDL3WHITESOLDIERS.R index 2fead055e..0f16cede9 100644 --- a/tests/testthat/test-ta_CDL3WHITESOLDIERS.R +++ b/tests/testthat/test-ta_CDL3WHITESOLDIERS.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLABANDONEDBABY.R b/tests/testthat/test-ta_CDLABANDONEDBABY.R index 8af4d3e6a..289efa662 100644 --- a/tests/testthat/test-ta_CDLABANDONEDBABY.R +++ b/tests/testthat/test-ta_CDLABANDONEDBABY.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLADVANCEBLOCK.R b/tests/testthat/test-ta_CDLADVANCEBLOCK.R index 99841b11a..bab5aad98 100644 --- a/tests/testthat/test-ta_CDLADVANCEBLOCK.R +++ b/tests/testthat/test-ta_CDLADVANCEBLOCK.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLBELTHOLD.R b/tests/testthat/test-ta_CDLBELTHOLD.R index cf98c69c9..69a8dd579 100644 --- a/tests/testthat/test-ta_CDLBELTHOLD.R +++ b/tests/testthat/test-ta_CDLBELTHOLD.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLBREAKAWAY.R b/tests/testthat/test-ta_CDLBREAKAWAY.R index bc510b1bf..c50eed3dc 100644 --- a/tests/testthat/test-ta_CDLBREAKAWAY.R +++ b/tests/testthat/test-ta_CDLBREAKAWAY.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLCLOSINGMARUBOZU.R b/tests/testthat/test-ta_CDLCLOSINGMARUBOZU.R index d3e9fc72a..1d7a1935c 100644 --- a/tests/testthat/test-ta_CDLCLOSINGMARUBOZU.R +++ b/tests/testthat/test-ta_CDLCLOSINGMARUBOZU.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLCONCEALBABYSWALL.R b/tests/testthat/test-ta_CDLCONCEALBABYSWALL.R index 6e5bbf613..1b36c4305 100644 --- a/tests/testthat/test-ta_CDLCONCEALBABYSWALL.R +++ b/tests/testthat/test-ta_CDLCONCEALBABYSWALL.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLCOUNTERATTACK.R b/tests/testthat/test-ta_CDLCOUNTERATTACK.R index 2de3e4319..c7e7f8dc8 100644 --- a/tests/testthat/test-ta_CDLCOUNTERATTACK.R +++ b/tests/testthat/test-ta_CDLCOUNTERATTACK.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLDARKCLOUDCOVER.R b/tests/testthat/test-ta_CDLDARKCLOUDCOVER.R index df221cf64..b2767cc71 100644 --- a/tests/testthat/test-ta_CDLDARKCLOUDCOVER.R +++ b/tests/testthat/test-ta_CDLDARKCLOUDCOVER.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLDOJI.R b/tests/testthat/test-ta_CDLDOJI.R index 67e041f02..7187658e6 100644 --- a/tests/testthat/test-ta_CDLDOJI.R +++ b/tests/testthat/test-ta_CDLDOJI.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLDOJISTAR.R b/tests/testthat/test-ta_CDLDOJISTAR.R index cc48aeddd..c0817b35f 100644 --- a/tests/testthat/test-ta_CDLDOJISTAR.R +++ b/tests/testthat/test-ta_CDLDOJISTAR.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLDRAGONFLYDOJI.R b/tests/testthat/test-ta_CDLDRAGONFLYDOJI.R index 098c48167..d4c033b9b 100644 --- a/tests/testthat/test-ta_CDLDRAGONFLYDOJI.R +++ b/tests/testthat/test-ta_CDLDRAGONFLYDOJI.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLENGULFING.R b/tests/testthat/test-ta_CDLENGULFING.R index fa7e4c09b..b0690f708 100644 --- a/tests/testthat/test-ta_CDLENGULFING.R +++ b/tests/testthat/test-ta_CDLENGULFING.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLEVENINGDOJISTAR.R b/tests/testthat/test-ta_CDLEVENINGDOJISTAR.R index b4b9b5fc8..b0edc1bb3 100644 --- a/tests/testthat/test-ta_CDLEVENINGDOJISTAR.R +++ b/tests/testthat/test-ta_CDLEVENINGDOJISTAR.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLEVENINGSTAR.R b/tests/testthat/test-ta_CDLEVENINGSTAR.R index a8a232d0a..ca694b9e5 100644 --- a/tests/testthat/test-ta_CDLEVENINGSTAR.R +++ b/tests/testthat/test-ta_CDLEVENINGSTAR.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLGAPSIDESIDEWHITE.R b/tests/testthat/test-ta_CDLGAPSIDESIDEWHITE.R index 10e7f8a07..8b61a3139 100644 --- a/tests/testthat/test-ta_CDLGAPSIDESIDEWHITE.R +++ b/tests/testthat/test-ta_CDLGAPSIDESIDEWHITE.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLGRAVESTONEDOJI.R b/tests/testthat/test-ta_CDLGRAVESTONEDOJI.R index 160936539..8a75d368e 100644 --- a/tests/testthat/test-ta_CDLGRAVESTONEDOJI.R +++ b/tests/testthat/test-ta_CDLGRAVESTONEDOJI.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHAMMER.R b/tests/testthat/test-ta_CDLHAMMER.R index 047e42d2e..fabd2becd 100644 --- a/tests/testthat/test-ta_CDLHAMMER.R +++ b/tests/testthat/test-ta_CDLHAMMER.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHANGINGMAN.R b/tests/testthat/test-ta_CDLHANGINGMAN.R index da7084715..0a0f014a1 100644 --- a/tests/testthat/test-ta_CDLHANGINGMAN.R +++ b/tests/testthat/test-ta_CDLHANGINGMAN.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHARAMI.R b/tests/testthat/test-ta_CDLHARAMI.R index 7ee501a58..dc8f13bb6 100644 --- a/tests/testthat/test-ta_CDLHARAMI.R +++ b/tests/testthat/test-ta_CDLHARAMI.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHARAMICROSS.R b/tests/testthat/test-ta_CDLHARAMICROSS.R index 7a61982b9..61748a1fa 100644 --- a/tests/testthat/test-ta_CDLHARAMICROSS.R +++ b/tests/testthat/test-ta_CDLHARAMICROSS.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHIGHWAVE.R b/tests/testthat/test-ta_CDLHIGHWAVE.R index d928d8fc6..45fc2aede 100644 --- a/tests/testthat/test-ta_CDLHIGHWAVE.R +++ b/tests/testthat/test-ta_CDLHIGHWAVE.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHIKKAKE.R b/tests/testthat/test-ta_CDLHIKKAKE.R index a1639124e..dfef13565 100644 --- a/tests/testthat/test-ta_CDLHIKKAKE.R +++ b/tests/testthat/test-ta_CDLHIKKAKE.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHIKKAKEMOD.R b/tests/testthat/test-ta_CDLHIKKAKEMOD.R index 82eecd158..561860d58 100644 --- a/tests/testthat/test-ta_CDLHIKKAKEMOD.R +++ b/tests/testthat/test-ta_CDLHIKKAKEMOD.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLHOMINGPIGEON.R b/tests/testthat/test-ta_CDLHOMINGPIGEON.R index c2ea37eca..1d452fbb0 100644 --- a/tests/testthat/test-ta_CDLHOMINGPIGEON.R +++ b/tests/testthat/test-ta_CDLHOMINGPIGEON.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLIDENTICAL3CROWS.R b/tests/testthat/test-ta_CDLIDENTICAL3CROWS.R index c001ea8f4..63359f763 100644 --- a/tests/testthat/test-ta_CDLIDENTICAL3CROWS.R +++ b/tests/testthat/test-ta_CDLIDENTICAL3CROWS.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLINNECK.R b/tests/testthat/test-ta_CDLINNECK.R index 17b847b8e..11f3b56c1 100644 --- a/tests/testthat/test-ta_CDLINNECK.R +++ b/tests/testthat/test-ta_CDLINNECK.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLINVERTEDHAMMER.R b/tests/testthat/test-ta_CDLINVERTEDHAMMER.R index 5a72d69e9..e848f4b2a 100644 --- a/tests/testthat/test-ta_CDLINVERTEDHAMMER.R +++ b/tests/testthat/test-ta_CDLINVERTEDHAMMER.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLKICKING.R b/tests/testthat/test-ta_CDLKICKING.R index 54e26ba44..4f023ac4b 100644 --- a/tests/testthat/test-ta_CDLKICKING.R +++ b/tests/testthat/test-ta_CDLKICKING.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLKICKINGBYLENGTH.R b/tests/testthat/test-ta_CDLKICKINGBYLENGTH.R index 96b3dd158..5684e63e5 100644 --- a/tests/testthat/test-ta_CDLKICKINGBYLENGTH.R +++ b/tests/testthat/test-ta_CDLKICKINGBYLENGTH.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLLADDERBOTTOM.R b/tests/testthat/test-ta_CDLLADDERBOTTOM.R index 75d5b4bc9..0359ee030 100644 --- a/tests/testthat/test-ta_CDLLADDERBOTTOM.R +++ b/tests/testthat/test-ta_CDLLADDERBOTTOM.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLLONGLEGGEDDOJI.R b/tests/testthat/test-ta_CDLLONGLEGGEDDOJI.R index 353ca3b28..0321b0b89 100644 --- a/tests/testthat/test-ta_CDLLONGLEGGEDDOJI.R +++ b/tests/testthat/test-ta_CDLLONGLEGGEDDOJI.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLLONGLINE.R b/tests/testthat/test-ta_CDLLONGLINE.R index 8982d3e8e..d6cf6e222 100644 --- a/tests/testthat/test-ta_CDLLONGLINE.R +++ b/tests/testthat/test-ta_CDLLONGLINE.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLMARUBOZU.R b/tests/testthat/test-ta_CDLMARUBOZU.R index 2aa85275b..b884f027d 100644 --- a/tests/testthat/test-ta_CDLMARUBOZU.R +++ b/tests/testthat/test-ta_CDLMARUBOZU.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLMATCHINGLOW.R b/tests/testthat/test-ta_CDLMATCHINGLOW.R index cc0b2d134..89ca0aef5 100644 --- a/tests/testthat/test-ta_CDLMATCHINGLOW.R +++ b/tests/testthat/test-ta_CDLMATCHINGLOW.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLMATHOLD.R b/tests/testthat/test-ta_CDLMATHOLD.R index 3061c6f99..73117c6a9 100644 --- a/tests/testthat/test-ta_CDLMATHOLD.R +++ b/tests/testthat/test-ta_CDLMATHOLD.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLMORNINGDOJISTAR.R b/tests/testthat/test-ta_CDLMORNINGDOJISTAR.R index 4e9d131eb..79985af85 100644 --- a/tests/testthat/test-ta_CDLMORNINGDOJISTAR.R +++ b/tests/testthat/test-ta_CDLMORNINGDOJISTAR.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLMORNINGSTAR.R b/tests/testthat/test-ta_CDLMORNINGSTAR.R index fb04a8d47..aa010f9e2 100644 --- a/tests/testthat/test-ta_CDLMORNINGSTAR.R +++ b/tests/testthat/test-ta_CDLMORNINGSTAR.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLONNECK.R b/tests/testthat/test-ta_CDLONNECK.R index a18cf4f92..5efeaa8c8 100644 --- a/tests/testthat/test-ta_CDLONNECK.R +++ b/tests/testthat/test-ta_CDLONNECK.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLPIERCING.R b/tests/testthat/test-ta_CDLPIERCING.R index 118b1041a..06affcd21 100644 --- a/tests/testthat/test-ta_CDLPIERCING.R +++ b/tests/testthat/test-ta_CDLPIERCING.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLRICKSHAWMAN.R b/tests/testthat/test-ta_CDLRICKSHAWMAN.R index 9b5de9900..f9297f1e8 100644 --- a/tests/testthat/test-ta_CDLRICKSHAWMAN.R +++ b/tests/testthat/test-ta_CDLRICKSHAWMAN.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLRISEFALL3METHODS.R b/tests/testthat/test-ta_CDLRISEFALL3METHODS.R index 4a9f7fe73..f5181dd32 100644 --- a/tests/testthat/test-ta_CDLRISEFALL3METHODS.R +++ b/tests/testthat/test-ta_CDLRISEFALL3METHODS.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLSEPARATINGLINES.R b/tests/testthat/test-ta_CDLSEPARATINGLINES.R index 7756e474b..58aa8ed21 100644 --- a/tests/testthat/test-ta_CDLSEPARATINGLINES.R +++ b/tests/testthat/test-ta_CDLSEPARATINGLINES.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLSHOOTINGSTAR.R b/tests/testthat/test-ta_CDLSHOOTINGSTAR.R index 7af511f6d..7a581d0da 100644 --- a/tests/testthat/test-ta_CDLSHOOTINGSTAR.R +++ b/tests/testthat/test-ta_CDLSHOOTINGSTAR.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLSHORTLINE.R b/tests/testthat/test-ta_CDLSHORTLINE.R index b98f773be..89a91940c 100644 --- a/tests/testthat/test-ta_CDLSHORTLINE.R +++ b/tests/testthat/test-ta_CDLSHORTLINE.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLSPINNINGTOP.R b/tests/testthat/test-ta_CDLSPINNINGTOP.R index 6bd2ec372..6e0c55a90 100644 --- a/tests/testthat/test-ta_CDLSPINNINGTOP.R +++ b/tests/testthat/test-ta_CDLSPINNINGTOP.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLSTALLEDPATTERN.R b/tests/testthat/test-ta_CDLSTALLEDPATTERN.R index 7e2bdff9f..d6bec7d15 100644 --- a/tests/testthat/test-ta_CDLSTALLEDPATTERN.R +++ b/tests/testthat/test-ta_CDLSTALLEDPATTERN.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLSTICKSANDWICH.R b/tests/testthat/test-ta_CDLSTICKSANDWICH.R index a083b6598..bd870f030 100644 --- a/tests/testthat/test-ta_CDLSTICKSANDWICH.R +++ b/tests/testthat/test-ta_CDLSTICKSANDWICH.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLTAKURI.R b/tests/testthat/test-ta_CDLTAKURI.R index ca4ddf6c1..16acab593 100644 --- a/tests/testthat/test-ta_CDLTAKURI.R +++ b/tests/testthat/test-ta_CDLTAKURI.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLTASUKIGAP.R b/tests/testthat/test-ta_CDLTASUKIGAP.R index 151338573..81322fc6e 100644 --- a/tests/testthat/test-ta_CDLTASUKIGAP.R +++ b/tests/testthat/test-ta_CDLTASUKIGAP.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLTHRUSTING.R b/tests/testthat/test-ta_CDLTHRUSTING.R index 775b2c9fa..76b26bd12 100644 --- a/tests/testthat/test-ta_CDLTHRUSTING.R +++ b/tests/testthat/test-ta_CDLTHRUSTING.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLTRISTAR.R b/tests/testthat/test-ta_CDLTRISTAR.R index 561cd18de..11a61f713 100644 --- a/tests/testthat/test-ta_CDLTRISTAR.R +++ b/tests/testthat/test-ta_CDLTRISTAR.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLUNIQUE3RIVER.R b/tests/testthat/test-ta_CDLUNIQUE3RIVER.R index 59f06585c..4a10fd598 100644 --- a/tests/testthat/test-ta_CDLUNIQUE3RIVER.R +++ b/tests/testthat/test-ta_CDLUNIQUE3RIVER.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLUPSIDEGAP2CROWS.R b/tests/testthat/test-ta_CDLUPSIDEGAP2CROWS.R index cb8d12ad3..20fb007a8 100644 --- a/tests/testthat/test-ta_CDLUPSIDEGAP2CROWS.R +++ b/tests/testthat/test-ta_CDLUPSIDEGAP2CROWS.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CDLXSIDEGAP3METHODS.R b/tests/testthat/test-ta_CDLXSIDEGAP3METHODS.R index f4b20b9e0..b75f9d538 100644 --- a/tests/testthat/test-ta_CDLXSIDEGAP3METHODS.R +++ b/tests/testthat/test-ta_CDLXSIDEGAP3METHODS.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CMO.R b/tests/testthat/test-ta_CMO.R index cbc21a57b..fee66ae36 100644 --- a/tests/testthat/test-ta_CMO.R +++ b/tests/testthat/test-ta_CMO.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_CORREL.R b/tests/testthat/test-ta_CORREL.R index 2680ac24d..f4a7c9964 100644 --- a/tests/testthat/test-ta_CORREL.R +++ b/tests/testthat/test-ta_CORREL.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz diff --git a/tests/testthat/test-ta_DEMA.R b/tests/testthat/test-ta_DEMA.R index 1ef030463..f1eb552aa 100644 --- a/tests/testthat/test-ta_DEMA.R +++ b/tests/testthat/test-ta_DEMA.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_DX.R b/tests/testthat/test-ta_DX.R index 0ef9a0ec7..324d9c9dc 100644 --- a/tests/testthat/test-ta_DX.R +++ b/tests/testthat/test-ta_DX.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_EMA.R b/tests/testthat/test-ta_EMA.R index 680097900..a891e0c47 100644 --- a/tests/testthat/test-ta_EMA.R +++ b/tests/testthat/test-ta_EMA.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_HT_DCPERIOD.R b/tests/testthat/test-ta_HT_DCPERIOD.R index c74fd4266..2c0888779 100644 --- a/tests/testthat/test-ta_HT_DCPERIOD.R +++ b/tests/testthat/test-ta_HT_DCPERIOD.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_HT_DCPHASE.R b/tests/testthat/test-ta_HT_DCPHASE.R index 44073b4ad..2213cd8cf 100644 --- a/tests/testthat/test-ta_HT_DCPHASE.R +++ b/tests/testthat/test-ta_HT_DCPHASE.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_HT_PHASOR.R b/tests/testthat/test-ta_HT_PHASOR.R index 063b034bf..8326cecb3 100644 --- a/tests/testthat/test-ta_HT_PHASOR.R +++ b/tests/testthat/test-ta_HT_PHASOR.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_HT_SINE.R b/tests/testthat/test-ta_HT_SINE.R index 21aab5ca8..02822c352 100644 --- a/tests/testthat/test-ta_HT_SINE.R +++ b/tests/testthat/test-ta_HT_SINE.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_HT_TRENDLINE.R b/tests/testthat/test-ta_HT_TRENDLINE.R index 7d05c935b..79727d320 100644 --- a/tests/testthat/test-ta_HT_TRENDLINE.R +++ b/tests/testthat/test-ta_HT_TRENDLINE.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_HT_TRENDMODE.R b/tests/testthat/test-ta_HT_TRENDMODE.R index df8d30209..2dcb0b53b 100644 --- a/tests/testthat/test-ta_HT_TRENDMODE.R +++ b/tests/testthat/test-ta_HT_TRENDMODE.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_IMI.R b/tests/testthat/test-ta_IMI.R index 586fd435c..004c14457 100644 --- a/tests/testthat/test-ta_IMI.R +++ b/tests/testthat/test-ta_IMI.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_KAMA.R b/tests/testthat/test-ta_KAMA.R index 3a7c163a1..2ac1496e6 100644 --- a/tests/testthat/test-ta_KAMA.R +++ b/tests/testthat/test-ta_KAMA.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MACD.R b/tests/testthat/test-ta_MACD.R index ba3060c1f..2490b0762 100644 --- a/tests/testthat/test-ta_MACD.R +++ b/tests/testthat/test-ta_MACD.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MACDEXT.R b/tests/testthat/test-ta_MACDEXT.R index ad6b9ccb0..0352920ff 100644 --- a/tests/testthat/test-ta_MACDEXT.R +++ b/tests/testthat/test-ta_MACDEXT.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -153,7 +153,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MACDFIX.R b/tests/testthat/test-ta_MACDFIX.R index 2ebd33b7e..dd74259cb 100644 --- a/tests/testthat/test-ta_MACDFIX.R +++ b/tests/testthat/test-ta_MACDFIX.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -147,7 +147,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MAMA.R b/tests/testthat/test-ta_MAMA.R index c817b02db..db393ede7 100644 --- a/tests/testthat/test-ta_MAMA.R +++ b/tests/testthat/test-ta_MAMA.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MAVP.R b/tests/testthat/test-ta_MAVP.R new file mode 100644 index 000000000..15b77dc14 --- /dev/null +++ b/tests/testthat/test-ta_MAVP.R @@ -0,0 +1,145 @@ +## autogenerated unit-test +## from codegen/ +## the file will be overwritten in the next iteration +## +## author: Serkan Korkmaz + +## alias and function similarity +## checks this ensures that +## MAVP and MAVP produces the same results +testthat::test_that(desc = 'Alias and function similarity', code = { + ## 1) test that the alias and + ## function returns the same values + output <- MAVP(SPY) + alias <- MAVP(SPY) + + ## 1.1) check if the values + ## are equal + testthat::expect_equal( + object = output, + expected = alias + ) +}) + +## type-checks for data.frames and +## matrices +## +## object +testthat::test_that(desc = 'Class in, class out ()', code = { + ## 1) check that the output class + ## matches the input class + testthat::expect_true( + inherits(MAVP(SPY), class(SPY)) + ) +}) + +## object +testthat::test_that(desc = 'Class in, class out ()', code = { + ## 1) check that the output class + ## matches the input class + testthat::expect_true( + inherits(MAVP(BTC), class(BTC)) + ) +}) + +## check that the default calls +## matches that of the constructed call +## with default values. +## +## NOTE: This test is more of a test of the internal +## series() function +testthat::test_that(desc = 'Default calls', code = { + testthat::expect_equal( + object = MAVP( + BTC + ), + expected = MAVP( + BTC, + cols = ~close + ) + ) +}) + +## check that the length of the input +## matches the output length with na.bridge = TRUE +## +## object +testthat::test_that(desc = 'Equal length of input and output for with na.bridge = TRUE', code = { + testthat::expect_equal( + object = nrow(MAVP( + ATOM, + na.bridge = TRUE + )), + expected = nrow(ATOM) + ) +}) + +## check that the rownames are being +## respected for with na.bridge = TRUE +testthat::test_that(desc = 'Row names are respected for , na.bridge = TRUE', code = { + ## extract row names + x_names <- row.names(ATOM) + + ## calculate indicator + indicator <- MAVP(ATOM, na.bridge = TRUE) + + testthat::expect_equal( + object = x_names, + expected = rownames(indicator) + ) +}) + +## check that the length of the input +## matches the output length +## +## object +testthat::test_that(desc = 'Equal length of input and output for ', code = { + testthat::expect_equal( + object = nrow(MAVP( + BTC + )), + expected = nrow(BTC) + ) +}) + +## check that the rownames are being +## respected for +testthat::test_that(desc = 'Row names are respected for ', code = { + ## extract row names + x_names <- row.names(BTC) + + ## calculate indicator + indicator <- MAVP(BTC) + + testthat::expect_equal( + object = x_names, + expected = rownames(indicator) + ) +}) + +## object +testthat::test_that(desc = 'Equal length of input and output for ', code = { + testthat::expect_equal( + object = nrow(MAVP( + SPY + )), + expected = nrow(SPY) + ) +}) + +## check that the rownames are being +## respected for +testthat::test_that(desc = 'Row names are respected for ', code = { + ## extract row names + ## NOTE: by default the SPY has no + ## rownames + rownames(SPY) <- paste0("row", 1:nrow(SPY)) + + ## calculate indicator + indicator <- MAVP(SPY) + + testthat::expect_equal( + object = paste0("row", 1:nrow(SPY)), + expected = rownames(indicator) + ) +}) diff --git a/tests/testthat/test-ta_MEDPRICE.R b/tests/testthat/test-ta_MEDPRICE.R index a3268f1ec..5260155c0 100644 --- a/tests/testthat/test-ta_MEDPRICE.R +++ b/tests/testthat/test-ta_MEDPRICE.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz diff --git a/tests/testthat/test-ta_MFI.R b/tests/testthat/test-ta_MFI.R index b6f832c39..18f975043 100644 --- a/tests/testthat/test-ta_MFI.R +++ b/tests/testthat/test-ta_MFI.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_ROCR.R b/tests/testthat/test-ta_MIDPOINT.R similarity index 58% rename from tests/testthat/test-ta_ROCR.R rename to tests/testthat/test-ta_MIDPOINT.R index 88baa1d32..3fff2596c 100644 --- a/tests/testthat/test-ta_ROCR.R +++ b/tests/testthat/test-ta_MIDPOINT.R @@ -1,17 +1,17 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz ## alias and function similarity ## checks this ensures that -## ratio_of_change and ROCR produces the same results +## MIDPOINT and MIDPOINT produces the same results testthat::test_that(desc = 'Alias and function similarity', code = { ## 1) test that the alias and ## function returns the same values - output <- ratio_of_change(SPY) - alias <- ROCR(SPY) + output <- MIDPOINT(SPY) + alias <- MIDPOINT(SPY) ## 1.1) check if the values ## are equal @@ -29,7 +29,7 @@ testthat::test_that(desc = 'Class in, class out ()', code = { ## 1) check that the output class ## matches the input class testthat::expect_true( - inherits(ratio_of_change(SPY), class(SPY)) + inherits(MIDPOINT(SPY), class(SPY)) ) }) @@ -38,7 +38,7 @@ testthat::test_that(desc = 'Class in, class out ()', code = { ## 1) check that the output class ## matches the input class testthat::expect_true( - inherits(ratio_of_change(BTC), class(BTC)) + inherits(MIDPOINT(BTC), class(BTC)) ) }) @@ -50,10 +50,10 @@ testthat::test_that(desc = 'Class in, class out ()', code = { ## series() function testthat::test_that(desc = 'Default calls', code = { testthat::expect_equal( - object = ratio_of_change( + object = MIDPOINT( BTC ), - expected = ratio_of_change( + expected = MIDPOINT( BTC, cols = ~close ) @@ -66,7 +66,7 @@ testthat::test_that(desc = 'Default calls', code = { ## object testthat::test_that(desc = 'Equal length of input and output for with na.bridge = TRUE', code = { testthat::expect_equal( - object = nrow(ratio_of_change( + object = nrow(MIDPOINT( ATOM, na.bridge = TRUE )), @@ -81,7 +81,7 @@ testthat::test_that(desc = 'Row names are respected for , na.bridge x_names <- row.names(ATOM) ## calculate indicator - indicator <- ratio_of_change(ATOM, na.bridge = TRUE) + indicator <- MIDPOINT(ATOM, na.bridge = TRUE) testthat::expect_equal( object = x_names, @@ -95,7 +95,7 @@ testthat::test_that(desc = 'Row names are respected for , na.bridge ## object testthat::test_that(desc = 'Equal length of input and output for ', code = { testthat::expect_equal( - object = nrow(ratio_of_change( + object = nrow(MIDPOINT( BTC )), expected = nrow(BTC) @@ -109,7 +109,7 @@ testthat::test_that(desc = 'Row names are respected for ', code = { x_names <- row.names(BTC) ## calculate indicator - indicator <- ratio_of_change(BTC) + indicator <- MIDPOINT(BTC) testthat::expect_equal( object = x_names, @@ -120,7 +120,7 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ## object testthat::test_that(desc = 'Equal length of input and output for ', code = { testthat::expect_equal( - object = nrow(ratio_of_change( + object = nrow(MIDPOINT( SPY )), expected = nrow(SPY) @@ -136,7 +136,7 @@ testthat::test_that(desc = 'Row names are respected for ', code = { rownames(SPY) <- paste0("row", 1:nrow(SPY)) ## calculate indicator - indicator <- ratio_of_change(SPY) + indicator <- MIDPOINT(SPY) testthat::expect_equal( object = paste0("row", 1:nrow(SPY)), @@ -144,100 +144,13 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - -## -method checks for -## and -## -## checks -testthat::test_that(desc = '-methods for ', code = { - ## check that ratio_of_change can - ## use without any issues - output <- testthat::expect_no_error( - { - chart(BTC) - indicator(ratio_of_change) - } - ) - - ## check that the output - ## is a -object - testthat::expect_true( - inherits(output, "plotly") - ) -}) - -## checks -testthat::test_that(desc = '-methods for ', code = { - ## check that ratio_of_change can - ## use without any issues - output <- testthat::expect_no_error( - { - chart(SPY) - indicator(ratio_of_change) - } - ) - - ## check that the output - ## is a -object - testthat::expect_true( - inherits(output, "plotly") - ) -}) - -## -method checks for -## and -## -## checks -testthat::test_that(desc = '-methods for ', code = { - testthat::skip_if_not_installed("ggplot2") - - ## check that ratio_of_change can - ## use without any issues - output <- testthat::expect_no_error( - { - options(talib.chart.backend = "ggplot2") - on.exit(options(talib.chart.backend = "plotly")) - chart(BTC) - indicator(ratio_of_change) - } - ) - - ## check that the output - ## is a -object or - testthat::expect_true( - inherits(output, "gg") || inherits(output, "talib_chart") - ) -}) - -## checks -testthat::test_that(desc = '-methods for ', code = { - testthat::skip_if_not_installed("ggplot2") - - ## check that ratio_of_change can - ## use without any issues - output <- testthat::expect_no_error( - { - options(talib.chart.backend = "ggplot2") - on.exit(options(talib.chart.backend = "plotly")) - chart(SPY) - indicator(ratio_of_change) - } - ) - - ## check that the output - ## is a -object or - testthat::expect_true( - inherits(output, "gg") || inherits(output, "talib_chart") - ) -}) - ## check that methods runs without ## issues and returns proper lengths testthat::test_that(desc = ' methods', code = { ## check that the method ## runs x <- testthat::expect_no_condition( - ratio_of_change(BTC[[1]]) + MIDPOINT(BTC[[1]]) ) target_length <- length(BTC[[1]]) diff --git a/tests/testthat/test-ta_MIDPRICE.R b/tests/testthat/test-ta_MIDPRICE.R index 3b0ff3d34..7c78aa970 100644 --- a/tests/testthat/test-ta_MIDPRICE.R +++ b/tests/testthat/test-ta_MIDPRICE.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz diff --git a/tests/testthat/test-ta_MIN.R b/tests/testthat/test-ta_MIN.R deleted file mode 100644 index 8e4b4a794..000000000 --- a/tests/testthat/test-ta_MIN.R +++ /dev/null @@ -1,45 +0,0 @@ -## autogenerated unit-test -## from codegen/generate_unit-tests.sh -## the file will be overwritten in the next iteration -## -## author: Serkan Korkmaz - -## test that the function runs without -## any conditions -testthat::test_that(desc = 'Runs without *any* conditions', code = { - output <- testthat::expect_no_condition( - { - rolling_min( - x = SPY[, 1] - ) - } - ) -}) - -## test that the length of the input -## matches the output -testthat::test_that(desc = 'Length in, length out', code = { - testthat::expect_equal( - object = length( - rolling_min( - x = SPY[, 1] - ) - ), - expected = length(SPY[, 1]) - ) -}) - -## test that the output is a vector -testthat::test_that(desc = 'Output type', code = { - output <- rolling_min( - x = SPY[, 1] - ) - - testthat::expect_true( - typeof(output) == "double" || typeof(output) == "integer" - ) - - testthat::expect_true( - is.null(dim(output)) - ) -}) diff --git a/tests/testthat/test-ta_MINUS_DI.R b/tests/testthat/test-ta_MINUS_DI.R index a2d444dd9..30f56e855 100644 --- a/tests/testthat/test-ta_MINUS_DI.R +++ b/tests/testthat/test-ta_MINUS_DI.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MINUS_DM.R b/tests/testthat/test-ta_MINUS_DM.R index bd13137d1..3e3451e9d 100644 --- a/tests/testthat/test-ta_MINUS_DM.R +++ b/tests/testthat/test-ta_MINUS_DM.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MOM.R b/tests/testthat/test-ta_MOM.R index 480243f7a..af988a278 100644 --- a/tests/testthat/test-ta_MOM.R +++ b/tests/testthat/test-ta_MOM.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_NATR.R b/tests/testthat/test-ta_NATR.R index 5d3e8d6cf..5bb7f97a7 100644 --- a/tests/testthat/test-ta_NATR.R +++ b/tests/testthat/test-ta_NATR.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_OBV.R b/tests/testthat/test-ta_OBV.R index e15438b2b..bac75f9bf 100644 --- a/tests/testthat/test-ta_OBV.R +++ b/tests/testthat/test-ta_OBV.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_PLUS_DI.R b/tests/testthat/test-ta_PLUS_DI.R index 252e91b89..4bcff06a0 100644 --- a/tests/testthat/test-ta_PLUS_DI.R +++ b/tests/testthat/test-ta_PLUS_DI.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_PLUS_DM.R b/tests/testthat/test-ta_PLUS_DM.R index 2e960ee99..a920be0ea 100644 --- a/tests/testthat/test-ta_PLUS_DM.R +++ b/tests/testthat/test-ta_PLUS_DM.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_PPO.R b/tests/testthat/test-ta_PPO.R index 1325491b4..895ae9c8f 100644 --- a/tests/testthat/test-ta_PPO.R +++ b/tests/testthat/test-ta_PPO.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_RSI.R b/tests/testthat/test-ta_RSI.R index cef6ef1ba..ed47b86b1 100644 --- a/tests/testthat/test-ta_RSI.R +++ b/tests/testthat/test-ta_RSI.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_SAR.R b/tests/testthat/test-ta_SAR.R index a3e0a58d8..f0d96cd7f 100644 --- a/tests/testthat/test-ta_SAR.R +++ b/tests/testthat/test-ta_SAR.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_SAREXT.R b/tests/testthat/test-ta_SAREXT.R index 3489c4c7f..1e3e54256 100644 --- a/tests/testthat/test-ta_SAREXT.R +++ b/tests/testthat/test-ta_SAREXT.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_SMA.R b/tests/testthat/test-ta_SMA.R index aa5a058ac..793b36c22 100644 --- a/tests/testthat/test-ta_SMA.R +++ b/tests/testthat/test-ta_SMA.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_STDDEV.R b/tests/testthat/test-ta_STDDEV.R index 938920e2c..6de7e1407 100644 --- a/tests/testthat/test-ta_STDDEV.R +++ b/tests/testthat/test-ta_STDDEV.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz diff --git a/tests/testthat/test-ta_STOCH.R b/tests/testthat/test-ta_STOCH.R index 45fcbc33e..1834350d0 100644 --- a/tests/testthat/test-ta_STOCH.R +++ b/tests/testthat/test-ta_STOCH.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_STOCHF.R b/tests/testthat/test-ta_STOCHF.R index 6605c6abf..73e081e23 100644 --- a/tests/testthat/test-ta_STOCHF.R +++ b/tests/testthat/test-ta_STOCHF.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_STOCHRSI.R b/tests/testthat/test-ta_STOCHRSI.R index 68e5a3cdc..6c96a42e4 100644 --- a/tests/testthat/test-ta_STOCHRSI.R +++ b/tests/testthat/test-ta_STOCHRSI.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_SUM.R b/tests/testthat/test-ta_SUM.R deleted file mode 100644 index 793bc616c..000000000 --- a/tests/testthat/test-ta_SUM.R +++ /dev/null @@ -1,45 +0,0 @@ -## autogenerated unit-test -## from codegen/generate_unit-tests.sh -## the file will be overwritten in the next iteration -## -## author: Serkan Korkmaz - -## test that the function runs without -## any conditions -testthat::test_that(desc = 'Runs without *any* conditions', code = { - output <- testthat::expect_no_condition( - { - rolling_sum( - x = SPY[, 1] - ) - } - ) -}) - -## test that the length of the input -## matches the output -testthat::test_that(desc = 'Length in, length out', code = { - testthat::expect_equal( - object = length( - rolling_sum( - x = SPY[, 1] - ) - ), - expected = length(SPY[, 1]) - ) -}) - -## test that the output is a vector -testthat::test_that(desc = 'Output type', code = { - output <- rolling_sum( - x = SPY[, 1] - ) - - testthat::expect_true( - typeof(output) == "double" || typeof(output) == "integer" - ) - - testthat::expect_true( - is.null(dim(output)) - ) -}) diff --git a/tests/testthat/test-ta_T3.R b/tests/testthat/test-ta_T3.R index e1aa95eb5..ab422c873 100644 --- a/tests/testthat/test-ta_T3.R +++ b/tests/testthat/test-ta_T3.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_TEMA.R b/tests/testthat/test-ta_TEMA.R index bfdf9cdb1..ff14cf8fb 100644 --- a/tests/testthat/test-ta_TEMA.R +++ b/tests/testthat/test-ta_TEMA.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_TRANGE.R b/tests/testthat/test-ta_TRANGE.R index de90b9169..359412103 100644 --- a/tests/testthat/test-ta_TRANGE.R +++ b/tests/testthat/test-ta_TRANGE.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_TRIMA.R b/tests/testthat/test-ta_TRIMA.R index 0701e8b95..ca8016d6b 100644 --- a/tests/testthat/test-ta_TRIMA.R +++ b/tests/testthat/test-ta_TRIMA.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_TRIX.R b/tests/testthat/test-ta_TRIX.R index 584478123..d8b3b91b8 100644 --- a/tests/testthat/test-ta_TRIX.R +++ b/tests/testthat/test-ta_TRIX.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_MAX.R b/tests/testthat/test-ta_TSF.R similarity index 89% rename from tests/testthat/test-ta_MAX.R rename to tests/testthat/test-ta_TSF.R index d18da372d..a15ae6fe9 100644 --- a/tests/testthat/test-ta_MAX.R +++ b/tests/testthat/test-ta_TSF.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -9,7 +9,7 @@ testthat::test_that(desc = 'Runs without *any* conditions', code = { output <- testthat::expect_no_condition( { - rolling_max( + TSF( x = SPY[, 1] ) } @@ -21,7 +21,7 @@ testthat::test_that(desc = 'Runs without *any* conditions', code = { testthat::test_that(desc = 'Length in, length out', code = { testthat::expect_equal( object = length( - rolling_max( + TSF( x = SPY[, 1] ) ), @@ -31,7 +31,7 @@ testthat::test_that(desc = 'Length in, length out', code = { ## test that the output is a vector testthat::test_that(desc = 'Output type', code = { - output <- rolling_max( + output <- TSF( x = SPY[, 1] ) diff --git a/tests/testthat/test-ta_TYPPRICE.R b/tests/testthat/test-ta_TYPPRICE.R index d6938c5aa..cd2b42e8c 100644 --- a/tests/testthat/test-ta_TYPPRICE.R +++ b/tests/testthat/test-ta_TYPPRICE.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz diff --git a/tests/testthat/test-ta_ULTOSC.R b/tests/testthat/test-ta_ULTOSC.R index 3ddd6650c..93f120abc 100644 --- a/tests/testthat/test-ta_ULTOSC.R +++ b/tests/testthat/test-ta_ULTOSC.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_VAR.R b/tests/testthat/test-ta_VAR.R index f8403c2cd..4340b8726 100644 --- a/tests/testthat/test-ta_VAR.R +++ b/tests/testthat/test-ta_VAR.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz diff --git a/tests/testthat/test-ta_WCLPRICE.R b/tests/testthat/test-ta_WCLPRICE.R index ab6ad34e9..92b9f76d8 100644 --- a/tests/testthat/test-ta_WCLPRICE.R +++ b/tests/testthat/test-ta_WCLPRICE.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz diff --git a/tests/testthat/test-ta_WILLR.R b/tests/testthat/test-ta_WILLR.R index a7e15e63b..1a038942c 100644 --- a/tests/testthat/test-ta_WILLR.R +++ b/tests/testthat/test-ta_WILLR.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## diff --git a/tests/testthat/test-ta_WMA.R b/tests/testthat/test-ta_WMA.R index 0d27be6a0..5cb9188bc 100644 --- a/tests/testthat/test-ta_WMA.R +++ b/tests/testthat/test-ta_WMA.R @@ -1,5 +1,5 @@ ## autogenerated unit-test -## from codegen/generate_unit-tests.sh +## from codegen/ ## the file will be overwritten in the next iteration ## ## author: Serkan Korkmaz @@ -144,7 +144,6 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) - ## -method checks for ## and ## From f650702fa53901d5fe29eaa093c127e8d3bbb201 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 11:43:42 +0200 Subject: [PATCH 10/37] :hammer: Added optional parameter documentation * The optional documentation is mined fromn the .xml file and manipulated so it emits proper R documentation for each documented parameter. --- codegen/src/metadata.rs | 30 +++++++- codegen/src/render.rs | 84 ++++++++++++++++++++- codegen/templates/indicator_template.R | 1 + codegen/templates/moving_average_template.R | 1 + codegen/templates/rolling_template.R | 1 + 5 files changed, 112 insertions(+), 5 deletions(-) diff --git a/codegen/src/metadata.rs b/codegen/src/metadata.rs index 5e1d34d5c..65d2513fc 100644 --- a/codegen/src/metadata.rs +++ b/codegen/src/metadata.rs @@ -47,12 +47,14 @@ impl MetaData { /// An reduced to what the /// R signature needs: an argument name, its type -/// (for the .Call() coercion) and its default value +/// (for the .Call() coercion), its default value and +/// its one-line description (for the @param docs) #[derive(Clone, Debug, PartialEq)] pub struct OptionalArg { pub name: String, pub kind: OptionalType, pub default: String, + pub description: String, } #[derive(Clone, Debug, PartialEq)] @@ -152,6 +154,19 @@ pub fn parse_api(xml: &str) -> Vec { let name = camel_case(tag_text(arg, "Name").expect("optional Name")); let default = tag_text(arg, "DefaultValue").expect("DefaultValue"); + // the ShortDescription becomes the @param text; the + // XML is entity-escaped and carries a few wording + // slips ('fro', 'Nb of') worth fixing at the source + let description = tag_text(arg, "ShortDescription") + .expect("optional ShortDescription") + .replace(">", ">") + .replace("<", "<") + .replace("&", "&") + .replace(" fro ", " for ") + .replace("Nb of", "Number of") + .trim_end_matches('.') + .to_string(); + let (kind, default) = match tag_text(arg, "Type").expect("optional Type") { "Integer" => (OptionalType::Integer, default.to_string()), "MA Type" => (OptionalType::MAType, default.to_string()), @@ -166,6 +181,7 @@ pub fn parse_api(xml: &str) -> Vec { name, kind, default, + description, }); } @@ -193,6 +209,7 @@ pub(crate) const SAMPLE: &str = r#" Time Period + Number of period Integer 2 @@ -202,11 +219,13 @@ pub(crate) const SAMPLE: &str = r#" Deviations up + Deviation multiplier for upper band Double 2.000000e+0 MA Type + Type of Moving Average MA Type 0 @@ -273,17 +292,20 @@ mod tests { OptionalArg { name: "timePeriod".to_string(), kind: OptionalType::Integer, - default: "5".to_string() + default: "5".to_string(), + description: "Number of period".to_string() }, OptionalArg { name: "deviationsUp".to_string(), kind: OptionalType::Double, - default: "2".to_string() + default: "2".to_string(), + description: "Deviation multiplier for upper band".to_string() }, OptionalArg { name: "maType".to_string(), kind: OptionalType::MAType, - default: "0".to_string() + default: "0".to_string(), + description: "Type of Moving Average".to_string() } ] ); diff --git a/codegen/src/render.rs b/codegen/src/render.rs index 246994e3b..540153ae8 100644 --- a/codegen/src/render.rs +++ b/codegen/src/render.rs @@ -15,7 +15,9 @@ //! on disk are preserved by preserve_regions() (see main.rs). use crate::metadata::{MetaData, OptionalArg, OptionalType}; -use crate::tables::{ChartType, agnostic, chart_type, function_name, is_candlestick, ma_type}; +use crate::tables::{ + ChartType, MOVING_AVERAGES, agnostic, chart_type, function_name, is_candlestick, ma_type, +}; /// The template files rendered by render_indicator(), /// loaded once from 'codegen/templates/' @@ -164,10 +166,60 @@ pub fn render_indicator(f: &MetaData, t: &Templates) -> String { name: "timePeriod".to_string(), kind: OptionalType::Integer, default: "30".to_string(), + description: "Number of period".to_string(), }, ); } + // the ${PARAM_DOCS} roxygen lines of the generic, one @param + // per optional input with its type, XML description and default, + // e.g. #' @param fastPeriod ([integer]). Number of period for + // the fast MA. Defaults to `12`. MAType formals additionally + // carry the index legend with the default's moving average + // spelled out inline. + // + // timePeriod and penetration are skipped: they are documented + // by the man-roxygen templates ('description.R' and + // 'rolling_description.R'). An empty result renders a blank + // roxygen line so the block stays contiguous + let param_docs = { + let docs = formals + .iter() + .filter(|a| a.name != "timePeriod" && a.name != "penetration") + .map(|a| match a.kind { + OptionalType::MAType => { + let default_ma = MOVING_AVERAGES + .iter() + .find(|(_, index)| index.trim_end_matches('L') == a.default) + .map(|(ma, _)| *ma) + .unwrap_or_else(|| panic!("no moving average for TA_MAType {}", a.default)); + + format!( + "#' @param {} ([integer]). {}. Defaults to `{}` ([{}]). Can also be passed as talib::{}.", + a.name, a.description, a.default, default_ma, default_ma + ) + } + _ => format!( + "#' @param {} ([{}]). {}. Defaults to `{}`.", + a.name, + match a.kind { + OptionalType::Double => "double", + _ => "integer", + }, + a.description, + a.default + ), + }) + .collect::>() + .join("\n"); + + if docs.is_empty() { + "#'".to_string() + } else { + docs + } + }; + // formals and pass-through arguments, // e.g. 'timePeriod = 14,' and 'timePeriod = timePeriod,' let args = formals @@ -251,6 +303,7 @@ pub fn render_indicator(f: &MetaData, t: &Templates) -> String { .replace("${TITLE}", &f.title) .replace("${FAMILY}", &f.family) .replace("${FORMULA}", &formula) + .replace("${PARAM_DOCS}", ¶m_docs) .replace("${ARGS}", &args) .replace("${PARGS}", &pargs) .replace("${C_SIGNATURE_LOOKBACK}", &c_lookback) @@ -535,6 +588,19 @@ tail assert!(rendered.contains("as.double(deviationsUp)")); assert!(!rendered.contains("${"), "unreplaced placeholder"); + // the optional inputs are documented with type, description + // and default; timePeriod stays with the man-roxygen template + assert!(rendered.contains( + "#' @param deviationsUp ([double]). Deviation multiplier for upper band. Defaults to `2`." + )); + assert!(!rendered.contains("#' @param timePeriod")); + + // MAType formals carry the TA_MAType legend with the + // default's moving average spelled out inline + assert!(rendered.contains( + "#' @param maType ([integer]). Type of Moving Average. Defaults to `0` ([SMA]). Can also be passed as talib::SMA." + )); + // univariate: the numeric method is appended // after the matrix method with the raw vector assert!(rendered.contains("bollinger_bands.numeric <- function(")); @@ -642,10 +708,26 @@ tail "constructed_series[[1]],\n\t\tas.double(fastLimit),\n\t\tas.double(slowLimit)" )); + // every optional input beyond timePeriod/penetration is + // documented with type, description and default + let macd = render("MACD"); + assert!(macd.contains( + "#' @param fastPeriod ([integer]). Number of period for the fast MA. Defaults to `12`." + )); + assert!(macd.contains( + "#' @param signalPeriod ([integer]). Smoothing for the signal line (nb of period). Defaults to `9`." + )); + // rolling statistics: protected .Call() region, // no chart methods let stddev = render("STDDEV"); assert!(stddev.contains("rolling_standard_deviation <- function(")); + assert!( + stddev.contains( + "#' @param deviations ([double]). Number of deviations. Defaults to `1`." + ) + ); + assert!(!stddev.contains("#' @param timePeriod")); assert!(stddev.contains("@template rolling_returns")); assert!(stddev.contains("## splice:call:start")); assert!(stddev.contains("as.double(x),")); diff --git a/codegen/templates/indicator_template.R b/codegen/templates/indicator_template.R index 1d1e5fe71..69e16a45e 100644 --- a/codegen/templates/indicator_template.R +++ b/codegen/templates/indicator_template.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +${PARAM_DOCS} #' @template returns ${FUN} <- function( x, diff --git a/codegen/templates/moving_average_template.R b/codegen/templates/moving_average_template.R index 44fb5e40e..69df17eeb 100644 --- a/codegen/templates/moving_average_template.R +++ b/codegen/templates/moving_average_template.R @@ -18,6 +18,7 @@ #' indicators that supports various Moving Average specifications. #' #' @template description +${PARAM_DOCS} #' @template returns ${FUN} <- function( x, diff --git a/codegen/templates/rolling_template.R b/codegen/templates/rolling_template.R index f1858d845..95b2d7f9b 100644 --- a/codegen/templates/rolling_template.R +++ b/codegen/templates/rolling_template.R @@ -10,6 +10,7 @@ ## splice:documentation:end #' #' @template rolling_description +${PARAM_DOCS} #' @template rolling_returns ${FUN} <- function( x, From 5a10826f4932d2e11cbc932b6c3bfbc850405a4a Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 11:45:08 +0200 Subject: [PATCH 11/37] :books: n --> timePeriod and eps --> penetration * This change reflects the new signature the exported functions follow. --- man-roxygen/description.R | 8 ++++---- man-roxygen/rolling_description.R | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/man-roxygen/description.R b/man-roxygen/description.R index 7b7426fb6..9eaa92455 100644 --- a/man-roxygen/description.R +++ b/man-roxygen/description.R @@ -62,12 +62,12 @@ <% } %> #' <% fun_args <- names(formals(.fun)) %> -<% if ("n" %in% fun_args) { %> -#' @param n ([integer]). Lookback period (window size). A positive [integer] +<% if ("timePeriod" %in% fun_args) { %> +#' @param timePeriod ([integer]). Lookback period (window size). A positive [integer] #' of [length] 1. <% } %> -<% if ("eps" %in% fun_args) { %> -#' @param eps ([double]). Penetration threshold for candlestick pattern +<% if ("penetration" %in% fun_args) { %> +#' @param penetration ([double]). Penetration threshold for candlestick pattern #' recognition, expressed as a fraction of the candle body. A [double] of #' [length] 1. <% } %> diff --git a/man-roxygen/rolling_description.R b/man-roxygen/rolling_description.R index a9dda6307..5143c256e 100644 --- a/man-roxygen/rolling_description.R +++ b/man-roxygen/rolling_description.R @@ -30,8 +30,8 @@ #' <% } %> <% fun_args <- names(formals(.fun)) %> -<% if ("n" %in% fun_args) { %> -#' @param n ([integer]). Lookback period (window size). A positive [integer] +<% if ("timePeriod" %in% fun_args) { %> +#' @param timePeriod ([integer]). Lookback period (window size). A positive [integer] #' of [length] 1. <% } %> <% if ("na.bridge" %in% fun_args) { %> From 5fd620517403486a69052255ecf0c56d16f82476 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 11:47:12 +0200 Subject: [PATCH 12/37] :hammer: Regenerated R-code with documentation --- R/ta_ACCBANDS.R | 1 + R/ta_AD.R | 1 + R/ta_ADOSC.R | 2 ++ R/ta_ADX.R | 1 + R/ta_ADXR.R | 1 + R/ta_APO.R | 3 +++ R/ta_AROON.R | 1 + R/ta_AROONOSC.R | 1 + R/ta_ATR.R | 1 + R/ta_AVGDEV.R | 1 + R/ta_AVGPRICE.R | 1 + R/ta_BBANDS.R | 3 +++ R/ta_BETA.R | 1 + R/ta_BOP.R | 1 + R/ta_CCI.R | 1 + R/ta_CMO.R | 1 + R/ta_CORREL.R | 1 + R/ta_DEMA.R | 1 + R/ta_DX.R | 1 + R/ta_EMA.R | 1 + R/ta_HT_DCPERIOD.R | 1 + R/ta_HT_DCPHASE.R | 1 + R/ta_HT_PHASOR.R | 1 + R/ta_HT_SINE.R | 1 + R/ta_HT_TRENDLINE.R | 1 + R/ta_HT_TRENDMODE.R | 1 + R/ta_IMI.R | 1 + R/ta_KAMA.R | 1 + R/ta_MACD.R | 3 +++ R/ta_MACDEXT.R | 6 ++++++ R/ta_MACDFIX.R | 1 + R/ta_MAMA.R | 2 ++ R/ta_MAVP.R | 3 +++ R/ta_MEDPRICE.R | 1 + R/ta_MFI.R | 1 + R/ta_MIDPOINT.R | 1 + R/ta_MIDPRICE.R | 1 + R/ta_MINUS_DI.R | 1 + R/ta_MINUS_DM.R | 1 + R/ta_MOM.R | 1 + R/ta_NATR.R | 1 + R/ta_OBV.R | 1 + R/ta_PLUS_DI.R | 1 + R/ta_PLUS_DM.R | 1 + R/ta_PPO.R | 3 +++ R/ta_RSI.R | 1 + R/ta_SAR.R | 2 ++ R/ta_SAREXT.R | 8 ++++++++ R/ta_SMA.R | 1 + R/ta_STDDEV.R | 1 + R/ta_STOCH.R | 5 +++++ R/ta_STOCHF.R | 3 +++ R/ta_STOCHRSI.R | 3 +++ R/ta_T3.R | 1 + R/ta_TEMA.R | 1 + R/ta_TRANGE.R | 1 + R/ta_TRIMA.R | 1 + R/ta_TRIX.R | 1 + R/ta_TSF.R | 1 + R/ta_TYPPRICE.R | 1 + R/ta_ULTOSC.R | 3 +++ R/ta_VAR.R | 1 + R/ta_WCLPRICE.R | 1 + R/ta_WILLR.R | 1 + R/ta_WMA.R | 1 + 65 files changed, 100 insertions(+) diff --git a/R/ta_ACCBANDS.R b/R/ta_ACCBANDS.R index 2e344ecb6..1d92376a9 100644 --- a/R/ta_ACCBANDS.R +++ b/R/ta_ACCBANDS.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns acceleration_bands <- function( x, diff --git a/R/ta_AD.R b/R/ta_AD.R index c0d439301..b752fcb19 100644 --- a/R/ta_AD.R +++ b/R/ta_AD.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns chaikin_accumulation_distribution_line <- function( x, diff --git a/R/ta_ADOSC.R b/R/ta_ADOSC.R index 6f8861cb6..ce4a07aaf 100644 --- a/R/ta_ADOSC.R +++ b/R/ta_ADOSC.R @@ -12,6 +12,8 @@ ## splice:documentation:end #' #' @template description +#' @param fastPeriod ([integer]). Number of period for the fast MA. Defaults to `3`. +#' @param slowPeriod ([integer]). Number of period for the slow MA. Defaults to `10`. #' @template returns chaikin_accumulation_distribution_oscillator <- function( x, diff --git a/R/ta_ADX.R b/R/ta_ADX.R index 04b2ddc47..a884ecb81 100644 --- a/R/ta_ADX.R +++ b/R/ta_ADX.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns average_directional_movement_index <- function( x, diff --git a/R/ta_ADXR.R b/R/ta_ADXR.R index 484d2f24f..47453c323 100644 --- a/R/ta_ADXR.R +++ b/R/ta_ADXR.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns average_directional_movement_index_rating <- function( x, diff --git a/R/ta_APO.R b/R/ta_APO.R index 3e4255ff4..4988cc132 100644 --- a/R/ta_APO.R +++ b/R/ta_APO.R @@ -12,6 +12,9 @@ ## splice:documentation:end #' #' @template description +#' @param fastPeriod ([integer]). Number of period for the fast MA. Defaults to `12`. +#' @param slowPeriod ([integer]). Number of period for the slow MA. Defaults to `26`. +#' @param maType ([integer]). Type of Moving Average. Defaults to `0` ([SMA]). Can also be passed as talib::SMA. #' @template returns absolute_price_oscillator <- function( x, diff --git a/R/ta_AROON.R b/R/ta_AROON.R index 2ee51324b..e48f8face 100644 --- a/R/ta_AROON.R +++ b/R/ta_AROON.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns aroon <- function( x, diff --git a/R/ta_AROONOSC.R b/R/ta_AROONOSC.R index 644e4b980..7a601c1f2 100644 --- a/R/ta_AROONOSC.R +++ b/R/ta_AROONOSC.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns aroon_oscillator <- function( x, diff --git a/R/ta_ATR.R b/R/ta_ATR.R index 498f2d633..c048deda1 100644 --- a/R/ta_ATR.R +++ b/R/ta_ATR.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns average_true_range <- function( x, diff --git a/R/ta_AVGDEV.R b/R/ta_AVGDEV.R index c8b34dbc8..c27eb5565 100644 --- a/R/ta_AVGDEV.R +++ b/R/ta_AVGDEV.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns AVGDEV <- function( x, diff --git a/R/ta_AVGPRICE.R b/R/ta_AVGPRICE.R index 9bce754c9..989f300af 100644 --- a/R/ta_AVGPRICE.R +++ b/R/ta_AVGPRICE.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns average_price <- function( x, diff --git a/R/ta_BBANDS.R b/R/ta_BBANDS.R index 87b370543..481913752 100644 --- a/R/ta_BBANDS.R +++ b/R/ta_BBANDS.R @@ -12,6 +12,9 @@ ## splice:documentation:end #' #' @template description +#' @param deviationsUp ([double]). Deviation multiplier for upper band. Defaults to `2`. +#' @param deviationsDown ([double]). Deviation multiplier for lower band. Defaults to `2`. +#' @param maType ([integer]). Type of Moving Average. Defaults to `0` ([SMA]). Can also be passed as talib::SMA. #' @template returns bollinger_bands <- function( x, diff --git a/R/ta_BETA.R b/R/ta_BETA.R index edf439921..ff1d70383 100644 --- a/R/ta_BETA.R +++ b/R/ta_BETA.R @@ -10,6 +10,7 @@ ## splice:documentation:end #' #' @template rolling_description +#' #' @template rolling_returns rolling_beta <- function( x, diff --git a/R/ta_BOP.R b/R/ta_BOP.R index 4dcc833d1..fdab8f600 100644 --- a/R/ta_BOP.R +++ b/R/ta_BOP.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns balance_of_power <- function( x, diff --git a/R/ta_CCI.R b/R/ta_CCI.R index 43344dadc..94b2c7d8a 100644 --- a/R/ta_CCI.R +++ b/R/ta_CCI.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns commodity_channel_index <- function( x, diff --git a/R/ta_CMO.R b/R/ta_CMO.R index 21d706834..429d18117 100644 --- a/R/ta_CMO.R +++ b/R/ta_CMO.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns chande_momentum_oscillator <- function( x, diff --git a/R/ta_CORREL.R b/R/ta_CORREL.R index 3af561a26..22ff2a692 100644 --- a/R/ta_CORREL.R +++ b/R/ta_CORREL.R @@ -10,6 +10,7 @@ ## splice:documentation:end #' #' @template rolling_description +#' #' @template rolling_returns rolling_correlation <- function( x, diff --git a/R/ta_DEMA.R b/R/ta_DEMA.R index 9e633b227..eeacbe045 100644 --- a/R/ta_DEMA.R +++ b/R/ta_DEMA.R @@ -18,6 +18,7 @@ #' indicators that supports various Moving Average specifications. #' #' @template description +#' #' @template returns double_exponential_moving_average <- function( x, diff --git a/R/ta_DX.R b/R/ta_DX.R index 663b50bb1..2907cf97b 100644 --- a/R/ta_DX.R +++ b/R/ta_DX.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns directional_movement_index <- function( x, diff --git a/R/ta_EMA.R b/R/ta_EMA.R index adffb6d18..f141e750e 100644 --- a/R/ta_EMA.R +++ b/R/ta_EMA.R @@ -18,6 +18,7 @@ #' indicators that supports various Moving Average specifications. #' #' @template description +#' #' @template returns exponential_moving_average <- function( x, diff --git a/R/ta_HT_DCPERIOD.R b/R/ta_HT_DCPERIOD.R index 13c9796e7..f487f87b0 100644 --- a/R/ta_HT_DCPERIOD.R +++ b/R/ta_HT_DCPERIOD.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns dominant_cycle_period <- function( x, diff --git a/R/ta_HT_DCPHASE.R b/R/ta_HT_DCPHASE.R index 1428acdb1..42b4ba1d0 100644 --- a/R/ta_HT_DCPHASE.R +++ b/R/ta_HT_DCPHASE.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns dominant_cycle_phase <- function( x, diff --git a/R/ta_HT_PHASOR.R b/R/ta_HT_PHASOR.R index 877e94761..9d8659275 100644 --- a/R/ta_HT_PHASOR.R +++ b/R/ta_HT_PHASOR.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns phasor_components <- function( x, diff --git a/R/ta_HT_SINE.R b/R/ta_HT_SINE.R index 4eac57d90..7cf71f1f9 100644 --- a/R/ta_HT_SINE.R +++ b/R/ta_HT_SINE.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns sine_wave <- function( x, diff --git a/R/ta_HT_TRENDLINE.R b/R/ta_HT_TRENDLINE.R index 43f7e06b4..df807f6e9 100644 --- a/R/ta_HT_TRENDLINE.R +++ b/R/ta_HT_TRENDLINE.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns trendline <- function( x, diff --git a/R/ta_HT_TRENDMODE.R b/R/ta_HT_TRENDMODE.R index 70942acde..976364718 100644 --- a/R/ta_HT_TRENDMODE.R +++ b/R/ta_HT_TRENDMODE.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns trend_cycle_mode <- function( x, diff --git a/R/ta_IMI.R b/R/ta_IMI.R index 2d800921d..d6b2d2eee 100644 --- a/R/ta_IMI.R +++ b/R/ta_IMI.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns intraday_movement_index <- function( x, diff --git a/R/ta_KAMA.R b/R/ta_KAMA.R index 8d244a2cd..6f6ba7f0f 100644 --- a/R/ta_KAMA.R +++ b/R/ta_KAMA.R @@ -18,6 +18,7 @@ #' indicators that supports various Moving Average specifications. #' #' @template description +#' #' @template returns kaufman_adaptive_moving_average <- function( x, diff --git a/R/ta_MACD.R b/R/ta_MACD.R index 0655ba9a2..87870a7cf 100644 --- a/R/ta_MACD.R +++ b/R/ta_MACD.R @@ -12,6 +12,9 @@ ## splice:documentation:end #' #' @template description +#' @param fastPeriod ([integer]). Number of period for the fast MA. Defaults to `12`. +#' @param slowPeriod ([integer]). Number of period for the slow MA. Defaults to `26`. +#' @param signalPeriod ([integer]). Smoothing for the signal line (nb of period). Defaults to `9`. #' @template returns moving_average_convergence_divergence <- function( x, diff --git a/R/ta_MACDEXT.R b/R/ta_MACDEXT.R index f022e3695..21ca82a71 100644 --- a/R/ta_MACDEXT.R +++ b/R/ta_MACDEXT.R @@ -12,6 +12,12 @@ ## splice:documentation:end #' #' @template description +#' @param fastPeriod ([integer]). Number of period for the fast MA. Defaults to `12`. +#' @param fastMa ([integer]). Type of Moving Average for fast MA. Defaults to `0` ([SMA]). Can also be passed as talib::SMA. +#' @param slowPeriod ([integer]). Number of period for the slow MA. Defaults to `26`. +#' @param slowMa ([integer]). Type of Moving Average for slow MA. Defaults to `0` ([SMA]). Can also be passed as talib::SMA. +#' @param signalPeriod ([integer]). Smoothing for the signal line (nb of period). Defaults to `9`. +#' @param signalMa ([integer]). Type of Moving Average for signal line. Defaults to `0` ([SMA]). Can also be passed as talib::SMA. #' @template returns extended_moving_average_convergence_divergence <- function( x, diff --git a/R/ta_MACDFIX.R b/R/ta_MACDFIX.R index 43b4f9286..afc5f6006 100644 --- a/R/ta_MACDFIX.R +++ b/R/ta_MACDFIX.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' @param signalPeriod ([integer]). Smoothing for the signal line (nb of period). Defaults to `9`. #' @template returns fixed_moving_average_convergence_divergence <- function( x, diff --git a/R/ta_MAMA.R b/R/ta_MAMA.R index 4a3e58f92..93bf54e3b 100644 --- a/R/ta_MAMA.R +++ b/R/ta_MAMA.R @@ -18,6 +18,8 @@ #' indicators that supports various Moving Average specifications. #' #' @template description +#' @param fastLimit ([double]). Upper limit use in the adaptive algorithm. Defaults to `0.5`. +#' @param slowLimit ([double]). Lower limit use in the adaptive algorithm. Defaults to `0.05`. #' @template returns mesa_adaptive_moving_average <- function( x, diff --git a/R/ta_MAVP.R b/R/ta_MAVP.R index 5d522133c..c5a73ec74 100644 --- a/R/ta_MAVP.R +++ b/R/ta_MAVP.R @@ -12,6 +12,9 @@ ## splice:documentation:end #' #' @template description +#' @param minimumPeriod ([integer]). Value less than minimum will be changed to Minimum period. Defaults to `2`. +#' @param maximumPeriod ([integer]). Value higher than maximum will be changed to Maximum period. Defaults to `30`. +#' @param maType ([integer]). Type of Moving Average. Defaults to `0` ([SMA]). Can also be passed as talib::SMA. #' @template returns MAVP <- function( x, diff --git a/R/ta_MEDPRICE.R b/R/ta_MEDPRICE.R index 501e1c307..d9d2bfe14 100644 --- a/R/ta_MEDPRICE.R +++ b/R/ta_MEDPRICE.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns median_price <- function( x, diff --git a/R/ta_MFI.R b/R/ta_MFI.R index 434cdea89..40d9bf132 100644 --- a/R/ta_MFI.R +++ b/R/ta_MFI.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns money_flow_index <- function( x, diff --git a/R/ta_MIDPOINT.R b/R/ta_MIDPOINT.R index a4c036038..d9ffa2ba3 100644 --- a/R/ta_MIDPOINT.R +++ b/R/ta_MIDPOINT.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns MIDPOINT <- function( x, diff --git a/R/ta_MIDPRICE.R b/R/ta_MIDPRICE.R index 2a90eb7af..feae6d7cd 100644 --- a/R/ta_MIDPRICE.R +++ b/R/ta_MIDPRICE.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns midpoint_price <- function( x, diff --git a/R/ta_MINUS_DI.R b/R/ta_MINUS_DI.R index e57a6e8f7..8af967266 100644 --- a/R/ta_MINUS_DI.R +++ b/R/ta_MINUS_DI.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns minus_directional_indicator <- function( x, diff --git a/R/ta_MINUS_DM.R b/R/ta_MINUS_DM.R index f0cde79db..2fd6a5997 100644 --- a/R/ta_MINUS_DM.R +++ b/R/ta_MINUS_DM.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns minus_directional_movement <- function( x, diff --git a/R/ta_MOM.R b/R/ta_MOM.R index 0534aece0..5ddfeef3e 100644 --- a/R/ta_MOM.R +++ b/R/ta_MOM.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns momentum <- function( x, diff --git a/R/ta_NATR.R b/R/ta_NATR.R index 57e8a1420..f594c997e 100644 --- a/R/ta_NATR.R +++ b/R/ta_NATR.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns normalized_average_true_range <- function( x, diff --git a/R/ta_OBV.R b/R/ta_OBV.R index b7debfc0a..9f95a0b7c 100644 --- a/R/ta_OBV.R +++ b/R/ta_OBV.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns on_balance_volume <- function( x, diff --git a/R/ta_PLUS_DI.R b/R/ta_PLUS_DI.R index 69310bf2c..7a9f0cc0f 100644 --- a/R/ta_PLUS_DI.R +++ b/R/ta_PLUS_DI.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns plus_directional_indicator <- function( x, diff --git a/R/ta_PLUS_DM.R b/R/ta_PLUS_DM.R index e11625493..7f432541e 100644 --- a/R/ta_PLUS_DM.R +++ b/R/ta_PLUS_DM.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns plus_directional_movement <- function( x, diff --git a/R/ta_PPO.R b/R/ta_PPO.R index 13c9fc52d..0a206c074 100644 --- a/R/ta_PPO.R +++ b/R/ta_PPO.R @@ -12,6 +12,9 @@ ## splice:documentation:end #' #' @template description +#' @param fastPeriod ([integer]). Number of period for the fast MA. Defaults to `12`. +#' @param slowPeriod ([integer]). Number of period for the slow MA. Defaults to `26`. +#' @param maType ([integer]). Type of Moving Average. Defaults to `0` ([SMA]). Can also be passed as talib::SMA. #' @template returns percentage_price_oscillator <- function( x, diff --git a/R/ta_RSI.R b/R/ta_RSI.R index 39151f6dd..b32429c4a 100644 --- a/R/ta_RSI.R +++ b/R/ta_RSI.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns relative_strength_index <- function( x, diff --git a/R/ta_SAR.R b/R/ta_SAR.R index 465124901..b2a6b4460 100644 --- a/R/ta_SAR.R +++ b/R/ta_SAR.R @@ -12,6 +12,8 @@ ## splice:documentation:end #' #' @template description +#' @param accelerationFactor ([double]). Acceleration Factor used up to the Maximum value. Defaults to `0.02`. +#' @param afMaximum ([double]). Acceleration Factor Maximum value. Defaults to `0.2`. #' @template returns parabolic_stop_and_reverse <- function( x, diff --git a/R/ta_SAREXT.R b/R/ta_SAREXT.R index 6a137ba54..79e4ccf30 100644 --- a/R/ta_SAREXT.R +++ b/R/ta_SAREXT.R @@ -12,6 +12,14 @@ ## splice:documentation:end #' #' @template description +#' @param startValue ([double]). Start value and direction. 0 for Auto, >0 for Long, <0 for Short. Defaults to `0`. +#' @param offsetOnReverse ([double]). Percent offset added/removed to initial stop on short/long reversal. Defaults to `0`. +#' @param afInitLong ([double]). Acceleration Factor initial value for the Long direction. Defaults to `0.02`. +#' @param afLong ([double]). Acceleration Factor for the Long direction. Defaults to `0.02`. +#' @param afMaxLong ([double]). Acceleration Factor maximum value for the Long direction. Defaults to `0.2`. +#' @param afInitShort ([double]). Acceleration Factor initial value for the Short direction. Defaults to `0.02`. +#' @param afShort ([double]). Acceleration Factor for the Short direction. Defaults to `0.02`. +#' @param afMaxShort ([double]). Acceleration Factor maximum value for the Short direction. Defaults to `0.2`. #' @template returns extended_parabolic_stop_and_reverse <- function( x, diff --git a/R/ta_SMA.R b/R/ta_SMA.R index 57ecbcfc1..89b431bea 100644 --- a/R/ta_SMA.R +++ b/R/ta_SMA.R @@ -18,6 +18,7 @@ #' indicators that supports various Moving Average specifications. #' #' @template description +#' #' @template returns simple_moving_average <- function( x, diff --git a/R/ta_STDDEV.R b/R/ta_STDDEV.R index 838912306..d4f2ba609 100644 --- a/R/ta_STDDEV.R +++ b/R/ta_STDDEV.R @@ -10,6 +10,7 @@ ## splice:documentation:end #' #' @template rolling_description +#' @param deviations ([double]). Number of deviations. Defaults to `1`. #' @template rolling_returns rolling_standard_deviation <- function( x, diff --git a/R/ta_STOCH.R b/R/ta_STOCH.R index 0c9bfd3b5..c23947a06 100644 --- a/R/ta_STOCH.R +++ b/R/ta_STOCH.R @@ -12,6 +12,11 @@ ## splice:documentation:end #' #' @template description +#' @param fastKPeriod ([integer]). Time period for building the Fast-K line. Defaults to `5`. +#' @param slowKPeriod ([integer]). Smoothing for making the Slow-K line. Usually set to 3. Defaults to `3`. +#' @param slowKMa ([integer]). Type of Moving Average for Slow-K. Defaults to `0` ([SMA]). Can also be passed as talib::SMA. +#' @param slowDPeriod ([integer]). Smoothing for making the Slow-D line. Defaults to `3`. +#' @param slowDMa ([integer]). Type of Moving Average for Slow-D. Defaults to `0` ([SMA]). Can also be passed as talib::SMA. #' @template returns stochastic <- function( x, diff --git a/R/ta_STOCHF.R b/R/ta_STOCHF.R index e27d3adac..c375dbad3 100644 --- a/R/ta_STOCHF.R +++ b/R/ta_STOCHF.R @@ -12,6 +12,9 @@ ## splice:documentation:end #' #' @template description +#' @param fastKPeriod ([integer]). Time period for building the Fast-K line. Defaults to `5`. +#' @param fastDPeriod ([integer]). Smoothing for making the Fast-D line. Usually set to 3. Defaults to `3`. +#' @param fastDMa ([integer]). Type of Moving Average for Fast-D. Defaults to `0` ([SMA]). Can also be passed as talib::SMA. #' @template returns fast_stochastic <- function( x, diff --git a/R/ta_STOCHRSI.R b/R/ta_STOCHRSI.R index d25886bef..5b63baba8 100644 --- a/R/ta_STOCHRSI.R +++ b/R/ta_STOCHRSI.R @@ -12,6 +12,9 @@ ## splice:documentation:end #' #' @template description +#' @param fastKPeriod ([integer]). Time period for building the Fast-K line. Defaults to `5`. +#' @param fastDPeriod ([integer]). Smoothing for making the Fast-D line. Usually set to 3. Defaults to `3`. +#' @param fastDMa ([integer]). Type of Moving Average for Fast-D. Defaults to `0` ([SMA]). Can also be passed as talib::SMA. #' @template returns stochastic_relative_strength_index <- function( x, diff --git a/R/ta_T3.R b/R/ta_T3.R index 5ba155506..f3a7d24d3 100644 --- a/R/ta_T3.R +++ b/R/ta_T3.R @@ -18,6 +18,7 @@ #' indicators that supports various Moving Average specifications. #' #' @template description +#' @param volumeFactor ([double]). Volume Factor. Defaults to `0.7`. #' @template returns t3_exponential_moving_average <- function( x, diff --git a/R/ta_TEMA.R b/R/ta_TEMA.R index e5cc430ce..afcc1979d 100644 --- a/R/ta_TEMA.R +++ b/R/ta_TEMA.R @@ -18,6 +18,7 @@ #' indicators that supports various Moving Average specifications. #' #' @template description +#' #' @template returns triple_exponential_moving_average <- function( x, diff --git a/R/ta_TRANGE.R b/R/ta_TRANGE.R index 8d50cde8b..a748605c1 100644 --- a/R/ta_TRANGE.R +++ b/R/ta_TRANGE.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns true_range <- function( x, diff --git a/R/ta_TRIMA.R b/R/ta_TRIMA.R index 0d0eca7ce..1c9134359 100644 --- a/R/ta_TRIMA.R +++ b/R/ta_TRIMA.R @@ -18,6 +18,7 @@ #' indicators that supports various Moving Average specifications. #' #' @template description +#' #' @template returns triangular_moving_average <- function( x, diff --git a/R/ta_TRIX.R b/R/ta_TRIX.R index a6c4a8fca..660e1e29f 100644 --- a/R/ta_TRIX.R +++ b/R/ta_TRIX.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns triple_exponential_average <- function( x, diff --git a/R/ta_TSF.R b/R/ta_TSF.R index 186b3e83f..b9e23abe4 100644 --- a/R/ta_TSF.R +++ b/R/ta_TSF.R @@ -10,6 +10,7 @@ ## splice:documentation:end #' #' @template rolling_description +#' #' @template rolling_returns TSF <- function( x, diff --git a/R/ta_TYPPRICE.R b/R/ta_TYPPRICE.R index f090a98a8..79180f84f 100644 --- a/R/ta_TYPPRICE.R +++ b/R/ta_TYPPRICE.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns typical_price <- function( x, diff --git a/R/ta_ULTOSC.R b/R/ta_ULTOSC.R index 7032ef124..7e2f185ed 100644 --- a/R/ta_ULTOSC.R +++ b/R/ta_ULTOSC.R @@ -12,6 +12,9 @@ ## splice:documentation:end #' #' @template description +#' @param firstPeriod ([integer]). Number of bars for 1st period. Defaults to `7`. +#' @param secondPeriod ([integer]). Number of bars for 2nd period. Defaults to `14`. +#' @param thirdPeriod ([integer]). Number of bars for 3rd period. Defaults to `28`. #' @template returns ultimate_oscillator <- function( x, diff --git a/R/ta_VAR.R b/R/ta_VAR.R index 21ad4d1ab..5415b3941 100644 --- a/R/ta_VAR.R +++ b/R/ta_VAR.R @@ -10,6 +10,7 @@ ## splice:documentation:end #' #' @template rolling_description +#' @param deviations ([double]). Number of deviations. Defaults to `1`. #' @template rolling_returns rolling_variance <- function( x, diff --git a/R/ta_WCLPRICE.R b/R/ta_WCLPRICE.R index a77e712f1..a73b7c7c8 100644 --- a/R/ta_WCLPRICE.R +++ b/R/ta_WCLPRICE.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns weighted_close_price <- function( x, diff --git a/R/ta_WILLR.R b/R/ta_WILLR.R index 11c4759b0..d56282696 100644 --- a/R/ta_WILLR.R +++ b/R/ta_WILLR.R @@ -12,6 +12,7 @@ ## splice:documentation:end #' #' @template description +#' #' @template returns williams_oscillator <- function( x, diff --git a/R/ta_WMA.R b/R/ta_WMA.R index 23da0abf8..2bd84a33a 100644 --- a/R/ta_WMA.R +++ b/R/ta_WMA.R @@ -18,6 +18,7 @@ #' indicators that supports various Moving Average specifications. #' #' @template description +#' #' @template returns weighted_moving_average <- function( x, From 36c51564dae8765361f8f0cc20eada6b491e4a47 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 11:50:45 +0200 Subject: [PATCH 13/37] :books: Updated README in response to (d7a2e979d8948fefd4b0d4338b572e096f9bd891) * Added entry to the README on the emitted the maType documentation for future reference. --- codegen/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/codegen/README.md b/codegen/README.md index 2b8e20dfd..81acb2344 100644 --- a/codegen/README.md +++ b/codegen/README.md @@ -172,6 +172,7 @@ both variants in one file; `render_backend()` renders it once per backend | `${TITLE}` | `` | `Bollinger Bands` | | `${FAMILY}` | `` | `Overlap Studies` | | `${FORMULA}` | Default column formula | `~close` | +| `${PARAM_DOCS}` | `@param` roxygen lines for the optional inputs (`timePeriod`/`penetration` excluded — the man-roxygen templates document those; MAType formals carry the TA_MAType → `[SMA]`…`[T3]` legend) | `#' @param fastPeriod ([integer]). Number of period for the fast MA. Defaults to \`12\`. Can also be passed as talib::SMA().` | | `${ARGS}` | Formals, one per line, trailing comma per entry | `timePeriod = 5,` | | `${PARGS}` | Named forwarding, trailing comma per entry | `timePeriod = timePeriod,` | | `${C_SIGNATURE}` | `.Call()` args: series columns + coerced formals | `constructed_series[[1]],\n as.integer(timePeriod), ...` | From 05444ce6a8e3421c811daaa095af1c649e2c51c8 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 12:04:19 +0200 Subject: [PATCH 14/37] :hammer: Mine instead of * Instead of mining -tags, mining -tags produces more reliable emission of input columns. - All columns are now 1:1 mapped instead of a greedy approach which classifies unmatched columns to 'close' --- R/ta_MAVP.R | 4 ++-- codegen/src/metadata.rs | 12 ++++++++++-- tests/testthat/test-ta_MAVP.R | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/R/ta_MAVP.R b/R/ta_MAVP.R index c5a73ec74..cb1bae2e9 100644 --- a/R/ta_MAVP.R +++ b/R/ta_MAVP.R @@ -6,7 +6,7 @@ #' @templateVar .author Serkan Korkmaz #' @templateVar .fun MAVP #' @templateVar .family Overlap Studies -#' @templateVar .formula ~close +#' @templateVar .formula ~close + periods #' ## splice:documentation:start ## splice:documentation:end @@ -58,7 +58,7 @@ MAVP.default <- function( ## from input constructed_series <- series( x = cols, - default_formula = ~close, + default_formula = ~ close + periods, data = x, ... ) diff --git a/codegen/src/metadata.rs b/codegen/src/metadata.rs index 65d2513fc..7f8523987 100644 --- a/codegen/src/metadata.rs +++ b/codegen/src/metadata.rs @@ -139,10 +139,18 @@ pub fn parse_api(xml: &str) -> Vec { // map to their OHLCV column while plain double arrays // (inReal) default to the 'close' column for arg in tag_blocks(block, "RequiredInputArgument") { - let input_type = tag_text(arg, "Type").expect("input Type"); + let input_type = tag_text(arg, "Name").expect("input Type"); f.input.push(match input_type { - "Open" | "High" | "Low" | "Close" | "Volume" => input_type.to_lowercase(), + "Open" | "High" | "Low" | "Close" | "Volume" => { + input_type.to_lowercase().replace("in", "") + } + "inReal" => "close".to_string(), + "inPeriods" => "periods".to_string(), + // inReal0: x and inReal1: y + // is affiliated with Price Transforms, Statistics Functions and Math Transforms + "inReal0" => "x".to_string(), + "inReal1" => "y".to_string(), _ => "close".to_string(), }); } diff --git a/tests/testthat/test-ta_MAVP.R b/tests/testthat/test-ta_MAVP.R index 15b77dc14..0950c707a 100644 --- a/tests/testthat/test-ta_MAVP.R +++ b/tests/testthat/test-ta_MAVP.R @@ -55,7 +55,7 @@ testthat::test_that(desc = 'Default calls', code = { ), expected = MAVP( BTC, - cols = ~close + cols = ~ close + periods ) ) }) From 826535e63dafa79e8e2b3a4a22476f02be434570 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 13:39:57 +0200 Subject: [PATCH 15/37] :bug:-fix: Bivariate indicators emitted one 'x' * The generated R files based on Transforms with more than one series (See TA_CORREL) were only emitting a single 'x' instead of x,y pair. --- R/ta_BETA.R | 5 ++++ R/ta_CORREL.R | 5 ++++ README.md | 36 +++++++++++++-------------- codegen/src/render.rs | 37 +++++++++++++++++++++++++++- codegen/templates/rolling_template.R | 8 +++--- 5 files changed, 68 insertions(+), 23 deletions(-) diff --git a/R/ta_BETA.R b/R/ta_BETA.R index ff1d70383..ac1c0dd00 100644 --- a/R/ta_BETA.R +++ b/R/ta_BETA.R @@ -14,6 +14,7 @@ #' @template rolling_returns rolling_beta <- function( x, + y, timePeriod = 5, na.bridge = FALSE ) { @@ -33,6 +34,7 @@ BETA <- rolling_beta #' @export rolling_beta.default <- function( x, + y, timePeriod = 5, na.bridge = FALSE ) { @@ -42,6 +44,7 @@ rolling_beta.default <- function( C_impl_ta_BETA, ## splice:call:start as.double(x), + as.double(y), as.integer(timePeriod), ## splice:call:end as.logical(na.bridge) @@ -62,6 +65,7 @@ rolling_beta.default <- function( #' @export rolling_beta.numeric <- function( x, + y, timePeriod = 5, na.bridge = FALSE ) { @@ -69,6 +73,7 @@ rolling_beta.numeric <- function( ## return as data.frame x <- rolling_beta.default( x = x, + y = y, timePeriod = timePeriod, na.bridge = na.bridge ) diff --git a/R/ta_CORREL.R b/R/ta_CORREL.R index 22ff2a692..1fa0d5839 100644 --- a/R/ta_CORREL.R +++ b/R/ta_CORREL.R @@ -14,6 +14,7 @@ #' @template rolling_returns rolling_correlation <- function( x, + y, timePeriod = 30, na.bridge = FALSE ) { @@ -33,6 +34,7 @@ CORREL <- rolling_correlation #' @export rolling_correlation.default <- function( x, + y, timePeriod = 30, na.bridge = FALSE ) { @@ -42,6 +44,7 @@ rolling_correlation.default <- function( C_impl_ta_CORREL, ## splice:call:start as.double(x), + as.double(y), as.integer(timePeriod), ## splice:call:end as.logical(na.bridge) @@ -62,6 +65,7 @@ rolling_correlation.default <- function( #' @export rolling_correlation.numeric <- function( x, + y, timePeriod = 30, na.bridge = FALSE ) { @@ -69,6 +73,7 @@ rolling_correlation.numeric <- function( ## return as data.frame x <- rolling_correlation.default( x = x, + y = y, timePeriod = timePeriod, na.bridge = na.bridge ) diff --git a/README.md b/README.md index e69809f15..49faa21c4 100644 --- a/README.md +++ b/README.md @@ -36,14 +36,14 @@ including 61 candlestick pattern detectors.
-| Need | {talib} | -|:---------------------|:----------------------------------------------------------------------------------------| +| Need | {talib} | +|:---|:---| | Technical indicators | TA-Lib-backed moving averages, momentum, volatility, volume, cycle, and overlap studies | -| Candlestick patterns | Built-in Japanese candlestick pattern recognition | -| OHLCV workflows | Works directly with open, high, low, close, and volume columns | -| Performance | Computation delegated to C routines through `.Call()` | -| Dependencies | Minimal required R dependencies; plotting packages are optional | -| Charts | Composable financial charts with optional `{plotly}` and `{ggplot2}` support | +| Candlestick patterns | Built-in Japanese candlestick pattern recognition | +| OHLCV workflows | Works directly with open, high, low, close, and volume columns | +| Performance | Computation delegated to C routines through `.Call()` | +| Dependencies | Minimal required R dependencies; plotting packages are optional | +| Charts | Composable financial charts with optional `{plotly}` and `{ggplot2}` support |
@@ -101,10 +101,10 @@ features <- cbind( tail(features) #> RSI UpperBand MiddleBand LowerBand CDLENGULFING -#> 2024-12-26 01:00:00 46.48851 100487.38 96698.61 92909.83 -1 +#> 2024-12-26 01:00:00 46.48851 100487.38 96698.61 92909.83 -100 #> 2024-12-27 01:00:00 43.85488 100670.65 96512.96 92355.27 0 #> 2024-12-28 01:00:00 45.93888 100632.13 96581.91 92531.69 0 -#> 2024-12-29 01:00:00 43.12301 99628.77 95576.60 91524.43 -1 +#> 2024-12-29 01:00:00 43.12301 99628.77 95576.60 91524.43 -100 #> 2024-12-30 01:00:00 41.47686 96403.53 94231.31 92059.09 0 #> 2024-12-31 01:00:00 43.37358 95441.13 93774.23 92107.34 0 ``` @@ -173,15 +173,15 @@ compatibility with the broader ecosystem:
-| Category | TA-Lib (C) | {talib} | {talib} alias | -|:----------------------|:---------------------|:----------------------------|:------------------| -| Overlap Studies | `TA_BBANDS()` | `bollinger_bands()` | `BBANDS()` | -| Momentum Indicators | `TA_CCI()` | `commodity_channel_index()` | `CCI()` | -| Volume Indicators | `TA_OBV()` | `on_balance_volume()` | `OBV()` | -| Volatility Indicators | `TA_ATR()` | `average_true_range()` | `ATR()` | -| Price Transform | `TA_AVGPRICE()` | `average_price()` | `AVGPRICE()` | -| Cycle Indicators | `TA_HT_SINE()` | `sine_wave()` | `HT_SINE()` | -| Pattern Recognition | `TA_CDLHANGINGMAN()` | `hanging_man()` | `CDLHANGINGMAN()` | +| Category | TA-Lib (C) | {talib} | {talib} alias | +|:---|:---|:---|:---| +| Overlap Studies | `TA_BBANDS()` | `bollinger_bands()` | `BBANDS()` | +| Momentum Indicators | `TA_CCI()` | `commodity_channel_index()` | `CCI()` | +| Volume Indicators | `TA_OBV()` | `on_balance_volume()` | `OBV()` | +| Volatility Indicators | `TA_ATR()` | `average_true_range()` | `ATR()` | +| Price Transform | `TA_AVGPRICE()` | `average_price()` | `AVGPRICE()` | +| Cycle Indicators | `TA_HT_SINE()` | `sine_wave()` | `HT_SINE()` | +| Pattern Recognition | `TA_CDLHANGINGMAN()` | `hanging_man()` | `CDLHANGINGMAN()` |
diff --git a/codegen/src/render.rs b/codegen/src/render.rs index 540153ae8..15940a972 100644 --- a/codegen/src/render.rs +++ b/codegen/src/render.rs @@ -281,7 +281,32 @@ pub fn render_indicator(f: &MetaData, t: &Templates) -> String { .collect::>() .join(",\n\t\t"); - let c_numeric = std::iter::once("as.double(x)".to_string()) + // the raw-vector series of the numeric/rolling path: the + // bivariate rolling statistics (BETA, CORREL: inReal0/inReal1, + // mined as x/y) take a pair of vectors, everything else a + // single 'x'. ${SERIES}/${PSERIES} render the formals and the + // forwarded arguments, one per line with a trailing comma + let series: &[&str] = if f.input == ["x", "y"] { + &["x", "y"] + } else { + &["x"] + }; + + let series_args = series + .iter() + .map(|s| format!("{s},")) + .collect::>() + .join("\n\t"); + + let pseries = series + .iter() + .map(|s| format!("{s} = {s},")) + .collect::>() + .join("\n\t\t"); + + let c_numeric = series + .iter() + .map(|s| format!("as.double({s})")) .chain(coercions.iter().cloned()) .collect::>() .join(",\n\t\t"); @@ -309,6 +334,8 @@ pub fn render_indicator(f: &MetaData, t: &Templates) -> String { .replace("${C_SIGNATURE_LOOKBACK}", &c_lookback) .replace("${C_SIGNATURE}", &c_signature) .replace("${C_NUMERIC}", &c_numeric) + .replace("${SERIES}", &series_args) + .replace("${PSERIES}", &pseries) .replace("${SPEC_FIELDS}", &spec_fields) .replace("${MA_TYPE}", ma_index.unwrap_or("-1L")) .replace("${CARGS}", &cargs) @@ -731,9 +758,17 @@ tail assert!(stddev.contains("@template rolling_returns")); assert!(stddev.contains("## splice:call:start")); assert!(stddev.contains("as.double(x),")); + assert!(!stddev.contains("as.double(y)")); assert!(!stddev.contains(".plotly")); assert!(!stddev.contains(".ggplot")); + // the bivariate rolling statistics (inReal0/inReal1) take + // the pair x/y and pass both series to the C routine + let correl = render("CORREL"); + assert!(correl.contains("rolling_correlation <- function(\n\tx,\n\ty,")); + assert!(correl.contains("as.double(x),\n\t\tas.double(y),\n\t\tas.integer(timePeriod)")); + assert!(correl.contains("x = x,\n\t\ty = y,")); + // candlesticks: the agnostic flag comes // from AGNOSTIC_PATTERNS assert!(render("CDLDOJI").contains("agnostic = TRUE")); diff --git a/codegen/templates/rolling_template.R b/codegen/templates/rolling_template.R index 95b2d7f9b..469554a99 100644 --- a/codegen/templates/rolling_template.R +++ b/codegen/templates/rolling_template.R @@ -13,7 +13,7 @@ ${PARAM_DOCS} #' @template rolling_returns ${FUN} <- function( - x, + ${SERIES} ${ARGS} na.bridge = FALSE) { UseMethod("${FUN}") @@ -31,7 +31,7 @@ ${ALIAS} <- ${FUN} #' #' @export ${FUN}.default <- function( - x, + ${SERIES} ${ARGS} na.bridge = FALSE) { @@ -59,14 +59,14 @@ ${FUN}.default <- function( #' #' @export ${FUN}.numeric <- function( - x, + ${SERIES} ${ARGS} na.bridge = FALSE) { ## calculate indicator and ## return as data.frame x <- ${FUN}.default( - x = x, + ${PSERIES} ${PARGS} na.bridge = na.bridge ) From fac3fa62239aee67497a425bb3a389720e1cd995 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 13:47:40 +0200 Subject: [PATCH 16/37] :hammer: (Proper) function naming of residual indicators --- R/ta_AVGDEV.R | 34 +++++++++++++++---------------- R/ta_MAVP.R | 30 +++++++++++++-------------- R/ta_MIDPOINT.R | 34 +++++++++++++++---------------- codegen/src/tables.rs | 3 +++ tests/testthat/test-ta_AVGDEV.R | 26 +++++++++++------------ tests/testthat/test-ta_MAVP.R | 24 +++++++++++----------- tests/testthat/test-ta_MIDPOINT.R | 26 +++++++++++------------ 7 files changed, 90 insertions(+), 87 deletions(-) diff --git a/R/ta_AVGDEV.R b/R/ta_AVGDEV.R index c27eb5565..89bd26974 100644 --- a/R/ta_AVGDEV.R +++ b/R/ta_AVGDEV.R @@ -4,7 +4,7 @@ #' @title Average Deviation #' @templateVar .title Average Deviation #' @templateVar .author Serkan Korkmaz -#' @templateVar .fun AVGDEV +#' @templateVar .fun average_deviation #' @templateVar .family Price Transform #' @templateVar .formula ~close #' @@ -14,28 +14,28 @@ #' @template description #' #' @template returns -AVGDEV <- function( +average_deviation <- function( x, cols, timePeriod = 14, na.bridge = FALSE, ... ) { - UseMethod("AVGDEV") + UseMethod("average_deviation") } #' @export #' @usage NULL -#' @rdname AVGDEV +#' @rdname average_deviation #' -#' @aliases AVGDEV -AVGDEV <- AVGDEV +#' @aliases average_deviation +AVGDEV <- average_deviation #' @usage NULL -#' @aliases AVGDEV +#' @aliases average_deviation #' #' @export -AVGDEV.default <- function( +average_deviation.default <- function( x, cols, timePeriod = 14, @@ -78,10 +78,10 @@ AVGDEV.default <- function( } #' @usage NULL -#' @aliases AVGDEV +#' @aliases average_deviation #' #' @export -AVGDEV.data.frame <- function( +average_deviation.data.frame <- function( x, cols, timePeriod = 14, @@ -89,7 +89,7 @@ AVGDEV.data.frame <- function( ... ) { map_dfr( - AVGDEV.default( + average_deviation.default( x = x, cols = cols, timePeriod = timePeriod, @@ -100,17 +100,17 @@ AVGDEV.data.frame <- function( } #' @usage NULL -#' @aliases AVGDEV +#' @aliases average_deviation #' #' @export -AVGDEV.matrix <- function( +average_deviation.matrix <- function( x, cols, timePeriod = 14, na.bridge = FALSE, ... ) { - AVGDEV.default( + average_deviation.default( x = x, cols = cols, timePeriod = timePeriod, @@ -120,7 +120,7 @@ AVGDEV.matrix <- function( } #' @usage NULL -AVGDEV_lookback <- function( +average_deviation_lookback <- function( x, cols, timePeriod = 14, @@ -133,10 +133,10 @@ AVGDEV_lookback <- function( ) } #' @usage NULL -#' @aliases AVGDEV +#' @aliases average_deviation #' #' @export -AVGDEV.numeric <- function( +average_deviation.numeric <- function( x, cols, timePeriod = 14, diff --git a/R/ta_MAVP.R b/R/ta_MAVP.R index cb1bae2e9..81604f4af 100644 --- a/R/ta_MAVP.R +++ b/R/ta_MAVP.R @@ -4,7 +4,7 @@ #' @title Moving average with variable period #' @templateVar .title Moving average with variable period #' @templateVar .author Serkan Korkmaz -#' @templateVar .fun MAVP +#' @templateVar .fun variable_moving_average_period #' @templateVar .family Overlap Studies #' @templateVar .formula ~close + periods #' @@ -16,7 +16,7 @@ #' @param maximumPeriod ([integer]). Value higher than maximum will be changed to Maximum period. Defaults to `30`. #' @param maType ([integer]). Type of Moving Average. Defaults to `0` ([SMA]). Can also be passed as talib::SMA. #' @template returns -MAVP <- function( +variable_moving_average_period <- function( x, cols, minimumPeriod = 2, @@ -25,21 +25,21 @@ MAVP <- function( na.bridge = FALSE, ... ) { - UseMethod("MAVP") + UseMethod("variable_moving_average_period") } #' @export #' @usage NULL -#' @rdname MAVP +#' @rdname variable_moving_average_period #' -#' @aliases MAVP -MAVP <- MAVP +#' @aliases variable_moving_average_period +MAVP <- variable_moving_average_period #' @usage NULL -#' @aliases MAVP +#' @aliases variable_moving_average_period #' #' @export -MAVP.default <- function( +variable_moving_average_period.default <- function( x, cols, minimumPeriod = 2, @@ -87,10 +87,10 @@ MAVP.default <- function( } #' @usage NULL -#' @aliases MAVP +#' @aliases variable_moving_average_period #' #' @export -MAVP.data.frame <- function( +variable_moving_average_period.data.frame <- function( x, cols, minimumPeriod = 2, @@ -100,7 +100,7 @@ MAVP.data.frame <- function( ... ) { map_dfr( - MAVP.default( + variable_moving_average_period.default( x = x, cols = cols, minimumPeriod = minimumPeriod, @@ -113,10 +113,10 @@ MAVP.data.frame <- function( } #' @usage NULL -#' @aliases MAVP +#' @aliases variable_moving_average_period #' #' @export -MAVP.matrix <- function( +variable_moving_average_period.matrix <- function( x, cols, minimumPeriod = 2, @@ -125,7 +125,7 @@ MAVP.matrix <- function( na.bridge = FALSE, ... ) { - MAVP.default( + variable_moving_average_period.default( x = x, cols = cols, minimumPeriod = minimumPeriod, @@ -137,7 +137,7 @@ MAVP.matrix <- function( } #' @usage NULL -MAVP_lookback <- function( +variable_moving_average_period_lookback <- function( x, cols, minimumPeriod = 2, diff --git a/R/ta_MIDPOINT.R b/R/ta_MIDPOINT.R index d9ffa2ba3..34e4c61d6 100644 --- a/R/ta_MIDPOINT.R +++ b/R/ta_MIDPOINT.R @@ -4,7 +4,7 @@ #' @title MidPoint over period #' @templateVar .title MidPoint over period #' @templateVar .author Serkan Korkmaz -#' @templateVar .fun MIDPOINT +#' @templateVar .fun midpoint_period #' @templateVar .family Overlap Studies #' @templateVar .formula ~close #' @@ -14,28 +14,28 @@ #' @template description #' #' @template returns -MIDPOINT <- function( +midpoint_period <- function( x, cols, timePeriod = 14, na.bridge = FALSE, ... ) { - UseMethod("MIDPOINT") + UseMethod("midpoint_period") } #' @export #' @usage NULL -#' @rdname MIDPOINT +#' @rdname midpoint_period #' -#' @aliases MIDPOINT -MIDPOINT <- MIDPOINT +#' @aliases midpoint_period +MIDPOINT <- midpoint_period #' @usage NULL -#' @aliases MIDPOINT +#' @aliases midpoint_period #' #' @export -MIDPOINT.default <- function( +midpoint_period.default <- function( x, cols, timePeriod = 14, @@ -78,10 +78,10 @@ MIDPOINT.default <- function( } #' @usage NULL -#' @aliases MIDPOINT +#' @aliases midpoint_period #' #' @export -MIDPOINT.data.frame <- function( +midpoint_period.data.frame <- function( x, cols, timePeriod = 14, @@ -89,7 +89,7 @@ MIDPOINT.data.frame <- function( ... ) { map_dfr( - MIDPOINT.default( + midpoint_period.default( x = x, cols = cols, timePeriod = timePeriod, @@ -100,17 +100,17 @@ MIDPOINT.data.frame <- function( } #' @usage NULL -#' @aliases MIDPOINT +#' @aliases midpoint_period #' #' @export -MIDPOINT.matrix <- function( +midpoint_period.matrix <- function( x, cols, timePeriod = 14, na.bridge = FALSE, ... ) { - MIDPOINT.default( + midpoint_period.default( x = x, cols = cols, timePeriod = timePeriod, @@ -120,7 +120,7 @@ MIDPOINT.matrix <- function( } #' @usage NULL -MIDPOINT_lookback <- function( +midpoint_period_lookback <- function( x, cols, timePeriod = 14, @@ -133,10 +133,10 @@ MIDPOINT_lookback <- function( ) } #' @usage NULL -#' @aliases MIDPOINT +#' @aliases midpoint_period #' #' @export -MIDPOINT.numeric <- function( +midpoint_period.numeric <- function( x, cols, timePeriod = 14, diff --git a/codegen/src/tables.rs b/codegen/src/tables.rs index 8dd60fcf2..07f06c4a9 100644 --- a/codegen/src/tables.rs +++ b/codegen/src/tables.rs @@ -21,6 +21,7 @@ pub const FUNCTION_NAMES: &[(&str, &str)] = &[ ("AROONOSC", "aroon_oscillator"), ("ATR", "average_true_range"), ("AVGPRICE", "average_price"), + ("AVGDEV", "average_deviation"), ("BBANDS", "bollinger_bands"), ("BETA", "rolling_beta"), ("BOP", "balance_of_power"), @@ -99,6 +100,7 @@ pub const FUNCTION_NAMES: &[(&str, &str)] = &[ ("HT_TRENDMODE", "trend_cycle_mode"), ("IMI", "intraday_movement_index"), ("KAMA", "kaufman_adaptive_moving_average"), + ("MAVP", "variable_moving_average_period"), ("MACD", "moving_average_convergence_divergence"), ("MACDEXT", "extended_moving_average_convergence_divergence"), ("MACDFIX", "fixed_moving_average_convergence_divergence"), @@ -107,6 +109,7 @@ pub const FUNCTION_NAMES: &[(&str, &str)] = &[ ("MEDPRICE", "median_price"), ("MFI", "money_flow_index"), ("MIDPRICE", "midpoint_price"), + ("MIDPOINT", "midpoint_period"), ("MIN", "rolling_min"), ("MINUS_DI", "minus_directional_indicator"), ("MINUS_DM", "minus_directional_movement"), diff --git a/tests/testthat/test-ta_AVGDEV.R b/tests/testthat/test-ta_AVGDEV.R index 1da02754b..983f86e55 100644 --- a/tests/testthat/test-ta_AVGDEV.R +++ b/tests/testthat/test-ta_AVGDEV.R @@ -6,11 +6,11 @@ ## alias and function similarity ## checks this ensures that -## AVGDEV and AVGDEV produces the same results +## average_deviation and AVGDEV produces the same results testthat::test_that(desc = 'Alias and function similarity', code = { ## 1) test that the alias and ## function returns the same values - output <- AVGDEV(SPY) + output <- average_deviation(SPY) alias <- AVGDEV(SPY) ## 1.1) check if the values @@ -29,7 +29,7 @@ testthat::test_that(desc = 'Class in, class out ()', code = { ## 1) check that the output class ## matches the input class testthat::expect_true( - inherits(AVGDEV(SPY), class(SPY)) + inherits(average_deviation(SPY), class(SPY)) ) }) @@ -38,7 +38,7 @@ testthat::test_that(desc = 'Class in, class out ()', code = { ## 1) check that the output class ## matches the input class testthat::expect_true( - inherits(AVGDEV(BTC), class(BTC)) + inherits(average_deviation(BTC), class(BTC)) ) }) @@ -50,10 +50,10 @@ testthat::test_that(desc = 'Class in, class out ()', code = { ## series() function testthat::test_that(desc = 'Default calls', code = { testthat::expect_equal( - object = AVGDEV( + object = average_deviation( BTC ), - expected = AVGDEV( + expected = average_deviation( BTC, cols = ~close ) @@ -66,7 +66,7 @@ testthat::test_that(desc = 'Default calls', code = { ## object testthat::test_that(desc = 'Equal length of input and output for with na.bridge = TRUE', code = { testthat::expect_equal( - object = nrow(AVGDEV( + object = nrow(average_deviation( ATOM, na.bridge = TRUE )), @@ -81,7 +81,7 @@ testthat::test_that(desc = 'Row names are respected for , na.bridge x_names <- row.names(ATOM) ## calculate indicator - indicator <- AVGDEV(ATOM, na.bridge = TRUE) + indicator <- average_deviation(ATOM, na.bridge = TRUE) testthat::expect_equal( object = x_names, @@ -95,7 +95,7 @@ testthat::test_that(desc = 'Row names are respected for , na.bridge ## object testthat::test_that(desc = 'Equal length of input and output for ', code = { testthat::expect_equal( - object = nrow(AVGDEV( + object = nrow(average_deviation( BTC )), expected = nrow(BTC) @@ -109,7 +109,7 @@ testthat::test_that(desc = 'Row names are respected for ', code = { x_names <- row.names(BTC) ## calculate indicator - indicator <- AVGDEV(BTC) + indicator <- average_deviation(BTC) testthat::expect_equal( object = x_names, @@ -120,7 +120,7 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ## object testthat::test_that(desc = 'Equal length of input and output for ', code = { testthat::expect_equal( - object = nrow(AVGDEV( + object = nrow(average_deviation( SPY )), expected = nrow(SPY) @@ -136,7 +136,7 @@ testthat::test_that(desc = 'Row names are respected for ', code = { rownames(SPY) <- paste0("row", 1:nrow(SPY)) ## calculate indicator - indicator <- AVGDEV(SPY) + indicator <- average_deviation(SPY) testthat::expect_equal( object = paste0("row", 1:nrow(SPY)), @@ -150,7 +150,7 @@ testthat::test_that(desc = ' methods', code = { ## check that the method ## runs x <- testthat::expect_no_condition( - AVGDEV(BTC[[1]]) + average_deviation(BTC[[1]]) ) target_length <- length(BTC[[1]]) diff --git a/tests/testthat/test-ta_MAVP.R b/tests/testthat/test-ta_MAVP.R index 0950c707a..61b32b496 100644 --- a/tests/testthat/test-ta_MAVP.R +++ b/tests/testthat/test-ta_MAVP.R @@ -6,11 +6,11 @@ ## alias and function similarity ## checks this ensures that -## MAVP and MAVP produces the same results +## variable_moving_average_period and MAVP produces the same results testthat::test_that(desc = 'Alias and function similarity', code = { ## 1) test that the alias and ## function returns the same values - output <- MAVP(SPY) + output <- variable_moving_average_period(SPY) alias <- MAVP(SPY) ## 1.1) check if the values @@ -29,7 +29,7 @@ testthat::test_that(desc = 'Class in, class out ()', code = { ## 1) check that the output class ## matches the input class testthat::expect_true( - inherits(MAVP(SPY), class(SPY)) + inherits(variable_moving_average_period(SPY), class(SPY)) ) }) @@ -38,7 +38,7 @@ testthat::test_that(desc = 'Class in, class out ()', code = { ## 1) check that the output class ## matches the input class testthat::expect_true( - inherits(MAVP(BTC), class(BTC)) + inherits(variable_moving_average_period(BTC), class(BTC)) ) }) @@ -50,10 +50,10 @@ testthat::test_that(desc = 'Class in, class out ()', code = { ## series() function testthat::test_that(desc = 'Default calls', code = { testthat::expect_equal( - object = MAVP( + object = variable_moving_average_period( BTC ), - expected = MAVP( + expected = variable_moving_average_period( BTC, cols = ~ close + periods ) @@ -66,7 +66,7 @@ testthat::test_that(desc = 'Default calls', code = { ## object testthat::test_that(desc = 'Equal length of input and output for with na.bridge = TRUE', code = { testthat::expect_equal( - object = nrow(MAVP( + object = nrow(variable_moving_average_period( ATOM, na.bridge = TRUE )), @@ -81,7 +81,7 @@ testthat::test_that(desc = 'Row names are respected for , na.bridge x_names <- row.names(ATOM) ## calculate indicator - indicator <- MAVP(ATOM, na.bridge = TRUE) + indicator <- variable_moving_average_period(ATOM, na.bridge = TRUE) testthat::expect_equal( object = x_names, @@ -95,7 +95,7 @@ testthat::test_that(desc = 'Row names are respected for , na.bridge ## object testthat::test_that(desc = 'Equal length of input and output for ', code = { testthat::expect_equal( - object = nrow(MAVP( + object = nrow(variable_moving_average_period( BTC )), expected = nrow(BTC) @@ -109,7 +109,7 @@ testthat::test_that(desc = 'Row names are respected for ', code = { x_names <- row.names(BTC) ## calculate indicator - indicator <- MAVP(BTC) + indicator <- variable_moving_average_period(BTC) testthat::expect_equal( object = x_names, @@ -120,7 +120,7 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ## object testthat::test_that(desc = 'Equal length of input and output for ', code = { testthat::expect_equal( - object = nrow(MAVP( + object = nrow(variable_moving_average_period( SPY )), expected = nrow(SPY) @@ -136,7 +136,7 @@ testthat::test_that(desc = 'Row names are respected for ', code = { rownames(SPY) <- paste0("row", 1:nrow(SPY)) ## calculate indicator - indicator <- MAVP(SPY) + indicator <- variable_moving_average_period(SPY) testthat::expect_equal( object = paste0("row", 1:nrow(SPY)), diff --git a/tests/testthat/test-ta_MIDPOINT.R b/tests/testthat/test-ta_MIDPOINT.R index 3fff2596c..c8c6ba147 100644 --- a/tests/testthat/test-ta_MIDPOINT.R +++ b/tests/testthat/test-ta_MIDPOINT.R @@ -6,11 +6,11 @@ ## alias and function similarity ## checks this ensures that -## MIDPOINT and MIDPOINT produces the same results +## midpoint_period and MIDPOINT produces the same results testthat::test_that(desc = 'Alias and function similarity', code = { ## 1) test that the alias and ## function returns the same values - output <- MIDPOINT(SPY) + output <- midpoint_period(SPY) alias <- MIDPOINT(SPY) ## 1.1) check if the values @@ -29,7 +29,7 @@ testthat::test_that(desc = 'Class in, class out ()', code = { ## 1) check that the output class ## matches the input class testthat::expect_true( - inherits(MIDPOINT(SPY), class(SPY)) + inherits(midpoint_period(SPY), class(SPY)) ) }) @@ -38,7 +38,7 @@ testthat::test_that(desc = 'Class in, class out ()', code = { ## 1) check that the output class ## matches the input class testthat::expect_true( - inherits(MIDPOINT(BTC), class(BTC)) + inherits(midpoint_period(BTC), class(BTC)) ) }) @@ -50,10 +50,10 @@ testthat::test_that(desc = 'Class in, class out ()', code = { ## series() function testthat::test_that(desc = 'Default calls', code = { testthat::expect_equal( - object = MIDPOINT( + object = midpoint_period( BTC ), - expected = MIDPOINT( + expected = midpoint_period( BTC, cols = ~close ) @@ -66,7 +66,7 @@ testthat::test_that(desc = 'Default calls', code = { ## object testthat::test_that(desc = 'Equal length of input and output for with na.bridge = TRUE', code = { testthat::expect_equal( - object = nrow(MIDPOINT( + object = nrow(midpoint_period( ATOM, na.bridge = TRUE )), @@ -81,7 +81,7 @@ testthat::test_that(desc = 'Row names are respected for , na.bridge x_names <- row.names(ATOM) ## calculate indicator - indicator <- MIDPOINT(ATOM, na.bridge = TRUE) + indicator <- midpoint_period(ATOM, na.bridge = TRUE) testthat::expect_equal( object = x_names, @@ -95,7 +95,7 @@ testthat::test_that(desc = 'Row names are respected for , na.bridge ## object testthat::test_that(desc = 'Equal length of input and output for ', code = { testthat::expect_equal( - object = nrow(MIDPOINT( + object = nrow(midpoint_period( BTC )), expected = nrow(BTC) @@ -109,7 +109,7 @@ testthat::test_that(desc = 'Row names are respected for ', code = { x_names <- row.names(BTC) ## calculate indicator - indicator <- MIDPOINT(BTC) + indicator <- midpoint_period(BTC) testthat::expect_equal( object = x_names, @@ -120,7 +120,7 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ## object testthat::test_that(desc = 'Equal length of input and output for ', code = { testthat::expect_equal( - object = nrow(MIDPOINT( + object = nrow(midpoint_period( SPY )), expected = nrow(SPY) @@ -136,7 +136,7 @@ testthat::test_that(desc = 'Row names are respected for ', code = { rownames(SPY) <- paste0("row", 1:nrow(SPY)) ## calculate indicator - indicator <- MIDPOINT(SPY) + indicator <- midpoint_period(SPY) testthat::expect_equal( object = paste0("row", 1:nrow(SPY)), @@ -150,7 +150,7 @@ testthat::test_that(desc = ' methods', code = { ## check that the method ## runs x <- testthat::expect_no_condition( - MIDPOINT(BTC[[1]]) + midpoint_period(BTC[[1]]) ) target_length <- length(BTC[[1]]) From 7750b718a87caca548018323fe362c2e440ae412 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 14:14:22 +0200 Subject: [PATCH 17/37] :hammer: Map maType to characters * The same-ol 0 --> "SMA", 1 --> "EMA" etc. for decorating charts. --- R/utils.R | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/R/utils.R b/R/utils.R index d31333a58..bc5a42f74 100644 --- a/R/utils.R +++ b/R/utils.R @@ -362,3 +362,19 @@ map_dfr.integer <- function(x) { x } + +mapMaType <- function(x) { + switch( + as.character(x + 1), + `1` = "SMA", + `2` = "EMA", + `3` = "WMA", + `4` = "DEMA", + `5` = "TEMA", + `6` = "TRIMA", + `7` = "KAMA", + `8` = "MAMA", + `9` = "T3", + "Unkown" + ) +} From 6e04b567fb082407be9a8c64b77fd0dfda19da5c Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 14:15:45 +0200 Subject: [PATCH 18/37] :hammer: Added charting methods for MAVP * MAVP has its own example to accomodate the additional array of periods needed in the underlying C-signature. --- R/ta_MAVP.R | 165 ++++++++++++++++++++++++++++++++++ codegen/src/tables.rs | 1 + man/examples/MAVP-example.R | 37 ++++++++ tests/testthat/test-ta_MAVP.R | 86 ++++++++++++++++++ 4 files changed, 289 insertions(+) create mode 100644 man/examples/MAVP-example.R diff --git a/R/ta_MAVP.R b/R/ta_MAVP.R index 81604f4af..51eba5671 100644 --- a/R/ta_MAVP.R +++ b/R/ta_MAVP.R @@ -9,6 +9,7 @@ #' @templateVar .formula ~close + periods #' ## splice:documentation:start +#' @example man/examples/MAVP-example.R ## splice:documentation:end #' #' @template description @@ -153,3 +154,167 @@ variable_moving_average_period_lookback <- function( as.integer(maType) ) } +#' @usage NULL +#' @aliases variable_moving_average_period +#' +#' @export +variable_moving_average_period.plotly <- function( + x, + cols, + minimumPeriod = 2, + maximumPeriod = 30, + maType = 0, + na.bridge = FALSE, + ## splice:optional-plotly:start + ## splice:optional-plotly:end + ... +) { + ## check that input value + ## 'x' is -object + assert_plotly_object(x) + + ## check that input value + ## 'cols' is a -objet + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series from + ## {plotly}-object + constructed_series <- series( + x = x, + formula = cols, + default_formula = ~ close + periods, + ... + ) + + ## construct indicator + ## from the series + constructed_indicator <- variable_moving_average_period( + x = constructed_series, + cols = rebuild_formula( + names(constructed_series) + ), + minimumPeriod = minimumPeriod, + maximumPeriod = maximumPeriod, + maType = maType, + na.bridge = TRUE + ) + + ## add conditional idx + constructed_indicator[["idx"]] <- add_idx( + constructed_series + ) + + ## construct {plotly}-object + ## splice:plotly-assembly:start + traces <- lapply( + setdiff(colnames(constructed_indicator), "idx"), + function(col) { + list( + y = stats::as.formula( + paste0("~", col) + ), + name = col + ) + } + ) + name <- sprintf( + "MAVP(%d, %d, %s)", + min(minimumPeriod, maximumPeriod), + max(minimumPeriod, maximumPeriod), + mapMaType(maType) + ) + ## splice:plotly-assembly:end + + state <- .chart_state() + plotly_object <- build_plotly( + init = state[["main"]], + traces = traces, + decorators = list(), + name = get0( + x = "name", + ifnotfound = NULL + ), + data = constructed_indicator + ) + state[["main"]] <- plotly_object + + plotly_object +} + +#' @usage NULL +#' @aliases variable_moving_average_period +#' +#' @export +variable_moving_average_period.ggplot <- function( + x, + cols, + minimumPeriod = 2, + maximumPeriod = 30, + maType = 0, + na.bridge = FALSE, + ## splice:optional-ggplot:start + ## splice:optional-ggplot:end + ... +) { + ## check ggplot2 availability + assert_ggplot2() + + ## check that input value + ## 'cols' is a -objet + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series from + ## {ggplot}-object + constructed_series <- series( + x = x, + formula = cols, + default_formula = ~ close + periods, + ... + ) + + ## construct indicator + ## from the series + constructed_indicator <- variable_moving_average_period( + x = constructed_series, + cols = rebuild_formula( + names(constructed_series) + ), + minimumPeriod = minimumPeriod, + maximumPeriod = maximumPeriod, + maType = maType, + na.bridge = TRUE + ) + + ## add conditional idx + constructed_indicator[["idx"]] <- add_idx( + constructed_series + ) + + ## construct {ggplot2}-object + ## splice:ggplot-assembly:start + layers <- lapply( + setdiff(colnames(constructed_indicator), "idx"), + function(col) list(y = col) + ) + name <- "MAVP" + ## splice:ggplot-assembly:end + + state <- .chart_state() + ggplot_object <- build_ggplot( + init = state[["main"]], + layers = layers, + decorators = list(), + name = get0( + x = "name", + ifnotfound = NULL + ), + data = constructed_indicator + ) + state[["main"]] <- ggplot_object + + ggplot_object +} diff --git a/codegen/src/tables.rs b/codegen/src/tables.rs index 07f06c4a9..f046048dd 100644 --- a/codegen/src/tables.rs +++ b/codegen/src/tables.rs @@ -185,6 +185,7 @@ pub const CHART_TYPES: &[(&str, ChartType)] = &[ ("HT_TRENDLINE", ChartType::Main), ("HT_TRENDMODE", ChartType::Sub), ("IMI", ChartType::Sub), + ("MAVP", ChartType::Main), ("MACD", ChartType::Sub), ("MACDEXT", ChartType::Sub), ("MACDFIX", ChartType::Sub), diff --git a/man/examples/MAVP-example.R b/man/examples/MAVP-example.R new file mode 100644 index 000000000..99b52b831 --- /dev/null +++ b/man/examples/MAVP-example.R @@ -0,0 +1,37 @@ +## load Bitcoin (BTC) +## series +data(BTC, package = "talib") + +## define a random series +## of periods to evaluate +## each candle +BTC$periods <- runif( + n = nrow(BTC), + min = 5, + max = 10 +) + +## calculate the indicator +## for Bitcoin (BTC) +utils::tail( + talib::variable_moving_average_period( + BTC + ) +) + +## visualize the indicator +## with talib::chart() +## +## see ?talib::chart or ?talib::indicator +## for more details +{ + ## chart OHLC-V + ## series with talib::chart() + talib::chart(BTC) + + ## chart indicator + ## with default values + talib::indicator( + talib::variable_moving_average_period + ) +} diff --git a/tests/testthat/test-ta_MAVP.R b/tests/testthat/test-ta_MAVP.R index 61b32b496..c7a7746a1 100644 --- a/tests/testthat/test-ta_MAVP.R +++ b/tests/testthat/test-ta_MAVP.R @@ -143,3 +143,89 @@ testthat::test_that(desc = 'Row names are respected for ', code = { expected = rownames(indicator) ) }) + +## -method checks for +## and +## +## checks +testthat::test_that(desc = '-methods for ', code = { + ## check that variable_moving_average_period can + ## use without any issues + output <- testthat::expect_no_error( + { + chart(BTC) + indicator(variable_moving_average_period) + } + ) + + ## check that the output + ## is a -object + testthat::expect_true( + inherits(output, "plotly") + ) +}) + +## checks +testthat::test_that(desc = '-methods for ', code = { + ## check that variable_moving_average_period can + ## use without any issues + output <- testthat::expect_no_error( + { + chart(SPY) + indicator(variable_moving_average_period) + } + ) + + ## check that the output + ## is a -object + testthat::expect_true( + inherits(output, "plotly") + ) +}) + +## -method checks for +## and +## +## checks +testthat::test_that(desc = '-methods for ', code = { + testthat::skip_if_not_installed("ggplot2") + + ## check that variable_moving_average_period can + ## use without any issues + output <- testthat::expect_no_error( + { + options(talib.chart.backend = "ggplot2") + on.exit(options(talib.chart.backend = "plotly")) + chart(BTC) + indicator(variable_moving_average_period) + } + ) + + ## check that the output + ## is a -object or + testthat::expect_true( + inherits(output, "gg") || inherits(output, "talib_chart") + ) +}) + +## checks +testthat::test_that(desc = '-methods for ', code = { + testthat::skip_if_not_installed("ggplot2") + + ## check that variable_moving_average_period can + ## use without any issues + output <- testthat::expect_no_error( + { + options(talib.chart.backend = "ggplot2") + on.exit(options(talib.chart.backend = "plotly")) + chart(SPY) + indicator(variable_moving_average_period) + } + ) + + ## check that the output + ## is a -object or + testthat::expect_true( + inherits(output, "gg") || inherits(output, "talib_chart") + ) +}) From 3c5418935dd821c511292313a85e92d113477c91 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 14:52:29 +0200 Subject: [PATCH 19/37] :hammer: ma --> maType and n --> timePeriod --- R/ta_VOLUME.R | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/R/ta_VOLUME.R b/R/ta_VOLUME.R index 2ffa45799..5f00e9828 100644 --- a/R/ta_VOLUME.R +++ b/R/ta_VOLUME.R @@ -17,7 +17,7 @@ trading_volume <- function( x, cols, - ma = list(SMA(n = 7), SMA(n = 15)), + maType = list(SMA(timePeriod = 7), SMA(timePeriod = 15)), na.bridge = FALSE, ... ) { @@ -38,7 +38,7 @@ VOLUME <- trading_volume trading_volume.default <- function( x, cols, - ma = list(SMA(n = 7), SMA(n = 15)), + maType = list(SMA(timePeriod = 7), SMA(timePeriod = 15)), na.bridge = FALSE, ... ) { @@ -68,7 +68,7 @@ trading_volume.default <- function( ## splice:call:start as.double(constructed_series[[1]]), lapply( - ma, + maType, function(x) { as.integer( unlist(x, use.names = FALSE) @@ -93,7 +93,7 @@ trading_volume.default <- function( trading_volume.data.frame <- function( x, cols, - ma = list(SMA(n = 7), SMA(n = 15)), + maType = list(SMA(timePeriod = 7), SMA(timePeriod = 15)), na.bridge = FALSE, ... ) { @@ -101,7 +101,7 @@ trading_volume.data.frame <- function( trading_volume.default( x = x, cols = cols, - ma = ma, + maType = maType, na.bridge = na.bridge, ... ) @@ -115,14 +115,14 @@ trading_volume.data.frame <- function( trading_volume.matrix <- function( x, cols, - ma = list(SMA(n = 7), SMA(n = 15)), + maType = list(SMA(timePeriod = 7), SMA(timePeriod = 15)), na.bridge = FALSE, ... ) { trading_volume.default( x = x, cols = cols, - ma = ma, + maType = maType, na.bridge = na.bridge, ... ) @@ -136,7 +136,7 @@ trading_volume.matrix <- function( trading_volume.numeric <- function( x, cols, - ma = list(SMA(n = 7), SMA(n = 15)), + maType = list(SMA(timePeriod = 7), SMA(timePeriod = 15)), na.bridge = FALSE, ... ) { @@ -154,7 +154,7 @@ trading_volume.numeric <- function( C_impl_ta_VOLUME, ## splice:numeric:start as.double(x), - ma, + maType, ## splice:numeric:end as.logical(na.bridge) ) @@ -174,7 +174,7 @@ trading_volume.numeric <- function( trading_volume.plotly <- function( x, cols, - ma = list(SMA(n = 7), SMA(n = 15)), + maType = list(SMA(timePeriod = 7), SMA(timePeriod = 15)), na.bridge = FALSE, ## splice:optional-plotly:start ## splice:optional-plotly:end @@ -207,7 +207,7 @@ trading_volume.plotly <- function( cols = rebuild_formula( names(constructed_series) ), - ma = ma, + maType = maType, na.bridge = TRUE ) @@ -311,7 +311,7 @@ trading_volume.plotly <- function( trading_volume.ggplot <- function( x, cols, - ma = list(SMA(n = 7), SMA(n = 15)), + maType = list(SMA(timePeriod = 7), SMA(timePeriod = 15)), na.bridge = FALSE, ## splice:optional-ggplot:start ## splice:optional-ggplot:end @@ -343,7 +343,7 @@ trading_volume.ggplot <- function( cols = rebuild_formula( names(constructed_series) ), - ma = ma, + maType = maType, na.bridge = TRUE ) @@ -370,7 +370,7 @@ trading_volume.ggplot <- function( list( y = trace_cols[1], geom = "bar", - direction = "direction" + directiotimePeriod = "direction" ) ) if (length(trace_cols) > 1L) { From 105692a0014c7afe2614f0d9669b5badef1f0b92 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 14:53:31 +0200 Subject: [PATCH 20/37] :books: Add periods column to template generation * All output is documented via roxygen2 templates which fails for MAVP due to missing periods column + The addition here avoids messing with the data-raw files. And documentation is generally generated once so its basically zero cost. --- man-roxygen/returns.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man-roxygen/returns.R b/man-roxygen/returns.R index 603b7d9d2..30917c672 100644 --- a/man-roxygen/returns.R +++ b/man-roxygen/returns.R @@ -2,4 +2,4 @@ #' #' An object of same [class] and [length] of `x`: #' -#' `r generate_returns_section(<%= tolower(.fun) %>(talib::BTC))` +#' `r BTC <- talib::BTC; BTC$periods <- runif(nrow(BTC), 10, 20); generate_returns_section(<%= tolower(.fun) %>(BTC))` From beed6f602a12d743e06759c4e49c37039efe16fc Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 14:57:51 +0200 Subject: [PATCH 21/37] :books: Documented maType (ma before) * This commit is related to 107c25bf3f329450666e61f480000deeee29592d where arguments were changed. --- R/ta_VOLUME.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/ta_VOLUME.R b/R/ta_VOLUME.R index 5f00e9828..eb96e7fad 100644 --- a/R/ta_VOLUME.R +++ b/R/ta_VOLUME.R @@ -9,7 +9,7 @@ #' @templateVar .formula ~volume + open + close #' ## splice:documentation:start -#' @param ma A list of MA specifications. +#' @param maType A [list] of maType specifications on the form SMA(timePeriod = 7). ## splice:documentation:end #' #' @template description From e58e9d168e619ef3ac54a2a5174cb00100a8fc22 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 14:58:55 +0200 Subject: [PATCH 22/37] :hammer: [INSERT_WHATEVER_AI_AGENT].md ignored * Its unclear when the CLAUDE.md files were merged into the {talib} repository - but R CMD check have not complained about this before now. --- .Rbuildignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.Rbuildignore b/.Rbuildignore index fcb397c48..8eb10b69e 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -106,3 +106,7 @@ src/ta-lib/Makefile.in ^codegen$ ^CRAN-SUBMISSION$ ^tests/testthat/test-parity.R + +## Claude.md +^src/ta-lib/CLAUDE.md +^src/ta-lib/.claude \ No newline at end of file From 243eeff306e63afd12c74b672e52285993b5496a Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 15:27:58 +0200 Subject: [PATCH 23/37] :hammer: Added charting methods for ta_MIDPRICE/ta_MIDPOINT * This is a barebone implementation without any modifications mainly added to supress the R CMD check errors. - It will be properly implemented in a later iteration. --- R/ta_MIDPOINT.R | 152 ++++++++++++++++++++++++++++++ R/ta_MIDPRICE.R | 151 +++++++++++++++++++++++++++++ codegen/src/tables.rs | 2 + tests/testthat/test-ta_MIDPOINT.R | 86 +++++++++++++++++ tests/testthat/test-ta_MIDPRICE.R | 86 +++++++++++++++++ 5 files changed, 477 insertions(+) diff --git a/R/ta_MIDPOINT.R b/R/ta_MIDPOINT.R index 34e4c61d6..3c4b02314 100644 --- a/R/ta_MIDPOINT.R +++ b/R/ta_MIDPOINT.R @@ -166,3 +166,155 @@ midpoint_period.numeric <- function( x } + +#' @usage NULL +#' @aliases midpoint_period +#' +#' @export +midpoint_period.plotly <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ## splice:optional-plotly:start + ## splice:optional-plotly:end + ... +) { + ## check that input value + ## 'x' is -object + assert_plotly_object(x) + + ## check that input value + ## 'cols' is a -objet + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series from + ## {plotly}-object + constructed_series <- series( + x = x, + formula = cols, + default_formula = ~close, + ... + ) + + ## construct indicator + ## from the series + constructed_indicator <- midpoint_period( + x = constructed_series, + cols = rebuild_formula( + names(constructed_series) + ), + timePeriod = timePeriod, + na.bridge = TRUE + ) + + ## add conditional idx + constructed_indicator[["idx"]] <- add_idx( + constructed_series + ) + + ## construct {plotly}-object + ## splice:plotly-assembly:start + traces <- lapply( + setdiff(colnames(constructed_indicator), "idx"), + function(col) { + list( + y = stats::as.formula( + paste0("~", col) + ), + name = col + ) + } + ) + name <- "MIDPOINT" + ## splice:plotly-assembly:end + + state <- .chart_state() + plotly_object <- build_plotly( + init = state[["main"]], + traces = traces, + decorators = list(), + name = get0( + x = "name", + ifnotfound = NULL + ), + data = constructed_indicator + ) + state[["main"]] <- plotly_object + + plotly_object +} + +#' @usage NULL +#' @aliases midpoint_period +#' +#' @export +midpoint_period.ggplot <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ## splice:optional-ggplot:start + ## splice:optional-ggplot:end + ... +) { + ## check ggplot2 availability + assert_ggplot2() + + ## check that input value + ## 'cols' is a -objet + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series from + ## {ggplot}-object + constructed_series <- series( + x = x, + formula = cols, + default_formula = ~close, + ... + ) + + ## construct indicator + ## from the series + constructed_indicator <- midpoint_period( + x = constructed_series, + cols = rebuild_formula( + names(constructed_series) + ), + timePeriod = timePeriod, + na.bridge = TRUE + ) + + ## add conditional idx + constructed_indicator[["idx"]] <- add_idx( + constructed_series + ) + + ## construct {ggplot2}-object + ## splice:ggplot-assembly:start + layers <- lapply( + setdiff(colnames(constructed_indicator), "idx"), + function(col) list(y = col) + ) + name <- "MIDPOINT" + ## splice:ggplot-assembly:end + + state <- .chart_state() + ggplot_object <- build_ggplot( + init = state[["main"]], + layers = layers, + decorators = list(), + name = get0( + x = "name", + ifnotfound = NULL + ), + data = constructed_indicator + ) + state[["main"]] <- ggplot_object + + ggplot_object +} diff --git a/R/ta_MIDPRICE.R b/R/ta_MIDPRICE.R index feae6d7cd..dd433948c 100644 --- a/R/ta_MIDPRICE.R +++ b/R/ta_MIDPRICE.R @@ -133,3 +133,154 @@ midpoint_price_lookback <- function( as.integer(timePeriod) ) } +#' @usage NULL +#' @aliases midpoint_price +#' +#' @export +midpoint_price.plotly <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ## splice:optional-plotly:start + ## splice:optional-plotly:end + ... +) { + ## check that input value + ## 'x' is -object + assert_plotly_object(x) + + ## check that input value + ## 'cols' is a -objet + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series from + ## {plotly}-object + constructed_series <- series( + x = x, + formula = cols, + default_formula = ~ high + low, + ... + ) + + ## construct indicator + ## from the series + constructed_indicator <- midpoint_price( + x = constructed_series, + cols = rebuild_formula( + names(constructed_series) + ), + timePeriod = timePeriod, + na.bridge = TRUE + ) + + ## add conditional idx + constructed_indicator[["idx"]] <- add_idx( + constructed_series + ) + + ## construct {plotly}-object + ## splice:plotly-assembly:start + traces <- lapply( + setdiff(colnames(constructed_indicator), "idx"), + function(col) { + list( + y = stats::as.formula( + paste0("~", col) + ), + name = col + ) + } + ) + name <- "MIDPRICE" + ## splice:plotly-assembly:end + + state <- .chart_state() + plotly_object <- build_plotly( + init = state[["main"]], + traces = traces, + decorators = list(), + name = get0( + x = "name", + ifnotfound = NULL + ), + data = constructed_indicator + ) + state[["main"]] <- plotly_object + + plotly_object +} + +#' @usage NULL +#' @aliases midpoint_price +#' +#' @export +midpoint_price.ggplot <- function( + x, + cols, + timePeriod = 14, + na.bridge = FALSE, + ## splice:optional-ggplot:start + ## splice:optional-ggplot:end + ... +) { + ## check ggplot2 availability + assert_ggplot2() + + ## check that input value + ## 'cols' is a -objet + if (!missing(cols)) { + assert_formula(cols) + } + + ## construct series from + ## {ggplot}-object + constructed_series <- series( + x = x, + formula = cols, + default_formula = ~ high + low, + ... + ) + + ## construct indicator + ## from the series + constructed_indicator <- midpoint_price( + x = constructed_series, + cols = rebuild_formula( + names(constructed_series) + ), + timePeriod = timePeriod, + na.bridge = TRUE + ) + + ## add conditional idx + constructed_indicator[["idx"]] <- add_idx( + constructed_series + ) + + ## construct {ggplot2}-object + ## splice:ggplot-assembly:start + layers <- lapply( + setdiff(colnames(constructed_indicator), "idx"), + function(col) list(y = col) + ) + name <- "MIDPRICE" + ## splice:ggplot-assembly:end + + state <- .chart_state() + ggplot_object <- build_ggplot( + init = state[["main"]], + layers = layers, + decorators = list(), + name = get0( + x = "name", + ifnotfound = NULL + ), + data = constructed_indicator + ) + state[["main"]] <- ggplot_object + + ggplot_object +} diff --git a/codegen/src/tables.rs b/codegen/src/tables.rs index f046048dd..9cd779268 100644 --- a/codegen/src/tables.rs +++ b/codegen/src/tables.rs @@ -190,6 +190,8 @@ pub const CHART_TYPES: &[(&str, ChartType)] = &[ ("MACDEXT", ChartType::Sub), ("MACDFIX", ChartType::Sub), ("MFI", ChartType::Sub), + ("MIDPOINT", ChartType::Main), + ("MIDPRICE", ChartType::Main), ("MINUS_DI", ChartType::Sub), ("MINUS_DM", ChartType::Sub), ("MOM", ChartType::Sub), diff --git a/tests/testthat/test-ta_MIDPOINT.R b/tests/testthat/test-ta_MIDPOINT.R index c8c6ba147..e650df52f 100644 --- a/tests/testthat/test-ta_MIDPOINT.R +++ b/tests/testthat/test-ta_MIDPOINT.R @@ -144,6 +144,92 @@ testthat::test_that(desc = 'Row names are respected for ', code = { ) }) +## -method checks for +## and +## +## checks +testthat::test_that(desc = '-methods for ', code = { + ## check that midpoint_period can + ## use without any issues + output <- testthat::expect_no_error( + { + chart(BTC) + indicator(midpoint_period) + } + ) + + ## check that the output + ## is a -object + testthat::expect_true( + inherits(output, "plotly") + ) +}) + +## checks +testthat::test_that(desc = '-methods for ', code = { + ## check that midpoint_period can + ## use without any issues + output <- testthat::expect_no_error( + { + chart(SPY) + indicator(midpoint_period) + } + ) + + ## check that the output + ## is a -object + testthat::expect_true( + inherits(output, "plotly") + ) +}) + +## -method checks for +## and +## +## checks +testthat::test_that(desc = '-methods for ', code = { + testthat::skip_if_not_installed("ggplot2") + + ## check that midpoint_period can + ## use without any issues + output <- testthat::expect_no_error( + { + options(talib.chart.backend = "ggplot2") + on.exit(options(talib.chart.backend = "plotly")) + chart(BTC) + indicator(midpoint_period) + } + ) + + ## check that the output + ## is a -object or + testthat::expect_true( + inherits(output, "gg") || inherits(output, "talib_chart") + ) +}) + +## checks +testthat::test_that(desc = '-methods for ', code = { + testthat::skip_if_not_installed("ggplot2") + + ## check that midpoint_period can + ## use without any issues + output <- testthat::expect_no_error( + { + options(talib.chart.backend = "ggplot2") + on.exit(options(talib.chart.backend = "plotly")) + chart(SPY) + indicator(midpoint_period) + } + ) + + ## check that the output + ## is a -object or + testthat::expect_true( + inherits(output, "gg") || inherits(output, "talib_chart") + ) +}) + ## check that methods runs without ## issues and returns proper lengths testthat::test_that(desc = ' methods', code = { diff --git a/tests/testthat/test-ta_MIDPRICE.R b/tests/testthat/test-ta_MIDPRICE.R index 7c78aa970..336da6fe2 100644 --- a/tests/testthat/test-ta_MIDPRICE.R +++ b/tests/testthat/test-ta_MIDPRICE.R @@ -143,3 +143,89 @@ testthat::test_that(desc = 'Row names are respected for ', code = { expected = rownames(indicator) ) }) + +## -method checks for +## and +## +## checks +testthat::test_that(desc = '-methods for ', code = { + ## check that midpoint_price can + ## use without any issues + output <- testthat::expect_no_error( + { + chart(BTC) + indicator(midpoint_price) + } + ) + + ## check that the output + ## is a -object + testthat::expect_true( + inherits(output, "plotly") + ) +}) + +## checks +testthat::test_that(desc = '-methods for ', code = { + ## check that midpoint_price can + ## use without any issues + output <- testthat::expect_no_error( + { + chart(SPY) + indicator(midpoint_price) + } + ) + + ## check that the output + ## is a -object + testthat::expect_true( + inherits(output, "plotly") + ) +}) + +## -method checks for +## and +## +## checks +testthat::test_that(desc = '-methods for ', code = { + testthat::skip_if_not_installed("ggplot2") + + ## check that midpoint_price can + ## use without any issues + output <- testthat::expect_no_error( + { + options(talib.chart.backend = "ggplot2") + on.exit(options(talib.chart.backend = "plotly")) + chart(BTC) + indicator(midpoint_price) + } + ) + + ## check that the output + ## is a -object or + testthat::expect_true( + inherits(output, "gg") || inherits(output, "talib_chart") + ) +}) + +## checks +testthat::test_that(desc = '-methods for ', code = { + testthat::skip_if_not_installed("ggplot2") + + ## check that midpoint_price can + ## use without any issues + output <- testthat::expect_no_error( + { + options(talib.chart.backend = "ggplot2") + on.exit(options(talib.chart.backend = "plotly")) + chart(SPY) + indicator(midpoint_price) + } + ) + + ## check that the output + ## is a -object or + testthat::expect_true( + inherits(output, "gg") || inherits(output, "talib_chart") + ) +}) From 0560e3462a4748a6ae2171aa6e5d250b77a9ba23 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 15:34:21 +0200 Subject: [PATCH 24/37] :wastebasket: Removed maType-tests * They are to be rewritten in a later iteration - too much AI slop and refactoring to do it meaningfully with the current setup. --- tests/testthat/test-moving_average_spec.R | 319 ---------------------- 1 file changed, 319 deletions(-) delete mode 100644 tests/testthat/test-moving_average_spec.R diff --git a/tests/testthat/test-moving_average_spec.R b/tests/testthat/test-moving_average_spec.R deleted file mode 100644 index 3707b873d..000000000 --- a/tests/testthat/test-moving_average_spec.R +++ /dev/null @@ -1,319 +0,0 @@ -## Moving-Average specification mode -## -## When an MA function is called without 'x' it returns a named list -## ("spec") consumed by indicators that support multiple MA types -## (APO, PPO, BBANDS, MACDEXT, STOCH, STOCHF, STOCHRSI). -## -## Hand-written (not generated via codegen/) because the contract is -## cross-cutting across the nine MA functions and would otherwise -## require threading maType through generate_unit-tests.sh. - -## ---- expected spec per MA ------------------------------------------------- -## Each row: function, alias, maType code, default-field values. -## Simple MAs take n only; MAMA takes fast/slow; T3 takes n/vfactor. -.ma_specs <- list( - list( - name = "SMA", - fun = simple_moving_average, - alias = SMA, - maType = 0L, - n = 30L - ), - list( - name = "EMA", - fun = exponential_moving_average, - alias = EMA, - maType = 1L, - n = 30L - ), - list( - name = "WMA", - fun = weighted_moving_average, - alias = WMA, - maType = 2L, - n = 30L - ), - list( - name = "DEMA", - fun = double_exponential_moving_average, - alias = DEMA, - maType = 3L, - n = 30L - ), - list( - name = "TEMA", - fun = triple_exponential_moving_average, - alias = TEMA, - maType = 4L, - n = 30L - ), - list( - name = "TRIMA", - fun = triangular_moving_average, - alias = TRIMA, - maType = 5L, - n = 30L - ), - list( - name = "KAMA", - fun = kaufman_adaptive_moving_average, - alias = KAMA, - maType = 6L, - n = 30L - ) -) - -## ---- shape and default contract (simple n-only MAs) ------------------------ -for (.spec in .ma_specs) { - local({ - spec <- .spec - - testthat::test_that( - sprintf("%s() without x returns list(n, maType)", spec$name), - { - out <- spec$fun() - - testthat::expect_type(out, "list") - testthat::expect_named(out, c("n", "maType")) - testthat::expect_identical(out$maType, spec$maType) - testthat::expect_identical(out$n, spec$n) - } - ) - - testthat::test_that( - sprintf( - "%s() alias returns identical spec to long-form", - spec$name - ), - { - testthat::expect_identical(spec$alias(), spec$fun()) - testthat::expect_identical(spec$alias(n = 7), spec$fun(n = 7)) - } - ) - - testthat::test_that( - sprintf( - "%s() coerces n to integer and honours explicit value", - spec$name - ), - { - ## explicit integer round-trips - testthat::expect_identical(spec$fun(n = 14)$n, 14L) - ## double is truncated to integer (matches as.integer semantics) - testthat::expect_identical(spec$fun(n = 14.7)$n, 14L) - ## storage type is integer even when caller passes double - testthat::expect_identical(typeof(spec$fun(n = 5)$n), "integer") - } - ) - }) -} - -## ---- MAMA (n + fast / slow) ------------------------------------------------ -## MAMA carries 'n' as a spec-only field so downstream consumers -## (BBANDS, STOCH, MACDEXT, ...) can read ma$n uniformly even though -## MAMA's own standalone calculation is adaptive and does not use n. -testthat::test_that("MAMA() without x returns list(n, fast, slow, maType = 7L)", { - out <- mesa_adaptive_moving_average() - - testthat::expect_type(out, "list") - testthat::expect_named(out, c("n", "fast", "slow", "maType")) - testthat::expect_identical(out$maType, 7L) - testthat::expect_identical(out$n, 30L) - testthat::expect_identical(out$fast, 0.5) - testthat::expect_identical(out$slow, 0.05) -}) - -testthat::test_that("MAMA() alias matches long-form and coerces types", { - testthat::expect_identical(MAMA(), mesa_adaptive_moving_average()) - testthat::expect_identical( - MAMA(n = 14, fast = 0.3, slow = 0.1), - mesa_adaptive_moving_average(n = 14, fast = 0.3, slow = 0.1) - ) - - out <- MAMA(n = 14.7, fast = 1L, slow = 0L) - testthat::expect_identical(out$n, 14L) - testthat::expect_identical(typeof(out$n), "integer") - testthat::expect_identical(out$fast, 1) - testthat::expect_identical(out$slow, 0) - testthat::expect_identical(typeof(out$fast), "double") - testthat::expect_identical(typeof(out$slow), "double") -}) - -## 'n' is spec-only: MAMA's standalone output must NOT depend on it. -## Regression guard against someone wiring 'n' into the C call. -testthat::test_that("MAMA(x, n) ignores n in standalone calculation", { - default_out <- mesa_adaptive_moving_average(BTC) - n14_out <- mesa_adaptive_moving_average(BTC, n = 14) - n50_out <- mesa_adaptive_moving_average(BTC, n = 50) - - testthat::expect_equal(default_out, n14_out) - testthat::expect_equal(default_out, n50_out) -}) - -## ---- T3 (n + vfactor) ------------------------------------------------------ -testthat::test_that("T3() without x returns list(n, vfactor, maType = 8L)", { - out <- t3_exponential_moving_average() - - testthat::expect_type(out, "list") - testthat::expect_named(out, c("n", "vfactor", "maType")) - testthat::expect_identical(out$maType, 8L) - testthat::expect_identical(out$n, 5L) - testthat::expect_identical(out$vfactor, 0.7) -}) - -testthat::test_that("T3() alias matches long-form and coerces types", { - testthat::expect_identical(T3(), t3_exponential_moving_average()) - testthat::expect_identical( - T3(n = 10, vfactor = 0.5), - t3_exponential_moving_average(n = 10, vfactor = 0.5) - ) - - out <- T3(n = 9.9, vfactor = 1L) - testthat::expect_identical(out$n, 9L) - testthat::expect_identical(out$vfactor, 1) - testthat::expect_identical(typeof(out$n), "integer") - testthat::expect_identical(typeof(out$vfactor), "double") -}) - -## ---- downstream integration ------------------------------------------------ -## Every MA spec carries 'n' + 'maType' and must drive every consumer: -## APO / PPO (read maType only) and -## BBANDS / stochastic / STOCHF / STOCHRSI / MACDEXT (read both n and maType). - -.all_specs <- list( - SMA = SMA, - EMA = EMA, - WMA = WMA, - DEMA = DEMA, - TEMA = TEMA, - TRIMA = TRIMA, - KAMA = KAMA, - MAMA = MAMA, - T3 = T3 -) - -for (.nm in names(.all_specs)) { - local({ - nm <- .nm - mk <- .all_specs[[nm]] - - testthat::test_that( - sprintf("APO() accepts %s() spec", nm), - { - out <- absolute_price_oscillator(BTC, ma = mk()) - testthat::expect_s3_class(out, "data.frame") - testthat::expect_equal(nrow(out), nrow(BTC)) - testthat::expect_true(any(is.finite(out[[1]]))) - } - ) - - testthat::test_that( - sprintf("PPO() accepts %s() spec", nm), - { - out <- percentage_price_oscillator(BTC, ma = mk()) - testthat::expect_s3_class(out, "data.frame") - testthat::expect_equal(nrow(out), nrow(BTC)) - testthat::expect_true(any(is.finite(out[[1]]))) - } - ) - - testthat::test_that( - sprintf("BBANDS() accepts %s() spec with explicit n", nm), - { - out <- bollinger_bands(BTC, ma = mk(n = 10)) - testthat::expect_s3_class(out, "data.frame") - testthat::expect_equal(nrow(out), nrow(BTC)) - testthat::expect_true(any(is.finite(out[[1]]))) - } - ) - - testthat::test_that( - sprintf("stochastic() accepts %s() spec for slowk/slowd", nm), - { - out <- stochastic(BTC, slowk = mk(n = 3), slowd = mk(n = 3)) - testthat::expect_s3_class(out, "data.frame") - testthat::expect_equal(nrow(out), nrow(BTC)) - testthat::expect_true(any(is.finite(out[[1]]))) - } - ) - - testthat::test_that( - sprintf("STOCHF() accepts %s() spec for fastd", nm), - { - out <- STOCHF(BTC, fastd = mk(n = 3)) - testthat::expect_s3_class(out, "data.frame") - testthat::expect_equal(nrow(out), nrow(BTC)) - testthat::expect_true(any(is.finite(out[[1]]))) - } - ) - - testthat::test_that( - sprintf("STOCHRSI() accepts %s() spec for fastd", nm), - { - out <- STOCHRSI(BTC, fastd = mk(n = 3)) - testthat::expect_s3_class(out, "data.frame") - testthat::expect_equal(nrow(out), nrow(BTC)) - testthat::expect_true(any(is.finite(out[[1]]))) - } - ) - - testthat::test_that( - sprintf("MACDEXT() accepts %s() spec for fast/slow/signal", nm), - { - out <- extended_moving_average_convergence_divergence( - BTC, - fast = mk(n = 5), - slow = mk(n = 10), - signal = mk(n = 3) - ) - testthat::expect_s3_class(out, "data.frame") - testthat::expect_equal(nrow(out), nrow(BTC)) - testthat::expect_true(any(is.finite(out[[1]]))) - } - ) - }) -} - -## ---- maType drives the consumer's output ----------------------------------- -## Swap EMA for SMA in APO: output must differ. Protects against consumers -## silently ignoring the spec (the bug shape that shape tests alone miss). -testthat::test_that("APO output depends on the MA spec (EMA != SMA)", { - out_sma <- absolute_price_oscillator(BTC, ma = SMA(n = 9)) - out_ema <- absolute_price_oscillator(BTC, ma = EMA(n = 9)) - - testthat::expect_equal(dim(out_sma), dim(out_ema)) - ## require an actual numerical difference somewhere in the overlap - testthat::expect_false( - isTRUE(all.equal(out_sma[[1]], out_ema[[1]])) - ) -}) - -testthat::test_that("BBANDS output depends on the MA spec (WMA != SMA)", { - out_sma <- bollinger_bands(BTC, ma = SMA(n = 10)) - out_wma <- bollinger_bands(BTC, ma = WMA(n = 10)) - - testthat::expect_equal(dim(out_sma), dim(out_wma)) - testthat::expect_false( - isTRUE(all.equal(out_sma[[1]], out_wma[[1]])) - ) -}) - -## 'n' must drive the consumer's window. If a future change drops ma$n -## lookup in favour of a hard-coded default, these tests catch it. -testthat::test_that("BBANDS consumes ma$n (different n => different output)", { - out_10 <- bollinger_bands(BTC, ma = SMA(n = 10)) - out_30 <- bollinger_bands(BTC, ma = SMA(n = 30)) - - testthat::expect_false( - isTRUE(all.equal(out_10[[1]], out_30[[1]])) - ) -}) - -testthat::test_that("stochastic() consumes slowk$n (different n => different output)", { - out_3 <- stochastic(BTC, slowk = SMA(n = 3), slowd = SMA(n = 3)) - out_7 <- stochastic(BTC, slowk = SMA(n = 7), slowd = SMA(n = 7)) - - testthat::expect_false( - isTRUE(all.equal(out_3[[1]], out_7[[1]])) - ) -}) From df37984f24b7de89e1efd24e106c570b409c8812 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 16:04:02 +0200 Subject: [PATCH 25/37] :wastebasket: Remove TSF * This is a Time Series Forecasting function. I have not studied the source code as per this commit - but as with the remaining regression related functions, I believe that R has a better available suite for this but I am open to include this (or similar functions) if there is demand for it. --- R/ta_TSF.R | 83 ------------------------------------ codegen/src/tables.rs | 1 + tests/testthat/test-ta_TSF.R | 45 ------------------- 3 files changed, 1 insertion(+), 128 deletions(-) delete mode 100644 R/ta_TSF.R delete mode 100644 tests/testthat/test-ta_TSF.R diff --git a/R/ta_TSF.R b/R/ta_TSF.R deleted file mode 100644 index b9e23abe4..000000000 --- a/R/ta_TSF.R +++ /dev/null @@ -1,83 +0,0 @@ -#' @export -#' @family Statistic Functions -#' -#' @title Time Series Forecast -#' @templateVar .title Time Series Forecast -#' @templateVar .author Serkan Korkmaz -#' @templateVar .fun TSF -#' -## splice:documentation:start -## splice:documentation:end -#' -#' @template rolling_description -#' -#' @template rolling_returns -TSF <- function( - x, - timePeriod = 14, - na.bridge = FALSE -) { - UseMethod("TSF") -} - -#' @export -#' @usage NULL -#' @rdname TSF -#' -#' @aliases TSF -TSF <- TSF - -#' @usage NULL -#' @aliases TSF -#' -#' @export -TSF.default <- function( - x, - timePeriod = 14, - na.bridge = FALSE -) { - ## calculate indicator and - ## return as data.frame - x <- .Call( - C_impl_ta_TSF, - ## splice:call:start - as.double(x), - as.integer(timePeriod), - ## splice:call:end - as.logical(na.bridge) - ) - - ## strip dimensions - ## while preserving - ## attributes - dim(x) <- NULL - - ## return indicator - x -} - -#' @usage NULL -#' @aliases TSF -#' -#' @export -TSF.numeric <- function( - x, - timePeriod = 14, - na.bridge = FALSE -) { - ## calculate indicator and - ## return as data.frame - x <- TSF.default( - x = x, - timePeriod = timePeriod, - na.bridge = na.bridge - ) - - ## strip dimensions - ## while preserving - ## attributes - dim(x) <- NULL - - ## return indicator - x -} diff --git a/codegen/src/tables.rs b/codegen/src/tables.rs index 9cd779268..80b74860a 100644 --- a/codegen/src/tables.rs +++ b/codegen/src/tables.rs @@ -291,6 +291,7 @@ pub const EXCLUDED_INDICATORS: &[&str] = &[ "LINEARREG_ANGLE", "LINEARREG_SLOPE", "LINEARREG_INTERCEPT", + "TSF", ]; /// GroupIds excluded from generation altogether; diff --git a/tests/testthat/test-ta_TSF.R b/tests/testthat/test-ta_TSF.R deleted file mode 100644 index a15ae6fe9..000000000 --- a/tests/testthat/test-ta_TSF.R +++ /dev/null @@ -1,45 +0,0 @@ -## autogenerated unit-test -## from codegen/ -## the file will be overwritten in the next iteration -## -## author: Serkan Korkmaz - -## test that the function runs without -## any conditions -testthat::test_that(desc = 'Runs without *any* conditions', code = { - output <- testthat::expect_no_condition( - { - TSF( - x = SPY[, 1] - ) - } - ) -}) - -## test that the length of the input -## matches the output -testthat::test_that(desc = 'Length in, length out', code = { - testthat::expect_equal( - object = length( - TSF( - x = SPY[, 1] - ) - ), - expected = length(SPY[, 1]) - ) -}) - -## test that the output is a vector -testthat::test_that(desc = 'Output type', code = { - output <- TSF( - x = SPY[, 1] - ) - - testthat::expect_true( - typeof(output) == "double" || typeof(output) == "integer" - ) - - testthat::expect_true( - is.null(dim(output)) - ) -}) From da875ea357ca114c0a735b1a87bed4475af054f6 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 16:05:36 +0200 Subject: [PATCH 26/37] :books: Updated NAMESPACE --- NAMESPACE | 54 ++++++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 90d8b5b0d..e5670ba52 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,8 @@ S3method("$",chart_theme) S3method(.DollarNames,chart_theme) +S3method(TSF,default) +S3method(TSF,numeric) S3method(abandoned_baby,data.frame) S3method(abandoned_baby,default) S3method(abandoned_baby,ggplot) @@ -33,6 +35,10 @@ S3method(aroon_oscillator,default) S3method(aroon_oscillator,ggplot) S3method(aroon_oscillator,matrix) S3method(aroon_oscillator,plotly) +S3method(average_deviation,data.frame) +S3method(average_deviation,default) +S3method(average_deviation,matrix) +S3method(average_deviation,numeric) S3method(average_directional_movement_index,data.frame) S3method(average_directional_movement_index,default) S3method(average_directional_movement_index,ggplot) @@ -322,9 +328,17 @@ S3method(mesa_adaptive_moving_average,ggplot) S3method(mesa_adaptive_moving_average,matrix) S3method(mesa_adaptive_moving_average,numeric) S3method(mesa_adaptive_moving_average,plotly) +S3method(midpoint_period,data.frame) +S3method(midpoint_period,default) +S3method(midpoint_period,ggplot) +S3method(midpoint_period,matrix) +S3method(midpoint_period,numeric) +S3method(midpoint_period,plotly) S3method(midpoint_price,data.frame) S3method(midpoint_price,default) +S3method(midpoint_price,ggplot) S3method(midpoint_price,matrix) +S3method(midpoint_price,plotly) S3method(minus_directional_indicator,data.frame) S3method(minus_directional_indicator,default) S3method(minus_directional_indicator,ggplot) @@ -411,18 +425,6 @@ S3method(plus_directional_movement,matrix) S3method(plus_directional_movement,plotly) S3method(print,talib_chart) S3method(print,talib_gg_chart) -S3method(rate_of_change,data.frame) -S3method(rate_of_change,default) -S3method(rate_of_change,ggplot) -S3method(rate_of_change,matrix) -S3method(rate_of_change,numeric) -S3method(rate_of_change,plotly) -S3method(ratio_of_change,data.frame) -S3method(ratio_of_change,default) -S3method(ratio_of_change,ggplot) -S3method(ratio_of_change,matrix) -S3method(ratio_of_change,numeric) -S3method(ratio_of_change,plotly) S3method(relative_strength_index,data.frame) S3method(relative_strength_index,default) S3method(relative_strength_index,ggplot) @@ -443,14 +445,8 @@ S3method(rolling_beta,default) S3method(rolling_beta,numeric) S3method(rolling_correlation,default) S3method(rolling_correlation,numeric) -S3method(rolling_max,default) -S3method(rolling_max,numeric) -S3method(rolling_min,default) -S3method(rolling_min,numeric) S3method(rolling_standard_deviation,default) S3method(rolling_standard_deviation,numeric) -S3method(rolling_sum,default) -S3method(rolling_sum,numeric) S3method(rolling_variance,default) S3method(rolling_variance,numeric) S3method(separating_lines,data.frame) @@ -636,6 +632,11 @@ S3method(upside_gap_2_crows,default) S3method(upside_gap_2_crows,ggplot) S3method(upside_gap_2_crows,matrix) S3method(upside_gap_2_crows,plotly) +S3method(variable_moving_average_period,data.frame) +S3method(variable_moving_average_period,default) +S3method(variable_moving_average_period,ggplot) +S3method(variable_moving_average_period,matrix) +S3method(variable_moving_average_period,plotly) S3method(weighted_close_price,data.frame) S3method(weighted_close_price,default) S3method(weighted_close_price,matrix) @@ -664,6 +665,7 @@ export(APO) export(AROON) export(AROONOSC) export(ATR) +export(AVGDEV) export(AVGPRICE) export(BBANDS) export(BETA) @@ -747,11 +749,11 @@ export(MACD) export(MACDEXT) export(MACDFIX) export(MAMA) -export(MAX) +export(MAVP) export(MEDPRICE) export(MFI) +export(MIDPOINT) export(MIDPRICE) -export(MIN) export(MINUS_DI) export(MINUS_DM) export(MOM) @@ -760,8 +762,6 @@ export(OBV) export(PLUS_DI) export(PLUS_DM) export(PPO) -export(ROC) -export(ROCR) export(RSI) export(SAR) export(SAREXT) @@ -770,12 +770,12 @@ export(STDDEV) export(STOCH) export(STOCHF) export(STOCHRSI) -export(SUM) export(T3) export(TEMA) export(TRANGE) export(TRIMA) export(TRIX) +export(TSF) export(TYPPRICE) export(ULTOSC) export(VAR) @@ -789,6 +789,7 @@ export(acceleration_bands) export(advance_block) export(aroon) export(aroon_oscillator) +export(average_deviation) export(average_directional_movement_index) export(average_directional_movement_index_rating) export(average_price) @@ -847,6 +848,7 @@ export(mat_hold) export(matching_low) export(median_price) export(mesa_adaptive_moving_average) +export(midpoint_period) export(midpoint_price) export(minus_directional_indicator) export(minus_directional_movement) @@ -864,17 +866,12 @@ export(phasor_components) export(piercing) export(plus_directional_indicator) export(plus_directional_movement) -export(rate_of_change) -export(ratio_of_change) export(relative_strength_index) export(rickshaw_man) export(rise_fall_3_methods) export(rolling_beta) export(rolling_correlation) -export(rolling_max) -export(rolling_min) export(rolling_standard_deviation) -export(rolling_sum) export(rolling_variance) export(separating_lines) export(set_theme) @@ -911,6 +908,7 @@ export(typical_price) export(ultimate_oscillator) export(unique_3_river) export(upside_gap_2_crows) +export(variable_moving_average_period) export(weighted_close_price) export(weighted_moving_average) export(williams_oscillator) From 1c5892d23ed2b5fa84cc93c2911fd799ccb06c00 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 16:06:23 +0200 Subject: [PATCH 27/37] =?UTF-8?q?=F0=9F=97=91=20Remove=20TSF=20(C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * This is a Time Series Forecasting function. I have not studied the source code as per this commit - but as with the remaining regression related functions, I believe that R has a better available suite for this but I am open to include this (or similar functions) if there is demand for it. --- src/TA-Lib.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/TA-Lib.h b/src/TA-Lib.h index 3e5fb4138..33b0c6acc 100644 --- a/src/TA-Lib.h +++ b/src/TA-Lib.h @@ -128,7 +128,6 @@ TA_INDICATOR(TEMA, TA_DOUBLE, TA_INPUT(inReal), TA_OPTIONS(OPTIONAL_INTEGER(optI 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) @@ -256,7 +255,6 @@ 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))) From 246d6a2bcede2ac2ba273e815b37d4a326f9675e Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 19:34:54 +0200 Subject: [PATCH 28/37] :hammer: Small maType-helper in S3 * The function helps mapping maTypes back and forth to TA_MA()-functions, and map the types to characters for charting. --- R/utils.R | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/R/utils.R b/R/utils.R index bc5a42f74..4496f9952 100644 --- a/R/utils.R +++ b/R/utils.R @@ -378,3 +378,23 @@ mapMaType <- function(x) { "Unkown" ) } + +## maType +## +## Description: +## A small S3 that helps mapping +## maTypes to and +## +#'@export +as.maType <- function(x, ...) { + UseMethod("as.maType") +} + +## +as.maType.maType <- function(x, ...) { + as.integer(x$maType) +} + +as.maType.double <- as.maType.integer <- function(x, ...) { + as.integer(x) +} From 891db5bc85fdccda39470f209894352010a7569a Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 19:36:33 +0200 Subject: [PATCH 29/37] :hammer: Added as.maType for maType args * All MA functions returns a maType-class list if x is missing - this functionality has always been in {talib} but without the explicit classes and dispatches. With the current changes so far, the S3 serves a rather crucial role in translating the maType-list back and forth from C and the charts. It was mainly implemented to fix ta_VOLUME which would crash due to the C-side extracting the first argument of the list that was coerced to a integer vector. * With this new S3 helper charting and new functions should become easier - this is what we call positive externality in economics. --- R/ta_APO.R | 6 +++--- R/ta_BBANDS.R | 6 +++--- R/ta_DEMA.R | 3 ++- R/ta_EMA.R | 3 ++- R/ta_KAMA.R | 3 ++- R/ta_MACDEXT.R | 18 +++++++++--------- R/ta_MAMA.R | 3 ++- R/ta_MAVP.R | 4 ++-- R/ta_PPO.R | 6 +++--- R/ta_SMA.R | 3 ++- R/ta_STOCH.R | 8 ++++---- R/ta_STOCHF.R | 4 ++-- R/ta_STOCHRSI.R | 6 +++--- R/ta_T3.R | 3 ++- R/ta_TEMA.R | 3 ++- R/ta_TRIMA.R | 3 ++- R/ta_VOLUME.R | 2 +- R/ta_WMA.R | 3 ++- codegen/src/render.rs | 3 ++- codegen/templates/moving_average_template.R | 3 ++- 20 files changed, 52 insertions(+), 41 deletions(-) diff --git a/R/ta_APO.R b/R/ta_APO.R index 4988cc132..bc252c042 100644 --- a/R/ta_APO.R +++ b/R/ta_APO.R @@ -74,7 +74,7 @@ absolute_price_oscillator.default <- function( constructed_series[[1]], as.integer(fastPeriod), as.integer(slowPeriod), - as.integer(maType), + as.maType(maType), as.logical(na.bridge) ) @@ -149,7 +149,7 @@ absolute_price_oscillator_lookback <- function( C_impl_ta_APO_lookback, as.integer(fastPeriod), as.integer(slowPeriod), - as.integer(maType) + as.maType(maType) ) } #' @usage NULL @@ -180,7 +180,7 @@ absolute_price_oscillator.numeric <- function( as.double(x), as.integer(fastPeriod), as.integer(slowPeriod), - as.integer(maType), + as.maType(maType), as.logical(na.bridge) ) diff --git a/R/ta_BBANDS.R b/R/ta_BBANDS.R index 481913752..7111e0c0c 100644 --- a/R/ta_BBANDS.R +++ b/R/ta_BBANDS.R @@ -77,7 +77,7 @@ bollinger_bands.default <- function( as.integer(timePeriod), as.double(deviationsUp), as.double(deviationsDown), - as.integer(maType), + as.maType(maType), as.logical(na.bridge) ) @@ -158,7 +158,7 @@ bollinger_bands_lookback <- function( as.integer(timePeriod), as.double(deviationsUp), as.double(deviationsDown), - as.integer(maType) + as.maType(maType) ) } #' @usage NULL @@ -191,7 +191,7 @@ bollinger_bands.numeric <- function( as.integer(timePeriod), as.double(deviationsUp), as.double(deviationsDown), - as.integer(maType), + as.maType(maType), as.logical(na.bridge) ) diff --git a/R/ta_DEMA.R b/R/ta_DEMA.R index eeacbe045..099697d1c 100644 --- a/R/ta_DEMA.R +++ b/R/ta_DEMA.R @@ -40,7 +40,8 @@ double_exponential_moving_average <- function( as.integer(timePeriod) }, maType = 3L - ) + ), + class = "maType" ) return(x) diff --git a/R/ta_EMA.R b/R/ta_EMA.R index f141e750e..3d636e3bb 100644 --- a/R/ta_EMA.R +++ b/R/ta_EMA.R @@ -40,7 +40,8 @@ exponential_moving_average <- function( as.integer(timePeriod) }, maType = 1L - ) + ), + class = "maType" ) return(x) diff --git a/R/ta_KAMA.R b/R/ta_KAMA.R index 6f6ba7f0f..fbbcff867 100644 --- a/R/ta_KAMA.R +++ b/R/ta_KAMA.R @@ -40,7 +40,8 @@ kaufman_adaptive_moving_average <- function( as.integer(timePeriod) }, maType = 6L - ) + ), + class = "maType" ) return(x) diff --git a/R/ta_MACDEXT.R b/R/ta_MACDEXT.R index 21ca82a71..4f9dce300 100644 --- a/R/ta_MACDEXT.R +++ b/R/ta_MACDEXT.R @@ -82,11 +82,11 @@ extended_moving_average_convergence_divergence.default <- function( C_impl_ta_MACDEXT, constructed_series[[1]], as.integer(fastPeriod), - as.integer(fastMa), + as.maType(fastMa), as.integer(slowPeriod), - as.integer(slowMa), + as.maType(slowMa), as.integer(signalPeriod), - as.integer(signalMa), + as.maType(signalMa), as.logical(na.bridge) ) @@ -175,11 +175,11 @@ extended_moving_average_convergence_divergence_lookback <- function( .Call( C_impl_ta_MACDEXT_lookback, as.integer(fastPeriod), - as.integer(fastMa), + as.maType(fastMa), as.integer(slowPeriod), - as.integer(slowMa), + as.maType(slowMa), as.integer(signalPeriod), - as.integer(signalMa) + as.maType(signalMa) ) } #' @usage NULL @@ -212,11 +212,11 @@ extended_moving_average_convergence_divergence.numeric <- function( C_impl_ta_MACDEXT, as.double(x), as.integer(fastPeriod), - as.integer(fastMa), + as.maType(fastMa), as.integer(slowPeriod), - as.integer(slowMa), + as.maType(slowMa), as.integer(signalPeriod), - as.integer(signalMa), + as.maType(signalMa), as.logical(na.bridge) ) diff --git a/R/ta_MAMA.R b/R/ta_MAMA.R index 93bf54e3b..bac49954b 100644 --- a/R/ta_MAMA.R +++ b/R/ta_MAMA.R @@ -53,7 +53,8 @@ mesa_adaptive_moving_average <- function( as.double(slowLimit) }, maType = 7L - ) + ), + class = "maType" ) return(x) diff --git a/R/ta_MAVP.R b/R/ta_MAVP.R index 51eba5671..726cb44d9 100644 --- a/R/ta_MAVP.R +++ b/R/ta_MAVP.R @@ -76,7 +76,7 @@ variable_moving_average_period.default <- function( constructed_series[[2]], as.integer(minimumPeriod), as.integer(maximumPeriod), - as.integer(maType), + as.maType(maType), as.logical(na.bridge) ) @@ -151,7 +151,7 @@ variable_moving_average_period_lookback <- function( C_impl_ta_MAVP_lookback, as.integer(minimumPeriod), as.integer(maximumPeriod), - as.integer(maType) + as.maType(maType) ) } #' @usage NULL diff --git a/R/ta_PPO.R b/R/ta_PPO.R index 0a206c074..d2b90190f 100644 --- a/R/ta_PPO.R +++ b/R/ta_PPO.R @@ -74,7 +74,7 @@ percentage_price_oscillator.default <- function( constructed_series[[1]], as.integer(fastPeriod), as.integer(slowPeriod), - as.integer(maType), + as.maType(maType), as.logical(na.bridge) ) @@ -149,7 +149,7 @@ percentage_price_oscillator_lookback <- function( C_impl_ta_PPO_lookback, as.integer(fastPeriod), as.integer(slowPeriod), - as.integer(maType) + as.maType(maType) ) } #' @usage NULL @@ -180,7 +180,7 @@ percentage_price_oscillator.numeric <- function( as.double(x), as.integer(fastPeriod), as.integer(slowPeriod), - as.integer(maType), + as.maType(maType), as.logical(na.bridge) ) diff --git a/R/ta_SMA.R b/R/ta_SMA.R index 89b431bea..854894288 100644 --- a/R/ta_SMA.R +++ b/R/ta_SMA.R @@ -40,7 +40,8 @@ simple_moving_average <- function( as.integer(timePeriod) }, maType = 0L - ) + ), + class = "maType" ) return(x) diff --git a/R/ta_STOCH.R b/R/ta_STOCH.R index c23947a06..ca23a996f 100644 --- a/R/ta_STOCH.R +++ b/R/ta_STOCH.R @@ -82,9 +82,9 @@ stochastic.default <- function( constructed_series[[3]], as.integer(fastKPeriod), as.integer(slowKPeriod), - as.integer(slowKMa), + as.maType(slowKMa), as.integer(slowDPeriod), - as.integer(slowDMa), + as.maType(slowDMa), as.logical(na.bridge) ) @@ -169,9 +169,9 @@ stochastic_lookback <- function( C_impl_ta_STOCH_lookback, as.integer(fastKPeriod), as.integer(slowKPeriod), - as.integer(slowKMa), + as.maType(slowKMa), as.integer(slowDPeriod), - as.integer(slowDMa) + as.maType(slowDMa) ) } #' @usage NULL diff --git a/R/ta_STOCHF.R b/R/ta_STOCHF.R index c375dbad3..3bcb4cd89 100644 --- a/R/ta_STOCHF.R +++ b/R/ta_STOCHF.R @@ -76,7 +76,7 @@ fast_stochastic.default <- function( constructed_series[[3]], as.integer(fastKPeriod), as.integer(fastDPeriod), - as.integer(fastDMa), + as.maType(fastDMa), as.logical(na.bridge) ) @@ -151,7 +151,7 @@ fast_stochastic_lookback <- function( C_impl_ta_STOCHF_lookback, as.integer(fastKPeriod), as.integer(fastDPeriod), - as.integer(fastDMa) + as.maType(fastDMa) ) } #' @usage NULL diff --git a/R/ta_STOCHRSI.R b/R/ta_STOCHRSI.R index 5b63baba8..f263f3380 100644 --- a/R/ta_STOCHRSI.R +++ b/R/ta_STOCHRSI.R @@ -77,7 +77,7 @@ stochastic_relative_strength_index.default <- function( as.integer(timePeriod), as.integer(fastKPeriod), as.integer(fastDPeriod), - as.integer(fastDMa), + as.maType(fastDMa), as.logical(na.bridge) ) @@ -158,7 +158,7 @@ stochastic_relative_strength_index_lookback <- function( as.integer(timePeriod), as.integer(fastKPeriod), as.integer(fastDPeriod), - as.integer(fastDMa) + as.maType(fastDMa) ) } #' @usage NULL @@ -191,7 +191,7 @@ stochastic_relative_strength_index.numeric <- function( as.integer(timePeriod), as.integer(fastKPeriod), as.integer(fastDPeriod), - as.integer(fastDMa), + as.maType(fastDMa), as.logical(na.bridge) ) diff --git a/R/ta_T3.R b/R/ta_T3.R index f3a7d24d3..2f1456e85 100644 --- a/R/ta_T3.R +++ b/R/ta_T3.R @@ -46,7 +46,8 @@ t3_exponential_moving_average <- function( as.double(volumeFactor) }, maType = 8L - ) + ), + class = "maType" ) return(x) diff --git a/R/ta_TEMA.R b/R/ta_TEMA.R index afcc1979d..4b8162da6 100644 --- a/R/ta_TEMA.R +++ b/R/ta_TEMA.R @@ -40,7 +40,8 @@ triple_exponential_moving_average <- function( as.integer(timePeriod) }, maType = 4L - ) + ), + class = "maType" ) return(x) diff --git a/R/ta_TRIMA.R b/R/ta_TRIMA.R index 1c9134359..eda56f033 100644 --- a/R/ta_TRIMA.R +++ b/R/ta_TRIMA.R @@ -40,7 +40,8 @@ triangular_moving_average <- function( as.integer(timePeriod) }, maType = 5L - ) + ), + class = "maType" ) return(x) diff --git a/R/ta_VOLUME.R b/R/ta_VOLUME.R index eb96e7fad..c9c04d255 100644 --- a/R/ta_VOLUME.R +++ b/R/ta_VOLUME.R @@ -71,7 +71,7 @@ trading_volume.default <- function( maType, function(x) { as.integer( - unlist(x, use.names = FALSE) + x ) } ), diff --git a/R/ta_WMA.R b/R/ta_WMA.R index 2bd84a33a..bbdef9897 100644 --- a/R/ta_WMA.R +++ b/R/ta_WMA.R @@ -40,7 +40,8 @@ weighted_moving_average <- function( as.integer(timePeriod) }, maType = 2L - ) + ), + class = "maType" ) return(x) diff --git a/codegen/src/render.rs b/codegen/src/render.rs index 15940a972..9c5a58de8 100644 --- a/codegen/src/render.rs +++ b/codegen/src/render.rs @@ -268,6 +268,7 @@ pub fn render_indicator(f: &MetaData, t: &Templates) -> String { .iter() .map(|a| match a.kind { OptionalType::Double => format!("as.double({})", a.name), + OptionalType::MAType => format!("as.maType({})", a.name), _ => format!("as.integer({})", a.name), }) .collect(); @@ -637,7 +638,7 @@ tail // coerced optional inputs to C assert!(rendered.contains("bollinger_bands_lookback <- function(")); assert!(rendered.contains( - "C_impl_ta_BBANDS_lookback,\n\t\tas.integer(timePeriod),\n\t\tas.double(deviationsUp),\n\t\tas.integer(maType)\n\t)" + "C_impl_ta_BBANDS_lookback,\n\t\tas.integer(timePeriod),\n\t\tas.double(deviationsUp),\n\t\tas.maType(maType)\n\t)" )); // BBANDS is a Main chart indicator: the plotly and ggplot diff --git a/codegen/templates/moving_average_template.R b/codegen/templates/moving_average_template.R index 69df17eeb..40b6f35bb 100644 --- a/codegen/templates/moving_average_template.R +++ b/codegen/templates/moving_average_template.R @@ -36,7 +36,8 @@ ${FUN} <- function( list( ${SPEC_FIELDS}, maType = ${MA_TYPE} - ) + ), + class = "maType" ) return(x) From 80072f637dc50a3fa15d7eba1dc09fa00f3c3cfd Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 19:40:18 +0200 Subject: [PATCH 30/37] :books: Adapted vignettes to new interface * All vignettes render cleanly locally. --- vignettes/candlestick.Rmd | 6 +-- vignettes/charting.Rmd | 86 +++++++++++++++++++-------------------- vignettes/talib.Rmd | 25 +++++++----- 3 files changed, 60 insertions(+), 57 deletions(-) diff --git a/vignettes/candlestick.Rmd b/vignettes/candlestick.Rmd index 0e4c630c1..62ea19932 100644 --- a/vignettes/candlestick.Rmd +++ b/vignettes/candlestick.Rmd @@ -184,13 +184,13 @@ table(talib::engulfing(talib::BTC)) options(talib.normalize = TRUE) ``` -### The `eps` parameter +### The `penetration` parameter -Seven patterns accept an `eps` (penetration) parameter that controls how far one candle must intrude into the body of another. These are `morning_star()`, `evening_star()`, `morning_doji_star()`, `evening_doji_star()`, `abandoned_baby()`, `dark_cloud_cover()`, and `mat_hold()`. The default is `eps = 0` for all of them. +Seven patterns accept an `penetration` (penetration) parameter that controls how far one candle must intrude into the body of another. These are `morning_star()`, `evening_star()`, `morning_doji_star()`, `evening_doji_star()`, `abandoned_baby()`, `dark_cloud_cover()`, and `mat_hold()`. The default is `penetration = 0` for all of them. ```{r} ## Evening Star with 30% penetration -x <- talib::evening_star(talib::BTC, eps = 0.3) +x <- talib::evening_star(talib::BTC, penetration = 0.3) sum(abs(x), na.rm = TRUE) ``` diff --git a/vignettes/charting.Rmd b/vignettes/charting.Rmd index 28e771232..06d3aad2b 100644 --- a/vignettes/charting.Rmd +++ b/vignettes/charting.Rmd @@ -57,8 +57,8 @@ Use `indicator()` to attach technical indicators to the most recent `chart()`. I ```{r} { talib::chart(talib::BTC) - talib::indicator(talib::SMA, n = 7) - talib::indicator(talib::SMA, n = 14) + talib::indicator(talib::SMA, timePeriod = 7) + talib::indicator(talib::SMA, timePeriod = 14) talib::indicator(talib::RSI) } ``` @@ -82,9 +82,9 @@ By default, each sub-panel indicator (RSI, MACD, etc.) gets its own panel. To me { talib::chart(talib::BTC) talib::indicator( - talib::RSI(n = 10), - talib::RSI(n = 14), - talib::RSI(n = 21) + talib::RSI(timePeriod = 10), + talib::RSI(timePeriod = 14), + talib::RSI(timePeriod = 21) ) } ``` @@ -95,7 +95,7 @@ Each indicator keeps its own arguments and receives a distinct color from the ac { talib::chart(talib::BTC) talib::indicator( - talib::RSI(n = 14), + talib::RSI(timePeriod = 14), talib::MACD() ) } @@ -108,15 +108,15 @@ Combined panels and regular panels can be freely mixed in the same chart: talib::chart(talib::BTC) talib::indicator(talib::BBANDS) talib::indicator( - talib::RSI(n = 10), - talib::RSI(n = 14), - talib::RSI(n = 21) + talib::RSI(timePeriod = 10), + talib::RSI(timePeriod = 14), + talib::RSI(timePeriod = 21) ) talib::indicator(talib::MACD) } ``` -> **Note:** the syntax matters. `indicator(RSI, n = 14)` passes a function and arguments separately (single indicator). `indicator(RSI(n = 14), RSI(n = 21))` passes _calls_ (combined panel). A single call like `indicator(RSI(n = 14))` also works and is equivalent to the single-indicator form. +> **Note:** the syntax matters. `indicator(RSI, timePeriod = 14)` passes a function and arguments separately (single indicator). `indicator(RSI(timePeriod = 14), RSI(timePeriod = 21))` passes _calls_ (combined panel). A single call like `indicator(RSI(timePeriod = 14))` also works and is equivalent to the single-indicator form. ### Standalone indicators @@ -221,10 +221,10 @@ The default theme uses a dark background with cyan and blue candles. ```{r} { talib::chart(talib::BTC) - talib::indicator(talib::SMA, n = 7) - talib::indicator(talib::SMA, n = 14) - talib::indicator(talib::SMA, n = 21) - talib::indicator(talib::SMA, n = 28) + talib::indicator(talib::SMA, timePeriod = 7) + talib::indicator(talib::SMA, timePeriod = 14) + talib::indicator(talib::SMA, timePeriod = 21) + talib::indicator(talib::SMA, timePeriod = 28) talib::indicator(talib::MACD) talib::indicator(talib::trading_volume) } @@ -238,10 +238,10 @@ A light theme with neutral grays. { talib::set_theme$hawks_and_doves talib::chart(talib::BTC) - talib::indicator(talib::SMA, n = 7) - talib::indicator(talib::SMA, n = 14) - talib::indicator(talib::SMA, n = 21) - talib::indicator(talib::SMA, n = 28) + talib::indicator(talib::SMA, timePeriod = 7) + talib::indicator(talib::SMA, timePeriod = 14) + talib::indicator(talib::SMA, timePeriod = 21) + talib::indicator(talib::SMA, timePeriod = 28) talib::indicator(talib::MACD) talib::indicator(talib::trading_volume) } @@ -255,10 +255,10 @@ A dark theme with teal and orange accents. { talib::set_theme$payout talib::chart(talib::BTC) - talib::indicator(talib::SMA, n = 7) - talib::indicator(talib::SMA, n = 14) - talib::indicator(talib::SMA, n = 21) - talib::indicator(talib::SMA, n = 28) + talib::indicator(talib::SMA, timePeriod = 7) + talib::indicator(talib::SMA, timePeriod = 14) + talib::indicator(talib::SMA, timePeriod = 21) + talib::indicator(talib::SMA, timePeriod = 28) talib::indicator(talib::MACD) talib::indicator(talib::trading_volume) } @@ -272,10 +272,10 @@ A bright theme with teal and red candles on a light background. { talib::set_theme$tp_slapped talib::chart(talib::BTC) - talib::indicator(talib::SMA, n = 7) - talib::indicator(talib::SMA, n = 14) - talib::indicator(talib::SMA, n = 21) - talib::indicator(talib::SMA, n = 28) + talib::indicator(talib::SMA, timePeriod = 7) + talib::indicator(talib::SMA, timePeriod = 14) + talib::indicator(talib::SMA, timePeriod = 21) + talib::indicator(talib::SMA, timePeriod = 28) talib::indicator(talib::MACD) talib::indicator(talib::trading_volume) } @@ -289,10 +289,10 @@ A light, muted theme with earthy tones. { talib::set_theme$trust_the_process talib::chart(talib::BTC) - talib::indicator(talib::SMA, n = 7) - talib::indicator(talib::SMA, n = 14) - talib::indicator(talib::SMA, n = 21) - talib::indicator(talib::SMA, n = 28) + talib::indicator(talib::SMA, timePeriod = 7) + talib::indicator(talib::SMA, timePeriod = 14) + talib::indicator(talib::SMA, timePeriod = 21) + talib::indicator(talib::SMA, timePeriod = 28) talib::indicator(talib::MACD) talib::indicator(talib::trading_volume) } @@ -306,10 +306,10 @@ A dark theme inspired by the Bloomberg Terminal interface. Orange bullish candle { talib::set_theme$bloomberg_terminal talib::chart(talib::BTC) - talib::indicator(talib::SMA, n = 7) - talib::indicator(talib::SMA, n = 14) - talib::indicator(talib::SMA, n = 21) - talib::indicator(talib::SMA, n = 28) + talib::indicator(talib::SMA, timePeriod = 7) + talib::indicator(talib::SMA, timePeriod = 14) + talib::indicator(talib::SMA, timePeriod = 21) + talib::indicator(talib::SMA, timePeriod = 28) talib::indicator(talib::MACD) talib::indicator(talib::trading_volume) } @@ -323,10 +323,10 @@ A dark monochrome theme that encodes direction with luminance only. Light-gray b { talib::set_theme$limit_up talib::chart(talib::BTC) - talib::indicator(talib::SMA, n = 7) - talib::indicator(talib::SMA, n = 14) - talib::indicator(talib::SMA, n = 21) - talib::indicator(talib::SMA, n = 28) + talib::indicator(talib::SMA, timePeriod = 7) + talib::indicator(talib::SMA, timePeriod = 14) + talib::indicator(talib::SMA, timePeriod = 21) + talib::indicator(talib::SMA, timePeriod = 28) talib::indicator(talib::MACD) talib::indicator(talib::trading_volume) } @@ -340,10 +340,10 @@ A light theme with the classic blue-vs-red trading pair. Steel-blue bullish and { talib::set_theme$bid_n_ask talib::chart(talib::BTC) - talib::indicator(talib::SMA, n = 7) - talib::indicator(talib::SMA, n = 14) - talib::indicator(talib::SMA, n = 21) - talib::indicator(talib::SMA, n = 28) + talib::indicator(talib::SMA, timePeriod = 7) + talib::indicator(talib::SMA, timePeriod = 14) + talib::indicator(talib::SMA, timePeriod = 21) + talib::indicator(talib::SMA, timePeriod = 28) talib::indicator(talib::MACD) talib::indicator(talib::trading_volume) } @@ -416,7 +416,7 @@ Set `talib.chart.backend` to `"ggplot2"` for static charts. This requires the ** talib::set_theme$hawks_and_doves talib::chart(talib::BTC) - talib::indicator(talib::SMA, n = 14) + talib::indicator(talib::SMA, timePeriod = 14) talib::indicator(talib::RSI) } ``` diff --git a/vignettes/talib.Rmd b/vignettes/talib.Rmd index 0a1a8eb83..9de1503eb 100644 --- a/vignettes/talib.Rmd +++ b/vignettes/talib.Rmd @@ -16,7 +16,7 @@ knitr::opts_chunk$set( comment = "#>", out.width = "100%", out.height = "680", - fig.align = "center" + fig.aligtimePeriod = "center" ) ``` @@ -99,8 +99,8 @@ Every indicator has a descriptive snake_case name and an uppercase alias that mi ```{r} ## these are equivalent identical( - talib::relative_strength_index(talib::BTC, n = 14), - talib::RSI(talib::BTC, n = 14) + talib::relative_strength_index(talib::BTC, timePeriod = 14), + talib::RSI(talib::BTC, timePeriod = 14) ) ``` @@ -109,17 +109,17 @@ identical( Most indicators require a minimum number of observations before they can produce a value. This is called the **lookback period**. The first `lookback` rows of the result will be `NA`: ```{r} -## SMA with n = 5 has a lookback of 4 +## SMA with timePeriod = 5 has a lookback of 4 head( - talib::SMA(talib::BTC, n = 5), - n = 7 + talib::SMA(talib::BTC, timePeriod = 5), + timePeriod = 7 ) ``` The lookback is stored as an attribute on the result: ```{r} -x <- talib::SMA(talib::BTC, n = 20) +x <- talib::SMA(talib::BTC, timePeriod = 20) attr(x, "lookback") ``` @@ -209,7 +209,7 @@ Several indicators accept a **Moving Average specification** for their smoothing ```{r} ## SMA as a specification str( - talib::SMA(n = 20) + talib::SMA(timePeriod = 20) ) ``` @@ -220,7 +220,8 @@ This specification can be passed to indicators like `bollinger_bands()` or `stoc tail( talib::bollinger_bands( talib::BTC, - ma = talib::EMA(n = 20) + timePeriod = 20, + maType = talib::EMA() ) ) ``` @@ -230,8 +231,10 @@ tail( tail( talib::stochastic( talib::BTC, - slowk = talib::WMA(n = 5), - slowd = talib::EMA(n = 3) + slowKPeriod = 5, + slowKMa = talib::EMA(), + slowDPeriod = 5, + slowDMa = talib::EMA() ) ) ``` From 357f64aacc02a8f6ec34895cecd81728c3c37af7 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 19:41:12 +0200 Subject: [PATCH 31/37] :wastebasket: Deleted AI-slop * This vignette was written "just" to to show {tidyverse} could be used for future tidy-people. The vignette was written purely with AI, without any consideration for the actual use-case or necessity. - Off it goes! --- vignettes/articles/tidyverse.Rmd | 184 ------------------------------- 1 file changed, 184 deletions(-) delete mode 100644 vignettes/articles/tidyverse.Rmd diff --git a/vignettes/articles/tidyverse.Rmd b/vignettes/articles/tidyverse.Rmd deleted file mode 100644 index 7fbe52085..000000000 --- a/vignettes/articles/tidyverse.Rmd +++ /dev/null @@ -1,184 +0,0 @@ ---- -title: "Tidyverse Workflows" -author: Serkan Korkmaz ---- - -```{r, include = FALSE} -options(talib.chart.dark = FALSE) - -knitr::opts_chunk$set( - collapse = TRUE, - comment = "#>", - out.width = "100%", - fig.align = "center" -) -``` - -`{talib}` indicators accept a `data.frame` and return a `data.frame`---but the returned data frame contains **only the indicator columns**, not the original data. This is by design: it keeps the core API minimal and composable. In a tidyverse pipeline, however, you usually want the indicator columns attached to your existing data so you can keep piping. - -This article builds a thin wrapper called `tidy_ta()` that bridges that gap, then puts it to work in increasingly realistic scenarios. - -```{r} -library(talib) -library(dplyr) -library(tidyr) -``` - -## The gap - -Piping into a `{talib}` indicator works---`x` is the first argument: - -```{r} -BTC %>% - RSI(n = 14) %>% - tail() -``` - -The result is a one-column data frame with just the RSI values. The original price data is gone. To keep both, you need to bind the indicator output back to the input. - -## Building `tidy_ta()` - -The simplest version takes a data frame, passes it to an indicator, and column-binds the result: - -```{r} -tidy_ta <- function(.data, .f, ...) { - dplyr::bind_cols(.data, .f(.data, ...)) -} -``` - -Three lines, and every indicator in `{talib}` is now pipe-friendly: - -```{r} -BTC %>% - tidy_ta(RSI, n = 14) %>% - tail() -``` - -Multi-column indicators work the same way---Bollinger Bands returns three columns, and all three get bound: - -```{r} -BTC %>% - tidy_ta(bollinger_bands) %>% - tail() -``` - -Chaining multiple indicators composes naturally: - -```{r} -BTC %>% - tidy_ta(RSI, n = 14) %>% - tidy_ta(bollinger_bands) %>% - tidy_ta(MACD) %>% - tail() -``` - -### Handling column-name collisions - -If you add two SMAs with different periods, both return a column named `SMA` and `bind_cols()` disambiguates with ugly suffixes like `SMA...6`. A `.suffix` parameter fixes this: - -```{r} -tidy_ta <- function(.data, .f, ..., .suffix = NULL) { - result <- .f(.data, ...) - - if (!is.null(.suffix)) { - colnames(result) <- paste(colnames(result), .suffix, sep = "_") - } - - dplyr::bind_cols(.data, result) -} -``` - -Now each indicator gets a clear name: - -```{r} -BTC %>% - tidy_ta(SMA, n = 10, .suffix = "10") %>% - tidy_ta(SMA, n = 20, .suffix = "20") %>% - tail() -``` - -The `cols` argument is forwarded through `...`, so column remapping still works: - -```{r} -BTC %>% - tidy_ta(RSI, cols = ~high, n = 14) %>% - tail() -``` - -This is the complete wrapper. The rest of the article uses it as-is. - -## Grouped operations across assets - -A common task is computing the same indicator across multiple tickers. Stack the data, `nest()` by ticker, apply `tidy_ta()` inside each group, and `unnest()`: - -```{r} -assets <- bind_rows( - BTC %>% as_tibble(rownames = "date") %>% mutate(ticker = "BTC"), - SPY %>% as_tibble(rownames = "date") %>% mutate(ticker = "SPY"), - NVDA %>% as_tibble(rownames = "date") %>% mutate(ticker = "NVDA") -) - -assets %>% - nest(.by = ticker) %>% - mutate(data = lapply(data, tidy_ta, RSI, n = 14)) %>% - unnest(data) %>% - select(ticker, date, close, RSI) %>% - filter(!is.na(RSI)) %>% - slice_tail(n = 3, by = ticker) -``` - -Because `tidy_ta()` returns the full enriched data frame, `unnest()` restores everything in one step. This scales to multiple indicators by chaining inside the `lapply()`: - -```{r} -assets %>% - nest(.by = ticker) %>% - mutate(data = lapply(data, function(d) { - d %>% - tidy_ta(RSI, n = 14) %>% - tidy_ta(bollinger_bands) - })) %>% - unnest(data) %>% - select(ticker, date, close, RSI, UpperBand, MiddleBand, LowerBand) %>% - filter(!is.na(RSI)) %>% - slice_tail(n = 3, by = ticker) -``` - -## Putting it all together - -A complete pipeline: enrich a multi-asset dataset, flag RSI signals, and find the most recent event per asset. - -```{r} -assets %>% - nest(.by = ticker) %>% - mutate(data = lapply(data, tidy_ta, RSI, n = 14)) %>% - unnest(data) %>% - filter(!is.na(RSI)) %>% - mutate( - signal = case_when( - RSI > 70 ~ "overbought", - RSI < 30 ~ "oversold" - ) - ) %>% - filter(!is.na(signal)) %>% - slice_tail(n = 1, by = c(ticker, signal)) %>% - select(ticker, date, close, RSI, signal) %>% - arrange(ticker, signal) -``` - -## Summary - -The entire wrapper is six lines: - -```r -tidy_ta <- function(.data, .f, ..., .suffix = NULL) { - result <- .f(.data, ...) - if (!is.null(.suffix)) { - colnames(result) <- paste(colnames(result), .suffix, sep = "_") - } - dplyr::bind_cols(.data, result) -} -``` - -It works because `{talib}` indicators already follow the key convention: data frame in, data frame out, with row counts and row names preserved. `tidy_ta()` just bridges the last mile---binding the result back to the input so the pipeline keeps flowing. - -The pattern is not specific to `{talib}`. Any function that takes a data frame and returns a same-length data frame can be wrapped the same way. From 7f0b051bf2ce663b5e784fc653a019fe3304161b Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 19:42:53 +0200 Subject: [PATCH 32/37] :books: Removed TSF, and added as.maType --- NAMESPACE | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index e5670ba52..45d842e19 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,8 +2,6 @@ S3method("$",chart_theme) S3method(.DollarNames,chart_theme) -S3method(TSF,default) -S3method(TSF,numeric) S3method(abandoned_baby,data.frame) S3method(abandoned_baby,default) S3method(abandoned_baby,ggplot) @@ -775,7 +773,6 @@ export(TEMA) export(TRANGE) export(TRIMA) export(TRIX) -export(TSF) export(TYPPRICE) export(ULTOSC) export(VAR) @@ -789,6 +786,7 @@ export(acceleration_bands) export(advance_block) export(aroon) export(aroon_oscillator) +export(as.maType) export(average_deviation) export(average_directional_movement_index) export(average_directional_movement_index_rating) From 10e0500186cdb57ada876090718ac350131f144e Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 20:42:37 +0200 Subject: [PATCH 33/37] :fire: Custom examples tags * Some indicators requires custom examples to run like, for example, the ta_MAVP - the new boolean flag takes precedence over any auto-generated example. --- man-roxygen/description.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/man-roxygen/description.R b/man-roxygen/description.R index 9eaa92455..06f0babbc 100644 --- a/man-roxygen/description.R +++ b/man-roxygen/description.R @@ -92,6 +92,7 @@ #' @concept trading #' @concept algorithmic trading #' +<% if (!exists(".custom_example")) { %> <% if (grepl(pattern = "Price Transform", x = .family)) { %> #' @examples #' ## load Bitcoin (BTC) @@ -136,3 +137,4 @@ #' } <% } %> +<% } %> From cc2a2c9dba058643c76e959dfaa77848ee1b47fb Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 20:43:42 +0200 Subject: [PATCH 34/37] :books: Added custom example flag --- R/ta_MAVP.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/ta_MAVP.R b/R/ta_MAVP.R index 726cb44d9..bb9dcc131 100644 --- a/R/ta_MAVP.R +++ b/R/ta_MAVP.R @@ -9,6 +9,7 @@ #' @templateVar .formula ~close + periods #' ## splice:documentation:start +#' @templateVar .custom_example TRUE #' @example man/examples/MAVP-example.R ## splice:documentation:end #' From e364548417ded4c383c16aa4f3d2803cb21c94a3 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 20:51:57 +0200 Subject: [PATCH 35/37] :hammer: Unexport generic / Export dispatches * This keeps R CMD check happy! --- NAMESPACE | 4 +++- R/utils.R | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 45d842e19..5d7e079b9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -33,6 +33,9 @@ S3method(aroon_oscillator,default) S3method(aroon_oscillator,ggplot) S3method(aroon_oscillator,matrix) S3method(aroon_oscillator,plotly) +S3method(as.maType,double) +S3method(as.maType,integer) +S3method(as.maType,maType) S3method(average_deviation,data.frame) S3method(average_deviation,default) S3method(average_deviation,matrix) @@ -786,7 +789,6 @@ export(acceleration_bands) export(advance_block) export(aroon) export(aroon_oscillator) -export(as.maType) export(average_deviation) export(average_directional_movement_index) export(average_directional_movement_index_rating) diff --git a/R/utils.R b/R/utils.R index 4496f9952..d34714723 100644 --- a/R/utils.R +++ b/R/utils.R @@ -385,16 +385,19 @@ mapMaType <- function(x) { ## A small S3 that helps mapping ## maTypes to and ## -#'@export as.maType <- function(x, ...) { UseMethod("as.maType") } -## +#' @export as.maType.maType <- function(x, ...) { as.integer(x$maType) } -as.maType.double <- as.maType.integer <- function(x, ...) { +#' @export +as.maType.double <- function(x, ...) { as.integer(x) } + +#' @export +as.maType.integer <- as.maType.double From ee8de83e2ca7c7fea04a2b1b1131358a13c2ef49 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 20:59:53 +0200 Subject: [PATCH 36/37] :hammer: data-helper for unit-tests * The helper files are run before the tests starts altogether. So the data can be properly prepared *once* and passed downstream. --- tests/testthat/helper-data.R | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/testthat/helper-data.R diff --git a/tests/testthat/helper-data.R b/tests/testthat/helper-data.R new file mode 100644 index 000000000..88abd10a5 --- /dev/null +++ b/tests/testthat/helper-data.R @@ -0,0 +1,29 @@ +## testthat helper - sourced automatically before the test files +## +## MAVP (variable_moving_average_period) consumes a 'periods' column +## alongside 'close' (default formula ~close + periods), but the +## built-in datasets ship without one. The autogenerated tests call +## every indicator on the bare datasets, so shadow them here with +## copies carrying a deterministic 'periods' column. Harmless for the +## remaining indicators - they select their columns via formula and +## ignore the extra column. +.add_periods <- function(x) { + periods <- rep_len( + x = 5:10, + length.out = nrow(x) + ) + + if (is.matrix(x)) { + return( + cbind(x, periods = periods) + ) + } + + x$periods <- periods + + x +} + +BTC <- .add_periods(talib::BTC) +SPY <- .add_periods(talib::SPY) +ATOM <- .add_periods(talib::ATOM) From 4d6747659789c802536e13c36a6eda0d2381e95d Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sun, 26 Jul 2026 21:15:11 +0200 Subject: [PATCH 37/37] :hammer: Pass NULL * This is an artifact from X-macro PR where it seemed like a good idea to add void to the C-signature + This commit is mostly to satisfy R CMD check rather than a proper fix on anything. Most of the zzz.R functions onload and unload are obsolete as its handled on the C-side anyways. --- R/zzz.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/zzz.R b/R/zzz.R index 8e81e80f6..8cd72e4a3 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -149,7 +149,7 @@ ) { ## reset candles on ## unload - .Call(C_reset_candle_setting) + .Call(C_reset_candle_setting, NULL) ## shutdown TA-Lib ## on unload