laplace-python-sdk 1.2.0__tar.gz → 1.2.1__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.
- {laplace_python_sdk-1.2.0/src/laplace_python_sdk.egg-info → laplace_python_sdk-1.2.1}/PKG-INFO +1 -1
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/pyproject.toml +3 -3
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace/models.py +19 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace/news.py +58 -7
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1/src/laplace_python_sdk.egg-info}/PKG-INFO +1 -1
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/LICENSE +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/MANIFEST.in +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/README.md +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/setup.cfg +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace/__init__.py +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace/base.py +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace/brokers.py +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace/capital_increase.py +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace/client.py +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace/collections.py +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace/earnings.py +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace/financials.py +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace/funds.py +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace/live_price.py +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace/politician.py +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace/search.py +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace/state.py +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace/stocks.py +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace/websocket.py +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace_python_sdk.egg-info/SOURCES.txt +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace_python_sdk.egg-info/dependency_links.txt +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace_python_sdk.egg-info/requires.txt +0 -0
- {laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace_python_sdk.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "laplace-python-sdk"
|
|
7
|
-
version = "1.2.
|
|
7
|
+
version = "1.2.1"
|
|
8
8
|
description = "Python SDK for Laplace stock data platform"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -64,14 +64,14 @@ profile = "black"
|
|
|
64
64
|
line_length = 100
|
|
65
65
|
|
|
66
66
|
[tool.mypy]
|
|
67
|
-
python_version = "1.2.
|
|
67
|
+
python_version = "1.2.1"
|
|
68
68
|
strict = true
|
|
69
69
|
warn_return_any = true
|
|
70
70
|
warn_unused_configs = true
|
|
71
71
|
|
|
72
72
|
[tool.ruff]
|
|
73
73
|
line-length = 100
|
|
74
|
-
target-version = "1.2.
|
|
74
|
+
target-version = "1.2.1"
|
|
75
75
|
|
|
76
76
|
[tool.ruff.lint]
|
|
77
77
|
select = ["E", "W", "F", "I", "N", "B", "UP"]
|
|
@@ -908,6 +908,25 @@ class News(BaseModel):
|
|
|
908
908
|
|
|
909
909
|
quality_score: int = Field(alias="qualityScore")
|
|
910
910
|
|
|
911
|
+
model_config = {"populate_by_name": True}
|
|
912
|
+
|
|
913
|
+
class NewsV2(BaseModel):
|
|
914
|
+
created_at: datetime = Field(alias="createdAt")
|
|
915
|
+
url: str
|
|
916
|
+
image_url: str = Field(alias="imageUrl")
|
|
917
|
+
timestamp: datetime
|
|
918
|
+
publisher_url: str = Field(alias="publisherUrl")
|
|
919
|
+
|
|
920
|
+
publisher: NewsPublisher
|
|
921
|
+
|
|
922
|
+
tickers: Optional[List[NewsTicker]] = None
|
|
923
|
+
categories: Optional[NewsCategory] = None
|
|
924
|
+
sectors: Optional[NewsSector] = None
|
|
925
|
+
content: Optional[NewsContent] = None
|
|
926
|
+
industries: Optional[NewsIndustry] = None
|
|
927
|
+
|
|
928
|
+
quality_score: int = Field(alias="qualityScore")
|
|
929
|
+
|
|
911
930
|
model_config = {"populate_by_name": True}
|
|
912
931
|
class NewsHighlight(BaseModel):
|
|
913
932
|
consumer: List[str]
|
|
@@ -10,6 +10,7 @@ from laplace.base import BaseClient
|
|
|
10
10
|
from .models import (
|
|
11
11
|
Locale,
|
|
12
12
|
News,
|
|
13
|
+
NewsV2,
|
|
13
14
|
NewsHighlight,
|
|
14
15
|
NewsOrderBy,
|
|
15
16
|
NewsType,
|
|
@@ -40,6 +41,7 @@ class NewsStream:
|
|
|
40
41
|
self,
|
|
41
42
|
base_client: BaseClient,
|
|
42
43
|
locale: Locale,
|
|
44
|
+
region: Region,
|
|
43
45
|
sectors: Optional[List[str]] = None,
|
|
44
46
|
tickers: Optional[List[str]] = None,
|
|
45
47
|
categories: Optional[List[str]] = None,
|
|
@@ -47,23 +49,24 @@ class NewsStream:
|
|
|
47
49
|
):
|
|
48
50
|
self.base_client = base_client
|
|
49
51
|
self.locale = locale
|
|
52
|
+
self.region = region
|
|
50
53
|
self.sectors = sectors
|
|
51
54
|
self.tickers = tickers
|
|
52
55
|
self.categories = categories
|
|
53
56
|
self.industries = industries
|
|
54
57
|
self._task: Optional[asyncio.Task] = None
|
|
55
|
-
self._queue: Optional[asyncio.Queue[NewsStreamResult[List[
|
|
58
|
+
self._queue: Optional[asyncio.Queue[NewsStreamResult[List[NewsV2]]]] = None
|
|
56
59
|
self._is_closed = False
|
|
57
60
|
|
|
58
61
|
async def subscribe(self) -> None:
|
|
59
62
|
"""Subscribe to news updates stream."""
|
|
60
63
|
await self._cleanup_existing_stream()
|
|
61
64
|
|
|
62
|
-
self._queue = asyncio.Queue[NewsStreamResult[List[
|
|
65
|
+
self._queue = asyncio.Queue[NewsStreamResult[List[NewsV2]]]()
|
|
63
66
|
self._is_closed = False
|
|
64
67
|
self._task = asyncio.create_task(self._start_streaming())
|
|
65
68
|
|
|
66
|
-
async def receive(self) -> AsyncGenerator[NewsStreamResult[List[
|
|
69
|
+
async def receive(self) -> AsyncGenerator[NewsStreamResult[List[NewsV2]], None]:
|
|
67
70
|
"""Receive news data from the stream."""
|
|
68
71
|
if not self._queue:
|
|
69
72
|
raise RuntimeError("Not subscribed. Call subscribe() first.")
|
|
@@ -97,7 +100,7 @@ class NewsStream:
|
|
|
97
100
|
def _build_stream_url(self) -> str:
|
|
98
101
|
"""Build the streaming URL for the news endpoint."""
|
|
99
102
|
url = f"{self.base_client.base_url}/v1/news/stream"
|
|
100
|
-
params = {"locale": self.locale}
|
|
103
|
+
params = {"locale": self.locale, "region": self.region.value}
|
|
101
104
|
if self.sectors:
|
|
102
105
|
params["sectors"] = ",".join(self.sectors)
|
|
103
106
|
if self.tickers:
|
|
@@ -157,8 +160,8 @@ class NewsStream:
|
|
|
157
160
|
parsed_data = json.loads(json_data)
|
|
158
161
|
|
|
159
162
|
# Process array of news items
|
|
160
|
-
news_items = [
|
|
161
|
-
result = NewsStreamResult[List[
|
|
163
|
+
news_items = [NewsV2(**item) for item in parsed_data]
|
|
164
|
+
result = NewsStreamResult[List[NewsV2]](data=news_items)
|
|
162
165
|
await self._queue.put(result)
|
|
163
166
|
|
|
164
167
|
except Exception as e:
|
|
@@ -168,7 +171,7 @@ class NewsStream:
|
|
|
168
171
|
async def _put_error(self, error_message: str) -> None:
|
|
169
172
|
"""Put an error result in the queue."""
|
|
170
173
|
if self._queue:
|
|
171
|
-
error_result = NewsStreamResult[List[
|
|
174
|
+
error_result = NewsStreamResult[List[NewsV2]](error=error_message)
|
|
172
175
|
await self._queue.put(error_result)
|
|
173
176
|
|
|
174
177
|
|
|
@@ -228,6 +231,51 @@ class NewsClient:
|
|
|
228
231
|
response = self._client.get("v1/news", params=params)
|
|
229
232
|
return PaginatedResponse[News](**response)
|
|
230
233
|
|
|
234
|
+
def get_news_v2(
|
|
235
|
+
self,
|
|
236
|
+
locale: Locale,
|
|
237
|
+
region: Region,
|
|
238
|
+
news_type: Optional[NewsType] = None,
|
|
239
|
+
news_order_by: Optional[NewsOrderBy] = None,
|
|
240
|
+
direction: Optional[SortDirection] = None,
|
|
241
|
+
extra_filters: Optional[str] = None,
|
|
242
|
+
page: int = 0,
|
|
243
|
+
page_size: PaginationPageSize = PaginationPageSize.PAGE_SIZE_10,
|
|
244
|
+
) -> PaginatedResponse[NewsV2]:
|
|
245
|
+
"""Retrieve paginated news (v2).
|
|
246
|
+
|
|
247
|
+
Args:
|
|
248
|
+
locale: Locale code (e.g. "tr", "en")
|
|
249
|
+
region: Region enum (e.g. Region.TR)
|
|
250
|
+
news_type: Optional news type filter
|
|
251
|
+
news_order_by: Optional sorting field
|
|
252
|
+
direction: Optional sort direction
|
|
253
|
+
extra_filters: Optional extra filters (API-specific)
|
|
254
|
+
page: Page number (default: 0)
|
|
255
|
+
page_size: Page size enum (default: 10)
|
|
256
|
+
|
|
257
|
+
Returns:
|
|
258
|
+
PaginatedResponse[NewsV2]
|
|
259
|
+
"""
|
|
260
|
+
params: Dict[str, object] = {
|
|
261
|
+
"locale": locale,
|
|
262
|
+
"region": region.value,
|
|
263
|
+
"page": page,
|
|
264
|
+
"size": page_size.value,
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if news_type is not None:
|
|
268
|
+
params["newsType"] = news_type.value
|
|
269
|
+
if news_order_by is not None:
|
|
270
|
+
params["orderBy"] = news_order_by.value
|
|
271
|
+
if direction is not None:
|
|
272
|
+
params["orderByDirection"] = direction.value
|
|
273
|
+
if extra_filters:
|
|
274
|
+
params["extraFilters"] = extra_filters
|
|
275
|
+
|
|
276
|
+
response = self._client.get("v2/news", params=params)
|
|
277
|
+
return PaginatedResponse[NewsV2](**response)
|
|
278
|
+
|
|
231
279
|
def get_highlights(
|
|
232
280
|
self,
|
|
233
281
|
locale: Locale,
|
|
@@ -253,6 +301,7 @@ class NewsClient:
|
|
|
253
301
|
async def get_news_stream(
|
|
254
302
|
self,
|
|
255
303
|
locale: Locale,
|
|
304
|
+
region: Region,
|
|
256
305
|
sectors: Optional[List[str]] = None,
|
|
257
306
|
tickers: Optional[List[str]] = None,
|
|
258
307
|
categories: Optional[List[str]] = None,
|
|
@@ -262,6 +311,7 @@ class NewsClient:
|
|
|
262
311
|
|
|
263
312
|
Args:
|
|
264
313
|
locale: Locale code (e.g., "tr", "en")
|
|
314
|
+
region: Region enum (e.g. Region.TR)
|
|
265
315
|
sectors: Optional list of sectors
|
|
266
316
|
tickers: Optional list of tickers
|
|
267
317
|
categories: Optional list of categories
|
|
@@ -273,6 +323,7 @@ class NewsClient:
|
|
|
273
323
|
stream = NewsStream(
|
|
274
324
|
self._client,
|
|
275
325
|
locale,
|
|
326
|
+
region,
|
|
276
327
|
sectors=sectors,
|
|
277
328
|
tickers=tickers,
|
|
278
329
|
categories=categories,
|
|
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
|
{laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace_python_sdk.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace_python_sdk.egg-info/requires.txt
RENAMED
|
File without changes
|
{laplace_python_sdk-1.2.0 → laplace_python_sdk-1.2.1}/src/laplace_python_sdk.egg-info/top_level.txt
RENAMED
|
File without changes
|