from typing import List, Dict, Any, Optional, Union, Callable, Awaitable
from types import TracebackType

class FiiDiiActivity:
    buy_value: Optional[float]
    category: Optional[str]
    date: Optional[str]
    net_value: Optional[float]
    sell_value: Optional[float]

class MarketStatus:
    market: Optional[str]
    status: Optional[str]
    last_update_time: Optional[str]
    index: Optional[str]

class MarketStatusResponse:
    market_state: List[MarketStatus]

class Holiday:
    sr_no: int
    description: Optional[str]
    trading_date: Optional[str]
    week_day: Optional[str]

class ASMStock:
    indicator: Optional[str]
    time: Optional[str]
    company_name: Optional[str]
    symbol: Optional[str]

class GSMStock:
    company: Optional[str]
    isin: Optional[str]
    symbol: Optional[str]
    stage: Optional[int]

class EquityInfo:
    symbol: Optional[str]
    company_name: Optional[str]
    series: Optional[str]
    listing_date: Optional[str]
    paid_up_value: Optional[float]
    market_lot: Optional[str]
    isin: Optional[str]
    face_value: Optional[float]

class PriceVolumeRow:
    symbol: Optional[str]
    series: Optional[str]
    date: Optional[str]
    prev_close: Optional[str]
    open_price: Optional[str]
    high_price: Optional[str]
    low_price: Optional[str]
    last_price: Optional[str]
    close_price: Optional[str]
    average_price: Optional[str]
    total_traded_quantity: Optional[str]
    turnover: Optional[str]
    no_of_trades: Optional[str]

class FinanceClient:
    def __init__(self) -> None: ...
    def _initialize_session(self) -> None: ...
    def get_market_status(self) -> MarketStatusResponse: ...
    def get_market_status_df(self) -> Any: ...
    def get_holidays(self) -> Any: ...
    def get_fii_dii_activity(self) -> List[FiiDiiActivity]: ...
    def get_fii_dii_activity_df(self) -> Any: ...
    def get_market_turnover(self) -> Any: ...
    
    # Equities
    def price_volume_data(self, symbol: str, from_date: str, to_date: str) -> List[PriceVolumeRow]: ...
    def price_volume_data_df(self, symbol: str, from_date: str, to_date: str) -> Any: ...
    def price_volume_data_raw(self, symbol: str, from_date: str, to_date: str) -> bytes: ...
    def deliverable_position_data(self, symbol: str, from_date: str, to_date: str) -> Dict[str, List[Any]]: ...
    def deliverable_position_data_df(self, symbol: str, from_date: str, to_date: str) -> Any: ...
    def deliverable_position_data_raw(self, symbol: str, from_date: str, to_date: str) -> bytes: ...
    def bhav_copy_equities(self, date: str) -> Dict[str, List[Any]]: ...
    def bhav_copy_equities_df(self, date: str) -> Any: ...
    def bhav_copy_equities_raw(self, date: str) -> bytes: ...
    def get_equity_list(self) -> List[EquityInfo]: ...
    def get_equity_list_df(self) -> Any: ...
    def get_equity_list_raw(self) -> bytes: ...
    def bulk_deal_data(self, from_date: str, to_date: str) -> Dict[str, List[Any]]: ...
    def bulk_deal_data_df(self, from_date: str, to_date: str) -> Any: ...
    def bulk_deal_data_raw(self, from_date: str, to_date: str) -> bytes: ...
    def block_deals_data(self, from_date: str, to_date: str) -> Dict[str, List[Any]]: ...
    def block_deals_data_df(self, from_date: str, to_date: str) -> Any: ...
    def block_deals_data_raw(self, from_date: str, to_date: str) -> bytes: ...
    def short_selling_data(self, from_date: str, to_date: str) -> Dict[str, List[Any]]: ...
    def short_selling_data_df(self, from_date: str, to_date: str) -> Any: ...
    def short_selling_data_raw(self, from_date: str, to_date: str) -> bytes: ...
    def get_52week_high_low(self, mode: str) -> Any: ...
    def get_top_gainers(self) -> Any: ...
    def get_top_losers(self) -> Any: ...
    def get_most_active(self, mode: str) -> Any: ...
    def get_advances_declines(self) -> Any: ...
    def get_monthly_settlement_stats(self, fin_year: str) -> Any: ...
    def get_equity_quote(self, symbol: str) -> Any: ...
    
    # Indices
    def get_all_indices(self) -> Any: ...
    def get_index_constituents(self, index: str) -> Any: ...
    def get_index_history(self, index: str, from_date: str, to_date: str) -> Any: ...
    def get_index_yield(self, index: str, from_date: str, to_date: str) -> Any: ...
    def get_india_vix_history(self, from_date: str, to_date: str) -> Any: ...
    def get_total_returns_index(self, index: str, from_date: str, to_date: str) -> Any: ...
    
    # Derivatives
    def get_option_chain(self, symbol: str, is_index: bool) -> Any: ...
    def bhav_copy_derivatives(self, date: str, segment: str) -> Dict[str, List[Any]]: ...
    def bhav_copy_derivatives_df(self, date: str, segment: str) -> Any: ...
    def bhav_copy_derivatives_raw(self, date: str, segment: str) -> bytes: ...
    def get_fo_sec_ban(self) -> Any: ...
    def get_span_margins(self, date: str) -> Dict[str, List[Any]]: ...
    def get_span_margins_df(self, date: str) -> Any: ...
    def get_span_margins_raw(self, date: str) -> bytes: ...
    def get_fo_ban_list(self, date: str) -> Dict[str, List[Any]]: ...
    def get_fo_ban_list_df(self, date: str) -> Any: ...
    def get_fo_ban_list_raw(self, date: str) -> bytes: ...
    def get_participant_volume(self, date: str) -> Dict[str, List[Any]]: ...
    def get_participant_volume_df(self, date: str) -> Any: ...
    def get_participant_volume_raw(self, date: str) -> bytes: ...
    def get_oi_limits_cli(self, date: str) -> str: ...
    def get_oi_limits_cli_raw(self, date: str) -> bytes: ...
    
    # Corporate
    def get_corporate_actions(self) -> Any: ...
    def get_financial_results(self, symbol: str, from_date: str, to_date: str, period: str) -> Any: ...
    def get_financial_details(self, xbrl_url: str) -> Any: ...
    def get_insider_trades(self, from_date: str, to_date: str) -> Any: ...
    def get_insider_trades_df(self, from_date: str, to_date: str) -> Any: ...
    
    # SLB
    def get_slb_bhavcopy(self, date: str) -> Dict[str, List[Any]]: ...
    def get_slb_bhavcopy_df(self, date: str) -> Any: ...
    def get_slb_bhavcopy_raw(self, date: str) -> bytes: ...
    def get_slb_eligible(self) -> Any: ...
    def get_slb_open_positions(self, series: str) -> Any: ...
    def get_slb_series_master(self) -> Any: ...
    
    # Currency
    def get_live_currency_market(self) -> Any: ...
    def get_currency_bhavcopy(self, date: str) -> Dict[str, List[Any]]: ...
    def get_currency_bhavcopy_df(self, date: str) -> Any: ...
    def get_currency_bhavcopy_raw(self, date: str) -> bytes: ...
    
    # Commodities & MCX
    def get_live_commodities_market(self) -> Any: ...
    def get_nse_commodities_bhavcopy(self, date: str) -> Dict[str, List[Any]]: ...
    def get_nse_commodities_bhavcopy_df(self, date: str) -> Any: ...
    def get_nse_commodities_bhavcopy_raw(self, date: str) -> bytes: ...
    def get_mcx_bhavcopy(self, date: str) -> bytes: ...
    
    # Macro
    def get_fii_stats(self, date: str) -> bytes: ...
    
    # Surveillance
    def get_asm_stocks(self) -> Any: ...
    def get_gsm_stocks(self) -> List[GSMStock]: ...
    def get_short_ban_stocks(self) -> Any: ...

class AsyncFinanceClient:
    def __init__(self) -> None: ...
    async def _initialize_session(self) -> None: ...
    async def get_market_status(self) -> MarketStatusResponse: ...
    async def get_holidays(self) -> Any: ...
    async def get_fii_dii_activity(self) -> List[FiiDiiActivity]: ...
    async def get_market_turnover(self) -> Any: ...
    
    # Equities
    async def price_volume_data(self, symbol: str, from_date: str, to_date: str) -> List[PriceVolumeRow]: ...
    async def price_volume_data_raw(self, symbol: str, from_date: str, to_date: str) -> bytes: ...
    async def deliverable_position_data(self, symbol: str, from_date: str, to_date: str) -> Dict[str, List[Any]]: ...
    async def deliverable_position_data_raw(self, symbol: str, from_date: str, to_date: str) -> bytes: ...
    async def bhav_copy_equities(self, date: str) -> Dict[str, List[Any]]: ...
    async def bhav_copy_equities_raw(self, date: str) -> bytes: ...
    async def get_equity_list(self) -> List[EquityInfo]: ...
    async def get_equity_list_raw(self) -> bytes: ...
    async def bulk_deal_data(self, from_date: str, to_date: str) -> Dict[str, List[Any]]: ...
    async def bulk_deal_data_raw(self, from_date: str, to_date: str) -> bytes: ...
    async def block_deals_data(self, from_date: str, to_date: str) -> Dict[str, List[Any]]: ...
    async def block_deals_data_raw(self, from_date: str, to_date: str) -> bytes: ...
    async def short_selling_data(self, from_date: str, to_date: str) -> Dict[str, List[Any]]: ...
    async def short_selling_data_raw(self, from_date: str, to_date: str) -> bytes: ...
    async def get_52week_high_low(self, mode: str) -> Any: ...
    async def get_top_gainers(self) -> Any: ...
    async def get_top_losers(self) -> Any: ...
    async def get_most_active(self, mode: str) -> Any: ...
    async def get_advances_declines(self) -> Any: ...
    async def get_monthly_settlement_stats(self, fin_year: str) -> Any: ...
    async def get_equity_quote(self, symbol: str) -> Any: ...
    
    # Indices
    async def get_all_indices(self) -> Any: ...
    async def get_index_constituents(self, index: str) -> Any: ...
    async def get_index_history(self, index: str, from_date: str, to_date: str) -> Any: ...
    async def get_index_yield(self, index: str, from_date: str, to_date: str) -> Any: ...
    async def get_india_vix_history(self, from_date: str, to_date: str) -> Any: ...
    async def get_total_returns_index(self, index: str, from_date: str, to_date: str) -> Any: ...
    
    # Derivatives
    async def get_option_chain(self, symbol: str, is_index: bool) -> Any: ...
    async def bhav_copy_derivatives(self, date: str, segment: str) -> Dict[str, List[Any]]: ...
    async def bhav_copy_derivatives_raw(self, date: str, segment: str) -> bytes: ...
    async def get_fo_sec_ban(self) -> Any: ...
    async def get_span_margins(self, date: str) -> Dict[str, List[Any]]: ...
    async def get_span_margins_raw(self, date: str) -> bytes: ...
    async def get_fo_ban_list(self, date: str) -> Dict[str, List[Any]]: ...
    async def get_fo_ban_list_raw(self, date: str) -> bytes: ...
    async def get_participant_volume(self, date: str) -> Dict[str, List[Any]]: ...
    async def get_participant_volume_raw(self, date: str) -> bytes: ...
    async def get_oi_limits_cli(self, date: str) -> str: ...
    async def get_oi_limits_cli_raw(self, date: str) -> bytes: ...
    
    # Corporate
    async def get_corporate_actions(self) -> Any: ...
    async def get_financial_results(self, symbol: str, from_date: str, to_date: str, period: str) -> Any: ...
    async def get_financial_details(self, xbrl_url: str) -> Any: ...
    async def get_insider_trades(self, from_date: str, to_date: str) -> Any: ...
    
    # SLB
    async def get_slb_bhavcopy(self, date: str) -> Dict[str, List[Any]]: ...
    async def get_slb_bhavcopy_raw(self, date: str) -> bytes: ...
    async def get_slb_eligible(self) -> Any: ...
    async def get_slb_open_positions(self, series: str) -> Any: ...
    async def get_slb_series_master(self) -> Any: ...
    
    # Currency
    async def get_live_currency_market(self) -> Any: ...
    async def get_currency_bhavcopy(self, date: str) -> Dict[str, List[Any]]: ...
    async def get_currency_bhavcopy_raw(self, date: str) -> bytes: ...
    
    # Commodities & MCX
    async def get_live_commodities_market(self) -> Any: ...
    async def get_nse_commodities_bhavcopy(self, date: str) -> Dict[str, List[Any]]: ...
    async def get_nse_commodities_bhavcopy_raw(self, date: str) -> bytes: ...
    async def get_mcx_bhavcopy(self, date: str) -> bytes: ...
    
    # Macro
    async def get_fii_stats(self, date: str) -> bytes: ...
    
    # Surveillance
    async def get_asm_stocks(self) -> Any: ...
    async def get_gsm_stocks(self) -> List[GSMStock]: ...
    async def get_short_ban_stocks(self) -> Any: ...

class MarketStream:
    def __init__(self, url: str) -> None: ...
    def listen(self, callback: Callable[[Union[str, bytes]], Any]) -> None: ...

class BhavArchive:
    def __init__(self) -> None: ...
    def archive_equities(self, dates: List[str], output_path: str) -> tuple[int, List[str]]: ...
