Skip to content

Commit

Permalink
Merge pull request #96 from ooples/develop
Browse files Browse the repository at this point in the history
Replaced some volume values with long instead of double
  • Loading branch information
ooples authored Oct 6, 2024
2 parents 6113953 + fa1b38f commit 4ff9e0e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/Helpers/ChartHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ internal override IEnumerable<T> ParseYahooJsonData<T>(string jsonData)
var result = new ChartInfo
{
DateList = new List<DateTime>(root != null ? root.Timestamp.Select(x => x.FromUnixTimeStamp()) : []),
CloseList = new List<double>(root != null ? root.Indicators?.Quote.SelectMany(x => x.Close.Select(y => y.GetValueOrDefault())) ?? [] : []),
OpenList = new List<double>(root != null ? root.Indicators?.Quote.SelectMany(x => x.Open.Select(y => y.GetValueOrDefault())) ?? [] : []),
HighList = new List<double>(root != null ? root.Indicators?.Quote.SelectMany(x => x.High.Select(y => y.GetValueOrDefault())) ?? [] : []),
VolumeList = new List<long>(root != null ? root.Indicators?.Quote.SelectMany(x => x.Volume.Select(y => y.GetValueOrDefault())) ?? [] : []),
LowList = new List<double>(root != null ? root.Indicators?.Quote.SelectMany(x => x.Low.Select(y => y.GetValueOrDefault())) ?? [] : [])
CloseList = new List<double>(root != null ? root.Indicators.Quote.SelectMany(x => x.Close.Select(y => y.GetValueOrDefault())) : []),

Check failure on line 18 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Create Release

Dereference of a possibly null reference.

Check failure on line 18 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 18 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 18 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 18 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 18 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Create Release

Dereference of a possibly null reference.

Check failure on line 18 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 18 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 18 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 18 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 18 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 18 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 18 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 18 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 18 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 18 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 18 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 18 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.
OpenList = new List<double>(root != null ? root.Indicators.Quote.SelectMany(x => x.Open.Select(y => y.GetValueOrDefault())) : []),

Check failure on line 19 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Create Release

Dereference of a possibly null reference.

Check failure on line 19 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 19 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 19 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 19 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 19 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Create Release

Dereference of a possibly null reference.

Check failure on line 19 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 19 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 19 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 19 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 19 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 19 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 19 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 19 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 19 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 19 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 19 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 19 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.
HighList = new List<double>(root != null ? root.Indicators.Quote.SelectMany(x => x.High.Select(y => y.GetValueOrDefault())) : []),

Check failure on line 20 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Create Release

Dereference of a possibly null reference.

Check failure on line 20 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 20 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 20 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 20 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 20 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Create Release

Dereference of a possibly null reference.

Check failure on line 20 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 20 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 20 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 20 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 20 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 20 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 20 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 20 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 20 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 20 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 20 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 20 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.
VolumeList = new List<long>(root != null ? root.Indicators.Quote.SelectMany(x => x.Volume.Select(y => y.GetValueOrDefault())) : []),

Check failure on line 21 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Create Release

Dereference of a possibly null reference.

Check failure on line 21 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 21 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 21 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 21 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 21 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Create Release

Dereference of a possibly null reference.

Check failure on line 21 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 21 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 21 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 21 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 21 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 21 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 21 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 21 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 21 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 21 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 21 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 21 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.
LowList = new List<double>(root != null ? root.Indicators.Quote.SelectMany(x => x.Low.Select(y => y.GetValueOrDefault())) : [])

Check failure on line 22 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Create Release

Dereference of a possibly null reference.

Check failure on line 22 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 22 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 22 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 22 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 22 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Create Release

Dereference of a possibly null reference.

Check failure on line 22 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 22 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 22 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 22 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 22 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 22 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 22 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 22 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 22 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 22 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (javascript)

Dereference of a possibly null reference.

Check failure on line 22 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.

Check failure on line 22 in src/Helpers/ChartHelper.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Dereference of a possibly null reference.
};

if (result.DateList.Count == 0 || result.CloseList.Count == 0 || result.OpenList.Count == 0 || result.HighList.Count == 0 ||
Expand Down
18 changes: 18 additions & 0 deletions src/Models/ChartData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ public class TradingPeriod
public int? Gmtoffset { get; set; }
}

public class ChartQuote
{
[JsonProperty("open")]
public List<double?> Open { get; set; } = [];

[JsonProperty("low")]
public List<double?> Low { get; set; } = [];

[JsonProperty("volume")]
public List<long?> Volume { get; set; } = [];

[JsonProperty("close")]
public List<double?> Close { get; set; } = [];

[JsonProperty("high")]
public List<double?> High { get; set; } = [];
}

public class ChartResult
{
[JsonProperty("meta")]
Expand Down
2 changes: 1 addition & 1 deletion src/OoplesFinance.YahooFinanceAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<AutoGenerateBindingRedirects>True</AutoGenerateBindingRedirects>
<Title>Ooples Finance Yahoo Finance API</Title>
<Version>1.6.8</Version>
<Version>1.6.9</Version>
<Authors>ooples</Authors>
<Company>Ooples Finance</Company>
<Copyright>Ooples Finance LLC 2022-2023</Copyright>
Expand Down
4 changes: 2 additions & 2 deletions src/YahooClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,9 @@ public async Task<IEnumerable<SparkInfo>> GetSparkChartInfoAsync(IEnumerable<str
/// </summary>
/// <param name="symbol"></param>
/// <returns></returns>
public async Task<RealTimeQuoteResult?> GetRealTimeQuotesAsync(string symbol)
public async Task<RealTimeQuoteResult> GetRealTimeQuotesAsync(string symbol)
{
return new RealTimeQuoteHelper().ParseYahooJsonData<RealTimeQuoteResult>(await DownloadRealTimeQuoteDataAsync(symbol, Country, Language)).FirstOrDefault();
return new RealTimeQuoteHelper().ParseYahooJsonData<RealTimeQuoteResult>(await DownloadRealTimeQuoteDataAsync(symbol, Country, Language)).FirstOrDefault() ?? new();
}

/// <summary>
Expand Down
16 changes: 13 additions & 3 deletions tests/UnitTests/OoplesFinance.YahooFinanceAPI.Tests.Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,24 @@

<ItemGroup>
<DotNetCliToolReference Include="JetBrains.dotCover.CommandLineTools" Version="2023.2.2" />
<PackageReference Include="coverlet.msbuild" Version="6.0.2" />
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Moq.Contrib.HttpClient" Version="1.4.0" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="coverlet.collector" Version="6.0.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 4ff9e0e

Please sign in to comment.