Skip to content

Commit 6c2be4d

Browse files
authored
Add financial score + update crypto namespace (#108)
* Update crypto namespace * add fmp tag * Add financial score
1 parent 3166e32 commit 6c2be4d

File tree

11 files changed

+87
-10
lines changed

11 files changed

+87
-10
lines changed

FinancialModelingPrepApi/Abstractions/AdvancedData/IAdvancedDataProvider.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@ public interface IAdvancedDataProvider
2525
Task<ApiResponse<SharesFloatResponse>> GetSharesFloatAsync(string symbol);
2626

2727
Task<ApiResponse<List<ESGScoreResponse>>> GetESGScoreAsync(string symbol);
28+
29+
Task<ApiResponse<FinancialScoreResponse>> GetFinancialScoreAsync(string symbol);
2830
}
2931
}

FinancialModelingPrepApi/Abstractions/Crypto/ICryptoMarketProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Collections.Generic;
55
using System.Threading.Tasks;
66

7-
namespace MatthiWare.FinancialModelingPrep.Abstractions.StockMarket
7+
namespace MatthiWare.FinancialModelingPrep.Abstractions.Crypto
88
{
99
public interface ICryptoMarketProvider
1010
{

FinancialModelingPrepApi/Abstractions/IFinancialModelingPrepApiClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using MatthiWare.FinancialModelingPrep.Abstractions.AdvancedData;
22
using MatthiWare.FinancialModelingPrep.Abstractions.Calendars;
33
using MatthiWare.FinancialModelingPrep.Abstractions.CompanyValuation;
4+
using MatthiWare.FinancialModelingPrep.Abstractions.Crypto;
45
using MatthiWare.FinancialModelingPrep.Abstractions.Economics;
56
using MatthiWare.FinancialModelingPrep.Abstractions.Fund;
67
using MatthiWare.FinancialModelingPrep.Abstractions.InstitutionalFund;

FinancialModelingPrepApi/Core/AdvancedData/AdvancedDataProvider.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,5 +173,27 @@ public Task<ApiResponse<List<ESGScoreResponse>>> GetESGScoreAsync(string symbol)
173173

174174
return client.GetJsonAsync<List<ESGScoreResponse>>(url, pathParams, queryString);
175175
}
176+
177+
public async Task<ApiResponse<FinancialScoreResponse>> GetFinancialScoreAsync(string symbol)
178+
{
179+
const string url = "[version]/score";
180+
181+
var pathParams = new NameValueCollection()
182+
{
183+
{ "version", ApiVersion.v4.ToString() }
184+
};
185+
186+
var queryString = new QueryStringBuilder();
187+
queryString.Add("symbol", symbol);
188+
189+
var result = await client.GetJsonAsync<List<FinancialScoreResponse>>(url, pathParams, queryString);
190+
191+
if (result.HasError)
192+
{
193+
return ApiResponse.FromError<FinancialScoreResponse>(result.Error);
194+
}
195+
196+
return ApiResponse.FromSucces(result.Data.First());
197+
}
176198
}
177199
}

FinancialModelingPrepApi/Core/Crypto/CryptoMarketProvider.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
using MatthiWare.FinancialModelingPrep.Abstractions.StockMarket;
1+
using MatthiWare.FinancialModelingPrep.Abstractions.Crypto;
22
using MatthiWare.FinancialModelingPrep.Core.Http;
33
using MatthiWare.FinancialModelingPrep.Model;
44
using MatthiWare.FinancialModelingPrep.Model.Crypto;
5-
using MatthiWare.FinancialModelingPrep.Model.StockMarket;
65
using System.Collections.Generic;
76
using System.Collections.Specialized;
87
using System.Threading.Tasks;
98

10-
namespace MatthiWare.FinancialModelingPrep.Core.StockMarket
9+
namespace MatthiWare.FinancialModelingPrep.Core.Crypto
1110
{
1211
public sealed class CryptoMarketProvider : ICryptoMarketProvider
1312
{

FinancialModelingPrepApi/Core/FinancialModelingPrepApiClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using MatthiWare.FinancialModelingPrep.Abstractions.AdvancedData;
22
using MatthiWare.FinancialModelingPrep.Abstractions.Calendars;
33
using MatthiWare.FinancialModelingPrep.Abstractions.CompanyValuation;
4+
using MatthiWare.FinancialModelingPrep.Abstractions.Crypto;
45
using MatthiWare.FinancialModelingPrep.Abstractions.Economics;
56
using MatthiWare.FinancialModelingPrep.Abstractions.Fund;
67
using MatthiWare.FinancialModelingPrep.Abstractions.InstitutionalFund;

FinancialModelingPrepApi/DependencyInjectionExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using MatthiWare.FinancialModelingPrep.Abstractions.AdvancedData;
22
using MatthiWare.FinancialModelingPrep.Abstractions.Calendars;
33
using MatthiWare.FinancialModelingPrep.Abstractions.CompanyValuation;
4+
using MatthiWare.FinancialModelingPrep.Abstractions.Crypto;
45
using MatthiWare.FinancialModelingPrep.Abstractions.Economics;
56
using MatthiWare.FinancialModelingPrep.Abstractions.Fund;
67
using MatthiWare.FinancialModelingPrep.Abstractions.Http;
@@ -13,6 +14,7 @@
1314
using MatthiWare.FinancialModelingPrep.Core.AdvancedData;
1415
using MatthiWare.FinancialModelingPrep.Core.Calendars;
1516
using MatthiWare.FinancialModelingPrep.Core.CompanyValuation;
17+
using MatthiWare.FinancialModelingPrep.Core.Crypto;
1618
using MatthiWare.FinancialModelingPrep.Core.Economics;
1719
using MatthiWare.FinancialModelingPrep.Core.Fund;
1820
using MatthiWare.FinancialModelingPrep.Core.Http;

FinancialModelingPrepApi/FinancialModelingPrepApi.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1515
<RepositoryUrl>https://github.com/MatthiWare/FinancialModelingPrep.NET</RepositoryUrl>
1616
<RepositoryType>git</RepositoryType>
17-
<PackageTags>FinancialModelingPrep stock quote finance-api</PackageTags>
17+
<PackageTags>FinancialModelingPrep stock quote finance-api fmp</PackageTags>
1818
<PackageProjectUrl>https://github.com/MatthiWare/FinancialModelingPrep.NET</PackageProjectUrl>
19-
<PackageReleaseNotes>- Include .NET 6 and .NET 7 in nuget package
20-
- Add Economic Indicators
19+
<PackageReleaseNotes>- Update crypto namespace
2120
</PackageReleaseNotes>
2221
<AssemblyName>FinancialModelingPrep</AssemblyName>
2322
</PropertyGroup>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace MatthiWare.FinancialModelingPrep.Model.AdvancedData
4+
{
5+
public class FinancialScoreResponse
6+
{
7+
[JsonPropertyName("symbol")]
8+
public string Symbol { get; set; }
9+
10+
[JsonPropertyName("altmanZScore")]
11+
public double AltmanZScore { get; set; }
12+
13+
[JsonPropertyName("piotroskiScore")]
14+
public int PiotroskiScore { get; set; }
15+
16+
[JsonPropertyName("workingCapital")]
17+
public long WorkingCapital { get; set; }
18+
19+
[JsonPropertyName("totalAssets")]
20+
public long TotalAssets { get; set; }
21+
22+
[JsonPropertyName("retainedEarnings")]
23+
public long RetainedEarnings { get; set; }
24+
25+
[JsonPropertyName("ebit")]
26+
public long Ebit { get; set; }
27+
28+
[JsonPropertyName("marketCap")]
29+
public long MarketCap { get; set; }
30+
31+
[JsonPropertyName("totalLiabilities")]
32+
public long TotalLiabilities { get; set; }
33+
34+
[JsonPropertyName("revenue")]
35+
public long Revenue { get; set; }
36+
}
37+
}

Tests/AdvancedData/AdvancedDataTests.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,20 @@ public async Task GetESGScoreAsync()
9898

9999
result.AssertNoErrors();
100100
Assert.NotEmpty(result.Data);
101-
101+
}
102+
103+
[Theory]
104+
[InlineData("AAPL")]
105+
[InlineData("AGS.BR")]
106+
[InlineData("PPL.TO")]
107+
[InlineData("AAP")]
108+
public async Task GetCompanyProfileTests(string symbol)
109+
{
110+
var result = await api.GetFinancialScoreAsync(symbol);
111+
112+
result.AssertNoErrors();
113+
114+
Assert.Equal(symbol, result.Data.Symbol);
102115
}
103116

104117
private Task<ApiResponse<StandardIndustrialClassificationResponse>> GetStandardIndustrialClassSwitch(string by, string value)

0 commit comments

Comments
 (0)