This repository has been archived by the owner on May 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab109aa
commit 23ba59a
Showing
16 changed files
with
454 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,20 @@ | ||
# PLACEHOLDER | ||
TODO: Add .NET projects to the *src* folder and run `docfx` to generate **REAL** *API Documentation*! | ||
# Installation | ||
|
||
## dotnet-interactive | ||
|
||
In a `dotnet-interactive` notebook, the library can be installed with | ||
|
||
```csharp | ||
#r "nuget: CosminSanda.Finance" | ||
``` | ||
|
||
Although transient dependencies should be installed as well, in the notebook context that does not seem to the case, so ou might also need to run: | ||
|
||
```csharp | ||
#r "nuget: CsvHelper" | ||
#r "nuget: ServiceStack.Text" | ||
``` | ||
|
||
## .NET project | ||
|
||
The ubiquitous `Install-Package CosminSanda.Finance`. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#- name: Articles | ||
# href: articles/ | ||
- name: Tutorials | ||
href: tutorials/ | ||
- name: Api Documentation | ||
href: api/ | ||
homepage: api/index.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
## 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. | ||
|
||
|
||
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 an asceding ordered list of all Tesla earnings dates. | ||
|
||
```csharp | ||
var earnings = await EarningsCalendar.GetPastEarningsDates("TSLA"); | ||
``` | ||
|
||
We'll exemplify using just the latest earnings call date. | ||
|
||
```csharp | ||
var lastDate = earnings.Last(); | ||
``` | ||
|
||
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); | ||
``` | ||
|
||
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. | ||
|
||
```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 | ||
``` | ||
|
||
You should see something similar to this: | ||
|
||
![Tesla earnings call](../images/tesla.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Here you can find end-to-end sample of using the library. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- name: Introduction | ||
href: intro.md | ||
- name: dotnet-interactive | ||
href: dotnet-interactive.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,65 @@ | ||
#!markdown | ||
|
||
#### Install the latest version of the package | ||
## Tesla earnings | ||
|
||
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. | ||
|
||
|
||
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" | ||
|
||
#!csharp | ||
|
||
using XPlot.Plotly; | ||
using CosminSanda.Finance; | ||
|
||
#!markdown | ||
|
||
Get an asceding ordered list of all Tesla earnings dates. | ||
|
||
#!csharp | ||
|
||
var earnings = await EarningsCalendar.GetPastEarningsDates("TWTR"); | ||
var earnings = await EarningsCalendar.GetPastEarningsDates("TSLA"); | ||
|
||
#!markdown | ||
|
||
We'll exemplify using just the latest earnings call date. | ||
|
||
#!csharp | ||
|
||
var lastDate = earnings.Last(); | ||
|
||
#!markdown | ||
|
||
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("TWTR", lastDate, 3); | ||
var quotes = await Quotes.GetQuotesAround("TSLA", lastDate, 5); | ||
|
||
#!markdown | ||
|
||
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. | ||
|
||
#!csharp | ||
|
||
Chart | ||
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 | ||
))) | ||
.WithLayout(new Layout.Layout{ | ||
title="OHLC" | ||
}) | ||
))); | ||
chart.WithLayout(new Layout.Layout{ | ||
title=$"Tesla earnings on {lastDate.Date}" | ||
}); | ||
chart |
Oops, something went wrong.