bw-essentials-core 0.0.7__tar.gz → 0.0.9__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.

Potentially problematic release.


This version of bw-essentials-core might be problematic. Click here for more details.

Files changed (30) hide show
  1. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/PKG-INFO +1 -1
  2. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/services/market_pricer.py +70 -1
  3. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/services/master_data.py +23 -1
  4. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials_core.egg-info/PKG-INFO +1 -1
  5. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/setup.py +1 -1
  6. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/README.md +0 -0
  7. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/__init__.py +0 -0
  8. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/constants/__init__.py +0 -0
  9. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/constants/services.py +0 -0
  10. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/data_loch/__init__.py +0 -0
  11. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/data_loch/data_loch.py +0 -0
  12. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/email_client/__init__.py +0 -0
  13. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/email_client/email_client.py +0 -0
  14. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/notifications/__init__.py +0 -0
  15. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/notifications/teams_notification_schemas.py +0 -0
  16. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/notifications/teams_notifications.py +0 -0
  17. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/s3_utils/__init__.py +0 -0
  18. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/s3_utils/s3_utils.py +0 -0
  19. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/services/__init__.py +0 -0
  20. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/services/api_client.py +0 -0
  21. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/services/broker.py +0 -0
  22. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/services/model_portfolio_reporting.py +0 -0
  23. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/services/trade_placement.py +0 -0
  24. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/services/user_portfolio.py +0 -0
  25. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials/services/user_portfolio_reporting.py +0 -0
  26. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials_core.egg-info/SOURCES.txt +0 -0
  27. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials_core.egg-info/dependency_links.txt +0 -0
  28. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials_core.egg-info/requires.txt +0 -0
  29. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/bw_essentials_core.egg-info/top_level.txt +0 -0
  30. {bw_essentials_core-0.0.7 → bw_essentials_core-0.0.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bw-essentials-core
3
- Version: 0.0.7
3
+ Version: 0.0.9
4
4
  Summary: Reusable utilities for S3, email, Data Loch, Microsoft Teams Notifications and more.
5
5
  Author: InvestorAI
6
6
  Author-email: support+tech@investorai.in
@@ -67,7 +67,8 @@ class MarketPricer(ApiClient):
67
67
  self.name = Services.MARKET_PRICER.value
68
68
  self.urls = {
69
69
  "live": "live",
70
- "eod": "eod"
70
+ "eod": "eod",
71
+ "index_performance": "index/{}/performance",
71
72
  }
72
73
 
73
74
  def get_live_prices(self, securities, exchange):
@@ -231,3 +232,71 @@ class MarketPricer(ApiClient):
231
232
 
232
233
  logger.info(f"{market_pricing_eod_response=}")
233
234
  return market_pricing_eod_response.get("data")
235
+
236
+ def get_index_performance_by_dates(self, index_name, start_date, end_date):
237
+ """
238
+ Fetches index performance metrics over a given date range.
239
+
240
+ Args:
241
+ index_name (str): The index name (e.g., "NIFTY50").
242
+ start_date (str): The start date for performance metrics in 'YYYY-MM-DD' format.
243
+ end_date (str): The end date for performance metrics in 'YYYY-MM-DD' format.
244
+
245
+ Returns:
246
+ dict: A dictionary containing cumulative return, volatility, drawdown, and a list
247
+ of daily return data.
248
+ Example:
249
+ {
250
+ "data": {
251
+ "cumulative_return": 2.332968692796598,
252
+ "volatility": 6.378354401960588,
253
+ "drawdown": 0,
254
+ "daily_returns": [
255
+ {
256
+ "date": "2025-06-05",
257
+ "close": 22934.5,
258
+ "daily_return": 0.5552912703301827,
259
+ "current_weight": 100.55529127033019
260
+ },
261
+ {
262
+ "date": "2025-06-06",
263
+ "close": 23165.1,
264
+ "daily_return": 1.0054721053434745,
265
+ "current_weight": 101.56634667450024
266
+ },
267
+ {
268
+ "date": "2025-06-09",
269
+ "close": 23329.4,
270
+ "daily_return": 0.7092565972087517,
271
+ "current_weight": 102.28671268883305
272
+ },
273
+ {
274
+ "date": "2025-06-10",
275
+ "close": 23339.95,
276
+ "daily_return": 0.04522190883606836,
277
+ "current_weight": 102.3329686927966
278
+ }
279
+ ]
280
+ },
281
+ "success": true
282
+ }
283
+ Raises:
284
+ ValueError: If input parameters are missing or invalid.
285
+ """
286
+ logger.info(f"In - get_index_performance_by_dates | {index_name=}, {start_date=}, {end_date=}")
287
+
288
+ if not all([index_name, start_date, end_date]):
289
+ logger.error("Missing required parameters for index performance fetch")
290
+ raise ValueError("index_name, start_date, and end_date are required")
291
+
292
+ endpoint = self.urls['index_performance'].format(index_name)
293
+ params = {"start_date": start_date, "end_date": end_date}
294
+ response = self._get(
295
+ url=self.base_url,
296
+ endpoint=endpoint,
297
+ params=params
298
+ )
299
+ logger.debug(f"Raw response from MarketPricer index API: {response}")
300
+ data = response.get("data")
301
+ logger.info("Out - get_index_performance_by_dates success")
302
+ return data
@@ -45,7 +45,8 @@ class MasterData(ApiClient):
45
45
  "broker_config": "broker/config/keys",
46
46
  "broker_details": "securities/{}/details",
47
47
  "isin_details": "company/details/isin",
48
- "shorten_url": "shorten-url"
48
+ "shorten_url": "shorten-url",
49
+ "broker_partner_mapping_details": "partner/{}/broker/{}/"
49
50
  }
50
51
 
51
52
  def get_security_details(self, securities: List[str]) -> Optional[Dict[str, Any]]:
@@ -277,3 +278,24 @@ class MasterData(ApiClient):
277
278
  data={"long_url": long_url})
278
279
  logger.info(f"Shortening URL {response =}")
279
280
  return response.get("data", {})
281
+
282
+ def get_or_create_broker_partner_mapping(self, broker_partner: str, broker: str) -> Dict[str, Any]:
283
+ """
284
+ Fetches or creates a broker-partner mapping from master data constants table.
285
+
286
+ This method sends a GET request to retrieve the mapping details for a given
287
+ broker and broker partner. If the mapping does not exist, the API
288
+ is expected to create it automatically (based on implementation).
289
+
290
+ Parameters:
291
+ - broker_partner (str): The identifier of the broker partner.
292
+ - broker (str): The identifier of the broker.
293
+
294
+ Returns:
295
+ - Dict[str, Any]: The mapping data returned from the service, or an empty
296
+ dictionary if no data is available.
297
+ """
298
+ logger.info(f"In - get_or_create_broker_partner_mapping | broker_partner={broker_partner} broker={broker}")
299
+ response = self._get(url=self.base_url, endpoint=self.urls["broker_partner_mapping_details"].format(broker_partner, broker))
300
+ logger.info(f"Broker partner mapping {response =}")
301
+ return response.get('data', {})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bw-essentials-core
3
- Version: 0.0.7
3
+ Version: 0.0.9
4
4
  Summary: Reusable utilities for S3, email, Data Loch, Microsoft Teams Notifications and more.
5
5
  Author: InvestorAI
6
6
  Author-email: support+tech@investorai.in
@@ -10,7 +10,7 @@ from setuptools import setup, find_packages
10
10
 
11
11
  setup(
12
12
  name="bw-essentials-core",
13
- version="0.0.7",
13
+ version="0.0.9",
14
14
  author="InvestorAI",
15
15
  author_email="support+tech@investorai.in",
16
16
  description="Reusable utilities for S3, email, Data Loch, Microsoft Teams Notifications and more.",