Skip to content

Commit d6f6129

Browse files
committed
Add Quote endpoint
1 parent 29929df commit d6f6129

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed

FinancialModelingPrepApi/Abstractions/CompanyValuation/ICompanyValuation.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ namespace MatthiWare.FinancialModelingPrepApi.Abstractions.CompanyValuation
77
{
88
public interface ICompanyValuation
99
{
10+
public Task<ApiResponse<QuoteResponse>> GetQuoteAsync(string symbol);
11+
1012
public Task<ApiResponse<CompanyProfileResponse>> GetCompanyProfileAsync(string symbol);
1113
public Task<ApiResponse<KeyMetricsTTMResponse>> GetCompanyKeyMetricsTTMAsync(string symbol);
1214
public Task<ApiResponse<List<KeyMetricsResponse>>> GetCompanyKeyMetricsAsync(string symbol, Period period = Period.Annual, int limit = 130);

FinancialModelingPrepApi/Core/CompanyValuation/CompanyValuation.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,5 +314,25 @@ public Task<ApiResponse<List<KeyMetricsResponse>>> GetCompanyKeyMetricsAsync(str
314314

315315
return client.GetAsync<List<KeyMetricsResponse>>(url, pathParams, queryString);
316316
}
317+
318+
public async Task<ApiResponse<QuoteResponse>> GetQuoteAsync(string symbol)
319+
{
320+
const string url = "[version]/quote/[symbol]";
321+
322+
var pathParams = new NameValueCollection()
323+
{
324+
{ "version", ApiVersion.v3.ToString() },
325+
{ "symbol", symbol }
326+
};
327+
328+
var result = await client.GetAsync<List<QuoteResponse>>(url, pathParams, null);
329+
330+
if (result.HasError)
331+
{
332+
return ApiResponse.FromError<QuoteResponse>(result.Error);
333+
}
334+
335+
return ApiResponse.FromSucces(result.Data.First());
336+
}
317337
}
318338
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using System;
2+
using System.Text.Json.Serialization;
3+
4+
namespace MatthiWare.FinancialModelingPrepApi.Model.CompanyValuation
5+
{
6+
public class QuoteResponse
7+
{
8+
[JsonPropertyName("symbol")]
9+
public string Symbol { get; set; }
10+
11+
[JsonPropertyName("name")]
12+
public string Name { get; set; }
13+
14+
[JsonPropertyName("price")]
15+
public double Price { get; set; }
16+
17+
[JsonPropertyName("changesPercentage")]
18+
public double ChangesPercentage { get; set; }
19+
20+
[JsonPropertyName("change")]
21+
public double Change { get; set; }
22+
23+
[JsonPropertyName("dayLow")]
24+
public double DayLow { get; set; }
25+
26+
[JsonPropertyName("dayHigh")]
27+
public double DayHigh { get; set; }
28+
29+
[JsonPropertyName("yearHigh")]
30+
public double YearHigh { get; set; }
31+
32+
[JsonPropertyName("yearLow")]
33+
public double YearLow { get; set; }
34+
35+
[JsonPropertyName("marketCap")]
36+
public double MarketCap { get; set; }
37+
38+
[JsonPropertyName("priceAvg50")]
39+
public double PriceAvg50 { get; set; }
40+
41+
[JsonPropertyName("priceAvg200")]
42+
public double PriceAvg200 { get; set; }
43+
44+
[JsonPropertyName("volume")]
45+
public int Volume { get; set; }
46+
47+
[JsonPropertyName("avgVolume")]
48+
public int AvgVolume { get; set; }
49+
50+
[JsonPropertyName("exchange")]
51+
public string Exchange { get; set; }
52+
53+
[JsonPropertyName("open")]
54+
public double Open { get; set; }
55+
56+
[JsonPropertyName("previousClose")]
57+
public double PreviousClose { get; set; }
58+
59+
[JsonPropertyName("eps")]
60+
public double Eps { get; set; }
61+
62+
[JsonPropertyName("pe")]
63+
public double Pe { get; set; }
64+
65+
[JsonPropertyName("earningsAnnouncement")]
66+
public string EarningsAnnouncement { get; set; }
67+
68+
[JsonPropertyName("sharesOutstanding")]
69+
public long SharesOutstanding { get; set; }
70+
71+
[JsonPropertyName("timestamp")]
72+
public int Timestamp { get; set; }
73+
}
74+
}

Tests/CompanyValuation/CompanyValuationTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,5 +216,16 @@ public async Task GetCompanyKeyMetricsAsync()
216216
Assert.Equal(5, result.Data.Count);
217217
Assert.All(result.Data, data => Assert.Equal("AAPL", data.Symbol));
218218
}
219+
220+
[Fact]
221+
public async Task GetQuoteAsync()
222+
{
223+
var api = ServiceProvider.GetRequiredService<IFinancialModelingPrepApiClient>();
224+
225+
var result = await api.CompanyValuation.GetQuoteAsync("AAPL");
226+
227+
result.AssertNoErrors();
228+
Assert.Equal("AAPL", result.Data.Symbol);
229+
}
219230
}
220231
}

0 commit comments

Comments
 (0)