Skip to content
Merged
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
4 changes: 3 additions & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Migration Guide

## 1.4.x -> 1.5.0 (REST / Onboarding / Stream clients)
## 1.4.x -> 2.0.0 (new project structure)

- `x10.perpetual.trading_client.PerpetualTradingClient` has been replaced with
`x10.clients.rest.RestApiClient` (client has the same interface but new name reflects its purpose better).
Expand All @@ -12,6 +12,8 @@
- `UserClient` replaced by `OnboardingClient`, which accepts an account address and a sign-message callback instead of a raw L1 private key.
- `onboard_subaccount` error handling has changed. Previously, it silently recovered an existing sub-account (HTTP 409) by fetching it from `get_accounts()`. Now it raises `ValidationError` on conflict. Handle duplicates explicitly if you relied on the automatic recovery.
- Signing-related modules have been extracted from `x10.perpetual` into a dedicated `x10.signing` package. The old paths no longer exist — there are no backwards-compatible re-exports.
- `x10.perpetual.orderbook` has moved to `x10.tools.orderbook`.
- `x10.perpetual.simple_client.simple_trading_client.BlockingTradingClient` has moved to `x10.clients.blocking.BlockingTradingClient`. The class is also re-exported from `x10.clients.blocking` directly for convenience (aligned with other clients).
- Fixes https://github.com/x10xchange/python_sdk/issues/99.

---
Expand Down
4 changes: 2 additions & 2 deletions examples/cases/advanced/market_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from examples.utils import BTC_USD_MARKET, create_rest_client
from x10.models.order import OrderSide
from x10.perpetual.orderbook import OrderBook, OrderBookEntry
from x10.tools.orderbook import OrderBook, OrderBookEntry

LOGGER = logging.getLogger()
MARKET_NAME = BTC_USD_MARKET
Expand Down Expand Up @@ -145,7 +145,7 @@ async def on_best_bid_change(best_bid: OrderBookEntry | None):

orderbook = await OrderBook.create(
rest_client.config,
market.name,
market_name=market.name,
start=True,
best_ask_change_callback=on_best_ask_change,
best_bid_change_callback=on_best_bid_change,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from x10.config import TESTNET_CONFIG
from x10.errors import ValidationError
from x10.models.order import OrderSide, OrderType, TimeInForce
from x10.perpetual.orderbook import OrderBook
from x10.tools.orderbook import OrderBook
from x10.utils.order import get_price_with_slippage

LOGGER = logging.getLogger()
Expand Down
2 changes: 1 addition & 1 deletion examples/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
import yaml
from dotenv import load_dotenv

from x10.clients.blocking import BlockingTradingClient
from x10.clients.rest import RestApiClient
from x10.clients.stream import StreamClient
from x10.config import TESTNET_CONFIG, Config
from x10.core.stark_account import StarkPerpetualAccount
from x10.models.market import TradingConfigModel
from x10.perpetual.simple_client.simple_trading_client import BlockingTradingClient
from x10.utils.string import is_hex_string

BTC_USD_MARKET = "BTC-USD"
Expand Down
40 changes: 1 addition & 39 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "x10-python-trading-starknet"
version = "1.5.0"
version = "2.0.0"
description = "Python client for X10 API"
authors = ["X10 <tech@ex10.org>"]
repository = "https://github.com/x10xchange/python_sdk"
Expand All @@ -29,9 +29,9 @@ pydantic = ">=2.9.0"
python = "^3.10"
pyyaml = ">=6.0.1"
sortedcontainers = ">=2.4.0"
strenum = "^0.4.15"
tenacity = "^9.1.2"
websockets = ">=12.0,<14.0"
strenum = ">=0.4.15"
tenacity = ">=9.1.2"
websockets = ">=12.0"

[tool.poetry.group.dev.dependencies]
black = "==23.12.0"
Expand All @@ -52,7 +52,7 @@ python-dotenv = "==1.0.1"
safety = "==3.5.1"
tox = "==4.11.4"
types-pyyaml = "==6.0.12.12"
typing-extensions = ">=4.9.0"
typing-extensions = "==4.15.0"


[tool.mypy]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from x10.config import TESTNET_CONFIG
from x10.models.orderbook import OrderbookQuantityModel, OrderbookUpdateModel
from x10.perpetual.orderbook import OrderBook
from x10.tools.orderbook import OrderBook


async def populate_dummy_data(market_name: str, orderbook: OrderBook):
Expand Down
3 changes: 3 additions & 0 deletions x10/clients/blocking/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from x10.clients.blocking.blocking_trading_client import ( # noqa: F401
BlockingTradingClient,
)
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ class CancelWaiter:


class BlockingTradingClient:
"""
A client for placing orders and receiving updates in a blocking manner.
Waits for the confirmation from the WS stream after placing or canceling an order.
"""

def __init__(self, config: Config, account: StarkPerpetualAccount):
if not asyncio.get_event_loop().is_running():
raise SdkError(
Expand Down
Empty file.
File renamed without changes.
1 change: 1 addition & 0 deletions x10/perpetual/orderbook.py → x10/tools/orderbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class OrderBook:
@staticmethod
async def create(
config: Config,
*,
market_name: str,
best_ask_change_callback: Callable[[OrderBookEntry | None], Awaitable[None]] | None = None,
best_bid_change_callback: Callable[[OrderBookEntry | None], Awaitable[None]] | None = None,
Expand Down
Loading