-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
140 additions
and
2 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
FinancialModelingPrepApi/Abstractions/Fund/IFundProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using MatthiWare.FinancialModelingPrep.Model; | ||
using MatthiWare.FinancialModelingPrep.Model.Fund; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace MatthiWare.FinancialModelingPrep.Abstractions.Fund | ||
{ | ||
public interface IFundProvider | ||
{ | ||
public Task<ApiResponse<List<ETFStockExposureResponse>>> GetETFStockExposureAsync(string symbol); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using MatthiWare.FinancialModelingPrep.Abstractions.Fund; | ||
using MatthiWare.FinancialModelingPrep.Core.Http; | ||
using MatthiWare.FinancialModelingPrep.Model; | ||
using MatthiWare.FinancialModelingPrep.Model.Fund; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Specialized; | ||
using System.Threading.Tasks; | ||
|
||
namespace MatthiWare.FinancialModelingPrep.Core.Fund | ||
{ | ||
public class FundProvider : IFundProvider | ||
{ | ||
private readonly FinancialModelingPrepHttpClient client; | ||
|
||
public FundProvider(FinancialModelingPrepHttpClient client) | ||
{ | ||
this.client = client ?? throw new System.ArgumentNullException(nameof(client)); | ||
} | ||
|
||
public Task<ApiResponse<List<ETFStockExposureResponse>>> GetETFStockExposureAsync(string symbol) | ||
{ | ||
const string url = "[version]/etf-stock-exposure/[symbol]"; | ||
|
||
var pathParams = new NameValueCollection() | ||
{ | ||
{ "version", ApiVersion.v3.ToString() }, | ||
{ "symbol", symbol } | ||
}; | ||
|
||
return client.GetJsonAsync<List<ETFStockExposureResponse>>(url, pathParams, null); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
FinancialModelingPrepApi/Model/Fund/ETFStockExposureResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace MatthiWare.FinancialModelingPrep.Model.Fund | ||
{ | ||
public class ETFStockExposureResponse | ||
{ | ||
[JsonPropertyName("etfSymbol")] | ||
public string EtfSymbol { get; set; } | ||
|
||
[JsonPropertyName("assetExposure")] | ||
public string AssetExposure { get; set; } | ||
|
||
[JsonPropertyName("sharesNumber")] | ||
public int SharesNumber { get; set; } | ||
|
||
[JsonPropertyName("weightPercentage")] | ||
public double WeightPercentage { get; set; } | ||
|
||
[JsonPropertyName("marketValue")] | ||
public double MarketValue { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using MatthiWare.FinancialModelingPrep.Abstractions.Fund; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Tests.CompanyValuation | ||
{ | ||
public class FundTests : TestingBase | ||
{ | ||
private readonly IFundProvider api; | ||
|
||
public FundTests(ITestOutputHelper testOutput) : base(testOutput) | ||
{ | ||
api = ServiceProvider.GetRequiredService<IFundProvider>(); | ||
} | ||
|
||
[Theory] | ||
[InlineData("AAPL")] | ||
[InlineData("AGS.BR")] | ||
[InlineData("O")] | ||
[InlineData("LGEN.L")] | ||
public async Task GetETFStockExposureAsyncTest(string symbol) | ||
{ | ||
var result = await api.GetETFStockExposureAsync(symbol); | ||
|
||
result.AssertNoErrors(); | ||
Assert.NotEmpty(result.Data); | ||
} | ||
} | ||
} |