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

Commit

Permalink
Documentation (#7)
Browse files Browse the repository at this point in the history
fx
  • Loading branch information
cosmincatalin committed Sep 29, 2022
1 parent b1ed845 commit 80480cf
Show file tree
Hide file tree
Showing 14 changed files with 250 additions and 29 deletions.
4 changes: 3 additions & 1 deletion .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"k--kato.docomment",
"edwinsulaiman.jetbrains-rider-dark-theme",
"obrejla.netbeans-light-theme",
"editorconfig.editorconfig"
"editorconfig.editorconfig",
"streetsidesoftware.code-spell-checker",
"ms-dotnettools.dotnet-interactive-vscode"
]
}
32 changes: 29 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,32 @@ jobs:
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage"
- name: Code coverage
uses: codecov/codecov-action@v3.1.0
run: dotnet test --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov
- name: Publish coverage report to coveralls.io
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./Tests/TestResults/coverage.info

documentation:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.x.x
- name: Setup DocFX
uses: crazy-max/ghaction-chocolatey@v1
with:
args: install docfx
- name: DocFX Build
working-directory: docfx_project
run: docfx .\docfx.json
continue-on-error: false
- name: Publish
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docfx_project/_site
force_orphan: true
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ riderModule.iml
.idea/
finance.sln.DotSettings.user
.vs
.vscode
.vscode
Tests/TestResults/**
_exported_templates/*
5 changes: 3 additions & 2 deletions 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.0.0</version>
<version>1.0.1</version>
<title>Yahoo Earnings Calendar</title>
<authors>Cosmin Catalin Sanda</authors>
<owners>cosmincatalin</owners>
Expand All @@ -15,8 +15,9 @@
<tags>finance scraper</tags>
<dependencies>
<group>
<dependency id="CsvHelper" version="28.0.1" />
<dependency id="Newtonsoft.Json" version="13.0.1" />
<dependency id="ServiceStack.Text" version="6.2.0" />
<dependency id="ServiceStack.Text" version="6.3.0" />
</group>
<group targetFramework="net6.0" />
</dependencies>
Expand Down
41 changes: 33 additions & 8 deletions Finance/EarningsCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,25 @@
namespace CosminSanda.Finance;

/// <summary>
/// The main class that should be utilized to get information about earnings releases
/// A static class that provides methods for retrieving information around earnings calls.
/// </summary>
public static class EarningsCalendar
{
/// <summary>
/// Get a list of companies that report earnings on a specific day.
/// </summary>
/// <example>
/// In this example we get a list of companies that report on 2022-09-28
/// <code language="c#">
/// using CosminSanda.Finance;
///
/// var companies = await EarningsCalendar
/// .GetCompaniesReporting(new DateTime(year: 2022, month: 9, day: 28));
/// companies.ForEach(Console.WriteLine);
/// </code>
/// </example>
/// <param name="day">The day for which you want to know the companies reporting earnings</param>
/// <returns>A list of financial instruments</returns>
/// <returns>A list of companies</returns>
public static async Task<List<FinancialInstrument>> GetCompaniesReporting(DateTime day)
{
var date = DateOnly.FromDateTime(day);
Expand All @@ -25,9 +35,18 @@ public static async Task<List<FinancialInstrument>> GetCompaniesReporting(DateTi
}

/// <summary>
/// Given a financial instrument, get the list of past ER dates available on Yahoo Finance.
/// Given a financial instrument, get the list of past earnings releases dates available on Yahoo Finance.
/// </summary>
/// <param name="ticker">The financial instrument's ticker as used on Yahoo Finance.</param>
/// <example>
/// In this example we get past earnings calls dates for the Microsoft Corporation.
/// <code language="c#">
/// using CosminSanda.Finance;
///
/// var earnings = await EarningsCalendar.GetPastEarningsDates("msft");
/// earnings.ForEach(Console.WriteLine);
/// </code>
/// </example>
/// <param name="ticker">The financial instrument's ticker as used on Yahoo Finance. The case is not important.</param>
/// <returns>A list of calendar dates</returns>
public static async Task<List<EarningsDate>> GetPastEarningsDates(string ticker)
{
Expand All @@ -45,9 +64,16 @@ public static async Task<List<EarningsDate>> GetPastEarningsDates(string ticker)
/// <summary>
/// A method to get the next estimated(or set) earnings release call.
/// </summary>
/// <param name="ticker"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
/// <example>
/// <code language="c#">
/// using CosminSanda.Finance;
///
/// var earning = await EarningsCalendar.GetNextEarningsDate("msft");
/// Console.WriteLine(earning);
/// </code>
/// </example>
/// <param name="ticker">The financial instrument's ticker as used on Yahoo Finance. The case is not important.</param>
/// <returns>An earnings date in the future</returns>
public static async Task<EarningsDate> GetNextEarningsDate(string ticker)
{
var financialInstrument = new FinancialInstrument { Ticker = ticker };
Expand All @@ -59,7 +85,6 @@ public static async Task<EarningsDate> GetNextEarningsDate(string ticker)
.Select(o => o.EarningsDate)
.OrderBy(o => o.Date)
.Take(1)
.ToList()
.First();
}
}
18 changes: 12 additions & 6 deletions Finance/Quotes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
namespace CosminSanda.Finance;

/// <summary>
/// Contains methods for retrieving quotes (prices) on selected days for selected companies.
/// Contains methods for retrieving daily quotes (prices) for selected companies.
/// </summary>
public static class Quotes
{
/// <summary>
/// Retrieve the day Candles for an instrument during a time interval.
/// Retrieve the Japanese candles for each day of a time interval for a specified company.
/// </summary>
/// <param name="ticker">The financial instrument's ticker as used on Yahoo Finance.</param>
/// <param name="startDate">The day from when you start retrieving the quotes, inclusive.</param>
Expand Down Expand Up @@ -103,10 +103,16 @@ string endDate
{
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/CosminSanda.Finance?style=plastic)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/cosmincatalin/finance-library/Test)
[![codecov](https://codecov.io/gh/cosmincatalin/finance-library/branch/retaliator/graph/badge.svg?token=76WWB6P86W)](https://codecov.io/gh/cosmincatalin/finance-library)
[![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.

Expand Down
4 changes: 4 additions & 0 deletions Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="3.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="nunit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
Expand Down
4 changes: 3 additions & 1 deletion docfx_project/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
}
],
"dest": "api",
"filter": "filter.yaml",
"disableGitFeatures": false,
"disableDefaultFilter": false
}
Expand Down Expand Up @@ -53,7 +54,8 @@
"globalMetadataFiles": [],
"fileMetadataFiles": [],
"template": [
"default"
"default",
"templates/custom"
],
"postProcessors": [],
"markdownEngineName": "markdig",
Expand Down
3 changes: 3 additions & 0 deletions docfx_project/filter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
apiRules:
- exclude:
uidRegex: ^CosminSanda\.Finance\.JsonConverters
25 changes: 21 additions & 4 deletions docfx_project/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
# This is the **HOMEPAGE**.
Refer to [Markdown](http://daringfireball.net/projects/markdown/) for how to write markdown files.
## Quick Start Notes:
1. Add images to the *images* folder if the file is referencing an image.
# CosminSanda.Finance

## Description

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.

## How to run

There are two ways you can use this library.

* As a dependency of a dotnet application/class library.
* Inside a `dotnet-interactive` notebook.
87 changes: 87 additions & 0 deletions docfx_project/templates/custom/partials/class.header.tmpl.partial
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}}

<h1 id="{{id}}" data-uid="{{uid}}" class="text-break">{{>partials/title}}</h1>
<div class="markdown level0 summary">{{{summary}}}</div>
<div class="markdown level0 conceptual">{{{conceptual}}}</div>
{{#implements.0}}
<div class="implements">
<h5>{{__global.implements}}</h5>
{{/implements.0}}
{{#implements}}
<div>{{{specName.0.value}}}</div>
{{/implements}}
{{#implements.0}}
</div>
{{/implements.0}}
<h6><strong>{{__global.namespace}}</strong>: {{{namespace.specName.0.value}}}</h6>
{{#syntax.parameters.0}}
<h5 class="parameters">{{__global.parameters}}</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>{{__global.type}}</th>
<th>{{__global.name}}</th>
<th>{{__global.description}}</th>
</tr>
</thead>
<tbody>
{{/syntax.parameters.0}}
{{#syntax.parameters}}
<tr>
<td>{{{type.specName.0.value}}}</td>
<td><span class="parametername">{{{id}}}</span></td>
<td>{{{description}}}</td>
</tr>
{{/syntax.parameters}}
{{#syntax.parameters.0}}
</tbody>
</table>
{{/syntax.parameters.0}}
{{#syntax.return}}
<h5 class="returns">{{__global.returns}}</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>{{__global.type}}</th>
<th>{{__global.description}}</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{{type.specName.0.value}}}</td>
<td>{{{description}}}</td>
</tr>
</tbody>
</table>
{{/syntax.return}}
{{#syntax.typeParameters.0}}
<h5 class="typeParameters">{{__global.typeParameters}}</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>{{__global.name}}</th>
<th>{{__global.description}}</th>
</tr>
</thead>
<tbody>
{{/syntax.typeParameters.0}}
{{#syntax.typeParameters}}
<tr>
<td><span class="parametername">{{{id}}}</span></td>
<td>{{{description}}}</td>
</tr>
{{/syntax.typeParameters}}
{{#syntax.typeParameters.0}}
</tbody>
</table>
{{/syntax.typeParameters.0}}
{{#remarks}}
<h5 id="{{id}}_remarks"><strong>{{__global.remarks}}</strong></h5>
<div class="markdown level0 remarks">{{{remarks}}}</div>
{{/remarks}}
{{#example.0}}
<h5 id="{{id}}_examples"><strong>{{__global.examples}}</strong></h5>
{{/example.0}}
{{#example}}
{{{.}}}
{{/example}}
4 changes: 2 additions & 2 deletions docfx_project/toc.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- name: Articles
href: articles/
#- name: Articles
# href: articles/
- name: Api Documentation
href: api/
homepage: api/index.md
Loading

0 comments on commit 80480cf

Please sign in to comment.