btgsolutions-dataservices-python-client 3.2.7__tar.gz → 3.2.8__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-3.2.7/btgsolutions_dataservices_python_client.egg-info → btgsolutions_dataservices_python_client-3.2.8}/PKG-INFO +31 -13
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/README.md +28 -2
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/__init__.py +1 -1
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/rest/historical_candles.py +14 -4
- btgsolutions_dataservices_python_client-3.2.8/btgsolutions_dataservices/rest/historical_candles_crypto.py +177 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8/btgsolutions_dataservices_python_client.egg-info}/PKG-INFO +31 -13
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices_python_client.egg-info/SOURCES.txt +1 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/setup.py +1 -1
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/LICENSE +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/MANIFEST.in +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/config.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/exceptions.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/rest/__init__.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/rest/authenticator.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/rest/broker_reference.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/rest/bulk_data.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/rest/company_data.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/rest/corporate_events.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/rest/hfn.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/rest/intraday_candles.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/rest/intraday_tick_data.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/rest/public_sources.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/rest/quotes.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/rest/reference_data.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/rest/stock_loan.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/rest/ticker_last_event.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/rest/ticker_last_event_polling.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/websocket/__init__.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/websocket/hfn_websocket_client.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/websocket/market_data_feed.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/websocket/market_data_websocket_client.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices/websocket/websocket_default_functions.py +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices_python_client.egg-info/dependency_links.txt +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices_python_client.egg-info/requires.txt +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/btgsolutions_dataservices_python_client.egg-info/top_level.txt +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/pyproject.toml +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/requirements.txt +0 -0
- {btgsolutions_dataservices_python_client-3.2.7 → btgsolutions_dataservices_python_client-3.2.8}/setup.cfg +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: btgsolutions_dataservices_python_client
|
|
3
|
-
Version: 3.2.
|
|
3
|
+
Version: 3.2.8
|
|
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
|
-
Requires-Python: >=3.9,<3.
|
|
7
|
+
Requires-Python: >=3.9,<3.15
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
License-File: LICENSE
|
|
10
10
|
Requires-Dist: pandas>=2.2.2
|
|
@@ -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
|
|
|
@@ -245,7 +237,7 @@ last_event.get()
|
|
|
245
237
|
```python
|
|
246
238
|
import btgsolutions_dataservices as btg
|
|
247
239
|
hist_candles = btg.HistoricalCandles(api_key='YOUR_API_KEY')
|
|
248
|
-
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)
|
|
240
|
+
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, round=False)
|
|
249
241
|
```
|
|
250
242
|
|
|
251
243
|
##### Intraday
|
|
@@ -253,7 +245,7 @@ hist_candles.get_interday_history_candles(ticker='PETR4', market_type='stocks',
|
|
|
253
245
|
```python
|
|
254
246
|
import btgsolutions_dataservices as btg
|
|
255
247
|
hist_candles = btg.HistoricalCandles(api_key='YOUR_API_KEY')
|
|
256
|
-
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)
|
|
248
|
+
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, round=True)
|
|
257
249
|
```
|
|
258
250
|
|
|
259
251
|
##### Available Tickers
|
|
@@ -272,6 +264,32 @@ hist_candles = btg.HistoricalCandles(api_key='YOUR_API_KEY')
|
|
|
272
264
|
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')
|
|
273
265
|
```
|
|
274
266
|
|
|
267
|
+
#### Historical Candles Crypto
|
|
268
|
+
|
|
269
|
+
##### Interday
|
|
270
|
+
|
|
271
|
+
```python
|
|
272
|
+
import btgsolutions_dataservices as btg
|
|
273
|
+
hist_candles_crypto = btg.HistoricalCandlesCrypto(api_key='YOUR_API_KEY')
|
|
274
|
+
hist_candles_crypto.get_interday_history_candles(ticker='BTC', currency='BRL', exchange='consolidated', start_date='2025-06-01', end_date='2025-07-01', timezone='UTC', raw_data=False)
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
##### Intraday
|
|
278
|
+
|
|
279
|
+
```python
|
|
280
|
+
import btgsolutions_dataservices as btg
|
|
281
|
+
hist_candles_crypto = btg.HistoricalCandlesCrypto(api_key='YOUR_API_KEY')
|
|
282
|
+
hist_candles_crypto.get_intraday_history_candles(ticker='BTC', currency='BRL', exchange='consolidated', date='2025-06-01', candle='1h', timezone='America/Sao_Paulo', raw_data=False)
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
##### Available Tickers
|
|
286
|
+
|
|
287
|
+
```python
|
|
288
|
+
import btgsolutions_dataservices as btg
|
|
289
|
+
hist_candles_crypto = btg.HistoricalCandlesCrypto(api_key='YOUR_API_KEY')
|
|
290
|
+
hist_candles_crypto.get_available_tickers(exchange='coinbase', date='2023-01-13')
|
|
291
|
+
```
|
|
292
|
+
|
|
275
293
|
#### Historical Tick Data (Bulk Data)
|
|
276
294
|
|
|
277
295
|
##### Available Tickers
|
|
@@ -222,7 +222,7 @@ last_event.get()
|
|
|
222
222
|
```python
|
|
223
223
|
import btgsolutions_dataservices as btg
|
|
224
224
|
hist_candles = btg.HistoricalCandles(api_key='YOUR_API_KEY')
|
|
225
|
-
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)
|
|
225
|
+
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, round=False)
|
|
226
226
|
```
|
|
227
227
|
|
|
228
228
|
##### Intraday
|
|
@@ -230,7 +230,7 @@ hist_candles.get_interday_history_candles(ticker='PETR4', market_type='stocks',
|
|
|
230
230
|
```python
|
|
231
231
|
import btgsolutions_dataservices as btg
|
|
232
232
|
hist_candles = btg.HistoricalCandles(api_key='YOUR_API_KEY')
|
|
233
|
-
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)
|
|
233
|
+
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, round=True)
|
|
234
234
|
```
|
|
235
235
|
|
|
236
236
|
##### Available Tickers
|
|
@@ -249,6 +249,32 @@ hist_candles = btg.HistoricalCandles(api_key='YOUR_API_KEY')
|
|
|
249
249
|
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')
|
|
250
250
|
```
|
|
251
251
|
|
|
252
|
+
#### Historical Candles Crypto
|
|
253
|
+
|
|
254
|
+
##### Interday
|
|
255
|
+
|
|
256
|
+
```python
|
|
257
|
+
import btgsolutions_dataservices as btg
|
|
258
|
+
hist_candles_crypto = btg.HistoricalCandlesCrypto(api_key='YOUR_API_KEY')
|
|
259
|
+
hist_candles_crypto.get_interday_history_candles(ticker='BTC', currency='BRL', exchange='consolidated', start_date='2025-06-01', end_date='2025-07-01', timezone='UTC', raw_data=False)
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
##### Intraday
|
|
263
|
+
|
|
264
|
+
```python
|
|
265
|
+
import btgsolutions_dataservices as btg
|
|
266
|
+
hist_candles_crypto = btg.HistoricalCandlesCrypto(api_key='YOUR_API_KEY')
|
|
267
|
+
hist_candles_crypto.get_intraday_history_candles(ticker='BTC', currency='BRL', exchange='consolidated', date='2025-06-01', candle='1h', timezone='America/Sao_Paulo', raw_data=False)
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
##### Available Tickers
|
|
271
|
+
|
|
272
|
+
```python
|
|
273
|
+
import btgsolutions_dataservices as btg
|
|
274
|
+
hist_candles_crypto = btg.HistoricalCandlesCrypto(api_key='YOUR_API_KEY')
|
|
275
|
+
hist_candles_crypto.get_available_tickers(exchange='coinbase', date='2023-01-13')
|
|
276
|
+
```
|
|
277
|
+
|
|
252
278
|
#### Historical Tick Data (Bulk Data)
|
|
253
279
|
|
|
254
280
|
##### Available Tickers
|
|
@@ -24,6 +24,7 @@ class HistoricalCandles:
|
|
|
24
24
|
>>> end_date = '2023-10-20',
|
|
25
25
|
>>> rmv_after_market = True,
|
|
26
26
|
>>> timezone = 'UTC',
|
|
27
|
+
>>> round = True,
|
|
27
28
|
>>> raw_data = False
|
|
28
29
|
>>> )
|
|
29
30
|
|
|
@@ -37,6 +38,7 @@ class HistoricalCandles:
|
|
|
37
38
|
>>> rmv_after_market = True,
|
|
38
39
|
>>> timezone = 'UTC',
|
|
39
40
|
>>> candle='1m',
|
|
41
|
+
>>> round = True,
|
|
40
42
|
>>> raw_data = False
|
|
41
43
|
>>> )
|
|
42
44
|
|
|
@@ -63,7 +65,8 @@ class HistoricalCandles:
|
|
|
63
65
|
corporate_events_adj:bool,
|
|
64
66
|
rmv_after_market:bool,
|
|
65
67
|
timezone:str,
|
|
66
|
-
raw_data:bool=False
|
|
68
|
+
raw_data:bool=False,
|
|
69
|
+
round:bool=True
|
|
67
70
|
):
|
|
68
71
|
"""
|
|
69
72
|
This method provides historical candles for a given ticket in determined period.
|
|
@@ -93,12 +96,15 @@ class HistoricalCandles:
|
|
|
93
96
|
raw_data: bool
|
|
94
97
|
If false, returns data in a dataframe. If true, returns raw data.
|
|
95
98
|
Field is not required. Default: False.
|
|
99
|
+
round: bool
|
|
100
|
+
Apply rounding to prices.
|
|
101
|
+
Field is not required. Default: True.
|
|
96
102
|
"""
|
|
97
103
|
|
|
98
104
|
if market_type not in ['stocks', 'derivatives']:
|
|
99
105
|
raise MarketTypeError(f'Allowed values: "stocks" or "derivatives". Input value: "{market_type}".')
|
|
100
106
|
|
|
101
|
-
url = f"{url_apis_v3}/marketdata/history/candles/intraday/{market_type}?ticker={ticker}&corporate_events_adj={corporate_events_adj}&rmv_after_market={rmv_after_market}&timezone={timezone}&date={date}&candle={candle}"
|
|
107
|
+
url = f"{url_apis_v3}/marketdata/history/candles/intraday/{market_type}?ticker={ticker}&corporate_events_adj={corporate_events_adj}&rmv_after_market={rmv_after_market}&timezone={timezone}&date={date}&candle={candle}&round={round}"
|
|
102
108
|
response = requests.request("GET", url, headers=self.headers)
|
|
103
109
|
if response.status_code == 200:
|
|
104
110
|
response_data = json.loads(response.text)
|
|
@@ -116,7 +122,8 @@ class HistoricalCandles:
|
|
|
116
122
|
corporate_events_adj:bool,
|
|
117
123
|
rmv_after_market:bool,
|
|
118
124
|
timezone:str,
|
|
119
|
-
raw_data:bool=False
|
|
125
|
+
raw_data:bool=False,
|
|
126
|
+
round:bool=True
|
|
120
127
|
):
|
|
121
128
|
"""
|
|
122
129
|
This method provides historical candles for a given ticket in determined period.
|
|
@@ -146,12 +153,15 @@ class HistoricalCandles:
|
|
|
146
153
|
raw_data: bool
|
|
147
154
|
If false, returns data in a dataframe. If true, returns raw data.
|
|
148
155
|
Field is not required. Default: False.
|
|
156
|
+
round: bool
|
|
157
|
+
Apply rounding to prices.
|
|
158
|
+
Field is not required. Default: True.
|
|
149
159
|
"""
|
|
150
160
|
|
|
151
161
|
if market_type not in ['stocks', 'derivatives']:
|
|
152
162
|
raise MarketTypeError(f'Allowed values: "stocks" or "derivatives". Input value: "{market_type}".')
|
|
153
163
|
|
|
154
|
-
url = f"{url_apis_v3}/marketdata/history/candles/interday/{market_type}?ticker={ticker}&corporate_events_adj={corporate_events_adj}&rmv_after_market={rmv_after_market}&timezone={timezone}&start_date={start_date}&end_date={end_date}"
|
|
164
|
+
url = f"{url_apis_v3}/marketdata/history/candles/interday/{market_type}?ticker={ticker}&corporate_events_adj={corporate_events_adj}&rmv_after_market={rmv_after_market}&timezone={timezone}&start_date={start_date}&end_date={end_date}&round={round}"
|
|
155
165
|
response = requests.request("GET", url, headers=self.headers)
|
|
156
166
|
if response.status_code == 200:
|
|
157
167
|
response_data = json.loads(response.text)
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
from ..exceptions import BadResponse, MarketTypeError
|
|
3
|
+
import requests
|
|
4
|
+
from ..config import url_apis_v3
|
|
5
|
+
from .authenticator import Authenticator
|
|
6
|
+
import json
|
|
7
|
+
import pandas as pd
|
|
8
|
+
|
|
9
|
+
class HistoricalCandlesCrypto:
|
|
10
|
+
"""
|
|
11
|
+
This class provides historical candles for cryptocurrencies.
|
|
12
|
+
|
|
13
|
+
Available tickers: ETH, SOL, BTC
|
|
14
|
+
Available exchanges: coinbase, mercado_bitcoin, consolidated
|
|
15
|
+
Available currencies: BRL, USD
|
|
16
|
+
Available candles: '1s', '30s', '1m', '5m', '15m', '30m', '1h'
|
|
17
|
+
|
|
18
|
+
* Main use case - Interday:
|
|
19
|
+
|
|
20
|
+
>>> from btgsolutions_dataservices import HistoricalCandlesCrypto
|
|
21
|
+
>>> hist_candles = HistoricalCandlesCrypto(
|
|
22
|
+
>>> api_key='YOUR_API_KEY',
|
|
23
|
+
>>> )
|
|
24
|
+
>>> hist_candles.get_interday_history_candles(
|
|
25
|
+
>>> ticker = 'BTC',
|
|
26
|
+
>>> currency = 'BRL',
|
|
27
|
+
>>> exchange = 'consolidated',
|
|
28
|
+
>>> start_date = '2025-06-01',
|
|
29
|
+
>>> end_date = '2025-07-01',
|
|
30
|
+
>>> timezone = 'UTC',
|
|
31
|
+
>>> raw_data = False
|
|
32
|
+
>>> )
|
|
33
|
+
|
|
34
|
+
* Main use case - Intraday:
|
|
35
|
+
|
|
36
|
+
>>> hist_candles.get_intraday_history_candles(
|
|
37
|
+
>>> ticker = 'BTC',
|
|
38
|
+
>>> currency = 'BRL',
|
|
39
|
+
>>> exchange = 'consolidated',
|
|
40
|
+
>>> date = '2025-06-01',
|
|
41
|
+
>>> timezone = 'America/Sao_Paulo',
|
|
42
|
+
>>> candle='1h',
|
|
43
|
+
>>> raw_data = False
|
|
44
|
+
>>> )
|
|
45
|
+
|
|
46
|
+
Parameters
|
|
47
|
+
----------------
|
|
48
|
+
api_key: str
|
|
49
|
+
User identification key.
|
|
50
|
+
Field is required.
|
|
51
|
+
"""
|
|
52
|
+
def __init__(
|
|
53
|
+
self,
|
|
54
|
+
api_key:Optional[str]
|
|
55
|
+
):
|
|
56
|
+
self.api_key = api_key
|
|
57
|
+
self.token = Authenticator(self.api_key).token
|
|
58
|
+
self.headers = {"authorization": f"authorization {self.token}"}
|
|
59
|
+
|
|
60
|
+
def get_intraday_history_candles(
|
|
61
|
+
self,
|
|
62
|
+
ticker:str,
|
|
63
|
+
currency:str,
|
|
64
|
+
exchange:str,
|
|
65
|
+
date:str,
|
|
66
|
+
candle:str,
|
|
67
|
+
timezone:str,
|
|
68
|
+
raw_data:bool=False
|
|
69
|
+
):
|
|
70
|
+
"""
|
|
71
|
+
This method provides historical intraday candles for cryptocurrencies.
|
|
72
|
+
|
|
73
|
+
Parameters
|
|
74
|
+
----------------
|
|
75
|
+
ticker: str
|
|
76
|
+
Cryptocurrency ticker.
|
|
77
|
+
Field is required. Allowed values: 'BTC', 'ETH', 'SOL'.
|
|
78
|
+
currency: str
|
|
79
|
+
Currency for the prices.
|
|
80
|
+
Field is required. Allowed values: 'BRL' or 'USD'.
|
|
81
|
+
exchange: str
|
|
82
|
+
Exchange name.
|
|
83
|
+
Field is required. Allowed values: 'coinbase', 'mercado_bitcoin', 'consolidated'.
|
|
84
|
+
date: string<date>
|
|
85
|
+
Date of requested data. Format: "YYYY-MM-DD".
|
|
86
|
+
Field is required. Example: '2025-06-01'.
|
|
87
|
+
candle: str
|
|
88
|
+
Candle period.
|
|
89
|
+
Field is required. Allowed values: '1s', '30s', '1m', '5m', '15m', '30m', '1h'.
|
|
90
|
+
timezone: str
|
|
91
|
+
Timezone of the datetime.
|
|
92
|
+
Field is required. Allowed values: 'America/Sao_Paulo' or 'UTC'.
|
|
93
|
+
raw_data: bool
|
|
94
|
+
If false, returns data in a dataframe. If true, returns raw data.
|
|
95
|
+
Field is not required. Default: False.
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
url = f"{url_apis_v3}/marketdata/history/candles/intraday/crypto?ticker={ticker}¤cy={currency}&exchange={exchange}&date={date}&candle={candle}&timezone={timezone}"
|
|
99
|
+
response = requests.request("GET", url, headers=self.headers)
|
|
100
|
+
if response.status_code == 200:
|
|
101
|
+
response_data = json.loads(response.text)
|
|
102
|
+
return response_data if raw_data else pd.DataFrame(response_data)
|
|
103
|
+
|
|
104
|
+
response = json.loads(response.text)
|
|
105
|
+
raise BadResponse(f'Error: {response.get("ApiClientError", "")}.\n{response.get("SuggestedAction", "")}')
|
|
106
|
+
|
|
107
|
+
def get_interday_history_candles(
|
|
108
|
+
self,
|
|
109
|
+
ticker:str,
|
|
110
|
+
currency:str,
|
|
111
|
+
exchange:str,
|
|
112
|
+
start_date:str,
|
|
113
|
+
end_date:str,
|
|
114
|
+
timezone:str,
|
|
115
|
+
raw_data:bool=False
|
|
116
|
+
):
|
|
117
|
+
"""
|
|
118
|
+
This method provides historical daily candles for cryptocurrencies.
|
|
119
|
+
|
|
120
|
+
Parameters
|
|
121
|
+
----------------
|
|
122
|
+
ticker: str
|
|
123
|
+
Cryptocurrency ticker.
|
|
124
|
+
Field is required. Allowed values: 'BTC', 'ETH', 'SOL'.
|
|
125
|
+
currency: str
|
|
126
|
+
Currency for the prices.
|
|
127
|
+
Field is required. Allowed values: 'BRL' or 'USD'.
|
|
128
|
+
exchange: str
|
|
129
|
+
Exchange name.
|
|
130
|
+
Field is required. Allowed values: 'coinbase', 'mercado_bitcoin', 'consolidated'.
|
|
131
|
+
start_date: string<date>
|
|
132
|
+
Start date of analysis. Format: "YYYY-MM-DD".
|
|
133
|
+
Field is required. Example: '2025-06-01'.
|
|
134
|
+
end_date: string<date>
|
|
135
|
+
End date of analysis. Format: "YYYY-MM-DD".
|
|
136
|
+
Field is required. Example: '2025-07-01'.
|
|
137
|
+
timezone: str
|
|
138
|
+
Timezone of the datetime.
|
|
139
|
+
Field is required. Allowed values: 'America/Sao_Paulo' or 'UTC'.
|
|
140
|
+
raw_data: bool
|
|
141
|
+
If false, returns data in a dataframe. If true, returns raw data.
|
|
142
|
+
Field is not required. Default: False.
|
|
143
|
+
"""
|
|
144
|
+
|
|
145
|
+
url = f"{url_apis_v3}/marketdata/history/candles/interday/crypto?ticker={ticker}¤cy={currency}&exchange={exchange}&start_date={start_date}&end_date={end_date}&timezone={timezone}"
|
|
146
|
+
response = requests.request("GET", url, headers=self.headers)
|
|
147
|
+
if response.status_code == 200:
|
|
148
|
+
response_data = json.loads(response.text)
|
|
149
|
+
return response_data if raw_data else pd.DataFrame(response_data)
|
|
150
|
+
|
|
151
|
+
response = json.loads(response.text)
|
|
152
|
+
raise BadResponse(f'Error: {response.get("ApiClientError", "")}.\n{response.get("SuggestedAction", "")}')
|
|
153
|
+
|
|
154
|
+
def get_available_tickers(
|
|
155
|
+
self,
|
|
156
|
+
exchange:str,
|
|
157
|
+
date:str,
|
|
158
|
+
):
|
|
159
|
+
"""
|
|
160
|
+
This method provides all cryptocurrency tickers available for query.
|
|
161
|
+
|
|
162
|
+
Parameters
|
|
163
|
+
----------------
|
|
164
|
+
exchange: str
|
|
165
|
+
Exchange name.
|
|
166
|
+
Field is required. Allowed values: 'coinbase', 'mercado_bitcoin', 'consolidated'.
|
|
167
|
+
date: string<date>
|
|
168
|
+
Date of requested data. Format: "YYYY-MM-DD".
|
|
169
|
+
Field is required. Example: '2023-01-13'.
|
|
170
|
+
"""
|
|
171
|
+
|
|
172
|
+
url = f"{url_apis_v3}/marketdata/history/candles/available-tickers/crypto?date={date}&exchange={exchange}"
|
|
173
|
+
|
|
174
|
+
response = requests.request("GET", url, headers=self.headers)
|
|
175
|
+
if response.status_code == 200: return response.json()
|
|
176
|
+
response = response.json()
|
|
177
|
+
raise BadResponse(f'Error: {response.get("ApiClientError", "") or response.get("ApiServerMessage", "")}.\n{response.get("SuggestedAction", "")}')
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: btgsolutions_dataservices_python_client
|
|
3
|
-
Version: 3.2.
|
|
3
|
+
Version: 3.2.8
|
|
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
|
-
Requires-Python: >=3.9,<3.
|
|
7
|
+
Requires-Python: >=3.9,<3.15
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
License-File: LICENSE
|
|
10
10
|
Requires-Dist: pandas>=2.2.2
|
|
@@ -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
|
|
|
@@ -245,7 +237,7 @@ last_event.get()
|
|
|
245
237
|
```python
|
|
246
238
|
import btgsolutions_dataservices as btg
|
|
247
239
|
hist_candles = btg.HistoricalCandles(api_key='YOUR_API_KEY')
|
|
248
|
-
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)
|
|
240
|
+
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, round=False)
|
|
249
241
|
```
|
|
250
242
|
|
|
251
243
|
##### Intraday
|
|
@@ -253,7 +245,7 @@ hist_candles.get_interday_history_candles(ticker='PETR4', market_type='stocks',
|
|
|
253
245
|
```python
|
|
254
246
|
import btgsolutions_dataservices as btg
|
|
255
247
|
hist_candles = btg.HistoricalCandles(api_key='YOUR_API_KEY')
|
|
256
|
-
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)
|
|
248
|
+
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, round=True)
|
|
257
249
|
```
|
|
258
250
|
|
|
259
251
|
##### Available Tickers
|
|
@@ -272,6 +264,32 @@ hist_candles = btg.HistoricalCandles(api_key='YOUR_API_KEY')
|
|
|
272
264
|
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')
|
|
273
265
|
```
|
|
274
266
|
|
|
267
|
+
#### Historical Candles Crypto
|
|
268
|
+
|
|
269
|
+
##### Interday
|
|
270
|
+
|
|
271
|
+
```python
|
|
272
|
+
import btgsolutions_dataservices as btg
|
|
273
|
+
hist_candles_crypto = btg.HistoricalCandlesCrypto(api_key='YOUR_API_KEY')
|
|
274
|
+
hist_candles_crypto.get_interday_history_candles(ticker='BTC', currency='BRL', exchange='consolidated', start_date='2025-06-01', end_date='2025-07-01', timezone='UTC', raw_data=False)
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
##### Intraday
|
|
278
|
+
|
|
279
|
+
```python
|
|
280
|
+
import btgsolutions_dataservices as btg
|
|
281
|
+
hist_candles_crypto = btg.HistoricalCandlesCrypto(api_key='YOUR_API_KEY')
|
|
282
|
+
hist_candles_crypto.get_intraday_history_candles(ticker='BTC', currency='BRL', exchange='consolidated', date='2025-06-01', candle='1h', timezone='America/Sao_Paulo', raw_data=False)
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
##### Available Tickers
|
|
286
|
+
|
|
287
|
+
```python
|
|
288
|
+
import btgsolutions_dataservices as btg
|
|
289
|
+
hist_candles_crypto = btg.HistoricalCandlesCrypto(api_key='YOUR_API_KEY')
|
|
290
|
+
hist_candles_crypto.get_available_tickers(exchange='coinbase', date='2023-01-13')
|
|
291
|
+
```
|
|
292
|
+
|
|
275
293
|
#### Historical Tick Data (Bulk Data)
|
|
276
294
|
|
|
277
295
|
##### Available Tickers
|
|
@@ -15,6 +15,7 @@ btgsolutions_dataservices/rest/company_data.py
|
|
|
15
15
|
btgsolutions_dataservices/rest/corporate_events.py
|
|
16
16
|
btgsolutions_dataservices/rest/hfn.py
|
|
17
17
|
btgsolutions_dataservices/rest/historical_candles.py
|
|
18
|
+
btgsolutions_dataservices/rest/historical_candles_crypto.py
|
|
18
19
|
btgsolutions_dataservices/rest/intraday_candles.py
|
|
19
20
|
btgsolutions_dataservices/rest/intraday_tick_data.py
|
|
20
21
|
btgsolutions_dataservices/rest/public_sources.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
|