Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using MatthiWare.FinancialModelingPrep.Abstractions.Fund;
using MatthiWare.FinancialModelingPrep.Abstractions.InstitutionalFund;
using MatthiWare.FinancialModelingPrep.Abstractions.MarketIndexes;
using MatthiWare.FinancialModelingPrep.Abstractions.StatementAnalysis;
using MatthiWare.FinancialModelingPrep.Abstractions.Statistics;
using MatthiWare.FinancialModelingPrep.Abstractions.StockMarket;
using MatthiWare.FinancialModelingPrep.Abstractions.StockTimeSeries;
Expand Down Expand Up @@ -76,5 +77,11 @@ public interface IFinancialModelingPrepApiClient
/// - Economic indicators
/// </summary>
public IEconomicsProvider Economics { get; }

/// <summary>
/// Statement Analysis related endpoints
/// - Financial Growth
/// </summary>
public IStatementAnalysisProvider StatementAnalysis { get; }
}
}
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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using MatthiWare.FinancialModelingPrep.Abstractions.Fund;
using MatthiWare.FinancialModelingPrep.Abstractions.InstitutionalFund;
using MatthiWare.FinancialModelingPrep.Abstractions.MarketIndexes;
using MatthiWare.FinancialModelingPrep.Abstractions.StatementAnalysis;
using MatthiWare.FinancialModelingPrep.Abstractions.Statistics;
using MatthiWare.FinancialModelingPrep.Abstractions.StockMarket;
using MatthiWare.FinancialModelingPrep.Abstractions.StockTimeSeries;
Expand Down Expand Up @@ -48,6 +49,8 @@ public class FinancialModelingPrepApiClient : IFinancialModelingPrepApiClient
/// <inheritdoc/>
public IEconomicsProvider Economics { get; }

public IStatementAnalysisProvider StatementAnalysis { get; }

/// <inheritdoc/>
public FinancialModelingPrepApiClient(ICompanyValuationProvider companyValuation,
IMarketIndexesProvider marketIndexes,
Expand All @@ -59,7 +62,8 @@ public FinancialModelingPrepApiClient(ICompanyValuationProvider companyValuation
IStockStatisticsProvider stockStatistics,
ICryptoMarketProvider cryptoMarket,
IFundProvider fund,
IEconomicsProvider economics)
IEconomicsProvider economics,
IStatementAnalysisProvider statementAnalysis)
{
CompanyValuation = companyValuation;
MarketIndexes = marketIndexes;
Expand All @@ -72,6 +76,7 @@ public FinancialModelingPrepApiClient(ICompanyValuationProvider companyValuation
Crypto = cryptoMarket;
Fund = fund;
Economics = economics;
StatementAnalysis = statementAnalysis;
}
}
}
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);
}
}
3 changes: 3 additions & 0 deletions FinancialModelingPrepApi/DependencyInjectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using System;
using MatthiWare.FinancialModelingPrep.Abstractions.StatementAnalysis;
using MatthiWare.FinancialModelingPrep.Core.StatementAnalysis;

namespace MatthiWare.FinancialModelingPrep
{
Expand Down Expand Up @@ -59,6 +61,7 @@ public static void AddFinancialModelingPrepApiClient(this IServiceCollection ser
services.TryAddTransient<IStockStatisticsProvider, StockStatisticsProvider>();
services.TryAddTransient<IFundProvider, FundProvider>();
services.TryAddTransient<IEconomicsProvider, EconomicsProvider>();
services.TryAddTransient<IStatementAnalysisProvider, StatementAnalysisProvider>();
}
}
}
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; }
}
8 changes: 7 additions & 1 deletion Tests/ClientFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ClientFactoryTests

public ClientFactoryTests()
{
this.api = FinancialModelingPrepApiClientFactory.CreateClient(new FinancialModelingPrepOptions());
this.api = FinancialModelingPrepApiClientFactory.CreateClient(new());
}

[Fact]
Expand Down Expand Up @@ -71,5 +71,11 @@ public void API_Contains_Economics_Provider()
{
Assert.NotNull(api.Economics);
}

[Fact]
public void API_Contains_StatementAnalysis_Provider()
{
Assert.NotNull(api.StatementAnalysis);
}
}
}
8 changes: 8 additions & 0 deletions Tests/ResolveApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,13 @@ public void API_Contains_Economics_Provider()

Assert.NotNull(api.Economics);
}

[Fact]
public void API_Contains_StatementAnalysis_Provider()
{
var api = ServiceProvider.GetRequiredService<IFinancialModelingPrepApiClient>();

Assert.NotNull(api.StatementAnalysis);
}
}
}
43 changes: 43 additions & 0 deletions Tests/StatementAnalysis/StatementAnalysisTests.cs
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);
}
}