Skip to content

IOHLC: Use an interface when interacting with financial data #2404

@mjpz

Description

@mjpz

Hi Scott, thank you for this great library.

Feature Suggestion

Imo FinancePlot could reuse existing data structures which come from webservices, databases or elsewhere without creating new Ohlc instances.

Feature description:

  • ScottPlot define an Interface describing the OHLC structure
  • X axis lables using ohlc.DateTime in sequential mode

Code example:

 public interface IOhlc
  {
    public double Open { get; }
    public double High { get; }
    public double Low { get; }
    public double Close { get; }
    public double Volume { get; }
    public DateTime DateTime { get; }
    public TimeSpan TimeSpan { get; }
  }


    public class FinancePlot : IPlottable
    {
        /// <summary>
        /// Create a finance plot from existing OHLC data.
        /// </summary>
        /// <param name="ohlcs"></param>
        public FinancePlot(IEnumerable <IOhlc> ohlcs)
        {
            ...
        }

        /// <summary>
        /// Add a single OHLC to the plot
        /// </summary>
        /// <param name="ohlc"></param>
        public void Add(IOhlc ohlc)
        {
            ...
        }

        /// <summary>
        /// Add multiple OHLCs to the plot
        /// </summary>
        /// <param name="ohlcs"></param>
        public void AddRange(IEnumerable <IOhlc> ohlcs)
        {
            ...
        }

        /// <summary>
        /// Returns the last element of OHLCs so users can modify FinancePlots in real time.
        /// </summary>
        public IOhlc Last() => ...

   

    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions