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.Globalization; using QuantConnect.Data; namespace QuantConnect.Algorithm.CSharp { public class EminiAlgorithm : QCAlgorithm { public override void Initialize() { SetStartDate(2016, 01, 04); SetEndDate(2016, 01, 04); //Set the cash for the strategy: SetCash(100000); //Define the symbol and "type" of our generic data: AddData<Emini>("ES"); } public void OnData(Emini data) { if (data.Time.TimeOfDay < new TimeSpan(9, 30, 00) || data.Time.TimeOfDay > new TimeSpan(12, 00, 00)) { return; } else { if (!Portfolio.Invested) { int quantity = (int)Math.Floor(Portfolio.Cash / data.Open); Order("ES", quantity); Debug("Buying " + quantity + " contracts at " + data.Open + " $"); } } } } public class Emini : BaseData { public decimal Open = 0; public decimal High = 0; public decimal Low = 0; public decimal Close = 0; public long Volume = 0; public Emini() { Symbol = "ES"; } public override SubscriptionDataSource GetSource(SubscriptionDataConfig config, DateTime date, bool isLiveMode) { return new SubscriptionDataSource("https://www.dropbox.com/s/jni2cm5r9d22a60/ES%202016-01-04%20-%202016-12-19.csv?dl=1 ", SubscriptionTransportMedium.RemoteFile); } public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode) { Emini index = new Emini(); try { var data = line.Split(','); var nowDate = DateTime.Parse(data[0], CultureInfo.InvariantCulture); var nowTime = TimeSpan.ParseExact(data[1], "HHmmss", CultureInfo.InvariantCulture); index.Time = nowDate + nowTime; index.Open = Convert.ToDecimal(data[2], CultureInfo.InvariantCulture); index.High = Convert.ToDecimal(data[3], CultureInfo.InvariantCulture); index.Low = Convert.ToDecimal(data[4], CultureInfo.InvariantCulture); index.Close = Convert.ToDecimal(data[5], CultureInfo.InvariantCulture); index.Volume = Convert.ToInt32(data[6], CultureInfo.InvariantCulture); index.Symbol = "ES"; index.Value = index.Close; } catch { /* Do nothing, skip first title row */ } return index; } } }