Skip to content

Commit 6a53fd2

Browse files
committed
Add Shares Float Endpoint
1 parent cc91412 commit 6a53fd2

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

FinancialModelingPrepApi/Abstractions/AdvancedData/IAdvancedDataProvider.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ public interface IAdvancedDataProvider
2121
Task<ApiResponse<CompanyPeersResponse>> GetStockPeersAsync(string symbol);
2222
Task<ApiResponse<List<SectorPEResponse>>> GetSectorsPriceEarningsRatioAsync(string date, string exchange);
2323
Task<ApiResponse<List<IndustryPEResponse>>> GetIndustriesPriceEarningsRatioAsync(string date, string exchange);
24+
25+
Task<ApiResponse<SharesFloatResponse>> GetSharesFloatAsync(string symbol);
2426
}
2527
}

FinancialModelingPrepApi/Core/AdvancedData/AdvancedDataProvider.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,27 @@ private Task<ApiResponse<List<T>>> GetGenericPERationAsync<T>(string url, string
136136

137137
return client.GetJsonAsync<List<T>>(url, pathParams, queryString);
138138
}
139+
140+
public async Task<ApiResponse<SharesFloatResponse>> GetSharesFloatAsync(string symbol)
141+
{
142+
const string url = "[version]/shares_float";
143+
144+
var pathParams = new NameValueCollection()
145+
{
146+
{ "version", ApiVersion.v4.ToString() }
147+
};
148+
149+
var queryString = new QueryStringBuilder();
150+
queryString.Add("symbol", symbol);
151+
152+
var result = await client.GetJsonAsync<List<SharesFloatResponse>>(url, pathParams, queryString);
153+
154+
if (result.HasError)
155+
{
156+
return ApiResponse.FromError<SharesFloatResponse>(result.Error);
157+
}
158+
159+
return ApiResponse.FromSucces(result.Data.First());
160+
}
139161
}
140162
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace MatthiWare.FinancialModelingPrep.Model.AdvancedData
4+
{
5+
public class SharesFloatResponse
6+
{
7+
[JsonPropertyName("symbol")]
8+
public string Symbol { get; set; }
9+
10+
[JsonPropertyName("date")]
11+
public string Date { get; set; }
12+
13+
[JsonPropertyName("freeFloat")]
14+
public double FreeFloat { get; set; }
15+
16+
[JsonPropertyName("floatShares")]
17+
public double FloatShares { get; set; }
18+
19+
[JsonPropertyName("outstandingShares")]
20+
public double OutstandingShares { get; set; }
21+
22+
[JsonPropertyName("source")]
23+
public string Source { get; set; }
24+
}
25+
}

Tests/AdvancedData/AdvancedDataTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ public async Task GetIndustriesPriceEarningsRatioAsync()
8080
Assert.NotEmpty(result.Data);
8181
}
8282

83+
[Fact]
84+
public async Task GetSharesFloatAsync()
85+
{
86+
var result = await api.GetSharesFloatAsync("AAPL");
87+
88+
result.AssertNoErrors();
89+
Assert.True(result.Data.FloatShares > 0);
90+
Assert.True(result.Data.FreeFloat > 0);
91+
Assert.True(result.Data.OutstandingShares > 0);
92+
}
93+
8394
private Task<ApiResponse<StandardIndustrialClassificationResponse>> GetStandardIndustrialClassSwitch(string by, string value)
8495
{
8596
return by switch

0 commit comments

Comments
 (0)