109 lines
2.7 KiB
C#
109 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using MarketData.Utils;
|
|
|
|
namespace MarketData.MarketDataModel
|
|
{
|
|
public class AnalystRatings : List<AnalystRating>
|
|
{
|
|
public AnalystRatings()
|
|
{
|
|
}
|
|
public AnalystRatings(List<AnalystRating> analystRatings)
|
|
{
|
|
foreach(AnalystRating analystRating in analystRatings)Add(analystRating);
|
|
}
|
|
public List<String> Symbols
|
|
{
|
|
get { return (from analystRating in this select analystRating.Symbol).ToList(); }
|
|
}
|
|
public void Remove(List<String> symbols)
|
|
{
|
|
for (int index = 0; index < symbols.Count; index++)
|
|
{
|
|
this.RemoveAll(x => x.Symbol.Equals(symbols[index]));
|
|
}
|
|
}
|
|
public void CalculateUpdatePercentiles()
|
|
{
|
|
double totalCount=1;
|
|
double upgradeCount=0;
|
|
for(int index=this.Count-1;index>=0;index--,totalCount++)
|
|
{
|
|
AnalystRating analystRating=this[index];
|
|
if(analystRating.Type.Equals("Upgrades")&&!analystRating.RatingsChange.Contains("Sell"))upgradeCount++;
|
|
analystRating.UpgradePercentile=(upgradeCount/totalCount)*100.00;
|
|
}
|
|
}
|
|
}
|
|
public class AnalystRating
|
|
{
|
|
private DateTime date;
|
|
private String symbol;
|
|
private String brokerageFirm;
|
|
private String type;
|
|
private String ratingsChange;
|
|
private double priceTarget;
|
|
private String companyName;
|
|
private double upgradePercentile;
|
|
|
|
public AnalystRating()
|
|
{
|
|
}
|
|
public DateTime Date
|
|
{
|
|
get { return date; }
|
|
set { date = value; }
|
|
}
|
|
public String Symbol
|
|
{
|
|
get { return symbol; }
|
|
set { symbol = value.Trim(); }
|
|
}
|
|
public String CompanyName
|
|
{
|
|
get { return companyName; }
|
|
set { companyName = value; }
|
|
}
|
|
public String BrokerageFirm
|
|
{
|
|
get { return brokerageFirm; }
|
|
set { brokerageFirm=value; }
|
|
}
|
|
public String Type
|
|
{
|
|
get { return type; }
|
|
set { type = value; }
|
|
}
|
|
public String RatingsChange
|
|
{
|
|
get { return ratingsChange; }
|
|
set { ratingsChange = value; }
|
|
}
|
|
public double PriceTarget
|
|
{
|
|
get { return priceTarget; }
|
|
set { priceTarget = value; }
|
|
}
|
|
public double UpgradePercentile
|
|
{
|
|
get{return upgradePercentile;}
|
|
set{upgradePercentile=value;}
|
|
|
|
}
|
|
public override String ToString()
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append(Symbol).Append(",");
|
|
sb.Append(CompanyName).Append(",");
|
|
sb.Append(BrokerageFirm).Append(",");
|
|
sb.Append(Type).Append(",");
|
|
sb.Append(RatingsChange).Append(",");
|
|
sb.Append(Utility.FormatCurrency(PriceTarget));
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
}
|