diff --git a/Finance/.nuspec b/Finance/.nuspec index d31ace0..809c97a 100644 --- a/Finance/.nuspec +++ b/Finance/.nuspec @@ -2,7 +2,7 @@ CosminSanda.Finance - 1.1.0 + 1.1.1 Yahoo Earnings Calendar Cosmin Catalin Sanda cosmincatalin diff --git a/README.md b/README.md index 09ee89d..7c0c9f4 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,20 @@ ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/cosmincatalin/finance-library/Test) [![Coverage Status](https://coveralls.io/repos/github/cosmincatalin/finance-library/badge.svg?branch=master)](https://coveralls.io/github/cosmincatalin/finance-library?branch=master) -A small library that can be used to easily scrape information about Earnings Releases and financial quotes from Yahoo Finance. +This package simplifies the process of retrieving data from Yahoo Finance. +Currently, it can fetch information about earnings calls and about daily quotes. + +This package can be used, typically, to analyze the price action around historical earnings calls for the purpose +of establishing strategies for future earnings releases a.k.a "Playing the Earnings". + +The package acts as a proxy to Yahoo Finance and is essentially a web scraper. +While in previous versions, caching was built in, it has been removed. +That means all methods make requests directly to Yahoo Finance and it is your responsibility to cache the data so as to avoid redundant requests. +The reason for disabling the cache has to do with the lack of guarantees regarding the provided data which can lead to inconsistencies for less popular instruments. + +Methods are made static to make it easier to use from interactive environments. +That is also the reason why there aren't a lot of options for Dependencies Injection of, for example, logging. +To further simplify the use of methods in the package, arguments are passed using basic types like `string` and `int32`. ## Installation @@ -22,31 +35,62 @@ A small library that can be used to easily scrape information about Earnings Rel #r "nuget,CosminSanda.Finance" ``` -## Usage +## Sample usage + +## Tesla earnings + +The code blocks in this tutorials should be executed as part of a `dotnet-interactive` notebook. + +In this example, we look at the price action before and after the last Tesla earnings. The number of days analyzed is always even, the first half of the days are from before the earnings call and the reminder are from after the earnings results have been released. -### Get a list of dates when the earnings for a symbol are released -```c# -var earnings = await EarningsCalendar.GetEarnings("ZTO"); +Although `CsvHelper` and `ServiceStack.Text` should be installed as transient dependencies, they are not, so in the notebook, they have to be installed individually. + +```csharp +#r "nuget: CosminSanda.Finance" +#r "nuget: XPlot.Plotly.Interactive" +#r "nuget: CsvHelper" +#r "nuget: ServiceStack.Text" ``` -### Get a list of financial stats in a selected date interval for a symbol +Get an ascending ordered list of all Tesla earnings dates. -```c# -var earnings = await Quotes.GetQuotes("ZTO", "2020-01-01", "2020-01-15"); +```csharp +var earnings = await EarningsCalendar.GetPastEarningsDates("TSLA"); ``` -### Get a list of financial stats around an earning date for a symbol +We'll exemplify using just the latest earnings call date. + +```csharp +var lastDate = earnings.Last(); +``` -The method will take into account if the earnings date is after or before market close. -If not specified, it will be considered to be after market close. +Get the OHLC data for 5 days before and 5 days after the earnings call. +The earnings call can take place before market open (in which case the date of the earnings call is included in the last 5 days) or after market close (in which case the date of the earnings call is included in the first 5 days). + +```csharp +var quotes = await Quotes.GetQuotesAround("TSLA", lastDate, 5); +``` -```c# -var quotes = await Quotes.GetQuotesAround("ZTO", earningsDate: earnings[6], lookAround: 3); +Use a charting library to vizualise the data and get a feel of how the earnings call expectations and actual results influence the price action. + +In the case of the Tesla earnings release on 20th of July 2022, it's obvious that the call happened after market close, so the 20th is part of the "before earnings" half of the candles. + +```csharp +var chart = Chart + .Candlestick(quotes.Select(o => new Tuple( + o.Date.ToDateTime(TimeOnly.Parse("10:00 PM")).ToString("yyyy-MM-dd"), + o.Open, + o.High, + o.Low, + o.Close + ))); +chart.WithLayout(new Layout.Layout{ + title=$"Tesla earnings on {lastDate.Date}" +}); +chart ``` -### Get the next earnings date for a symbol +You should see something similar to this: -```c# -var nextEarnings = await EarningsCalendar.GetNextEarningsDate("ZTO"); -``` \ No newline at end of file +![Tesla earnings call](docfx_project/images/tesla.png) \ No newline at end of file diff --git a/docfx_project/tutorials/dotnet-interactive.md b/docfx_project/tutorials/dotnet-interactive.md index e60f18b..badee51 100644 --- a/docfx_project/tutorials/dotnet-interactive.md +++ b/docfx_project/tutorials/dotnet-interactive.md @@ -14,7 +14,7 @@ Although `CsvHelper` and `ServiceStack.Text` should be installed as transient de #r "nuget: ServiceStack.Text" ``` -Get an asceding ordered list of all Tesla earnings dates. +Get an ascending ordered list of all Tesla earnings dates. ```csharp var earnings = await EarningsCalendar.GetPastEarningsDates("TSLA"); @@ -35,7 +35,7 @@ var quotes = await Quotes.GetQuotesAround("TSLA", lastDate, 5); Use a charting library to vizualise the data and get a feel of how the earnings call expectations and actual results influence the price action. -In the case of the Tesla earnings release on 20th of July 2022, it's obvious that the call happened after market close, so the 20th is part of the "before earnings" half of the cancles. +In the case of the Tesla earnings release on 20th of July 2022, it's obvious that the call happened after market close, so the 20th is part of the "before earnings" half of the candles. ```csharp var chart = Chart