Skip to main content

Python library to access BTG OTC Markets APIs.

Project description

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)

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)

Historical Data - OTC Trades

import btgsolutions_otcmarkets as otc

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

historical_data.get_otc_trades(ticker = 'PLSB1A')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

btgsolutions_otcmarkets_python_client-0.1.0.tar.gz (10.9 kB view details)

Uploaded Source

File details

Details for the file btgsolutions_otcmarkets_python_client-0.1.0.tar.gz.

File metadata

File hashes

Hashes for btgsolutions_otcmarkets_python_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6c5b3acba4128b3259f84c79dcb6b0606280af460a7663b7f13b9b5cd9c748e8
MD5 4280d7c61d265c4912d75e433664f515
BLAKE2b-256 59df12acfb23b5f1bfd60f44b65fd474d6445f362e2568f8ed31c874bd699428

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page