pmxt 1.0.4__py3-none-any.whl → 1.1.0__py3-none-any.whl
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.
- pmxt/__init__.py +1 -1
- pmxt/_server/server/bundled.js +21927 -274
- pmxt/client.py +104 -0
- {pmxt-1.0.4.dist-info → pmxt-1.1.0.dist-info}/METADATA +4 -4
- {pmxt-1.0.4.dist-info → pmxt-1.1.0.dist-info}/RECORD +15 -12
- pmxt_internal/__init__.py +7 -1
- pmxt_internal/api/default_api.py +578 -0
- pmxt_internal/api_client.py +1 -1
- pmxt_internal/configuration.py +1 -1
- pmxt_internal/models/__init__.py +3 -0
- pmxt_internal/models/watch_order_book_request.py +102 -0
- pmxt_internal/models/watch_order_book_request_args_inner.py +143 -0
- pmxt_internal/models/watch_trades_request.py +102 -0
- {pmxt-1.0.4.dist-info → pmxt-1.1.0.dist-info}/WHEEL +0 -0
- {pmxt-1.0.4.dist-info → pmxt-1.1.0.dist-info}/top_level.txt +0 -0
pmxt/client.py
CHANGED
|
@@ -206,6 +206,10 @@ class Exchange(ABC):
|
|
|
206
206
|
|
|
207
207
|
self._api = DefaultApi(api_client=self._api_client)
|
|
208
208
|
|
|
209
|
+
def close(self):
|
|
210
|
+
"""No-op for now, kept for API compatibility with TS."""
|
|
211
|
+
pass
|
|
212
|
+
|
|
209
213
|
def _handle_response(self, response: Dict[str, Any]) -> Any:
|
|
210
214
|
"""Handle API response and extract data."""
|
|
211
215
|
if not response.get("success"):
|
|
@@ -442,6 +446,106 @@ class Exchange(ABC):
|
|
|
442
446
|
except ApiException as e:
|
|
443
447
|
raise Exception(f"Failed to fetch trades: {e}")
|
|
444
448
|
|
|
449
|
+
# WebSocket Streaming Methods
|
|
450
|
+
|
|
451
|
+
def watch_order_book(self, outcome_id: str, limit: Optional[int] = None) -> OrderBook:
|
|
452
|
+
"""
|
|
453
|
+
Watch real-time order book updates via WebSocket.
|
|
454
|
+
|
|
455
|
+
Returns a promise that resolves with the next order book update.
|
|
456
|
+
Call repeatedly in a loop to stream updates (CCXT Pro pattern).
|
|
457
|
+
|
|
458
|
+
Args:
|
|
459
|
+
outcome_id: Outcome ID to watch
|
|
460
|
+
limit: Optional depth limit for order book
|
|
461
|
+
|
|
462
|
+
Returns:
|
|
463
|
+
Next order book update
|
|
464
|
+
|
|
465
|
+
Example:
|
|
466
|
+
>>> # Stream order book updates
|
|
467
|
+
>>> while True:
|
|
468
|
+
... order_book = exchange.watch_order_book(outcome_id)
|
|
469
|
+
... print(f"Best bid: {order_book.bids[0].price}")
|
|
470
|
+
... print(f"Best ask: {order_book.asks[0].price}")
|
|
471
|
+
"""
|
|
472
|
+
try:
|
|
473
|
+
args = [outcome_id]
|
|
474
|
+
if limit is not None:
|
|
475
|
+
args.append(limit)
|
|
476
|
+
|
|
477
|
+
body_dict = {"args": args}
|
|
478
|
+
|
|
479
|
+
# Add credentials if available
|
|
480
|
+
creds = self._get_credentials_dict()
|
|
481
|
+
if creds:
|
|
482
|
+
body_dict["credentials"] = creds
|
|
483
|
+
|
|
484
|
+
request_body = internal_models.WatchOrderBookRequest.from_dict(body_dict)
|
|
485
|
+
|
|
486
|
+
response = self._api.watch_order_book(
|
|
487
|
+
exchange=self.exchange_name,
|
|
488
|
+
watch_order_book_request=request_body,
|
|
489
|
+
)
|
|
490
|
+
|
|
491
|
+
data = self._handle_response(response.to_dict())
|
|
492
|
+
return _convert_order_book(data)
|
|
493
|
+
except ApiException as e:
|
|
494
|
+
raise Exception(f"Failed to watch order book: {e}")
|
|
495
|
+
|
|
496
|
+
def watch_trades(
|
|
497
|
+
self,
|
|
498
|
+
outcome_id: str,
|
|
499
|
+
since: Optional[int] = None,
|
|
500
|
+
limit: Optional[int] = None
|
|
501
|
+
) -> List[Trade]:
|
|
502
|
+
"""
|
|
503
|
+
Watch real-time trade updates via WebSocket.
|
|
504
|
+
|
|
505
|
+
Returns a promise that resolves with the next trade(s).
|
|
506
|
+
Call repeatedly in a loop to stream updates (CCXT Pro pattern).
|
|
507
|
+
|
|
508
|
+
Args:
|
|
509
|
+
outcome_id: Outcome ID to watch
|
|
510
|
+
since: Optional timestamp to filter trades from
|
|
511
|
+
limit: Optional limit for number of trades
|
|
512
|
+
|
|
513
|
+
Returns:
|
|
514
|
+
Next trade update(s)
|
|
515
|
+
|
|
516
|
+
Example:
|
|
517
|
+
>>> # Stream trade updates
|
|
518
|
+
>>> while True:
|
|
519
|
+
... trades = exchange.watch_trades(outcome_id)
|
|
520
|
+
... for trade in trades:
|
|
521
|
+
... print(f"Trade: {trade.price} @ {trade.amount}")
|
|
522
|
+
"""
|
|
523
|
+
try:
|
|
524
|
+
args = [outcome_id]
|
|
525
|
+
if since is not None:
|
|
526
|
+
args.append(since)
|
|
527
|
+
if limit is not None:
|
|
528
|
+
args.append(limit)
|
|
529
|
+
|
|
530
|
+
body_dict = {"args": args}
|
|
531
|
+
|
|
532
|
+
# Add credentials if available
|
|
533
|
+
creds = self._get_credentials_dict()
|
|
534
|
+
if creds:
|
|
535
|
+
body_dict["credentials"] = creds
|
|
536
|
+
|
|
537
|
+
request_body = internal_models.WatchTradesRequest.from_dict(body_dict)
|
|
538
|
+
|
|
539
|
+
response = self._api.watch_trades(
|
|
540
|
+
exchange=self.exchange_name,
|
|
541
|
+
watch_trades_request=request_body,
|
|
542
|
+
)
|
|
543
|
+
|
|
544
|
+
data = self._handle_response(response.to_dict())
|
|
545
|
+
return [_convert_trade(t) for t in data]
|
|
546
|
+
except ApiException as e:
|
|
547
|
+
raise Exception(f"Failed to watch trades: {e}")
|
|
548
|
+
|
|
445
549
|
# Trading Methods (require authentication)
|
|
446
550
|
|
|
447
551
|
def create_order(self, params: CreateOrderParams) -> Order:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pmxt
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: Unified prediction market data API - The ccxt for prediction markets
|
|
5
5
|
Author: PMXT Contributors
|
|
6
6
|
License: MIT
|
|
@@ -206,10 +206,10 @@ For deep-dive methods like `fetch_ohlcv()`, `fetch_order_book()`, and `fetch_tra
|
|
|
206
206
|
|
|
207
207
|
```python
|
|
208
208
|
markets = poly.search_markets("Trump")
|
|
209
|
-
outcome_id = markets[0].outcomes[0].id #
|
|
209
|
+
outcome_id = markets[0].outcomes[0].id # Correct
|
|
210
210
|
|
|
211
|
-
candles = poly.fetch_ohlcv(outcome_id, ...) #
|
|
212
|
-
candles = poly.fetch_ohlcv(markets[0].id, ...) #
|
|
211
|
+
candles = poly.fetch_ohlcv(outcome_id, ...) # Works
|
|
212
|
+
candles = poly.fetch_ohlcv(markets[0].id, ...) # Wrong!
|
|
213
213
|
```
|
|
214
214
|
|
|
215
215
|
### Prices are 0.0 to 1.0
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
pmxt/__init__.py,sha256=
|
|
2
|
-
pmxt/client.py,sha256=
|
|
1
|
+
pmxt/__init__.py,sha256=2XbKCO7ujQzhPPnyxAh1Qtc3aQuvilehplhDgoo1t3w,1150
|
|
2
|
+
pmxt/client.py,sha256=2qlCJsxkQiHYrYvZYX4p-APvYq0rF_yicNfUPgcE3ZU,27368
|
|
3
3
|
pmxt/models.py,sha256=Mu0hLVjQU3PM5m68poK61VQcJtPQ8ZdLdLU7pq1lqjQ,6004
|
|
4
4
|
pmxt/server_manager.py,sha256=wmHcGBM3oMNLSajCZ0xnANNSmqBYt9vWxQzeYmfo0-Y,10635
|
|
5
5
|
pmxt/_server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
pmxt/_server/bin/pmxt-ensure-server,sha256=kXIond0UbxS52FAVQD7kHmSBaL_s6cbIyapLRr4KZJw,4544
|
|
7
|
-
pmxt/_server/server/bundled.js,sha256=
|
|
8
|
-
pmxt_internal/__init__.py,sha256=
|
|
9
|
-
pmxt_internal/api_client.py,sha256=
|
|
7
|
+
pmxt/_server/server/bundled.js,sha256=TXtX8YZlSnrIoN_ZmxMA25WqQw6j-eZXMi4YNr32p58,4175627
|
|
8
|
+
pmxt_internal/__init__.py,sha256=gbAxJ-pDBsZHbr7bgWhX66LV_CEkm--f9BYRB9X483o,6400
|
|
9
|
+
pmxt_internal/api_client.py,sha256=viGpxECLDA9KW58HKl-hxCM9a-0nuYNMWnWHXPAirrk,27889
|
|
10
10
|
pmxt_internal/api_response.py,sha256=eMxw1mpmJcoGZ3gs9z6jM4oYoZ10Gjk333s9sKxGv7s,652
|
|
11
|
-
pmxt_internal/configuration.py,sha256=
|
|
11
|
+
pmxt_internal/configuration.py,sha256=pngy-anwjS9enhuiaYdNcz0AP1xJ6cYHEoTYUJjXsQg,18320
|
|
12
12
|
pmxt_internal/exceptions.py,sha256=txF8A7vlan57JS69kFPs-IZF-Qhp7IZobBTJVa4fOaM,6644
|
|
13
13
|
pmxt_internal/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
pmxt_internal/rest.py,sha256=FMj4yaV6XLr842u_ScWHSzQsTFdk0jaUeuWLJoRbogQ,9760
|
|
15
15
|
pmxt_internal/api/__init__.py,sha256=ppJSCipQ5IAk2z6UZkFaGSsEmnoAnSSHb8sjb_DYUkY,101
|
|
16
|
-
pmxt_internal/api/default_api.py,sha256=
|
|
17
|
-
pmxt_internal/models/__init__.py,sha256=
|
|
16
|
+
pmxt_internal/api/default_api.py,sha256=h1vGidUmbkXhBHAE1THOWsGjiJc0RnIQTy1fRVSye7M,171451
|
|
17
|
+
pmxt_internal/models/__init__.py,sha256=vjHF9UaS2iEhSGavMQL9PtS5NFaFUMTEKKzg-qJwKeE,3449
|
|
18
18
|
pmxt_internal/models/balance.py,sha256=Dj5kFiLrsXOZyyXTC18bPjWrgw7qdWnTgTSCmk_l6xk,2962
|
|
19
19
|
pmxt_internal/models/base_request.py,sha256=ZNipF7ycXFkQJ6j3QmB1TzA0UO3fB54AMPlAgIA3KOA,2987
|
|
20
20
|
pmxt_internal/models/base_response.py,sha256=g-NG4Swxl3cg4-YOCPl65dUeHzOnA9S7ubTj8HOYZs0,2975
|
|
@@ -53,7 +53,10 @@ pmxt_internal/models/search_markets_request.py,sha256=BARoy2GXgV7RQNIGck6UaOyQqf
|
|
|
53
53
|
pmxt_internal/models/search_markets_request_args_inner.py,sha256=PkusFd_OxhUsItsBpluPJA11zg0sXXjbOK-lPmemvLs,5561
|
|
54
54
|
pmxt_internal/models/trade.py,sha256=U6Fc18rbwILs9FmX8CSDYYL8dF6763l8QzeMQNRxQdo,3328
|
|
55
55
|
pmxt_internal/models/unified_market.py,sha256=mNyUrGKWxvI2f2KCa2uhGwq22cBdDia2hD5AtzFw8fE,4487
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
pmxt-1.0.
|
|
56
|
+
pmxt_internal/models/watch_order_book_request.py,sha256=kavGUI-SLz2-Kam_jcJ_h0GDe0-9UkxqCmVsAi6Uios,3726
|
|
57
|
+
pmxt_internal/models/watch_order_book_request_args_inner.py,sha256=ZHrjmFDGxRG5MXbuz4mUp9KFfo3XS7zuXWTyMNgi4xI,5464
|
|
58
|
+
pmxt_internal/models/watch_trades_request.py,sha256=brrg8JbEe-aeg7mIe_Y2HzRPogp-IfRhkXChrxzqoLU,3722
|
|
59
|
+
pmxt-1.1.0.dist-info/METADATA,sha256=le091hHBquNEKcZpGKhRyouzBh1amaAcD7ZUkL7loPc,6288
|
|
60
|
+
pmxt-1.1.0.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
61
|
+
pmxt-1.1.0.dist-info/top_level.txt,sha256=J_jrcouJ-x-5lpcXMxeW0GOSi1HsBVR5_PdSfvigVrw,19
|
|
62
|
+
pmxt-1.1.0.dist-info/RECORD,,
|
pmxt_internal/__init__.py
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
""" # noqa: E501
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
__version__ = "1.0
|
|
17
|
+
__version__ = "1.1.0"
|
|
18
18
|
|
|
19
19
|
# Define package exports
|
|
20
20
|
__all__ = [
|
|
@@ -66,6 +66,9 @@ __all__ = [
|
|
|
66
66
|
"SearchMarketsRequestArgsInner",
|
|
67
67
|
"Trade",
|
|
68
68
|
"UnifiedMarket",
|
|
69
|
+
"WatchOrderBookRequest",
|
|
70
|
+
"WatchOrderBookRequestArgsInner",
|
|
71
|
+
"WatchTradesRequest",
|
|
69
72
|
]
|
|
70
73
|
|
|
71
74
|
# import apis into sdk package
|
|
@@ -121,4 +124,7 @@ from pmxt_internal.models.search_markets_request import SearchMarketsRequest as
|
|
|
121
124
|
from pmxt_internal.models.search_markets_request_args_inner import SearchMarketsRequestArgsInner as SearchMarketsRequestArgsInner
|
|
122
125
|
from pmxt_internal.models.trade import Trade as Trade
|
|
123
126
|
from pmxt_internal.models.unified_market import UnifiedMarket as UnifiedMarket
|
|
127
|
+
from pmxt_internal.models.watch_order_book_request import WatchOrderBookRequest as WatchOrderBookRequest
|
|
128
|
+
from pmxt_internal.models.watch_order_book_request_args_inner import WatchOrderBookRequestArgsInner as WatchOrderBookRequestArgsInner
|
|
129
|
+
from pmxt_internal.models.watch_trades_request import WatchTradesRequest as WatchTradesRequest
|
|
124
130
|
|