31 - Utils Functionalities

Overview

The utils directory contains shared utility functions used across the OpenAlgo platform for authentication, logging, configuration, and common operations.

Utils Directory Structure

utils/
├── auth_utils.py           # Authentication helpers
├── session.py              # Session management
├── security_middleware.py  # IP security
├── logging.py              # Centralized logging
├── traffic_logger.py       # HTTP traffic logging
├── ip_helper.py            # IP address resolution
├── httpx_client.py         # HTTP client pooling
├── socketio_error_handler.py # Socket.IO errors
├── latency_monitor.py      # Performance tracking
├── api_analyzer.py         # API validation
├── mpp_slab.py             # Market price protection
├── number_formatter.py     # Indian number format
├── constants.py            # Order constants
├── config.py               # Config helpers
├── env_check.py            # Environment validation
├── version.py              # Version management
├── plugin_loader.py        # Broker plugin loading
├── email_utils.py          # Email sending
├── email_debug.py          # Email debugging
├── ngrok_manager.py        # Ngrok tunnels
└── health_monitor.py       # Background health monitoring daemon

Key Utilities

1. Authentication Utilities (auth_utils.py)

2. Session Management (session.py)

3. IP Helper (ip_helper.py)

4. HTTP Client (httpx_client.py)

5. Logging (logging.py)

6. Market Price Protection (mpp_slab.py)

7. Number Formatter (number_formatter.py)

8. Constants (constants.py)

9. Environment Validation (env_check.py)

10. Latency Monitor (latency_monitor.py)

11. Plugin Loader (plugin_loader.py)

12. Ngrok Manager (ngrok_manager.py)

13. Email Utilities (email_utils.py)

14. API Analyzer (api_analyzer.py)

Usage Examples

Using Logger

Using Session Decorator

Using HTTP Client

Using Constants

Key Files Reference

File
Purpose

auth_utils.py

Authentication helpers

session.py

Session management

logging.py

Logging configuration

httpx_client.py

HTTP client

constants.py

Order constants

config.py

Config helpers

ip_helper.py

IP resolution

latency_monitor.py

Performance tracking

Last updated