
    i                         d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl	m	Z	 ddl
mZ ddlmZ dd	lmZ dd
lmZ ddlmZmZ ddlZddlZddlmZ ddlmZ ddlmZmZ ddlmZ ddl m!Z! ddl"m#Z#m$Z$ ddl%m&Z& ddl'm(Z( ddl)m*Z* ddl+m,Z, ddl-m.Z.m/Z/m0Z0 ddl1m2Z2m3Z3 ddl4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z: ddl;m<Z< ddl=m>Z> ddl?m@Z@ ddlAmBZB  e@j                  eD      ZE ed       G d  d!             ZF G d" d#eGe      ZH G d$ d%      ZI G d& d'      ZJy)(a  
Unified TradingSuite class for simplified SDK initialization and management.

Author: @TexasCoding
Date: 2025-08-04

Overview:
    Provides a single, intuitive entry point for creating a complete trading
    environment with all components properly configured and connected. This
    replaces the complex factory functions with a clean, simple API.

Key Features:
    - Single-line initialization with sensible defaults
    - Automatic component wiring and dependency injection
    - Built-in connection management and error recovery
    - Feature flags for optional components
    - Configuration file and environment variable support

Example Usage:
    ```python
    # Simple one-liner with defaults
    suite = await TradingSuite.create("MNQ")

    # With specific configuration
    suite = await TradingSuite.create(
        "MNQ",
        timeframes=["1min", "5min", "15min"],
        features=["orderbook", "risk_manager"],
    )

    # From configuration file
    suite = await TradingSuite.from_config("config/trading.yaml")
    ```
    N)Iterator)AbstractAsyncContextManager)	dataclass)datetime)Decimal)Enum)Path)TracebackType)Anycast)ProjectX)ProjectXBase)EventBus	EventType)
Instrument)OrderManager)OrderChainBuilderOrderTracker)	OrderBook)PositionManager)ProjectXRealtimeClient)RealtimeDataManager)ManagedTrade
RiskConfigRiskManager)SessionConfigSessionType)StatisticsAggregator)DataManagerConfigOrderbookConfigOrderManagerConfigPositionManagerConfig)ProjectXClientProtocol)TradingSuiteStats)ProjectXLogger)
deprecatedT)frozenc                       e Zd ZU dZeed<   eed<   eed<   eed<   e	ed<   e
ed<   dZedz  ed	<   dZedz  ed
<   deez  deddfdZdeez  deddfdZ	 ddeez  dz  dedz  ddfdZ	 ddeez  dedz  defdZy)InstrumentContexta  
    Encapsulates all managers and data for a single financial instrument.

    This class holds all the components needed to trade and analyze a single
    instrument, providing a clean interface for multi-instrument trading.

    Attributes:
        symbol: The instrument symbol (e.g., "MNQ", "ES")
        instrument_info: The Instrument object with contract details
        data: Real-time data manager for OHLCV data
        orders: Order management system
        positions: Position tracking system
        event_bus: Event bus for this instrument's events
        orderbook: Level 2 market depth (optional)
        risk_manager: Risk management system (optional)
    symbolinstrument_infodataorders	positions	event_busN	orderbookrisk_managereventhandlerreturnc                 X   K   | j                   j                  ||       d{    y7 w)z
        Register event handler on this instrument's event bus.

        Args:
            event: Event type to listen for
            handler: Async callable to handle events
        N)r/   onselfr2   r3   s      S/home/work/apex_v16/venv/lib/python3.12/site-packages/project_x_py/trading_suite.pyr6   zInstrumentContext.onj   s"      nnw///    *(*c                 X   K   | j                   j                  ||       d{    y7 w)z
        Register one-time event handler on this instrument's event bus.

        Args:
            event: Event type to listen for
            handler: Async callable to handle event once
        N)r/   oncer7   s      r9   r<   zInstrumentContext.oncet   s"      nn!!%111r:   c                 X   K   | j                   j                  ||       d{    y7 w)z
        Remove event handler(s) from this instrument's event bus.

        Args:
            event: Event type to remove handler from (None for all)
            handler: Specific handler to remove (None for all)
        N)r/   offr7   s      r9   r>   zInstrumentContext.off~   s"      nn  000r:   timeoutc                 V   K   | j                   j                  ||       d{   S 7 w)a3  
        Wait for specific event to occur on this instrument's event bus.

        Args:
            event: Event type to wait for
            timeout: Optional timeout in seconds

        Returns:
            Event object when received

        Raises:
            TimeoutError: If timeout expires
        N)r/   wait_forr8   r2   r?   s      r9   rA   zInstrumentContext.wait_for   s%       ^^,,UG<<<<    )')NNN)__name__
__module____qualname____doc__str__annotations__r   r   r   r   r   r0   r   r1   r   r   r   r6   r<   r>   floatrA        r9   r)   r)   N   s    " K
"&Iy4&'+L+$+0i#o 0 0 02	C 2# 2$ 2 KO
1_t+
1=@4Z
1	
1 ?C=_=/4t|=	=rN   r)   c                   $    e Zd ZdZdZdZdZdZdZy)Featuresz)Available feature flags for TradingSuite.r0   r1   trade_journalperformance_analyticsauto_reconnectN)	rF   rG   rH   rI   	ORDERBOOKRISK_MANAGERTRADE_JOURNALPERFORMANCE_ANALYTICSAUTO_RECONNECTrM   rN   r9   rP   rP      s    3I!L#M3%NrN   rP   c                       e Zd ZdZ	 	 	 	 	 	 	 	 	 	 	 ddedee   dz  dee   dz  dededed	e	dz  d
e
dz  dedz  dedz  dedz  dedz  fdZde	fdZde
fdZdefdZdefdZdefdZy)TradingSuiteConfigz.Configuration for TradingSuite initialization.N
instrument
timeframesfeaturesinitial_daysauto_connecttimezoneorder_manager_configposition_manager_configdata_manager_configorderbook_configrisk_configsession_configc                     || _         |xs dg| _        |xs g | _        || _        || _        || _        || _        || _        |	| _        |
| _	        || _
        || _        y )N5min)r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   )r8   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   s                r9   __init__zTradingSuiteConfig.__init__   sk     %$0 B(( $8!'>$#6  0&,rN   r4   c                     | j                   r| j                   S t        j                  | j                  v dt        j                  | j                  v ddS )z
        Get configuration for OrderManager.

        Returns:
            OrderManagerConfig: The configuration for the OrderManager.
        T)enable_bracket_ordersenable_trailing_stopsauto_risk_managementenable_order_validation)ra   rP   rU   r]   r8   s    r9   get_order_manager_configz+TradingSuiteConfig.get_order_manager_config   sM     $$,,,%-%:%:dmm%K%)$,$9$9T]]$J'+	
 	
rN   c                     | j                   r| j                   S t        j                  | j                  v t        j                  | j                  v ddS )z
        Get configuration for PositionManager.

        Returns:
            PositionManagerConfig: The configuration for the PositionManager.
        F)enable_risk_monitoringenable_correlation_analysisenable_portfolio_rebalancing)rb   rP   rU   r]   rW   ro   s    r9   get_position_manager_configz.TradingSuiteConfig.get_position_manager_config   sM     ''///&.&;&;t}}&L+3+I+I}},,1	
 	
rN   c                     | j                   r| j                   S ddt        j                  | j                  v dddddddddS )z
        Get configuration for RealtimeDataManager.

        Returns:
            DataManagerConfig: The configuration for the RealtimeDataManager.
          Tg      .@g?g      >@)memory_target_percentmemory_pressure_thresholdcpu_pressure_thresholdmonitoring_interval)max_bars_per_timeframeenable_tick_dataenable_level2_datadata_validationauto_cleanupenable_dynamic_limitsresource_config)rc   rP   rT   r]   ro   s    r9   get_data_manager_configz*TradingSuiteConfig.get_data_manager_config   sU     ##+++&* $"*"4"4"E# %))--0*-'+	 
 	
rN   c                 t    | j                   r| j                   S ddt        j                  | j                  v ddS )z
        Get configuration for OrderBook.

        Returns:
            OrderbookConfig: The configuration for the OrderBook.
        d   rw   T)max_depth_levelsmax_trade_historyenable_analyticsenable_pattern_detection)rd   rP   rW   r]   ro   s    r9   get_orderbook_configz'TradingSuiteConfig.get_orderbook_config   s>       ((( #!% ( > >$-- O(,	
 	
rN   c                     | j                   r| j                   S t        t        d      t        d      ddddt        d            S )z
        Get configuration for RiskManager.

        Returns:
            RiskConfig: The configuration for the RiskManager.
        z0.01z0.03   Tz2.0)max_risk_per_trademax_daily_lossmax_positionsuse_stop_lossuse_take_profituse_trailing_stopsdefault_risk_reward_ratio)re   r   r   ro   s    r9   get_risk_configz"TradingSuiteConfig.get_risk_config  sG     ###&v"6? #&-en
 	
rN   )NN   TzAmerica/ChicagoNNNNNN)rF   rG   rH   rI   rJ   listrP   intboolr!   r"   r   r    r   r   ri   rp   ru   r   r   r   rM   rN   r9   rZ   rZ      s   8
 (,*.!):>@D8<37)-/3-- I$- x.4'	-
 - - - 147- "7!=- /5- *D0-  $&- &,-8
*< 
 
-B 
 
): 
0
o 
 
 
rN   rZ   c                   @   e Zd ZdZ	 dNdedededeee	f   dz  fdZ
e	 	 	 	 	 dOdeee   z  dz  d	edz  d
ee   dz  dee   dz  dedz  dedd fd       Zedee   dedededeee	f   f
d       ZdPdZedeee	f   ddfd       Zededd fd       Zed	ededd fd       ZdPdZdPdZdPdZdPdZdPdZdPdZdPdZdQdZdee   dz  d edz  d!edz  ddfd"Z e!de"fd#       Z#e!defd$       Z$e!defd%       Z%e!defd&       Z&e!defd'       Z'e!defd(       Z(e!defd)       Z)e!dedz  fd*       Z*d+e+ez  d,eddfd-Z,d+e+ez  d,eddfd.Z-	 dRd+e+ez  dz  d,edz  ddfd/Z.dNd0ede/fd1Z0de1fd2Z2	 	 dRd3e3dz  d4e3dz  de4fd5Z5	 dNd+e+ez  d6e3dz  defd7Z6de7fd8Z8 e9d9d:d;d<=      de7fd>       Z:d?e;ddfd@Z<	 dNdAed?e;dz  defdBZ=dSdAedeeef   fdCZ>dDede	fdEZ?de@fdFZAdeBe   fdGZCdDede"fdHZDdeBe   fdIZEdeBe	   fdJZFdeBeGee	f      fdKZHdLedefdMZIy)TTradingSuitea  
    Unified trading suite providing simplified access to all SDK components.

    This class replaces the complex factory functions with a clean, intuitive
    API that handles all initialization, connection, and dependency management
    automatically.

    Attributes:
        instrument: Trading instrument symbol
        data: Real-time data manager for OHLCV data
        orders: Order management system
        positions: Position tracking system
        orderbook: Level 2 market depth (if enabled)
        risk_manager: Risk management system (if enabled)
        client: Underlying ProjectX API client
        realtime: WebSocket connection manager
        config: Suite configuration
        events: Unified event bus for all components
    Nclientrealtime_clientconfiginstrument_contextsc           
         || _         || _        || _        |xs i | _        t	        | j                        dk(  | _        | j
                  r8| j                  r,t        t        | j                  j                                     nd| _	        |j                  | _        d| _
        t               | _        t        dd      | _        | | j                  _        || j                  _         || j                  _        |st%        |j                  |||j&                  |j(                  |j+                         | j                  |j,                        | _        t1        ||j3                         | j                        | _        | j4                  | j                  _        | j.                  | j                  _        d| _        d| _        d| _        d| _         tC        || j                  d| j.                  |jE                               | _#        | jF                  | j                  _$        tJ        jL                  |jN                  v rtQ        tS        tT        |      | j4                  | j                  | jF                  |jW                         	      | _        | j<                  | jF                  _,        | j<                  | j                  _,        n| j
                  r| j                  r | j                  jZ                  | _
        | j                  j\                  | j                  _        | j                  j^                  | j                  _        | j                  j`                  | j                  _$        | j                  jX                  r%| j                  jX                  | j                  _,        | j                  jb                  r%| j                  jb                  | j                  _1        d
| _2        d
| _3        ti        jj                         | _6        d| _7        | j                  r#tq        | j                  js                               n|j                  g}tt        jw                  d| d|jN                          y)a  
        Initialize TradingSuite with core components.

        Note: Use the factory methods (create, from_config, from_env) instead
        of instantiating directly.

        Args:
            client: ProjectX API client
            realtime_client: WebSocket realtime client
            config: Suite configuration
            instrument_contexts: Pre-built instrument contexts (for multi-instrument)
           Ng      @g      ?)	cache_ttlcomponent_timeoutr[   	project_xr   r\   r`   r   r/   rf   r   r/   r/   r1   data_managerr   r   order_managerr/   position_managerr   FzTradingSuite created for z with features: )<r   realtimer   _instrumentslen_is_single_instrumentnextitervalues_single_contextr[   _symbolr   eventsr   _stats_aggregatortrading_suiter   r   r\   r`   r   rf   _datar   rp   _ordersr   r   
_orderbook_risk_managerjournal	analyticsr   ru   
_positionsr   rP   rU   r]   r   r   r#   r   r1   r+   r-   r,   r.   r0   
_connected_initializedr   now_created_at_client_contextr   keysloggerinfo)r8   r   r   r   r   instrument_lists         r9   ri   zTradingSuite.__init__7  s   & ' ;N:SQS%():):%;q%@"
 ))d.?.? d''..012 	 ((-1 j "6!"
 04,(.%1@. #,!,,  /!,,557++%44	DJ (v>>@DKKDL
 48<<D""026**D""/ 15DO59D
  DL!DN .++!!ZZ99;DO 7;ooD""3 $$7%0"#96B"&,,"kk%)__!113&" 04/A/A,6:6H6H&&3 ))d.B.B"&"6"6"F"F 8<7K7K7R7R&&46:6J6J6O6O&&3:>:N:N:X:X&&7''44,,99 **7 ''117;7K7K7U7UD**4  !#<<> 	
 /3.?.?D""'')*fFWFWEX 	 	''8 9$oo.0	
rN   instrumentsr[   r\   r]   rf   kwargsr4   c                 T  K   |||g}|}n+|t        |t              r|g}|}n|}|d   }nt        d      t        d||xs dg|xs g D 	cg c]  }	t	        |	       c}	|d|}
t        j                         }|j                          d{   }	 |j                          d{    |j                  st        d      t        |j                  t        |j                  j                        |j                        }| j                  ||||
       d{   } | |||
|      }|j                          d{    ||_        |
j"                  r|j%                          d{    |S c c}	w 7 7 7 ]7 <7 # t&        $ r |j)                  ddd       d{  7    w xY ww)	a  
        Create a fully initialized TradingSuite with sensible defaults.

        This is the primary way to create a trading environment. It handles:
        - Authentication with ProjectX
        - WebSocket connection setup
        - Component initialization
        - Historical data loading
        - Market data subscriptions

        Args:
            instruments: Trading symbol(s) - str for single, list for multiple
            instrument: (Deprecated) Single trading symbol for backward compatibility
            timeframes: Data timeframes (default: ["5min"])
            features: Optional features to enable
            session_config: Optional session configuration
            **kwargs: Additional configuration options

        Returns:
            Fully initialized and connected TradingSuite

        Example:
            ```python
            # Single instrument (backward compatible)
            suite = await TradingSuite.create("MNQ")

            # Multiple instruments
            suite = await TradingSuite.create(["MNQ", "MES", "MCL"])

            # Access specific instruments
            mnq_context = suite["MNQ"]
            current_price = await mnq_context.data.get_current_price()
            ```
        Nr   z;Must provide either 'instruments' or 'instrument' parameterrh   )r[   r\   r]   rf   z$Failed to authenticate with ProjectX)	jwt_token
account_idr   rM   )
isinstancerJ   
ValueErrorrZ   rP   r   from_env
__aenter__authenticateaccount_infor   session_tokenidr   _create_instrument_contexts_setup_event_forwardingr   r_   _initialize	Exception	__aexit__)clsr   r[   r\   r]   rf   r   r   primary_instrumentfr   client_contextr   r   r   suites                   r9   createzTradingSuite.create  s    Z :#9)lO!+$+s+#.-%0""-%0^"M 
 $ 
)!-fX,4N<ahqk<)	

 
 "**,%0022$	%%'''&& !GHH 5 ..v22556}}O ),(G(G&) #
 9LME //111 %3E! ""'')))LQ = 3 (# 2 *  	 **4t<<<	s   AF(E/0F(E4F(E> (E6)A1E> E8"E> =E:>*E> (E<)E> .F(6E> 8E> :E> <E> >F%F F%%F(c                    K   dt         dt        t         t        f   ffdi t        j                         dt         dt        t         t        f   f fd}	 |D cg c]
  } ||       }}t        j
                  |ddi d{   }i }	|D ]9  }
t        |
t              r|
t        t        t         t        f   |
      \  }}||	|<   ; |	S c c}w 7 K# t        $ r\ 4 d{  7    j                  j                                d{  7   ddd      d{  7    # 1 d{  7  sw Y    xY ww xY ww)ap  
        Create InstrumentContext objects for multiple instruments in parallel.

        Args:
            instruments: List of instrument symbols
            client: Authenticated ProjectX client
            realtime_client: WebSocket client
            config: Suite configuration

        Returns:
            Dictionary mapping symbol to InstrumentContext
        r*   r4   c           
        K   	j                  |        d{   }t               }t        | 	
j                  
j                  
j                         |
j                        }t        	
j                         |      }t        	|d|
j                               }d}t        j                  
j                  v r(t        | |	
j                  
j                               }d}t        j                   
j                  v r3t#        t%        t&        	      |||
j)                               }||_        t-        | |||||||      }| |fS 7 6w)z#Create a single instrument context.Nr   r   r   )r   timezone_strr   r   )r*   r+   r,   r-   r.   r/   r0   r1   )get_instrumentr   r   r\   r`   r   rf   r   rp   r   ru   rP   rT   r]   r   r   rU   r   r   r#   r   r1   r)   )r*   r+   r/   r   r   r   r0   r1   contextr   r   r   s            r9   _create_single_contextzHTradingSuite._create_instrument_contexts.<locals>._create_single_contextF  sg     %+$9$9&$AAO !
I /!  /!,,557#%44	L )v>>@IM
  /#!)99;  I!!V__4%$!'!668	  L$$7*"#96B"/'%5!113  1= - ( /!$*##)	G 7?"C Bs   EED6Ec                   K   	  |        d{   \  }}4 d{    ||<   ddd      d{    ||fS 7 +7 7 # 1 d{  7  sw Y   xY w# t         $ r\ 4 d{  7   j                  j                                d{  7   ddd      d{  7    # 1 d{  7  sw Y    xY ww xY ww)z4Create context and track it immediately for cleanup.N)r   _cleanup_contextscopy)r*   symbol_resultr   r   cleanup_lockr   created_contextss      r9   $_create_single_context_with_trackingzVTradingSuite._create_instrument_contexts.<locals>._create_single_context_with_tracking  s     
/Ef/M)M&w' > >6=$]3> >$g--	 *N> > > > >  ' I I//0@0E0E0GHHHI I II I I	s   B?A <A >A AA A A B?A A  A AA	AA B<&A)'B<+#B&BB&B<B" B<&B8	,B/-B8	4B<<B?return_exceptionsTN)rJ   tupler)   asyncioLockgatherr   r   r   r   r   )r   r   r   r   r   r   r*   tasksresultsfinal_contextsresultr   r   r   r   s   ` ```       @@@r9   r   z(TradingSuite._create_instrument_contexts1  si    *D	# D	#sDU?U9V D	#P :<||~		3))*	 	 	 LWAG4V<E  $NNEJTJJG <>N! 1fi0 L #'uS2C-C'Df"M)0v&1 "!! K  	# E E++,<,A,A,CDDDE E EE E E		s   AE$C (C7C CAC EC E.C1/E3#D.DD.E'D*(E.E 	4D75E 	<EEc                    K   | j                   sy| j                   j                         D ]/  }|j                  j                  | j                         d{    1 y7 w)a4  
        Set up event forwarding from instrument EventBuses to the suite's main EventBus.

        This ensures that events emitted to instrument-specific EventBuses are also
        forwarded to the suite-level EventBus, allowing suite-level handlers to receive
        events from all instruments.
        N)r   r   r/   
forward_tor   )r8   r   s     r9   r   z$TradingSuite._setup_event_forwarding  sS        ((//1 	<G##..t{{;;;	<;s   AAAAcontextsc                   K   |syg }|j                         D ]Z  \  }}	 t        |j                  d      r)|j                  |j                  j	                                t        |j
                  d      r)|j                  |j
                  j	                                t        |j                  d      r)|j                  |j                  j	                                |j                  r?t        |j                  d      r)|j                  |j                  j	                                |j                  r?t        |j                  d      r)|j                  |j                  j	                                ] |r	 t        j                  |ddi d{    yy# t        $ r&}t        j                  d| d|        Y d}~d}~ww xY w7 8# t        $ r"}t        j                  d|        Y d}~yd}~ww xY ww)z
        Clean up partially created instrument contexts.

        Args:
            contexts: Dictionary of contexts that need cleanup
        NcleanupzError cleaning up context for z: r   Tz'Error during parallel context cleanup: )itemshasattrr,   appendr   r-   r.   r0   r1   r   r   warningr   r   )r   r   cleanup_tasksr*   r   es         r9   r   zTradingSuite._cleanup_contexts  s     '~~/ 	OOFGO7<<3!(()=)=)?@7>>95!(()?)?)AB7,,i8!(():):)B)B)DE$$1B1BI)N!(():):)B)B)DE''GG4H4H),T!(()=)=)E)E)GH	O$ NnnmLtLLL   O!?xr!MNNO M N!HLMMNsk   G:EF3G:9G G
G G:	G!G<G:GG:
G 	G7G2-G:2G77G:config_pathc                 @  K   t        |      }|j                  dvrt        d|j                         |j                         st	        d|       |j                  dv r*t        |      5 }t        j                  |      }ddd       n`|j                  dk(  r9t        |d      5 }t        j                  |j                               }ddd       nt        d|j                          | j                  di  d{   S # 1 sw Y   #xY w# 1 sw Y   /xY w7 w)	a  
        Create TradingSuite from a configuration file.

        Supports both YAML and JSON configuration files.

        Args:
            config_path: Path to configuration file

        Returns:
            Configured TradingSuite instance

        Example:
            ```yaml
            # config/trading.yaml
            instrument: MNQ
            timeframes:
              - 1min
              - 5min
              - 15min
            features:
              - orderbook
              - risk_manager
            initial_days: 30
            ```

            ```python
            # Note: Create the config file first with the above content
            suite = await TradingSuite.from_config("config/trading.yaml")
            ```
        ).yaml.yml.jsonzUnsupported config format: zConfiguration file not found: )r  r  Nr  rbrM   )r	   suffixr   existsFileNotFoundErroropenyaml	safe_loadorjsonloadsreadr   )r   r   pathr   r,   s        r9   from_configzTradingSuite.from_config  s    @ K  ;;88:4;;-HII {{}#&D[M$RSS ;;++d )q~~a() )[[G#dD! .Q||AFFH-. . :4;;-HII  SZZ'$''') ). . (sB   A)D+D$D%$D	6D?D DD	DDDc                 D   K    | j                   |fi | d{   S 7 w)a  
        Create TradingSuite using environment variables for configuration.

        This method automatically loads ProjectX credentials from environment
        variables and applies any additional configuration from kwargs.

        Required environment variables:
        - PROJECT_X_API_KEY
        - PROJECT_X_USERNAME

        Args:
            instrument: Trading instrument symbol
            **kwargs: Additional configuration options

        Returns:
            Configured TradingSuite instance

        Example:
            ```python
            # Uses PROJECT_X_API_KEY and PROJECT_X_USERNAME from environment
            suite = await TradingSuite.from_env("MNQ", timeframes=["1min", "5min"])
            ```
        N)r   )r   r[   r   s      r9   r   zTradingSuite.from_env%  s$     4  SZZ
5f5555s     c                 0  K   | j                   ry	 t        j                  d       | j                  j	                          d{    | j                  j                          d{    | j                  r| j                          d{    n| j                          d{    d| _	        d| _         t        j                  d       y7 7 g7 E7 .# t        $ r7}t        j                  d|        | j                          d{  7    d}~ww xY ww)z4Initialize all components and establish connections.Nz Connecting to real-time feeds...Tz$TradingSuite initialization completez#Failed to initialize TradingSuite: )r   r   r   r   connectsubscribe_user_updatesr   _initialize_instrument_contexts$_initialize_legacy_single_instrumentr   r   error
disconnectr8   r   s     r9   r   zTradingSuite._initializeA  s     	KK:;--'')))--66888  ::<<< ??AAA"DO $DKK>? *8 = B  	LL>qcBC//###	s|   D2C C!C %C&#C 	C
C "C#'C 
DC C C C 	D+DD
DDDc                    K   dt         ddf fd} j                  j                         D cg c]
  } ||       }}t        j                  |  d{     j
                  r j                  r j                  j                   j                  _	         j                  j                   j                  _         j                  j                   j                  _         j                  j                  r% j                  j                   j                  _         j                  j                  r& j                  j                   j                  _        yy j                  r~t!        t#         j                  j                                     }|j                   j                  _	        |j                   j                  _        |j                   j                  _        yyc c}w 7 w)z/Initialize all instrument contexts in parallel.r   r4   Nc                   K   | j                   j                  j                         d{    | j                  j                  j                  | j                          d{    | j                  j                  j
                  j                         d{    j                  j                  | j                  j                  g       d{    | j                  j                          d{    | j                  r1| j                  j                  j                  dd       d{    yy7 7 7 7 k7 K7 w)z'Initialize a single instrument context.r   Nr   r   r^   Tr   subscribe_to_depthsubscribe_to_quotes)r-   
initializer   r.   r,   r   r^   subscribe_market_datar+   r   start_realtime_feedr0   )r   r8   s    r9   _initialize_single_contextzPTradingSuite._initialize_instrument_contexts.<locals>._initialize_single_context_  s)     ..++DMM+JJJ ##.. $%nn /    ,,))t{{7O7O)PPP --55w7N7N7Q7Q6RSSS ,,22444   ''22$(MM'+(, 3    !% K Q T 5si   *ED;8E&D>'7EE 7EE!E8E9;E4E5E>E EEEE)r)   r   r   r   r   r   r   r-   r   r   r,   r   r.   r   r1   r0   r   r   )r8   r%  r   r   first_contexts   `    r9   r  z,TradingSuite._initialize_instrument_contexts\  s    	6G 	D 	>  ,,335
 'w/
 
 nne$$$ %%$*>*>373G3G3N3ND""0262F2F2K2KD""/6:6J6J6T6TD""3##006:6J6J6W6W&&3##--373G3G3Q3Q&&0 .
    $T$*;*;*B*B*D%E F7D7K7K&&46C6H6H&&3:G:Q:Q&&7	 !'
 	%s   +G+G#G+G(FG+c                   K   | j                   j                  | j                         d{    | j                  j                  | j                  | j                          d{    t        j                  d| j                  j                   d       | j                  j                  | j                  j                         d{    | j                  j                  | j                         d{   | _        | j                  st        d| j                         | j                  j                  | j                  j                  g       d{    | j                  j!                          d{    t"        j$                  | j                  j&                  v rt        j                  d       t)        | j                  j                  | j                  j*                  | j                  | j                  j-                         | j.                  	      | _        | j0                  j                  | j                  d
d
       d{    | j0                  | j2                  _        yy7 D7 7 7 7 $7 7 3w)z7Initialize components in legacy single-instrument mode.r  Nr  zLoading z days of historical data...r  z"Failed to get instrument info for zInitializing orderbook...)r[   r   r   r   r/   Tr  )r   r"  r   r   r   r   r   r^   r   r   r   r   r[   r   r#  r   r$  rP   rT   r]   r   r`   r   r   r   r   r0   ro   s    r9   r  z1TradingSuite._initialize_legacy_single_instrument  s     ll%%dmm%DDD oo(( MM,, ) 
 	
 	
 	ht{{7788STUjj##1I1I#JJJ !% : :4<< HHA$,,PQQmm114??3E3E2FGGG jj,,... !5!55KK34'??--![[11++{{779++DO //,, $#'$( -   
 04D"", 6/ 	E	
 	K I 	H 	/s~   *JI08J%I3&A$J
I6,J7I98A JI<!J:I?;CJJ"J3J6J9J<J?JJc                 Z   K   | j                   s| j                          d{    yy7 w)a  
        Manually connect all components if auto_connect was disabled.

        Example:
            ```python
            suite = await TradingSuite.create("MNQ", auto_connect=False)
            # ... configure components ...
            await suite.connect()
            ```
        Nr   r   ro   s    r9   r  zTradingSuite.connect  s)      ""$$$ $    +)+c                 :  K   t         j                  d       | j                  r| j                          d{    n| j	                          d{    | j
                  r"| j
                  j                          d{    t        | d      r2| j                  r&	 | j                  j                  ddd       d{    d| _        d| _        t         j                  d       y7 7 7 j7 .# t        $ r"}t         j                  d|        Y d}~Rd}~ww xY ww)z
        Gracefully disconnect all components and clean up resources.

        Example:
            ```python
            await suite.disconnect()
            ```
        zDisconnecting TradingSuite...Nr   z"Error cleaning up client context: FzTradingSuite disconnected)r   r   r   _disconnect_instrument_contexts$_disconnect_legacy_single_instrumentr   r  r   r   r   r   r  r   r   r  s     r9   r  zTradingSuite.disconnect  s      	3466888 ;;=== ==--**,,, 4*+0D0DG**44T4FFF
  !/0' 9 > -
 G GA!EFFGso   5DC%DC'-D>C)?D C- <C+=C- %D'D)D+C- -	D6DDDDc                    K   dt         ddfd}| j                  j                         D cg c]
  } ||       }}t        j                  |  d{    yc c}w 7 
w)z/Disconnect all instrument contexts in parallel.r   r4   Nc                   K   | j                   rD| j                   j                          d{    | j                   j                          d{    | j                  r#| j                  j                          d{    yy7 V7 67 
w)z'Disconnect a single instrument context.N)r,   stop_realtime_feedr   r0   )r   s    r9   _disconnect_single_contextzPTradingSuite._disconnect_instrument_contexts.<locals>._disconnect_single_context  sr      ||ll55777ll**,,,   ''//111 !	 8, 2s3   *B	B!B	B-B	<B=B	B	B	)r)   r   r   r   r   )r8   r1  r   r   s       r9   r,  z,TradingSuite._disconnect_instrument_contexts  sk     		26G 		2D 		2  ,,335
 'w/
 
 nne$$$	
 	%s   )AAAAAc                 H  K   t        | d      rP| j                  rD| j                  j                          d{    | j                  j                          d{    t        | d      r0| j                  r#| j                  j                          d{    yyy7 c7 C7 w)z7Disconnect components in legacy single-instrument mode.r   Nr   )r   r   r0  r   r   ro   s    r9   r-  z1TradingSuite._disconnect_legacy_single_instrument  s      4!djj**//111**$$&&& 4&4??//))+++ ,;&	 2& ,s3   6B"B!B"B9B"B B"B" B"c                 Z   K   | j                   s| j                          d{    | S 7 w)zAsync context manager entry.Nr)  ro   s    r9   r   zTradingSuite.__aenter__  s+      ""$$$ %r*  exc_typeexc_valexc_tbc                 @   K   | j                          d{    y7 w)z(Async context manager exit with cleanup.N)r  )r8   r4  r5  r6  s       r9   r   zTradingSuite.__aexit__  s      oos   c                 R    | j                   xr | j                  j                         S )z0Check if all components are connected and ready.)r   r   is_connectedro   s    r9   r9  zTradingSuite.is_connected!  s      ?4==#=#=#??rN   c                 `   t        | d      r6t        j                  d| j                   dt        d       | j
                  S | j                  rV| j                  rJt        j                  d| j                  j                   dt        d       | j                  j                  S t        d      )z*Deprecated: Direct access to data manager.r   z9Direct access to 'data' is deprecated. Please use suite['zC'].data instead. This compatibility mode will be removed in v4.0.0.   
stacklevelz-'TradingSuite' object has no attribute 'data')r   warningswarnr   DeprecationWarningr   r   r   r*   r,   AttributeErrorro   s    r9   r,   zTradingSuite.data'  s     4!MM%%)\\N 3EF # ::''D,@,@MM%%)%9%9%@%@$A BEF # '',,,LMMrN   c                 `   t        | d      r6t        j                  d| j                   dt        d       | j
                  S | j                  rV| j                  rJt        j                  d| j                  j                   dt        d       | j                  j                  S t        d      )z+Deprecated: Direct access to order manager.r   z;Direct access to 'orders' is deprecated. Please use suite['zE'].orders instead. This compatibility mode will be removed in v4.0.0.r;  r<  z/'TradingSuite' object has no attribute 'orders')r   r>  r?  r   r@  r   r   r   r*   r-   rA  ro   s    r9   r-   zTradingSuite.orders>  s     4#MM%%)\\N 3EF # <<''D,@,@MM%%)%9%9%@%@$A BEF # ''...NOOrN   c                 `   t        | d      r6t        j                  d| j                   dt        d       | j
                  S | j                  rV| j                  rJt        j                  d| j                  j                   dt        d       | j                  j                  S t        d      )z.Deprecated: Direct access to position manager.r   z>Direct access to 'positions' is deprecated. Please use suite['zH'].positions instead. This compatibility mode will be removed in v4.0.0.r;  r<  z2'TradingSuite' object has no attribute 'positions')r   r>  r?  r   r@  r   r   r   r*   r.   rA  ro   s    r9   r.   zTradingSuite.positionsU       4&MM%%)\\N 3EF # ??"''D,@,@MM%%)%9%9%@%@$A BEF # ''111QRRrN   c                 `   t        | d      r6t        j                  d| j                   dt        d       | j
                  S | j                  rV| j                  rJt        j                  d| j                  j                   dt        d       | j                  j                  S t        d      )z'Deprecated: Direct access to orderbook.r   z>Direct access to 'orderbook' is deprecated. Please use suite['zH'].orderbook instead. This compatibility mode will be removed in v4.0.0.r;  r<  z2'TradingSuite' object has no attribute 'orderbook')r   r>  r?  r   r@  r   r   r   r*   r0   rA  ro   s    r9   r0   zTradingSuite.orderbookl  rD  rN   c                 `   t        | d      r6t        j                  d| j                   dt        d       | j
                  S | j                  rV| j                  rJt        j                  d| j                  j                   dt        d       | j                  j                  S t        d      )z*Deprecated: Direct access to risk manager.r   zADirect access to 'risk_manager' is deprecated. Please use suite['zK'].risk_manager instead. This compatibility mode will be removed in v4.0.0.r;  r<  z5'TradingSuite' object has no attribute 'risk_manager')r   r>  r?  r   r@  r   r   r   r*   r1   rA  ro   s    r9   r1   zTradingSuite.risk_manager  s     4)MM%%)\\N 3EF # %%%''D,@,@MM%%)%9%9%@%@$A BEF # ''444TUUrN   c                     | j                   S )z?Get the original symbol (e.g., 'MNQ') without contract details.)r   ro   s    r9   r*   zTradingSuite.symbol  s     ||rN   c                 J    | j                   r| j                   j                  S dS )z?Get the full instrument/contract ID (e.g., 'CON.F.US.MNQ.U25').N)r[   r   ro   s    r9   instrument_idzTradingSuite.instrument_id  s     &*__t!!>$>rN   r2   r3   c                 X   K   | j                   j                  ||       d{    y7 w)af  
        Register event handler through unified event bus.

        This is the single interface for all event handling in the SDK,
        replacing the scattered callback systems across components.

        Args:
            event: Event type to listen for (EventType enum or string)
            handler: Async callable to handle events

        Example:
            ```python
            async def handle_new_bar(event):
                # event.data contains: {'timeframe': str, 'data': bar_dict}
                bar_data = event.data.get("data", {})
                timeframe = event.data.get("timeframe", "")
                print(f"New {timeframe} bar: ${bar_data.get('close', 0):.2f}")


            async def handle_position_closed(event):
                # event.data contains the position object
                position = event.data
                print(f"Position closed: P&L = {position.pnl}")


            async def handle_order_filled(event):
                # event.data contains the order object
                order = event.data
                print(f"Order filled at {order.filledPrice}")


            # Register handlers
            await suite.on(EventType.NEW_BAR, handle_new_bar)
            await suite.on(EventType.POSITION_CLOSED, handle_position_closed)
            await suite.on(EventType.ORDER_FILLED, handle_order_filled)
            ```
        N)r   r6   r7   s      r9   r6   zTradingSuite.on  s!     L kknnUG,,,r:   c                 X   K   | j                   j                  ||       d{    y7 w)z
        Register one-time event handler.

        Handler will be automatically removed after first invocation.

        Args:
            event: Event type to listen for
            handler: Async callable to handle event once
        N)r   r<   r7   s      r9   r<   zTradingSuite.once  s"      kkug...r:   c                 X   K   | j                   j                  ||       d{    y7 w)z
        Remove event handler(s).

        Args:
            event: Event type to remove handler from (None for all)
            handler: Specific handler to remove (None for all)
        N)r   r>   r7   s      r9   r>   zTradingSuite.off  s       kkooeW---r:   orderc                     t        | |      }|S )a  
        Create an OrderTracker for comprehensive order lifecycle management.

        This provides automatic order state tracking with async waiting capabilities,
        eliminating the need for manual order status polling.

        Args:
            order: Optional order to track immediately (Order, OrderPlaceResponse, or order ID)

        Returns:
            OrderTracker instance (use as context manager)

        Example:
            ```python
            from project_x_py.types.trading import OrderSide

            # Track a new order
            async with suite.track_order() as tracker:
                order = await suite.orders.place_limit_order(
                    contract_id=suite.instrument_id,
                    side=OrderSide.BUY,
                    size=1,
                    price=current_price - 10,
                )
                tracker.track(order)

                try:
                    filled = await tracker.wait_for_fill(timeout=60)
                    print(f"Order filled at {filled.filledPrice}")
                except TimeoutError:
                    await tracker.modify_or_cancel(new_price=current_price - 5)
            ```
        )r   )r8   rM  trackers      r9   track_orderzTradingSuite.track_order  s    D tU+rN   c                     t        |       S )a  
        Create an order chain builder for complex order structures.

        Provides a fluent API for building multi-part orders (entry + stops + targets)
        with clean, readable syntax.

        Returns:
            OrderChainBuilder instance

        Example:
            ```python
            # Build a bracket order with stops and targets
            # Note: side=0 for BUY, side=1 for SELL
            order_chain = (
                suite.order_chain()
                .market_order(size=2, side=0)  # BUY 2 contracts
                .with_stop_loss(offset=50)
                .with_take_profit(offset=100)
                .with_trail_stop(offset=25, trigger_offset=50)
            )

            result = await order_chain.execute()

            # Or use a limit entry
            order_chain = (
                suite.order_chain()
                .limit_order(size=1, price=16000, side=0)  # BUY limit
                .with_stop_loss(price=15950)
                .with_take_profit(price=16100)
            )
            ```
        )r   ro   s    r9   order_chainzTradingSuite.order_chain	  s    B !&&rN   max_risk_percentmax_risk_amountc           	          | j                   st        d      t        | j                   | j                  | j                  | j
                  xs | j                  | j                  ||      S )ag  
        Create a managed trade context manager with automatic risk management.

        This provides a high-level interface for executing trades with built-in:
        - Position sizing based on risk parameters
        - Trade validation against risk rules
        - Automatic stop-loss and take-profit attachment
        - Position monitoring and adjustment
        - Cleanup on exit

        Args:
            max_risk_percent: Override max risk percentage for this trade
            max_risk_amount: Override max risk dollar amount for this trade

        Returns:
            ManagedTrade context manager

        Raises:
            ValueError: If risk manager is not enabled

        Example:
            ```python
            # Enter a risk-managed long position
            async with suite.managed_trade(max_risk_percent=0.01) as trade:
                result = await trade.enter_long(
                    stop_loss=current_price - 50,
                    take_profit=current_price + 100,
                )

                # Optional: Scale in
                if market_conditions_favorable:
                    await trade.scale_in(additional_size=1)

                # Optional: Adjust stop
                if price_moved_favorably:
                    await trade.adjust_stop(new_stop_loss=entry_price)

            # Automatic cleanup on exit
            ```
        z>Risk manager not enabled. Add 'risk_manager' to features list.)r1   r   r   rI  r   rS  rT  )r1   r   r   r-   r.   rI  r   r,   )r8   rS  rT  s      r9   managed_tradezTradingSuite.managed_trade,  sc    Z   P  **++!^^,,<-+
 	
rN   r?   c                 V   K   | j                   j                  ||       d{   S 7 w)a  
        Wait for specific event to occur.

        Args:
            event: Event type to wait for
            timeout: Optional timeout in seconds

        Returns:
            Event object when received

        Raises:
            TimeoutError: If timeout expires
        N)r   rA   rB   s      r9   rA   zTradingSuite.wait_forh  s%       [[))%9999rC   c                 R   K   | j                   j                          d{   S 7 w)z
        Get comprehensive statistics from all components using the aggregator.

        Returns:
            Structured statistics from all active components with accurate metrics
        N)r   aggregate_statsro   s    r9   	get_statszTradingSuite.get_statsz  s#      ++;;====s   '%'zCSynchronous methods are being phased out in favor of async-only APIz3.3.0z4.0.0zawait get_stats())reasonversionremoval_versionreplacementc                    ddl }	  |j                         }ddl}|j                  j	                         5 }|j                  |j                  | j                               }|j                         cddd       S # 1 sw Y   yxY w# t        $ r 	  |j                         }|j                         rpddl}|j                  j	                         5 }|j                  |j                  | j                               }|j                         cddd       cY S # 1 sw Y   nxY wn2# t        $ r&  |j                         } |j                  |       Y nw xY w|j                  | j                               cY S w xY w)z
        Synchronous wrapper for get_stats for backward compatibility.

        Returns:
            Structured statistics from all active components
        r   N)r   get_running_loopconcurrent.futuresfuturesThreadPoolExecutorsubmitrunrZ  r   RuntimeErrorget_event_loop
is_runningnew_event_loopset_event_looprun_until_complete)r8   r   loop
concurrentexecutorfutures         r9   get_stats_synczTradingSuite.get_stats_sync  s5    		=+7++-D%##668 'H!dnn6FG}}' ' '  	=--w--/??$-#++>>@ /H!)dnn>N!O%}}/ / /   --w--/&&&t,- **4>>+;<<	=sp   /B :A9/	B 9B>B B 	E5?D!:D	D!E5D	D! E5!,EE5E"E54E5session_typec                   K   | j                   rs| j                  rgt        | j                  j                  d      rF| j                  j                  j	                  |       d{    t
        j                  d|        yy| j                  j                         D ]<  }t        |j                  d      s|j                  j	                  |       d{    > | j                  rt
        j                  d| d       yy7 7 /w)a-  
        Change the active session type for data filtering.

        Args:
            session_type: Type of session to filter for (RTH/ETH)

        Example:
            ```python
            # Switch to RTH-only data
            await suite.set_session_type(SessionType.RTH)
            ```
        set_session_typeNzSession type changed to z for all instruments)	r   r   r   r,   rs  r   r   r   r   )r8   rq  r   s      r9   rs  zTradingSuite.set_session_type  s      %%$*>*>t++002DE**//@@NNN6|nEF F
  ,,335 F7<<);<!,,77EEEF   .|n<PQ ! O Fs+   A!D#D$AD6DD.DD	timeframec                 \  K   | j                   r| j                  r{t        | j                  j                  d      r.| j                  j                  j	                  ||       d{   S | j                  j                  j                  |       d{   S i }| j                  j                         D ]i  \  }}t        |j                  d      r(|j                  j	                  ||       d{   ||<   D|j                  j                  |       d{   ||<   k |r|S dS 7 7 7 :7 w)a  
        Get session-filtered market data.

        Args:
            timeframe: Data timeframe (e.g., "1min", "5min")
            session_type: Optional session type override

        Returns:
            Polars DataFrame with session-filtered data

        Example:
            ```python
            # Get RTH-only data
            rth_data = await suite.get_session_data("1min", SessionType.RTH)
            ```
        get_session_dataN)r   r   r   r,   rv  get_datar   r   )r8   rt  rq  r   r*   r   s         r9   rv  zTradingSuite.get_session_data  s    ( %%$*>*>t++002DE!1166GG|   --22;;IFFF #00668 	HOFGw||%78'.||'D'D|( "v (/||'<'<Y'G!Gv	H  v)T) G" "HsI   A"D,$D$%,D,D&AD,-D(.&D,D*D,&D,(D,*D,c                   K   | j                   r[| j                  rOt        | j                  j                  d      r-| j                  j                  j	                  |       d{   S i S i }| j
                  j                         D ]B  \  }}t        |j                  d      s|j                  j	                  |       d{   ||<   D |r|S i S 7 m7 w)ar  
        Get session-specific statistics.

        Returns:
            Dictionary containing session statistics like volume, VWAP, etc.

        Example:
            ```python
            stats = await suite.get_session_statistics()
            print(f"RTH Volume: {stats['rth_volume']}")
            print(f"ETH Volume: {stats['eth_volume']}")
            ```
        get_session_statisticsN)r   r   r   r,   ry  r   r   )r8   rt  r   r*   r   s        r9   ry  z#TradingSuite.get_session_statistics  s      %%$*>*>t++002JK!1166MMiXXXI #00668 	VOFGw||%=>'.||'J'J9'U!Uv	V  v'R' Y "Vs*   A!C#C$>C#CCCCr*   c                      | j                   |   S )a  
        Get InstrumentContext for a specific symbol.

        Args:
            symbol: The instrument symbol (e.g., "MNQ", "ES")

        Returns:
            InstrumentContext for the specified symbol

        Raises:
            KeyError: If symbol is not found

        Example:
            ```python
            # Access specific instrument context
            mnq_context = suite["MNQ"]
            current_price = await mnq_context.data.get_current_price()
            ```
        r   r8   r*   s     r9   __getitem__zTradingSuite.__getitem__  s    (   ((rN   c                 ,    t        | j                        S )z.Return the number of instruments in the suite.)r   r   ro   s    r9   __len__zTradingSuite.__len__"  s    4$$%%rN   c                 ,    t        | j                        S )z Iterate over instrument symbols.)r   r   ro   s    r9   __iter__zTradingSuite.__iter__&  s    D%%&&rN   c                     || j                   v S )z.Check if an instrument symbol is in the suite.r{  r|  s     r9   __contains__zTradingSuite.__contains__*  s    ****rN   c                 H    t        | j                  j                               S )z+Return an iterator over instrument symbols.)r   r   r   ro   s    r9   r   zTradingSuite.keys.  s    D%%**,--rN   c                 H    t        | j                  j                               S )z,Return an iterator over instrument contexts.)r   r   r   ro   s    r9   r   zTradingSuite.values2  s    D%%,,.//rN   c                 H    t        | j                  j                               S )z0Return an iterator over (symbol, context) pairs.)r   r   r   ro   s    r9   r   zTradingSuite.items6  s    D%%++-..rN   namec           
         | j                   rr| j                  rft        | j                  |      rPt        j                  d| d| j                  j
                   d| dt        d       t        | j                  |      S t        | j                        dkD  rMt        | j                  j                               }t        dt        |       j                   d	| d
| d|       t        dt        |       j                   d	| d      )a  
        Provide backward compatibility for single-instrument access.

        This allows existing code to work while providing deprecation warnings.
        Only works in single-instrument mode.

        Args:
            name: Attribute name being accessed

        Returns:
            The requested attribute from the single instrument context

        Raises:
            AttributeError: If not in single-instrument mode or attribute not found
        zDirect access to 'z#' is deprecated. Please use suite['z'].z< instead. This compatibility mode will be removed in v4.0.0.r;  r<  r   'z' object has no attribute 'z4'. For multi-instrument suites, use suite['SYMBOL'].z. Available instruments: )r   r   r   r>  r?  r*   r@  getattrr   r   r   r   rA  typerF   )r8   r  available_symbolss      r9   __getattr__zTradingSuite.__getattr__;  s   " &&$$,,d3MM$TF +%%)%9%9%@%@$ATF KEF # 4//66 t  !A% $T%6%6%;%;%= > DJ''((CD6 JDDH6 J**;)<>  !DJ''((CD6K rN   rE   )NNNNN)r4   N)r4   r   rD   )1min)JrF   rG   rH   rI   r   r   rZ   dictrJ   r)   ri   classmethodr   r   r   r   r   r   r   r  r   r   r  r  r  r  r,  r-  r   r  BaseExceptionr
   r   propertyr   r9  r,   r-   r.   r0   r1   r*   rI  r   r6   r<   r>   r   rP  r   rR  rL   r   rV  rA   r$   rZ  r&   rp  r   rs  rv  ry  r}  r   r  r   r  r  r   r   r   r   r  rM   rN   r9   r   r   "  s7   2 DHG
G
 0G
 #	G

 "#'8"89D@G
R  /3!%'+%)/3n49_t+n $Jn I$	n
 s)d"n &,n n 
n n` G#YG G 0	G
 #G 
c$$	%G GR< !NtC9J4J/K !NPT !N !NF 5(C 5(N 5( 5(n 6 6s 6~ 6 6667Rr)?V% 1D%*	, }%,  %  $	 
 
  @d @ @
 Nc N N, P P P, S3 S S, S3 S S, Vc V V,    ?sTz ? ?&-i#o &- &- &-P
/	C 
/# 
/$ 
/ KO
._t+
.=@4Z
.	
.# # #J!'. !'J *.(,:
$,:
 :
 
	:
z ?C:_:/4t|:	:$>!2 > T'	!= 1 !=!=H; 4 : BF%*%*,7$,>%*	%*N(c (tCQTH~ (8)# )*; ),& &'(3- '+3 +4 +.hsm .0!23 0/xc+<&< => /
) ) )rN   r   )KrI   r   r>  collections.abcr   
contextlibr   dataclassesr   r   decimalr   enumr   pathlibr	   typesr
   typingr   r   r  r
  project_x_py.clientr   project_x_py.client.baser   project_x_py.event_busr   r   project_x_py.modelsr   project_x_py.order_managerr   project_x_py.order_trackerr   r   project_x_py.orderbookr   project_x_py.position_managerr   project_x_py.realtimer   "project_x_py.realtime_data_managerr   project_x_py.risk_managerr   r   r   project_x_py.sessionsr   r   project_x_py.statisticsr   project_x_py.types.config_typesr   r    r!   r"   project_x_py.types.protocolsr#   project_x_py.types.stats_typesr$   project_x_py.utilsr%   project_x_py.utils.deprecationr&   
get_loggerrF   r   r)   rJ   rP   rZ   r   rM   rN   r9   <module>r     s   !F   $ 2 !         ( 1 6 * 3 F , 9 8 B K K < 8  @ < - 5	"	"	"8	, $K= K= K=\&sD &x
 x
vB BrN   