btgsolutions-dataservices-python-client 2.2.0__tar.gz → 2.3.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.3.0/PKG-INFO +348 -0
- btgsolutions_dataservices_python_client-2.2.0/btgsolutions_dataservices_python_client.egg-info/PKG-INFO → btgsolutions-dataservices-python-client-2.3.0/README.md +337 -334
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices/websocket/market_data_websocket_client.py +15 -5
- btgsolutions-dataservices-python-client-2.3.0/btgsolutions_dataservices_python_client.egg-info/PKG-INFO +348 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/setup.py +2 -2
- btgsolutions_dataservices_python_client-2.2.0/PKG-INFO +0 -334
- btgsolutions_dataservices_python_client-2.2.0/README.md +0 -319
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/LICENSE +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/MANIFEST.in +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices/__init__.py +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices/config.py +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices/exceptions.py +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices/rest/__init__.py +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices/rest/authenticator.py +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices/rest/bulk_data.py +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices/rest/company_data.py +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices/rest/corporate_events.py +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices/rest/hfn.py +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices/rest/historical_candles.py +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices/rest/intraday_candles.py +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices/rest/intraday_tick_data.py +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices/rest/quotes.py +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices/rest/ticker_last_event.py +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices/websocket/__init__.py +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices/websocket/hfn_websocket_client.py +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices/websocket/websocket_default_functions.py +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices_python_client.egg-info/SOURCES.txt +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices_python_client.egg-info/dependency_links.txt +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices_python_client.egg-info/requires.txt +3 -3
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/btgsolutions_dataservices_python_client.egg-info/top_level.txt +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/pyproject.toml +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/requirements.txt +0 -0
- {btgsolutions_dataservices_python_client-2.2.0 → btgsolutions-dataservices-python-client-2.3.0}/setup.cfg +0 -0
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: btgsolutions-dataservices-python-client
|
|
3
|
+
Version: 2.3.0
|
|
4
|
+
Summary: Python package containing several classes and data for extracting and manipulating market and trading data.
|
|
5
|
+
Home-page: https://github.com/BTG-Pactual-Solutions/btgsolutions-dataservices-python-client
|
|
6
|
+
Author: BTG Solutions Data Services powered by BTG Pactual Solutions
|
|
7
|
+
License: UNKNOWN
|
|
8
|
+
Description: # BTG Solutions - Data Service
|
|
9
|
+
|
|
10
|
+
Python library to get Brazilian Financial Market Data.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip3 install btgsolutions-dataservices-python-client
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Examples
|
|
19
|
+
|
|
20
|
+
### WebSocket Books
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
import btgsolutions_dataservices as btg
|
|
24
|
+
ws = btg.MarketDataWebSocketClient(api_key='YOUR_API_KEY', data_type='books', instruments=['PETR4', 'VALE3'])
|
|
25
|
+
ws.run(on_message=lambda message: print(message))
|
|
26
|
+
|
|
27
|
+
## The following is optional to keep the program running in a .py file:
|
|
28
|
+
# from time import sleep
|
|
29
|
+
# while True:
|
|
30
|
+
# sleep(1)
|
|
31
|
+
|
|
32
|
+
## Another examples
|
|
33
|
+
# ws.available_to_subscribe()
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### WebSocket Trades Delayed
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
import btgsolutions_dataservices as btg
|
|
40
|
+
ws = btg.MarketDataWebSocketClient(api_key='YOUR_API_KEY', data_type='trades', stream_type='delayed', instruments=['PETR4', 'VALE3'])
|
|
41
|
+
ws.run(on_message=lambda message: print(message))
|
|
42
|
+
|
|
43
|
+
## The following is optional to keep the program running in a .py file:
|
|
44
|
+
# from time import sleep
|
|
45
|
+
# while True:
|
|
46
|
+
# sleep(1)
|
|
47
|
+
|
|
48
|
+
## Another examples
|
|
49
|
+
# ws.available_to_subscribe()
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### WebSocket Trades with 1 second throttle
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
import btgsolutions_dataservices as btg
|
|
56
|
+
ws = btg.MarketDataWebSocketClient(api_key='YOUR_API_KEY', data_type='trades', stream_type='throttle', instruments=['PETR4', 'VALE3'])
|
|
57
|
+
ws.run(on_message=lambda message: print(message))
|
|
58
|
+
|
|
59
|
+
## The following is optional to keep the program running in a .py file:
|
|
60
|
+
# from time import sleep
|
|
61
|
+
# while True:
|
|
62
|
+
# sleep(1)
|
|
63
|
+
|
|
64
|
+
## Another examples
|
|
65
|
+
# ws.available_to_subscribe()
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### WebSocket Securities (Derivatives)
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
import btgsolutions_dataservices as btg
|
|
72
|
+
ws = btg.MarketDataWebSocketClient(api_key='YOUR_API_KEY', data_type='securities', data_subtype='derivatives')
|
|
73
|
+
ws.run(on_message=lambda message: print(message))
|
|
74
|
+
|
|
75
|
+
## The following is optional to keep the program running in a .py file:
|
|
76
|
+
# from time import sleep
|
|
77
|
+
# while True:
|
|
78
|
+
# sleep(1)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### WebSocket Candles 1S
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
import btgsolutions_dataservices as btg
|
|
85
|
+
ws = btg.MarketDataWebSocketClient(api_key='YOUR_API_KEY', data_type='candles-1S', stream_type='realtime')
|
|
86
|
+
ws.run(on_message=lambda message: print(message))
|
|
87
|
+
ws.candle_subscribe(list_instruments=['PETR4','VALE3'], candle_type='partial')
|
|
88
|
+
|
|
89
|
+
## The following is optional to keep the program running in a .py file:
|
|
90
|
+
# from time import sleep
|
|
91
|
+
# while True:
|
|
92
|
+
# sleep(1)
|
|
93
|
+
|
|
94
|
+
## Another examples
|
|
95
|
+
# ws.candle_subscribe(list_instruments=['PRIO3'], candle_type='closed')
|
|
96
|
+
# ws.candle_subscribe(list_instruments=['WEGE3'], candle_type='all')
|
|
97
|
+
# ws.candle_unsubscribe(list_instruments=['PRIO3', 'PETR4'], candle_type='all')
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### WebSocket BMV Trades
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
import btgsolutions_dataservices as btg
|
|
104
|
+
ws = btg.MarketDataWebSocketClient(api_key='YOUR_API_KEY', exchange='bmv', data_type='trades')
|
|
105
|
+
ws.run(on_message=lambda message: print(message))
|
|
106
|
+
|
|
107
|
+
## The following is optional to keep the program running in a .py file:
|
|
108
|
+
# from time import sleep
|
|
109
|
+
# while True:
|
|
110
|
+
# sleep(1)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### WebSocket Books (without spawning a new thread for incoming server messages)
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
import btgsolutions_dataservices as btg
|
|
117
|
+
ws = btg.MarketDataWebSocketClient(api_key='YOUR_API_KEY', data_type='books', instruments=['PETR4', 'VALE3'])
|
|
118
|
+
ws.run(on_message=lambda message: print(message), spawn_thread=False)
|
|
119
|
+
|
|
120
|
+
## The following is optional to keep the program running in a .py file:
|
|
121
|
+
# from time import sleep
|
|
122
|
+
# while True:
|
|
123
|
+
# sleep(1)
|
|
124
|
+
|
|
125
|
+
## Another examples
|
|
126
|
+
# ws.available_to_subscribe()
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### WebSocket Books with n = 1 (Book TOB - Top Of Book)
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
import btgsolutions_dataservices as btg
|
|
133
|
+
ws = btg.MarketDataWebSocketClient(api_key='YOUR_API_KEY', data_type='books')
|
|
134
|
+
ws.run(on_message=lambda message: print(message))
|
|
135
|
+
ws.subscribe(['PETR4', 'VALE3'], n=1)
|
|
136
|
+
## The following is optional to keep the program running in a .py file:
|
|
137
|
+
# from time import sleep
|
|
138
|
+
# while True:
|
|
139
|
+
# sleep(1)
|
|
140
|
+
|
|
141
|
+
## Another examples
|
|
142
|
+
# ws.available_to_subscribe()
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
### WebSocket High Frequency News
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
import btgsolutions_dataservices as btg
|
|
151
|
+
ws = btg.HFNWebSocketClient(api_key='YOUR_API_KEY', country='brazil')
|
|
152
|
+
ws.run(on_message=lambda message: print(message))
|
|
153
|
+
|
|
154
|
+
## The following is optional to keep the program running in a .py file:
|
|
155
|
+
# from time import sleep
|
|
156
|
+
# while True:
|
|
157
|
+
# sleep(1)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### IntradayCandles
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
import btgsolutions_dataservices as btg
|
|
164
|
+
int_candles = btg.IntradayCandles(api_key='YOUR_API_KEY')
|
|
165
|
+
int_candles.get_intraday_candles(market_type='stocks', tickers=['PETR4', 'VALE3'], candle_period='1m', delay='delayed', mode='relative', timezone='UTC', raw_data=True)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Get Interday History Candles
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
import btgsolutions_dataservices as btg
|
|
172
|
+
hist_candles = btg.HistoricalCandles(api_key='YOUR_API_KEY')
|
|
173
|
+
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)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Get Intraday History Candles
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
import btgsolutions_dataservices as btg
|
|
180
|
+
hist_candles = btg.HistoricalCandles(api_key='YOUR_API_KEY')
|
|
181
|
+
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)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Plot History Candles
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
import btgsolutions_dataservices as btg
|
|
188
|
+
hist_candles = btg.HistoricalCandles(api_key='YOUR_API_KEY')
|
|
189
|
+
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')
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Quotes
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
import btgsolutions_dataservices as btg
|
|
196
|
+
quotes = btg.Quotes(api_key='YOUR_API_KEY')
|
|
197
|
+
quotes.get_quote(market_type = 'stocks', tickers = ['PETR4', 'VALE3'])
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Ticker Last Event
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
import btgsolutions_dataservices as btg
|
|
204
|
+
last_event = btg.TickerLastEvent(api_key='YOUR_API_KEY')
|
|
205
|
+
last_event.get_trades(data_type='equities', ticker='VALE3')
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### BulkData - Available Tickers
|
|
209
|
+
|
|
210
|
+
```python
|
|
211
|
+
import btgsolutions_dataservices as btg
|
|
212
|
+
bulk_data = btg.BulkData(api_key='YOUR_API_KEY')
|
|
213
|
+
bulk_data.get_available_tickers(date='2023-07-03', data_type='trades', prefix='PETR')
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### BulkData - Get Data
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
import btgsolutions_dataservices as btg
|
|
220
|
+
bulk_data = btg.BulkData(api_key='YOUR_API_KEY')
|
|
221
|
+
bulk_data.get_data(ticker='DI1F18', date='2017-01-02', data_type='trades')
|
|
222
|
+
# bulk_data.get_data(ticker='PETR4', date='2024-01-22', data_type='books')
|
|
223
|
+
# bulk_data.get_data(ticker='VALE3', date='2024-04-01', data_type='trades-and-book-events')
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### BulkData - Get Market Data Channels
|
|
227
|
+
|
|
228
|
+
```python
|
|
229
|
+
import btgsolutions_dataservices as btg
|
|
230
|
+
bulk_data = btg.BulkData(api_key='YOUR_API_KEY')
|
|
231
|
+
bulk_data.get_market_data_channels(date='2024-01-03')
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### BulkData - Get Compressed Data (PCAP files)
|
|
235
|
+
|
|
236
|
+
```python
|
|
237
|
+
import btgsolutions_dataservices as btg
|
|
238
|
+
bulk_data = btg.BulkData(api_key='YOUR_API_KEY')
|
|
239
|
+
bulk_data.get_compressed_data(channel='001', date='2024-01-03', data_type='instruments')
|
|
240
|
+
# bulk_data.get_compressed_data(channel='053', date='2024-01-03', data_type='incremental')
|
|
241
|
+
# bulk_data.get_compressed_data(channel='051', date='2024-01-03', data_type='snapshot')
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Intraday Tick Data
|
|
245
|
+
|
|
246
|
+
```python
|
|
247
|
+
import btgsolutions_dataservices as btg
|
|
248
|
+
intra_tickdata = btg.IntradayTickData(api_key='YOUR_API_KEY')
|
|
249
|
+
intra_tickdata.get_trades(ticker='PETR4')
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### High Frequency News
|
|
253
|
+
|
|
254
|
+
```python
|
|
255
|
+
import btgsolutions_dataservices as btg
|
|
256
|
+
hfn = btg.HighFrequencyNews(api_key='YOUR_API_KEY')
|
|
257
|
+
hfn.latest_news()
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Corporate Events
|
|
261
|
+
|
|
262
|
+
```python
|
|
263
|
+
import btgsolutions_dataservices as btg
|
|
264
|
+
corporate_events = btg.CorporateEvents(api_key='YOUR_API_KEY')
|
|
265
|
+
corporate_events.get(start_date='2024-05-01', end_date='2024-05-31')
|
|
266
|
+
# corporate_events.get(start_date='2024-05-01', end_date='2024-05-31', tickers=['VALE3'])
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Company Data
|
|
270
|
+
#### Company General Information
|
|
271
|
+
|
|
272
|
+
```python
|
|
273
|
+
import btgsolutions_dataservices as btg
|
|
274
|
+
company_data = btg.CompanyData(api_key='YOUR_API_KEY')
|
|
275
|
+
company_data.general_info(ticker='PETR4')
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
#### Income Statement
|
|
279
|
+
|
|
280
|
+
```python
|
|
281
|
+
import btgsolutions_dataservices as btg
|
|
282
|
+
company_data = btg.CompanyData(api_key='YOUR_API_KEY')
|
|
283
|
+
company_data.income_statement(ticker='PETR4')
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
#### Balance Sheet
|
|
287
|
+
|
|
288
|
+
```python
|
|
289
|
+
import btgsolutions_dataservices as btg
|
|
290
|
+
company_data = btg.CompanyData(api_key='YOUR_API_KEY')
|
|
291
|
+
company_data.balance_sheet(ticker='PETR4')
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
#### Cash Flow
|
|
295
|
+
|
|
296
|
+
```python
|
|
297
|
+
import btgsolutions_dataservices as btg
|
|
298
|
+
company_data = btg.CompanyData(api_key='YOUR_API_KEY')
|
|
299
|
+
company_data.cash_flow(ticker='PETR4')
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
#### Valuation
|
|
303
|
+
|
|
304
|
+
```python
|
|
305
|
+
import btgsolutions_dataservices as btg
|
|
306
|
+
company_data = btg.CompanyData(api_key='YOUR_API_KEY')
|
|
307
|
+
company_data.valuation(ticker='PETR4')
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
#### Ratios
|
|
311
|
+
|
|
312
|
+
```python
|
|
313
|
+
import btgsolutions_dataservices as btg
|
|
314
|
+
company_data = btg.CompanyData(api_key='YOUR_API_KEY')
|
|
315
|
+
company_data.ratios(ticker='PETR4')
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
#### Growth
|
|
319
|
+
|
|
320
|
+
```python
|
|
321
|
+
import btgsolutions_dataservices as btg
|
|
322
|
+
company_data = btg.CompanyData(api_key='YOUR_API_KEY')
|
|
323
|
+
company_data.growth(ticker='PETR4')
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
#### Interims
|
|
327
|
+
|
|
328
|
+
```python
|
|
329
|
+
import btgsolutions_dataservices as btg
|
|
330
|
+
company_data = btg.CompanyData(api_key='YOUR_API_KEY')
|
|
331
|
+
company_data.interims(ticker='PETR4')
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
#### All Financial Tables
|
|
335
|
+
|
|
336
|
+
```python
|
|
337
|
+
import btgsolutions_dataservices as btg
|
|
338
|
+
company_data = btg.CompanyData(api_key='YOUR_API_KEY')
|
|
339
|
+
company_data.all_financial_tables(ticker='PETR4')
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## Documentation
|
|
343
|
+
|
|
344
|
+
The official documentation is hosted at https://python-client-docs.dataservices.btgpactualsolutions.com/
|
|
345
|
+
|
|
346
|
+
Platform: UNKNOWN
|
|
347
|
+
Requires-Python: >=3.9,<3.13
|
|
348
|
+
Description-Content-Type: text/markdown
|