# 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__ = [
    "BYBIT",
    "BYBIT_CLIENT_ID",
    "BYBIT_VENUE",
    "BybitDataClientConfig",
    "BybitDataClientFactory",
    "BybitEnvironment",
    "BybitExecutionClientConfig",
    "BybitExecutionClientFactory",
    "BybitMarginAction",
    "BybitMarginBorrowResult",
    "BybitMarginRepayResult",
    "BybitMarginStatusResult",
    "BybitPositionIdx",
    "BybitPositionMode",
    "BybitProductType",
    "BybitTickerData",
]

BYBIT: str
BYBIT_CLIENT_ID: model.ClientId
BYBIT_VENUE: model.Venue

@typing.final
class BybitAccountDetails: ...

@typing.final
class BybitApiKeyPermissions: ...

@typing.final
class BybitDataClientConfig:
    @property
    def product_types(self) -> list[BybitProductType]: ...
    @property
    def environment(self) -> BybitEnvironment: ...
    @property
    def base_url_http(self) -> str | None: ...
    @property
    def base_url_ws_public(self) -> str | None: ...
    @property
    def base_url_ws_private(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 heartbeat_interval_secs(self) -> int: ...
    @property
    def recv_window_ms(self) -> int: ...
    @property
    def update_instruments_interval_mins(self) -> int | None: ...
    @property
    def transport_backend(self) -> network.TransportBackend: ...
    def __init__(
        self,
        product_types: typing.Sequence[BybitProductType] | None = None,
        environment: BybitEnvironment | None = None,
        api_key: str | None = None,
        api_secret: str | None = None,
        base_url_http: str | None = None,
        base_url_ws_public: str | None = None,
        base_url_ws_private: 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,
        heartbeat_interval_secs: int | None = None,
        recv_window_ms: int | None = None,
        update_instruments_interval_mins: int | None = None,
        instrument_status_poll_secs: int | None = None,
        transport_backend: network.TransportBackend | None = None,
    ) -> None: ...
    @property
    def instrument_status_poll_secs(self) -> int | None: ...
    @property
    def has_proxy_url(self) -> bool: ...

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

@typing.final
class BybitExecutionClientConfig:
    @property
    def product_types(self) -> list[BybitProductType]: ...
    @property
    def environment(self) -> BybitEnvironment: ...
    @property
    def base_url_http(self) -> str | None: ...
    @property
    def base_url_ws_private(self) -> str | None: ...
    @property
    def base_url_ws_trade(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 heartbeat_interval_secs(self) -> int: ...
    @property
    def auth_timeout_secs(self) -> int | None: ...
    @property
    def recv_window_ms(self) -> int: ...
    @property
    def account_id(self) -> model.AccountId | None: ...
    @property
    def use_spot_position_reports(self) -> bool: ...
    @property
    def auto_repay_spot_borrows(self) -> bool: ...
    @property
    def margin_mode(self) -> BybitMarginMode | None: ...
    @property
    def transport_backend(self) -> network.TransportBackend: ...
    def __init__(
        self,
        product_types: typing.Sequence[BybitProductType] | None = None,
        environment: BybitEnvironment | None = None,
        api_key: str | None = None,
        api_secret: str | None = None,
        base_url_http: str | None = None,
        base_url_ws_private: str | None = None,
        base_url_ws_trade: 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,
        heartbeat_interval_secs: int | None = None,
        auth_timeout_secs: int | None = None,
        recv_window_ms: int | None = None,
        account_id: model.AccountId | None = None,
        use_spot_position_reports: bool | None = None,
        auto_repay_spot_borrows: bool | None = None,
        margin_mode: BybitMarginMode | None = None,
        smp_type: str | None = None,
        transport_backend: network.TransportBackend | None = None,
    ) -> None: ...
    @property
    def smp_type(self) -> str | None: ...
    @property
    def has_proxy_url(self) -> bool: ...

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

@typing.final
class BybitFeeRate: ...

@typing.final
class BybitHttpClient:
    def __init__(
        self,
        api_key: str | None = None,
        api_secret: str | None = None,
        base_url: str | None = None,
        demo: bool = False,
        testnet: bool = False,
        timeout_secs: int = 60,
        max_retries: int = 3,
        retry_delay_ms: int = 1000,
        retry_delay_max_ms: int = 10000,
        recv_window_ms: int = 5000,
        proxy_url: str | None = None,
    ) -> None: ...
    @property
    def base_url(self) -> str: ...
    @property
    def api_key(self) -> str | None: ...
    @property
    def api_key_masked(self) -> str | None: ...
    def cache_instrument(self, instrument: typing.Any) -> None: ...
    def cancel_all_requests(self) -> None: ...
    def set_use_spot_position_reports(self, value: bool) -> None: ...
    def set_margin_mode(self, margin_mode: BybitMarginMode) -> typing.Any: ...
    def get_account_details(self) -> typing.Any: ...
    def set_leverage(
        self, product_type: BybitProductType, symbol: str, buy_leverage: str, sell_leverage: str
    ) -> typing.Any: ...
    def switch_mode(
        self,
        product_type: BybitProductType,
        mode: BybitPositionMode,
        symbol: str | None = None,
        coin: str | None = None,
    ) -> typing.Any: ...
    def get_spot_borrow_amount(self, coin: str) -> typing.Any: ...
    def borrow_spot(self, coin: str, amount: model.Quantity) -> typing.Any: ...
    def repay_spot_borrow(self, coin: str, amount: model.Quantity | None = None) -> typing.Any: ...
    def repay_spot_borrow_with_conversion(
        self, coin: str, amount: model.Quantity | None = None
    ) -> typing.Any: ...
    def request_instruments(
        self,
        product_type: BybitProductType,
        symbol: str | None = None,
        base_coin: str | None = None,
    ) -> typing.Any: ...
    def request_instrument_statuses(self, product_type: BybitProductType) -> typing.Any: ...
    def request_tickers(self, params: BybitTickersParams) -> typing.Any: ...
    def submit_order(
        self,
        account_id: model.AccountId,
        product_type: BybitProductType,
        instrument_id: model.InstrumentId,
        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,
        trigger_price: model.Price | None = None,
        post_only: bool | None = None,
        reduce_only: bool = False,
        is_quote_quantity: bool = False,
        is_leverage: bool = False,
        position_idx: BybitPositionIdx | None = None,
        bbo_side_type: str | None = None,
        bbo_level: str | None = None,
        smp_type: str | None = None,
        native_tp_sl: BybitNativeTpSlParams | None = None,
    ) -> typing.Any: ...
    def modify_order(
        self,
        account_id: model.AccountId,
        product_type: BybitProductType,
        instrument_id: model.InstrumentId,
        client_order_id: model.ClientOrderId | None = None,
        venue_order_id: model.VenueOrderId | None = None,
        quantity: model.Quantity | None = None,
        price: model.Price | None = None,
    ) -> typing.Any: ...
    def cancel_order(
        self,
        account_id: model.AccountId,
        product_type: BybitProductType,
        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,
        account_id: model.AccountId,
        product_type: BybitProductType,
        instrument_id: model.InstrumentId,
    ) -> typing.Any: ...
    def query_order(
        self,
        account_id: model.AccountId,
        product_type: BybitProductType,
        instrument_id: model.InstrumentId,
        client_order_id: model.ClientOrderId | None = None,
        venue_order_id: model.VenueOrderId | None = None,
    ) -> typing.Any: ...
    def request_trades(
        self,
        product_type: BybitProductType,
        instrument_id: model.InstrumentId,
        limit: int | None = None,
    ) -> typing.Any: ...
    def request_funding_rates(
        self,
        product_type: BybitProductType,
        instrument_id: model.InstrumentId,
        start: datetime.datetime | None = None,
        end: datetime.datetime | None = None,
        limit: int | None = None,
    ) -> typing.Any: ...
    def request_orderbook_snapshot(
        self,
        product_type: BybitProductType,
        instrument_id: model.InstrumentId,
        limit: int | None = None,
    ) -> typing.Any: ...
    def request_bars(
        self,
        product_type: BybitProductType,
        bar_type: model.BarType,
        start: datetime.datetime | None = None,
        end: datetime.datetime | None = None,
        limit: int | None = None,
        timestamp_on_close: bool = True,
    ) -> typing.Any: ...
    def request_fee_rates(
        self,
        product_type: BybitProductType,
        symbol: str | None = None,
        base_coin: str | None = None,
    ) -> typing.Any: ...
    def request_account_state(
        self, account_type: BybitAccountType, account_id: model.AccountId
    ) -> typing.Any: ...
    def request_order_status_reports(
        self,
        account_id: model.AccountId,
        product_type: BybitProductType,
        instrument_id: model.InstrumentId | None = None,
        open_only: bool = False,
        start: datetime.datetime | None = None,
        end: datetime.datetime | None = None,
        limit: int | None = None,
    ) -> typing.Any: ...
    def request_fill_reports(
        self,
        account_id: model.AccountId,
        product_type: BybitProductType,
        instrument_id: model.InstrumentId | None = None,
        start: int | None = None,
        end: int | None = None,
        limit: int | None = None,
    ) -> typing.Any: ...
    def request_position_status_reports(
        self,
        account_id: model.AccountId,
        product_type: BybitProductType,
        instrument_id: model.InstrumentId | None = None,
    ) -> typing.Any: ...

@typing.final
class BybitMarginBorrowResult:
    def __init__(
        self, coin: str, amount: str, success: bool, message: str, ts_event: int, ts_init: int
    ) -> None: ...
    @property
    def coin(self) -> str: ...
    @property
    def amount(self) -> str: ...
    @property
    def success(self) -> bool: ...
    @property
    def message(self) -> str: ...
    @property
    def ts_event(self) -> int: ...
    @property
    def ts_init(self) -> int: ...

@typing.final
class BybitMarginRepayResult:
    def __init__(
        self,
        coin: str,
        amount: str | None,
        success: bool,
        result_status: str,
        message: str,
        ts_event: int,
        ts_init: int,
    ) -> None: ...
    @property
    def coin(self) -> str: ...
    @property
    def amount(self) -> str | None: ...
    @property
    def success(self) -> bool: ...
    @property
    def result_status(self) -> str: ...
    @property
    def message(self) -> str: ...
    @property
    def ts_event(self) -> int: ...
    @property
    def ts_init(self) -> int: ...

@typing.final
class BybitMarginStatusResult:
    def __init__(self, coin: str, borrow_amount: str, ts_event: int, ts_init: int) -> None: ...
    @property
    def coin(self) -> str: ...
    @property
    def borrow_amount(self) -> str: ...
    @property
    def ts_event(self) -> int: ...
    @property
    def ts_init(self) -> int: ...

@typing.final
class BybitNativeTpSlParams:
    def __init__(
        self,
        take_profit: str | None = None,
        stop_loss: str | None = None,
        tp_trigger_by: str | None = None,
        sl_trigger_by: str | None = None,
        tp_order_type: str | None = None,
        sl_order_type: str | None = None,
        tp_limit_price: str | None = None,
        sl_limit_price: str | None = None,
        tpsl_mode: str | None = None,
        close_on_trigger: bool | None = None,
        order_iv: str | None = None,
        mmp: bool | None = None,
    ) -> None: ...

@typing.final
class BybitOrder: ...

@typing.final
class BybitOrderCursorList: ...

@typing.final
class BybitRawHttpClient:
    def __init__(
        self,
        api_key: str | None = None,
        api_secret: str | None = None,
        base_url: str | None = None,
        demo: bool = False,
        testnet: bool = False,
        timeout_secs: int = 60,
        max_retries: int = 3,
        retry_delay_ms: int = 1000,
        retry_delay_max_ms: int = 10000,
        recv_window_ms: int = 5000,
        proxy_url: str | None = None,
    ) -> None: ...
    @property
    def base_url(self) -> str: ...
    @property
    def api_key(self) -> str | None: ...
    @property
    def recv_window_ms(self) -> int: ...
    def cancel_all_requests(self) -> None: ...
    def get_server_time(self) -> typing.Any: ...
    def get_open_orders(
        self,
        category: BybitProductType,
        symbol: str | None = None,
        base_coin: str | None = None,
        settle_coin: str | None = None,
        order_id: str | None = None,
        order_link_id: str | None = None,
        open_only: BybitOpenOnly | None = None,
        order_filter: BybitOrderFilter | None = None,
        limit: int | None = None,
        cursor: str | None = None,
    ) -> typing.Any: ...

@typing.final
class BybitServerTime: ...

@typing.final
class BybitTickerData: ...

@typing.final
class BybitTickersParams:
    def __init__(
        self,
        category: BybitProductType,
        symbol: str | None = None,
        base_coin: str | None = None,
        exp_date: str | None = None,
    ) -> None: ...

@typing.final
class BybitAccountType(enum.Enum):
    UNIFIED = ...
    FUND = ...

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

@typing.final
class BybitCancelType(enum.Enum):
    CancelByUser = ...
    CancelByReduceOnly = ...
    CancelByPrepareLiq = ...
    CancelAllBeforeLiq = ...
    CancelByPrepareAdl = ...
    CancelAllBeforeAdl = ...
    CancelByPrepareLackOfMargin = ...
    CancelByPrepareOrderFilter = ...
    CancelByPrepareOrderMarginCheckFailed = ...
    CancelByPrepareOrderCommission = ...
    CancelByPrepareOrderRms = ...
    CancelByPrepareOrderOther = ...
    CancelByRiskLimit = ...
    CancelOnDisconnect = ...
    CancelByStopOrdersExceeded = ...
    CancelByPzMarketClose = ...
    CancelByMarginCheckFailed = ...
    CancelByPzTakeover = ...
    CancelByAdmin = ...
    CancelBySettle = ...
    CancelByTpSlTsClear = ...
    CancelByAmendNotModified = ...
    CancelByPzCancel = ...
    CancelBySmp = ...
    CancelByDcp = ...
    CancelByRebalance = ...
    CancelByOcoTpCanceledBySlTriggered = ...
    CancelByOcoSlCanceledByTpTriggered = ...
    CancelByCannotAffordOrderCost = ...
    CancelByPmTrialMmOverEquity = ...
    CancelByAccountBlocking = ...
    CancelByDelivery = ...
    CancelByMmpTriggered = ...
    CancelByCrossSelfMuch = ...
    CancelByCrossReachMaxTradeNum = ...
    CancelByCrossSelfMatch = ...
    CancelBySelfMatchPrevention = ...
    Other = ...

@typing.final
class BybitEnvironment(enum.Enum):
    MAINNET = ...
    DEMO = ...
    TESTNET = ...

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

@typing.final
class BybitMarginAction(enum.Enum):
    BORROW = ...
    REPAY = ...
    GET_BORROW_AMOUNT = ...

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

@typing.final
class BybitMarginMode(enum.Enum):
    ISOLATED_MARGIN = ...
    REGULAR_MARGIN = ...
    PORTFOLIO_MARGIN = ...

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

@typing.final
class BybitOpenOnly(enum.Enum):
    OpenOnly = ...
    ClosedRecent = ...

@typing.final
class BybitOrderFilter(enum.Enum):
    Order = ...
    StopOrder = ...
    TpslOrder = ...
    OcoOrder = ...
    BidirectionalTpslOrder = ...

@typing.final
class BybitOrderSide(enum.Enum):
    Unknown = ...
    Buy = ...
    Sell = ...

@typing.final
class BybitOrderStatus(enum.Enum):
    Created = ...
    New = ...
    Rejected = ...
    PartiallyFilled = ...
    PartiallyFilledCanceled = ...
    Filled = ...
    Canceled = ...
    Untriggered = ...
    Triggered = ...
    Deactivated = ...

@typing.final
class BybitOrderType(enum.Enum):
    Market = ...
    Limit = ...
    Unknown = ...

@typing.final
class BybitPositionIdx(enum.Enum):
    ONE_WAY = ...
    BUY_HEDGE = ...
    SELL_HEDGE = ...

    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) -> BybitPositionIdx: ...

@typing.final
class BybitPositionMode(enum.Enum):
    MERGED_SINGLE = ...
    BOTH_SIDES = ...

    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) -> BybitPositionMode: ...

@typing.final
class BybitProductType(enum.Enum):
    SPOT = ...
    LINEAR = ...
    INVERSE = ...
    OPTION = ...

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

@typing.final
class BybitStopOrderType(enum.Enum):
    None_ = ...
    Unknown = ...
    TakeProfit = ...
    StopLoss = ...
    TrailingStop = ...
    Stop = ...
    PartialTakeProfit = ...
    PartialStopLoss = ...
    TpslOrder = ...
    OcoOrder = ...
    MmRateClose = ...
    BidirectionalTpslOrder = ...

@typing.final
class BybitTimeInForce(enum.Enum):
    Gtc = ...
    Ioc = ...
    Fok = ...
    PostOnly = ...
    Rpi = ...

@typing.final
class BybitTpSlMode(enum.Enum):
    Full = ...
    Partial = ...
    Unknown = ...

@typing.final
class BybitTriggerDirection(enum.Enum):
    None_ = ...
    RisesTo = ...
    FallsTo = ...

@typing.final
class BybitTriggerType(enum.Enum):
    None_ = ...
    LastPrice = ...
    IndexPrice = ...
    MarkPrice = ...

def bybit_bar_spec_to_interval(aggregation: model.BarAggregation, step: int) -> str: ...
def bybit_extract_raw_symbol(symbol: str) -> str: ...
def bybit_product_type_from_symbol(symbol: str) -> BybitProductType: ...
def bybit_resolve_position_idx(
    position_mode: BybitPositionMode | None,
    order_side: model.OrderSide,
    is_reduce_only: bool,
    manual_override: BybitPositionIdx | None = None,
) -> BybitPositionIdx | None: ...
