MIDASV1(1)

NAME
midasv1 - A modular trading bot for Interactive Brokers

SYNOPSIS
python
    main.py [--no-checks] [--skip-checks] [--verbose] [--version]

DESCRIPTION
MidasV1 is a sophisticated trading bot written in Python, designed to interact seamlessly with the Interactive Brokers (IB) Gateway or the IBJTS API and JTS. Leveraging a modular architecture, MidasV1 performs comprehensive system checks, retrieves and refines stock data, executes trading strategies based on real-time market analysis, and manages risks effectively.

FEATURES

Modular
    MidasV1 is divided into multiple modules, each responsible for distinct functionalities, ensuring a clear separation of concerns and streamlined operations.

Comprehensive
    Before initiating trading operations, MidasV1 verifies the operating system, checks for necessary dependencies, assesses system resources, and ensures a secure connection with the IB Gateway.

Real-Time
    Utilizes the IB API to scan and refine a list of stocks based on predefined criteria such as trading volume, net change, and volatility.

Automated
    Analyzes real-time market data to determine bullish or bearish trends and executes trades accordingly, incorporating risk management protocols.

Risk
    Implements multi-stage risk assessments to ensure trades are executed within acceptable risk parameters, including stop-loss mechanisms.

WORKFLOW AND PROGRAM DESIGN
MidasV1 operates through a series of interconnected modules, each performing specific tasks:

Module
    Includes:

a.  Determines the operating system, supporting Linux by default. Unsupported OSes like Windows and MacOS trigger informative warnings and exit gracefully.

b.  Reads required dependencies from `requirements.txt` located in the parent directory. Ensures all necessary Python packages are installed, informing the user of any missing dependencies with clear instructions.

c.  Verifies a secure connection with the IB Gateway using configuration parameters from `config/config.config`. Reports connectivity status with colored and formatted messages for enhanced readability.

Module
    Includes:

a.  Retrieves a list of stocks that meet predefined criteria such as search volume, net change, and percent change.

b.  Further refines the scanned stock list based on additional criteria like share price, availability of option contracts, and volatility index.

Module
    Includes:

a.  Loads the refined stock list from Module 2.

b.  Spawns individual threads to fetch real-time market data for each stock and determines the optimal trading strategy based on collected data.

c.  Analyzes indicators like RSI, MACD, ADX, and EMA to classify market sentiment as bullish or bearish for each stock.

Module
    Includes:

a.  Retrieves and analyzes option chain data for selected bullish and bearish stocks.

b.  Assesses the acceptability of risk based on user account balance and predefined thresholds.

c.  Executes trades, sets up stop-loss orders, and continuously monitors market data to implement selling strategies.

General
    - **Command-Line Flags:** Allows users to run the program with or without initial checks, enable verbose output, and display the program version. - **Logging & Console Outputs:** Implements both file-based logging and colored console outputs for better traceability and user feedback. - **Graceful Shutdowns:** Handles interrupt signals to ensure connections are closed properly. - **Extensibility:** Designed to determine the number of threads based on system resources for optimal performance.

FILE STRUCTURE
The project directory `MidasV1` is organized as follows:

project_root/MidasV1/

    README.md
        Documentation and overview of the project.

    requirements.txt
        Lists all Python dependencies required by MidasV1.

    config/config.config
        Configuration file containing all necessary parameters and thresholds.

    main.py
        The primary script that orchestrates the application's flow.

    modules/
        Contains all modular components of MidasV1.

    modules/initial_checks.py
        Performs system and environment checks.

    modules/stock_list_petitioner.py
        Retrieves and refines stock lists based on criteria.

    tests/
        Contains test scripts for various modules.

    tests/test_stock_retriever.py
        Tests stock retrieval and filtering.

    tests/test_connection.py
        Tests connectivity with IB Gateway.

    logs/
        Stores detailed execution logs.

    logs/MidasV1.log

    data/
        Stores JSON files with raw market data for each stock.

INSTALLATION

Prerequisites
    Python 3.6+ Interactive Brokers (IB) Account

Steps

    1.
        python -m venv venv
        source venv/bin/activate  # On Windows: venvtivate
        pip install -r requirements.txt

    2.  Download and install the latest version of the [Interactive Brokers API](https://www.interactivebrokers.com/en/index.php?f=5041).

    3.  Ensure that IB Gateway is running with API settings configured to allow connections from your machine.

CONFIGURATION
All configurable parameters are stored in `config/config.config`. Below is an example configuration:

    [Connectivity]
        host = 127.0.0.1 port = 4002 client_id = 0

    [Logging]
        level = INFO

    [Module2]
        default_search_volume = 1000000 default_net_change = 0.50 default_percent_change = 2.0 default_refinement_share_price = 15.0 default_volatility_threshold = 30.0 conditional_refinement_enabled = True max_refined_list_size = 100

USAGE
Run the application using the following command:

    python
        [--no-checks] [--skip-checks] [--verbose] [--version]

Available

--no-checks
    Run the program without prompting for user confirmation after initial checks.

--skip-checks
    Skip specific initial checks (primarily dependency checks).

--verbose
    Enable verbose and colorful output to the console.

--version
    Print the program version and exit.

LOGGING
MidasV1 utilizes both file-based logging and colored console outputs to track its operations.

Log logs/MidasV1.log Stores detailed logs including debug information, errors, and informational messages.

Console
    Color-coded messages enhance readability:

Green
    Indicates successful operations or passing criteria.

Red Highlights errors or critical issues.

Yellow
    Used for warnings and informational messages.

Blue
    Used for decorative separators and headers.

FUTURE ENHANCEMENTS
MidasV1 is designed with scalability in mind, allowing for future feature additions and optimizations:

Operating
    Extend support to Windows, MacOS, BSD, illumos, etc., with specific handling mechanisms.

Advanced
    Implement dynamic dependency resolution and version management.

Enhanced
    Develop more sophisticated trading strategies based on additional market indicators.

Risk
    Implement multi-stage risk assessments and portfolio diversification strategies.

Performance
    Utilize system resource checks to dynamically allocate threads for optimal performance.

User
    Develop a graphical user interface (GUI) for easier interaction and monitoring.

Extensive
    Expand test coverage to include integration and stress tests, and implement CI pipelines.

Documentation
    Enhance documentation with tutorials and usage guides, and provide support mechanisms.

DISCLAIMER
MidasV1 is proprietary software developed for private use. Unauthorized distribution, replication, or modification is strictly prohibited. The author assumes no responsibility for any misuse or damages resulting from the use of this software. Users are advised to thoroughly test the application in a controlled environment (e.g., paper trading) before deploying it in live trading scenarios.

AUTHOR
kleinpainc (kleinpanic@gmail.com)

COPYRIGHT
© 2024 kleinpanic. All rights reserved.