Merge branch 'MKDT_CNN01'
This commit is contained in:
@@ -5,6 +5,7 @@ using MarketData.MarketDataModel;
|
||||
using MarketData.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace MarketData.Generator.CMMomentum
|
||||
@@ -132,6 +133,35 @@ namespace MarketData.Generator.CMMomentum
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// This method is made public in order that it can be tested
|
||||
//public static bool PredictCandidate(CMCandidate cmCandidate,CMParams cmParams)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// CNNClient cnnClient=new CNNClient(cmParams.UseCNNHost);
|
||||
// DataProcessor dataProcessor=new DataProcessor();
|
||||
// dataProcessor.Width=128;
|
||||
// dataProcessor.Height=128;
|
||||
// dataProcessor.PenWidth=1;
|
||||
// TestCase testCase=new TestCase(cmCandidate.Symbol,cmCandidate.TradeDate,cmParams.UseCNNDayCount,TestCase.CaseType.Test,TestCase.GenerateType.BollingerBand,TestCase.OutputType.OutputStream);
|
||||
// dataProcessor.ProcessData(testCase);
|
||||
// String prediction = cnnClient.Predict(CNNClient.Model.resnet50_20241024_270,testCase.LastStream);
|
||||
// prediction=prediction.Substring(prediction.IndexOf("-->"));
|
||||
// int result=int.Parse(Utility.BetweenString(prediction,"[[","]"));
|
||||
// if(1==result)
|
||||
// {
|
||||
// cmCandidate.Score*=(1.00+cmParams.UseCNNRewardPercentDecimal); // increase the score by the percentage indicated in the params settings
|
||||
// cmCandidate.CNNPrediction=true;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// catch(Exception exception)
|
||||
// {
|
||||
// MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Error encountered calling convolutional model at {0}. Exception was {1}",cmParams.UseCNNHost,exception.ToString()));
|
||||
// return false;
|
||||
// }
|
||||
//}
|
||||
|
||||
// This method is made public in order that it can be tested
|
||||
public static bool PredictCandidate(CMCandidate cmCandidate,CMParams cmParams)
|
||||
{
|
||||
@@ -139,12 +169,14 @@ namespace MarketData.Generator.CMMomentum
|
||||
{
|
||||
CNNClient cnnClient=new CNNClient(cmParams.UseCNNHost);
|
||||
DataProcessor dataProcessor=new DataProcessor();
|
||||
dataProcessor.Width=128;
|
||||
dataProcessor.Height=128;
|
||||
int imageDimensions=224;
|
||||
dataProcessor.Width=imageDimensions;
|
||||
dataProcessor.Height=imageDimensions;
|
||||
dataProcessor.PenWidth=1;
|
||||
TestCase testCase=new TestCase(cmCandidate.Symbol,cmCandidate.TradeDate,cmParams.UseCNNDayCount,TestCase.CaseType.Test,TestCase.GenerateType.BollingerBand,TestCase.OutputType.OutputStream);
|
||||
TestCase testCase=new TestCase(cmCandidate.Symbol,cmCandidate.TradeDate,cmParams.UseCNNDayCount,TestCase.CaseType.Test,TestCase.GenerateType.BollingerBandWithVIX,TestCase.OutputType.OutputStream);
|
||||
dataProcessor.ProcessData(testCase);
|
||||
String prediction = cnnClient.Predict(CNNClient.Model.resnet50_20241024_270,testCase.LastStream);
|
||||
Stream streamResult = cnnClient.ProcessImage(testCase.LastStream); // process the image through PIL
|
||||
String prediction = cnnClient.Predict(CNNClient.Model.convnext,streamResult);
|
||||
prediction=prediction.Substring(prediction.IndexOf("-->"));
|
||||
int result=int.Parse(Utility.BetweenString(prediction,"[[","]"));
|
||||
if(1==result)
|
||||
@@ -160,5 +192,7 @@ namespace MarketData.Generator.CMMomentum
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user