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.Globalization; namespace QuantConnect { /* * QuantConnect University: Generic data import for Quandl data */ public class QuandlReader : BaseData { public decimal Open = 0; public decimal High = 0; public decimal Low = 0; public decimal Close = 0; // public decimal AdjustedClose = 0; // public decimal Volume = 0; public QuandlReader() { this.Symbol = ""; } /// <summary> /// Return the URL external source for the data: QuantConnect will download it an read it line by line automatically: /// </summary> public override SubscriptionDataSource GetSource(SubscriptionDataConfig config, DateTime date, bool isLive) { this.Symbol = config.Symbol; var startDate = new DateTime(2000, 1, 1).ToString("yyyy-MM-dd"); var endDate = DateTime.Now.ToString("yyyy-MM-dd"); return new SubscriptionDataSource("https://www.quandl.com/api/v1/datasets/" + config.Symbol + ".csv?trim_start=" + startDate + "&trim_end=" + endDate + "&sort_order=asc&exclude_headers=true", SubscriptionTransportMedium.RemoteFile); } public override BaseData Clone() { QuandlReader coin = new QuandlReader(); coin.Close = this.Close; coin.High = this.High; coin.Low = this.Low; coin.Open = this.Open; coin.Symbol = this.Symbol; coin.Value = this.Close; coin.Time = this.Time; return coin; } /// <summary> /// Convert each line of the file above into an object. /// </summary> public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLive) { QuandlReader bar = new QuandlReader(); try { string[] data = line.Split(','); //Required. bar.Symbol = config.Symbol; bar.Time = DateTime.ParseExact(data[0], "yyyy-MM-dd", CultureInfo.InvariantCulture); //User configured / optional data on each bar: bar.Open = Convert.ToDecimal(data[1]); bar.High = Convert.ToDecimal(data[2]); bar.Low = Convert.ToDecimal(data[3]); bar.Close = Convert.ToDecimal(data[4]); // bar.Volume = Convert.ToDecimal(data[5]); // We don't need volume // bar.AdjustedClose = Convert.ToDecimal(data[6]); // We don't need adjusted close //This is the value the engine uses for portfolio calculations bar.Value = bar.Close; // bar.Value = bar.AdjustedClose; // I want to the close, not adjusted close. } catch { /* Do nothing, skip first title row */ } return bar; } } }
using System; using System.Collections; using System.Collections.Generic; using QuantConnect.Securities; using QuantConnect.Models; namespace QuantConnect { /* * QuantConnect University: Importing Custom Yahoo / Google Data: * * Quandl.com is a library and API wrapper for many data sources which makes * sorting and reading the data easier. */ public class CustomDataYahooQuandl : QCAlgorithm { public static string indicatorOne = "YAHOO/VIX"; public static string indicatorTwo = "GOOG/NYSE_TKC"; public bool first = true; //Initialize the data and resolution you require for your strategy: /// <summary> /// Setup the algorithm data, cash, job start end date etc: /// </summary> public override void Initialize() { SetStartDate(2000, 1, 1); SetEndDate(DateTime.Now); SetCash(25000); //Quandl Indexes AddData<QuandlReader>(indicatorOne); AddData<QuandlReader>(indicatorTwo); } public void OnData(QuandlReader data) { if (!Portfolio.Invested && data.Value > 0 && data.Symbol == indicatorOne) { var quantity = (int) (Portfolio.Cash / data.Value); Order("INDEX_VIX", quantity); } } /// <summary> /// QC-TradeBars Data Event Handler: Not used in this strategy: /// </summary> public void OnData(TradeBars data) { } } }