57 lines
2.3 KiB
C#
Executable File
57 lines
2.3 KiB
C#
Executable File
using MarketData.MarketDataModel;
|
|
|
|
namespace MarketData.Generator.Momentum
|
|
{
|
|
public class QualityIndicatorCandidate
|
|
{
|
|
public QualityIndicatorCandidate()
|
|
{
|
|
}
|
|
//public QualityIndicatorCandidate(String symbol,double idIndicator,double score)
|
|
//{
|
|
// Symbol=symbol;
|
|
// IDIndicator=idIndicator;
|
|
// Score=score;
|
|
//}
|
|
public String Symbol{get;set;}
|
|
public double CumReturn252{get;set;}
|
|
public double IDIndicator{get;set;}
|
|
public double Score{get;set;}
|
|
public int DayCount{get;set;}
|
|
public double PE{get;set;}
|
|
public double Beta{get;set;}
|
|
public double Return1D{get;set;}
|
|
}
|
|
// *********************************************************************************************************
|
|
public class IDIndicator
|
|
{
|
|
private IDIndicator()
|
|
{
|
|
}
|
|
//CountOf CountOf
|
|
//Negative Positive Return Sign IDIndicator
|
|
// 50 202 0.2 1 -60.31746032
|
|
// 100 152 0.2 1 -20.63492063
|
|
// 0 252 0.1 1 -100
|
|
// 0 252 0.2 1 -100
|
|
// The lower the IDIndicator the better
|
|
// This calculator deviates from the original by using an exponential decay on the stream of returns such that weigh distant returns a bit less than current returns
|
|
// and thereby attempt to give a more accurate picture of the quality of current returns.
|
|
public static double Calculate(Prices prices)
|
|
{
|
|
double idIndicator=0.00;
|
|
double cumulativeReturn=0.00;
|
|
float[] returns=prices.GetReturns();
|
|
ExponentialDecay exponentialDecay=new ExponentialDecay();
|
|
exponentialDecay.Prime(returns,2.00);
|
|
for(int index=0;index<returns.Length;index++)returns[index]=returns[index]*(float)exponentialDecay[index];
|
|
double positiveCount=(from float value in returns where value>0.00 select value).Count();
|
|
double negativeCount=(from float value in returns where value<0.00 select value).Count();
|
|
for(int index=0;index<returns.Length;index++)cumulativeReturn+=(double)returns[index];
|
|
double sign=cumulativeReturn>0.00?1.00:-1.00;
|
|
idIndicator=sign*((negativeCount/returns.Length)*100.00-(positiveCount/returns.Length)*100.00);
|
|
return idIndicator;
|
|
}
|
|
}
|
|
}
|