From c3729551a8f5f80ea4521069cbf910e13073c1ef Mon Sep 17 00:00:00 2001 From: Sean Date: Wed, 9 Apr 2025 23:02:30 -0400 Subject: [PATCH] Optimize CMTTrend model --- MarketData/MarketData.sln | 30 +++++++++++++++++++ .../MarketDataLib/DataAccess/PricingDA.cs | 1 - .../CMTrend/CMTCandidateGenerator.cs | 11 +++++-- .../Generator/CMTrend/CMTTrendGenerator.cs | 5 +++- .../MarketDataLib/Generator/RSIGenerator.cs | 7 +++++ 5 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 MarketData/MarketData.sln diff --git a/MarketData/MarketData.sln b/MarketData/MarketData.sln new file mode 100644 index 0000000..1520c73 --- /dev/null +++ b/MarketData/MarketData.sln @@ -0,0 +1,30 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.2.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarketDataLib", "MarketDataLib\MarketDataLib.csproj", "{40159117-A4E2-F689-5B94-20FB81B71B98}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarketData", "MarketData\MarketData.csproj", "{BB564CF9-7A6C-0F05-E71E-F77096A11D78}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {40159117-A4E2-F689-5B94-20FB81B71B98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40159117-A4E2-F689-5B94-20FB81B71B98}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40159117-A4E2-F689-5B94-20FB81B71B98}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40159117-A4E2-F689-5B94-20FB81B71B98}.Release|Any CPU.Build.0 = Release|Any CPU + {BB564CF9-7A6C-0F05-E71E-F77096A11D78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BB564CF9-7A6C-0F05-E71E-F77096A11D78}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BB564CF9-7A6C-0F05-E71E-F77096A11D78}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BB564CF9-7A6C-0F05-E71E-F77096A11D78}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C6CD530F-2E33-4EE2-BF91-4BF561B4A11E} + EndGlobalSection +EndGlobal diff --git a/MarketData/MarketDataLib/DataAccess/PricingDA.cs b/MarketData/MarketDataLib/DataAccess/PricingDA.cs index 9138cc5..7af18fe 100755 --- a/MarketData/MarketDataLib/DataAccess/PricingDA.cs +++ b/MarketData/MarketDataLib/DataAccess/PricingDA.cs @@ -285,7 +285,6 @@ namespace MarketData.DataAccess if(null!=sqlConnection) sqlConnection.Close(); } } - public static Dictionary GetLatestDates(List symbols) { MySqlConnection sqlConnection = null; diff --git a/MarketData/MarketDataLib/Generator/CMTrend/CMTCandidateGenerator.cs b/MarketData/MarketDataLib/Generator/CMTrend/CMTCandidateGenerator.cs index 510c1c6..56b3ccd 100755 --- a/MarketData/MarketDataLib/Generator/CMTrend/CMTCandidateGenerator.cs +++ b/MarketData/MarketDataLib/Generator/CMTrend/CMTCandidateGenerator.cs @@ -95,7 +95,7 @@ namespace MarketData.Generator.CMTrend } // Current Price Check Price currentPrice=prices[0]; - if(currentPrice.Date!=tradeDate) + if(currentPrice.Date.Date!=tradeDate.Date) { cmtCandidate.Violation=true; cmtCandidate.Symbol=symbol; @@ -203,8 +203,13 @@ namespace MarketData.Generator.CMTrend // Trend #8 check. Evaluate the RSI // generate a 14 day standard RSI with 30 days of pricing data - RSICollection rsiCollection=RSIGenerator.GenerateRSI(symbol,currentPrice.Date,30); - if(null==rsiCollection||0==rsiCollection.Count||rsiCollection[rsiCollection.Count-1].RSI symbols=PricingDA.GetSymbols(); + Dictionary latestDates = PricingDA.GetLatestDates(symbols); + symbols=symbols.Where(x => latestDates.ContainsKey(x) && latestDates[x].Date>=tradeDate.Date).ToList(); for(int index=0;index=0;index--) {