-
Notifications
You must be signed in to change notification settings - Fork 22
feat: add financial growth api #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Matthiee
merged 2 commits into
MatthiWare:master
from
scott-david-walker:financial-growth-api
Jan 13, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
12 changes: 12 additions & 0 deletions
12
FinancialModelingPrepApi/Abstractions/StatementAnalysis/IStatementAnalysisProvider.cs
This file contains hidden or 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,12 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using MatthiWare.FinancialModelingPrep.Model; | ||
using MatthiWare.FinancialModelingPrep.Model.StatementAnalysis; | ||
|
||
namespace MatthiWare.FinancialModelingPrep.Abstractions.StatementAnalysis; | ||
|
||
public interface IStatementAnalysisProvider | ||
{ | ||
public Task<ApiResponse<List<FinancialGrowthResponse>>> GetFinancialGrowthAsync(string symbol, | ||
Period period = Period.Annual, int? limit = 30); | ||
} |
This file contains hidden or 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
43 changes: 43 additions & 0 deletions
43
FinancialModelingPrepApi/Core/StatementAnalysis/StatementAnalysisProvider.cs
This file contains hidden or 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,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Specialized; | ||
using System.Threading.Tasks; | ||
using MatthiWare.FinancialModelingPrep.Abstractions.StatementAnalysis; | ||
using MatthiWare.FinancialModelingPrep.Core.Http; | ||
using MatthiWare.FinancialModelingPrep.Model; | ||
using MatthiWare.FinancialModelingPrep.Model.StatementAnalysis; | ||
|
||
namespace MatthiWare.FinancialModelingPrep.Core.StatementAnalysis; | ||
|
||
public class StatementAnalysisProvider : IStatementAnalysisProvider | ||
{ | ||
private readonly FinancialModelingPrepHttpClient client; | ||
|
||
public StatementAnalysisProvider(FinancialModelingPrepHttpClient client) | ||
{ | ||
this.client = client ?? throw new ArgumentNullException(nameof(client)); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public Task<ApiResponse<List<FinancialGrowthResponse>>> GetFinancialGrowthAsync(string symbol, Period period = Period.Annual, int? limit = 30) | ||
{ | ||
const string url = "[version]/financial-growth/[symbol]"; | ||
|
||
var pathParams = new NameValueCollection() | ||
{ | ||
{ "version", ApiVersion.v3.ToString() }, | ||
{ "symbol", symbol }, | ||
}; | ||
|
||
var queryString = new QueryStringBuilder(); | ||
|
||
queryString.Add("period", period.ToString().ToLower()); | ||
|
||
if (limit != null) | ||
{ | ||
queryString.Add("limit", limit); | ||
} | ||
|
||
return client.GetJsonAsync<List<FinancialGrowthResponse>>(url, pathParams, queryString); | ||
} | ||
} |
This file contains hidden or 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
78 changes: 78 additions & 0 deletions
78
FinancialModelingPrepApi/Model/StatementAnalysis/FinancialGrowthResponse.cs
This file contains hidden or 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,78 @@ | ||
using System; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace MatthiWare.FinancialModelingPrep.Model.StatementAnalysis; | ||
|
||
public class FinancialGrowthResponse | ||
{ | ||
[JsonPropertyName("symbol")] | ||
public string Symbol { get; set; } | ||
[JsonPropertyName("date")] | ||
public DateOnly Date { get; set; } | ||
[JsonPropertyName("calendarYear")] | ||
public string CalendarYear { get; set; } | ||
[JsonPropertyName("period")] | ||
public string Period { get; set; } | ||
[JsonPropertyName("revenueGrowth")] | ||
public double? RevenueGrowth { get; set; } | ||
[JsonPropertyName("grossProfitGrowth")] | ||
public double? GrossProfitGrowth { get; set; } | ||
[JsonPropertyName("ebitgrowth")] | ||
public double? EarningsBeforeInterestAndTaxes { get; set; } | ||
[JsonPropertyName("operatingIncomeGrowth")] | ||
public double? OperatingIncomeGrowth { get; set; } | ||
[JsonPropertyName("netIncomeGrowth")] | ||
public double? NetIncomeGrowth { get; set; } | ||
[JsonPropertyName("epsGrowth")] | ||
public double? EarningsPerShareGrowth { get; set; } | ||
[JsonPropertyName("epsDilutedGrowth")] | ||
public double? EarningsPerShareDilutedGrowth { get; set; } | ||
[JsonPropertyName("weightedAverageSharesGrowth")] | ||
public double? WeightedAverageSharesGrowth { get; set; } | ||
[JsonPropertyName("weightedAverageSharesDilutedGrowth")] | ||
public double? WeightedAverageSharesDilutedGrowth { get; set; } | ||
[JsonPropertyName("dividendsperShareGrowth")] | ||
public double? DividendsPerShareGrowth { get; set; } | ||
[JsonPropertyName("operatingCashFlowGrowth")] | ||
public double? OperatingCashFlowGrowth { get; set; } | ||
[JsonPropertyName("freeCashFlowGrowth")] | ||
public double? FreeCashFlowGrowth { get; set; } | ||
[JsonPropertyName("tenYRevenueGrowthPerShare")] | ||
public double? TenYearRevenueGrowthPerShare { get; set; } | ||
[JsonPropertyName("fiveYRevenueGrowthPerShare")] | ||
public double? FiveYearRevenueGrowthPerShare { get; set; } | ||
[JsonPropertyName("threeYOperatingCFGrowthPerShare")] | ||
public double? ThreeYearOperatingCFGrowthPerShare { get; set; } | ||
[JsonPropertyName("tenYNetIncomeGrowthPerShare")] | ||
public double? TenYearNetIncomeGrowthPerShare { get; set; } | ||
[JsonPropertyName("fiveYNetIncomeGrowthPerShare")] | ||
public double? FiveYearNetIncomeGrowthPerShare { get; set; } | ||
[JsonPropertyName("threeYNetIncomeGrowthPerShare")] | ||
public double? ThreeYearNetIncomeGrowthPerShare { get; set; } | ||
[JsonPropertyName("tenYShareholdersEquityGrowthPerShare")] | ||
public double? TenYearShareholdersEquityGrowthPerShare { get; set; } | ||
[JsonPropertyName("fiveYShareholdersEquityGrowthPerShare")] | ||
public double? FiveYearShareholdersEquityGrowthPerShare { get; set; } | ||
[JsonPropertyName("threeYShareholdersEquityGrowthPerShare")] | ||
public double? ThreeYearShareholdersEquityGrowthPerShare { get; set; } | ||
[JsonPropertyName("tenYDividendperShareGrowthPerShare")] | ||
public double? TenYearDividendPerShareGrowthPerShare { get; set; } | ||
[JsonPropertyName("fiveYDividendperShareGrowthPerShare")] | ||
public double? FiveYearDividendPerShareGrowthPerShare { get; set; } | ||
[JsonPropertyName("threeYDividendperShareGrowthPerShare")] | ||
public double? ThreeYearDividendPerShareGrowthPerShare { get; set; } | ||
[JsonPropertyName("receivablesGrowth")] | ||
public double? ReceivablesGrowth { get; set; } | ||
[JsonPropertyName("inventoryGrowth")] | ||
public double? InventoryGrowth { get; set; } | ||
[JsonPropertyName("assetGrowth")] | ||
public double? AssetGrowth { get; set; } | ||
[JsonPropertyName("bookValueperShareGrowth")] | ||
public double? BookValuePerShareGrowth { get; set; } | ||
[JsonPropertyName("debtGrowth")] | ||
public double? DebtGrowth { get; set; } | ||
[JsonPropertyName("rdexpenseGrowth")] | ||
public double? ResearchAndDevelopmentExpenseGrowth { get; set; } | ||
[JsonPropertyName("sgaexpensesGrowth")] | ||
public double? SellingGeneralAdminExpensesGrowth { get; set; } | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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,43 @@ | ||
using System.Threading.Tasks; | ||
using MatthiWare.FinancialModelingPrep.Abstractions.StatementAnalysis; | ||
using MatthiWare.FinancialModelingPrep.Model; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Tests.StatementAnalysis; | ||
|
||
public class StatementAnalysisTests: TestingBase | ||
{ | ||
private readonly IStatementAnalysisProvider api; | ||
|
||
public StatementAnalysisTests(ITestOutputHelper testOutput) : base(testOutput) | ||
{ | ||
api = ServiceProvider.GetRequiredService<IStatementAnalysisProvider>(); | ||
} | ||
|
||
[Fact] | ||
public async Task GetFinancialGrowthWithLimit() | ||
{ | ||
var result = await api.GetFinancialGrowthAsync("AAPL", Period.Annual, 1); | ||
result.AssertNoErrors(); | ||
Assert.NotEmpty(result.Data); | ||
Assert.Single(result.Data); | ||
} | ||
|
||
[Fact] | ||
public async Task GetFinancialGrowthAnnual() | ||
{ | ||
var result = await api.GetFinancialGrowthAsync("AAPL"); | ||
result.AssertNoErrors(); | ||
Assert.NotEmpty(result.Data); | ||
} | ||
|
||
[Fact] | ||
public async Task GetFinancialGrowthQuarterly() | ||
{ | ||
var result = await api.GetFinancialGrowthAsync("AAPL", Period.Quarter); | ||
result.AssertNoErrors(); | ||
Assert.NotEmpty(result.Data); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.