Skip to main content

BTG Solutions - OTC Markets

Python library to access BTG OTC Markets.

Official package docs are hosted at https://otcmarkets-python-docs.btgpactualsolutions.com/

Installation

pip3 install btgsolutions-otcmarkets-python-client

Examples

Ticker Reference Data

import btgsolutions_otcmarkets as otc
ref = otc.ReferenceData(api_key='API_KEY')
ref.get_ticker_data(tickers=['ZTEST01', 'ZTEST02'])

Ticker Reference Data (All Tickers)

import btgsolutions_otcmarkets as otc
ref = otc.ReferenceData(api_key='API_KEY')
ref.get_ticker_data()

Ticker Pricing

import btgsolutions_otcmarkets as otc
pricing = otc.Pricing(api_key='API_KEY')
pricing.get_ticker_price(ticker='ZTEST01', rate=6.51)
# pricing.get_ticker_rate(ticker='ZTEST01', price=1052.20)

Top Of Book

import btgsolutions_otcmarkets as otc
tob = otc.TopOfBook(api_key='API_KEY')
tob.get_top_of_book(ticker='ZTEST01')

Top Of Book (All Tickers)

import btgsolutions_otcmarkets as otc
tob = otc.TopOfBook(api_key='API_KEY')
tob.get_top_of_book()

Risk Status

import btgsolutions_otcmarkets as otc
risk = otc.Risk(api_key='API_KEY')
risk.risk_status_trader(investor_id='YOUR_INVESTOR_ID')
# risk.risk_status_investor(investor_id='YOUR_INVESTOR_ID')

Market Data Stream

import btgsolutions_otcmarkets as otc
mktdata = otc.MarketDataStream(api_key='API_KEY')
mktdata.run()
mktdata.subscribe(tickers=['ZTEST01'])
# mktdata.unsubscribe(tickers=['ZTEST01'])

## The following code is optional, it keeps the program running in a .py file:
# from time import sleep
# while True:
#   sleep(1)

NTN-B Prices Stream

import btgsolutions_otcmarkets as otc

def on_price_update(message):
    print(message)

ntnb_prices = otc.NtnbPrices(api_key='API_KEY')
ntnb_prices.run(on_price_update=on_price_update)

## The following code is optional, it keeps the program running in a .py file:
# from time import sleep
# while True:
#   sleep(1)

Order Entry - Create New Order

import btgsolutions_otcmarkets as otc
order_entry = otc.OrderEntry(api_key='API_KEY', investor_id='YOUR_INVESTOR_ID')
order_entry.run()
order_entry.create_new_order(
    order_temp_id="123",
    ticker='ZTEST01',
    rate=6.22,
    qty=200,
    side='buy',
)

## The following code is optional, it keeps the program running in a .py file:
# from time import sleep
# while True:
#   sleep(1)

Order Entry - Replace Order

import btgsolutions_otcmarkets as otc
order_entry = otc.OrderEntry(api_key='API_KEY', investor_id='YOUR_INVESTOR_ID')
order_entry.run()
order_entry.replace_order(
    external_id="your-order-external-id",
    rate=6.30,
    qty=180,
)

## The following code is optional, it keeps the program running in a .py file:
# from time import sleep
# while True:
#   sleep(1)

Order Entry - Cancel Order

import btgsolutions_otcmarkets as otc
order_entry = otc.OrderEntry(api_key='API_KEY', investor_id='YOUR_INVESTOR_ID')
order_entry.run()
order_entry.cancel_order(
    external_id="your-order-external-id",
)

## The following code is optional, it keeps the program running in a .py file:
# from time import sleep
# while True:
#   sleep(1)

RFQ OTC - Create RFQ

import btgsolutions_otcmarkets as otc

rfq = otc.RfqOtc(api_key='API_KEY')
rfq.run()
rfq.subscribe(investor_id='YOUR_INVESTOR_ID')

rfq.create_rfq(
    symbol='ZTEST01',
    side='1',
    volume=100000,
    to_everyone=False,
    accept_partial=True,
    quote_mode='nominal_rate',
    expiration_minutes=10,
)

## The following code is optional, it keeps the program running in a .py file:
# from time import sleep
# while True:
#   sleep(1)

RFQ OTC - Quote RFQ

import btgsolutions_otcmarkets as otc

rfq = otc.RfqOtc(api_key='API_KEY')
rfq.run()
rfq.subscribe(investor_id='YOUR_INVESTOR_ID')

rfq.quote(
    request_id='RFQ_REQUEST_ID',
    rate=10.25,
    volume=100000,
)

## quote_mode is optional. If omitted, the API uses the quote_mode from the original RFQ.

RFQ OTC - Accept or Cancel RFQ

import btgsolutions_otcmarkets as otc

rfq = otc.RfqOtc(api_key='API_KEY')
rfq.run()
rfq.subscribe(investor_id='YOUR_INVESTOR_ID')

rfq.accept_quote(
    request_id='RFQ_REQUEST_ID',
    quote_id='QUOTE_ID',
)

# rfq.cancel_rfq(request_id='RFQ_REQUEST_ID')
# rfq.cancel_quote(request_id='RFQ_REQUEST_ID')

Historical Data - OTC Trades

import btgsolutions_otcmarkets as otc

historical_data = otc.HistoricalData(api_key='API_KEY')

historical_data.get_otc_trades(ticker = 'PLSB1A')

Metadata

Release files for btgsolutions-otcmarkets-python-client 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for btgsolutions-otcmarkets-python-client 0.2.0
File Size Uploaded Provenance Actions
btgsolutions_otcmarkets_python_client-0.2.0.tar.gz 13.9 kB Without provenance Details for btgsolutions_otcmarkets_python_client-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for btgsolutions-otcmarkets-python-client 0.2.0
File Interpreter ABI Platform Actions
btgsolutions_otcmarkets_python_client-0.2.0-py3-none-any.whl Python 3 none any Details for btgsolutions_otcmarkets_python_client-0.2.0-py3-none-any.whl

Total release size: 36.6 kB

Release files / btgsolutions_otcmarkets_python_client-0.2.0.tar.gz

Download URL btgsolutions_otcmarkets_python_client-0.2.0.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f82b5d28554f96a9b60ab32e86899abb9231162462bb516b968720437589c7be
BLAKE2b-256 checksum
How to use checksums
a4a5e81b11f7aeea446c3d502d2feed92f704d02b29794453b10b9c8f52ba858
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / btgsolutions_otcmarkets_python_client-0.2.0-py3-none-any.whl

Download URL btgsolutions_otcmarkets_python_client-0.2.0-py3-none-any.whl
Size 22.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
073472147d64470dd7c2ee9bb152314dc6b0f42fc159e6184ea4049782ad1b6f
BLAKE2b-256 checksum
How to use checksums
513c7028699101471b12bf4337a0c941c6bd0c56b29eaf44375dfefb2a5298f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for btgsolutions-otcmarkets-python-client 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page