btgsolutions_dataservices.rest package

Submodules

btgsolutions_dataservices.rest.authenticator module

class btgsolutions_dataservices.rest.authenticator.Authenticator(api_key)[source]

Bases: object

get_new_token()[source]
property token

btgsolutions_dataservices.rest.bulk_data module

class btgsolutions_dataservices.rest.bulk_data.BulkData(api_key: str | None)[source]

Bases: object

This class provides market data by ticker and date, in .csv format

  • Main use case:

>>> from btgsolutions_dataservices import BulkData
>>> bulk_data = BulkData(
>>>     api_key='YOUR_API_KEY',
>>> )
>>> bulk_data.get_data(
>>>     ticker = 'DI1F18',
>>>     date = '2017-01-02',
>>>     data_type = 'trades',
>>>     raw_data = False
>>> )
Parameters:

api_key (str) – User identification key. Field is required.

get_available_tickers(date: str, data_type: str, prefix: str = '')[source]

This method provides all tickers available for query, for the provided market data type.

Parameters:
  • date (str) – Date period. Field is required. Format: ‘YYYY-MM-DD’. Example: ‘2023-07-03’.

  • data_type (str) – Market data type. Field is required. Example: ‘trades’, ‘books’ or ‘trades-and-book-events’.

  • prefix (str) – Filters tickers starting with the prefix. Field is optional. Example: ‘DOL’.

get_compressed_data(channel: str, date: str, data_type: str = 'instruments', feed: str = '')[source]

This method provides market data via compressed files (instruments, snapshot, incremental) for a given market data channel and date. Function get_market_data_channels provides all the available channels for a given date.

Parameters:
  • channel (str) – Market Data channel. Field is required. Example: ‘72’.

  • date (str) – Date period. Field is required. Format: ‘YYYY-MM-DD’. Example: ‘2026-01-30’.

  • data_type (str) – Market data type. Field is required. Example: ‘instruments’, ‘snapshot’, ‘incremental’.

  • feed (str) – Available only for ‘incremental’ data type. Allowed values: ‘feedA’ or ‘feedB’ Field is not required.

get_data(ticker: str, date: str, data_type: str = 'trades', raw_data: bool = False)[source]

This method provides tick-by-tick market data (trades, book events, book snapshots) for a given ticker and date.

Parameters:
  • ticker (str) – Ticker that needs to be returned. Field is required. Example: ‘DI1F18’.

  • date (str) – Date period. Field is required. Format: ‘YYYY-MM-DD’. Example: ‘2023-07-03’, ‘2023-07-28’.

  • data_type (str) – Market data type. Field is required. Available types: ‘trades’, ‘books’, ‘trades-and-book-events’

  • raw_data (bool) – If false, returns data in a dataframe. If true, returns raw data. Field is not required. Default: False.

get_market_data_channels(date: str)[source]

This method provides all the available market data channels for a given date. For more detailed information about market data channels, please consult our documentation, at https://dataservicesdocs.btgpactualsolutions.com/home > Data Specs > Market Data channel definition.

Parameters:

date (str) – Date period. Field is required. Format: ‘YYYY-MM-DD’. Example: ‘2026-01-30’.

get_security_list(date: str, raw_data: bool = False)[source]

This method returns the security list for a given date.

Parameters:
  • date (str) – Date period. Field is required. Format: ‘YYYY-MM-DD’. Example: ‘2025-05-12’.

  • raw_data (bool) – If false, returns data in a dataframe. If true, returns raw data. Default: False.

btgsolutions_dataservices.rest.bulk_data.download_compressed_file(url, headers)[source]

btgsolutions_dataservices.rest.broker_reference module

class btgsolutions_dataservices.rest.broker_reference.BrokerReference(api_key: str | None)[source]

Bases: object

This class provides broker reference information.

  • Main use case:

>>> from btgsolutions_dataservices import BrokerReference
>>> broker_reference = BrokerReference(
>>>     api_key='YOUR_API_KEY',
>>> )
>>> broker_reference.get()
Parameters:

api_key (str) – User identification key. Field is required.

get(raw_data: bool = False)[source]

Returns the full broker reference dataset from the API.

Parameters:

raw_data (bool) – If False, returns the response as a pandas DataFrame. If True, returns the raw JSON payload. Field is not required. Default: False.

Returns:

Broker reference data returned by the API.

Return type:

pandas.DataFrame | dict | list

btgsolutions_dataservices.rest.book_scope module

class btgsolutions_dataservices.rest.book_scope.BookScope(api_key: str | None)[source]

Bases: object

This class provides market scope data (trades, book snapshots, book incremental) for a given symbol and time window.

  • Main use case:

>>> from btgsolutions_dataservices import BookScope
>>> book_scope = BookScope(
>>>     api_key='YOUR_API_KEY',
>>> )
>>> book_scope.get(
>>>     symbol='DOLM26',
>>>     market_type='derivatives',
>>>     start_time='2026-05-28T14:12:00Z',
>>>     end_time='2026-05-28T14:15:00Z',
>>> )
Parameters:

api_key (str) – User identification key. Field is required.

get(symbol: str, market_type: str, start_time: str, end_time: str, select: List[str] = ['trades', 'book_snapshot', 'book_incremental'], aggregate_info: bool = False)[source]

Returns trades, book snapshot and book incremental data for the given symbol and time window.

Pagination is handled automatically: if the API returns the maximum number of rows (10 000), additional pages are fetched using the rpt_seq cursor until all events in the requested horizon are retrieved. The caller always receives a single, complete DataFrame per dataset.

Parameters:
  • symbol (str) – The ticker symbol to query. Field is required. Example: ‘PETR4’, ‘DOLM26’.

  • market_type (str) – Market type. Field is required. Allowed values: ‘derivatives’, ‘options’, ‘stocks’.

  • start_time (str) – Start of the analysis window in ISO-8601 UTC format. Field is required. Example: ‘2026-05-28T14:12:00Z’.

  • end_time (str) – End of the analysis window in ISO-8601 UTC format. Field is required. Example: ‘2026-05-28T14:15:00Z’.

  • select (list of str) – Which datasets to return. Field is optional. Default: [‘trades’, ‘book_snapshot’, ‘book_incremental’]. Allowed values: ‘trades’, ‘book_snapshot’, ‘book_incremental’.

  • aggregate_info (bool) – When True, returns a single pandas.DataFrame containing the selected datasets. Field is optional. Default: False.

Returns:

When aggregate_info is False (default): dictionary with the selected keys (‘trades’, ‘book_snapshot’, ‘book_incremental’), each mapping directly to a pandas.DataFrame with all rows for the requested time window. When aggregate_info is True: returns a single pandas.DataFrame with all selected datasets combined.

Return type:

dict or pandas.DataFrame

btgsolutions_dataservices.rest.broker_analytics module

class btgsolutions_dataservices.rest.broker_analytics.BrokerAnalytics(api_key: str, market_type: str)[source]

Bases: object

This class provides broker analytics data (summary, top brokers, top tickers) for a given market type.

  • Main use case:

>>> from btgsolutions_dataservices import BrokerAnalytics
>>> broker_analytics = BrokerAnalytics(
>>>     api_key='YOUR_API_KEY',
>>>     market_type='stocks',
>>> )
>>> broker_analytics.get_summary(
>>>     brokers=['85', '3'],
>>>     tickers=['ABCB4', 'PETR4'],
>>> )
>>> broker_analytics.get_top_brokers(n=10, tickers=['ABCB4'])
>>> broker_analytics.get_top_tickers(n=10, brokers=['85', '3'])
Parameters:
  • api_key (str) – User identification key. Field is required.

  • market_type (str) – Market type to query. One of: ‘derivatives’, ‘stocks’, ‘options’. Field is required.

get_summary(brokers: List[str], tickers: List[str], side: str | None = None) dict[source]

Get day analytics summary for specific brokers and tickers.

Parameters:
  • brokers (List[str]) – List of broker names to filter. Required.

  • tickers (List[str]) – List of ticker symbols to filter. Required.

  • side (str, optional) – Filter by side (‘buy’ or ‘sell’). If None, both sides are returned.

Returns:

JSON response with broker analytics summary data.

Return type:

dict

get_top_brokers(n: int, tickers: List[str] | None = None, side: str | None = None) dict[source]

Get top N brokers ranked by financial volume, with ticker breakdown.

Parameters:
  • n (int) – Number of top brokers to return. Required.

  • tickers (List[str], optional) – List of ticker symbols to filter.

  • side (str, optional) – Filter by side (‘buy’ or ‘sell’).

Returns:

JSON response with top brokers and their top assets breakdown.

Return type:

dict

get_top_tickers(n: int, brokers: List[str] | None = None, side: str | None = None) dict[source]

Get top N tickers ranked by financial volume, with broker breakdown.

Parameters:
  • n (int) – Number of top tickers to return. Required.

  • brokers (List[str], optional) – List of broker names to filter.

  • side (str, optional) – Filter by side (‘buy’ or ‘sell’).

Returns:

JSON response with top tickers and their top brokers breakdown.

Return type:

dict

btgsolutions_dataservices.rest.company_data module

class btgsolutions_dataservices.rest.company_data.CompanyData(api_key: str | None)[source]

Bases: object

This class provides company general information and fundamentalist data.

  • Main use case:

>>> from btgsolutions_dataservices import CompanyData
>>> company_data = CompanyData(
>>>     api_key='YOUR_API_KEY',
>>> )
>>> company_data.general_info(
>>>     ticker = 'PETR4'
>>> )
>>> company_data.income_statement(
>>>     ticker = 'PETR4'
>>> )
>>> company_data.balance_sheet(
>>>     ticker = 'PETR4'
>>> )
>>> company_data.cash_flow(
>>>     ticker = 'PETR4'
>>> )
>>> company_data.valuation(
>>>     ticker = 'PETR4'
>>> )
>>> company_data.ratios(
>>>     ticker = 'PETR4'
>>> )
>>> company_data.growth(
>>>     ticker = 'PETR4'
>>> )
>>> company_data.interims(
>>>     ticker = 'PETR4'
>>> )
>>> company_data.all_financial_tables(
>>>     ticker = 'PETR4'
>>> )
Parameters:

api_key (str) – User identification key. Field is required.

all_financial_tables(ticker: str, raw_data: bool = False)[source]

This method returns all available financial tables (such as Valuation, Income Statement, Cash Flow) for the requested company ticker.

Parameters:
  • ticker (str) – Company ticker symbol. Field is required. Example: “PETR4”. The ticker radical is also allowed. Example: “PETR”.

  • raw_data (bool) – If false, returns financial tables in dataframes. If true, returns raw data. Field is not required. Default: False.

balance_sheet(ticker: str)[source]

This method returns the company Balance Sheet.

Parameters:

ticker (str) – Company ticker symbol. Field is required. Example: “PETR4”. The ticker radical is also allowed. Example: “PETR”.

cash_flow(ticker: str)[source]

This method returns the company Cash Flow.

Parameters:

ticker (str) – Company ticker symbol. Field is required. Example: “PETR4”. The ticker radical is also allowed. Example: “PETR”.

general_info(ticker: str, raw_data: bool = False)[source]

This method returns company general information such as name, ticker, sector, description.

Parameters:
  • ticker (str) – Company ticker symbol. Field is required. Example: ‘PETR4’.

  • raw_data (bool) – If false, returns financial tables in dataframes. If true, returns raw data. Field is not required. Default: False.

growth(ticker: str)[source]

This method returns the company Growth.

Parameters:

ticker (str) – Company ticker symbol. Field is required. Example: “PETR4”. The ticker radical is also allowed. Example: “PETR”.

income_statement(ticker: str)[source]

This method returns the company Income Statement.

Parameters:

ticker (str) – Company ticker symbol. Field is required. Example: “PETR4”. The ticker radical is also allowed. Example: “PETR”.

interims(ticker: str)[source]

This method returns the company Interims.

Parameters:

ticker (str) – Company ticker symbol. Field is required. Example: “PETR4”. The ticker radical is also allowed. Example: “PETR”.

ratios(ticker: str)[source]

This method returns the company Ratios.

Parameters:

ticker (str) – Company ticker symbol. Field is required. Example: “PETR4”. The ticker radical is also allowed. Example: “PETR”.

valuation(ticker: str)[source]

This method returns the company Valuation.

Parameters:

ticker (str) – Company ticker symbol. Field is required. Example: “PETR4”. The ticker radical is also allowed. Example: “PETR”.

btgsolutions_dataservices.rest.company_data.process_financial_table(financial_table_content: list)[source]

btgsolutions_dataservices.rest.corporate_events module

class btgsolutions_dataservices.rest.corporate_events.CorporateEvents(api_key: str | None)[source]

Bases: object

This class provides the market data corporate events

  • Main use case:

>>> from btgsolutions_dataservices import CorporateEvents
>>> corporate_events = CorporateEvents(
>>>     api_key='YOUR_API_KEY',
>>> )
>>> corporate_events.get(
>>>     start_date = '2024-05-10',
>>>     end_date = '2024-05-31',
>>>     tickers = ['PETR4']
>>> )
Parameters:

api_key (str) – User identification key. Field is required.

get(start_date: str, end_date: str, tickers: List[str] = [], raw_data: bool = False)[source]

This method uses corporate events filtered by a range of dates (ex_date) and a list of tickers

Parameters:
  • start_date (string<date>) – Lower bound for corporate events. Filtering by ex_date. Format: “YYYY-MM-DD”. Field is required. Example: ‘2023-10-06’.

  • end_date (string<date>) – Upper bound for corporate events. Filtering by ex_date. Format: “YYYY-MM-DD”. Field is required. Example: ‘2023-10-06’.

  • ticker (List[str]) – List of tickers. Field is not required. Example: [‘PETR4’, ‘VALE3’]. Default: [].

  • raw_data (bool) – If false, returns data in a dataframe. If true, returns raw data. Field is not required. Default: False.

btgsolutions_dataservices.rest.hfn module

class btgsolutions_dataservices.rest.hfn.HighFrequencyNews(api_key: str | None)[source]

Bases: object

This class provides realtime and historical news of several news .

  • Main use case:

>>> from btgsolutions_dataservices import HighFrequencyNews
>>> hfn = HighFrequencyNews(
>>>     api_key='YOUR_API_KEY',
>>> )
>>> latest_news = hfn.latest_news(
>>>     n = 15,
>>> )
>>> petro_news = hfn.filter_news(
>>>     ticker = 'PETR4',
>>> )
>>> ibov_news = hfn.filter_news(
>>>     tag = 'IBOV',
>>> )
>>> news_21_08 = hfn.historical_news(
>>>     start_date = '2023-08-21',
>>>     end_date = '2023-08-22',
>>> )
>>> available_feeds = hfn.get_available_feeds()
>>> available_sources = hfn.get_available_sources()
>>> available_tickers = hfn.get_available_tickers()
>>> available_tags = hfn.get_available_tags()
Parameters:

api_key (str) – User identification key. Field is required.

filter_news(ticker: str = None, tag: str = None, force: bool = True, country: str = 'brazil', raw_data: bool = False)[source]

Filter news by ticker or tag. If both ticker and tag are provided, the filter will be by ticker only

Parameters:
  • ticker (str) – Ticker symbol. Will be used to filter news. Example: ‘VALE3’, ‘PETR4’. Field is not required.

  • tag (str) – Tag name. Will be used to filter news. Example: ‘IBOV’, ‘TESOURO’, ‘RENDA_FIXA’. Field is not required.

  • force (bool) – Force to return news even if it does not match the requested parameters. Default: True Example: True, False. Field is required.

  • country (str) – Country name. Default: ‘brazil’ Example: ‘brazil’, ‘chile’. Field is required.

  • raw_data (bool) – If True, returns raw data from API, if False, returns a Pandas DataFrame. Default: False. Field is not required.

get_available_feeds(country: str = 'brazil')[source]

This method provides all feeds available for query.

Parameters:

country (str) – Country name. Default: ‘brazil’ Example: ‘brazil’, ‘chile’. Field is required.

get_available_sources(country: str = 'brazil')[source]

This method provides all sources available for query.

Parameters:

country (str) – Country name. Default: ‘brazil’ Example: ‘brazil’, ‘chile’. Field is required.

get_available_tags(country: str = 'brazil')[source]

This method provides all tags available for query.

Parameters:

country (str) – Country name. Default: ‘brazil’ Example: ‘brazil’, ‘chile’. Field is required.

get_available_tickers(country: str = 'brazil')[source]

This method provides all tickers available for query.

Parameters:

country (str) – Country name. Default: ‘brazil’ Example: ‘brazil’, ‘chile’. Field is required.

historical_news(start_date: str, end_date: str, feed: str = 'raw', country: str = 'brazil', raw_data: bool = False)[source]

Provide a datetime interval and get all the news registered on that interval. The interval between start_date and end_date must be 24 hours maximum.

Parameters:
  • start_date (str) – Upper bound for news publishing time. Supported formats: ISO Date (YYYY-MM-DD), Long Date (MMM DD YYYY), Short Date (MM/DD/YYYY). Example: ‘2023-08-21’. Field is required.

  • end_date (str) – Lower bound for news publishing time. Supported formats: ISO Date (YYYY-MM-DD), Long Date (MMM DD YYYY), Short Date (MM/DD/YYYY). Example: ‘2023-08-22’. Field is required.

  • feed (str) – Feed name. Default: ‘raw’ Example: ‘raw’, ‘economy’, ‘politics’, ‘crypto’, ‘cvm’. Field is required.

  • country (str) – Country name. Default: ‘brazil’ Example: ‘brazil’, ‘chile’. Field is required.

  • raw_data (bool) – If True, returns raw data from API, if False, returns a Pandas DataFrame. Default: False. Field is not required.

latest_news(feed: str = 'raw', country: str = 'brazil', n: int = 10, raw_data: bool = False)[source]

Latest news by feed.

Parameters:
  • feed (str) – News feed. Example: ‘raw’, ‘economy’, ‘politics’, ‘crypto’, ‘cvm’. Default: ‘raw’. Field is not required.

  • country (str) – Country name. Example: ‘brazil’, ‘chile’. Default: ‘brazil’. Field is not required.

  • n (int) – Number of news to be returned. Default: 10. Field is not required.

  • raw_data (bool) – If True, returns raw data from API, if False, returns a Pandas DataFrame. Default: False. Field is not required.

btgsolutions_dataservices.rest.historical_candles module

class btgsolutions_dataservices.rest.historical_candles.HistoricalCandles(api_key: str | None)[source]

Bases: object

This class provides historical candles for a given ticker or all tickers available for query.

  • Main use case - Interday:

>>> from btgsolutions_dataservices import HistoricalCandles
>>> hist_candles = HistoricalCandles(
>>>     api_key='YOUR_API_KEY',
>>> )
>>> hist_candles.get_interday_history_candles(
>>>     ticker = 'PETR4',
>>>     market_type = 'stocks',
>>>     corporate_events_adj = True,
>>>     start_date = '2023-10-11',
>>>     end_date = '2023-10-20',
>>>     rmv_after_market = True,
>>>     timezone = 'UTC',
>>>     round = True,
>>>     raw_data = False
>>> )
  • Main use case - Intraday:

>>> hist_candles.get_intraday_history_candles(
>>>     ticker = 'PETR4',
>>>     market_type = 'stocks',
>>>     corporate_events_adj = True,
>>>     date = '2023-10-20',
>>>     rmv_after_market = True,
>>>     timezone = 'UTC',
>>>     candle='1m',
>>>     round = True,
>>>     raw_data = False
>>> )
Parameters:

api_key (str) – User identification key. Field is required.

get_available_tickers(market_type: str, date: str)[source]

This method provides all tickers available for query.

Parameters:
  • market_type (str) – Market type. Options: ‘stocks’, ‘derivatives’ or ‘indices’. Field is required.

  • date (string<date>) – Date of requested data. Format: “YYYY-MM-DD”. Field is required. Example: ‘2023-10-06’.

get_interday_history_candles(market_type: str, ticker: str, start_date: str, end_date: str, corporate_events_adj: bool, rmv_after_market: bool, timezone: str, raw_data: bool = False, round: bool = True)[source]

This method provides historical candles for a given ticket in determined period.

Parameters:
  • market_type (str) – Field is required. Allowed values: ‘stocks’, ‘derivatives’ or ‘indices’.

  • ticker (str) – Ticker that needs to be returned. Field is required. Example: ‘PETR4’.

  • start_date (string<date>) – Start date of analysis. Format: “YYYY-MM-DD”. Field is required. Example: ‘2022-10-06’.

  • end_date (string<date>) – End date of analysis. Format: “YYYY-MM-DD”. Field is required. Example: ‘2023-01-22’.

  • corporate_events_adj (bool) – Corporate events adjustment. Field is required. Allowed values: ‘true’ or ‘false’.

  • rmv_after_market (bool) – Remove trades after market close. Field is required. Allowed values: ‘true’ or ‘false’.

  • timezone (str) – Timezone of the datetime. Field is required. Allowed values: ‘America/Sao_Paulo’ or ‘UTC’.

  • raw_data (bool) – If false, returns data in a dataframe. If true, returns raw data. Field is not required. Default: False.

  • round (bool) – Apply rounding to prices. Useful when corporate_events_adj=True, since price adjustment factors may generate values with many decimal places. Field is not required. Default: True.

get_interday_history_candles_batch(market_type: str, tickers: list, start_date: str, end_date: str, corporate_events_adj: bool, rmv_after_market: bool, timezone: str, raw_data: bool = False, round: bool = True)[source]

This method provides historical candles for a batch of tickers in determined period.

Parameters:
  • market_type (str) – Field is required. Allowed values: ‘stocks’ or ‘derivatives’.

  • tickers (list) – Tickers that need to be returned. Field is required. Example: [‘PETR4’, ‘VALE3’].

  • start_date (string<date>) – Start date of analysis. Format: “YYYY-MM-DD”. Field is required. Example: ‘2022-10-06’.

  • end_date (string<date>) – End date of analysis. Format: “YYYY-MM-DD”. Field is required. Example: ‘2023-01-22’.

  • corporate_events_adj (bool) – Corporate events adjustment. Field is required. Allowed values: ‘true’ or ‘false’.

  • rmv_after_market (bool) – Remove trades after market close. Field is required. Allowed values: ‘true’ or ‘false’.

  • timezone (str) – Timezone of the datetime. Field is required. Allowed values: ‘America/Sao_Paulo’ or ‘UTC’.

  • raw_data (bool) – If false, returns data in a dataframe. If true, returns raw data. Field is not required. Default: False.

  • round (bool) – Apply rounding to prices. Useful when corporate_events_adj=True, since price adjustment factors may generate values with many decimal places. Field is not required. Default: True.

get_intraday_history_candles(market_type: str, ticker: str, date: str, candle: str, corporate_events_adj: bool, rmv_after_market: bool, timezone: str, raw_data: bool = False, round: bool = True)[source]

This method provides historical candles for a given ticket in determined period.

Parameters:
  • market_type (str) – Field is required. Allowed values: ‘stocks’, ‘derivatives’ or ‘indices’.

  • ticker (str) – Ticker that needs to be returned. Field is required. Example: ‘PETR4’.

  • date (string<date>) – Date of requested data. Format: “YYYY-MM-DD”. Field is required. Example: ‘2023-10-06’.

  • candle (str) – Candle period. Field is required. Allowed values: ‘1s’, ‘1m’, ‘5m’, ‘15m’, ‘30m’ or ‘1h’.

  • corporate_events_adj (bool) – Corporate events adjustment. Field is required. Allowed values: ‘true’ or ‘false’.

  • rmv_after_market (bool) – Remove trades after market close. Field is required. Allowed values: ‘true’ or ‘false’.

  • timezone (str) – Timezone of the datetime. Field is required. Allowed values: ‘America/Sao_Paulo’ or ‘UTC’.

  • raw_data (bool) – If false, returns data in a dataframe. If true, returns raw data. Field is not required. Default: False.

  • round (bool) – Apply rounding to prices. Useful when corporate_events_adj=True, since price adjustment factors may generate values with many decimal places. Field is not required. Default: True.

btgsolutions_dataservices.rest.historical_candles_crypto module

class btgsolutions_dataservices.rest.historical_candles_crypto.HistoricalCandlesCrypto(api_key: str | None)[source]

Bases: object

This class provides historical candles for cryptocurrencies.

Available tickers: ETH, SOL, BTC Available exchanges: coinbase, mercado_bitcoin, consolidated Available currencies: BRL, USD Available candles: ‘1s’, ’30s’, ‘1m’, ‘5m’, ‘15m’, ‘30m’, ‘1h’

  • Main use case - Interday:

>>> from btgsolutions_dataservices import HistoricalCandlesCrypto
>>> hist_candles = HistoricalCandlesCrypto(
>>>     api_key='YOUR_API_KEY',
>>> )
>>> hist_candles.get_interday_history_candles(
>>>     ticker = 'BTC',
>>>     currency = 'BRL',
>>>     exchange = 'consolidated',
>>>     start_date = '2025-06-01',
>>>     end_date = '2025-07-01',
>>>     timezone = 'UTC',
>>>     raw_data = False
>>> )
  • Main use case - Intraday:

>>> hist_candles.get_intraday_history_candles(
>>>     ticker = 'BTC',
>>>     currency = 'BRL',
>>>     exchange = 'consolidated',
>>>     date = '2025-06-01',
>>>     timezone = 'America/Sao_Paulo',
>>>     candle='1h',
>>>     raw_data = False
>>> )
Parameters:

api_key (str) – User identification key. Field is required.

get_available_tickers(exchange: str, date: str)[source]

This method provides all cryptocurrency tickers available for query.

Parameters:
  • exchange (str) – Exchange name. Field is required. Allowed values: ‘coinbase’, ‘mercado_bitcoin’, ‘consolidated’.

  • date (string<date>) – Date of requested data. Format: “YYYY-MM-DD”. Field is required. Example: ‘2023-01-13’.

get_interday_history_candles(ticker: str, currency: str, exchange: str, start_date: str, end_date: str, timezone: str, raw_data: bool = False)[source]

This method provides historical daily candles for cryptocurrencies.

Parameters:
  • ticker (str) – Cryptocurrency ticker. Field is required. Allowed values: ‘BTC’, ‘ETH’, ‘SOL’.

  • currency (str) – Currency for the prices. Field is required. Allowed values: ‘BRL’ or ‘USD’.

  • exchange (str) – Exchange name. Field is required. Allowed values: ‘coinbase’, ‘mercado_bitcoin’, ‘consolidated’.

  • start_date (string<date>) – Start date of analysis. Format: “YYYY-MM-DD”. Field is required. Example: ‘2025-06-01’.

  • end_date (string<date>) – End date of analysis. Format: “YYYY-MM-DD”. Field is required. Example: ‘2025-07-01’.

  • timezone (str) – Timezone of the datetime. Field is required. Allowed values: ‘America/Sao_Paulo’ or ‘UTC’.

  • raw_data (bool) – If false, returns data in a dataframe. If true, returns raw data. Field is not required. Default: False.

get_intraday_history_candles(ticker: str, currency: str, exchange: str, date: str, candle: str, timezone: str, raw_data: bool = False)[source]

This method provides historical intraday candles for cryptocurrencies.

Parameters:
  • ticker (str) – Cryptocurrency ticker. Field is required. Allowed values: ‘BTC’, ‘ETH’, ‘SOL’.

  • currency (str) – Currency for the prices. Field is required. Allowed values: ‘BRL’ or ‘USD’.

  • exchange (str) – Exchange name. Field is required. Allowed values: ‘coinbase’, ‘mercado_bitcoin’, ‘consolidated’.

  • date (string<date>) – Date of requested data. Format: “YYYY-MM-DD”. Field is required. Example: ‘2025-06-01’.

  • candle (str) – Candle period. Field is required. Allowed values: ‘1s’, ’30s’, ‘1m’, ‘5m’, ‘15m’, ‘30m’, ‘1h’.

  • timezone (str) – Timezone of the datetime. Field is required. Allowed values: ‘America/Sao_Paulo’ or ‘UTC’.

  • raw_data (bool) – If false, returns data in a dataframe. If true, returns raw data. Field is not required. Default: False.

btgsolutions_dataservices.rest.intraday_candles module

class btgsolutions_dataservices.rest.intraday_candles.IntradayCandles(api_key: str | None)[source]

Bases: object

This class provides realtime intraday candles for a given ticker or all tickers available for query.

  • Main use case:

>>> from btgsolutions_dataservices import IntradayCandles
>>> intraday_candles = IntradayCandles(
>>>     api_key='YOUR_API_KEY',
>>> )
>>> candles = intraday_candles.get_intraday_candles(
>>>     market_type = 'stocks',
>>>     tickers = ['PETR4', 'ABEV3'],
>>>     candle_period = '1m',
>>>     delay='delayed',
>>>     mode='absolute',
>>>     timezone='UTC',
>>>     raw_data=False
>>> )
>>> PETR4 = candles.get('PETR4')
>>> ABEV3 = candles.get('ABEV3')
>>> intraday_candles.get_available_tickers(
>>>     market_type='stocks',
>>>     delay='delayed'
>>> )
Parameters:

api_key (str) – User identification key. Field is required.

get_available_tickers(market_type: str, delay: str)[source]

This method provides all tickers available for query.

Parameters:
  • market_type (str) – Market type. Options: ‘stocks’, ‘derivatives’ or ‘options’. Field is required.

  • delay (str) – Data delay. Options: ‘delayed’ or ‘realtime’. Field is required.

get_intraday_candles(market_type: str, tickers: list, delay: str, timezone: str, candle_period: str, start: int = 0, end: int = 0, mode: str = 'absolute', raw_data: bool = False, cross_filter: str = '', market_status: str = '')[source]

This method provides realtime intraday candles for a given ticker.

Parameters:
  • market_type (str) – Market type. Options: ‘stocks’, ‘derivatives’, ‘options’ or ‘indices’. Field is required.

  • tickers (list of str) – Tickers that needs to be returned. Example: [‘PETR4’, ‘ABEV3’] Field is required.

  • delay (str) – Data delay. Options: ‘delayed’ or ‘realtime’. Field is required.

  • timezone (str) – Timezone of the datetime. Options: ‘America/Sao_Paulo’ or ‘UTC’. Field is required.

  • candle_period (str) – Grouping interval. Example: ‘1m’, ‘5m’, ‘30m’, ‘1h’ or ‘1d’. Field is required.

  • start (int) – Start date (in Unix timestamp format).

  • end (int) – End date (in Unix timestamp format)

  • mode (str) – Candle mode. Example: ‘absolute’, ‘relative’ or ‘spark’. Default: absolute.

  • cross_filter (str) – Filter trades by cross status. Options: ‘all’, ‘only_cross’ or ‘without_cross’. Default: ‘all’.

  • market_status (str) – Filter trades by market status. Not available for ‘Indices’. Options: ‘all’ or ‘regular’. Default: ‘all’.

  • raw_data (bool) – If false, returns data in a dict of dataframes. If true, returns raw data. Default: False.

btgsolutions_dataservices.rest.intraday_tick_data module

class btgsolutions_dataservices.rest.intraday_tick_data.IntradayTickData(api_key: str | None)[source]

Bases: object

This class provides tick-by-tick market data from the current day, for the provided ticker

  • Main use case:

>>> from btgsolutions_dataservices import IntradayTickData
>>> tick_data = IntradayTickData(
>>>     api_key='YOUR_API_KEY',
>>> )
>>> tick_data.get_trades(
>>>     ticker = 'PETR4',
>>>     raw_data = False
>>> )
Parameters:

api_key (str) – User identification key. Field is required.

get_trades(ticker: str, start: str = None, end: str = None, raw_data: bool = False)[source]

This method provides tick-by-tick trade data from the current day, for the provided ticker.

Parameters:
  • ticker (str) – Ticker symbol. Field is required. Example: ‘PETR4’.

  • start (str) – Query start datetime, in ISO string format (UTC). Field is required. Examples: ‘2025-02-11’, ‘2025-02-11T17:40:00.000Z’.

  • end (str) – Query end datetime, in ISO string format (UTC). Field is required. Examples: ‘2025-02-12’, ‘2025-02-11T18:10:00.000Z’.

  • raw_data (bool) – If false, returns data in a dataframe. If true, returns raw data. Field is not required. Default: False.

btgsolutions_dataservices.rest.quotes module

class btgsolutions_dataservices.rest.quotes.Quotes(api_key: str | None)[source]

Bases: object

This class provides ticker quote information and quotes sorted by top-bottom quote variation, filtered by ticker market type.

  • Main use case:

>>> from btgsolutions_dataservices import Quotes
>>> quotes = Quotes(
>>>     api_key='YOUR_API_KEY',
>>> )
>>> quotes.get_quote(
>>>     market_type = 'stocks',
>>>     tickers = ['PETR4', 'VALE3'],
>>> )
>>> quotes.get_top_bottom(
>>>     market_type = 'stocks',
>>>     ticker_type = 'IBOV',
>>> )
>>> quotes.get_available_tickers(market_type="stocks")
Parameters:

api_key (str) – User identification key. Field is required.

get_available_tickers(market_type: str, mode: str = 'realtime')[source]

This method provides all tickers available for query, for the provided market type.

Parameters:
  • market_type (str) – Market type. Field is required. Example: ‘stocks’, ‘options’, ‘derivatives’, ‘indices’.

  • mode (str) – Realtime or 15-minutes delayed. Field is not required. Example: ‘realtime’ or ‘delayed’. Default: ‘realtime’.

get_quote(tickers: list, market_type: str, mode: str = 'realtime', raw_data: bool = False)[source]

This method provides realtime and delayed quote information for a given ticker.

Parameters:
  • tickers (list) – List of tickers that needs to be returned. Field is required. Example: [‘VALE3’], [‘PETR4’, ‘PRIO3’].

  • market_type (str) – Market type. Field is required. Example: ‘stocks’, ‘options’, ‘derivatives’, ‘indices’.

  • mode (str) – Realtime or 15-minutes delayed. Field is required. Example: ‘realtime’ or ‘delayed’. Default: ‘realtime’.

  • raw_data (bool) – If false, returns data in a dataframe. If true, returns raw data. Field is not required. Default: False.

get_top_bottom(market_type: str, mode: str = 'realtime', ticker_type: str = 'IBOV', variation: str = 'interday', n: int = 5, raw_data: bool = False)[source]

This method provides realtime and delayed quotes sorted by top-bottom quote variation, filtered by ticker market type.

Parameters:
  • market_type (str) – Market type. Field is required. Example: ‘stocks’, ‘options’, ‘derivatives’, ‘indices’.

  • mode (str) – Realtime or 15-minutes delayed. Field is not required. Example: ‘realtime’ or ‘delayed’. Default: ‘realtime’.

  • ticker_type (str) – Type of tickers to be returned. Field is not required. Example: ‘SHARE’, ‘BDR’, ‘FII’, ‘ETF’, ‘UNIT’, ‘IBOV’. Default: ‘IBOV’.

  • variation (str) – Choose between intraday or interday quotes. Field is not required. Example: ‘interday’ or ‘intraday’. Default: ‘interday’.

  • n (int) – Top-N tickers to be returned. Field is not required. Default: 5.

  • raw_data (bool) – If false, returns data in a dataframe. If true, returns raw data. Field is not required. Default: False.

btgsolutions_dataservices.rest.ticker_last_event module

class btgsolutions_dataservices.rest.ticker_last_event.TickerLastEvent(api_key: str | None)[source]

Bases: object

This class provides the last market data event available, for the provided ticker

  • Main use case:

>>> from btgsolutions_dataservices import TickerLastEvent
>>> last_event = TickerLastEvent(
>>>     api_key='YOUR_API_KEY',
>>> )
>>> last_event.get_trades(
>>>     data_type = 'equities',
>>>     ticker = 'PETR4',
>>>     raw_data = False
>>> )
>>> last_event.get_tob(
>>>     data_type = 'derivatives',
>>>     raw_data = False
>>> )
Parameters:

api_key (str) – User identification key. Field is required.

get_available_tickers(type: str, data_type: str)[source]

This method provides all the available tickers for the specific data type.

Parameters:
  • type (str) – Data Type. Field is required. Example: ‘trades’, ‘books’

  • data_type (str) – Market Data Type. Field is required. Example: ‘equities’, ‘derivatives’.

get_status(tickers: List[str] = None, raw_data: bool = False)[source]

This method provides the current ticker trading status information.

Parameters:
  • tickers (List[str]) – Ticker symbol. Field is not required. Default: None Example: [‘PETR4’, ‘VALE3’, ‘DOLM25’]. If no ticker is provided, it returns trading status information for all available tickers.

  • raw_data (bool) – If false, returns data in a dataframe. If true, returns raw data. Field is not required. Default: False.

get_tobs(data_type: str, raw_data: bool = False)[source]

This method provides the last available top of book for all tickers of the given market type.

Parameters:
  • data_type (str) – Market Data Type. Field is required. Example: ‘equities’, ‘derivatives’.

  • raw_data (bool) – If false, returns data in a dataframe. If true, returns raw data. Field is not required. Default: False.

get_trades(data_type: str, ticker: str, raw_data: bool = False)[source]

This method provides the last market data event available, for the provided ticker.

Parameters:
  • data_type (str) – Market Data Type. Field is required. Example: ‘equities’, ‘derivatives’.

  • ticker (str) – Ticker symbol. Field is required. Example: ‘PETR4’.

  • raw_data (bool) – If false, returns data in a dataframe. If true, returns raw data. Field is not required. Default: False.

Module contents