Replacing update #626
Replies: 6 comments 3 replies
-
That can be easily added. Can you suggest how you would the API to look like? Do you want to pass a boolean flag to the update method to indicate if you wish to replace the last value? |
Beta Was this translation helpful? Give feedback.
-
Alternatively popping the last n update values would be useful--though, the replace boolean probably covers most use case. Was looking into normalization with periods of >500, and if removing is added as a feature (at a specific index, but in this case at the beginning) then instead of reducing to sum during the batch operations for MA's and incurring O(n) each update, a running total could be kept and the removed value could be subtracted from the running total and consequently avoid that reduce's loop for the update calculation. |
Beta Was this translation helpful? Give feedback.
-
Any update on this? I am willing to become a sponsor of this project. How can I become a sponsor? |
Beta Was this translation helpful? Give feedback.
-
If I get it right, you want that the last value pushed to an indicator can be replaced so that you can update an indicator's value as an unfinished candle fills up? Am I right with this, @luxsush, @atengberg & @piboistudios? I guess it would be similar to this code? https://github.com/debut-js/Indicators/blob/v1.3.19/src/cci.ts#L26-L32 |
Beta Was this translation helpful? Give feedback.
-
That is why I ended up finding this thread. A current candle is used to hold state updated until that candle closes, at which point it's pushed to an array of only previous closed candles. Any calculations of derived state (TA, other statistics, etc) can always be run once the candle closes, but it can also be necessary to calculate that kind of derived state for the current candle in real time (just like the linked |
Beta Was this translation helpful? Give feedback.
-
Hi all, the replacing functionality is now live with v5. 🥳 Here is the API design: Simply pass a |
Beta Was this translation helpful? Give feedback.
-
Would be nice to have a method to be able to replace the last value, rather than pushing a new value to the dataset.
This way you can have live indicators, where the last data point will update in realtime until the next period of data is available. Otherwise you have to basically recreate the indicator and re-push all the values with the last value replaced if I'm not mistaken.
Beta Was this translation helpful? Give feedback.
All reactions