Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve typing #48

Merged
merged 5 commits into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion vertex_protocol/engine_client/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def place_market_order(self, params: PlaceMarketOrderParams) -> ExecuteResponse:
"""
orderbook = self._querier.get_market_liquidity(params.product_id, 1)
is_bid = int(params.market_order.amount) > 0
assert_book_not_empty(orderbook.bids, orderbook.asks, is_bid)
assert_book_not_empty(orderbook.bids, orderbook.asks, is_bid) # type: ignore
yruej301 marked this conversation as resolved.
Show resolved Hide resolved
slippage = to_x18(params.slippage or 0.005) # defaults to 0.5%
market_price_x18 = (
mul_x18(orderbook.bids[0][0], to_x18(1) + slippage)
Expand Down
7 changes: 6 additions & 1 deletion vertex_protocol/utils/asserts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
def assert_book_not_empty(bids: list, asks: list, is_bid: bool):
from typing import Tuple


def assert_book_not_empty(
bids: list[Tuple[str, str]], asks: list[Tuple[str, str]], is_bid: bool # type: ignore
):
book_is_empty = (is_bid and len(bids) == 0) or (not is_bid and len(asks) == 0)
if book_is_empty:
raise Exception("Orderbook is empty.")
Loading