Refactor unit tests for CNNGenerateOutputFileBollinger and CNNGenerateOutputFileBollingerWithVIX
This commit is contained in:
@@ -191,18 +191,19 @@ namespace MarketData.CNNProcessing
|
|||||||
if(null==NoiseArray)NoiseArray=new double[]{0.00};
|
if(null==NoiseArray)NoiseArray=new double[]{0.00};
|
||||||
if(testCase.TypeGenerate.Equals(TestCase.GenerateType.BollingerBand))
|
if(testCase.TypeGenerate.Equals(TestCase.GenerateType.BollingerBand))
|
||||||
{
|
{
|
||||||
testCase.PathFileNames.Add(CreateFileName("T",testCase.Symbol,testCase.DayCount,0,0,0,TestCase.CaseType.Test,TestCase.GenerateType.BollingerBand,testCase.PurchaseDate));
|
testCase.PathFileNames.Add(CreateFileName(testCase.HomePath,testCase.Symbol,testCase.DayCount,0,0,0,TestCase.CaseType.Test,TestCase.GenerateType.BollingerBand,testCase.PurchaseDate));
|
||||||
ProcessBollingerBandData(testCase,PenWidthArray[0],NoiseArray[0]);
|
ProcessBollingerBandData(testCase,PenWidthArray[0],NoiseArray[0]);
|
||||||
}
|
}
|
||||||
else if(testCase.TypeGenerate.Equals(TestCase.GenerateType.BollingerBandWithVIX))
|
else if(testCase.TypeGenerate.Equals(TestCase.GenerateType.BollingerBandWithVIX))
|
||||||
{
|
{
|
||||||
testCase.PathFileNames.Add(CreateFileName("T",testCase.Symbol,testCase.DayCount,0,0,0,TestCase.CaseType.Test,TestCase.GenerateType.BollingerBandWithVIX,testCase.PurchaseDate));
|
testCase.PathFileNames.Add(CreateFileName(testCase.HomePath,testCase.Symbol,testCase.DayCount,0,0,0,TestCase.CaseType.Test,TestCase.GenerateType.BollingerBandWithVIX,testCase.PurchaseDate));
|
||||||
ProcessBollingerBandDataWithVolatility(testCase,PenWidthArray[0],NoiseArray[0]);
|
ProcessBollingerBandDataWithVolatility(testCase,PenWidthArray[0],NoiseArray[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String CreateFileName(String strFolderPath,String symbol,int dayCount,int index,int penIndex,int noiseIndex,TestCase.CaseType caseType,TestCase.GenerateType generateType,DateTime purchaseDate)
|
private String CreateFileName(String strFolderPath,String symbol,int dayCount,int index,int penIndex,int noiseIndex,TestCase.CaseType caseType,TestCase.GenerateType generateType,DateTime purchaseDate)
|
||||||
{
|
{
|
||||||
|
if(!strFolderPath.EndsWith("/"))strFolderPath+="/";
|
||||||
return String.Format("{0}{1}_{2}_{3}_{4}_{5}_{6}_{7}_{8}d.jpg",strFolderPath,symbol,index,penIndex,noiseIndex,caseType.ToString(),generateType.ToString(),Utility.DateToLong(purchaseDate),dayCount);
|
return String.Format("{0}{1}_{2}_{3}_{4}_{5}_{6}_{7}_{8}d.jpg",strFolderPath,symbol,index,penIndex,noiseIndex,caseType.ToString(),generateType.ToString(),Utility.DateToLong(purchaseDate),dayCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,16 +11,25 @@ namespace MarketData.CNNProcessing
|
|||||||
public class TestCases : List<TestCase>
|
public class TestCases : List<TestCase>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TestCase
|
public class TestCase
|
||||||
{
|
{
|
||||||
public enum CaseType{Training,Test,Validation};
|
public enum CaseType{Training,Test,Validation};
|
||||||
|
|
||||||
public enum GenerateType{Price,BollingerBand,BollingerBandWithVIX};
|
public enum GenerateType{Price,BollingerBand,BollingerBandWithVIX};
|
||||||
|
|
||||||
public enum OutputType{OutputFile,OutputStream}
|
public enum OutputType{OutputFile,OutputStream}
|
||||||
|
|
||||||
private readonly List<Stream> streams=new List<Stream>();
|
private readonly List<Stream> streams=new List<Stream>();
|
||||||
|
|
||||||
private readonly List<String> pathFileNames=new List<String>();
|
private readonly List<String> pathFileNames=new List<String>();
|
||||||
|
|
||||||
private readonly List<String> responses=new List<String>();
|
private readonly List<String> responses=new List<String>();
|
||||||
|
|
||||||
|
public String HomePath { get; set;} = Directory.GetCurrentDirectory();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ProcessData item
|
/// TestCase
|
||||||
/// </summary>
|
/// </summary>
|
||||||
///<param name="symbol">Symbol</param>
|
///<param name="symbol">Symbol</param>
|
||||||
///<param name="startDate">The start datee.</param>
|
///<param name="startDate">The start datee.</param>
|
||||||
@@ -38,18 +47,31 @@ namespace MarketData.CNNProcessing
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String Symbol{get;set;}
|
public String Symbol{get;set;}
|
||||||
|
|
||||||
public DateTime PurchaseDate{get;set;}
|
public DateTime PurchaseDate{get;set;}
|
||||||
|
|
||||||
public DateTime HistDate{get;set;}
|
public DateTime HistDate{get;set;}
|
||||||
|
|
||||||
public CaseType TypeCase{get;set;}
|
public CaseType TypeCase{get;set;}
|
||||||
|
|
||||||
public int DayCount{get;private set;}
|
public int DayCount{get;private set;}
|
||||||
|
|
||||||
public GenerateType TypeGenerate{get;set;}
|
public GenerateType TypeGenerate{get;set;}
|
||||||
|
|
||||||
public OutputType TypeOutput{get;set;}
|
public OutputType TypeOutput{get;set;}
|
||||||
public List<Stream> Streams{get{return streams;}} // This will get set automatically depending on OutputType
|
|
||||||
|
public List<Stream> Streams{get{return streams;}} // This will get set automatically depending on OutputType
|
||||||
|
|
||||||
public List<String> PathFileNames{get{return pathFileNames;}} // This will get set automaticall depending on OutputType
|
public List<String> PathFileNames{get{return pathFileNames;}} // This will get set automaticall depending on OutputType
|
||||||
|
|
||||||
public List<String> Responses{get{return responses;}}
|
public List<String> Responses{get{return responses;}}
|
||||||
|
|
||||||
public Stream LastStream{get{return Streams.Count>0?Streams[Streams.Count-1]:null;}}
|
public Stream LastStream{get{return Streams.Count>0?Streams[Streams.Count-1]:null;}}
|
||||||
|
|
||||||
public String LastPathFileName{get{return PathFileNames.Count>0?PathFileNames[PathFileNames.Count-1]:null;}}
|
public String LastPathFileName{get{return PathFileNames.Count>0?PathFileNames[PathFileNames.Count-1]:null;}}
|
||||||
|
|
||||||
public String LastResponse{get{return Responses.Count>0?Responses[Responses.Count-1]:null;}}
|
public String LastResponse{get{return Responses.Count>0?Responses[Responses.Count-1]:null;}}
|
||||||
|
|
||||||
public override String ToString()
|
public override String ToString()
|
||||||
{
|
{
|
||||||
StringBuilder sb=new StringBuilder();
|
StringBuilder sb=new StringBuilder();
|
||||||
|
|||||||
@@ -186,11 +186,16 @@ public class MarketDataUnitTestClass
|
|||||||
Assert.IsTrue(result);
|
Assert.IsTrue(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// CNNGenerateOutputFileBollingerWithVIX - This generates the new bollinger band with VIX 224x224 image with 90 days of history
|
||||||
|
/// Note that output goes in "/home/pi/ARM64/MarketDataUnitTests/TestResults"
|
||||||
|
/// </summary>
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CNNGenerateOutputFileVIX()
|
public void CNNGenerateOutputFileBollingerWithVIX()
|
||||||
{
|
{
|
||||||
DataProcessor dataProcessor=new DataProcessor();
|
DataProcessor dataProcessor=new DataProcessor();
|
||||||
int imageDimensions=224;
|
int imageDimensions=224;
|
||||||
|
int dayCount = 90;
|
||||||
dataProcessor.Width=imageDimensions;
|
dataProcessor.Width=imageDimensions;
|
||||||
dataProcessor.Height=imageDimensions;
|
dataProcessor.Height=imageDimensions;
|
||||||
dataProcessor.PenWidth=1;
|
dataProcessor.PenWidth=1;
|
||||||
@@ -201,21 +206,27 @@ public class MarketDataUnitTestClass
|
|||||||
|
|
||||||
cmParams.UseCNN = true;
|
cmParams.UseCNN = true;
|
||||||
cmParams.UseCNNHost = "http://" + cnnHostName + ":5000";
|
cmParams.UseCNNHost = "http://" + cnnHostName + ":5000";
|
||||||
cmParams.UseCNNDayCount = 90;
|
cmParams.UseCNNDayCount = dayCount;
|
||||||
cmParams.UseCNNRewardPercentDecimal = 0.25;
|
cmParams.UseCNNRewardPercentDecimal = 0.25;
|
||||||
|
|
||||||
cmCandidate.Symbol = "MIDD";
|
cmCandidate.Symbol = "MIDD";
|
||||||
cmCandidate.TradeDate = DateTime.Parse("07-01-2024");
|
cmCandidate.TradeDate = DateTime.Parse("07-01-2024");
|
||||||
|
|
||||||
TestCase testCase=new TestCase(cmCandidate.Symbol,cmCandidate.TradeDate,cmParams.UseCNNDayCount,TestCase.CaseType.Test,TestCase.GenerateType.BollingerBandWithVIX,TestCase.OutputType.OutputFile);
|
TestCase testCase=new TestCase(cmCandidate.Symbol,cmCandidate.TradeDate,cmParams.UseCNNDayCount,TestCase.CaseType.Test,TestCase.GenerateType.BollingerBandWithVIX,TestCase.OutputType.OutputFile);
|
||||||
|
testCase.HomePath="/home/pi/ARM64/MarketDataUnitTests/TestResults";
|
||||||
dataProcessor.ProcessData(testCase);
|
dataProcessor.ProcessData(testCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// CNNGenerateOutputFileBollinger - This generates the legacy bollinger band 128x128 image with 270 days of history
|
||||||
|
/// Note that output goes in "/home/pi/ARM64/MarketDataUnitTests/TestResults"
|
||||||
|
/// </summary>
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CNNGenerateOutputFileBand()
|
public void CNNGenerateOutputFileBollinger()
|
||||||
{
|
{
|
||||||
DataProcessor dataProcessor=new DataProcessor();
|
DataProcessor dataProcessor=new DataProcessor();
|
||||||
int imageDimensions=224;
|
int imageDimensions=128;
|
||||||
|
int dayCount=270;
|
||||||
dataProcessor.Width=imageDimensions;
|
dataProcessor.Width=imageDimensions;
|
||||||
dataProcessor.Height=imageDimensions;
|
dataProcessor.Height=imageDimensions;
|
||||||
dataProcessor.PenWidth=1;
|
dataProcessor.PenWidth=1;
|
||||||
@@ -226,18 +237,18 @@ public class MarketDataUnitTestClass
|
|||||||
|
|
||||||
cmParams.UseCNN = true;
|
cmParams.UseCNN = true;
|
||||||
cmParams.UseCNNHost = "http://" + cnnHostName + ":5000";
|
cmParams.UseCNNHost = "http://" + cnnHostName + ":5000";
|
||||||
cmParams.UseCNNDayCount = 90;
|
cmParams.UseCNNDayCount = dayCount;
|
||||||
cmParams.UseCNNRewardPercentDecimal = 0.25;
|
cmParams.UseCNNRewardPercentDecimal = 0.25;
|
||||||
|
|
||||||
cmCandidate.Symbol = "MIDD";
|
cmCandidate.Symbol = "MIDD";
|
||||||
cmCandidate.TradeDate = DateTime.Parse("07-01-2024");
|
cmCandidate.TradeDate = DateTime.Parse("07-01-2024");
|
||||||
|
|
||||||
TestCase testCase=new TestCase(cmCandidate.Symbol,cmCandidate.TradeDate,cmParams.UseCNNDayCount,TestCase.CaseType.Test,TestCase.GenerateType.BollingerBand,TestCase.OutputType.OutputFile);
|
TestCase testCase=new TestCase(cmCandidate.Symbol,cmCandidate.TradeDate,cmParams.UseCNNDayCount,TestCase.CaseType.Test,TestCase.GenerateType.BollingerBand,TestCase.OutputType.OutputFile);
|
||||||
|
testCase.HomePath="/home/pi/ARM64/MarketDataUnitTests/TestResults";
|
||||||
dataProcessor.ProcessData(testCase);
|
dataProcessor.ProcessData(testCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void PremarketRetrieval()
|
public void PremarketRetrieval()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user