# Generated by ariadne-codegen
# Source: queries.graphql

from typing import Any, List, Literal, Optional, Union

from pydantic import Field

from .base_model import BaseModel
from .enums import FillKind, OrderStateFlags


class SubscribeOrderflow(BaseModel):
    orderflow: Union[
        "SubscribeOrderflowOrderflowOmsOrderUpdate",
        "SubscribeOrderflowOrderflowCancel",
        "SubscribeOrderflowOrderflowCancelAll",
        "SubscribeOrderflowOrderflowAck",
        "SubscribeOrderflowOrderflowReject",
        "SubscribeOrderflowOrderflowFill",
        "SubscribeOrderflowOrderflowAberrantFill",
        "SubscribeOrderflowOrderflowOut",
    ] = Field(discriminator="typename__")


class SubscribeOrderflowOrderflowOmsOrderUpdate(BaseModel):
    typename__: Literal["OmsOrderUpdate"] = Field(alias="__typename")
    order_id: Any = Field(alias="orderId")
    order_state: List[OrderStateFlags] = Field(alias="orderState")
    filled_qty: Any = Field(alias="filledQty")
    avg_fill_price: Optional[Any] = Field(alias="avgFillPrice")


class SubscribeOrderflowOrderflowCancel(BaseModel):
    typename__: Literal["Cancel"] = Field(alias="__typename")


class SubscribeOrderflowOrderflowCancelAll(BaseModel):
    typename__: Literal["CancelAll"] = Field(alias="__typename")


class SubscribeOrderflowOrderflowAck(BaseModel):
    typename__: Literal["Ack"] = Field(alias="__typename")
    order_id: Any = Field(alias="orderId")


class SubscribeOrderflowOrderflowReject(BaseModel):
    typename__: Literal["Reject"] = Field(alias="__typename")
    typename__: Literal["Reject"] = Field(alias="__typename")
    order_id: Any = Field(alias="orderId")
    reason: str


class SubscribeOrderflowOrderflowFill(BaseModel):
    typename__: Literal["Fill"] = Field(alias="__typename")
    fill_order_id: Optional[Any] = Field(alias="fillOrderId")
    fill_kind: FillKind = Field(alias="fillKind")
    market_id: Any = Field(alias="marketId")
    dir: Any
    price: Any
    quantity: Any
    trade_time: Any = Field(alias="tradeTime")


class SubscribeOrderflowOrderflowAberrantFill(BaseModel):
    typename__: Literal["AberrantFill"] = Field(alias="__typename")


class SubscribeOrderflowOrderflowOut(BaseModel):
    typename__: Literal["Out"] = Field(alias="__typename")
    order_id: Any = Field(alias="orderId")


SubscribeOrderflow.model_rebuild()
