This is a fundamental provider that downloads historical
analyst buy and sell recommendations for U.S. stocks available at
MarketBeat.
Part of MS123 Extra Fundamental/News Providers.
Sample chart annotations |
The provider only considers Upgrades (a green "
+" on charts) and Downgrades (a red "
-") while Initiated's, Reitereated's etc. are ignored. Each rating comes with extra details attached:
firm (analyst),
action (upgrade/downgrade),
rating (the change from and to e.g. "Outperform -> Market Perform") and
priceTarget (previous and current price targets, if available e.g. "$120.00 -> $120.00"). These are available in two forms:
- In a popup when mousing over an Analyst Rating on a stock chart
- In WealthScript Strategies via the GetDetail or FormatValue methods:
Make sure you've collected the fundamental data before running this Strategy (Data Manager > Update Data tab > check "Marketbeat analyst ratings" > DataSets tab > "Update DataSet").
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
namespace WealthLab.Strategies
{
public class MyStrategy : WealthScript
{
protected override void Execute()
{
// Illustrates the usage of GetDetail using the fundamental data item "analyst rating"
const char tab = '\u0009';
string item = "mb analyst rating";
IList fList = FundamentalDataItems(item);
ClearDebug();
PrintDebug(Bars.Symbol + tab + "Item Count: " + fList.Count);
PrintDebug("Date " + tab + "Analyst");
foreach (FundamentalItem fi in fList)
{
PrintDebug(
fi.Date.ToShortDateString() + tab +
fi.GetDetail("firm") + tab +
fi.GetDetail("action") + tab +
fi.GetDetail("rating") + tab +
fi.GetDetail("priceTarget") + tab );
}
}
}
}