tradingapi 0.3.4__tar.gz → 0.3.5__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 (31) hide show
  1. {tradingapi-0.3.4 → tradingapi-0.3.5}/PKG-INFO +1 -1
  2. {tradingapi-0.3.4 → tradingapi-0.3.5}/pyproject.toml +1 -1
  3. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/allocation.py +18 -4
  4. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/fivepaisa.py +3 -6
  5. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/utils.py +1 -1
  6. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi.egg-info/PKG-INFO +1 -1
  7. {tradingapi-0.3.4 → tradingapi-0.3.5}/README.md +0 -0
  8. {tradingapi-0.3.4 → tradingapi-0.3.5}/setup.cfg +0 -0
  9. {tradingapi-0.3.4 → tradingapi-0.3.5}/tests/test_find_option_with_delta.py +0 -0
  10. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/__init__.py +0 -0
  11. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/attribution.py +0 -0
  12. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/broker_base.py +0 -0
  13. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/config/commissions_20241216.yaml +0 -0
  14. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/config/config_sample.yaml +0 -0
  15. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/config.py +0 -0
  16. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/dhan.py +0 -0
  17. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/error_handling.py +0 -0
  18. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/exceptions.py +0 -0
  19. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/flattrade.py +0 -0
  20. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/globals.py +0 -0
  21. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/icicidirect.py +0 -0
  22. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/icicidirect_generate_session.py +0 -0
  23. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/market_data_exchanges.py +0 -0
  24. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/proxy_utils.py +0 -0
  25. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/shoonya.py +0 -0
  26. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi/span.py +0 -0
  27. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi.egg-info/SOURCES.txt +0 -0
  28. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi.egg-info/dependency_links.txt +0 -0
  29. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi.egg-info/entry_points.txt +0 -0
  30. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi.egg-info/requires.txt +0 -0
  31. {tradingapi-0.3.4 → tradingapi-0.3.5}/tradingapi.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tradingapi
3
- Version: 0.3.4
3
+ Version: 0.3.5
4
4
  Summary: Trade integration with brokers
5
5
  Author-email: Pankaj Sharma <sharma.pankaj.kumar@gmail.com>
6
6
  License-Expression: MIT
@@ -28,7 +28,7 @@ packages = ["tradingapi"]
28
28
 
29
29
  [project]
30
30
  name = "tradingapi"
31
- version = "0.3.4"
31
+ version = "0.3.5"
32
32
  description = "Trade integration with brokers"
33
33
  readme = "README.md"
34
34
  license = "MIT"
@@ -21,13 +21,15 @@ _ALLOCATIONS_DIR = Path(os.path.expanduser("~/onedrive/.tradingapi/allocations")
21
21
  _TODAY_SYMLINK = _ALLOCATIONS_DIR / "master_allocation_today.yaml"
22
22
 
23
23
 
24
- def load_today_allocation(broker_name: str, strategy_name: str) -> float:
25
- """Return the pct (0.0–1.0) allocated to strategy_name on broker_name today.
24
+ def load_today_allocation_entry(broker_name: str, strategy_name: str) -> dict:
25
+ """Return the full allocation entry dict for strategy_name on broker_name today.
26
+
27
+ Example return value: {'pct': 0.275, 'redis_db': 8}
28
+ SCALPING strategies include a 'redis_db' key; others have only 'pct'.
26
29
 
27
30
  Reads master_allocation_today.yaml (a symlink to today's dated file).
28
31
  Raises FileNotFoundError if the symlink/file is missing.
29
32
  Raises ValueError if the date in the file does not match today.
30
- Returns 0.0 if the strategy is listed with pct == 0 (inactive today).
31
33
  Raises KeyError if the broker/strategy is not found in the file at all.
32
34
  """
33
35
  if not _TODAY_SYMLINK.exists():
@@ -63,7 +65,19 @@ def load_today_allocation(broker_name: str, strategy_name: str) -> float:
63
65
  f"Available strategies: {list(strategies.keys())}"
64
66
  )
65
67
 
66
- entry = strategies[strategy_key]
68
+ return dict(strategies[strategy_key])
69
+
70
+
71
+ def load_today_allocation(broker_name: str, strategy_name: str) -> float:
72
+ """Return the pct (0.0–1.0) allocated to strategy_name on broker_name today.
73
+
74
+ Reads master_allocation_today.yaml (a symlink to today's dated file).
75
+ Raises FileNotFoundError if the symlink/file is missing.
76
+ Raises ValueError if the date in the file does not match today.
77
+ Returns 0.0 if the strategy is listed with pct == 0 (inactive today).
78
+ Raises KeyError if the broker/strategy is not found in the file at all.
79
+ """
80
+ entry = load_today_allocation_entry(broker_name, strategy_name)
67
81
  return float(entry.get("pct", 0.0))
68
82
 
69
83
 
@@ -3860,12 +3860,9 @@ class FivePaisa(BrokerBase):
3860
3860
 
3861
3861
  # Start the connection and receiving data in a separate thread
3862
3862
  if not has_live_stream():
3863
- self.subscribe_thread = threading.Thread(
3864
- target=connect_and_receive, args=(req_data,), name="MarketDataStreamer"
3865
- )
3866
- self.subscribe_thread.start()
3867
- time.sleep(2)
3868
- trading_logger.log_info("Streaming thread started", {"thread_name": "MarketDataStreamer"})
3863
+ # WS is dead — full reconnect restoring all subscribed_symbols (already updated above).
3864
+ # Connecting with just the current op's req_data would lose all prior subscriptions.
3865
+ reconnect_stream()
3869
3866
  else:
3870
3867
  trading_logger.log_info(
3871
3868
  "Requesting streaming for existing connection", {"req_data": json.dumps(req_data)}
@@ -93,7 +93,7 @@ empty_trades = pd.DataFrame(
93
93
  "exit_time": pd.Series(dtype="string"),
94
94
  "exit_quantity": pd.Series(dtype="float64"),
95
95
  "exit_price": pd.Series(dtype="float64"),
96
- "commission": pd.Series(dtype="int64"),
96
+ "commission": pd.Series(dtype="float64"),
97
97
  "int_order_id": pd.Series(dtype="object"),
98
98
  "entry_keys": pd.Series(dtype="object"),
99
99
  "exit_keys": pd.Series(dtype="object"),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tradingapi
3
- Version: 0.3.4
3
+ Version: 0.3.5
4
4
  Summary: Trade integration with brokers
5
5
  Author-email: Pankaj Sharma <sharma.pankaj.kumar@gmail.com>
6
6
  License-Expression: MIT
File without changes
File without changes