fslaborg / Deedle

Easy to use .NET library for data and time series manipulation and for scientific programming
http://fslab.org/Deedle/
BSD 2-Clause "Simplified" License
924 stars 196 forks source link

Truncate part of a Frame #529

Open Hulkstance opened 3 years ago

Hulkstance commented 3 years ago

Since I'm doing calculations based on indicators, the first, let's say 50 records are not so accurate due to the fact that there wasn't enough data. I want to truncate those 50 records/results. How can I do that? The truncate should be executed in the beginning of the Frame.

public class RsiStrategy : StrategyBase
{
    public override Frame<int, string> PopulateIndicators(Frame<int, string> dataFrame)
    {
        var candles = dataFrame.Rows.Select(kvp => new Candle
        {
            Timestamp = kvp.Value.GetAs<DateTime>("Timestamp"),
            Open = kvp.Value.GetAs<decimal>("Open"),
            High = kvp.Value.GetAs<decimal>("High"),
            Low = kvp.Value.GetAs<decimal>("Low"),
            Close = kvp.Value.GetAs<decimal>("Close"),
            Volume = kvp.Value.GetAs<decimal>("Volume")
        }).Observations.Select(e => e.Value).ToList<IOhlcv>();

                // TODO: Truncate the first 50 elements of the Frame

        dataFrame.AddColumn("Rsi", candles.Rsi(2));

        return dataFrame;
    }
}
nhirschey commented 2 years ago

See Frame.skip https://fslab.org/Deedle/reference/deedle-framemodule.html