Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
asda
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmincatalin committed Sep 29, 2022
1 parent 5738911 commit 99047e6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
14 changes: 10 additions & 4 deletions Finance/Quotes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,16 @@ public static async Task<List<Candle>> GetQuotesAround(
{
lookAround = Math.Max(lookAround, 1);
var start = earningsDate.Date;
var end = start.AddDays(1);
if (earningsDate.DateType != "BMO")
lookAround -= 1;
for (var i = 0; i < lookAround; i++)
var end = earningsDate.Date.AddDays(1);
while (Util.IsHoliday(end))
end = end.AddDays(1);
if (earningsDate.DateType == "BMO") {
start = earningsDate.Date.AddDays(-1);
while (Util.IsHoliday(start))
start = start.AddDays(-1);
end = earningsDate.Date;
}
for (var i = 1; i < lookAround; i++)
{
start = start.AddDays(-1);
while (Util.IsHoliday(start))
Expand Down
21 changes: 13 additions & 8 deletions notebooks/demo.dib
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#!csharp

#r "nuget: CosminSanda.Finance"
#r "nuget: ScottPlot"
#r "nuget: XPlot.Plotly.Interactive"
#r "nuget: CsvHelper"
#r "nuget: ServiceStack.Text"

#!csharp

using System.Linq;
using XPlot.Plotly;
using CosminSanda.Finance;
using CosminSanda.Finance.Records;

Expand All @@ -29,13 +29,18 @@ var quotes = await Quotes.GetQuotesAround("TWTR", lastDate, 3);

#!csharp

using Microsoft.DotNet.Interactive.Formatting;
var chart4 = Chart.Candlestick(quotes.Select(o => new Tuple<string, double, double, double, double>(
o.Date.ToDateTime(TimeOnly.Parse("10:00 PM")).ToString("yyyy-MM-dd"),
o.Open,
o.High,
o.Low,
o.Close
)));

Formatter.Register(typeof(ScottPlot.Plot), (plt, writer) =>
writer.Write(((ScottPlot.Plot)plt).GetImageHTML()), HtmlFormatter.MimeType);
chart4.WithLayout(new Layout.Layout{
title="OHLC"
});

#!csharp

var plt = new ScottPlot.Plot(600, 400);

plt.AddCandlesticks(prices);
chart4

0 comments on commit 99047e6

Please sign in to comment.