Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    quandl example

    General Code/Help
    3
    6
    3947
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      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',
      

      #.....
      )

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by backtrader

        There is no need to apply the baseurl parameter. 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:

        • Docs - Data Feeds Rereference

        The important things:

        • dataset which defaults to WIKI (just change it if you need something from other dataset)
        • dataname which 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): fromdate, todate, sessionstart, sessionend, timeframe, compression, tz

        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/

        L 1 Reply Last reply Reply Quote 0
        • P
          pookeye last edited by

          thanks that worked!

          1 Reply Last reply Reply Quote 0
          • L
            Locusta @backtrader 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()
            
            1 Reply Last reply Reply Quote 0
            • B
              backtrader administrators last edited by

              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 YahooFinanceData and 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.

              1 Reply Last reply Reply Quote 0
              • B
                backtrader administrators last edited by

                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, dataset=CURRFX

                1 Reply Last reply Reply Quote 1
                • 1 / 1
                • First post
                  Last post
                Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
                $(document).ready(function () { app.coldLoad(); }); }