-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to remove (to re-calc) cached calculations #33
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## main #33 +/- ##
==========================================
+ Coverage 99.29% 99.31% +0.02%
==========================================
Files 35 35
Lines 566 587 +21
==========================================
+ Hits 562 583 +21
Misses 2 2
Partials 2 2
Continue to review full report at Codecov.
|
Hey @tomcruise81! Love the idea. Check out #30 which I just merged. I think if we export the new |
@sdcoffey - I think we'd still need to augment the other types due to the need for recursively removing the cached calculations from inner indicators. So even if I do something like: type CachedIndicator interface {
Indicator
cache() resultCache
setCache(cache resultCache)
windowSize() int
}
func RemoveCachedEntry(indicator Indicator, index int) {
cachedIndicator, ok := indicator.(CachedIndicator)
if ok {
cacheResult(cachedIndicator, index, nil)
}
for _, subIndicator := range indicator.subIndicators() {
RemoveCachedEntry(subIndicator, index)
}
} we'd need to change to something like |
...although I may be able to create another interface: type NestedIndicator interface {
Indicator
nestedIndicators() []Indicator
}
func RemoveCachedEntry(indicator Indicator, index int) {
cachedIndicator, ok := indicator.(CachedIndicator)
if ok {
cacheResult(cachedIndicator, index, nil)
}
// Recursion
nestedIndicator, ok := indicator.(NestedIndicator)
if ok {
for _, nestedIndicator := range nestedIndicator.nestedIndicators() {
cachedNestedIndicator, ok := nestedIndicator.(CachedIndicator)
if ok {
RemoveCachedEntry(cachedNestedIndicator, index)
}
}
}
} |
Not sure if this would be something that you're interested in, but I've found benefit from using the MACD Histogram with minute candles, where the last candle is updated based on sub-minute streamed values - i.e. the last candle is an approximation, but still provides value. It requires the ability to re-calculate (i.e. not use the cached value).