How beatzxbt/bybit-smm works
Based on our analysis of the file tree and README, we recognize that this project is an algorithmic trading bot—a market making bot specifically designed for Bybit (with an optional Binance data feed). The project is organized around handling live market data via websockets and REST endpoints, processing that data with indicators and strategies, and (optionally) managing orders via an order management component.
Main components
• Environment & Configuration: Represent the .env, parameters.yaml, and configuration files that hold API keys and trading parameters.
• Exchange Interface Modules: Separate components under the “src/exchanges” directory for each supported exchange (Bybit and Binance). Each exchange has its own directories for REST endpoints (GET, POST) and websocket functionalities (with dedicated websocket handlers for different event types, e.g., orderbook updates, trades, executions).
• Shared State & Data Aggregation: A central shared state class (e.g., src/sharedstate.py) that aggregates incoming market data from the various exchange modules. Also consider the “src/exchanges/common” module that includes utilities like local order books.
• Indicators Module: Components found in “src/indicators” that calculate market indicators (for example, Bollinger Band Width, EMA) used by the strategy.
• Strategy Engine: Under the “src/strategy” directory you have the core logic (core.py) and specific features (the features subdirectory) that process market data, evaluate inventory levels, and determine optimal bid/ask quotes. This module incorporates logic for generating pricing, spread adjustments, and managing edge cases.
• Order Management System (OMS): Although mentioned as “currently disabled,” this module (likely in src/strategy/oms.py) is responsible for managing order states, transitions, and sending orders in a rate-limited efficient manner.
• Utility Modules: The “src/utils” folder provides supportive functionality such as rounding, JIT functions, and miscellaneous helpers.
Relationships and Data Flow
• Next, connect the Indicators module to the “Strategy Engine” where different features (e.g., ob_imbalance, trades_imbalance, mark_spread) calculate market conditions and generate optimal quotes. Also, incorporate a relationship from the shared market data directly to strategy modules since some features likely use raw data as well.
• Finally, from the Strategy Engine, show a connection to the “OMS” (Order Management System) which handles order placement and (when enabled) order state transitions. Additionally, show feedback loops or confirmation channels back from the OMS to the shared state if necessary.
Architectural Patterns and Technologies
• That the project separates responsibilities clearly by having different directories for exchange-specific code, strategy, and calculation modules.
• There is an adherence to a clean modular design where data flow is unidirectional: from external market data -> aggregation/shared state -> processing/indicators -> strategy decision making -> order management.
• Python is used as the primary language with supporting libraries indicated in the requirements.txt.
• The use of websockets (real-time data streaming) and REST endpoints suggests an architecture that handles asynchronous data processing, ensuring that components remain decoupled and can be maintained or replaced individually.