29 lines
1.0 KiB
C#
29 lines
1.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Microsoft.Research.DynamicDataDisplay.DataSources;
|
|
using MarketData.MarketDataModel;
|
|
|
|
namespace TradeBlotter.Model
|
|
{
|
|
public class RatingsModel
|
|
{
|
|
private RatingsModel()
|
|
{
|
|
}
|
|
// if latestPrice is provided and PriceTarget of rating is zero then the graph is placed at current price. This improves the appearance of the graph on the screen
|
|
public static CompositeDataSource Ratings(AnalystRatings analystRatings,Price latestPrice)
|
|
{
|
|
if (null == analystRatings) return null;
|
|
CompositeDataSource compositeDataSource;
|
|
var xData = new EnumerableDataSource<DateTime>(analystRatings.Select(x => x.Date.Date));
|
|
xData.SetXMapping(x => (x.Ticks / 10000000000.0));
|
|
var yData = new EnumerableDataSource<double>(analystRatings.Select(y => 0==y.PriceTarget&&null!=latestPrice?latestPrice.Close:y.PriceTarget));
|
|
yData.SetYMapping(y => y);
|
|
compositeDataSource = xData.Join(yData);
|
|
return compositeDataSource;
|
|
}
|
|
}
|
|
}
|