| Overall Statistics |
|
Total Trades 1 Average Win 25.97% Average Loss 0% Compounding Annual Return 7.784% Drawdown 43.700% Expectancy 0 Net Profit 25.981% Sharpe Ratio 0.387 Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0.15 Beta -0.033 Annual Standard Deviation 0.388 Annual Variance 0.151 Information Ratio 0.341 Tracking Error 0.449 Treynor Ratio -4.556 |
namespace QuantConnect
{
/// <summary>
/// QC University algorithm to demonstrate split and dividend events
/// </summary>
public class QCUTotalReturnsAlgorithm : QCAlgorithm
{
public SimpleMovingAverage SMA_MSFT;
/// <summary>
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
/// </summary>
public override void Initialize()
{
SetStartDate(2001, 01, 01); //Set Start Date
SetEndDate(2004, 02, 01); //Set End Date
SetCash(100000); //Set Strategy Cash
// Find more symbols here: http://quantconnect.com/data
AddSecurity(SecurityType.Equity, "MSFT", Resolution.Minute);
Securities["MSFT"].SetDataNormalizationMode(DataNormalizationMode.Raw);
SMA_MSFT = SMA("MSFT", 14);
}
/// <summary>
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
/// </summary>
/// <param name="data">TradeBars IDictionary object with your stock data</param>
public void OnData(TradeBars data)
{
if (!Portfolio.Invested)
{
SetHoldings("MSFT", .5);
Debug("Purchased Stock");
}
if (data.Time.Date == new DateTime(2004, 01, 07) && data.Time.Hour == 10 && data.Time.Minute == 0)
{
// split adjusted and raw have the same value here because there are no MSFT splits after Feb 18, 2003
// DataNormalizationMode.TotalReturn = SMA Value: 28.41071
// DataNormalizationMode.Raw = SMA Value: 28.17071
// DataNormalizationMode.Adjusted = SMA Value: 20.22256
// DataNormalizationMode.SplitAdjusted = SMA Value: 28.17071
Debug("SMA Value: " + SMA_MSFT);
}
}
public void OnData(Dividends data) // update this to Dividends dictionary
{
var dividend = data["MSFT"];
Debug(string.Format("{0} >> DIVIDEND >> {1} - {2} - {3} - {4}", dividend.Time.ToString("o"), dividend.Symbol, dividend.Distribution.ToString("C"), Portfolio.Cash, Portfolio["MSFT"].Price.ToString("C")));
}
public void OnData(Splits data)
{
var split = data["MSFT"];
Debug(string.Format("{0} >> SPLIT >> {1} - {2} - {3} - {4} - {5}", split.Time.ToString("o"), split.Symbol, split.SplitFactor, Portfolio.Cash, Portfolio["MSFT"].Quantity, Portfolio["MSFT"].Price.ToString("C")));
}
}
}