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.
Example
>>> data = bt.feeds.YahooFinanceCSVData(dataname='yahoo.csv')
>>> cerebro.adddata(data)
- class backtrader.feeds.yahoo.YahooFinanceCSVData[source]¶
Bases:
CSVDataBaseParses pre-downloaded Yahoo CSV Data Feeds (or locally generated if they comply to the Yahoo format)
Specific parameters:
datanameThe filename to parse or a file-like object
reverseIt is assumed that locally stored files have the newest lines at the bottom
If this is not the case, pass reverse =
Trueadjclose(default:True) Whether to use the dividend/split adjusted close and adjust all values according to it.adjvolume(default:True) Do also adjustvolumeifadjcloseis alsoTrueround(default:True) Whether to round the values to a specific number of decimals after having adjusted the closeroundvolume(default:0) Round the resulting volume to the given number of decimals after having adjusted itdecimals(default:2) Number of decimals to round toswapcloses(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()[source]¶
Start the Yahoo Finance CSV data feed.
Reverses data order if needed for correct chronological sequence.
- frompackages = ()¶
- packages = ()¶
- class backtrader.feeds.yahoo.YahooLegacyCSV[source]¶
Bases:
YahooFinanceCSVDataThis 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[source]¶
Bases:
CSVFeedBaseYahoo Finance CSV feed class.
Wrapper class for YahooFinanceCSVData feed functionality.
- DataCls¶
alias of
YahooFinanceCSVData
- class backtrader.feeds.yahoo.YahooFinanceData[source]¶
Bases:
YahooFinanceCSVDataExecutes a direct download of data from Yahoo servers for the given time range.
Specific parameters (or specific meaning):
datanameThe ticker to download (‘YHOO’ for Yahoo own stock quotes)
proxiesA dict indicating which proxy to go through for the download as in {‘http’: ‘http://myproxy.com’} or {‘http’: ‘http://127.0.0.1:8080’}
periodThe 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
reversefor the online download is therefore set toFalseadjcloseWhether to use the dividend/split adjusted close and adjust all values according to it.
urlhistThe url of the historical quotes in Yahoo Finance used to gather a
crumbauthorization cookie for the downloadurldownThe url of the actual download server
retriesNumber of times (each) to try to get a
crumbcookie 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()[source]¶
Start Yahoo Finance data download using v7 API.
Fetches crumb cookie and downloads historical data.
- frompackages = ()¶
- packages = ()¶
- class backtrader.feeds.yahoo.YahooFinance[source]¶
Bases:
CSVFeedBaseYahoo Finance feed class.
Wrapper class for YahooFinanceData feed functionality.
- DataCls¶
alias of
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))¶