Skip to content

Commit 03fd7de

Browse files
feat: add financial growth api (#136)
* feat: add financial growth api * fix: spelling mistake in net income growth. Updated tests for factory
1 parent 7139f78 commit 03fd7de

File tree

9 files changed

+207
-2
lines changed

9 files changed

+207
-2
lines changed

FinancialModelingPrepApi/Abstractions/IFinancialModelingPrepApiClient.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using MatthiWare.FinancialModelingPrep.Abstractions.Fund;
77
using MatthiWare.FinancialModelingPrep.Abstractions.InstitutionalFund;
88
using MatthiWare.FinancialModelingPrep.Abstractions.MarketIndexes;
9+
using MatthiWare.FinancialModelingPrep.Abstractions.StatementAnalysis;
910
using MatthiWare.FinancialModelingPrep.Abstractions.Statistics;
1011
using MatthiWare.FinancialModelingPrep.Abstractions.StockMarket;
1112
using MatthiWare.FinancialModelingPrep.Abstractions.StockTimeSeries;
@@ -76,5 +77,11 @@ public interface IFinancialModelingPrepApiClient
7677
/// - Economic indicators
7778
/// </summary>
7879
public IEconomicsProvider Economics { get; }
80+
81+
/// <summary>
82+
/// Statement Analysis related endpoints
83+
/// - Financial Growth
84+
/// </summary>
85+
public IStatementAnalysisProvider StatementAnalysis { get; }
7986
}
8087
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using MatthiWare.FinancialModelingPrep.Model;
4+
using MatthiWare.FinancialModelingPrep.Model.StatementAnalysis;
5+
6+
namespace MatthiWare.FinancialModelingPrep.Abstractions.StatementAnalysis;
7+
8+
public interface IStatementAnalysisProvider
9+
{
10+
public Task<ApiResponse<List<FinancialGrowthResponse>>> GetFinancialGrowthAsync(string symbol,
11+
Period period = Period.Annual, int? limit = 30);
12+
}

FinancialModelingPrepApi/Core/FinancialModelingPrepApiClient.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using MatthiWare.FinancialModelingPrep.Abstractions.Fund;
77
using MatthiWare.FinancialModelingPrep.Abstractions.InstitutionalFund;
88
using MatthiWare.FinancialModelingPrep.Abstractions.MarketIndexes;
9+
using MatthiWare.FinancialModelingPrep.Abstractions.StatementAnalysis;
910
using MatthiWare.FinancialModelingPrep.Abstractions.Statistics;
1011
using MatthiWare.FinancialModelingPrep.Abstractions.StockMarket;
1112
using MatthiWare.FinancialModelingPrep.Abstractions.StockTimeSeries;
@@ -48,6 +49,8 @@ public class FinancialModelingPrepApiClient : IFinancialModelingPrepApiClient
4849
/// <inheritdoc/>
4950
public IEconomicsProvider Economics { get; }
5051

52+
public IStatementAnalysisProvider StatementAnalysis { get; }
53+
5154
/// <inheritdoc/>
5255
public FinancialModelingPrepApiClient(ICompanyValuationProvider companyValuation,
5356
IMarketIndexesProvider marketIndexes,
@@ -59,7 +62,8 @@ public FinancialModelingPrepApiClient(ICompanyValuationProvider companyValuation
5962
IStockStatisticsProvider stockStatistics,
6063
ICryptoMarketProvider cryptoMarket,
6164
IFundProvider fund,
62-
IEconomicsProvider economics)
65+
IEconomicsProvider economics,
66+
IStatementAnalysisProvider statementAnalysis)
6367
{
6468
CompanyValuation = companyValuation;
6569
MarketIndexes = marketIndexes;
@@ -72,6 +76,7 @@ public FinancialModelingPrepApiClient(ICompanyValuationProvider companyValuation
7276
Crypto = cryptoMarket;
7377
Fund = fund;
7478
Economics = economics;
79+
StatementAnalysis = statementAnalysis;
7580
}
7681
}
7782
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.Specialized;
4+
using System.Threading.Tasks;
5+
using MatthiWare.FinancialModelingPrep.Abstractions.StatementAnalysis;
6+
using MatthiWare.FinancialModelingPrep.Core.Http;
7+
using MatthiWare.FinancialModelingPrep.Model;
8+
using MatthiWare.FinancialModelingPrep.Model.StatementAnalysis;
9+
10+
namespace MatthiWare.FinancialModelingPrep.Core.StatementAnalysis;
11+
12+
public class StatementAnalysisProvider : IStatementAnalysisProvider
13+
{
14+
private readonly FinancialModelingPrepHttpClient client;
15+
16+
public StatementAnalysisProvider(FinancialModelingPrepHttpClient client)
17+
{
18+
this.client = client ?? throw new ArgumentNullException(nameof(client));
19+
}
20+
21+
/// <inheritdoc/>
22+
public Task<ApiResponse<List<FinancialGrowthResponse>>> GetFinancialGrowthAsync(string symbol, Period period = Period.Annual, int? limit = 30)
23+
{
24+
const string url = "[version]/financial-growth/[symbol]";
25+
26+
var pathParams = new NameValueCollection()
27+
{
28+
{ "version", ApiVersion.v3.ToString() },
29+
{ "symbol", symbol },
30+
};
31+
32+
var queryString = new QueryStringBuilder();
33+
34+
queryString.Add("period", period.ToString().ToLower());
35+
36+
if (limit != null)
37+
{
38+
queryString.Add("limit", limit);
39+
}
40+
41+
return client.GetJsonAsync<List<FinancialGrowthResponse>>(url, pathParams, queryString);
42+
}
43+
}

FinancialModelingPrepApi/DependencyInjectionExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
using Microsoft.Extensions.DependencyInjection;
2727
using Microsoft.Extensions.DependencyInjection.Extensions;
2828
using System;
29+
using MatthiWare.FinancialModelingPrep.Abstractions.StatementAnalysis;
30+
using MatthiWare.FinancialModelingPrep.Core.StatementAnalysis;
2931

3032
namespace MatthiWare.FinancialModelingPrep
3133
{
@@ -59,6 +61,7 @@ public static void AddFinancialModelingPrepApiClient(this IServiceCollection ser
5961
services.TryAddTransient<IStockStatisticsProvider, StockStatisticsProvider>();
6062
services.TryAddTransient<IFundProvider, FundProvider>();
6163
services.TryAddTransient<IEconomicsProvider, EconomicsProvider>();
64+
services.TryAddTransient<IStatementAnalysisProvider, StatementAnalysisProvider>();
6265
}
6366
}
6467
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
using System;
2+
using System.Text.Json.Serialization;
3+
4+
namespace MatthiWare.FinancialModelingPrep.Model.StatementAnalysis;
5+
6+
public class FinancialGrowthResponse
7+
{
8+
[JsonPropertyName("symbol")]
9+
public string Symbol { get; set; }
10+
[JsonPropertyName("date")]
11+
public DateOnly Date { get; set; }
12+
[JsonPropertyName("calendarYear")]
13+
public string CalendarYear { get; set; }
14+
[JsonPropertyName("period")]
15+
public string Period { get; set; }
16+
[JsonPropertyName("revenueGrowth")]
17+
public double? RevenueGrowth { get; set; }
18+
[JsonPropertyName("grossProfitGrowth")]
19+
public double? GrossProfitGrowth { get; set; }
20+
[JsonPropertyName("ebitgrowth")]
21+
public double? EarningsBeforeInterestAndTaxes { get; set; }
22+
[JsonPropertyName("operatingIncomeGrowth")]
23+
public double? OperatingIncomeGrowth { get; set; }
24+
[JsonPropertyName("netIncomeGrowth")]
25+
public double? NetIncomeGrowth { get; set; }
26+
[JsonPropertyName("epsGrowth")]
27+
public double? EarningsPerShareGrowth { get; set; }
28+
[JsonPropertyName("epsDilutedGrowth")]
29+
public double? EarningsPerShareDilutedGrowth { get; set; }
30+
[JsonPropertyName("weightedAverageSharesGrowth")]
31+
public double? WeightedAverageSharesGrowth { get; set; }
32+
[JsonPropertyName("weightedAverageSharesDilutedGrowth")]
33+
public double? WeightedAverageSharesDilutedGrowth { get; set; }
34+
[JsonPropertyName("dividendsperShareGrowth")]
35+
public double? DividendsPerShareGrowth { get; set; }
36+
[JsonPropertyName("operatingCashFlowGrowth")]
37+
public double? OperatingCashFlowGrowth { get; set; }
38+
[JsonPropertyName("freeCashFlowGrowth")]
39+
public double? FreeCashFlowGrowth { get; set; }
40+
[JsonPropertyName("tenYRevenueGrowthPerShare")]
41+
public double? TenYearRevenueGrowthPerShare { get; set; }
42+
[JsonPropertyName("fiveYRevenueGrowthPerShare")]
43+
public double? FiveYearRevenueGrowthPerShare { get; set; }
44+
[JsonPropertyName("threeYOperatingCFGrowthPerShare")]
45+
public double? ThreeYearOperatingCFGrowthPerShare { get; set; }
46+
[JsonPropertyName("tenYNetIncomeGrowthPerShare")]
47+
public double? TenYearNetIncomeGrowthPerShare { get; set; }
48+
[JsonPropertyName("fiveYNetIncomeGrowthPerShare")]
49+
public double? FiveYearNetIncomeGrowthPerShare { get; set; }
50+
[JsonPropertyName("threeYNetIncomeGrowthPerShare")]
51+
public double? ThreeYearNetIncomeGrowthPerShare { get; set; }
52+
[JsonPropertyName("tenYShareholdersEquityGrowthPerShare")]
53+
public double? TenYearShareholdersEquityGrowthPerShare { get; set; }
54+
[JsonPropertyName("fiveYShareholdersEquityGrowthPerShare")]
55+
public double? FiveYearShareholdersEquityGrowthPerShare { get; set; }
56+
[JsonPropertyName("threeYShareholdersEquityGrowthPerShare")]
57+
public double? ThreeYearShareholdersEquityGrowthPerShare { get; set; }
58+
[JsonPropertyName("tenYDividendperShareGrowthPerShare")]
59+
public double? TenYearDividendPerShareGrowthPerShare { get; set; }
60+
[JsonPropertyName("fiveYDividendperShareGrowthPerShare")]
61+
public double? FiveYearDividendPerShareGrowthPerShare { get; set; }
62+
[JsonPropertyName("threeYDividendperShareGrowthPerShare")]
63+
public double? ThreeYearDividendPerShareGrowthPerShare { get; set; }
64+
[JsonPropertyName("receivablesGrowth")]
65+
public double? ReceivablesGrowth { get; set; }
66+
[JsonPropertyName("inventoryGrowth")]
67+
public double? InventoryGrowth { get; set; }
68+
[JsonPropertyName("assetGrowth")]
69+
public double? AssetGrowth { get; set; }
70+
[JsonPropertyName("bookValueperShareGrowth")]
71+
public double? BookValuePerShareGrowth { get; set; }
72+
[JsonPropertyName("debtGrowth")]
73+
public double? DebtGrowth { get; set; }
74+
[JsonPropertyName("rdexpenseGrowth")]
75+
public double? ResearchAndDevelopmentExpenseGrowth { get; set; }
76+
[JsonPropertyName("sgaexpensesGrowth")]
77+
public double? SellingGeneralAdminExpensesGrowth { get; set; }
78+
}

Tests/ClientFactoryTests.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class ClientFactoryTests
99

1010
public ClientFactoryTests()
1111
{
12-
this.api = FinancialModelingPrepApiClientFactory.CreateClient(new FinancialModelingPrepOptions());
12+
this.api = FinancialModelingPrepApiClientFactory.CreateClient(new());
1313
}
1414

1515
[Fact]
@@ -71,5 +71,11 @@ public void API_Contains_Economics_Provider()
7171
{
7272
Assert.NotNull(api.Economics);
7373
}
74+
75+
[Fact]
76+
public void API_Contains_StatementAnalysis_Provider()
77+
{
78+
Assert.NotNull(api.StatementAnalysis);
79+
}
7480
}
7581
}

Tests/ResolveApiTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,13 @@ public void API_Contains_Economics_Provider()
9898

9999
Assert.NotNull(api.Economics);
100100
}
101+
102+
[Fact]
103+
public void API_Contains_StatementAnalysis_Provider()
104+
{
105+
var api = ServiceProvider.GetRequiredService<IFinancialModelingPrepApiClient>();
106+
107+
Assert.NotNull(api.StatementAnalysis);
108+
}
101109
}
102110
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System.Threading.Tasks;
2+
using MatthiWare.FinancialModelingPrep.Abstractions.StatementAnalysis;
3+
using MatthiWare.FinancialModelingPrep.Model;
4+
using Microsoft.Extensions.DependencyInjection;
5+
using Xunit;
6+
using Xunit.Abstractions;
7+
8+
namespace Tests.StatementAnalysis;
9+
10+
public class StatementAnalysisTests: TestingBase
11+
{
12+
private readonly IStatementAnalysisProvider api;
13+
14+
public StatementAnalysisTests(ITestOutputHelper testOutput) : base(testOutput)
15+
{
16+
api = ServiceProvider.GetRequiredService<IStatementAnalysisProvider>();
17+
}
18+
19+
[Fact]
20+
public async Task GetFinancialGrowthWithLimit()
21+
{
22+
var result = await api.GetFinancialGrowthAsync("AAPL", Period.Annual, 1);
23+
result.AssertNoErrors();
24+
Assert.NotEmpty(result.Data);
25+
Assert.Single(result.Data);
26+
}
27+
28+
[Fact]
29+
public async Task GetFinancialGrowthAnnual()
30+
{
31+
var result = await api.GetFinancialGrowthAsync("AAPL");
32+
result.AssertNoErrors();
33+
Assert.NotEmpty(result.Data);
34+
}
35+
36+
[Fact]
37+
public async Task GetFinancialGrowthQuarterly()
38+
{
39+
var result = await api.GetFinancialGrowthAsync("AAPL", Period.Quarter);
40+
result.AssertNoErrors();
41+
Assert.NotEmpty(result.Data);
42+
}
43+
}

0 commit comments

Comments
 (0)