Skip to content

Commit

Permalink
Make timestamp, price nullable (#77)
Browse files Browse the repository at this point in the history
* Make properties nullable

* Fix failing tests

* Make avg volume also double

* Fix different error handling on FMP
  • Loading branch information
Matthiee authored Jan 20, 2023
1 parent 1b8f825 commit f34af7c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class FinancialModelingPrepHttpClient
private readonly ILogger<FinancialModelingPrepHttpClient> logger;
private readonly JsonSerializerOptions jsonSerializerOptions;
private const string EmptyArrayResponse = "[ ]";
private const string EmptyArrayResponse2 = "[]";
private const string ErrorMessageResponse = "Error Message";

public FinancialModelingPrepHttpClient(HttpClient client, FinancialModelingPrepOptions options,
Expand Down Expand Up @@ -64,7 +65,8 @@ public async Task<ApiResponse<string>> GetStringAsync(string urlPattern, NameVal
return ApiResponse.FromError<string>(errorData.ErrorMessage);
}

if (response.Data.Equals(EmptyArrayResponse, StringComparison.OrdinalIgnoreCase))
if (response.Data.Equals(EmptyArrayResponse, StringComparison.OrdinalIgnoreCase) ||
response.Data.Equals(EmptyArrayResponse2, StringComparison.OrdinalIgnoreCase))
{
return ApiResponse.FromError<string>("Invalid parameters");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public class QuoteResponse
public double? PriceAvg200 { get; set; }

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

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

[JsonPropertyName("exchange")]
public string Exchange { get; set; }
Expand All @@ -66,9 +66,9 @@ public class QuoteResponse
public string EarningsAnnouncement { get; set; }

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

[JsonPropertyName("timestamp")]
public int Timestamp { get; set; }
public int? Timestamp { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class SymbolResponse
public string Name { get; set; }

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

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

0 comments on commit f34af7c

Please sign in to comment.