Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return -15.060% Drawdown 75.100% Expectancy 0 Net Profit 0% Sharpe Ratio -0.241 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.067 Beta -0.032 Annual Standard Deviation 0.292 Annual Variance 0.085 Information Ratio -0.504 Tracking Error 0.31 Treynor Ratio 2.202 Total Fees $0.00 |
from clr import AddReference AddReference("System") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Indicators") AddReference("QuantConnect.Common") AddReference("QuantConnect.Configuration") from System import * from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Data import * from QuantConnect.Indicators import * from QuantConnect.Orders import * from QuantConnect.Securities import * from QuantConnect.Python import PythonData from QuantConnect.Configuration import Config from datetime import datetime, timedelta import decimal class QCUQuandlFutures(QCAlgorithm): '''QuantConnect University: Generic Quandl Data Importer Using the underlying dynamic data class "Quandl" we take care of the data importing and definition for you. Simply point QuantConnect to the Quandl Short Code. The Quandl object has properties which match the spreadsheet headers. If you have multiple quandl streams look at data.Symbol to distinguish them.''' def Initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.quandlCode = "SCF/CME_CL1_ON"; self.SetStartDate(2013,1,1) #Set Start Date self.SetEndDate(datetime.today() - timedelta(1)) #Set End Date self.SetCash(25000) #Set Strategy Cash self.AddData(QuandlFuture, self.quandlCode, Resolution.Daily) self.sma = self.SMA(self.quandlCode, 14) def OnData(self, data): '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.''' if not self.Portfolio.HoldStock: self.SetHoldings(self.quandlCode, 1) self.Debug("Purchased {0} >> {1}".format(self.quandlCode, self.Time)) self.Plot(self.quandlCode, self.sma.Current.Value) class QuandlFuture(PythonData): def GetSource(self, config, date, isLiveMode): return SubscriptionDataSource(str("https://www.quandl.com/api/v3/datasets/") + str(config.Symbol) + str(".csv?order=asc&api_key=" + str(Config.Get("quandl-auth-token"))), SubscriptionTransportMedium.RemoteFile) def Reader(self, config, line, date, isLiveMode): quandl_future = QuandlFuture() quandl_future.Symbol = config.Symbol # Example Line Format: # Date,Open,High,Low,Settle,Volume,Prev. Day Open Interest # 2005-01-03,43.1,43.1,41.25,42.12,69484.0,165451.0 if not (line.strip() and line[0].isdigit()): return None try: data = line.split(',') value = float(data[4]) if value == 0: return None quandl_future.Time = datetime.strptime(data[0], "%Y-%m-%d") quandl_future.Value = decimal.Decimal(value) quandl_future["Settle"] = value return quandl_future; except ValueError: return None