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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ lint:
black --check --diff --target-version py310 --line-length 120 ./examples ./tests ./x10
flake8 ./examples ./tests ./x10
mypy ./examples ./x10
mypy --explicit-package-bases ./tests

test:
tox
Expand Down
19 changes: 9 additions & 10 deletions tests/fixtures/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@ def create_accounts():
AccountModel(
status="ACTIVE",
l2_key="0x6970ac7180192cb58070d639064408610d0fbfd3b16c6b2c6219b9d91aa456f",
l2_vault="10001",
l2_vault=10001,
account_index=0,
id=1001,
description="Account 1",
api_keys=[],
),
AccountModel(
status="ACTIVE",
l2_key="0x3895139a98a6168dc8b0db251bcd0e6dcf97fd1e96f7a87d9bd3f341753a844",
l2_vault="10002",
l2_vault=10002,
account_index=1,
id=1002,
description="Account 2",
api_keys=[],
),
]

Expand All @@ -39,25 +37,26 @@ def create_trading_account():

def create_account_update_trade_message():
from x10.models.account import AccountStreamDataModel
from x10.models.http import WrappedStreamResponseModel
from x10.models.trade import AccountTradeModel
from x10.models.http import StreamDataType, WrappedStreamResponseModel
from x10.models.order import OrderSide
from x10.models.trade import AccountTradeModel, TradeType

return WrappedStreamResponseModel[AccountStreamDataModel](
type="TRADE",
type=StreamDataType.TRADE,
data=AccountStreamDataModel(
trades=[
AccountTradeModel(
id=1811328331296018432,
account_id=3004,
market="BTC-USD",
order_id=1811328331287359488,
side="BUY",
side=OrderSide.BUY,
price=Decimal("58249.8000000000000000"),
qty=Decimal("0.0010000000000000"),
value=Decimal("58.2498000000000000"),
fee=Decimal("0.0291240000000000"),
is_taker=True,
trade_type="TRADE",
trade_type=TradeType.TRADE,
created_time=1720689301691,
)
]
Expand All @@ -72,7 +71,7 @@ def create_account_update_unknown_message():
from x10.models.http import WrappedStreamResponseModel

return WrappedStreamResponseModel[AccountStreamDataModel](
type="UNEXPECTED",
type="UNEXPECTED", # type: ignore
data=None,
ts=1704798222748,
seq=570,
Expand Down
15 changes: 10 additions & 5 deletions tests/fixtures/asset.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
from decimal import Decimal

from x10.models.asset import AssetModel, AssetOperationModel
from x10.models.asset import (
AssetModel,
AssetOperationModel,
AssetOperationStatus,
AssetOperationType,
)


def create_asset_operations():
return [
AssetOperationModel(
id="1816814506626514944",
type="TRANSFER",
status="COMPLETED",
type=AssetOperationType.TRANSFER,
status=AssetOperationStatus.COMPLETED,
amount=Decimal("-100.0000000000000000"),
fee=Decimal("0"),
asset=1,
Expand All @@ -18,8 +23,8 @@ def create_asset_operations():
),
AssetOperationModel(
id="1813548171448147968",
type="CLAIM",
status="COMPLETED",
type=AssetOperationType.CLAIM,
status=AssetOperationStatus.COMPLETED,
amount=Decimal("100000.0000000000000000"),
fee=Decimal("0"),
asset=1,
Expand Down
8 changes: 7 additions & 1 deletion tests/fixtures/candle.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from decimal import Decimal
from typing import List

from x10.models.candle import CandleModel
Expand All @@ -8,7 +9,12 @@ def create_candle_stream_message():
return WrappedStreamResponseModel[List[CandleModel]](
data=[
CandleModel(
open="3458.64", low="3399.07", high="3476.89", close="3414.85", volume="3.938", timestamp=1721106000000
open=Decimal("3458.64"),
low=Decimal("3399.07"),
high=Decimal("3476.89"),
close=Decimal("3414.85"),
volume=Decimal("3.938"),
timestamp=1721106000000,
)
],
ts=1721283121979,
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/orderbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@


def create_orderbook_message():
from x10.models.http import WrappedStreamResponseModel
from x10.models.http import StreamDataType, WrappedStreamResponseModel
from x10.models.orderbook import OrderbookQuantityModel, OrderbookUpdateModel

return WrappedStreamResponseModel[OrderbookUpdateModel](
type="SNAPSHOT",
type=StreamDataType.SNAPSHOT,
data=OrderbookUpdateModel(
market="BTC-USD",
bid=[
Expand Down
Loading
Loading