btgsolutions-dataservices-python-client 2.17.0__tar.gz → 2.18.0__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-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/PKG-INFO +6 -6
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/README.md +5 -1
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/rest/ticker_last_event_polling.py +25 -9
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices_python_client.egg-info/PKG-INFO +5 -5
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/setup.py +2 -2
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/LICENSE +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/MANIFEST.in +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/__init__.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/config.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/exceptions.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/rest/__init__.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/rest/authenticator.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/rest/bulk_data.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/rest/company_data.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/rest/corporate_events.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/rest/hfn.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/rest/historical_candles.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/rest/intraday_candles.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/rest/intraday_tick_data.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/rest/public_sources.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/rest/quotes.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/rest/reference_data.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/rest/stock_loan.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/rest/ticker_last_event.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/websocket/__init__.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/websocket/hfn_websocket_client.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/websocket/market_data_feed.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/websocket/market_data_websocket_client.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices/websocket/websocket_default_functions.py +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices_python_client.egg-info/SOURCES.txt +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices_python_client.egg-info/dependency_links.txt +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices_python_client.egg-info/requires.txt +3 -3
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/btgsolutions_dataservices_python_client.egg-info/top_level.txt +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/pyproject.toml +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/requirements.txt +0 -0
- {btgsolutions-dataservices-python-client-2.17.0 → btgsolutions_dataservices_python_client-2.18.0}/setup.cfg +0 -0
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
|
-
Name:
|
|
3
|
-
Version: 2.
|
|
2
|
+
Name: btgsolutions_dataservices_python_client
|
|
3
|
+
Version: 2.18.0
|
|
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
|
|
7
|
-
License: UNKNOWN
|
|
8
|
-
Platform: UNKNOWN
|
|
9
7
|
Requires-Python: >=3.9,<3.14
|
|
10
8
|
Description-Content-Type: text/markdown
|
|
11
9
|
License-File: LICENSE
|
|
@@ -13,6 +11,7 @@ License-File: LICENSE
|
|
|
13
11
|
# BTG Solutions - Data Services
|
|
14
12
|
|
|
15
13
|
Real time and historical Financial Market Data, News, Corporate Events and more.
|
|
14
|
+
More information at https://dataservices.btgpactualsolutions.com/.
|
|
16
15
|
|
|
17
16
|
## Installation
|
|
18
17
|
|
|
@@ -233,6 +232,7 @@ import btgsolutions_dataservices as btg
|
|
|
233
232
|
last_event = btg.TickerLastEvent(api_key='YOUR_API_KEY')
|
|
234
233
|
last_event.get_tobs(data_type='stocks')
|
|
235
234
|
```
|
|
235
|
+
|
|
236
236
|
#### Ticker Last Trading Status
|
|
237
237
|
|
|
238
238
|
```python
|
|
@@ -240,7 +240,8 @@ import btgsolutions_dataservices as btg
|
|
|
240
240
|
last_event = btg.TickerLastEvent(api_key='YOUR_API_KEY')
|
|
241
241
|
last_event.get_status(tickers=['PETR4','VALE3'])
|
|
242
242
|
```
|
|
243
|
-
|
|
243
|
+
|
|
244
|
+
#### Ticker Last Polling - Top of Books
|
|
244
245
|
|
|
245
246
|
```python
|
|
246
247
|
import btgsolutions_dataservices as btg
|
|
@@ -466,4 +467,3 @@ ref = btg.ReferenceData(api_key='YOUR_API_KEY')
|
|
|
466
467
|
ref.ticker_reference(tickers=['VALE3','PETR4'])
|
|
467
468
|
```
|
|
468
469
|
|
|
469
|
-
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# BTG Solutions - Data Services
|
|
2
2
|
|
|
3
3
|
Real time and historical Financial Market Data, News, Corporate Events and more.
|
|
4
|
+
More information at https://dataservices.btgpactualsolutions.com/.
|
|
4
5
|
|
|
5
6
|
## Installation
|
|
6
7
|
|
|
@@ -221,6 +222,7 @@ import btgsolutions_dataservices as btg
|
|
|
221
222
|
last_event = btg.TickerLastEvent(api_key='YOUR_API_KEY')
|
|
222
223
|
last_event.get_tobs(data_type='stocks')
|
|
223
224
|
```
|
|
225
|
+
|
|
224
226
|
#### Ticker Last Trading Status
|
|
225
227
|
|
|
226
228
|
```python
|
|
@@ -228,7 +230,8 @@ import btgsolutions_dataservices as btg
|
|
|
228
230
|
last_event = btg.TickerLastEvent(api_key='YOUR_API_KEY')
|
|
229
231
|
last_event.get_status(tickers=['PETR4','VALE3'])
|
|
230
232
|
```
|
|
231
|
-
|
|
233
|
+
|
|
234
|
+
#### Ticker Last Polling - Top of Books
|
|
232
235
|
|
|
233
236
|
```python
|
|
234
237
|
import btgsolutions_dataservices as btg
|
|
@@ -453,3 +456,4 @@ import btgsolutions_dataservices as btg
|
|
|
453
456
|
ref = btg.ReferenceData(api_key='YOUR_API_KEY')
|
|
454
457
|
ref.ticker_reference(tickers=['VALE3','PETR4'])
|
|
455
458
|
```
|
|
459
|
+
|
|
@@ -6,7 +6,7 @@ from ..config import url_api_v1
|
|
|
6
6
|
from .authenticator import Authenticator
|
|
7
7
|
import pandas as pd
|
|
8
8
|
import json
|
|
9
|
-
from datetime import datetime, timezone
|
|
9
|
+
from datetime import datetime, timezone, timedelta
|
|
10
10
|
import threading
|
|
11
11
|
|
|
12
12
|
class TickerLastEventPolling:
|
|
@@ -33,11 +33,11 @@ class TickerLastEventPolling:
|
|
|
33
33
|
Field is required.
|
|
34
34
|
data_type: str
|
|
35
35
|
Market Data type.
|
|
36
|
-
Options: 'top-of-books'
|
|
36
|
+
Options: 'top-of-books', 'snapshot-tob'.
|
|
37
37
|
Field is required.
|
|
38
38
|
data_subtype: str
|
|
39
39
|
Market Data subtype.
|
|
40
|
-
Options: 'stocks', 'options', 'derivatives'.
|
|
40
|
+
Options: 'stocks', 'options', 'derivatives', 'equities'.
|
|
41
41
|
Field is required.
|
|
42
42
|
"""
|
|
43
43
|
def __init__(
|
|
@@ -45,24 +45,33 @@ class TickerLastEventPolling:
|
|
|
45
45
|
api_key:Optional[str],
|
|
46
46
|
data_type: str,
|
|
47
47
|
data_subtype: str,
|
|
48
|
-
interval_seconds: float
|
|
48
|
+
interval_seconds: Optional[float]=None
|
|
49
49
|
):
|
|
50
50
|
self.api_key = api_key
|
|
51
51
|
self.authenticator = Authenticator(self.api_key)
|
|
52
|
-
self.interval_seconds = interval_seconds
|
|
53
52
|
self.data_type = data_type
|
|
54
53
|
|
|
55
54
|
self._last_request_datetime = None
|
|
56
55
|
self._cache = {}
|
|
57
56
|
|
|
58
57
|
self._available_data_types = {
|
|
59
|
-
"top-of-books": ['stocks', 'derivatives', 'options']
|
|
58
|
+
"top-of-books": ['stocks', 'derivatives', 'options'],
|
|
59
|
+
"snapshot-tob": ['equities', 'derivatives']
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
self._default_interval_seconds = {
|
|
63
|
+
"top-of-books": 1,
|
|
64
|
+
"snapshot-tob": 10
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
self._available_url = {
|
|
63
68
|
"top-of-books": {
|
|
64
69
|
"data": f"{url_api_v1}/marketdata/last-event/books/top/{data_subtype}/batch",
|
|
65
70
|
"available": f"{url_api_v1}/marketdata/last-event/books/{data_subtype}/availables"
|
|
71
|
+
},
|
|
72
|
+
"snapshot-tob": {
|
|
73
|
+
"data": f"{url_api_v1}/marketdata/br/b3/snapshot/book/tob/{data_subtype}/batch",
|
|
74
|
+
"available": f"{url_api_v1}/marketdata/br/b3/snapshot/book/tob/{data_subtype}/available-tickers"
|
|
66
75
|
}
|
|
67
76
|
}
|
|
68
77
|
|
|
@@ -72,6 +81,12 @@ class TickerLastEventPolling:
|
|
|
72
81
|
if data_subtype not in self._available_data_types[data_type]:
|
|
73
82
|
raise Exception(f"Must provide a valid data_subtype. Valid data subtypes are: {self._available_data_types[data_type]}")
|
|
74
83
|
|
|
84
|
+
|
|
85
|
+
if interval_seconds is None:
|
|
86
|
+
self.interval_seconds = self._default_interval_seconds[data_type]
|
|
87
|
+
else:
|
|
88
|
+
self.interval_seconds = interval_seconds
|
|
89
|
+
|
|
75
90
|
self.url = self._available_url[self.data_type]["data"]
|
|
76
91
|
|
|
77
92
|
self._update_data()
|
|
@@ -91,15 +106,16 @@ class TickerLastEventPolling:
|
|
|
91
106
|
|
|
92
107
|
|
|
93
108
|
def _update_data(self):
|
|
94
|
-
url = self.url + (f"?dt={self._last_request_datetime.strftime('%Y-%m-%dT%H:%M:%S.000Z')}" if self._last_request_datetime else "")
|
|
109
|
+
url = self.url + (f"?dt={(self._last_request_datetime - timedelta(seconds=60)).strftime('%Y-%m-%dT%H:%M:%S.000Z')}" if self._last_request_datetime else "")
|
|
95
110
|
|
|
96
111
|
request_datetime = datetime.now(timezone.utc)
|
|
97
112
|
|
|
98
113
|
response = requests.request("GET", url, headers={"authorization": f"Bearer {self.authenticator.token}"})
|
|
99
|
-
|
|
114
|
+
|
|
100
115
|
if response.status_code != 200:
|
|
101
116
|
return
|
|
102
|
-
|
|
117
|
+
|
|
118
|
+
|
|
103
119
|
self._last_request_datetime = request_datetime
|
|
104
120
|
|
|
105
121
|
new_data = { tob["sb"]: tob for tob in response.json() if tob.get("sb")}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: btgsolutions-dataservices-python-client
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.18.0
|
|
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
|
|
7
|
-
License: UNKNOWN
|
|
8
|
-
Platform: UNKNOWN
|
|
9
7
|
Requires-Python: >=3.9,<3.14
|
|
10
8
|
Description-Content-Type: text/markdown
|
|
11
9
|
License-File: LICENSE
|
|
@@ -13,6 +11,7 @@ License-File: LICENSE
|
|
|
13
11
|
# BTG Solutions - Data Services
|
|
14
12
|
|
|
15
13
|
Real time and historical Financial Market Data, News, Corporate Events and more.
|
|
14
|
+
More information at https://dataservices.btgpactualsolutions.com/.
|
|
16
15
|
|
|
17
16
|
## Installation
|
|
18
17
|
|
|
@@ -233,6 +232,7 @@ import btgsolutions_dataservices as btg
|
|
|
233
232
|
last_event = btg.TickerLastEvent(api_key='YOUR_API_KEY')
|
|
234
233
|
last_event.get_tobs(data_type='stocks')
|
|
235
234
|
```
|
|
235
|
+
|
|
236
236
|
#### Ticker Last Trading Status
|
|
237
237
|
|
|
238
238
|
```python
|
|
@@ -240,7 +240,8 @@ import btgsolutions_dataservices as btg
|
|
|
240
240
|
last_event = btg.TickerLastEvent(api_key='YOUR_API_KEY')
|
|
241
241
|
last_event.get_status(tickers=['PETR4','VALE3'])
|
|
242
242
|
```
|
|
243
|
-
|
|
243
|
+
|
|
244
|
+
#### Ticker Last Polling - Top of Books
|
|
244
245
|
|
|
245
246
|
```python
|
|
246
247
|
import btgsolutions_dataservices as btg
|
|
@@ -466,4 +467,3 @@ ref = btg.ReferenceData(api_key='YOUR_API_KEY')
|
|
|
466
467
|
ref.ticker_reference(tickers=['VALE3','PETR4'])
|
|
467
468
|
```
|
|
468
469
|
|
|
469
|
-
|
|
@@ -21,8 +21,8 @@ else:
|
|
|
21
21
|
description = "Python package containing several classes and data for extracting and manipulating market and trading data."
|
|
22
22
|
|
|
23
23
|
setup(
|
|
24
|
-
name='
|
|
25
|
-
version='2.
|
|
24
|
+
name='btgsolutions_dataservices_python_client',
|
|
25
|
+
version='2.18.0',
|
|
26
26
|
description=description,
|
|
27
27
|
long_description=long_description,
|
|
28
28
|
long_description_content_type='text/markdown',
|
|
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
|