Skip to content

yf module

Module with YFData.


YFData class

YFData(
    wrapper,
    data,
    single_key=True,
    classes=None,
    level_name=None,
    fetch_kwargs=None,
    returned_kwargs=None,
    last_index=None,
    delisted=None,
    tz_localize=None,
    tz_convert=None,
    missing_index=None,
    missing_columns=None,
    **kwargs
)

Data class for fetching from Yahoo Finance.

See https://github.com/ranaroussi/yfinance for API.

See YFData.fetch_symbol() for arguments.

Usage

>>> from vectorbtpro import *

>>> data = vbt.YFData.pull(
...     "BTC-USD",
...     start="2020-01-01",
...     end="2021-01-01",
...     timeframe="1 day"
... )

Superclasses

Inherited members


feature_config class variable

Column config of YFData.

HybridConfig({
    'Dividends': dict(
        resample_func=<function YFData.<lambda> at 0x15fa828e0>
    ),
    'Stock Splits': dict(
        resample_func=<function YFData.<lambda> at 0x15fa82980>
    ),
    'Capital Gains': dict(
        resample_func=<function YFData.<lambda> at 0x15fa82a20>
    )
})

Returns YFData._feature_config, which gets (hybrid-) copied upon creation of each instance. Thus, changing this config won't affect the class.

To change fields, you can either change the config in-place, override this property, or overwrite the instance variable YFData._feature_config.


fetch_symbol class method

YFData.fetch_symbol(
    symbol,
    period=None,
    start=None,
    end=None,
    timeframe=None,
    tz=None,
    **history_kwargs
)

Override Data.fetch_symbol() to fetch a symbol from Yahoo Finance.

Args

symbol : str
Symbol.
period : str
Period.
start : any

Start datetime.

See to_tzaware_datetime().

end : any

End datetime.

See to_tzaware_datetime().

timeframe : str

Timeframe.

Allows human-readable strings such as "15 minutes".

tz : any

Timezone.

See to_timezone().

**history_kwargs
Keyword arguments passed to yfinance.base.TickerBase.history.

For defaults, see custom.yf in data.

Warning

Data coming from Yahoo is not the most stable data out there. Yahoo may manipulate data how they want, add noise, return missing data points (see volume in the example below), etc. It's only used in vectorbt for demonstration purposes.