2019-10-02: The community is currently in read-only mode
pookeye last edited by
Hello, backtrader newbie here, not an expert python guy, but am still learning,
I'm trying to use quandl, but have yet to see any sample code on how it works...
according to the documents, you will need baseURL, but not sure what they want here, I believe my code starts like this, but need help to just get whatever data i can get, can anyone help me? I just need a sample of the code should look like.. I'm also sure I need to use my APIkey as well in this case...
data = bt.feeds.Quandl( dataname='AAPL',
There is no need to apply the
baseurlparameter. It is only there in case the base url of the service would change, allowing the end user to keep on working.
The parameters and default values are documented here:
The important things:
datasetwhich defaults to
WIKI(just change it if you need something from other dataset)
datanamewhich is the value to download from the dataset
apikey, just put yours
mydata = bt.feeds.Quandl(dataname='YHOO' apikey='myapikey', dataset='myspecialdataset')
You can additionally configure any of the standard parameters of the data feeds (the most important being):
Note (from the top of the community)
For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
pookeye last edited by
thanks that worked!
Locusta last edited by Locusta
Hi , I am trying to play around with the example stategy, but can´t get the data feed to work. What am i missing ? (AttributeError: 'NoneType' object has no attribute 'close')
Quandl returns the fx-data with a column rate instead of close.
#!/usr/bin/python from datetime import datetime import backtrader as bt class SmaCross(bt.SignalStrategy): params = (('pfast', 10), ('pslow', 30),) def __init__(self): sma1, sma2 = bt.ind.SMA(period=self.p.pfast), bt.ind.SMA(period=self.p.pslow) self.signal_add(bt.SIGNAL_LONG, bt.ind.CrossOver(sma1, sma2)) cerebro = bt.Cerebro() data = bt.feeds.Quandl(dataname='CURRFX/GBPEUR', apikey='xxxxxxxx') cerebro.adddata(data) cerebro.addstrategy(SmaCross) cerebro.run() cerebro.plot()
That's an indication that something has happened.
- The connection to Quandl has failed
- There was no data received
The original code was from the original
YahooFinanceDataand not much care was put into sending a notification back to the system (they didn't exist back then) or to raise an exception indicating an approximate error condition.
See Docs - Data Feeds Reference and the reference for the Quandl data feed.
It could be (unknown here) that what you have before the
/is the dataset and you have to pass it using that parameter,