Remove Quandl from LEAN (#6110)
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
* Remove Quandl from LEAN * Nit changes and CustomLiveDataFeedTests.cs * Resolve conflicts * Remove files related with Quandl * Fix bug * Fix QuantBookHistoryTests.cs * Fix bug * Fix bug * Fix unit tests * Try fix regression tests * Nit changes * Fix bug * Some of the requested changes * The missing changes * Requested changes * Nit changes * Revert "Nit changes" This reverts commit 9800bc5c34f3ac20e30bea7a92dd4a9867213bb5. * Nit changes * Fix bug * Requested changes * Missing file using Quandl to be removed * Nit changes * Not applied nit change * Nit change * Nit change * Add nasdaq-auth-code parameter in config.json * Remove 'quandl-auth-token' from config.json Co-authored-by: Martin-Molinero <martin@quantconnect.com>
This commit is contained in:
committed by
GitHub
parent
0c26d42561
commit
472f78cc53
@@ -30,12 +30,11 @@ class HistoryAlgorithm(QCAlgorithm):
|
||||
self.SetCash(100000) #Set Strategy Cash
|
||||
# Find more symbols here: http://quantconnect.com/data
|
||||
self.AddEquity("SPY", Resolution.Daily)
|
||||
self.AddData(QuandlFuture,"CHRIS/CME_SP1", Resolution.Daily)
|
||||
self.AddData(CustomDataEquity, "IBM", Resolution.Daily)
|
||||
# specifying the exchange will allow the history methods that accept a number of bars to return to work properly
|
||||
self.Securities["CHRIS/CME_SP1"].Exchange = EquityExchange()
|
||||
|
||||
# we can get history in initialize to set up indicators and such
|
||||
self.spyDailySma = SimpleMovingAverage(14)
|
||||
self.dailySma = SimpleMovingAverage(14)
|
||||
|
||||
# get the last calendar year's worth of SPY data at the configured resolution (daily)
|
||||
tradeBarHistory = self.History([self.Securities["SPY"].Symbol], timedelta(365))
|
||||
@@ -56,56 +55,52 @@ class HistoryAlgorithm(QCAlgorithm):
|
||||
# we can loop over the return value from these functions and we get TradeBars
|
||||
# we can use these TradeBars to initialize indicators or perform other math
|
||||
for index, tradeBar in tradeBarHistory.loc["SPY"].iterrows():
|
||||
self.spyDailySma.Update(index, tradeBar["close"])
|
||||
self.dailySma.Update(index, tradeBar["close"])
|
||||
|
||||
# get the last calendar year's worth of quandl data at the configured resolution (daily)
|
||||
quandlHistory = self.History(QuandlFuture, "CHRIS/CME_SP1", timedelta(365))
|
||||
self.AssertHistoryCount("History(QuandlFuture, \"CHRIS/CME_SP1\", timedelta(365))", quandlHistory, 250)
|
||||
# get the last calendar year's worth of customData data at the configured resolution (daily)
|
||||
customDataHistory = self.History(CustomDataEquity, "IBM", timedelta(365))
|
||||
self.AssertHistoryCount("History(CustomDataEquity, \"IBM\", timedelta(365))", customDataHistory, 10)
|
||||
|
||||
# get the last 14 bars of SPY at the configured resolution (daily)
|
||||
quandlHistory = self.History(QuandlFuture, "CHRIS/CME_SP1", 14)
|
||||
self.AssertHistoryCount("History(QuandlFuture, \"CHRIS/CME_SP1\", 14)", quandlHistory, 14)
|
||||
# get the last 10 bars of IBM at the configured resolution (daily)
|
||||
customDataHistory = self.History(CustomDataEquity, "IBM", 14)
|
||||
self.AssertHistoryCount("History(CustomDataEquity, \"IBM\", 14)", customDataHistory, 10)
|
||||
|
||||
# we can loop over the return values from these functions and we'll get Quandl data
|
||||
# we can loop over the return values from these functions and we'll get Custom data
|
||||
# this can be used in much the same way as the tradeBarHistory above
|
||||
self.spyDailySma.Reset()
|
||||
for index, quandl in quandlHistory.loc["CHRIS/CME_SP1"].iterrows():
|
||||
self.spyDailySma.Update(index, quandl["settle"])
|
||||
self.dailySma.Reset()
|
||||
for index, customData in customDataHistory.loc["IBM"].iterrows():
|
||||
self.dailySma.Update(index, customData["value"])
|
||||
|
||||
# get the last year's worth of all configured Quandl data at the configured resolution (daily)
|
||||
#allQuandlData = self.History(QuandlFuture, timedelta(365))
|
||||
#self.AssertHistoryCount("History(QuandlFuture, timedelta(365))", allQuandlData, 250)
|
||||
# get the last 10 bars worth of Custom data for the specified symbols at the configured resolution (daily)
|
||||
allCustomData = self.History(CustomDataEquity, self.Securities.Keys, 14)
|
||||
self.AssertHistoryCount("History(CustomDataEquity, self.Securities.Keys, 14)", allCustomData, 10)
|
||||
|
||||
# get the last 14 bars worth of Quandl data for the specified symbols at the configured resolution (daily)
|
||||
allQuandlData = self.History(QuandlFuture, self.Securities.Keys, 14)
|
||||
self.AssertHistoryCount("History(QuandlFuture, self.Securities.Keys, 14)", allQuandlData, 14)
|
||||
# NOTE: Using different resolutions require that they are properly implemented in your data type. If your
|
||||
# custom data source has different resolutions, it would need to be implemented in the GetSource and
|
||||
# Reader methods properly.
|
||||
#customDataHistory = self.History(CustomDataEquity, "IBM", timedelta(7), Resolution.Minute)
|
||||
#customDataHistory = self.History(CustomDataEquity, "IBM", 14, Resolution.Minute)
|
||||
#allCustomData = self.History(CustomDataEquity, timedelta(365), Resolution.Minute)
|
||||
#allCustomData = self.History(CustomDataEquity, self.Securities.Keys, 14, Resolution.Minute)
|
||||
#allCustomData = self.History(CustomDataEquity, self.Securities.Keys, timedelta(1), Resolution.Minute)
|
||||
#allCustomData = self.History(CustomDataEquity, self.Securities.Keys, 14, Resolution.Minute)
|
||||
|
||||
# NOTE: using different resolutions require that they are properly implemented in your data type, since
|
||||
# Quandl doesn't support minute data, this won't actually work, but if your custom data source has
|
||||
# different resolutions, it would need to be implemented in the GetSource and Reader methods properly
|
||||
#quandlHistory = self.History(QuandlFuture, "CHRIS/CME_SP1", timedelta(7), Resolution.Minute)
|
||||
#quandlHistory = self.History(QuandlFuture, "CHRIS/CME_SP1", 14, Resolution.Minute)
|
||||
#allQuandlData = self.History(QuandlFuture, timedelta(365), Resolution.Minute)
|
||||
#allQuandlData = self.History(QuandlFuture, self.Securities.Keys, 14, Resolution.Minute)
|
||||
#allQuandlData = self.History(QuandlFuture, self.Securities.Keys, timedelta(1), Resolution.Minute)
|
||||
#allQuandlData = self.History(QuandlFuture, self.Securities.Keys, 14, Resolution.Minute)
|
||||
|
||||
# get the last calendar year's worth of all quandl data
|
||||
allQuandlData = self.History(QuandlFuture, self.Securities.Keys, timedelta(365))
|
||||
self.AssertHistoryCount("History(QuandlFuture, self.Securities.Keys, timedelta(365))", allQuandlData, 250)
|
||||
# get the last calendar year's worth of all customData data
|
||||
allCustomData = self.History(CustomDataEquity, self.Securities.Keys, timedelta(365))
|
||||
self.AssertHistoryCount("History(CustomDataEquity, self.Securities.Keys, timedelta(365))", allCustomData, 10)
|
||||
|
||||
# we can also access the return value from the multiple symbol functions to request a single
|
||||
# symbol and then loop over it
|
||||
singleSymbolQuandl = allQuandlData.loc["CHRIS/CME_SP1"]
|
||||
self.AssertHistoryCount("allQuandlData.loc[\"CHRIS/CME_SP1\"]", singleSymbolQuandl, 250)
|
||||
for quandl in singleSymbolQuandl:
|
||||
# do something with 'CHRIS/CME_SP1.QuandlFuture' quandl data
|
||||
singleSymbolCustom = allCustomData.loc["IBM"]
|
||||
self.AssertHistoryCount("allCustomData.loc[\"IBM\"]", singleSymbolCustom, 10)
|
||||
for customData in singleSymbolCustom:
|
||||
# do something with 'IBM.CustomDataEquity' customData data
|
||||
pass
|
||||
|
||||
quandlSpyLows = allQuandlData.loc["CHRIS/CME_SP1"]["low"]
|
||||
self.AssertHistoryCount("allQuandlData.loc[\"CHRIS/CME_SP1\"][\"low\"]", quandlSpyLows, 250)
|
||||
for low in quandlSpyLows:
|
||||
# do something with 'CHRIS/CME_SP1.QuandlFuture' quandl data
|
||||
customDataSpyValues = allCustomData.loc["IBM"]["value"]
|
||||
self.AssertHistoryCount("allCustomData.loc[\"IBM\"][\"value\"]", customDataSpyValues, 10)
|
||||
for value in customDataSpyValues:
|
||||
# do something with 'IBM.CustomDataEquity' value data
|
||||
pass
|
||||
|
||||
|
||||
@@ -124,10 +119,20 @@ class HistoryAlgorithm(QCAlgorithm):
|
||||
raise Exception("{} expected {}, but received {}".format(methodCall, expected, count))
|
||||
|
||||
|
||||
class QuandlFuture(PythonQuandl):
|
||||
'''Custom quandl data type for setting customized value column name. Value column is used for the primary trading calculations and charting.'''
|
||||
def __init__(self):
|
||||
# Define ValueColumnName: cannot be None, Empty or non-existant column name
|
||||
# If ValueColumnName is "Close", do not use PythonQuandl, use Quandl:
|
||||
# self.AddData[QuandlFuture](self.crude, Resolution.Daily)
|
||||
self.ValueColumnName = "Settle"
|
||||
class CustomDataEquity(PythonData):
|
||||
def GetSource(self, config, date, isLive):
|
||||
source = "https://www.dl.dropboxusercontent.com/s/o6ili2svndzn556/custom_data.csv?dl=0"
|
||||
return SubscriptionDataSource(source, SubscriptionTransportMedium.RemoteFile)
|
||||
|
||||
def Reader(self, config, line, date, isLive):
|
||||
if line == None:
|
||||
return None
|
||||
|
||||
customData = CustomDataEquity()
|
||||
customData.Symbol = config.Symbol
|
||||
|
||||
csv = line.split(",")
|
||||
customData.Time = datetime.strptime(csv[0], '%Y%m%d %H:%M')
|
||||
customData.EndTime = customData.Time + timedelta(days=1)
|
||||
customData.Value = float(csv[1])
|
||||
return customData
|
||||
|
||||
Reference in New Issue
Block a user