From 755f95b1c70d9a431b09afc88200869cba8fd5b7 Mon Sep 17 00:00:00 2001 From: Derek Melchin <38889814+DerekMelchin@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:57:27 -0600 Subject: [PATCH] Update 06 Plot Data.html --- .../06 Plot Data.html | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/08 Drafts/04 Research Environment/03 Datasets/06 Equity Fundamental Data/06 Plot Data.html b/08 Drafts/04 Research Environment/03 Datasets/06 Equity Fundamental Data/06 Plot Data.html index 78e6de4047..b1c98ac402 100644 --- a/08 Drafts/04 Research Environment/03 Datasets/06 Equity Fundamental Data/06 Plot Data.html +++ b/08 Drafts/04 Research Environment/03 Datasets/06 Equity Fundamental Data/06 Plot Data.html @@ -2,24 +2,31 @@

Follow these steps to plot line charts using built-in methodsPlotly.NET package:

-
    +
    1. Get some historical data.
    2. var history = qb.GetFundamental(symbols, "ValuationRatios.PERatio", new DateTime(2014, 1, 1), new DateTime(2015, 1, 1));
      history = qb.GetFundamental(symbols, "ValuationRatios.PERatio", datetime(2014, 1, 1), datetime(2015, 1, 1))
      + +
    3. Load the Plotly.NET package.
    4. +
      +
      #r "../Plotly.NET.dll"
      +#r "../Plotly.NET.Interactive.dll"
      +
      +using Plotly.NET;
      +using Plotly.NET.Interactive;
      +using Plotly.NET.LayoutObjects;
      +
      -
    5. Create Line charts.
    6. +
    7. Create Line objects for each Symbol.
    8. -
      var chart1 = Chart2D.Chart.Line<DateTime, decimal, string>(
      -    history.Select(x => (DateTime)x.Time),
      -    history.Select(x => (decimal)x[aapl]),
      -    Name: "AAPL"
      -);
      -var chart2 = Chart2D.Chart.Line<DateTime, decimal, string>(
      -    history.Select(x => (DateTime)x.Time),
      -    history.Select(x => (decimal)x[goog]),
      -    Name: "GOOG"
      +        
      var charts = symbols.Select(
      +    symbol => Chart2D.Chart.Line<DateTime, decimal, string>(
      +        history.Select(x => (DateTime)x.Time),
      +        history.Select(x => (decimal)x[symbol]),
      +        Name: symbol.Value
      +    )
       );
      @@ -29,7 +36,7 @@ xAxis.SetValue("title", "Time"); LinearAxis yAxis = new LinearAxis(); yAxis.SetValue("title", "PE Ratio"); -Title title = Title.init("AAPL & GOOG PE Ratio"); +Title title = Title.init("PE Ratios Over Time"); Layout layout = new Layout(); layout.SetValue("xaxis", xAxis); @@ -39,7 +46,7 @@
    9. Combine the charts and assign the Layout to the chart.
    10. -
      var chart = Plotly.NET.Chart.Combine(new []{chart1, chart2});
      +        
      var chart = Plotly.NET.Chart.Combine(charts);
       chart.WithLayout(layout);
      @@ -57,4 +64,4 @@
    Line plot of PE ratio of US Equities -Line plot of PE ratio of AAPL & GOOG +Line plot of PE ratio of US Equities