Documentation
HomeGithubDiscordBlog
  • What is OpenAlgo?
  • OpenAlgo Architecture
  • Mini FOSS Universe
  • Community Support
  • OpenAlgo GPT
  • New Features
    • Fast Scalper
    • API Analyzer
    • Traffic/Latency Monitor
    • Chartink Integration
  • Monetization
  • Connect Brokers
    • Brokers
      • 5Paisa
      • 5paisa (XTS)
      • AliceBlue
      • AngelOne
      • Compositedge
      • Dhan
      • Dhan(Sandbox)
      • Firstock
      • FlatTrade
      • Fyers
      • Groww
      • IIFL (XTS)
      • Jainam Retail (XTS)
      • Jainam Dealer (XTS)
      • Kotak Securities
      • Paytm
      • Pocketful
      • Shoonya
      • Tradejini
      • Upstox
      • Wisdom Capital
      • Zebu
      • Zerodha
  • Installation Guidelines
  • Getting Started
    • Windows Installation
      • Pre-Requesites
      • Setup
      • Install Dependencies
      • Ngrok Config
      • Environmental Variables
      • Start OpenAlgo
      • SSL Verification Failed
      • Accessing OpenAlgo
    • Windows Server Installation
    • Mac OS Installation
      • Pre-Requesties
      • Setup
      • Install Dependencies
      • Ngrok Config
      • Environmental Variables
      • Start OpenAlgo
      • Install certifi
      • Accessing OpenAlgo
    • Amazon Elastic Beanstalk
    • Ubuntu Server Installation
    • Docker Development
    • Testing OpenAlgo in Cloud
    • Upgrade
  • Latency
  • API Documentation
    • V1
      • Accounts API
        • Funds
        • Orderbook
        • Tradebook
        • PositionBook
        • Holdings
      • Orders API
        • Placeorder
        • PlaceSmartOrder
        • BasketOrder
        • SplitOrder
        • ModifyOrder
        • CancelOrder
        • CancelAllOrder
        • ClosePosition
        • OrderStatus
        • OpenPosition
      • Data API
        • Quotes
        • Depth
        • History
        • Intervals
        • Symbol
        • Ticker
      • Websockets
      • Order Constants
      • HTTP Status Codes
      • Rate Limiting
      • API Collections
  • Symbol Format
  • MCP
  • Trading Platform
    • Amibroker
      • AmiQuotes
      • Button Trading Module
      • Button Trading with Split Orders
      • Button Trading with Stoploss
      • SmartOrder Chart Module
      • Trailing Stoploss Execution Module
      • Line Trading Module
      • Equity Exploration Module
      • CSV Exploration Module
      • Options Button Trading Module
      • Spot/Futures to Options Module (Single Leg)
      • Spot/Futures to Options Module (Two Leg)
      • Time Based Execution
    • Tradingview
      • Futures to Options Module
    • ChartInk
    • Python
      • Strategy Management
      • EMA Crossover Strategy
      • EMA Crossover Strategy with Stoploss and Target
      • Supertrend Strategy
      • Supertrend Strategy with yfinance data
      • Voice Based Orders
    • NodeJS
    • Metatrader 5
      • Download & Install Library
      • OpenAlgo MQL5 Functions
      • Include the Header File
      • Sample Expert Advisor
    • Excel
    • Google Spreadsheets
    • N8N
    • Chrome Extension
  • Strategy Management
  • Developers
    • Design Documentation
      • Architecture
      • API Layer
      • Broker Integerations
      • Database Layer
      • Authentication Platforms
      • Configuration
      • Utilities
      • Broker Integration Checklist
  • Change Log
    • Version 1.0.0.25 Launched
    • Version 1.0.0.24 Launched
    • Version 1.0.0.23 Launched
    • Version 1.0.0.22 Launched
    • Version 1.0.0.21 Launched
    • Version 1.0.0.20 Launched
    • Version 1.0.0.19 Launched
    • Version 1.0.0.18 Launched
    • Version 1.0.0.17 Launched
    • Version 1.0.0.16 Launched
    • Version 1.0.0.15 Launched
    • Version 1.0.0.14 Launched
    • Version 1.0.0.13 Launched
    • Version 1.0.0.12 Launched
    • Version 1.0.0.11 Launched
    • Version 1.0.0.10 Launched
    • Version 1.0.0.9 Launched
    • Version 1.0.0.8 Launched
    • Version 1.0.0.7 Launched
    • Version 1.0.0.6 Launched
    • Version 1.0.0.5 Launched
    • Version 1.0.0.4 Launched
    • Version 1.0.0.3 Launched
    • Version 1.0.0.2 Launched
    • Version 1.0.0.1 Launched
    • Version 1.0.0.0 Launched
Powered by GitBook
On this page
  1. Developers
  2. Design Documentation

Utilities

The ./design/08_utilities.md directory contains helper modules, classes, and functions that provide common functionalities used across different parts of the OpenAlgo application. Encapsulating these utilities promotes code reuse and separation of concerns.

Key Utility Modules

Based on the directory listing, here are some of the key utility modules and their likely responsibilities:

  • utils/env_check.py:

    • Responsible for loading environment variables from the .env file at application startup.

    • Performs checks to ensure essential configuration variables are present and potentially valid.

    • Called very early in app.py.

  • utils/plugin_loader.py:

    • Contains logic to dynamically discover and load modules, specifically observed loading broker authentication functions (load_broker_auth_functions called in app.py).

    • Allows the application to easily recognize and use new broker integrations placed in the broker/ directory without manual registration in the core code.

  • utils/session.py:

    • Provides utilities related to Flask session management.

    • Likely contains the @check_session_validity decorator used to protect routes that require a logged-in user.

    • May include logic for session expiry checks based on the SESSION_EXPIRY_TIME config.

  • utils/latency_monitor.py:

    • Implements middleware and functions to monitor the processing time of API requests.

    • Records latency metrics, likely storing them in the database via database/latency_db.py.

    • Initialized in app.py.

  • utils/traffic_logger.py:

    • Implements middleware to log details about incoming HTTP requests and their corresponding responses.

    • Stores traffic logs, likely using database/traffic_db.py.

    • Initialized in app.py.

  • utils/httpx_client.py:

    • Provides a shared/configured instance of the httpx HTTP client library.

    • Using a shared client can improve performance through connection pooling for outgoing HTTP requests (e.g., to broker APIs).

  • utils/auth_utils.py:

    • Likely contains helper functions related to authentication or authorization logic that are shared between different modules (e.g., token generation/validation, password complexity checks).

  • utils/config.py:

    • Might contain constants or helper functions specifically for accessing or processing configuration values beyond simple os.getenv.

  • utils/constants.py:

    • Defines constant values used throughout the application (e.g., order statuses, transaction types, exchange names) to avoid hardcoding strings.

  • utils/version.py:

    • Provides a mechanism (get_version()) to retrieve the application's current version, potentially reading from a file or variable.

    • Used in app.py to inject the version into template contexts.

  • utils/api_analyzer.py:

    • A potentially large module containing significant logic related to API analysis features, possibly including data processing, calculations, or report generation tied to the analyzer blueprint and analyzer_db.

Using these utilities helps keep the main application logic in blueprints, database modules, and broker adapters cleaner and more focused on their specific tasks.

PreviousConfigurationNextBroker Integration Checklist

Last updated 1 month ago