Skip to content

Commit

Permalink
Add fixes for too many requests
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeoriani committed Jun 4, 2024
1 parent ece53f3 commit 2e7ac99
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 205 deletions.
12 changes: 6 additions & 6 deletions src/Fynance.Tests/TickerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ public void Should_download_ticker_data_from_yahoo_finance_by_start_finish_date_
[TestMethod]
public void Splits_Should_not_be_null_when_requested()
{
const string symbol = "PSPC";
const string symbol = "FESA4.SA";

var ticker = Ticker.Build()
.SetSymbol(symbol)
.SetStartDate(new DateTime(2020, 1, 1))
.SetFinishDate(new DateTime(2021, 12, 1))
.SetStartDate(new DateTime(2024, 1, 1))
.SetFinishDate(new DateTime(2024, 12, 1))
.SetInterval(Interval.OneDay)
.SetSplits(true);

Expand All @@ -107,12 +107,12 @@ public void Splits_Should_not_be_null_when_requested()
[TestMethod]
public void Dividends_Should_not_be_null_when_requested()
{
const string symbol = "PSPC";
const string symbol = "PETR4.SA";

var ticker = Ticker.Build()
.SetSymbol(symbol)
.SetStartDate(new DateTime(2020, 1, 1))
.SetFinishDate(new DateTime(2021, 12, 1))
.SetStartDate(new DateTime(2024, 1, 1))
.SetFinishDate(new DateTime(2024, 12, 1))
.SetInterval(Interval.OneDay)
.SetDividends(true);

Expand Down
8 changes: 4 additions & 4 deletions src/Fynance/Fynance.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
<PackageLicenseFile></PackageLicenseFile>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/felipeoriani/Fynance</PackageProjectUrl>
<AssemblyVersion>1.1.0.0</AssemblyVersion>
<FileVersion>1.1.0.0</FileVersion>
<Version>1.1.0</Version>
<AssemblyVersion>1.2.0.0</AssemblyVersion>
<FileVersion>1.2.0.0</FileVersion>
<Version>1.2.0</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 11 additions & 0 deletions src/Fynance/Ticker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public abstract class Ticker : IDisposable
/// </summary>
public FyResult Result { get; protected set; }

/// <summary>
/// It contains the information about the user-agent http request header. The default value is fynance, but you can set your own application.
/// </summary>
public string UserAgent { get; protected set; } = "fynance";

#endregion

#region Construtors
Expand Down Expand Up @@ -204,6 +209,12 @@ public virtual Ticker SetHttpClient(HttpClient client)
return this;
}

public virtual Ticker SetUserAgent(string userAgent)
{
this.UserAgent = userAgent;
return this;
}

/// <summary>
/// Sync implementation to get the results from the predefined settings.
/// </summary>
Expand Down
Loading

0 comments on commit 2e7ac99

Please sign in to comment.