-
Notifications
You must be signed in to change notification settings - Fork 23
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
cff9fbf
dad880e
eb419ff
665662b
1cf5e3b
889351e
e0fdeb8
9085954
19ab3b5
7bd8d19
d9bf2c5
1647d4a
69b0ebd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
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(); | ||
|
||
public Task<ApiResponse<List<CryptoHistoricalPricePeriodListing>>> GetHistoricalPrices(string symbol, HistoricalPricingPeriod period); | ||
Task<ApiResponse<List<CryptoHistoricalPricePeriodListing>>> GetHistoricalQuoteAsync(string symbol, HistoricalPricingPeriod period); | ||
|
||
public Task<ApiResponse<CryptoHistoricalPriceDailyItem>> GetDailyPrices(string symbol); | ||
Task<ApiResponse<CryptoHistoricalPriceDailyItem>> GetDailyPricesAsync(string symbol); | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace MatthiWare.FinancialModelingPrep.Abstractions.Model | ||
{ | ||
public interface ICurrentQuote | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
{ | ||
[JsonPropertyName("symbol")] | ||
public string Symbol { get; set; } | ||
|
||
[JsonPropertyName("name")] | ||
public string Name { get; set; } | ||
|
||
[JsonPropertyName("exchange")] | ||
public string Exchange { get; set; } | ||
|
||
[JsonPropertyName("open")] | ||
public decimal Open { get; set; } | ||
|
||
[JsonPropertyName("price")] | ||
public decimal Price { get; set; } | ||
|
||
[JsonPropertyName("previousclose")] | ||
public decimal PreviousClose { get; set; } | ||
|
||
[JsonPropertyName("daylow")] | ||
public decimal DayLow { get; set; } | ||
|
||
[JsonPropertyName("dayhigh")] | ||
public decimal DayHigh { get; set; } | ||
|
||
[JsonPropertyName("yearlow")] | ||
public decimal YearlyLow { get; set; } | ||
|
||
[JsonPropertyName("yearhigh")] | ||
public decimal YearlyHigh { get; set; } | ||
|
||
[JsonPropertyName("priceavg50")] | ||
public decimal PriceAvg50 { get; set; } | ||
|
||
[JsonPropertyName("priceavg200")] | ||
public decimal PriceAvg200 { get; set; } | ||
|
||
[JsonPropertyName("change")] | ||
public decimal Change { get; set; } | ||
|
||
[JsonPropertyName("changespercentage")] | ||
public decimal ChangesPercentage { get; set; } | ||
|
||
[JsonPropertyName("timestamp")] | ||
public long Timestamp { get; set; } | ||
|
||
// Not used by Forex or Futures. | ||
|
||
[JsonPropertyName("eps")] | ||
public decimal? Eps { get; set; } | ||
|
||
[JsonPropertyName("pe")] | ||
public decimal? Pe { get; set; } | ||
|
||
[JsonPropertyName("earningsAnnouncement")] | ||
public string? EarningsAnnouncement { get; set; } | ||
|
||
[JsonPropertyName("sharesOutstanding")] | ||
public long? SharesOutstanding { get; set; } | ||
|
||
[JsonPropertyName("marketCap")] | ||
public decimal? MarketCap { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
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 decimal Open { get; set; } | ||
|
||
[JsonPropertyName("high")] | ||
public decimal High { get; set; } | ||
|
||
[JsonPropertyName("low")] | ||
public decimal Low { get; set; } | ||
|
||
[JsonPropertyName("close")] | ||
public decimal Close { get; set; } | ||
|
||
[JsonPropertyName("change")] | ||
public decimal? Change { get; set; } | ||
|
||
[JsonPropertyName("changePercent")] | ||
public decimal? ChangePercent { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
using MatthiWare.FinancialModelingPrep.Abstractions.StockMarket; | ||
using MatthiWare.FinancialModelingPrep.Abstractions.Crypto; | ||
using MatthiWare.FinancialModelingPrep.Abstractions.StockMarket; | ||
using MatthiWare.FinancialModelingPrep.Core.Http; | ||
using MatthiWare.FinancialModelingPrep.Model; | ||
using MatthiWare.FinancialModelingPrep.Model.Crypto; | ||
using MatthiWare.FinancialModelingPrep.Model.StockMarket; | ||
using System.Collections.Generic; | ||
using System.Collections.Specialized; | ||
using System.Threading.Tasks; | ||
|
@@ -18,7 +18,7 @@ public CryptoMarketProvider(FinancialModelingPrepHttpClient client) | |
this.client = client ?? throw new System.ArgumentNullException(nameof(client)); | ||
} | ||
|
||
public Task<ApiResponse<List<CryptoItem>>> GetAvilableCryptocurrencies() | ||
public async Task<ApiResponse<List<CryptoItem>>> GetAvilableCryptocurrenciesAsync() | ||
{ | ||
|
||
const string url = "[version]/symbol/available-cryptocurrencies"; | ||
|
@@ -28,10 +28,23 @@ public Task<ApiResponse<List<CryptoItem>>> GetAvilableCryptocurrencies() | |
{ "version", ApiVersion.v3.ToString() } | ||
}; | ||
|
||
return client.GetJsonAsync<List<CryptoItem>>(url, pathParams, null); | ||
return await client.GetJsonAsync<List<CryptoItem>>(url, pathParams, null); | ||
} | ||
|
||
public Task<ApiResponse<CryptoHistoricalPriceDailyItem>> GetDailyPrices(string symbol) | ||
public async Task<ApiResponse<List<CryptoQuoteResponse>>> GetQuoteAsync(string symbol) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you just await the Task without doing anything with it you can remove the async/await keywords here. |
||
{ | ||
const string url = "[version]/quote/[symbol]"; | ||
|
||
var pathParams = new NameValueCollection() | ||
{ | ||
{ "version", ApiVersion.v3.ToString() }, | ||
{ "symbol", symbol }, | ||
}; | ||
|
||
return await client.GetJsonAsync<List<CryptoQuoteResponse>>(url, pathParams, null); | ||
} | ||
|
||
public async Task<ApiResponse<CryptoHistoricalPriceDailyItem>> GetDailyPricesAsync(string symbol) | ||
{ | ||
const string url = "[version]/historical-price-full/[symbol]"; | ||
|
||
|
@@ -41,10 +54,10 @@ public Task<ApiResponse<CryptoHistoricalPriceDailyItem>> GetDailyPrices(string s | |
{ "symbol", symbol } | ||
}; | ||
|
||
return client.GetJsonAsync<CryptoHistoricalPriceDailyItem>(url, pathParams, null); | ||
return await client.GetJsonAsync<CryptoHistoricalPriceDailyItem>(url, pathParams, null); | ||
} | ||
|
||
public Task<ApiResponse<List<CryptoHistoricalPricePeriodListing>>> GetHistoricalPrices(string symbol, HistoricalPricingPeriod period) | ||
public async Task<ApiResponse<List<CryptoHistoricalPricePeriodListing>>> GetHistoricalQuoteAsync(string symbol, HistoricalPricingPeriod period) | ||
{ | ||
const string url = "[version]/historical-chart/[pricePeriod]/[symbol]"; | ||
|
||
|
@@ -57,9 +70,7 @@ public Task<ApiResponse<List<CryptoHistoricalPricePeriodListing>>> GetHistorical | |
{ "pricePeriod", pricePeriod } | ||
}; | ||
|
||
var queryString = new QueryStringBuilder(); | ||
|
||
return client.GetJsonAsync<List<CryptoHistoricalPricePeriodListing>>(url, pathParams, queryString); | ||
return await client.GetJsonAsync<List<CryptoHistoricalPricePeriodListing>>(url, pathParams, null); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
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();