| Overall Statistics |
|
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees $0.00 |
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Data.Market;
using QuantConnect.Orders;
using QuantConnect.Orders.Fees;
using QuantConnect.Orders.Fills;
using QuantConnect.Orders.Slippage;
using QuantConnect.Securities;
namespace QuantConnect
{
public class AutomatonTrade : QCAlgorithm
{
private List<string> symbolTracker = new List<string>();
public override void Initialize()
{
// Initialize.
this.SetStartDate(2017, 1, 1);
this.SetEndDate(2017, 1, 31);
this.SetCash(1000);
this.SetTimeZone(TimeZones.NewYork);
// Setup brokerage.
this.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin);
// Setup universe.
this.UniverseSettings.Resolution = Resolution.Minute;
// Live universe with selection.
this.AddUniverse(CoarseSelectionFunction);
}
public IEnumerable<Symbol> CoarseSelectionFunction(IEnumerable<CoarseFundamental> coarse)
{
var sortedByDollarVolume = coarse
.Where(x => x.Volume > 1000000)
.OrderBy(x => x.Price)
.ThenByDescending(x => x.DollarVolume)
.ThenByDescending(x => x.Volume);
var top = sortedByDollarVolume.Take(200);
this.Log("CoarseSelectionFunction count: " + top.Count());
return top.Select(x => x.Symbol);
}
public override void OnSecuritiesChanged(SecurityChanges changes)
{
this.Log("ActiveSecurities count: " + this.ActiveSecurities.Count());
if (changes.AddedSecurities.Count > 0)
{
foreach (var security in changes.AddedSecurities)
{
this.symbolTracker.Add(security.Symbol);
}
}
if (changes.RemovedSecurities.Count > 0)
{
foreach (var security in changes.RemovedSecurities)
{
this.symbolTracker.Remove(security.Symbol);
}
}
this.Log("symbolTracker count: " + this.symbolTracker.Count());
}
private void Log(string message)
{
base.Log(message);
Debug(message);
}
}
}