| Overall Statistics |
|
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return -5.775% Drawdown 36.900% Expectancy 0 Net Profit 0% Sharpe Ratio -0.326 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.041 Beta 0.014 Annual Standard Deviation 0.123 Annual Variance 0.015 Information Ratio -0.729 Tracking Error 0.183 Treynor Ratio -2.812 Total Fees $0.00 |
namespace QuantConnect
{
/// <summary>
/// Shows how to use the Minus and Of extension methods to define a MACD on the
/// difference in closing price between two securities
/// </summary>
public class MacdOnDifferenceAlgorithm : QCAlgorithm
{
/// <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(2011, 01, 01); //Set Start Date
SetEndDate(2015, 10, 11); //Set End Date
SetCash(100000); //Set Strategy Cash
// Find more symbols here: http://quantconnect.com/data
AddSecurity(SecurityType.Forex, "USDCAD", Resolution.Daily);
//AddSecurity(SecurityType.Equity, "MSFT", Resolution.Daily);
AddData<QuandlFuture>("SCF/CME_CL1_ON", Resolution.Daily);
// The reason we need to explicitly define our consolidator here
// is because out data type: QuandlFuture, doesn't actually create
// instances of QuandlFutures, instead they create instance of Quandl
// which then are being passed into our consolidators. We've defined
// our consolidator to work on Quandl data instead. If we wanted, we
// could also implement the Reader method in QuandlFuture and have it
// return a QuandlFuture instance and then the old commented our code
// would work as expected.
// Identity will get updated on each data point before OnData gets called
var msft = new Identity("SCF/CME_CL1_ON");// Identity("SCF/CME_CL1_ON");
var msftConsolidator = new IdentityDataConsolidator<Quandl>();
RegisterIndicator("SCF/CME_CL1_ON", msft, msftConsolidator);
var aapl = Identity("USDCAD");
// Minus will get free updates from it's components pieces (msft, aapl)
var diff = msft.Minus(aapl);
// Of will get free updates from it's parent indicator (diff)
var macdDiff = new MovingAverageConvergenceDivergence("CL1_CAD_MACD", 12, 26, 9).Of(diff);
// Plot macdDiff on each new update
PlotIndicator("CL1_CAD_MACD", macdDiff);
}
/// <summary>
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
/// </summary>
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
public override void OnData(Slice data)
{
if (!Portfolio.Invested)
{
SetHoldings("SCF/CME_CL1_ON", .5);
SetHoldings("USDCAD", .5);
}
}
}
public class QuandlFuture : Quandl
{
public QuandlFuture()
: base(valueColumnName: "Settle")
{
}
}
}