Comments (2)
Hi, I've got the same issue here.
Turned out the problem is in this line:
numMA <- do.call(maType, c(list(num), list(n = smooth)))
The output contains strange float errors
ex:
expected 0 but -0.000000000000003552714
expected 0.2 but 0.199999999999995736744
And the code:
fastK <- numMA/denMA
That's why there are Infinities in fastK
Since the Inf is in the vector, the code below is not able to correct it:
fastK[is.nan(fastK)] <- 0.5
Can it be fixed ?
from ttr.
The only way I can reproduce this is if the Close is > High, and High and Low are equal. But that would be a data error. Regardless, this can be fixed in stoch()
by changing is.nan()
to !is.finite()
.
Here's a reproducible example:
x <- structure(c(53.99, 54.69, 55.55, 55.55, 55.55, 52.5, 52.5, 52.5, 52.5,
52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 51.77, 51.77, 53.99,
54.69, 55.55, 55.55, 55.55, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5, 52.5,
52.5, 52.5, 52.5, 52.5, 52.5, 51.77, 51.77, 54.09, 54.79, 55.65, 55.65,
55.65, 52.6, 52.6, 52.6, 52.6, 52.6, 52.6, 52.6, 52.6, 52.6, 52.6, 52.6,
52.6, 52.6, 51.87, 51.87), class = c("xts", "zoo"), src = "yahoo",
updated = structure(1597593022.65377, class = c("POSIXct", "POSIXt")),
index = structure(c(1446422400, 1446508800, 1446595200, 1446681600,
1446768000, 1447027200, 1447113600, 1447200000, 1447286400, 1447372800,
1447632000, 1447718400, 1447804800, 1447891200, 1447977600, 1448236800,
1448323200, 1448409600, 1448582400, 1448841600), tzone = "UTC", tclass = "Date"),
.Dim = c(20L, 3L), .Dimnames = list(NULL, c("QTWN.High", "QTWN.Low", "QTWN.Close")))
s <- TTR::stoch(x, 10, 3)
The error is different because the original error was from a .Fortran()
call and the current code use .Call()
.
from ttr.
Related Issues (20)
- "Series contains non-leading NAs" on stoch() HOT 8
- support TR calculations without Average HOT 2
- ERROR: package or namespace load failed for 'TTR' in dyn.load(file, DLLpath = DLLpath, ...): HOT 1
- Standardize leading NA checks in C code
- ALMA optimization HOT 2
- runSum produces leading NA when cumulative = TRUE HOT 2
- how can i buy and finish a operation in R? HOT 1
- Issue on nSig for TRIX HOT 2
- cumulative runSD returns all NA HOT 3
- runMean(..., cumulative = TRUE) doesn't account for leading NA in denominator
- Use R_forceSymbols(dll, TRUE) for native routines
- Add argument to EMA to prevent setting first n-1 obs to NA
- malloc(): invalid size (unsorted) HOT 8
- CTI doesn't pad non-xtsible inputs with NA
- The Symbol for Nano Labs Ltd (NASDAQ), NA, conflicts with NA in R HOT 6
- Change Readme to reflect that Fortran is no longer used HOT 1
- indicators show different values on windows of different sizes HOT 4
- rolling trimmed mean HOT 7
- Add Fibonacci Retracements and Extensions
- support for integer64 type in runXXX functions HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ttr.