from typing import Literal, TypedDict

AccountInfo = TypedDict(
    "AccountInfo",
    {
        "id": str,
        "PrepaidCrypto-Z": bool,
        "PrepaidCrypto-P": bool,
        "brokerageAccess": bool,
        "accountId": str,
        "accountVan": str,
        "accountTitle": str,
        "displayName": str,
        "accountAlias": str | None,
        "accountStatus": int,
        "currency": str,
        "type": str,
        "tradingType": str,
        "businessType": str,
        "category": str,
        "ibEntity": str,
        "faclient": bool,
        "clearingStatus": str,
        "covestor": bool,
        "noClientTrading": bool,
        "trackVirtualFXPortfolio": bool,
        "acctCustType": str,
        "parent": dict,
        "desc": str
    },
    total=True,
)

OrderInfo = TypedDict(
    "OrderInfo",
    {
        "acct": str,
        "conidex": str,
        "conid": int,
        "account": str,
        "orderId": int,
        "cashCcy": str,
        "sizeAndFills": str,
        "orderDesc": str,
        "description1": str,
        "ticker": str,
        "secType": Literal['STK'],
        "listingExchange": str,
        "remainingQuantity": float,
        "filledQuantity": float,
        "totalSize": float,
        "companyName": str,
        "status": str,
        "order_ccp_status": str,
        "outsideRTH": bool,
        "origOrderType": str,
        "supportsTaxOpt": str,
        "lastExecutionTime": str,
        "orderType": str,
        "bgColor": str,
        "fgColor": str,
        "isEventTrading": str,
        "price": str,
        "timeInForce": str,
        "lastExecutionTime_r": int,
        "side": Literal['BUY', 'SELL'],
    }
)

PositionInfo = TypedDict(
    "PositionInfo",
    {
        "acctId": str,
        "conid": int,
        "contractDesc": str,
        "position": float,
        "mktPrice": float,
        "mktValue": float,
        "currency": str,
        "avgCost": float,
        "avgPrice": float,
        "realizedPnl": float,
        "unrealizedPnl": float,
        "exchs": str | None,
        "expiry": str | None,
        "putOrCall": str | None,
        "multiplier": float,
        "strike": str,
        "exerciseStyle": str | None,
        "conExchMap": list,
        "assetClass": str,
        "undConid": int,
        "model": str,
        "baseMktValue": float,
        "baseMktPrice": float,
        "baseAvgCost": float,
        "baseAvgPrice": float,
        "baseRealizedPnl": float,
        "baseUnrealizedPnl": float,
        "incrementRules": list,
        "displayRule": dict,
        "time": int,
        "chineseName": str,
        "allExchanges": str,
        "listingExchange": str,
        "countryCode": str,
        "name": str,
        "lastTradingDay": str | None,
        "group": str,
        "sector": str,
        "sectorGroup": str,
        "ticker": str,
        "type": str,
        "hasOptions": bool,
        "fullName": str,
        "isUS": bool,
        "isEventContract": bool,
        "pageSize": int
    },
    total=True,
)


ContractInfo = TypedDict(
    "ContractInfo",
    {
        "cfi_code": str,
        "symbol": str,
        "cusip": str | None,
        "expiry_full": str | None,
        "con_id": int,
        "maturity_date": str | None,
        "industry": str,
        "instrument_type": str,
        "trading_class": str,
        "valid_exchanges": str,
        "allow_sell_long": bool,
        "is_zero_commission_security": bool,
        "local_symbol": str,
        "contract_clarification_type": str | None,
        "classifier": str | None,
        "currency": str,
        "text": str | None,
        "underlying_con_id": int,
        "r_t_h": bool,
        "multiplier": str | None,
        "underlying_issuer": str | None,
        "contract_month": str | None,
        "company_name": str,
        "smart_available": bool,
        "exchange": str,
        "category": str
    },
    total=True,
)
