pmxt 1.0.3__tar.gz → 1.0.4__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 (65) hide show
  1. {pmxt-1.0.3 → pmxt-1.0.4}/PKG-INFO +1 -1
  2. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/__init__.py +1 -1
  3. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/api_client.py +1 -1
  4. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/configuration.py +1 -1
  5. {pmxt-1.0.3 → pmxt-1.0.4}/pmxt/__init__.py +1 -1
  6. {pmxt-1.0.3 → pmxt-1.0.4}/pmxt/_server/server/bundled.js +4 -2
  7. {pmxt-1.0.3 → pmxt-1.0.4}/pmxt/client.py +6 -0
  8. {pmxt-1.0.3 → pmxt-1.0.4}/pmxt/server_manager.py +51 -4
  9. {pmxt-1.0.3 → pmxt-1.0.4}/pmxt.egg-info/PKG-INFO +1 -1
  10. {pmxt-1.0.3 → pmxt-1.0.4}/pyproject.toml +1 -1
  11. {pmxt-1.0.3 → pmxt-1.0.4}/README.md +0 -0
  12. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/api/__init__.py +0 -0
  13. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/api/default_api.py +0 -0
  14. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/api_response.py +0 -0
  15. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/exceptions.py +0 -0
  16. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/__init__.py +0 -0
  17. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/balance.py +0 -0
  18. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/base_request.py +0 -0
  19. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/base_response.py +0 -0
  20. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/cancel_order_request.py +0 -0
  21. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/create_order200_response.py +0 -0
  22. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/create_order_params.py +0 -0
  23. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/create_order_request.py +0 -0
  24. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/error_detail.py +0 -0
  25. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/error_response.py +0 -0
  26. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/exchange_credentials.py +0 -0
  27. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/fetch_balance200_response.py +0 -0
  28. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/fetch_markets200_response.py +0 -0
  29. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/fetch_markets_request.py +0 -0
  30. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/fetch_ohlcv200_response.py +0 -0
  31. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/fetch_ohlcv_request.py +0 -0
  32. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/fetch_ohlcv_request_args_inner.py +0 -0
  33. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/fetch_open_orders200_response.py +0 -0
  34. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/fetch_open_orders_request.py +0 -0
  35. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/fetch_order_book200_response.py +0 -0
  36. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/fetch_order_book_request.py +0 -0
  37. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/fetch_positions200_response.py +0 -0
  38. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/fetch_positions_request.py +0 -0
  39. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/fetch_trades200_response.py +0 -0
  40. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/fetch_trades_request.py +0 -0
  41. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/get_markets_by_slug_request.py +0 -0
  42. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/health_check200_response.py +0 -0
  43. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/history_filter_params.py +0 -0
  44. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/market_filter_params.py +0 -0
  45. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/market_outcome.py +0 -0
  46. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/order.py +0 -0
  47. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/order_book.py +0 -0
  48. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/order_level.py +0 -0
  49. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/position.py +0 -0
  50. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/price_candle.py +0 -0
  51. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/search_markets_request.py +0 -0
  52. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/search_markets_request_args_inner.py +0 -0
  53. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/trade.py +0 -0
  54. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/models/unified_market.py +0 -0
  55. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/py.typed +0 -0
  56. {pmxt-1.0.3 → pmxt-1.0.4}/generated/pmxt_internal/rest.py +0 -0
  57. {pmxt-1.0.3 → pmxt-1.0.4}/pmxt/_server/__init__.py +0 -0
  58. {pmxt-1.0.3 → pmxt-1.0.4}/pmxt/_server/bin/pmxt-ensure-server +0 -0
  59. {pmxt-1.0.3 → pmxt-1.0.4}/pmxt/models.py +0 -0
  60. {pmxt-1.0.3 → pmxt-1.0.4}/pmxt.egg-info/SOURCES.txt +0 -0
  61. {pmxt-1.0.3 → pmxt-1.0.4}/pmxt.egg-info/dependency_links.txt +0 -0
  62. {pmxt-1.0.3 → pmxt-1.0.4}/pmxt.egg-info/requires.txt +0 -0
  63. {pmxt-1.0.3 → pmxt-1.0.4}/pmxt.egg-info/top_level.txt +0 -0
  64. {pmxt-1.0.3 → pmxt-1.0.4}/setup.cfg +0 -0
  65. {pmxt-1.0.3 → pmxt-1.0.4}/tests/test_integration.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pmxt
3
- Version: 1.0.3
3
+ Version: 1.0.4
4
4
  Summary: Unified prediction market data API - The ccxt for prediction markets
5
5
  Author: PMXT Contributors
6
6
  License: MIT
@@ -14,7 +14,7 @@
14
14
  """ # noqa: E501
15
15
 
16
16
 
17
- __version__ = "1.0.3"
17
+ __version__ = "1.0.4"
18
18
 
19
19
  # Define package exports
20
20
  __all__ = [
@@ -91,7 +91,7 @@ class ApiClient:
91
91
  self.default_headers[header_name] = header_value
92
92
  self.cookie = cookie
93
93
  # Set default User-Agent.
94
- self.user_agent = 'OpenAPI-Generator/1.0.3/python'
94
+ self.user_agent = 'OpenAPI-Generator/1.0.4/python'
95
95
  self.client_side_validation = configuration.client_side_validation
96
96
 
97
97
  def __enter__(self):
@@ -506,7 +506,7 @@ class Configuration:
506
506
  "OS: {env}\n"\
507
507
  "Python Version: {pyversion}\n"\
508
508
  "Version of the API: 0.4.4\n"\
509
- "SDK Package Version: 1.0.3".\
509
+ "SDK Package Version: 1.0.4".\
510
510
  format(env=sys.platform, pyversion=sys.version)
511
511
 
512
512
  def get_host_settings(self) -> List[HostSetting]:
@@ -33,7 +33,7 @@ from .models import (
33
33
  CreateOrderParams,
34
34
  )
35
35
 
36
- __version__ = "1.0.3"
36
+ __version__ = "1.0.4"
37
37
  __all__ = [
38
38
  # Exchanges
39
39
  "Polymarket",
@@ -83381,6 +83381,7 @@ var require_fetchMarkets2 = __commonJS({
83381
83381
  }
83382
83382
  async function fetchMarkets(params) {
83383
83383
  const limit = params?.limit || 50;
83384
+ const offset = params?.offset || 0;
83384
83385
  const now = Date.now();
83385
83386
  try {
83386
83387
  let events;
@@ -83389,8 +83390,9 @@ var require_fetchMarkets2 = __commonJS({
83389
83390
  events = cachedEvents;
83390
83391
  seriesMap = cachedSeriesMap;
83391
83392
  } else {
83393
+ const fetchLimit = 1e3;
83392
83394
  const [allEvents, fetchedSeriesMap] = await Promise.all([
83393
- fetchActiveEvents(limit),
83395
+ fetchActiveEvents(fetchLimit),
83394
83396
  fetchSeriesMap()
83395
83397
  ]);
83396
83398
  events = allEvents;
@@ -83419,7 +83421,7 @@ var require_fetchMarkets2 = __commonJS({
83419
83421
  } else if (params?.sort === "liquidity") {
83420
83422
  allMarkets.sort((a, b) => b.liquidity - a.liquidity);
83421
83423
  }
83422
- return allMarkets.slice(0, limit);
83424
+ return allMarkets.slice(offset, offset + limit);
83423
83425
  } catch (error) {
83424
83426
  console.error("Error fetching Kalshi data:", error);
83425
83427
  return [];
@@ -198,6 +198,12 @@ class Exchange(ABC):
198
198
  # Configure the API client with the actual base URL
199
199
  config = Configuration(host=base_url)
200
200
  self._api_client = ApiClient(configuration=config)
201
+
202
+ # Add access token from lock file
203
+ server_info = self._server_manager.get_server_info()
204
+ if server_info and 'accessToken' in server_info:
205
+ self._api_client.default_headers['x-pmxt-access-token'] = server_info['accessToken']
206
+
201
207
  self._api = DefaultApi(api_client=self._api_client)
202
208
 
203
209
  def _handle_response(self, response: Dict[str, Any]) -> Any:
@@ -69,15 +69,62 @@ class ServerManager:
69
69
  Raises:
70
70
  Exception: If server fails to start or become healthy
71
71
  """
72
- # Step 1: Check if server is already running
72
+ # Step 1: Check if force restart is requested (DEV MODE)
73
+ if os.getenv('PMXT_ALWAYS_RESTART') == '1':
74
+ self._kill_old_server()
75
+
76
+ # Step 2: Check if server is already running and matches version
73
77
  if self.is_server_alive():
74
- return
78
+ if self._is_version_mismatch():
79
+ # print("PMXT: Version mismatch detected. Restarting server...")
80
+ self._kill_old_server()
81
+ else:
82
+ return
75
83
 
76
- # Step 2: Start server via launcher
84
+ # Step 3: Start server via launcher
77
85
  self._start_server_via_launcher()
78
86
 
79
- # Step 3: Wait for health check
87
+ # Step 4: Wait for health check
80
88
  self._wait_for_health()
89
+
90
+ def _is_version_mismatch(self) -> bool:
91
+ """Check if running server version matches expected version."""
92
+ server_info = self.get_server_info()
93
+ if not server_info or 'version' not in server_info:
94
+ return True # Old server without version
95
+
96
+ # Get expected version
97
+ try:
98
+ # 1. Check production path (bundled)
99
+ pkg_path = Path(__file__).parent / '_server' / 'package.json'
100
+
101
+ # 2. Check dev path (monorepo)
102
+ if not pkg_path.exists():
103
+ # Traverse up to find core/package.json
104
+ pkg_path = Path(__file__).parent.parent.parent.parent / 'core' / 'package.json'
105
+
106
+ if pkg_path.exists():
107
+ data = json.loads(pkg_path.read_text())
108
+ expected_version = data.get('version')
109
+ if expected_version and not server_info['version'].startswith(expected_version):
110
+ return True
111
+ except:
112
+ pass
113
+
114
+ return False
115
+
116
+ def _kill_old_server(self) -> None:
117
+ """Kill the currently running server."""
118
+ server_info = self.get_server_info()
119
+ if server_info and 'pid' in server_info:
120
+ import signal
121
+ try:
122
+ os.kill(server_info['pid'], signal.SIGTERM)
123
+ # Brief wait for cleanup
124
+ time.sleep(0.5)
125
+ except:
126
+ pass
127
+ self._remove_stale_lock()
81
128
 
82
129
  def is_server_alive(self) -> bool:
83
130
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pmxt
3
- Version: 1.0.3
3
+ Version: 1.0.4
4
4
  Summary: Unified prediction market data API - The ccxt for prediction markets
5
5
  Author: PMXT Contributors
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pmxt"
7
- version = "1.0.3"
7
+ version = "1.0.4"
8
8
  description = "Unified prediction market data API - The ccxt for prediction markets"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes