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(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]);
|
||||
}
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,16 +11,25 @@ namespace MarketData.CNNProcessing
|
||||
public class TestCases : List<TestCase>
|
||||
{
|
||||
}
|
||||
|
||||
public class TestCase
|
||||
{
|
||||
public enum CaseType{Training,Test,Validation};
|
||||
|
||||
public enum GenerateType{Price,BollingerBand,BollingerBandWithVIX};
|
||||
|
||||
public enum OutputType{OutputFile,OutputStream}
|
||||
|
||||
private readonly List<Stream> streams=new List<Stream>();
|
||||
|
||||
private readonly List<String> pathFileNames=new List<String>();
|
||||
|
||||
private readonly List<String> responses=new List<String>();
|
||||
|
||||
public String HomePath { get; set;} = Directory.GetCurrentDirectory();
|
||||
|
||||
/// <summary>
|
||||
/// ProcessData item
|
||||
/// TestCase
|
||||
/// </summary>
|
||||
///<param name="symbol">Symbol</param>
|
||||
///<param name="startDate">The start datee.</param>
|
||||
@@ -38,18 +47,31 @@ namespace MarketData.CNNProcessing
|
||||
}
|
||||
|
||||
public String Symbol{get;set;}
|
||||
|
||||
public DateTime PurchaseDate{get;set;}
|
||||
|
||||
public DateTime HistDate{get;set;}
|
||||
|
||||
public CaseType TypeCase{get;set;}
|
||||
|
||||
public int DayCount{get;private set;}
|
||||
|
||||
public GenerateType TypeGenerate{get;set;}
|
||||
|
||||
public OutputType TypeOutput{get;set;}
|
||||
|
||||
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> Responses{get{return responses;}}
|
||||
|
||||
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 LastResponse{get{return Responses.Count>0?Responses[Responses.Count-1]:null;}}
|
||||
|
||||
public override String ToString()
|
||||
{
|
||||
StringBuilder sb=new StringBuilder();
|
||||
|
||||
@@ -186,11 +186,16 @@ public class MarketDataUnitTestClass
|
||||
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]
|
||||
public void CNNGenerateOutputFileVIX()
|
||||
public void CNNGenerateOutputFileBollingerWithVIX()
|
||||
{
|
||||
DataProcessor dataProcessor=new DataProcessor();
|
||||
int imageDimensions=224;
|
||||
int dayCount = 90;
|
||||
dataProcessor.Width=imageDimensions;
|
||||
dataProcessor.Height=imageDimensions;
|
||||
dataProcessor.PenWidth=1;
|
||||
@@ -201,21 +206,27 @@ public class MarketDataUnitTestClass
|
||||
|
||||
cmParams.UseCNN = true;
|
||||
cmParams.UseCNNHost = "http://" + cnnHostName + ":5000";
|
||||
cmParams.UseCNNDayCount = 90;
|
||||
cmParams.UseCNNDayCount = dayCount;
|
||||
cmParams.UseCNNRewardPercentDecimal = 0.25;
|
||||
|
||||
cmCandidate.Symbol = "MIDD";
|
||||
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.HomePath="/home/pi/ARM64/MarketDataUnitTests/TestResults";
|
||||
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]
|
||||
public void CNNGenerateOutputFileBand()
|
||||
public void CNNGenerateOutputFileBollinger()
|
||||
{
|
||||
DataProcessor dataProcessor=new DataProcessor();
|
||||
int imageDimensions=224;
|
||||
int imageDimensions=128;
|
||||
int dayCount=270;
|
||||
dataProcessor.Width=imageDimensions;
|
||||
dataProcessor.Height=imageDimensions;
|
||||
dataProcessor.PenWidth=1;
|
||||
@@ -226,18 +237,18 @@ public class MarketDataUnitTestClass
|
||||
|
||||
cmParams.UseCNN = true;
|
||||
cmParams.UseCNNHost = "http://" + cnnHostName + ":5000";
|
||||
cmParams.UseCNNDayCount = 90;
|
||||
cmParams.UseCNNDayCount = dayCount;
|
||||
cmParams.UseCNNRewardPercentDecimal = 0.25;
|
||||
|
||||
cmCandidate.Symbol = "MIDD";
|
||||
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.HomePath="/home/pi/ARM64/MarketDataUnitTests/TestResults";
|
||||
dataProcessor.ProcessData(testCase);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void PremarketRetrieval()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user