btgsolutions-dataservices-python-client 2.11.8__tar.gz → 2.12.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.
Files changed (35) hide show
  1. {btgsolutions_dataservices_python_client-2.11.8/btgsolutions_dataservices_python_client.egg-info → btgsolutions-dataservices-python-client-2.12.0}/PKG-INFO +15 -16
  2. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/README.md +9 -1
  3. btgsolutions-dataservices-python-client-2.12.0/btgsolutions_dataservices/rest/ticker_last_event.py +147 -0
  4. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0/btgsolutions_dataservices_python_client.egg-info}/PKG-INFO +15 -16
  5. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/setup.py +1 -1
  6. btgsolutions_dataservices_python_client-2.11.8/btgsolutions_dataservices/rest/ticker_last_event.py +0 -94
  7. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/LICENSE +0 -0
  8. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/MANIFEST.in +0 -0
  9. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/__init__.py +0 -0
  10. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/config.py +0 -0
  11. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/exceptions.py +0 -0
  12. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/rest/__init__.py +0 -0
  13. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/rest/authenticator.py +0 -0
  14. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/rest/bulk_data.py +0 -0
  15. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/rest/company_data.py +0 -0
  16. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/rest/corporate_events.py +0 -0
  17. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/rest/hfn.py +0 -0
  18. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/rest/historical_candles.py +0 -0
  19. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/rest/intraday_candles.py +0 -0
  20. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/rest/intraday_tick_data.py +0 -0
  21. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/rest/public_sources.py +0 -0
  22. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/rest/quotes.py +0 -0
  23. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/rest/reference_data.py +0 -0
  24. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/websocket/__init__.py +0 -0
  25. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/websocket/hfn_websocket_client.py +0 -0
  26. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/websocket/market_data_feed.py +0 -0
  27. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/websocket/market_data_websocket_client.py +0 -0
  28. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices/websocket/websocket_default_functions.py +0 -0
  29. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices_python_client.egg-info/SOURCES.txt +0 -0
  30. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices_python_client.egg-info/dependency_links.txt +0 -0
  31. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices_python_client.egg-info/requires.txt +3 -3
  32. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/btgsolutions_dataservices_python_client.egg-info/top_level.txt +0 -0
  33. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/pyproject.toml +0 -0
  34. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/requirements.txt +0 -0
  35. {btgsolutions_dataservices_python_client-2.11.8 → btgsolutions-dataservices-python-client-2.12.0}/setup.cfg +0 -0
@@ -1,25 +1,14 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: btgsolutions-dataservices-python-client
3
- Version: 2.11.8
3
+ Version: 2.12.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
7
9
  Requires-Python: >=3.9,<3.13
8
10
  Description-Content-Type: text/markdown
9
11
  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
23
12
 
24
13
  # BTG Solutions - Data Services
25
14
 
@@ -214,7 +203,7 @@ quotes = btg.Quotes(api_key='YOUR_API_KEY')
214
203
  quotes.get_quote(market_type = 'stocks', tickers = ['PETR4', 'VALE3'])
215
204
  ```
216
205
 
217
- #### Ticker Last Event
206
+ #### Ticker Last Event (Trades)
218
207
 
219
208
  ```python
220
209
  import btgsolutions_dataservices as btg
@@ -222,6 +211,14 @@ last_event = btg.TickerLastEvent(api_key='YOUR_API_KEY')
222
211
  last_event.get_trades(data_type='equities', ticker='VALE3')
223
212
  ```
224
213
 
214
+ #### Ticker Last Event (TOBs)
215
+
216
+ ```python
217
+ import btgsolutions_dataservices as btg
218
+ last_event = btg.TickerLastEvent(api_key='YOUR_API_KEY')
219
+ last_event.get_tobs(data_type='stocks')
220
+ ```
221
+
225
222
  ### Historical Data
226
223
 
227
224
  #### Historical Candles
@@ -428,3 +425,5 @@ import btgsolutions_dataservices as btg
428
425
  ref = btg.ReferenceData(api_key='YOUR_API_KEY')
429
426
  ref.ticker_reference(tickers=['VALE3','PETR4'])
430
427
  ```
428
+
429
+
@@ -191,7 +191,7 @@ quotes = btg.Quotes(api_key='YOUR_API_KEY')
191
191
  quotes.get_quote(market_type = 'stocks', tickers = ['PETR4', 'VALE3'])
192
192
  ```
193
193
 
194
- #### Ticker Last Event
194
+ #### Ticker Last Event (Trades)
195
195
 
196
196
  ```python
197
197
  import btgsolutions_dataservices as btg
@@ -199,6 +199,14 @@ last_event = btg.TickerLastEvent(api_key='YOUR_API_KEY')
199
199
  last_event.get_trades(data_type='equities', ticker='VALE3')
200
200
  ```
201
201
 
202
+ #### Ticker Last Event (TOBs)
203
+
204
+ ```python
205
+ import btgsolutions_dataservices as btg
206
+ last_event = btg.TickerLastEvent(api_key='YOUR_API_KEY')
207
+ last_event.get_tobs(data_type='stocks')
208
+ ```
209
+
202
210
  ### Historical Data
203
211
 
204
212
  #### Historical Candles
@@ -0,0 +1,147 @@
1
+ from typing import Optional
2
+ from ..exceptions import BadResponse
3
+ import requests
4
+ from ..config import url_api_v1
5
+ from .authenticator import Authenticator
6
+ import pandas as pd
7
+ import json
8
+
9
+ class TickerLastEvent:
10
+ """
11
+ This class provides the last market data event available, for the provided ticker
12
+
13
+ * Main use case:
14
+
15
+ >>> from btgsolutions_dataservices import TickerLastEvent
16
+ >>> last_event = TickerLastEvent(
17
+ >>> api_key='YOUR_API_KEY',
18
+ >>> )
19
+
20
+ >>> last_event.get_trades(
21
+ >>> data_type = 'equities',
22
+ >>> ticker = 'PETR4',
23
+ >>> raw_data = False
24
+ >>> )
25
+
26
+ >>> last_event.get_tob(
27
+ >>> data_type = 'stocks',
28
+ >>> raw_data = False
29
+ >>> )
30
+
31
+ Parameters
32
+ ----------------
33
+ api_key: str
34
+ User identification key.
35
+ Field is required.
36
+ """
37
+ def __init__(
38
+ self,
39
+ api_key:Optional[str]
40
+ ):
41
+ self.api_key = api_key
42
+ self.authenticator = Authenticator(self.api_key)
43
+
44
+ self.available_data_types = {
45
+ "trades": ['equities', 'derivatives'],
46
+ "books": ['stocks', 'derivatives', 'options']
47
+ }
48
+
49
+ def get_trades(self, data_type:str, ticker:str, raw_data:bool=False):
50
+
51
+ """
52
+ This method provides the last market data event available, for the provided ticker.
53
+
54
+ Parameters
55
+ ----------------
56
+ data_type: str
57
+ Market Data Type.
58
+ Field is required.
59
+ Example: 'equities', 'derivatives'.
60
+ ticker: str
61
+ Ticker symbol.
62
+ Field is required. Example: 'PETR4'.
63
+ raw_data: bool
64
+ If false, returns data in a dataframe. If true, returns raw data.
65
+ Field is not required. Default: False.
66
+ """
67
+ if data_type not in self.available_data_types["trades"]:
68
+ raise Exception(f"Must provide a valid data_type. Valid data types are: {self.available_data_types['trades']}")
69
+
70
+ url = f"{url_api_v1}/marketdata/last-event/trades/{data_type}?ticker={ticker}"
71
+
72
+ response = requests.request("GET", url, headers={"authorization": f"Bearer {self.authenticator.token}"})
73
+ if response.status_code == 200:
74
+ if raw_data:
75
+ return response.json()
76
+ else:
77
+ return pd.DataFrame([response.json()])
78
+ else:
79
+ response = json.loads(response.text)
80
+ raise BadResponse(f'Error: {response.get("error", "")}')
81
+
82
+ def get_tobs(self, data_type:str, raw_data:bool=False):
83
+
84
+ """
85
+ This method gives the last available book type for all tickers of the given type.
86
+
87
+ Parameters
88
+ ----------------
89
+ data_type: str
90
+ Market Data Type.
91
+ Field is required.
92
+ Example: 'stocks', 'derivatives', 'options'.
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
+ if data_type not in self.available_data_types["books"]:
99
+ raise Exception(f"Must provide a valid data_type. Valid data types are: {self.available_data_types}")
100
+
101
+ url = f"{url_api_v1}/marketdata/last-event/books/top/{data_type}/batch"
102
+
103
+ response = requests.request("GET", url, headers={"authorization": f"Bearer {self.authenticator.token}"})
104
+
105
+ if response.status_code == 200:
106
+ if raw_data:
107
+ return response.json()
108
+ else:
109
+ return pd.DataFrame(response.json())
110
+ else:
111
+
112
+ response = json.loads(response.text)
113
+ raise BadResponse(f'Error: {response.get("error", "")}')
114
+
115
+
116
+ def get_available_tickers(self,type:str, data_type:str):
117
+
118
+ """
119
+ This method provides all the available tickers for the specific data type.
120
+
121
+ Parameters
122
+ ----------------
123
+ type: str
124
+ Data Type.
125
+ Field is required.
126
+ Example: 'trades', 'books'
127
+ data_type: str
128
+ Market Data Type.
129
+ Field is required.
130
+ Example: 'equities', 'derivatives', 'options', 'stocks'.
131
+ """
132
+
133
+ if type not in self.available_data_types:
134
+ raise Exception(f"Must provide a valid type. Valid data types are: {list(self.available_data_types.keys())}")
135
+
136
+ if data_type not in self.available_data_types[type]:
137
+ raise Exception(f"Must provide a valid data_type. Valid data types are: {self.available_data_types['books']}")
138
+
139
+ url = f"{url_api_v1}/marketdata/last-event/trades/{data_type}/available-tickers" if type == "trades" else \
140
+ f"{url_api_v1}/marketdata/last-event/books/{data_type}/availables"
141
+
142
+ response = requests.request("GET", url, headers={"authorization": f"Bearer {self.authenticator.token}"})
143
+ if response.status_code == 200:
144
+ return response.json()
145
+ else:
146
+ response = json.loads(response.text)
147
+ raise BadResponse(f'Error: {response.get("error", "")}')
@@ -1,25 +1,14 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: btgsolutions-dataservices-python-client
3
- Version: 2.11.8
3
+ Version: 2.12.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
7
9
  Requires-Python: >=3.9,<3.13
8
10
  Description-Content-Type: text/markdown
9
11
  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
23
12
 
24
13
  # BTG Solutions - Data Services
25
14
 
@@ -214,7 +203,7 @@ quotes = btg.Quotes(api_key='YOUR_API_KEY')
214
203
  quotes.get_quote(market_type = 'stocks', tickers = ['PETR4', 'VALE3'])
215
204
  ```
216
205
 
217
- #### Ticker Last Event
206
+ #### Ticker Last Event (Trades)
218
207
 
219
208
  ```python
220
209
  import btgsolutions_dataservices as btg
@@ -222,6 +211,14 @@ last_event = btg.TickerLastEvent(api_key='YOUR_API_KEY')
222
211
  last_event.get_trades(data_type='equities', ticker='VALE3')
223
212
  ```
224
213
 
214
+ #### Ticker Last Event (TOBs)
215
+
216
+ ```python
217
+ import btgsolutions_dataservices as btg
218
+ last_event = btg.TickerLastEvent(api_key='YOUR_API_KEY')
219
+ last_event.get_tobs(data_type='stocks')
220
+ ```
221
+
225
222
  ### Historical Data
226
223
 
227
224
  #### Historical Candles
@@ -428,3 +425,5 @@ import btgsolutions_dataservices as btg
428
425
  ref = btg.ReferenceData(api_key='YOUR_API_KEY')
429
426
  ref.ticker_reference(tickers=['VALE3','PETR4'])
430
427
  ```
428
+
429
+
@@ -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.11.8',
25
+ version='2.12.0',
26
26
  description=description,
27
27
  long_description=long_description,
28
28
  long_description_content_type='text/markdown',
@@ -1,94 +0,0 @@
1
- from typing import Optional
2
- from ..exceptions import BadResponse
3
- import requests
4
- from ..config import url_api_v1
5
- from .authenticator import Authenticator
6
- import pandas as pd
7
- import json
8
-
9
- class TickerLastEvent:
10
- """
11
- This class provides the last market data event available, for the provided ticker
12
-
13
- * Main use case:
14
-
15
- >>> from btgsolutions_dataservices import TickerLastEvent
16
- >>> last_event = TickerLastEvent(
17
- >>> api_key='YOUR_API_KEY',
18
- >>> )
19
-
20
- >>> last_event.get_trades(
21
- >>> ticker = 'PETR4',
22
- >>> raw_data = False
23
- >>> )
24
-
25
- Parameters
26
- ----------------
27
- api_key: str
28
- User identification key.
29
- Field is required.
30
- """
31
- def __init__(
32
- self,
33
- api_key:Optional[str]
34
- ):
35
- self.api_key = api_key
36
- self.token = Authenticator(self.api_key).token
37
- self.headers = {"authorization": f"authorization {self.token}"}
38
-
39
- self.available_data_types = ['equities', 'derivatives']
40
-
41
- def get_trades(self, data_type:str, ticker:str, raw_data:bool=False):
42
-
43
- """
44
- This method provides the last market data event available, for the provided ticker.
45
-
46
- Parameters
47
- ----------------
48
- data_type: str
49
- Market Data Type.
50
- Field is required.
51
- Example: 'equities', 'derivatives'.
52
- ticker: str
53
- Ticker symbol.
54
- Field is required. Example: 'PETR4'.
55
- raw_data: bool
56
- If false, returns data in a dataframe. If true, returns raw data.
57
- Field is not required. Default: False.
58
- """
59
- if data_type not in self.available_data_types:
60
- raise Exception("Must provide a valid data_type. Valid data types are: {self.available_data_types}")
61
-
62
- url = f"{url_api_v1}/marketdata/last-event/trades/{data_type}?ticker={ticker}"
63
-
64
- response = requests.request("GET", url, headers=self.headers)
65
- if response.status_code == 200:
66
- if raw_data:
67
- return response.json()
68
- else:
69
- return pd.DataFrame([response.json()])
70
- else:
71
- response = json.loads(response.text)
72
- raise BadResponse(f'Error: {response.get("error", "")}')
73
-
74
- def get_available_tickers(self, data_type:str):
75
-
76
- """
77
- This method provides all the available tickers for the specific data type.
78
-
79
- Parameters
80
- ----------------
81
- data_type: str
82
- Market Data Type.
83
- Field is required.
84
- Example: 'equities', 'derivatives'.
85
- """
86
-
87
- url = f"{url_api_v1}/marketdata/last-event/trades/{data_type}/available-tickers"
88
-
89
- response = requests.request("GET", url, headers=self.headers)
90
- if response.status_code == 200:
91
- return response.json()
92
- else:
93
- response = json.loads(response.text)
94
- raise BadResponse(f'Error: {response.get("error", "")}')
@@ -1,5 +1,5 @@
1
- pandas>=2.2.2
2
- websocket-client>=1.8.0
3
1
  PyJWT>=2.8.0
4
- requests>=2.32.3
2
+ pandas>=2.2.2
5
3
  pyarrow>=17.0.0
4
+ requests>=2.32.3
5
+ websocket-client>=1.8.0