amv-dev / yata

Yet Another Technical Analysis library [for Rust]
Apache License 2.0
321 stars 49 forks source link

Sequential timeframe collapse #20

Closed agubarev closed 2 years ago

agubarev commented 2 years ago

Hi,

I've found something that could possibly be an issue with https://docs.rs/yata/latest/yata/core/trait.Sequence.html#method.collapse_timeframe

When using collapse_timeframe(n, true) on a sequence i.e., Vec<Candle>, it collapses each subsequent pair, for example, given an input sequence [1, 2, 3, 4, 5, 6] candles, it produces a following output:

[(1, 2), (2, 3), (3, 4), (4, 5), (5, 6)] instead of [(1, 2), (3, 4), (5, 6)], please correct me if I'm wrong and this is working as intended.

I'll now try the https://docs.rs/yata/latest/yata/methods/struct.CollapseTimeframe.html with chunks of the original sequence.

P.S. You're developing a beautiful library.

amv-dev commented 2 years ago

Hello! Thank you. Did you try to use collapse_timeframe with continuous argument set to false? Looks like this is what you are looking for.

agubarev commented 2 years ago

No, but now I understand what I got wrong about continuous, I misunderstood your idea and didn't see it in the code last night. It does exactly what I had to write yesterday for my purpose, so now sticking back to yours. Thank you.