Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forex, Futures, Crypto and Stock updates #51

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public interface IAdvancedDataProvider
Task<ApiResponse<CompanyPeersResponse>> GetStockPeersAsync(string symbol);
Task<ApiResponse<List<SectorPEResponse>>> GetSectorsPriceEarningsRatioAsync(string date, string exchange);
Task<ApiResponse<List<IndustryPEResponse>>> GetIndustriesPriceEarningsRatioAsync(string date, string exchange);

Task<ApiResponse<List<CommitmentOfTradersResponse>>> GetCommitmentOfTradersReportAsync(string symbol);
Task<ApiResponse<SharesFloatResponse>> GetSharesFloatAsync(string symbol);

Task<ApiResponse<List<ESGScoreResponse>>> GetESGScoreAsync(string symbol);
Task<ApiResponse<List<FinancialScoreResponse>>> GetFinancialScoreAsync(string symbol);
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
using MatthiWare.FinancialModelingPrep.Model;
using MatthiWare.FinancialModelingPrep.Model.Crypto;
using MatthiWare.FinancialModelingPrep.Model.StockMarket;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace MatthiWare.FinancialModelingPrep.Abstractions.StockMarket
namespace MatthiWare.FinancialModelingPrep.Abstractions.Crypto
{
public interface ICryptoMarketProvider
{
public Task<ApiResponse<List<CryptoItem>>> GetAvilableCryptocurrencies();
Task<ApiResponse<List<CryptoItem>>> GetAvilableCryptocurrenciesAsync();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Task<ApiResponse<List<CryptoItem>>> GetAvailableCryptocurrenciesAsync();

Task<ApiResponse<List<CryptoQuoteResponse>>> GetDailyQuotes();

public Task<ApiResponse<List<CryptoHistoricalPricePeriodListing>>> GetHistoricalPrices(string symbol, HistoricalPricingPeriod period);
Task<ApiResponse<CryptoHistoricalPriceDailyItem>> GetHistoricalQuoteAsync(string symbol);

public Task<ApiResponse<CryptoHistoricalPriceDailyItem>> GetDailyPrices(string symbol);
Task<ApiResponse<CryptoHistoricalPriceDailyItem>> GetHistoricalQuoteAsync(string symbol, string from, string to);

Task<ApiResponse<List<CryptoHistoricalPricePeriodListing>>> GetHistoricalQuoteAsync(string symbol, HistoricalPricingPeriod period);

Task<ApiResponse<List<CryptoQuoteResponse>>> GetQuoteAsync(string symbol);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using MatthiWare.FinancialModelingPrep.Model;
using MatthiWare.FinancialModelingPrep.Model.Forex;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace MatthiWare.FinancialModelingPrep.Abstractions.Forex
{
public interface IForexMarketProvider
{
Task<ApiResponse<List<ForexBookResponse>>> GetBookAsync(string symbol);

Task<ApiResponse<List<ForexQuoteResponse>>> GetQuoteAsync(string symbol);

Task<ApiResponse<List<ForexHistoricalQuoteResponse>>> GetHistoricalQuoteAsync(string symbol, HistoricalPricingPeriod period);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using MatthiWare.FinancialModelingPrep.Model;
using MatthiWare.FinancialModelingPrep.Model.Futures;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace MatthiWare.FinancialModelingPrep.Abstractions.Futures
{
public interface IFuturesMarketProvider
{
Task<ApiResponse<List<FuturesQuoteResponse>>> GetQuoteAsync(string symbol);

Task<ApiResponse<List<FuturesHistoricalQuoteResponse>>> GetHistoricalQuoteAsync(string symbol, HistoricalPricingPeriod period);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using MatthiWare.FinancialModelingPrep.Abstractions.AdvancedData;
using MatthiWare.FinancialModelingPrep.Abstractions.Calendars;
using MatthiWare.FinancialModelingPrep.Abstractions.CompanyValuation;
using MatthiWare.FinancialModelingPrep.Abstractions.Crypto;
using MatthiWare.FinancialModelingPrep.Abstractions.Forex;
using MatthiWare.FinancialModelingPrep.Abstractions.Fund;
using MatthiWare.FinancialModelingPrep.Abstractions.Futures;
using MatthiWare.FinancialModelingPrep.Abstractions.InstitutionalFund;
using MatthiWare.FinancialModelingPrep.Abstractions.MarketIndexes;
using MatthiWare.FinancialModelingPrep.Abstractions.Statistics;
Expand Down Expand Up @@ -61,6 +64,16 @@ public interface IFinancialModelingPrepApiClient
/// </summary>
ICryptoMarketProvider Crypto { get; }

/// <summary>
/// Forex related enpoints
/// </summary>
IForexMarketProvider Forex { get; }

/// <summary>
/// Futures related enpoints
/// </summary>
IFuturesMarketProvider Futures { get; }

/// <summary>
/// ETF/Mutual Fund related enpoints
/// </summary>
Expand Down
74 changes: 74 additions & 0 deletions FinancialModelingPrepApi/Abstractions/Model/ICurrentQuote.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using System.Text.Json.Serialization;

namespace MatthiWare.FinancialModelingPrep.Abstractions.Model
{
public interface ICurrentQuote
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to have this interface, just create the different models with the properties that they have.
Futures/Forex Quote models should not be forced to implement the Eps or PE properties

{
[JsonPropertyName("symbol")]
public string Symbol { get; set; }

[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("exchange")]
public string Exchange { get; set; }

[JsonPropertyName("open")]
public double? Open { get; set; }

[JsonPropertyName("price")]
public double? Price { get; set; }

[JsonPropertyName("previousclose")]
public double? PreviousClose { get; set; }

[JsonPropertyName("daylow")]
public double? DayLow { get; set; }

[JsonPropertyName("dayhigh")]
public double? DayHigh { get; set; }

[JsonPropertyName("yearlow")]
public double? YearlyLow { get; set; }

[JsonPropertyName("yearhigh")]
public double? YearlyHigh { get; set; }

[JsonPropertyName("priceavg50")]
public double? PriceAvg50 { get; set; }

[JsonPropertyName("priceavg200")]
public double? PriceAvg200 { get; set; }

[JsonPropertyName("change")]
public double? Change { get; set; }

[JsonPropertyName("changespercentage")]
public double? ChangesPercentage { get; set; }

[JsonPropertyName("timestamp")]
public long? Timestamp { get; set; }
[JsonPropertyName("volume")]
public double? Volume { get; set; }
[JsonPropertyName("avgVolume")]
public double? AvgVolume { get; set; }

// Not used by Forex or Futures.

[JsonPropertyName("eps")]
public double? Eps { get; set; }

[JsonPropertyName("pe")]
public double? Pe { get; set; }

[JsonPropertyName("earningsAnnouncement")]
public string? EarningsAnnouncement { get; set; }

[JsonPropertyName("sharesOutstanding")]
public double? SharesOutstanding { get; set; }

[JsonPropertyName("marketCap")]
public double? MarketCap { get; set; }
}
}
35 changes: 35 additions & 0 deletions FinancialModelingPrepApi/Abstractions/Model/IHistoricalQuote.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace MatthiWare.FinancialModelingPrep.Abstractions.Model
{
public interface IHistoricalQuote
{
[JsonPropertyName("date")]
public string Date { get; set; }

[JsonPropertyName("open")]
public double? Open { get; set; }

[JsonPropertyName("high")]
public double? High { get; set; }

[JsonPropertyName("low")]
public double? Low { get; set; }

[JsonPropertyName("close")]
public double Close { get; set; }

[JsonPropertyName("change")]
public double? Change { get; set; }
[JsonPropertyName("volume")]
public double Volume { get; set; }

[JsonPropertyName("changePercent")]
public double? ChangePercent { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ namespace MatthiWare.FinancialModelingPrep.Abstractions.StockMarket
{
public interface IStockMarketProvider
{
public Task<ApiResponse<List<IndexConstituentResponse>>> GetNasdaqConstituents();
public Task<ApiResponse<List<IndexConstituentResponse>>> GetSP500Constituents();
public Task<ApiResponse<List<StockMarketSymbolResponse>>> GetMostActiveStocksAsync();
public Task<ApiResponse<List<StockMarketSymbolResponse>>> GetBiggestGainerStocksAsync();
public Task<ApiResponse<List<StockMarketSymbolResponse>>> GetBiggestLoserStocksAsync();
public Task<ApiResponse<StockDividendResponse>> GetStockHistoricalDividends(string symbol);
public Task<ApiResponse<List<StockScreenerItem>>> StockScreener(int? marketCapMoreThan = null, int? marketCapLowerThan = null, decimal? priceMoreThan = null, decimal? priceLowerThan = null,
decimal? betaMoreThan = null, decimal? betaLowerThan = null, int? volumeMoreThan = null, int? volumeLowerThan = null, bool? isEtf = null, bool? isActivelyTraded = null,
Sector? sector = null, Industry? industry = null, Country? country = null, Exchange? exchange = null, int? limit = 30);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MatthiWare.FinancialModelingPrep.Model;
using MatthiWare.FinancialModelingPrep.Model.StockMarket;
using MatthiWare.FinancialModelingPrep.Model.StockTimeSeries;
using System.Collections.Generic;
using System.Threading.Tasks;
Expand All @@ -7,6 +8,12 @@ namespace MatthiWare.FinancialModelingPrep.Abstractions.StockTimeSeries
{
public interface IStockTimeSeriesProvider
{
/// <summary>
/// Get the latest quote for given stock.
/// </summary>
/// <param name="symbol"></param>
/// <returns></returns>
public Task<ApiResponse<List<StockQuoteResponse>>> GetQuoteAsync(string symbol);
/// <summary>
/// Get Daily Historical Dividends
/// </summary>
Expand Down Expand Up @@ -61,6 +68,6 @@ public interface IStockTimeSeriesProvider
/// <param name="symbol">Ticker symbol</param>
/// <param name="series">Time series</param>
/// <returns><see cref="HistoricalPriceForLineChartResponse"/></returns>
Task<ApiResponse<List<HistoricalPriceForChartWithVolumeResponse>>> GetHistoricalPricesForChartWithVolume(string symbol, HistoricalChartSeries series);
Task<ApiResponse<List<HistoricalPriceForChartWithVolumeResponse>>> GetHistoricalPricesForChartWithVolume(string symbol, HistoricalPricingPeriod series);
}
}
50 changes: 47 additions & 3 deletions FinancialModelingPrepApi/Core/AdvancedData/AdvancedDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,51 @@ private async Task<ApiResponse<StandardIndustrialClassificationResponse>> GetSta
return ApiResponse.FromError<StandardIndustrialClassificationResponse>(result.Error);
}

return ApiResponse.FromSucces(result.Data.First());
return ApiResponse.FromSuccess(result.Data.First());
}

public async Task<ApiResponse<List<CommitmentOfTradersResponse>>> GetCommitmentOfTradersReportAsync(string symbol)
{
const string url = "[version]/commitment_of_traders_report";

var pathParams = new NameValueCollection()
{
{ "version", ApiVersion.v4.ToString() }
};

var queryString = new QueryStringBuilder();
queryString.Add("symbol", symbol);

var result = await client.GetJsonAsync<List<CommitmentOfTradersResponse>>(url, pathParams, queryString);

if (result.HasError)
{
return ApiResponse.FromError<List<CommitmentOfTradersResponse>>(result.Error);
}

return ApiResponse.FromSuccess(result.Data);
}

public async Task<ApiResponse<List<FinancialScoreResponse>>> GetFinancialScoreAsync(string symbol)
{
const string url = "[version]/score";

var pathParams = new NameValueCollection()
{
{ "version", ApiVersion.v4.ToString() }
};

var queryString = new QueryStringBuilder();
queryString.Add("symbol", symbol);

var result = await client.GetJsonAsync<List<FinancialScoreResponse>>(url, pathParams, queryString);

if (result.HasError)
{
return ApiResponse.FromError<List<FinancialScoreResponse>>(result.Error);
}

return ApiResponse.FromSuccess(result.Data);
}

public async Task<ApiResponse<CompanyPeersResponse>> GetStockPeersAsync(string symbol)
Expand All @@ -99,7 +143,7 @@ public async Task<ApiResponse<CompanyPeersResponse>> GetStockPeersAsync(string s
return ApiResponse.FromError<CompanyPeersResponse>(result.Error);
}

return ApiResponse.FromSucces(result.Data.First());
return ApiResponse.FromSuccess(result.Data.First());
}

public Task<ApiResponse<List<SectorPEResponse>>> GetSectorsPriceEarningsRatioAsync(string date, string exchange)
Expand Down Expand Up @@ -156,7 +200,7 @@ public async Task<ApiResponse<SharesFloatResponse>> GetSharesFloatAsync(string s
return ApiResponse.FromError<SharesFloatResponse>(result.Error);
}

return ApiResponse.FromSucces(result.Data.First());
return ApiResponse.FromSuccess(result.Data.First());
}

public Task<ApiResponse<List<ESGScoreResponse>>> GetESGScoreAsync(string symbol)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task<ApiResponse<CompanyProfileResponse>> GetCompanyProfileAsync(st
return ApiResponse.FromError<CompanyProfileResponse>(result.Error);
}

return ApiResponse.FromSucces(result.Data.First());
return ApiResponse.FromSuccess(result.Data.First());
}

public Task<ApiResponse<List<SymbolResponse>>> GetETFListAsync()
Expand Down Expand Up @@ -264,7 +264,7 @@ public async Task<ApiResponse<CompanyRatingResponse>> GetCompanyRatingAsync(stri
return ApiResponse.FromError<CompanyRatingResponse>(result.Error);
}

return ApiResponse.FromSucces(result.Data.First());
return ApiResponse.FromSuccess(result.Data.First());
}

public Task<ApiResponse<List<CompanyRatingResponse>>> GetHistoricalCompanyRatingAsync(string symbol, int? limit = 140)
Expand Down Expand Up @@ -304,7 +304,7 @@ public async Task<ApiResponse<DCFResponse>> GetDiscountedCashFlowAsync(string sy
return ApiResponse.FromError<DCFResponse>(result.Error);
}

return ApiResponse.FromSucces(result.Data.First());
return ApiResponse.FromSuccess(result.Data.First());
}

public Task<ApiResponse<List<HistoricalDCFResponse>>> GetHistoricalDiscountedCashFlowAsync(string symbol, Period period = Period.Annual)
Expand Down Expand Up @@ -364,7 +364,7 @@ public async Task<ApiResponse<RatiosTTMResponse>> GetRatiosTTMAsync(string symbo
return ApiResponse.FromError<RatiosTTMResponse>(result.Error);
}

return ApiResponse.FromSucces(result.Data.First());
return ApiResponse.FromSuccess(result.Data.First());
}

public async Task<ApiResponse<KeyMetricsTTMResponse>> GetCompanyKeyMetricsTTMAsync(string symbol)
Expand All @@ -384,7 +384,7 @@ public async Task<ApiResponse<KeyMetricsTTMResponse>> GetCompanyKeyMetricsTTMAsy
return ApiResponse.FromError<KeyMetricsTTMResponse>(result.Error);
}

return ApiResponse.FromSucces(result.Data.First());
return ApiResponse.FromSuccess(result.Data.First());
}

public Task<ApiResponse<List<KeyMetricsResponse>>> GetCompanyKeyMetricsAsync(string symbol, Period period = Period.Annual, int? limit = 130)
Expand Down Expand Up @@ -429,7 +429,7 @@ public async Task<ApiResponse<QuoteResponse>> GetQuoteAsync(string symbol)
return ApiResponse.FromError<QuoteResponse>(result.Error);
}

return ApiResponse.FromSucces(result.Data.First());
return ApiResponse.FromSuccess(result.Data.First());
}

public Task<ApiResponse<List<QuoteResponse>>> GetQuotesAsync(IEnumerable<string> symbols)
Expand Down Expand Up @@ -482,7 +482,7 @@ public async Task<ApiResponse<MarketCapResponse>> GetMarketCapitalizationAsync(s
return ApiResponse.FromError<MarketCapResponse>(result.Error);
}

return ApiResponse.FromSucces(result.Data.First());
return ApiResponse.FromSuccess(result.Data.First());
}

public Task<ApiResponse<List<MarketCapResponse>>> GetHistoricalMarketCapitalizationAsync(string symbol, int? limit = 100)
Expand Down
Loading