Python package containing several classes and data for extracting and manipulating market and trading data.
Project description
BTG Solutions - Data Service
Python library to get Brazilian Financial Market Data.
Installation
pip3 install btgsolutions-dataservices-python-client
Example - WebSocket Books
import btgsolutions_dataservices as btg
ws = btg.WebSocketClient(api_key='YOUR_API_KEY', ws_type='books', instruments=['PETR4', 'VALE3'])
ws.run(on_message=lambda message: print(message))
## The following is optional to keep the program running in a .py file:
# from time import sleep
# while True:
# sleep(1)
Example - WebSocket Trades Delayed
import btgsolutions_dataservices as btg
ws = btg.WebSocketClient(api_key='YOUR_API_KEY', ws_type='trades', target='delayed', instruments=['PETR4', 'VALE3'])
ws.run(on_message=lambda message: print(message))
## The following is optional to keep the program running in a .py file:
# from time import sleep
# while True:
# sleep(1)
Example - WebSocket Trades with 1 second throttle
import btgsolutions_dataservices as btg
ws = btg.WebSocketClient(api_key='YOUR_API_KEY', ws_type='trades', target='throttle', instruments=['PETR4', 'VALE3'])
ws.run(on_message=lambda message: print(message))
## The following is optional to keep the program running in a .py file:
# from time import sleep
# while True:
# sleep(1)
Example - WebSocket Securities (Derivatives)
import btgsolutions_dataservices as btg
ws = btg.WebSocketClient(api_key='YOUR_API_KEY', ws_type='securities', feed='stocks', target='realtime')
ws.run(on_message=lambda message: print(message))
## The following is optional to keep the program running in a .py file:
# from time import sleep
# while True:
# sleep(1)
Example - WebSocket Candles 1S
import btgsolutions_dataservices as btg
ws = btg.WebSocketClient(api_key='YOUR_API_KEY', ws_type='candles-1S', target='delayed')
ws.run(on_message=lambda message: print(message))
ws.candle_subscribe(list_instruments=['PETR4','VALE3'], candle_type='partial')
## The following is optional to keep the program running in a .py file:
# from time import sleep
# while True:
# sleep(1)
## Another examples
# ws.candle_subscribe(list_instruments=['PRIO3'], candle_type='closed')
# ws.candle_subscribe(list_instruments=['WEGE3'], candle_type='all')
# ws.candle_unsubscribe(list_instruments=['PRIO3', 'PETR4'], candle_type='all')
Example - WebSocket High Frequency News
import btgsolutions_dataservices as btg
ws = btg.WebSocketClient(api_key='YOUR_API_KEY', feed='hfn', ws_type='brazil')
ws.run(on_message=lambda message: print(message))
## The following is optional to keep the program running in a .py file:
# from time import sleep
# while True:
# sleep(1)
Example - IntradayCandles
import btgsolutions_dataservices as btg
int_candles = btg.IntradayCandles(api_key='YOUR_API_KEY')
int_candles.get_intraday_candles(market_type='stocks', tickers=['PETR4', 'VALE3'], candle_period='1m', mode='relative', raw_data=True)
Example - Get Interday History Candles
import btgsolutions_dataservices as btg
hist_candles = btg.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-01', end_date='2023-10-13', rmv_after_market=True, timezone='UTC', raw_data=False)
Example - Get Intraday History Candles
import btgsolutions_dataservices as btg
hist_candles = btg.HistoricalCandles(api_key='YOUR_API_KEY')
hist_candles.get_intraday_history_candles(ticker='PETR4', market_type='stocks', corporate_events_adj=True, date='2023-10-06', candle='1m', rmv_after_market=True, timezone='UTC', raw_data=False)
Example - Plot History Candles
import btgsolutions_dataservices as btg
hist_candles = btg.HistoricalCandles(api_key='YOUR_API_KEY')
hist_candles.get_intraday_history_candles(ticker='PETR4', market_type='stocks', corporate_events_adj=True, date='2023-10-06', candle='1m', rmv_after_market=True, timezone='UTC', raw_data=False).plot(x='candle_time', y='close_price', kind='scatter')
Example - Quotes
import btgsolutions_dataservices as btg
quotes = btg.Quotes(api_key='YOUR_API_KEY')
quotes.get_quote(market_type = 'stocks', tickers = ['PETR4', 'VALE3'])
Example - BulkData
import btgsolutions_dataservices as btg
bulk_data = btg.BulkData(api_key='YOUR_API_KEY')
bulk_data.get_data(ticker='PETR4', date='2023-07-03', data_type='trades')
Example - Intraday Tick Data
import btgsolutions_dataservices as btg
intra_tickdata = btg.IntradayTickData(api_key='YOUR_API_KEY')
intra_tickdata.get_trades(ticker='PETR4')
Example - HighFrequencyNews
import btgsolutions_dataservices as btg
hfn = btg.HighFrequencyNews(api_key='YOUR_API_KEY')
hfn.latest_news()
Documentation
The official documentation is hosted at https://python-client-docs.dataservices.btgpactualsolutions.com/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for btgsolutions-dataservices-python-client-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba255df763488e0ec404d13afaaa753373acab8b87486a0306ec35047e00f38c |
|
MD5 | a8374366e6bf51108d5796597e1bd750 |
|
BLAKE2b-256 | 149de455da94a89c9290c063bbcfe1d729dddc7d614b92de9bfe7032707de0eb |
Close
Hashes for btgsolutions_dataservices_python_client-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fc12060c65266f2d5bdda2b1dd0afed300143e46e435036c81866341c43713b |
|
MD5 | 5167e2ea7d17d0abdf3f2f2bc69013ba |
|
BLAKE2b-256 | 62a7e97b7bf7d19945fd625aac8f0f05a1908d9f661d793bcbb9be7c679adfce |