Optimize CMTTrend model
This commit is contained in:
30
MarketData/MarketData.sln
Normal file
30
MarketData/MarketData.sln
Normal file
@@ -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
|
||||||
@@ -285,7 +285,6 @@ namespace MarketData.DataAccess
|
|||||||
if(null!=sqlConnection) sqlConnection.Close();
|
if(null!=sqlConnection) sqlConnection.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dictionary<String,DateTime> GetLatestDates(List<String> symbols)
|
public static Dictionary<String,DateTime> GetLatestDates(List<String> symbols)
|
||||||
{
|
{
|
||||||
MySqlConnection sqlConnection = null;
|
MySqlConnection sqlConnection = null;
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ namespace MarketData.Generator.CMTrend
|
|||||||
}
|
}
|
||||||
// Current Price Check
|
// Current Price Check
|
||||||
Price currentPrice=prices[0];
|
Price currentPrice=prices[0];
|
||||||
if(currentPrice.Date!=tradeDate)
|
if(currentPrice.Date.Date!=tradeDate.Date)
|
||||||
{
|
{
|
||||||
cmtCandidate.Violation=true;
|
cmtCandidate.Violation=true;
|
||||||
cmtCandidate.Symbol=symbol;
|
cmtCandidate.Symbol=symbol;
|
||||||
@@ -203,8 +203,13 @@ namespace MarketData.Generator.CMTrend
|
|||||||
|
|
||||||
// Trend #8 check. Evaluate the RSI
|
// Trend #8 check. Evaluate the RSI
|
||||||
// generate a 14 day standard RSI with 30 days of pricing data
|
// generate a 14 day standard RSI with 30 days of pricing data
|
||||||
RSICollection rsiCollection=RSIGenerator.GenerateRSI(symbol,currentPrice.Date,30);
|
Prices rsiPrices=GBPriceCache.GetInstance().GetPrices(symbol,currentPrice.Date,30);
|
||||||
if(null==rsiCollection||0==rsiCollection.Count||rsiCollection[rsiCollection.Count-1].RSI<cmtParams.MinRSI)
|
RSICollection rsiCollection=RSIGenerator.GenerateRSI(rsiPrices);
|
||||||
|
double rsi=rsiCollection[rsiCollection.Count-1].RSI;
|
||||||
|
|
||||||
|
// RSICollection rsiCollection=RSIGenerator.GenerateRSI(symbol,currentPrice.Date,30);
|
||||||
|
// double rsi=rsiCollection[rsiCollection.Count-1].RSI;
|
||||||
|
if(null==rsiCollection||0==rsiCollection.Count||rsi<cmtParams.MinRSI)
|
||||||
{
|
{
|
||||||
cmtCandidate.Violation=true;
|
cmtCandidate.Violation=true;
|
||||||
cmtCandidate.Symbol=symbol;
|
cmtCandidate.Symbol=symbol;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using MarketData.DataAccess;
|
using Axiom.Interpreter;
|
||||||
|
using MarketData.DataAccess;
|
||||||
using MarketData.MarketDataModel;
|
using MarketData.MarketDataModel;
|
||||||
using MarketData.Utils;
|
using MarketData.Utils;
|
||||||
using System;
|
using System;
|
||||||
@@ -20,6 +21,8 @@ namespace MarketData.Generator.CMTrend
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<String> symbols=PricingDA.GetSymbols();
|
List<String> symbols=PricingDA.GetSymbols();
|
||||||
|
Dictionary<String,DateTime> latestDates = PricingDA.GetLatestDates(symbols);
|
||||||
|
symbols=symbols.Where(x => latestDates.ContainsKey(x) && latestDates[x].Date>=tradeDate.Date).ToList();
|
||||||
for(int index=0;index<symbols.Count;index++)
|
for(int index=0;index<symbols.Count;index++)
|
||||||
{
|
{
|
||||||
String symbol=symbols[index];
|
String symbol=symbols[index];
|
||||||
|
|||||||
@@ -67,11 +67,18 @@ namespace MarketData.Generator
|
|||||||
rsiCollection=new RSICollection(rsiCollection.Skip(rsiDayCount).ToList());
|
rsiCollection=new RSICollection(rsiCollection.Skip(rsiDayCount).ToList());
|
||||||
return rsiCollection;
|
return rsiCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RSICollection GenerateRSI(String symbol,DateTime analysisDate,int priceCount,int rsiDayCount=14)
|
public static RSICollection GenerateRSI(String symbol,DateTime analysisDate,int priceCount,int rsiDayCount=14)
|
||||||
{
|
{
|
||||||
if(priceCount<rsiDayCount)priceCount=(rsiDayCount*2)+1;
|
if(priceCount<rsiDayCount)priceCount=(rsiDayCount*2)+1;
|
||||||
Prices prices=PricingDA.GetPrices(symbol,analysisDate,priceCount);
|
Prices prices=PricingDA.GetPrices(symbol,analysisDate,priceCount);
|
||||||
if(null==prices||priceCount!=prices.Count)return null;
|
if(null==prices||priceCount!=prices.Count)return null;
|
||||||
|
return GenerateRSI(prices, rsiDayCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RSICollection GenerateRSI(Prices prices,int rsiDayCount=14)
|
||||||
|
{
|
||||||
|
if(null==prices || prices.Count<(rsiDayCount*2))return null;
|
||||||
RSICollection rsiCollection=new RSICollection();
|
RSICollection rsiCollection=new RSICollection();
|
||||||
for(int index=prices.Count-1;index>=0;index--)
|
for(int index=prices.Count-1;index>=0;index--)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user