Utilities
=========

Utility functions and helper tools for trading, analysis, and data processing.

.. currentmodule:: project_x_py.utils

.. automodule:: project_x_py.utils
   :members:
   :undoc-members:
   :show-inheritance:
   :no-index:

Price and Position Utilities
----------------------------

.. autofunction:: calculate_tick_value
.. autofunction:: calculate_position_value
.. autofunction:: round_to_tick_size
.. autofunction:: format_price
.. autofunction:: format_volume

Risk Management
---------------

.. autofunction:: calculate_risk_reward_ratio
.. autofunction:: calculate_position_sizing
.. autofunction:: calculate_max_drawdown
.. autofunction:: calculate_sharpe_ratio

Portfolio Analysis
------------------

.. autofunction:: calculate_portfolio_metrics
.. autofunction:: calculate_correlation_matrix

Contract Utilities
------------------

.. autofunction:: validate_contract_id
.. autofunction:: extract_symbol_from_contract_id

Market Session
--------------

.. autofunction:: get_market_session_info
.. autofunction:: is_market_hours

Data Processing
---------------

.. autofunction:: create_data_snapshot
.. autofunction:: convert_timeframe_to_seconds

Logging and Configuration
-------------------------

.. autofunction:: setup_logging
.. autofunction:: get_env_var

Rate Limiting
-------------

.. autoclass:: RateLimiter
   :members:
   :undoc-members:
   :show-inheritance: 