| Overall Statistics |
|
Total Trades 1 Average Win 65.59% Average Loss 0% Compounding Annual Return 26.94% Drawdown 29.400% Expectancy 0 Net Profit 65.586% Sharpe Ratio 1.05 Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0.128 Beta 0.698 Annual Standard Deviation 0.253 Annual Variance 0.064 Information Ratio 0.281 Tracking Error 0.243 Treynor Ratio 0.381 |
namespace QuantConnect
{
/*
* QuantConnect University: Helper Algorithm - Check there is always data:
*
*/
public class AlwaysDataAlgorithm : QCAlgorithm
{
//Data Required
List<string> _symbols = new List<string>() { "SPY", "AAPL", "IBM" };
TradeBars _bars = new TradeBars();
//Initialize the data and resolution you require for your strategy:
public override void Initialize()
{
//Start and End Date range for the backtest:
SetStartDate(2013, 1, 1);
SetEndDate(DateTime.Now.Date.AddDays(-1));
//Cash allocation
SetCash(25000);
//Add as many securities as you like. All the data will be passed into the event handler:
foreach (var symbol in _symbols) {
AddSecurity(SecurityType.Equity, symbol, Resolution.Minute);
}
}
//Data Event Handler: New data arrives here. "TradeBars" type is a dictionary of strings so you can access it by symbol.
public void OnData(TradeBars data)
{
UpdateBars(data);
if (_bars.Count != _symbols.Count) return;
if (!Portfolio.Invested) Buy("AAPL", 330);
}
//Update the global "_bars" object
private void UpdateBars(TradeBars data)
{
foreach (var bar in data.Values)
{
if (!_bars.ContainsKey(bar.Symbol)) {
_bars.Add(bar.Symbol, bar);
}
_bars[bar.Symbol] = bar;
}
}
}
}