Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return -3.800% Drawdown 87.200% Expectancy 0 Net Profit 0% Sharpe Ratio 0.4 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.348 Beta 0.331 Annual Standard Deviation 0.897 Annual Variance 0.804 Information Ratio 0.362 Tracking Error 0.902 Treynor Ratio 1.083 Total Fees $0.00 |
using System; using System.Collections; using System.Collections.Generic; using QuantConnect.Securities; using QuantConnect.Models; using System.Globalization; namespace QuantConnect { /* * QuantConnect University: Generic GOOGLE Data Importer: * * Import Google data using only a symbol. Be sure to confirm google has the * data you're requesting. */ public class Google : 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 Google() { } /// <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) { var startDate = new DateTime(2000, 1, 1).ToString("yyyy-MM-dd"); var endDate = DateTime.Now.ToString("yyyy-MM-dd"); //QUANDL WRAPPER ON Google FINANCE API TO SORT DATA: //https://www.quandl.com/api/v1/datasets/GOOG/NYSE_TKC.csv?trim_start=2000-01-01&trim_end=2014-12-03&sort_order=asc return new SubscriptionDataSource("https://www.quandl.com/api/v1/datasets/GOOG/" + config.Symbol + ".csv?trim_start=" + startDate + "&trim_end=" + endDate + "&sort_order=asc&exclude_headers=true", SubscriptionTransportMedium.RemoteFile); } /// <summary> /// Convert each line of the file above into an object. /// </summary> public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLive) { Google gBar = new Google(); try { string[] data = line.Split(','); //Required. gBar.Symbol = config.Symbol; gBar.Time = DateTime.ParseExact(data[0], "yyyy-MM-dd", CultureInfo.InvariantCulture); //User configured / optional data on each bar: gBar.Open = Convert.ToDecimal(data[1]); gBar.High = Convert.ToDecimal(data[2]); gBar.Low = Convert.ToDecimal(data[3]); gBar.Close = Convert.ToDecimal(data[4]); gBar.Volume = Convert.ToDecimal(data[5]); //This is the value the engine uses for portfolio calculations gBar.Value = gBar.Close; } catch { } return gBar; } } }
using System; using System.Collections; using System.Collections.Generic; using QuantConnect.Securities; using QuantConnect.Models; namespace QuantConnect { /* * QuantConnect University: Importing Custom Yahoo / Google Data: * * With the LEAN Engine you can import any data type. We attempt to make this * easier by providing importer code for Yahoo and Google. * * Quandl.com is a library and API wrapper for many data sources which makes * sorting and reading the data easier. */ public class CustomDataYahooQuandl : QCAlgorithm { //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<Yahoo>("INDEX_SPY"); AddData<Yahoo>("INDEX_VIX"); //Google finance importing foreign markets sources AddData<Google>("NYSE_TKC"); } /// <summary> /// Google Finance Daily Bars Event Handler: /// </summary> public void OnData(Google data) { // Google TKC Data Events Here: } /// <summary> /// Yahoo Daily Bars Event Handler: Daily bars arrive here for processing. /// </summary> public void OnData(Yahoo data) { //Google/Quandl TKC Events here: if (!Portfolio.Invested && data.Value > 0 && data.Symbol == "INDEX_VIX") { 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) { } } }
using System.Globalization; namespace QuantConnect { /* * QuantConnect University: Generic Yahoo Data Importer: * * Import Yahoo data using only a symbol. Be sure to confirm yahoo has the * data you're requesting. */ public class Yahoo : 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 Yahoo() { 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) { var startDate = new DateTime(2000, 1, 1).ToString("yyyy-MM-dd"); var endDate = DateTime.Now.ToString("yyyy-MM-dd"); //QUANDL WRAPPER ON YAHOO FINANCE API TO SORT DATA: //https://www.quandl.com/api/v1/datasets/YAHOO/INDEX_SPY.csv?trim_start=2000-01-01&trim_end=2014-12-03&sort_order=asc return new SubscriptionDataSource("https://www.quandl.com/api/v1/datasets/YAHOO/" + config.Symbol + ".csv?trim_start=" + startDate + "&trim_end=" + endDate + "&sort_order=asc&exclude_headers=true", SubscriptionTransportMedium.RemoteFile); } /// <summary> /// Convert each line of the file above into an object. /// </summary> public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLive) { Yahoo yBar = new Yahoo(); try { string[] data = line.Split(','); //Required. yBar.Symbol = config.Symbol; yBar.Time = DateTime.ParseExact(data[0], "yyyy-MM-dd", CultureInfo.InvariantCulture); //User configured / optional data on each bar: yBar.Open = Convert.ToDecimal(data[1]); yBar.High = Convert.ToDecimal(data[2]); yBar.Low = Convert.ToDecimal(data[3]); yBar.Close = Convert.ToDecimal(data[4]); yBar.Volume = Convert.ToDecimal(data[5]); yBar.AdjustedClose = Convert.ToDecimal(data[6]); //This is the value the engine uses for portfolio calculations yBar.Value = yBar.AdjustedClose; } catch { } return yBar; } } }