btgsolutions-dataservices-python-client 2.15.0__tar.gz → 2.16.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.15.0/btgsolutions_dataservices_python_client.egg-info → btgsolutions_dataservices_python_client-2.16.0}/PKG-INFO +26 -3
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/README.md +10 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/rest/__init__.py +2 -1
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/rest/intraday_candles.py +10 -1
- btgsolutions_dataservices_python_client-2.16.0/btgsolutions_dataservices/rest/stock_loan.py +110 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0/btgsolutions_dataservices_python_client.egg-info}/PKG-INFO +26 -3
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices_python_client.egg-info/SOURCES.txt +1 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/setup.py +2 -2
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/LICENSE +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/MANIFEST.in +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/__init__.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/config.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/exceptions.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/rest/authenticator.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/rest/bulk_data.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/rest/company_data.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/rest/corporate_events.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/rest/hfn.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/rest/historical_candles.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/rest/intraday_tick_data.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/rest/public_sources.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/rest/quotes.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/rest/reference_data.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/rest/ticker_last_event.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/websocket/__init__.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/websocket/hfn_websocket_client.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/websocket/market_data_feed.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/websocket/market_data_websocket_client.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices/websocket/websocket_default_functions.py +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices_python_client.egg-info/dependency_links.txt +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices_python_client.egg-info/requires.txt +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/btgsolutions_dataservices_python_client.egg-info/top_level.txt +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/pyproject.toml +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/requirements.txt +0 -0
- {btgsolutions-dataservices-python-client-2.15.0 → btgsolutions_dataservices_python_client-2.16.0}/setup.cfg +0 -0
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: btgsolutions-dataservices-python-client
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.16.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
|
-
Requires-Python: >=3.9,<3.
|
|
7
|
+
Requires-Python: >=3.9,<3.14
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
License-File: LICENSE
|
|
10
|
+
Requires-Dist: pandas>=2.2.2
|
|
11
|
+
Requires-Dist: websocket-client>=1.8.0
|
|
12
|
+
Requires-Dist: PyJWT>=2.8.0
|
|
13
|
+
Requires-Dist: requests>=2.32.3
|
|
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
|
|
10
23
|
|
|
11
24
|
# BTG Solutions - Data Services
|
|
12
25
|
|
|
@@ -354,6 +367,16 @@ public_sources = btg.PublicSources(api_key='YOUR_API_KEY')
|
|
|
354
367
|
public_sources.get_opas(start_date='2022-10-01', end_date='2024-10-01')
|
|
355
368
|
```
|
|
356
369
|
|
|
370
|
+
#### STOCK LOAN
|
|
371
|
+
|
|
372
|
+
```python
|
|
373
|
+
import btgsolutions_dataservices as btg
|
|
374
|
+
stock_loan = btg.StockLoan(api_key='YOUR_API_KEY')
|
|
375
|
+
stock_loan.get_trades()
|
|
376
|
+
stock_loan.get_paginated_trades(page=1, limit=1000, ticker ='PETR4')
|
|
377
|
+
stock_loan.get_available_tickers()
|
|
378
|
+
```
|
|
379
|
+
|
|
357
380
|
#### Company Fundamentals
|
|
358
381
|
|
|
359
382
|
##### Company General Information
|
|
@@ -344,6 +344,16 @@ public_sources = btg.PublicSources(api_key='YOUR_API_KEY')
|
|
|
344
344
|
public_sources.get_opas(start_date='2022-10-01', end_date='2024-10-01')
|
|
345
345
|
```
|
|
346
346
|
|
|
347
|
+
#### STOCK LOAN
|
|
348
|
+
|
|
349
|
+
```python
|
|
350
|
+
import btgsolutions_dataservices as btg
|
|
351
|
+
stock_loan = btg.StockLoan(api_key='YOUR_API_KEY')
|
|
352
|
+
stock_loan.get_trades()
|
|
353
|
+
stock_loan.get_paginated_trades(page=1, limit=1000, ticker ='PETR4')
|
|
354
|
+
stock_loan.get_available_tickers()
|
|
355
|
+
```
|
|
356
|
+
|
|
347
357
|
#### Company Fundamentals
|
|
348
358
|
|
|
349
359
|
##### Company General Information
|
|
@@ -9,4 +9,5 @@ from .ticker_last_event import TickerLastEvent
|
|
|
9
9
|
from .corporate_events import CorporateEvents
|
|
10
10
|
from .company_data import CompanyData
|
|
11
11
|
from .public_sources import PublicSources
|
|
12
|
-
from .reference_data import ReferenceData
|
|
12
|
+
from .reference_data import ReferenceData
|
|
13
|
+
from .stock_loan import StockLoan
|
|
@@ -58,7 +58,8 @@ class IntradayCandles:
|
|
|
58
58
|
start:int=0,
|
|
59
59
|
end:int=0,
|
|
60
60
|
mode:str='absolute',
|
|
61
|
-
raw_data:bool=False
|
|
61
|
+
raw_data:bool=False,
|
|
62
|
+
cross_filter:str='',
|
|
62
63
|
):
|
|
63
64
|
"""
|
|
64
65
|
This method provides realtime intraday candles for a given ticker.
|
|
@@ -93,6 +94,10 @@ class IntradayCandles:
|
|
|
93
94
|
Candle mode.
|
|
94
95
|
Example: 'absolute', 'relative' or 'spark'.
|
|
95
96
|
Default: absolute.
|
|
97
|
+
cross_filter: str
|
|
98
|
+
Filter trades by cross status. Available only when market_type is derivatives.
|
|
99
|
+
Options: 'all', 'only_cross' or 'without_cross'.
|
|
100
|
+
Default: 'all'.
|
|
96
101
|
raw_data: bool
|
|
97
102
|
If false, returns data in a dict of dataframes. If true, returns raw data.
|
|
98
103
|
Default: False.
|
|
@@ -101,6 +106,8 @@ class IntradayCandles:
|
|
|
101
106
|
if market_type not in ['stocks', 'derivatives', 'options', 'indices']: raise MarketTypeError(f"Must provide a valid 'market_type' parameter. Input: '{market_type}'. Accepted values: 'stocks', 'derivatives', 'options' or 'indices'.")
|
|
102
107
|
|
|
103
108
|
if delay not in ['delayed', 'realtime']: raise DelayError(f"Must provide a valid 'delay' parameter. Input: '{delay}'. Accepted values: 'delayed' or 'realtime'.")
|
|
109
|
+
|
|
110
|
+
if cross_filter and market_type != 'derivatives': raise DelayError(f"The 'cross_filter' flag is only valid for market_type 'derivatives'.")
|
|
104
111
|
|
|
105
112
|
tickers = ','.join(tickers) if type(tickers) is list else tickers
|
|
106
113
|
|
|
@@ -109,6 +116,8 @@ class IntradayCandles:
|
|
|
109
116
|
if start: url += f'&start={start}'
|
|
110
117
|
|
|
111
118
|
if end: url += f'&end={end}'
|
|
119
|
+
|
|
120
|
+
if cross_filter: url += f'&cross_filter={cross_filter}'
|
|
112
121
|
|
|
113
122
|
response = requests.request("GET", url, headers=self.headers)
|
|
114
123
|
if response.status_code == 200:
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
|
|
2
|
+
from typing import Optional
|
|
3
|
+
from ..exceptions import BadResponse
|
|
4
|
+
import requests
|
|
5
|
+
from ..config import url_api_v1
|
|
6
|
+
import json
|
|
7
|
+
from .authenticator import Authenticator
|
|
8
|
+
import pandas as pd
|
|
9
|
+
|
|
10
|
+
class StockLoan:
|
|
11
|
+
"""
|
|
12
|
+
This class provides trades related to stock loan operations.
|
|
13
|
+
|
|
14
|
+
* Main use case:
|
|
15
|
+
|
|
16
|
+
>>> from btgsolutions_dataservices import StockLoan
|
|
17
|
+
>>> stock_loan = StockLoan(
|
|
18
|
+
>>> api_key='YOUR_API_KEY',
|
|
19
|
+
>>> )
|
|
20
|
+
>>> trades = stock_loan.get_trades(
|
|
21
|
+
>>> ticker = 'PETR4'
|
|
22
|
+
>>> )
|
|
23
|
+
>>> trades = stock_loan.get_paginated_trades(
|
|
24
|
+
>>> page = 1,
|
|
25
|
+
>>> limit = 1000
|
|
26
|
+
>>> )
|
|
27
|
+
>>> stock_loan.get_available_tickers()
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------------
|
|
31
|
+
api_key: str
|
|
32
|
+
User identification key.
|
|
33
|
+
Field is required.
|
|
34
|
+
"""
|
|
35
|
+
def __init__(
|
|
36
|
+
self,
|
|
37
|
+
api_key: Optional[str]
|
|
38
|
+
):
|
|
39
|
+
self.api_key = api_key
|
|
40
|
+
self.token = Authenticator(self.api_key).token
|
|
41
|
+
self.headers = {"authorization": f"authorization {self.token}"}
|
|
42
|
+
|
|
43
|
+
def get_trades(
|
|
44
|
+
self,
|
|
45
|
+
ticker:Optional[str]='',
|
|
46
|
+
):
|
|
47
|
+
"""
|
|
48
|
+
Returns trades related to stock loan operations.
|
|
49
|
+
|
|
50
|
+
Parameters
|
|
51
|
+
----------------
|
|
52
|
+
ticker : str, optional
|
|
53
|
+
The ticker symbol to be returned.
|
|
54
|
+
Example: 'PETR4'
|
|
55
|
+
|
|
56
|
+
"""
|
|
57
|
+
page = 1
|
|
58
|
+
df = pd.DataFrame()
|
|
59
|
+
while True:
|
|
60
|
+
url = f"{url_api_v1}/marketdata/stock-loan/daily-trades?page={page}&limit=20000"
|
|
61
|
+
if ticker: url += f'&ticker={ticker}'
|
|
62
|
+
response = requests.request("GET", url, headers=self.headers)
|
|
63
|
+
if response.status_code != 200: raise BadResponse(response.json())
|
|
64
|
+
response = response.json()
|
|
65
|
+
df = pd.concat([df, pd.DataFrame(response['data'])])
|
|
66
|
+
if response['totalPages'] <= page: break
|
|
67
|
+
page += 1
|
|
68
|
+
|
|
69
|
+
return df.reset_index(drop=True)
|
|
70
|
+
|
|
71
|
+
def get_paginated_trades(
|
|
72
|
+
self,
|
|
73
|
+
page:int,
|
|
74
|
+
limit:int,
|
|
75
|
+
ticker:Optional[str]='',
|
|
76
|
+
):
|
|
77
|
+
"""
|
|
78
|
+
Returns paginated trades related to stock loan operations.
|
|
79
|
+
|
|
80
|
+
Parameters
|
|
81
|
+
----------------
|
|
82
|
+
ticker : str, optional
|
|
83
|
+
The ticker symbol to be returned.
|
|
84
|
+
Example: 'PETR4'
|
|
85
|
+
|
|
86
|
+
page : int
|
|
87
|
+
Page number for paginated results.
|
|
88
|
+
Example: 1
|
|
89
|
+
|
|
90
|
+
limit : int
|
|
91
|
+
Maximum number of items to return per page.
|
|
92
|
+
Example: 1000
|
|
93
|
+
|
|
94
|
+
"""
|
|
95
|
+
url = f"{url_api_v1}/marketdata/stock-loan/daily-trades?page={page}&limit={limit}"
|
|
96
|
+
if ticker: url += f'&ticker={ticker}'
|
|
97
|
+
response = requests.request("GET", url, headers=self.headers)
|
|
98
|
+
if response.status_code == 200: return json.loads(response.text)
|
|
99
|
+
raise BadResponse(response.json())
|
|
100
|
+
|
|
101
|
+
def get_available_tickers(
|
|
102
|
+
self,
|
|
103
|
+
):
|
|
104
|
+
"""
|
|
105
|
+
This method provides all tickers available for query.
|
|
106
|
+
"""
|
|
107
|
+
url = f"{url_api_v1}/marketdata/stock-loan/available-tickers"
|
|
108
|
+
response = requests.request("GET", url, headers=self.headers)
|
|
109
|
+
if response.status_code == 200: return json.loads(response.text)
|
|
110
|
+
raise BadResponse(response.json())
|
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: btgsolutions-dataservices-python-client
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.16.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
|
-
Requires-Python: >=3.9,<3.
|
|
7
|
+
Requires-Python: >=3.9,<3.14
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
License-File: LICENSE
|
|
10
|
+
Requires-Dist: pandas>=2.2.2
|
|
11
|
+
Requires-Dist: websocket-client>=1.8.0
|
|
12
|
+
Requires-Dist: PyJWT>=2.8.0
|
|
13
|
+
Requires-Dist: requests>=2.32.3
|
|
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
|
|
10
23
|
|
|
11
24
|
# BTG Solutions - Data Services
|
|
12
25
|
|
|
@@ -354,6 +367,16 @@ public_sources = btg.PublicSources(api_key='YOUR_API_KEY')
|
|
|
354
367
|
public_sources.get_opas(start_date='2022-10-01', end_date='2024-10-01')
|
|
355
368
|
```
|
|
356
369
|
|
|
370
|
+
#### STOCK LOAN
|
|
371
|
+
|
|
372
|
+
```python
|
|
373
|
+
import btgsolutions_dataservices as btg
|
|
374
|
+
stock_loan = btg.StockLoan(api_key='YOUR_API_KEY')
|
|
375
|
+
stock_loan.get_trades()
|
|
376
|
+
stock_loan.get_paginated_trades(page=1, limit=1000, ticker ='PETR4')
|
|
377
|
+
stock_loan.get_available_tickers()
|
|
378
|
+
```
|
|
379
|
+
|
|
357
380
|
#### Company Fundamentals
|
|
358
381
|
|
|
359
382
|
##### Company General Information
|
|
@@ -19,6 +19,7 @@ btgsolutions_dataservices/rest/intraday_tick_data.py
|
|
|
19
19
|
btgsolutions_dataservices/rest/public_sources.py
|
|
20
20
|
btgsolutions_dataservices/rest/quotes.py
|
|
21
21
|
btgsolutions_dataservices/rest/reference_data.py
|
|
22
|
+
btgsolutions_dataservices/rest/stock_loan.py
|
|
22
23
|
btgsolutions_dataservices/rest/ticker_last_event.py
|
|
23
24
|
btgsolutions_dataservices/websocket/__init__.py
|
|
24
25
|
btgsolutions_dataservices/websocket/hfn_websocket_client.py
|
|
@@ -22,7 +22,7 @@ description = "Python package containing several classes and data for extracting
|
|
|
22
22
|
|
|
23
23
|
setup(
|
|
24
24
|
name='btgsolutions-dataservices-python-client',
|
|
25
|
-
version='2.
|
|
25
|
+
version='2.16.0',
|
|
26
26
|
description=description,
|
|
27
27
|
long_description=long_description,
|
|
28
28
|
long_description_content_type='text/markdown',
|
|
@@ -30,5 +30,5 @@ setup(
|
|
|
30
30
|
packages=find_packages(),
|
|
31
31
|
url="https://github.com/BTG-Pactual-Solutions/btgsolutions-dataservices-python-client",
|
|
32
32
|
install_requires=install_requires,
|
|
33
|
-
python_requires=">=3.9,<3.
|
|
33
|
+
python_requires=">=3.9,<3.14",
|
|
34
34
|
)
|
|
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
|