backtrader.feeds.yahoo module

Yahoo Finance Data Feed Module - Yahoo CSV data parsing.

This module provides the YahooFinanceCSVData feed for parsing pre-downloaded Yahoo Finance CSV files.

Classes:

YahooFinanceCSVData: Parses Yahoo Finance format CSV files.

示例

>>> data = bt.feeds.YahooFinanceCSVData(dataname='yahoo.csv')
>>> cerebro.adddata(data)
class backtrader.feeds.yahoo.YahooFinanceCSVData[源代码]

基类:CSVDataBase

Parses pre-downloaded Yahoo CSV Data Feeds (or locally generated if they comply to the Yahoo format)

Specific parameters:

  • dataname

    The filename to parse or a file-like object

  • reverse

    It is assumed that locally stored files have the newest lines at the bottom

    If this is not the case, pass reverse = True

  • adjclose (default: True) Whether to use the dividend/split adjusted close and adjust all values according to it.

  • adjvolume (default: True) Do also adjust volume if adjclose is also True

  • round (default: True) Whether to round the values to a specific number of decimals after having adjusted the close

  • roundvolume (default: 0) Round the resulting volume to the given number of decimals after having adjusted it

  • decimals (default: 2) Number of decimals to round to

  • swapcloses (default: False) [2018-11-16] It would seem that the order of close and adjusted close is now fixed. The parameter is retained, in case the need to swap the columns again arose.

start()[源代码]

Start the Yahoo Finance CSV data feed.

Reverses data order if needed for correct chronological sequence.

frompackages = ()
packages = ()
class backtrader.feeds.yahoo.YahooLegacyCSV[源代码]

基类:YahooFinanceCSVData

This is intended to load files which were downloaded before Yahoo discontinued the original service in May-2017 Used to load data downloaded before May 2017

frompackages = ()
packages = ()
class backtrader.feeds.yahoo.YahooFinanceCSV[源代码]

基类:CSVFeedBase

Yahoo Finance CSV feed class.

Wrapper class for YahooFinanceCSVData feed functionality.

DataCls

YahooFinanceCSVData 的别名

class backtrader.feeds.yahoo.YahooFinanceData[源代码]

基类:YahooFinanceCSVData

Executes a direct download of data from Yahoo servers for the given time range.

Specific parameters (or specific meaning):

  • dataname

    The ticker to download ('YHOO' for Yahoo own stock quotes)

  • proxies

    A dict indicating which proxy to go through for the download as in {'http': 'http://myproxy.com'} or {'http': 'http://127.0.0.1:8080'}

  • period

    The timeframe to download data in. Pass 'w' for weekly and 'm' for monthly.

  • reverse

    [2018-11-16] The latest incarnation of Yahoo online downloads returns the data in the proper order. The default value of reverse for the online download is therefore set to False

  • adjclose

    Whether to use the dividend/split adjusted close and adjust all values according to it.

  • urlhist

    The url of the historical quotes in Yahoo Finance used to gather a crumb authorization cookie for the download

  • urldown

    The url of the actual download server

  • retries

    Number of times (each) to try to get a crumb cookie and download the data

__init__(*args, **kwargs)

Initialize a LineMultiple instance.

Sets up the internal state for managing multiple lines, including line type indicator, lines collection, clock reference, and line iterator tracking.

Initializes:

_ltype: Line type indicator (None for base LineMultiple). lines: Collection of line objects (creates if not exists). _clock: Clock reference for synchronization. _lineiterators: Dictionary tracking registered lineiterators. _minperiod: Minimum period requirement (defaults to 1).

start_v7()[源代码]

Start Yahoo Finance data download using v7 API.

Fetches crumb cookie and downloads historical data.

start()[源代码]

Start the Yahoo Finance data feed.

Initiates download and prepares CSV parser.

frompackages = ()
packages = ()
class backtrader.feeds.yahoo.YahooFinance[源代码]

基类:CSVFeedBase

Yahoo Finance feed class.

Wrapper class for YahooFinanceData feed functionality.

DataCls

YahooFinanceData 的别名

params = (('period', 'd'), ('movav', None), ('_movav', None), ('lookback', 1), ('upperband', 70.0), ('lowerband', 30.0), ('safediv', False), ('safepct', False), ('fast', 5), ('slow', 34), ('signal', 9), ('mult', 2.0), ('matype', 0), ('dataname', None), ('name', ''), ('compression', 1), ('timeframe', 5), ('fromdate', None), ('todate', None), ('sessionstart', None), ('sessionend', None), ('filters', []), ('tz', None), ('tzinput', None), ('qcheck', 0.0), ('calendar', None), ('headers', True), ('separator', ','), ('reverse', False), ('adjclose', True), ('adjvolume', True), ('round', True), ('decimals', 2), ('roundvolume', False), ('swapcloses', False), ('proxies', {}), ('urlhist', 'https://finance.yahoo.com/quote/{}/history'), ('urldown', 'https://query1.finance.yahoo.com/v7/finance/download'), ('retries', 3))