CM (Content Model)

The Quickest Way to Access Financial Data

Content Factory (Data)

Import & Initialize

from finter.data import ContentFactory

# For stock data
content_factory = ContentFactory(
    universe_name="kr_stock", start=20230101, end=20230131
)
# Explore available data (ipywidgets needed)
content_factory.show()

# Available Data with list
content_factory.item_list

Get Specific Content Model (CM)

# Get Content Model (data)
df = content_factory.get_df('price_close')

Get CM with full CM name

from finter.data import ContentFactory

# For using with full cm name
content_factory = ContentFactory(universe_name="raw", 20230101, 20230131)

df = content_factory.get_df('content.fnguide.ftp.price_volume.price_close.1d')

Get trading days by universe

To retrieve trading days for a specific universe, you can use the trading_days attribute. For the "raw" universe, this will return all calendar days.

# Retrieve trading days
trading_days = content_factory.trading_days

Enhancing Performance with Cache

To improve the performance of ContentFactory repeated data retrieval, you can utilize the cache_timeout parameter.


content_factory = ContentFactory(
    universe_name,
    20230101,
    20230131,
    cache_timeout=600, # Set cache timeout to 10 minutes (600 seconds)
    cache_maxsize=10, # Maximum number of items to store
)

Last updated