btgsolutions_otcmarkets.rest package
Submodules
btgsolutions_otcmarkets.rest.authenticator module
btgsolutions_otcmarkets.rest.historical_data module
- class btgsolutions_otcmarkets.rest.historical_data.HistoricalData(api_key: str | None)[source]
Bases:
objectThis class provides historical data from OTC Market and CETIP Market.
Main use case:
>>> from btgsolutions_otcmarkets import HistoricalData >>> historical_data = HistoricalData( >>> api_key='YOUR_API_KEY', >>> )
>>> historical_data.get_otc_trades( >>> ticker='PLSB1A', >>> start_date='2024-09-01', >>> end_date='2024-10-01', >>> )
>>> historical_data.get_cetip_grouped_trades( >>> ticker='PLSB1A', >>> granularity='monthly' >>> )
- Parameters:
api_key (str) – User identification key. Field is required.
- get_cetip_grouped_trades(ticker: str, start_date: str = '1900-01-01', end_date: str = '2100-01-01', granularity: str = 'daily')[source]
This method get the historical trades of CETIP Market by ticker and aggregated daily, weekly or monthly.
- Parameters:
ticker (string) – Asset ticker. Field is required. Example: ‘PLSB1A’.
start_date (str) – Start date-time in YYYY-MM-DD format (e.g., 2024-01-01). Field is not required. Default: “1900-01-01”.
end_date (str) – Final date-time in YYYY-MM-DD format (e.g., 2024-01-01). Field is not required. Default: “2100-01-01”.
granularity (str) – Granularity of the data (daily, weekly, monthly) Field is not required. Default: daily.
- get_cetip_tickers()[source]
This method get the available tickers for getting CETIP trades. Includes all ticker that has at least one trade in our CETIP database.
- get_otc_grouped_trades(ticker: str, start_date: str = '1900-01-01', end_date: str = '2100-01-01', granularity: str = 'daily')[source]
This method get the historical trades of BTG OTC Market by ticker and aggregated daily, weekly or monthly.
- Parameters:
ticker (string) – Asset ticker. Field is required. Example: ‘PLSB1A’.
start_date (str) – Start date-time in YYYY-MM-DD format (e.g., 2024-01-01). Field is not required. Default: “1900-01-01”.
end_date (str) – Final date-time in YYYY-MM-DD format (e.g., 2024-01-01). Field is not required. Default: “2100-01-01”.
granularity (str) – Granularity of the data (daily, weekly, monthly) Field is not required. Default: daily.
- get_otc_tickers()[source]
This method get the available tickers for getting OTC trades. Includes all ticker that has at least one trade in OTC.
- get_otc_trades(ticker: str, start_date: str = '1900-01-01', end_date: str = '2100-01-01')[source]
This method get the historical trades of BTG OTC Market by ticker.
- Parameters:
ticker (string) – Asset ticker. Field is required. Example: ‘PLSB1A’.
start_date (str) – Start date-time in YYYY-MM-DD format (e.g., 2024-01-01). Field is not required. Default: “1900-01-01”.
end_date (str) – Final date-time in YYYY-MM-DD format (e.g., 2024-01-01). Field is not required. Default: “2100-01-01”.
btgsolutions_otcmarkets.rest.pricing module
- class btgsolutions_otcmarkets.rest.pricing.Pricing(api_key: str | None)[source]
Bases:
objectThis class provides asset pricing.
Main use case:
>>> from btgsolutions_otcmarkets import Pricing >>> pricing = Pricing( >>> api_key='YOUR_API_KEY', >>> )
>>> pricing.get_ticker_price( >>> ticker='ZTEST01', >>> rate=6.41, >>> )
>>> pricing.get_ticker_rate( >>> ticker='ZTEST01', >>> price=952.32, >>> )
- Parameters:
api_key (str) – User identification key. Field is required.
- get_ticker_price(ticker: str, rate: float, date: str = None)[source]
This method calculates ticker unit price for a given rate.
- Parameters:
ticker (string) – Asset ticker. Field is required. Example: ‘ZTEST01’.
rate (float) – Desired rate. Expressed in percentage (6.41% would be represented as 6.41). Field is required. Example: 6.41.
date (string) – Desired date, in “YYYY-MM-DD” format. Field is not required. Default: today, represented in “YYYY-MM-DD” format.
- get_ticker_rate(ticker: str, price: float, date: str = None)[source]
This method calculates asset rate for a given unit price.
- Parameters:
ticker (string) – Asset ticker. Field is required. Example: ‘ZTEST01’.
price (float) – Desired unit price. Expressed in absolute value (R$923,70 would be represented as 923.7). Field is required. Example: 923.7.
date (string) – Desired date, in “YYYY-MM-DD” format. Field is not required. Default: today, represented in “YYYY-MM-DD” format.
btgsolutions_otcmarkets.rest.reference_data module
- class btgsolutions_otcmarkets.rest.reference_data.ReferenceData(api_key: str | None)[source]
Bases:
objectThis class provides OTC Markets reference data, such as: available tickers, holidays, market status, etc.
Main use case:
>>> from btgsolutions_otcmarkets import ReferenceData >>> ref = ReferenceData( >>> api_key='YOUR_API_KEY', >>> )
>>> ref.get_ticker_data()
>>> ref.get_ticker_data( >>> tickers=['ZTEST01','ZTEST02'], >>> )
>>> ref.get_ticker_data_paginated( >>> page=1, >>> size=50, >>> )
>>> ref.get_available_tickers()
>>> ref.get_market_status()
>>> ref.get_holidays()
- Parameters:
api_key (str) – User identification key. Field is required.
- get_holidays(raw_data: bool = False)[source]
This method provides the list of holidays that the OTC Markets platform follows.
- Parameters:
raw_data (bool) – If false, returns data in a dataframe. If true, returns raw data. Field is not required. Default: False.
- get_market_status()[source]
This method provides opening and closing time for DMA and Algo orders. It also returns OTC Markets server current time.
- get_ticker_data(tickers: list = [], raw_data: bool = False)[source]
This method provides ticker data for all available tickers. One can filter by an array of tickers if want.
- Parameters:
tickers (list) – Array of strings, each string representing a single ticker. Example: [‘ZTEST01’,’ZTEST02’]. Field is not required. Default: Empty list.
raw_data (bool) – If false, returns data in a dataframe. If true, returns raw data. Field is not required. Default: False.
- get_ticker_data_paginated(page: int, size: int)[source]
This method provides paginated ticker data for all available tickers. One must specify the desired page number and page size.
- Parameters:
page (int) – Page number. Field is required.
size (int) – Page size (number of records in a page). Field is required.
btgsolutions_otcmarkets.rest.risk_status module
- class btgsolutions_otcmarkets.rest.risk_status.Risk(api_key: str | None)[source]
Bases:
objectThis class provides risk status information for a given trader or investor ID.
Main use case:
>>> from btgsolutions_otcmarkets import Risk >>> risk = Risk( >>> api_key='YOUR_API_KEY', >>> )
>>> risk.risk_status_trader( >>> investor='YOUR_INVESTOR_ID', >>> )
>>> risk.risk_status_investor( >>> investor='YOUR_INVESTOR_ID', >>> )
- Parameters:
api_key (str) – User identification key. Field is required.
btgsolutions_otcmarkets.rest.top_of_book module
- class btgsolutions_otcmarkets.rest.top_of_book.TopOfBook(api_key: str | None)[source]
Bases:
objectThis class provides the Top Of Book for all tickers that have at least 1 placed order.
Main use case:
>>> from btgsolutions_otcmarkets import TopOfBook >>> tob = TopOfBook( >>> api_key='YOUR_API_KEY', >>> )
>>> tob.get_top_of_book( >>> ticker='ZTEST01', >>> )
>>> tob.get_top_of_book()
- Parameters:
api_key (str) – User identification key. Field is required.
- get_top_of_book(ticker: str = None, raw_data: bool = False)[source]
This method provides the Top Of Book for a given ticker. If no ticker is provided, it returns the Top Of Book for all tickers that have at least 1 placed order.
- Parameters:
ticker (string) – Asset ticker. Field is required. Example: ‘ZTEST01’.
raw_data (bool) – If false, returns data in a dataframe. If true, returns raw data. Field is not required. Default: False.