Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion sdks/python/pmxt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from .constants import ENV, ENV_BASE_URL, ENV_API_KEY
from ._exchanges import Polymarket, Limitless, Kalshi, KalshiDemo, Probable, Baozi, Myriad, Opinion, Metaculus, Smarkets, PolymarketUS, Polymarket_us, Hyperliquid, GeminiTitan, SuiBets, Suibets, Rain, Mock, Router
from .router import Router
from .feed_client import FeedClient
from .feed_client import FeedClient, FeedMarket, Market, OHLCV, OracleRound, Ticker, Tickers
from .server_manager import ServerManager
from .errors import (
PmxtError,
Expand Down Expand Up @@ -189,6 +189,12 @@ def restart_server() -> None:
"Router",
"Exchange",
"FeedClient",
"Ticker",
"Tickers",
"OHLCV",
"Market",
"FeedMarket",
"OracleRound",
"ExchangeOptions",
"PolymarketOptions",
"RouterOptions",
Expand Down
4 changes: 4 additions & 0 deletions sdks/python/pmxt/feed_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Ticker:
mark_price: Optional[float] = None


Tickers = Dict[str, Ticker]
OHLCV = Tuple[float, float, float, float, float, float]


Expand All @@ -58,6 +59,9 @@ class Market:
info: Any = field(default_factory=dict)


FeedMarket = Market


@dataclass(frozen=True)
class OracleRound:
feed: str
Expand Down
32 changes: 32 additions & 0 deletions sdks/python/tests/test_public_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,38 @@ def test_feed_client_is_top_level_public_export():
assert "FeedClient" in public_exports


def test_feed_client_supporting_types_are_top_level_public_exports():
init_path = Path(__file__).resolve().parents[1] / "pmxt" / "__init__.py"
tree = ast.parse(init_path.read_text(encoding="utf-8"))

imported_modules = {
alias.asname or alias.name: node.module
for node in tree.body
if isinstance(node, ast.ImportFrom)
for alias in node.names
}
public_exports = set()

for node in tree.body:
if (
isinstance(node, ast.Assign)
and len(node.targets) == 1
and isinstance(node.targets[0], ast.Name)
and node.targets[0].id == "__all__"
and isinstance(node.value, ast.List)
):
public_exports.update(
item.value
for item in node.value.elts
if isinstance(item, ast.Constant) and isinstance(item.value, str)
)

expected = {"Ticker", "Tickers", "OHLCV", "Market", "FeedMarket", "OracleRound"}
assert expected <= imported_modules.keys()
assert all(imported_modules[name] == "feed_client" for name in expected)
assert expected <= public_exports


def test_environment_constants_are_top_level_public_exports():
init_path = Path(__file__).resolve().parents[1] / "pmxt" / "__init__.py"
tree = ast.parse(init_path.read_text(encoding="utf-8"))
Expand Down
Loading