Giter VIP home page Giter VIP logo

Comments (9)

codeplea avatar codeplea commented on September 7, 2024

I don't think I'm understanding what you're asking.

For e.g in SMA didn't we only need to exclude the oldest period value in average and include the latest period value to calculate one additional point in SMA ?

That is exactly how the code works. For each output, it subtracts the oldest bar in the average, and adds in a new bar. See here.

Performance gain by this should be huge.

Performance is a goal of this library. There is a benchmark against ta-lib here.

from tulipindicators.

G8XSU avatar G8XSU commented on September 7, 2024

If we were storing/using the previously calculate SMA, it would be O(1) implementation.
Similar to https://github.com/askmike/gekko/blob/develop/strategies/indicators/SMA.js

from tulipindicators.

codeplea avatar codeplea commented on September 7, 2024

It does run in linear time. I guess you didn't look at the code I linked to?

from tulipindicators.

G8XSU avatar G8XSU commented on September 7, 2024

Hi,
I did look at the code, from what i understood, we are iterating over the input as fresh input in "for loop".
This is linear time implementation but this can be done in constant time if we have already computed SMA for previous window. (Previous SMA just didn't include the latest candle)
Is there some other platform where we can chat?

from tulipindicators.

G8XSU avatar G8XSU commented on September 7, 2024

I think whats missing here is context,
If we calculate SMA the way we are currently doing we are kind of assuming that we have a single chart of candlesticks and then we computed the SMA for it just once and displayed it as a overlay over original chart.

But in reality, the candlestick graph keeps on updating and adding new candles.
This is true for :

  1. Showing the graph live on some trading exchange.
  2. Using trading bot in live market, which needs to calculate this indicator again and again for every new candle.
  3. While testing existing trading-bot over historical data, we would need to calculate this indicator again and again since candles are being ingested one-at-a-time.

When we are adding new candle to graph every minute, it is sub-optimal to calculate whole SMA again and again every minute.
Instead we need to re-use the SMA which was computed without considering the latest candle from input. This will result in savings of redundant computation.

from tulipindicators.

codeplea avatar codeplea commented on September 7, 2024

I see. You're not talking about the initial calculation (in which linear time is optimal), but instead about updating the calculation over time.

We're working on a streaming interface for the next release that does exactly what you're asking. It's currently in the 0.9 branch. See here: https://github.com/TulipCharts/tulipindicators/blob/0.9/indicators/sma.c

from tulipindicators.

G8XSU avatar G8XSU commented on September 7, 2024

Went through very useful discussion on #57 . I read through the comments and it was very insightful.

Is 0.9 #35 ready ? Why isn't this merged to mainline?

I will see if i can contribute to this project but i am not that familiar with writing optimized C code.
I am pretty new to technical analysis, i will try if i can implement some reference indicator.

I will go on and request support for streaming interface in tulipy.

from tulipindicators.

adrianog avatar adrianog commented on September 7, 2024

And... What happened?

from tulipindicators.

codeplea avatar codeplea commented on September 7, 2024

We lost the sponsor for this feature, and it's not a priority for me at this time. If someone else wants to sponsor the work, it'll happen much faster.

The way I use this library is primarily for back-testing, and the routines are already optimal for that. The calculation load for running live algos, where the implementation isn't optimal, is minuscule compared to back-testing.

from tulipindicators.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.