# This file is automatically generated by pyo3_stub_gen
# ruff: noqa: E501

import datetime
import enum
import typing

from nautilus_trader import model
from nautilus_trader import network

__all__ = [
    "OKX",
    "OKX_CLIENT_ID",
    "OKX_VENUE",
    "OKXDataClientConfig",
    "OKXDataClientFactory",
    "OKXEnvironment",
    "OKXExecutionClientConfig",
    "OKXExecutionClientFactory",
]

OKX: str
OKX_CLIENT_ID: model.ClientId
OKX_VENUE: model.Venue

@typing.final
class OKXBalanceDetail:
    @property
    def ccy(self) -> str: ...
    @property
    def cash_bal(self) -> str: ...
    @property
    def liab(self) -> str: ...

@typing.final
class OKXDataClientConfig:
    @property
    def instrument_types(self) -> list[OKXInstrumentType]: ...
    @property
    def instrument_families(self) -> list[str] | None: ...
    @property
    def environment(self) -> OKXEnvironment: ...
    @property
    def region(self) -> OKXRegion: ...
    @property
    def base_url_http(self) -> str | None: ...
    @property
    def base_url_ws_public(self) -> str | None: ...
    @property
    def base_url_ws_business(self) -> str | None: ...
    @property
    def http_timeout_secs(self) -> int: ...
    @property
    def max_retries(self) -> int: ...
    @property
    def retry_delay_initial_ms(self) -> int: ...
    @property
    def retry_delay_max_ms(self) -> int: ...
    @property
    def update_instruments_interval_mins(self) -> int: ...
    @property
    def book_stale_check_interval_secs(self) -> int: ...
    @property
    def book_stale_threshold_secs(self) -> int: ...
    @property
    def book_snapshot_timeout_secs(self) -> int: ...
    @property
    def vip_level(self) -> OKXVipLevel | None: ...
    @property
    def load_spreads(self) -> bool: ...
    @property
    def transport_backend(self) -> network.TransportBackend: ...
    def __init__(
        self,
        instrument_types: typing.Sequence[OKXInstrumentType] | None = None,
        environment: OKXEnvironment | None = None,
        region: OKXRegion | None = None,
        api_key: str | None = None,
        api_secret: str | None = None,
        api_passphrase: str | None = None,
        base_url_http: str | None = None,
        base_url_ws_public: str | None = None,
        base_url_ws_business: str | None = None,
        proxy_url: str | None = None,
        http_timeout_secs: int | None = None,
        max_retries: int | None = None,
        retry_delay_initial_ms: int | None = None,
        retry_delay_max_ms: int | None = None,
        update_instruments_interval_mins: int | None = None,
        book_stale_check_interval_secs: int | None = None,
        book_stale_threshold_secs: int | None = None,
        book_snapshot_timeout_secs: int | None = None,
        vip_level: OKXVipLevel | None = None,
        load_spreads: bool = False,
        transport_backend: network.TransportBackend | None = None,
        instrument_families: typing.Sequence[str] | None = None,
    ) -> None: ...
    @property
    def has_proxy_url(self) -> bool: ...

@typing.final
class OKXDataClientFactory:
    def __init__(self) -> None: ...
    def name(self) -> str: ...

@typing.final
class OKXExecutionClientConfig:
    @property
    def account_id(self) -> model.AccountId: ...
    @property
    def instrument_types(self) -> list[OKXInstrumentType]: ...
    @property
    def environment(self) -> OKXEnvironment: ...
    @property
    def region(self) -> OKXRegion: ...
    @property
    def base_url_http(self) -> str | None: ...
    @property
    def base_url_ws_private(self) -> str | None: ...
    @property
    def base_url_ws_business(self) -> str | None: ...
    @property
    def http_timeout_secs(self) -> int: ...
    @property
    def max_retries(self) -> int: ...
    @property
    def retry_delay_initial_ms(self) -> int: ...
    @property
    def retry_delay_max_ms(self) -> int: ...
    @property
    def margin_mode(self) -> OKXMarginMode | None: ...
    @property
    def load_spreads(self) -> bool: ...
    @property
    def auth_timeout_secs(self) -> int | None: ...
    @property
    def transport_backend(self) -> network.TransportBackend: ...
    @property
    def spot_trade_quote_ccy(self) -> str | None: ...
    def __init__(
        self,
        account_id: model.AccountId,
        instrument_types: typing.Sequence[OKXInstrumentType] | None = None,
        environment: OKXEnvironment | None = None,
        region: OKXRegion | None = None,
        api_key: str | None = None,
        api_secret: str | None = None,
        api_passphrase: str | None = None,
        base_url_http: str | None = None,
        base_url_ws_private: str | None = None,
        base_url_ws_business: str | None = None,
        proxy_url: str | None = None,
        http_timeout_secs: int | None = None,
        max_retries: int | None = None,
        retry_delay_initial_ms: int | None = None,
        retry_delay_max_ms: int | None = None,
        margin_mode: OKXMarginMode | None = None,
        load_spreads: bool = False,
        auth_timeout_secs: int | None = None,
        transport_backend: network.TransportBackend | None = None,
        spot_trade_quote_ccy: str | None = None,
    ) -> None: ...
    @property
    def has_proxy_url(self) -> bool: ...

@typing.final
class OKXExecutionClientFactory:
    def __init__(self) -> None: ...
    def name(self) -> str: ...

@typing.final
class OKXHttpClient:
    def __init__(
        self,
        api_key: str | None = None,
        api_secret: str | None = None,
        api_passphrase: str | None = None,
        base_url: str | None = None,
        timeout_secs: int = 60,
        max_retries: int = 3,
        retry_delay_ms: int = 1000,
        retry_delay_max_ms: int = 10000,
        environment: OKXEnvironment = ...,
        proxy_url: str | None = None,
    ) -> None: ...
    @staticmethod
    def from_env() -> OKXHttpClient: ...
    @property
    def base_url(self) -> str: ...
    @property
    def api_key(self) -> str | None: ...
    @property
    def api_key_masked(self) -> str | None: ...
    def is_initialized(self) -> bool: ...
    def get_cached_symbols(self) -> list[str]: ...
    def cancel_all_requests(self) -> None: ...
    def cache_instruments(self, instruments: typing.Sequence[typing.Any]) -> None: ...
    def cache_instrument(self, instrument: typing.Any) -> None: ...
    def set_position_mode(self, position_mode: OKXPositionMode) -> typing.Any: ...
    def activate_feature(self, feature: str) -> typing.Any: ...
    def set_spot_trade_quote_ccy(self, ccy: str | None = ...) -> None: ...
    def request_instruments(
        self, instrument_type: OKXInstrumentType, instrument_family: str | None = None
    ) -> typing.Any: ...
    def request_spread_instruments(
        self,
        base_currency: str | None = None,
        instrument_id: model.InstrumentId | None = None,
        spread_id: str | None = None,
        state: str | None = None,
    ) -> typing.Any: ...
    def request_instrument(self, instrument_id: model.InstrumentId) -> typing.Any: ...
    def request_event_contract_series(self, series_id: str | None = None) -> typing.Any: ...
    def request_event_contract_events(
        self,
        series_id: str,
        event_id: str | None = None,
        state: str | None = None,
        limit: str | None = None,
        before: str | None = None,
        after: str | None = None,
    ) -> typing.Any: ...
    def request_event_contract_markets(
        self,
        series_id: str,
        event_id: str | None = None,
        inst_id: str | None = None,
        state: str | None = None,
        limit: str | None = None,
        before: str | None = None,
        after: str | None = None,
    ) -> typing.Any: ...
    def request_account_state(self, account_id: model.AccountId) -> typing.Any: ...
    def request_trades(
        self,
        instrument_id: model.InstrumentId,
        start: datetime.datetime | None = None,
        end: datetime.datetime | None = None,
        limit: int | None = None,
    ) -> typing.Any: ...
    def request_bars(
        self,
        bar_type: model.BarType,
        start: datetime.datetime | None = None,
        end: datetime.datetime | None = None,
        limit: int | None = None,
    ) -> typing.Any: ...
    def request_orderbook_snapshot(
        self, instrument_id: model.InstrumentId, depth: int | None = None
    ) -> typing.Any: ...
    def request_funding_rates(
        self,
        instrument_id: model.InstrumentId,
        start: datetime.datetime | None = None,
        end: datetime.datetime | None = None,
        limit: int | None = None,
    ) -> typing.Any: ...
    def request_mark_price(self, instrument_id: model.InstrumentId) -> typing.Any: ...
    def request_price_limit(self, instrument_id: model.InstrumentId) -> typing.Any: ...
    def request_index_price(self, instrument_id: model.InstrumentId) -> typing.Any: ...
    def request_order_status_reports(
        self,
        account_id: model.AccountId,
        instrument_type: OKXInstrumentType | None = None,
        instrument_id: model.InstrumentId | None = None,
        start: datetime.datetime | None = None,
        end: datetime.datetime | None = None,
        open_only: bool = False,
        limit: int | None = None,
    ) -> typing.Any: ...
    def request_algo_order_status_reports(
        self,
        account_id: model.AccountId,
        instrument_type: OKXInstrumentType | None = None,
        instrument_id: model.InstrumentId | None = None,
        algo_id: str | None = None,
        algo_client_order_id: model.ClientOrderId | None = None,
        state: OKXAlgoOrderStatus | None = None,
        limit: int | None = None,
    ) -> typing.Any: ...
    def request_algo_order_status_report(
        self,
        account_id: model.AccountId,
        instrument_id: model.InstrumentId,
        client_order_id: model.ClientOrderId,
    ) -> typing.Any: ...
    def request_fill_reports(
        self,
        account_id: model.AccountId,
        instrument_type: OKXInstrumentType | None = None,
        instrument_id: model.InstrumentId | None = None,
        start: datetime.datetime | None = None,
        end: datetime.datetime | None = None,
        limit: int | None = None,
    ) -> typing.Any: ...
    def request_position_status_reports(
        self,
        account_id: model.AccountId,
        instrument_type: OKXInstrumentType | None = None,
        instrument_id: model.InstrumentId | None = None,
    ) -> typing.Any: ...
    def place_order(
        self,
        trader_id: model.TraderId,
        strategy_id: model.StrategyId,
        instrument_id: model.InstrumentId,
        td_mode: OKXTradeMode,
        client_order_id: model.ClientOrderId,
        order_side: model.OrderSide,
        order_type: model.OrderType,
        quantity: model.Quantity,
        time_in_force: model.TimeInForce | None = None,
        price: model.Price | None = None,
        post_only: bool | None = None,
        reduce_only: bool | None = None,
        quote_quantity: bool | None = None,
        position_side: model.PositionSide | None = None,
        attach_algo_ords: typing.Sequence[dict] | None = None,
        px_usd: str | None = None,
        px_vol: str | None = None,
        outcome: str | None = None,
        slippage_pct: str | None = None,
    ) -> typing.Any: ...
    def place_algo_order(
        self,
        trader_id: model.TraderId,
        strategy_id: model.StrategyId,
        instrument_id: model.InstrumentId,
        td_mode: OKXTradeMode,
        client_order_id: model.ClientOrderId,
        order_side: model.OrderSide,
        order_type: model.OrderType,
        quantity: model.Quantity,
        trigger_price: model.Price | None = None,
        trigger_type: model.TriggerType | None = None,
        limit_price: model.Price | None = None,
        reduce_only: bool | None = None,
        close_fraction: str | None = None,
        callback_ratio: str | None = None,
        callback_spread: str | None = None,
        activation_price: model.Price | None = None,
    ) -> typing.Any: ...
    def cancel_algo_order(self, instrument_id: model.InstrumentId, algo_id: str) -> typing.Any: ...
    def cancel_order(
        self,
        instrument_id: model.InstrumentId,
        client_order_id: model.ClientOrderId | None = None,
        venue_order_id: model.VenueOrderId | None = None,
    ) -> typing.Any: ...
    def cancel_all_orders(self, instrument_id: model.InstrumentId) -> typing.Any: ...
    def amend_algo_order(
        self,
        instrument_id: model.InstrumentId,
        algo_id: str,
        new_trigger_price: model.Price | None = None,
        new_limit_price: model.Price | None = None,
        new_quantity: model.Quantity | None = None,
        new_callback_ratio: str | None = None,
        new_callback_spread: str | None = None,
        new_activation_price: model.Price | None = None,
        new_sl_trigger_price: model.Price | None = None,
        new_tp_trigger_price: model.Price | None = None,
        new_tp_order_price: str | None = None,
        new_tp_trigger_px_type: str | None = None,
        new_sl_order_price: str | None = None,
        new_sl_trigger_px_type: str | None = None,
    ) -> typing.Any: ...
    def cancel_algo_orders(
        self, orders: typing.Sequence[tuple[model.InstrumentId, str]]
    ) -> typing.Any: ...
    def cancel_advance_algo_order(
        self, instrument_id: model.InstrumentId, algo_id: str
    ) -> typing.Any: ...
    def get_server_time(self) -> typing.Any: ...
    def get_balance(self) -> typing.Any: ...

@typing.final
class OKXAlgoOrderStatus(enum.Enum):
    LIVE = ...
    PAUSE = ...
    EFFECTIVE = ...
    ORDER_PLACED = ...
    PARTIALLY_EFFECTIVE = ...
    CANCELED = ...
    FILLED = ...
    ORDER_FAILED = ...
    PARTIALLY_FAILED = ...
    UNKNOWN = ...

    def __init__(self, value: typing.Any) -> None: ...
    def __hash__(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def value(self) -> int: ...
    @staticmethod
    def variants() -> list[str]: ...
    @classmethod
    def from_str(cls, data: typing.Any) -> OKXAlgoOrderStatus: ...

@typing.final
class OKXContractType(enum.Enum):
    NONE = ...
    LINEAR = ...
    INVERSE = ...

    def __init__(self, value: typing.Any) -> None: ...
    def __hash__(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def value(self) -> int: ...
    @classmethod
    def from_str(cls, data: typing.Any) -> OKXContractType: ...
    @staticmethod
    def variants() -> list[str]: ...

@typing.final
class OKXEnvironment(enum.Enum):
    LIVE = ...
    DEMO = ...

    def __init__(self, value: typing.Any) -> None: ...
    def __hash__(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def value(self) -> int: ...
    @classmethod
    def variants(cls) -> list[str]: ...
    @classmethod
    def from_str(cls, data: typing.Any) -> OKXEnvironment: ...

@typing.final
class OKXGreeksType(enum.Enum):
    BS = ...
    PA = ...

@typing.final
class OKXInstrumentType(enum.Enum):
    ANY = ...
    SPOT = ...
    MARGIN = ...
    SWAP = ...
    FUTURES = ...
    OPTION = ...
    EVENTS = ...

    def __init__(self, value: typing.Any) -> None: ...
    def __hash__(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def value(self) -> int: ...
    @staticmethod
    def variants() -> list[str]: ...
    @classmethod
    def from_str(cls, data: typing.Any) -> OKXInstrumentType: ...

@typing.final
class OKXMarginMode(enum.Enum):
    NONE = ...
    ISOLATED = ...
    CROSS = ...

    def __init__(self, value: typing.Any) -> None: ...
    def __hash__(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def value(self) -> int: ...
    @staticmethod
    def variants() -> list[str]: ...
    @classmethod
    def from_str(cls, data: typing.Any) -> OKXMarginMode: ...

@typing.final
class OKXOrderStatus(enum.Enum):
    CANCELED = ...
    LIVE = ...
    PARTIALLY_FILLED = ...
    FILLED = ...
    MMP_CANCELED = ...
    UNKNOWN = ...

    def __init__(self, value: typing.Any) -> None: ...
    def __hash__(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def value(self) -> int: ...
    @staticmethod
    def variants() -> list[str]: ...
    @classmethod
    def from_str(cls, data: typing.Any) -> OKXOrderStatus: ...

@typing.final
class OKXPositionMode(enum.Enum):
    NET_MODE = ...
    LONG_SHORT_MODE = ...

    def __init__(self, value: typing.Any) -> None: ...
    def __hash__(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def value(self) -> int: ...
    @staticmethod
    def variants() -> list[str]: ...
    @classmethod
    def from_str(cls, data: typing.Any) -> OKXPositionMode: ...

@typing.final
class OKXRegion(enum.Enum):
    GLOBAL = ...
    EEA = ...
    US = ...

    def __init__(self, value: typing.Any) -> None: ...
    def __hash__(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def value(self) -> int: ...
    @classmethod
    def variants(cls) -> list[str]: ...
    @classmethod
    def from_str(cls, data: typing.Any) -> OKXRegion: ...

@typing.final
class OKXTradeMode(enum.Enum):
    CASH = ...
    ISOLATED = ...
    CROSS = ...
    SPOT_ISOLATED = ...

    def __init__(self, value: typing.Any) -> None: ...
    def __hash__(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def value(self) -> int: ...
    @staticmethod
    def variants() -> list[str]: ...
    @classmethod
    def from_str(cls, data: typing.Any) -> OKXTradeMode: ...

@typing.final
class OKXVipLevel(enum.Enum):
    VIP0 = ...
    VIP1 = ...
    VIP2 = ...
    VIP3 = ...
    VIP4 = ...
    VIP5 = ...
    VIP6 = ...
    VIP7 = ...
    VIP8 = ...
    VIP9 = ...

    def __init__(self, value: typing.Any) -> None: ...
    def __hash__(self) -> int: ...
    @property
    def name(self) -> str: ...
    @property
    def value(self) -> int: ...
    @staticmethod
    def variants() -> list[str]: ...
    @classmethod
    def from_str(cls, data: typing.Any) -> OKXVipLevel: ...

def get_okx_http_base_url(region: OKXRegion | None = None) -> str: ...
def get_okx_ws_url_business(
    environment: OKXEnvironment, region: OKXRegion | None = None
) -> str: ...
def get_okx_ws_url_private(environment: OKXEnvironment, region: OKXRegion | None = None) -> str: ...
def get_okx_ws_url_public(environment: OKXEnvironment, region: OKXRegion | None = None) -> str: ...
