# uberdeveloper/omspy architecture

> Architecture diagram of the GitHub repository uberdeveloper/omspy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/uberdeveloper/omspy
- Repository: https://github.com/uberdeveloper/omspy

## Overview

##### Main Components

A. Core System Layer:
- Base Components (/omspy/base.py, models.py)
- Order Management (/omspy/order.py)
- Multi-broker Support (/omspy/multi.py)
- Utility Functions (/omspy/utils.py)

B. Broker Integration Layer (/omspy/brokers/):
- Multiple Broker Implementations:
- Finvasia
- ICICI
- Neo
- Noren
- Paper Trading
- Zerodha
- API Helper Module

C. Advanced Order Types Layer (/omspy/orders/):
- Depth-based Orders
- Pegged Orders
- Stop Orders

D. Algorithm Layer (/omspy/algos/):
- Straddle Implementation
- Trailing Orders

E. Simulation System (/omspy/simulation/):
- Virtual Trading Environment
- Simulation Models
- Simulation Server

**┌─────────────────────────────────────────────────────┐**
- Client Applications                 │
- ┘
- ↑
**┌─────────────────────────────────────────────────────┐**
- Algorithm Layer                     │
- (Straddle, Trailing, Custom Implementations)     │
- ┘
- ↑
**┌─────────────────────────────────────────────────────┐**
- Advanced Order Types                   │
- (Depth, Peg, Stop Order Handlers)           │
- ┘
- ↑
**┌─────────────────────────────────────────────────────┐**
- Core OMS Layer                     │
- (Order Management, Models, Multi-broker Support)  │
- ┘
- ↑
**┌─────────────────────────────────────────────────────┐**
- Broker Integration Layer               │
- (Multiple Broker Implementations + API Helper)    │
- ┘
- ↑
**┌─────────────────────────────────────────────────────┐**
- External Broker APIs                    │
- ┘

##### Important Elements to Highlight

A. Data Flow Patterns:
- How orders flow from algorithms through the core system to brokers
- How market data flows from brokers up through the system
- Demonstrate how the simulation system interfaces with other components

B. Integration Points:
- Broker API connections
- How different order types interact with the core system
- Where algorithms plug into the system

C. Key Interfaces:
- Common broker API interface
- Order management interfaces
- Algorithm interfaces

##### Implementation Details to Note

- Annotations for critical configuration points
- Version/compatibility information where relevant

Remember to maintain a balance between showing enough detail to understand the system's architecture while keeping it clean and readable. Consider creating additional detailed views for complex subsystems if necessary.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef core fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef broker fill:#90EE90,stroke:#333,stroke-width:2px
    classDef order fill:#FFB347,stroke:#333,stroke-width:2px
    classDef algo fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef sim fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% Client Applications Layer
    subgraph ClientApps["Client Applications"]
        Client["Trading Applications"]
    end

    %% Algorithm Layer
    subgraph AlgoLayer["Algorithm Layer"]
        Straddle["Straddle Implementation"]
        Trailing["Trailing Orders"]
    end

    %% Advanced Order Types Layer
    subgraph OrderTypes["Advanced Order Types"]
        DepthOrders["Depth-based Orders"]
        PegOrders["Pegged Orders"]
        StopOrders["Stop Orders"]
    end

    %% Core System Layer
    subgraph CoreSystem["Core System Layer"]
        Base["Base Components"]
        OrderMgmt["Order Management"]
        MultiBroker["Multi-broker Support"]
        Models["Models"]
        Utils["Utilities"]
    end

    %% Broker Integration Layer
    subgraph BrokerIntegration["Broker Integration Layer"]
        APIHelper["API Helper"]
        Finvasia["Finvasia"]
        ICICI["ICICI"]
        Neo["Neo"]
        Noren["Noren"]
        Paper["Paper Trading"]
        Zerodha["Zerodha"]
    end

    %% Simulation System
    subgraph SimSystem["Simulation System"]
        VirtualTrading["Virtual Trading"]
        SimModels["Simulation Models"]
        SimServer["Simulation Server"]
    end

    %% External Layer
    subgraph ExternalAPIs["External Broker APIs"]
        BrokerAPIs["Broker APIs"]
    end

    %% Relationships
    Client --> AlgoLayer
    AlgoLayer --> OrderTypes
    OrderTypes --> CoreSystem
    CoreSystem --> BrokerIntegration
    BrokerIntegration --> ExternalAPIs
    SimSystem --> CoreSystem

    %% Component Mappings
    click Base "https://github.com/uberdeveloper/omspy/blob/main/omspy/base.py"
    click OrderMgmt "https://github.com/uberdeveloper/omspy/blob/main/omspy/order.py"
    click MultiBroker "https://github.com/uberdeveloper/omspy/blob/main/omspy/multi.py"
    click Models "https://github.com/uberdeveloper/omspy/blob/main/omspy/models.py"
    click Utils "https://github.com/uberdeveloper/omspy/blob/main/omspy/utils.py"
    
    click APIHelper "https://github.com/uberdeveloper/omspy/blob/main/omspy/brokers/api_helper.py"
    click Finvasia "https://github.com/uberdeveloper/omspy/blob/main/omspy/brokers/finvasia.py"
    click ICICI "https://github.com/uberdeveloper/omspy/blob/main/omspy/brokers/icici.py"
    click Neo "https://github.com/uberdeveloper/omspy/blob/main/omspy/brokers/neo.py"
    click Noren "https://github.com/uberdeveloper/omspy/blob/main/omspy/brokers/noren.py"
    click Paper "https://github.com/uberdeveloper/omspy/blob/main/omspy/brokers/paper.py"
    click Zerodha "https://github.com/uberdeveloper/omspy/blob/main/omspy/brokers/zerodha.py"
    
    click DepthOrders "https://github.com/uberdeveloper/omspy/blob/main/omspy/orders/depth.py"
    click PegOrders "https://github.com/uberdeveloper/omspy/blob/main/omspy/orders/peg.py"
    click StopOrders "https://github.com/uberdeveloper/omspy/blob/main/omspy/orders/stop.py"
    
    click Straddle "https://github.com/uberdeveloper/omspy/blob/main/omspy/algos/straddle.py"
    click Trailing "https://github.com/uberdeveloper/omspy/blob/main/omspy/algos/trailing.py"
    
    click VirtualTrading "https://github.com/uberdeveloper/omspy/blob/main/omspy/simulation/virtual.py"
    click SimModels "https://github.com/uberdeveloper/omspy/blob/main/omspy/simulation/models.py"
    click SimServer "https://github.com/uberdeveloper/omspy/blob/main/omspy/simulation/server.py"

    %% Styling
    class Base,OrderMgmt,MultiBroker,Models,Utils core
    class APIHelper,Finvasia,ICICI,Neo,Noren,Paper,Zerodha broker
    class DepthOrders,PegOrders,StopOrders order
    class Straddle,Trailing algo
    class VirtualTrading,SimModels,SimServer sim
    class BrokerAPIs external
```
