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

Commit

Permalink
Dev (#10)
Browse files Browse the repository at this point in the history
* doc

* sd

* s

* typo

* d
  • Loading branch information
cosmincatalin committed Oct 1, 2022
1 parent 23ba59a commit 0bd1d40
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Finance/.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>CosminSanda.Finance</id>
<version>1.1.0</version>
<version>1.1.1</version>
<title>Yahoo Earnings Calendar</title>
<authors>Cosmin Catalin Sanda</authors>
<owners>cosmincatalin</owners>
Expand Down
78 changes: 61 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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<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
)));
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");
```
![Tesla earnings call](docfx_project/images/tesla.png)
4 changes: 2 additions & 2 deletions docfx_project/tutorials/dotnet-interactive.md
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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
Expand Down

0 comments on commit 0bd1d40

Please sign in to comment.