Faker MarketData

raw JSON →
0.4 verified Sat May 09 auth: no python

A Faker provider that generates realistic financial market data such as tickers, ISINs, CUSIPs, SEDOLs, currencies, and market indices. Version 0.4 supports Python 3.6+ and requires the Faker library. Release cadence is low; updates are infrequent.

pip install faker-marketdata
error ModuleNotFoundError: No module named 'faker_marketdata'
cause The library is not installed or the Python environment does not have it.
fix
Run 'pip install faker-marketdata'.
error ImportError: cannot import name 'MarketDataProvider' from 'faker_marketdata'
cause Incorrect import path or the library version is too old.
fix
Use 'from faker_marketdata import MarketDataProvider'. Ensure version >=0.2.
error AttributeError: 'Faker' object has no attribute 'bbg_ticker'
cause The provider was not added to the Faker instance.
fix
Add 'fake.add_provider(MarketDataProvider)' before calling the method.
gotcha Faker must be installed before or alongside faker-marketdata. The provider will not work without the Faker package.
fix Ensure Faker is installed: `pip install Faker faker-marketdata`
gotcha The provider methods (bbg_ticker, isin, etc.) are only available after adding the provider to a Faker instance. They are not top-level functions.
fix Call `fake.add_provider(MarketDataProvider)` before generating data.
deprecated This library has not been updated since 2022 and may not be actively maintained. Check for compatibility with newer Faker versions.
fix Consider testing with your version of Faker or pinning Faker to a known compatible version.

Initialize Faker with the MarketData provider and generate sample financial instruments.

from faker import Faker
from faker_marketdata import MarketDataProvider

fake = Faker()
fake.add_provider(MarketDataProvider)

# Generate a stock ticker
print(fake.bbg_ticker())  # example: 'AAPL US Equity'
print(fake.isin())        # example: 'US0378331005'
print(fake.cusip())       # example: '037833100'
print(fake.sedol())       # example: 'B03MLW9'
print(fake.currency())    # example: 'USD'
print(fake.market_index()) # example: 'S&P 500'