btgsolutions-dataservices-python-client 4.8.1__tar.gz → 4.8.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {btgsolutions_dataservices_python_client-4.8.1/btgsolutions_dataservices_python_client.egg-info → btgsolutions_dataservices_python_client-4.8.2}/PKG-INFO +23 -14
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/README.md +21 -4
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/__init__.py +1 -1
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/__init__.py +1 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/bulk_data.py +3 -3
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/dataservices_catalog.py +3 -6
- btgsolutions_dataservices_python_client-4.8.2/btgsolutions_dataservices/rest/market_events.py +149 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2/btgsolutions_dataservices_python_client.egg-info}/PKG-INFO +23 -14
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices_python_client.egg-info/SOURCES.txt +1 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/LICENSE +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/MANIFEST.in +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/config.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/exceptions.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/algohunter.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/alternative_data_catalog.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/alternative_data_companies.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/alternative_data_funds.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/alternative_data_macro_markets.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/alternative_data_metadata.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/alternative_data_ownership.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/alternative_data_people.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/authenticator.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/book_scope.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/broker_analytics.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/broker_reference.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/company_data.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/corporate_events.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/hfn.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/historical_candles.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/historical_candles_crypto.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/intraday_candles.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/intraday_tick_data.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/public_sources.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/quotes.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/reference_data.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/stock_loan.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/ticker_last_event.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/rest/ticker_last_event_polling.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/websocket/__init__.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/websocket/broker_analytics.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/websocket/hfn_websocket_client.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/websocket/market_data_feed.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/websocket/market_data_websocket_client.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices/websocket/websocket_default_functions.py +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices_python_client.egg-info/dependency_links.txt +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices_python_client.egg-info/requires.txt +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/btgsolutions_dataservices_python_client.egg-info/top_level.txt +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/pyproject.toml +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/requirements.txt +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/setup.cfg +0 -0
- {btgsolutions_dataservices_python_client-4.8.1 → btgsolutions_dataservices_python_client-4.8.2}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: btgsolutions_dataservices_python_client
|
|
3
|
-
Version: 4.8.
|
|
3
|
+
Version: 4.8.2
|
|
4
4
|
Summary: Python package containing several classes and data for extracting and manipulating market and trading data.
|
|
5
5
|
Home-page: https://github.com/BTG-Pactual-Solutions/btgsolutions-dataservices-python-client
|
|
6
6
|
Author: BTG Solutions Data Services powered by BTG Pactual Solutions
|
|
@@ -12,14 +12,6 @@ Requires-Dist: websocket-client>=1.8.0
|
|
|
12
12
|
Requires-Dist: PyJWT>=2.8.0
|
|
13
13
|
Requires-Dist: requests>=2.32.3
|
|
14
14
|
Requires-Dist: pyarrow>=17.0.0
|
|
15
|
-
Dynamic: author
|
|
16
|
-
Dynamic: description
|
|
17
|
-
Dynamic: description-content-type
|
|
18
|
-
Dynamic: home-page
|
|
19
|
-
Dynamic: license-file
|
|
20
|
-
Dynamic: requires-dist
|
|
21
|
-
Dynamic: requires-python
|
|
22
|
-
Dynamic: summary
|
|
23
15
|
|
|
24
16
|
# BTG Solutions - Data Services
|
|
25
17
|
|
|
@@ -349,12 +341,8 @@ bulk_data.get_data(ticker='DI1F18', date='2017-01-02', data_type='trades')
|
|
|
349
341
|
# bulk_data.get_data(ticker='PETR4', date='2024-01-22', data_type='books')
|
|
350
342
|
# bulk_data.get_data(ticker='VALE3', date='2024-04-01', data_type='trades-and-book-events')
|
|
351
343
|
# bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='instrument-status')
|
|
352
|
-
# bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='price-events')
|
|
353
|
-
# bulk_data.get_data(ticker='AURE3T', date='2025-05-07', data_type='open-interest')
|
|
354
344
|
# bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='execution-summary')
|
|
355
345
|
# bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='execution-statistics')
|
|
356
|
-
# bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='auction-imbalance')
|
|
357
|
-
# bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='price-quantity-bands')
|
|
358
346
|
```
|
|
359
347
|
|
|
360
348
|
##### Get Data With Billing Headers
|
|
@@ -392,6 +380,27 @@ bulk_data.get_compressed_data(channel='98', date='2026-01-30', data_type='instru
|
|
|
392
380
|
# bulk_data.get_compressed_data(channel='98', date='2026-01-30', data_type='snapshot')
|
|
393
381
|
```
|
|
394
382
|
|
|
383
|
+
#### Market Events
|
|
384
|
+
|
|
385
|
+
##### Available Tickers
|
|
386
|
+
|
|
387
|
+
```python
|
|
388
|
+
import btgsolutions_dataservices as btg
|
|
389
|
+
market_events = btg.MarketEvents(api_key='YOUR_API_KEY')
|
|
390
|
+
market_events.get_available_tickers(date='2025-05-07', data_type='price-events', prefix='PETR')
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
##### Get Data
|
|
394
|
+
|
|
395
|
+
```python
|
|
396
|
+
import btgsolutions_dataservices as btg
|
|
397
|
+
market_events = btg.MarketEvents(api_key='YOUR_API_KEY')
|
|
398
|
+
market_events.get_data(ticker='PETR4', date='2025-05-07', data_type='price-events')
|
|
399
|
+
# market_events.get_data(ticker='AURE3T', date='2025-05-07', data_type='open-interest')
|
|
400
|
+
# market_events.get_data(ticker='PETR4', date='2025-05-07', data_type='auction-imbalance')
|
|
401
|
+
# market_events.get_data(ticker='PETR4', date='2025-05-07', data_type='price-quantity-bands')
|
|
402
|
+
```
|
|
403
|
+
|
|
395
404
|
### Alternative Data
|
|
396
405
|
|
|
397
406
|
#### High Frequency News Stream
|
|
@@ -326,12 +326,8 @@ bulk_data.get_data(ticker='DI1F18', date='2017-01-02', data_type='trades')
|
|
|
326
326
|
# bulk_data.get_data(ticker='PETR4', date='2024-01-22', data_type='books')
|
|
327
327
|
# bulk_data.get_data(ticker='VALE3', date='2024-04-01', data_type='trades-and-book-events')
|
|
328
328
|
# bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='instrument-status')
|
|
329
|
-
# bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='price-events')
|
|
330
|
-
# bulk_data.get_data(ticker='AURE3T', date='2025-05-07', data_type='open-interest')
|
|
331
329
|
# bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='execution-summary')
|
|
332
330
|
# bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='execution-statistics')
|
|
333
|
-
# bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='auction-imbalance')
|
|
334
|
-
# bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='price-quantity-bands')
|
|
335
331
|
```
|
|
336
332
|
|
|
337
333
|
##### Get Data With Billing Headers
|
|
@@ -369,6 +365,27 @@ bulk_data.get_compressed_data(channel='98', date='2026-01-30', data_type='instru
|
|
|
369
365
|
# bulk_data.get_compressed_data(channel='98', date='2026-01-30', data_type='snapshot')
|
|
370
366
|
```
|
|
371
367
|
|
|
368
|
+
#### Market Events
|
|
369
|
+
|
|
370
|
+
##### Available Tickers
|
|
371
|
+
|
|
372
|
+
```python
|
|
373
|
+
import btgsolutions_dataservices as btg
|
|
374
|
+
market_events = btg.MarketEvents(api_key='YOUR_API_KEY')
|
|
375
|
+
market_events.get_available_tickers(date='2025-05-07', data_type='price-events', prefix='PETR')
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
##### Get Data
|
|
379
|
+
|
|
380
|
+
```python
|
|
381
|
+
import btgsolutions_dataservices as btg
|
|
382
|
+
market_events = btg.MarketEvents(api_key='YOUR_API_KEY')
|
|
383
|
+
market_events.get_data(ticker='PETR4', date='2025-05-07', data_type='price-events')
|
|
384
|
+
# market_events.get_data(ticker='AURE3T', date='2025-05-07', data_type='open-interest')
|
|
385
|
+
# market_events.get_data(ticker='PETR4', date='2025-05-07', data_type='auction-imbalance')
|
|
386
|
+
# market_events.get_data(ticker='PETR4', date='2025-05-07', data_type='price-quantity-bands')
|
|
387
|
+
```
|
|
388
|
+
|
|
372
389
|
### Alternative Data
|
|
373
390
|
|
|
374
391
|
#### High Frequency News Stream
|
|
@@ -3,6 +3,7 @@ from .historical_candles import HistoricalCandles
|
|
|
3
3
|
from .historical_candles_crypto import HistoricalCandlesCrypto
|
|
4
4
|
from .authenticator import Authenticator
|
|
5
5
|
from .bulk_data import BulkData
|
|
6
|
+
from .market_events import MarketEvents
|
|
6
7
|
from .hfn import HighFrequencyNews
|
|
7
8
|
from .quotes import Quotes
|
|
8
9
|
from .intraday_tick_data import IntradayTickData
|
|
@@ -112,7 +112,8 @@ class BulkData:
|
|
|
112
112
|
data_type: str
|
|
113
113
|
Market data type.
|
|
114
114
|
Field is required.
|
|
115
|
-
Example: 'trades', 'books'
|
|
115
|
+
Example: 'trades', 'books', 'trades-and-book-events', 'execution-summary'
|
|
116
|
+
or 'execution-statistics'.
|
|
116
117
|
prefix: str
|
|
117
118
|
Filters tickers starting with the prefix.
|
|
118
119
|
Field is optional.
|
|
@@ -208,8 +209,7 @@ class BulkData:
|
|
|
208
209
|
data_type: str
|
|
209
210
|
Market data type.
|
|
210
211
|
Field is required. Available types: 'trades', 'books', 'trades-and-book-events',
|
|
211
|
-
'instrument-status', '
|
|
212
|
-
'execution-statistics', 'auction-imbalance', 'price-quantity-bands'
|
|
212
|
+
'instrument-status', 'execution-summary', 'execution-statistics'
|
|
213
213
|
raw_data: bool
|
|
214
214
|
If false, returns data in a dataframe. If true, returns raw data.
|
|
215
215
|
Field is not required. Default: False.
|
|
@@ -859,18 +859,15 @@ DATASERVICES_ENDPOINTS: dict[str, dict[str, Any]] = {
|
|
|
859
859
|
"description": (
|
|
860
860
|
"Return tick-by-tick bulk market data for one ticker and date as a "
|
|
861
861
|
"Parquet-backed dataset. Data types include trades, books, "
|
|
862
|
-
"trades-and-book-events, instrument-status,
|
|
863
|
-
"
|
|
864
|
-
"auction-imbalance and price-quantity-bands."
|
|
862
|
+
"trades-and-book-events, instrument-status, execution-summary "
|
|
863
|
+
"and execution-statistics."
|
|
865
864
|
),
|
|
866
865
|
"parameters": {
|
|
867
866
|
"ticker": "Ticker such as DI1F18 or PETR4.",
|
|
868
867
|
"date": "Coverage date in YYYY-MM-DD.",
|
|
869
868
|
"data_type": (
|
|
870
869
|
"Bulk data type: trades, books, trades-and-book-events, "
|
|
871
|
-
"instrument-status,
|
|
872
|
-
"execution-summary, execution-statistics, auction-imbalance "
|
|
873
|
-
"or price-quantity-bands."
|
|
870
|
+
"instrument-status, execution-summary or execution-statistics."
|
|
874
871
|
),
|
|
875
872
|
},
|
|
876
873
|
"relationships": [
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
from ..exceptions import BadResponse
|
|
3
|
+
import requests
|
|
4
|
+
from ..config import url_apis
|
|
5
|
+
from .authenticator import Authenticator
|
|
6
|
+
from .bulk_data import extract_billing_headers
|
|
7
|
+
import json
|
|
8
|
+
from io import BytesIO
|
|
9
|
+
import pyarrow.parquet as pq
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class MarketEvents:
|
|
13
|
+
"""
|
|
14
|
+
This class provides B3 market events data (price events, open interest, auction imbalance,
|
|
15
|
+
price & quantity bands) by ticker and date.
|
|
16
|
+
|
|
17
|
+
* Main use case:
|
|
18
|
+
|
|
19
|
+
>>> from btgsolutions_dataservices import MarketEvents
|
|
20
|
+
>>> market_events = MarketEvents(
|
|
21
|
+
>>> api_key='YOUR_API_KEY',
|
|
22
|
+
>>> )
|
|
23
|
+
>>> market_events.get_data(
|
|
24
|
+
>>> ticker = 'PETR4',
|
|
25
|
+
>>> date = '2025-05-07',
|
|
26
|
+
>>> data_type = 'price-events',
|
|
27
|
+
>>> raw_data = False
|
|
28
|
+
>>> )
|
|
29
|
+
|
|
30
|
+
Parameters
|
|
31
|
+
----------------
|
|
32
|
+
api_key: str
|
|
33
|
+
User identification key.
|
|
34
|
+
Field is required.
|
|
35
|
+
"""
|
|
36
|
+
def __init__(
|
|
37
|
+
self,
|
|
38
|
+
api_key:Optional[str]
|
|
39
|
+
):
|
|
40
|
+
self.api_key = api_key
|
|
41
|
+
self.token = Authenticator(self.api_key).token
|
|
42
|
+
self.headers = {"authorization": f"authorization {self.token}"}
|
|
43
|
+
|
|
44
|
+
def get_available_tickers(
|
|
45
|
+
self,
|
|
46
|
+
date:str,
|
|
47
|
+
data_type:str,
|
|
48
|
+
prefix:str=''
|
|
49
|
+
):
|
|
50
|
+
"""
|
|
51
|
+
This method provides all tickers available for query, for the provided market events data type.
|
|
52
|
+
|
|
53
|
+
Parameters
|
|
54
|
+
----------------
|
|
55
|
+
date: str
|
|
56
|
+
Date period.
|
|
57
|
+
Field is required.
|
|
58
|
+
Format: 'YYYY-MM-DD'.
|
|
59
|
+
Example: '2025-05-07'.
|
|
60
|
+
data_type: str
|
|
61
|
+
Market events data type.
|
|
62
|
+
Field is required.
|
|
63
|
+
Example: 'price-events', 'open-interest', 'auction-imbalance' or 'price-quantity-bands'.
|
|
64
|
+
prefix: str
|
|
65
|
+
Filters tickers starting with the prefix.
|
|
66
|
+
Field is optional.
|
|
67
|
+
Example: 'PETR'.
|
|
68
|
+
"""
|
|
69
|
+
url = f"{url_apis}/marketdata/market-events/available-tickers?date={date}&data_type={data_type}&prefix={prefix}"
|
|
70
|
+
response = requests.request("GET", url, headers=self.headers)
|
|
71
|
+
|
|
72
|
+
try:
|
|
73
|
+
response_json = response.json()
|
|
74
|
+
except ValueError as exc:
|
|
75
|
+
body = (response.text or "").strip()
|
|
76
|
+
raise BadResponse(
|
|
77
|
+
f"Error {response.status_code}: non-JSON response from market events available-tickers. "
|
|
78
|
+
f"{body[:500]}"
|
|
79
|
+
) from exc
|
|
80
|
+
if response.status_code == 200: return response_json['tickers']
|
|
81
|
+
raise BadResponse(f'Error: {response_json.get("ApiClientError", "")}.\n{response_json.get("SuggestedAction", "")}')
|
|
82
|
+
|
|
83
|
+
def get_data(
|
|
84
|
+
self,
|
|
85
|
+
ticker:str,
|
|
86
|
+
date:str,
|
|
87
|
+
data_type:str='price-events',
|
|
88
|
+
raw_data:bool=False,
|
|
89
|
+
dry_run:bool=False,
|
|
90
|
+
):
|
|
91
|
+
"""
|
|
92
|
+
This method provides B3 market events data (price events, open interest, auction imbalance,
|
|
93
|
+
price & quantity bands) for a given ticker and date.
|
|
94
|
+
|
|
95
|
+
Parameters
|
|
96
|
+
----------------
|
|
97
|
+
ticker: str
|
|
98
|
+
Ticker that needs to be returned.
|
|
99
|
+
Field is required. Example: 'PETR4'.
|
|
100
|
+
date: str
|
|
101
|
+
Date period.
|
|
102
|
+
Field is required.
|
|
103
|
+
Format: 'YYYY-MM-DD'. Example: '2025-05-07'.
|
|
104
|
+
data_type: str
|
|
105
|
+
Market events data type.
|
|
106
|
+
Field is required. Available types: 'price-events', 'open-interest',
|
|
107
|
+
'auction-imbalance', 'price-quantity-bands'.
|
|
108
|
+
raw_data: bool
|
|
109
|
+
If false, returns data in a dataframe. If true, returns raw data.
|
|
110
|
+
Field is not required. Default: False.
|
|
111
|
+
dry_run: bool
|
|
112
|
+
If true, checks request validity without downloading data and returns informative headers.
|
|
113
|
+
Field is not required. Default: False.
|
|
114
|
+
"""
|
|
115
|
+
|
|
116
|
+
url = f"{url_apis}/marketdata/market-events/{data_type}?ticker={ticker}&date={date}"
|
|
117
|
+
if dry_run:
|
|
118
|
+
url = f"{url}&dry_run=true"
|
|
119
|
+
|
|
120
|
+
response = requests.request("GET", url, headers=self.headers)
|
|
121
|
+
|
|
122
|
+
if response.status_code == 204 and dry_run:
|
|
123
|
+
return extract_billing_headers(response.headers)
|
|
124
|
+
|
|
125
|
+
if response.status_code == 200:
|
|
126
|
+
|
|
127
|
+
try:
|
|
128
|
+
|
|
129
|
+
if raw_data == False:
|
|
130
|
+
parquet_buffer = BytesIO(response.content)
|
|
131
|
+
parquet_file = pq.ParquetFile(parquet_buffer)
|
|
132
|
+
df = parquet_file.read().to_pandas()
|
|
133
|
+
return df
|
|
134
|
+
|
|
135
|
+
else:
|
|
136
|
+
content_disposition = response.headers.get('Content-Disposition', '')
|
|
137
|
+
filename = content_disposition.split('filename=')[1]
|
|
138
|
+
|
|
139
|
+
# Write the content to a file
|
|
140
|
+
with open(filename, 'wb') as file:
|
|
141
|
+
file.write(response.content)
|
|
142
|
+
return None
|
|
143
|
+
|
|
144
|
+
except Exception as e:
|
|
145
|
+
print(f'error while trying to retrieve file:\n{e}')
|
|
146
|
+
return None
|
|
147
|
+
|
|
148
|
+
response = json.loads(response.text)
|
|
149
|
+
raise BadResponse(f'Error: {response.get("ApiClientError", "")}.\n{response.get("SuggestedAction", "")}')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: btgsolutions_dataservices_python_client
|
|
3
|
-
Version: 4.8.
|
|
3
|
+
Version: 4.8.2
|
|
4
4
|
Summary: Python package containing several classes and data for extracting and manipulating market and trading data.
|
|
5
5
|
Home-page: https://github.com/BTG-Pactual-Solutions/btgsolutions-dataservices-python-client
|
|
6
6
|
Author: BTG Solutions Data Services powered by BTG Pactual Solutions
|
|
@@ -12,14 +12,6 @@ Requires-Dist: websocket-client>=1.8.0
|
|
|
12
12
|
Requires-Dist: PyJWT>=2.8.0
|
|
13
13
|
Requires-Dist: requests>=2.32.3
|
|
14
14
|
Requires-Dist: pyarrow>=17.0.0
|
|
15
|
-
Dynamic: author
|
|
16
|
-
Dynamic: description
|
|
17
|
-
Dynamic: description-content-type
|
|
18
|
-
Dynamic: home-page
|
|
19
|
-
Dynamic: license-file
|
|
20
|
-
Dynamic: requires-dist
|
|
21
|
-
Dynamic: requires-python
|
|
22
|
-
Dynamic: summary
|
|
23
15
|
|
|
24
16
|
# BTG Solutions - Data Services
|
|
25
17
|
|
|
@@ -349,12 +341,8 @@ bulk_data.get_data(ticker='DI1F18', date='2017-01-02', data_type='trades')
|
|
|
349
341
|
# bulk_data.get_data(ticker='PETR4', date='2024-01-22', data_type='books')
|
|
350
342
|
# bulk_data.get_data(ticker='VALE3', date='2024-04-01', data_type='trades-and-book-events')
|
|
351
343
|
# bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='instrument-status')
|
|
352
|
-
# bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='price-events')
|
|
353
|
-
# bulk_data.get_data(ticker='AURE3T', date='2025-05-07', data_type='open-interest')
|
|
354
344
|
# bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='execution-summary')
|
|
355
345
|
# bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='execution-statistics')
|
|
356
|
-
# bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='auction-imbalance')
|
|
357
|
-
# bulk_data.get_data(ticker='PETR4', date='2025-05-07', data_type='price-quantity-bands')
|
|
358
346
|
```
|
|
359
347
|
|
|
360
348
|
##### Get Data With Billing Headers
|
|
@@ -392,6 +380,27 @@ bulk_data.get_compressed_data(channel='98', date='2026-01-30', data_type='instru
|
|
|
392
380
|
# bulk_data.get_compressed_data(channel='98', date='2026-01-30', data_type='snapshot')
|
|
393
381
|
```
|
|
394
382
|
|
|
383
|
+
#### Market Events
|
|
384
|
+
|
|
385
|
+
##### Available Tickers
|
|
386
|
+
|
|
387
|
+
```python
|
|
388
|
+
import btgsolutions_dataservices as btg
|
|
389
|
+
market_events = btg.MarketEvents(api_key='YOUR_API_KEY')
|
|
390
|
+
market_events.get_available_tickers(date='2025-05-07', data_type='price-events', prefix='PETR')
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
##### Get Data
|
|
394
|
+
|
|
395
|
+
```python
|
|
396
|
+
import btgsolutions_dataservices as btg
|
|
397
|
+
market_events = btg.MarketEvents(api_key='YOUR_API_KEY')
|
|
398
|
+
market_events.get_data(ticker='PETR4', date='2025-05-07', data_type='price-events')
|
|
399
|
+
# market_events.get_data(ticker='AURE3T', date='2025-05-07', data_type='open-interest')
|
|
400
|
+
# market_events.get_data(ticker='PETR4', date='2025-05-07', data_type='auction-imbalance')
|
|
401
|
+
# market_events.get_data(ticker='PETR4', date='2025-05-07', data_type='price-quantity-bands')
|
|
402
|
+
```
|
|
403
|
+
|
|
395
404
|
### Alternative Data
|
|
396
405
|
|
|
397
406
|
#### High Frequency News Stream
|
|
@@ -29,6 +29,7 @@ btgsolutions_dataservices/rest/historical_candles.py
|
|
|
29
29
|
btgsolutions_dataservices/rest/historical_candles_crypto.py
|
|
30
30
|
btgsolutions_dataservices/rest/intraday_candles.py
|
|
31
31
|
btgsolutions_dataservices/rest/intraday_tick_data.py
|
|
32
|
+
btgsolutions_dataservices/rest/market_events.py
|
|
32
33
|
btgsolutions_dataservices/rest/public_sources.py
|
|
33
34
|
btgsolutions_dataservices/rest/quotes.py
|
|
34
35
|
btgsolutions_dataservices/rest/reference_data.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|