Tools

Quandl

pyalgotrade.tools.quandl.build_feed(sourceCode, tableCodes, fromYear, toYear, storage, frequency=86400, timezone=None, skipErrors=False, authToken=None, columnNames={}, forceDownload=False, skipMalformedBars=False)

Build and load a pyalgotrade.barfeed.quandlfeed.Feed using CSV files downloaded from Quandl. CSV files are downloaded if they haven’t been downloaded before.

Parameters:
  • sourceCode (string.) – The dataset source code.
  • tableCodes (list.) – The dataset table codes.
  • fromYear (int.) – The first year.
  • toYear (int.) – The last year.
  • storage (string.) – The path were the files will be loaded from, or downloaded to.
  • frequency – The frequency of the bars. Only pyalgotrade.bar.Frequency.DAY or pyalgotrade.bar.Frequency.WEEK are supported.
  • timezone (A pytz timezone.) – The default timezone to use to localize bars. Check pyalgotrade.marketsession.
  • skipErrors (boolean.) – True to keep on loading/downloading files in case of errors.
  • authToken (string.) – Optional. An authentication token needed if you’re doing more than 50 calls per day.
  • columnNames (dict.) –

    Optional. A dictionary to map column names. Valid key values are:

    • datetime
    • open
    • high
    • low
    • close
    • volume
    • adj_close
  • skipMalformedBars (boolean.) – True to skip errors while parsing bars.
Return type:

pyalgotrade.barfeed.quandlfeed.Feed.

pyalgotrade.tools.quandl.download_daily_bars(sourceCode, tableCode, year, csvFile, authToken=None)

Download daily bars from Quandl for a given year.

Parameters:
  • sourceCode (string.) – The dataset’s source code.
  • tableCode (string.) – The dataset’s table code.
  • year (int.) – The year.
  • csvFile (string.) – The path to the CSV file to write.
  • authToken (string.) – Optional. An authentication token needed if you’re doing more than 50 calls per day.
pyalgotrade.tools.quandl.download_weekly_bars(sourceCode, tableCode, year, csvFile, authToken=None)

Download weekly bars from Quandl for a given year.

Parameters:
  • sourceCode (string.) – The dataset’s source code.
  • tableCode (string.) – The dataset’s table code.
  • year (int.) – The year.
  • csvFile (string.) – The path to the CSV file to write.
  • authToken (string.) – Optional. An authentication token needed if you’re doing more than 50 calls per day.

BarFeed resampling

pyalgotrade.tools.resample.resample_to_csv(barFeed, frequency, csvFile)

Resample a BarFeed into a CSV file grouping bars by a certain frequency. The resulting file can be loaded using pyalgotrade.barfeed.csvfeed.GenericBarFeed. The CSV file will have the following format:

Date Time,Open,High,Low,Close,Volume,Adj Close
2013-01-01 00:00:00,13.51001,13.56,13.51,13.56,273.88014126,13.51001
Parameters:
  • barFeed (pyalgotrade.barfeed.BarFeed) – The bar feed that will provide the bars. It should only hold bars from a single instrument.
  • frequency – The grouping frequency in seconds. Must be > 0.
  • csvFile (string.) – The path to the CSV file to write.

Note

  • Datetimes are stored without timezone information.

  • Adj Close column may be empty if the input bar feed doesn’t have that info.

  • Supported resampling frequencies are:
    • Less than bar.Frequency.DAY
    • bar.Frequency.DAY
    • bar.Frequency.MONTH

Table Of Contents

Previous topic

marketsession – Market sessions

Next topic

Event profiler

This Page