Skip to content

Commit

Permalink
upgrade nuget packages. expand holiday calendar.
Browse files Browse the repository at this point in the history
  • Loading branch information
fbertram committed Apr 1, 2024
1 parent 07abc3f commit 544bd05
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 7 deletions.
23 changes: 23 additions & 0 deletions TuringTrader.Simulator/Simulator/v1/Core/HolidayCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,29 @@ static public class HolidayCalendar
DateTime.Parse("09/04/2023", CultureInfo.InvariantCulture), // Labor Day
DateTime.Parse("11/23/2023", CultureInfo.InvariantCulture), // Thanksgiving Day
DateTime.Parse("12/25/2023", CultureInfo.InvariantCulture), // Christmas Day
//--- 2024
DateTime.Parse("01/01/2024", CultureInfo.InvariantCulture), // New Years Day
DateTime.Parse("01/15/2024", CultureInfo.InvariantCulture), // Martin Luther King, Jr. Day
DateTime.Parse("02/19/2024", CultureInfo.InvariantCulture), // Washington's Birthday
DateTime.Parse("03/29/2024", CultureInfo.InvariantCulture), // Good Friday
DateTime.Parse("05/27/2024", CultureInfo.InvariantCulture), // Memorial Day
DateTime.Parse("06/19/2024", CultureInfo.InvariantCulture), // Juneteenth National Independence Day
DateTime.Parse("07/04/2024", CultureInfo.InvariantCulture), // Independence Day
DateTime.Parse("09/02/2024", CultureInfo.InvariantCulture), // Labor Day
DateTime.Parse("11/28/2024", CultureInfo.InvariantCulture), // Thanksgiving Day
DateTime.Parse("12/25/2024", CultureInfo.InvariantCulture), // Christmas Day
//--- 2025
DateTime.Parse("01/01/2025", CultureInfo.InvariantCulture), // New Years Day
DateTime.Parse("01/20/2025", CultureInfo.InvariantCulture), // Martin Luther King, Jr. Day
DateTime.Parse("02/17/2025", CultureInfo.InvariantCulture), // Washington's Birthday
DateTime.Parse("04/18/2025", CultureInfo.InvariantCulture), // Good Friday
DateTime.Parse("05/26/2025", CultureInfo.InvariantCulture), // Memorial Day
DateTime.Parse("06/19/2025", CultureInfo.InvariantCulture), // Juneteenth National Independence Day
DateTime.Parse("07/04/2025", CultureInfo.InvariantCulture), // Independence Day
DateTime.Parse("09/01/2025", CultureInfo.InvariantCulture), // Labor Day
DateTime.Parse("11/27/2025", CultureInfo.InvariantCulture), // Thanksgiving Day
DateTime.Parse("12/25/2025", CultureInfo.InvariantCulture), // Christmas Day
//---
};

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions TuringTrader.Simulator/TuringTrader.Simulator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@

<ItemGroup>
<PackageReference Include="MathNet.Numerics" Version="5.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions TuringTrader.Tests/TuringTrader.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.2.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.2.2" />
</ItemGroup>

<ItemGroup>
Expand Down
52 changes: 52 additions & 0 deletions TuringTrader/ReportTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,7 @@ protected PlotModel RenderSimple(string selectedChart)
newSeries.XAxisKey = "x";
newSeries.YAxisKey = "y";
newSeries.Color = CFG_COLORS[allSeries.Count % CFG_COLORS.Count()];
//newSeries.StrokeThickness = 5;
allSeries[yLabel] = newSeries;
}

Expand Down Expand Up @@ -2006,7 +2007,49 @@ protected List<Dictionary<string, object>> RenderComps()

foreach (var p in periods)
{
#if false
// retired 2024i08
DateTime datePastTarget = dateLast - TimeSpan.FromDays(p.Item2 * 365.25);
#else
// new 2024i08
DateTime datePastTarget;

if (Math.Abs(p.Item2 - 1 / 52.0) < 1e-4)
{
// multi-week
var weeksBack = (int)Math.Round(52.0 * p.Item2);

datePastTarget = dateLast - TimeSpan.FromDays(7 * weeksBack);
}
else if (p.Item2 < 1.0)
{
// multi-month
var monthsBack = (int)Math.Round(12.0 * p.Item2);

var month = (dateLast.Month + 11 - monthsBack) % 12 + 1;

var year = month < dateLast.Month
? dateLast.Year
: dateLast.Year - 1;

var day = month == 2
? Math.Min(dateLast.Day, 28) // FIXME
: Math.Min(dateLast.Day, 30); // FIXME

datePastTarget = new DateTime(year, month, day) + dateLast.TimeOfDay;
}
else
{
// multi-year
var yearsBack = (int)Math.Round(p.Item2);

var day = dateLast.Month == 2
? Math.Min(dateLast.Day, 28) // FIXME
: Math.Min(dateLast.Day, 30); // FIXME

datePastTarget = new DateTime(dateLast.Year - yearsBack, dateLast.Month, day) + dateLast.TimeOfDay;
}
#endif
Dictionary<string, object> rowPast = _firstChart
.OrderBy(r => Math.Abs((datePastTarget - (DateTime)r[_xLabel]).TotalSeconds))
.First();
Expand All @@ -2022,10 +2065,19 @@ protected List<Dictionary<string, object>> RenderComps()
}
//--- year-to-date
{
#if false
// retired 2024i08: calculate against close of first day of the year
DateTime datePastTarget = dateLast - TimeSpan.FromDays(dateLast.DayOfYear);
Dictionary<string, object> rowPast = _firstChart
.OrderBy(r => Math.Abs((datePastTarget - (DateTime)r[_xLabel]).TotalSeconds))
.First();
#else
// new 2024i08: calculate against close of last day of previous year
Dictionary<string, object> rowPast = _firstChart
.Where(r => ((DateTime)r[_xLabel]).Year < dateLast.Year)
.OrderByDescending(r => ((DateTime)r[_xLabel]).Ticks)
.First();
#endif
DateTime datePast = (DateTime)rowPast[_xLabel];
double years = (dateLast - datePast).TotalDays / 365.25;
double navPast = (double)rowPast[_firstYLabel];
Expand Down
4 changes: 2 additions & 2 deletions TuringTrader/TuringTrader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

<ItemGroup>
<PackageReference Include="AvalonLibrary" Version="3.0.0" />
<PackageReference Include="NetOfficeFw.Core" Version="1.9.3">
<PackageReference Include="NetOfficeFw.Core" Version="1.9.5">
<NoWarn>NU1701</NoWarn>
</PackageReference>
<PackageReference Include="NetOfficeFw.Excel" Version="1.9.3">
<PackageReference Include="NetOfficeFw.Excel" Version="1.9.5">
<NoWarn>NU1701</NoWarn>
</PackageReference>
<PackageReference Include="OxyPlot.Wpf" Version="2.1.2" />
Expand Down

0 comments on commit 544bd05

Please sign in to comment.