Trying to fix flake8

This commit is contained in:
klein panic
2024-12-13 02:43:47 -05:00
parent 4f1d2ab767
commit 03c46dcfb5
32 changed files with 2925 additions and 47 deletions

View File

@@ -1,3 +0,0 @@
# ManPage Readme
- This directory will contain the actual man pages

233
docs/ManPages/midasv1.1 Normal file
View File

@@ -0,0 +1,233 @@
.TH MIDASV1 1 "December 2024" "MidasV1 Manual" "MidasV1 Manual"
.SH NAME
midasv1 \- A modular trading bot for Interactive Brokers
.SH SYNOPSIS
.B python
.RS
.B main.py
[\fB--no-checks\fP]
[\fB--skip-checks\fP]
[\fB--verbose\fP]
[\fB--version\fP]
.RE
.SH 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.
.SH FEATURES
.IP \fBModular Architecture\fP
MidasV1 is divided into multiple modules, each responsible for distinct functionalities, ensuring a clear separation of concerns and streamlined operations.
.IP \fBComprehensive System Checks\fP
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.
.IP \fBReal-Time Market Data Retrieval\fP
Utilizes the IB API to scan and refine a list of stocks based on predefined criteria such as trading volume, net change, and volatility.
.IP \fBAutomated Trading Strategies\fP
Analyzes real-time market data to determine bullish or bearish trends and executes trades accordingly, incorporating risk management protocols.
.IP \fBRisk Management\fP
Implements multi-stage risk assessments to ensure trades are executed within acceptable risk parameters, including stop-loss mechanisms.
.SH WORKFLOW AND PROGRAM DESIGN
MidasV1 operates through a series of interconnected modules, each performing specific tasks:
.IP \fBModule 1: Initial Checks\fP
Includes:
.IP a. Operating System Check
Determines the operating system, supporting Linux by default. Unsupported OSes like Windows and MacOS trigger informative warnings and exit gracefully.
.IP b. Dependency Check
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.
.IP c. Connectivity Check
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.
.IP \fBModule 2: IBJTS List Petitioner\fP
Includes:
.IP a. Scanner
Retrieves a list of stocks that meet predefined criteria such as search volume, net change, and percent change.
.IP b. Refiner
Further refines the scanned stock list based on additional criteria like share price, availability of option contracts, and volatility index.
.IP \fBModule 3: Stock Information Retrieval\fP
Includes:
.IP a. Load
Loads the refined stock list from Module 2.
.IP b. Threaded Information Gathering & Choosing Strategy
Spawns individual threads to fetch real-time market data for each stock and determines the optimal trading strategy based on collected data.
.IP c. Strategy Implementation & Market Determination
Analyzes indicators like RSI, MACD, ADX, and EMA to classify market sentiment as bullish or bearish for each stock.
.IP \fBModule 4: Option Chain Trading & Risk Management\fP
Includes:
.IP a. Option Chain Data
Retrieves and analyzes option chain data for selected bullish and bearish stocks.
.IP b. Risk Management Stage 1
Assesses the acceptability of risk based on user account balance and predefined thresholds.
.IP c. Buying and Selling / Risk Management Stage 2
Executes trades, sets up stop-loss orders, and continuously monitors market data to implement selling strategies.
.IP \fBGeneral Additions\fP
- **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.
.SH FILE STRUCTURE
The project directory `MidasV1` is organized as follows:
.IP \fBproject_root/MidasV1/\fP
.RS
.IP \fBREADME.md\fP
Documentation and overview of the project.
.IP \fBrequirements.txt\fP
Lists all Python dependencies required by MidasV1.
.IP \fBconfig/config.config\fP
Configuration file containing all necessary parameters and thresholds.
.IP \fBmain.py\fP
The primary script that orchestrates the application's flow.
.IP \fBmodules/\fP
Contains all modular components of MidasV1.
.IP \fBmodules/initial_checks.py\fP
Performs system and environment checks.
.IP \fBmodules/stock_list_petitioner.py\fP
Retrieves and refines stock lists based on criteria.
.IP \fBtests/\fP
Contains test scripts for various modules.
.IP \fBtests/test_stock_retriever.py\fP
Tests stock retrieval and filtering.
.IP \fBtests/test_connection.py\fP
Tests connectivity with IB Gateway.
.IP \fBlogs/\fP
Stores detailed execution logs.
.IP \fBlogs/MidasV1.log\fP
.IP \fBdata/\fP
Stores JSON files with raw market data for each stock.
.RE
.SH INSTALLATION
.IP \fBPrerequisites\fP
.B Python 3.6+
.B Interactive Brokers (IB) Account
.IP \fBSteps\fP
.RS
.IP 1. Clone the Repository
.B
.RS
.nf
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
.RE
.IP 2. Download IB API
Download and install the latest version of the [Interactive Brokers API](https://www.interactivebrokers.com/en/index.php?f=5041).
.IP 3. Configure IB Gateway
Ensure that IB Gateway is running with API settings configured to allow connections from your machine.
.RE
.SH CONFIGURATION
All configurable parameters are stored in `config/config.config`. Below is an example configuration:
.RS
.IP \fB[Connectivity]\fP
.B host = 127.0.0.1
.B port = 4002
.B client_id = 0
.IP \fB[Logging]\fP
.B level = INFO
.IP \fB[Module2]\fP
.B default_search_volume = 1000000
.B default_net_change = 0.50
.B default_percent_change = 2.0
.B default_refinement_share_price = 15.0
.B default_volatility_threshold = 30.0
.B conditional_refinement_enabled = True
.B max_refined_list_size = 100
.RE
.SH USAGE
Run the application using the following command:
.RS
.IP \fBpython main.py\fP
[\fB--no-checks\fP]
[\fB--skip-checks\fP]
[\fB--verbose\fP]
[\fB--version\fP]
.RE
.IP \fBAvailable Flags\fP
.TP
\fB--no-checks\fP
Run the program without prompting for user confirmation after initial checks.
.TP
\fB--skip-checks\fP
Skip specific initial checks (primarily dependency checks).
.TP
\fB--verbose\fP
Enable verbose and colorful output to the console.
.TP
\fB--version\fP
Print the program version and exit.
.RE
.SH LOGGING
MidasV1 utilizes both file-based logging and colored console outputs to track its operations.
.IP \fBLog File\fP
.B logs/MidasV1.log
Stores detailed logs including debug information, errors, and informational messages.
.IP \fBConsole Outputs\fP
Color-coded messages enhance readability:
.IP \fBGreen\fP
Indicates successful operations or passing criteria.
.IP \fBRed\fP
Highlights errors or critical issues.
.IP \fBYellow\fP
Used for warnings and informational messages.
.IP \fBBlue\fP and \fBMagentafP
Used for decorative separators and headers.
.RE
.SH FUTURE ENHANCEMENTS
MidasV1 is designed with scalability in mind, allowing for future feature additions and optimizations:
.IP \fBOperating System Support\fP
Extend support to Windows, MacOS, BSD, illumos, etc., with specific handling mechanisms.
.IP \fBAdvanced Dependency Management\fP
Implement dynamic dependency resolution and version management.
.IP \fBEnhanced Strategy Module\fP
Develop more sophisticated trading strategies based on additional market indicators.
.IP \fBRisk Management Enhancements\fP
Implement multi-stage risk assessments and portfolio diversification strategies.
.IP \fBPerformance Optimization\fP
Utilize system resource checks to dynamically allocate threads for optimal performance.
.IP \fBUser Interface\fP
Develop a graphical user interface (GUI) for easier interaction and monitoring.
.IP \fBExtensive Testing\fP
Expand test coverage to include integration and stress tests, and implement CI pipelines.
.IP \fBDocumentation & Support\fP
Enhance documentation with tutorials and usage guides, and provide support mechanisms.
.RE
.SH DISCLAIMER
.B 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.
.SH AUTHOR
.CC
kleinpainc (kleinpanic@gmail.com)
.RE
.SH COPYRIGHT
.CC
© 2024 kleinpanic. All rights reserved.
.RE

View File

@@ -1,6 +1,6 @@
# Documentation Directory
Welcome to the **Documentation** directory for the project. This directory is divided into three primary sections: **Business Documentation**, **Policies and Standards**, and **Man Pages**. Each subdirectory has a unique purpose and serves to organize our projects documentation comprehensively. Please follow the structure and guidelines below when adding new documents.
Welcome to the **Documentation** directory for the **MidasV1** project. This directory is organized into three primary sections: **Business Documentation**, **Policies and Standards**, and **Man Pages**. Each subdirectory serves a unique purpose, ensuring comprehensive and organized documentation for our project. Please adhere to the structure and guidelines below when adding new documents.
---
@@ -9,19 +9,44 @@ Welcome to the **Documentation** directory for the project. This directory is di
```
docs/
├── business_docs/
│ ├── business_plan.md
│ ├── lcc_documentation.md
└── legal_license.md
├── BusinessDocumentation/
│ ├── BusinessPlans/
│ ├── AUP.md
│ ├── ConfidentialityAgreementForThirdPartyContractorsAndVendors.md
│ │ ├── ContributorAgreement.md
│ │ ├── CyberSecurityAgreement.md
│ │ ├── DataRetentionPolicy.md
│ │ ├── DataUseAdPrivacyPolicy.md
│ │ ├── DisasterRecoveryAndBusinessContinuityPlan.md
│ │ ├── EmployeeConsultantOnboardingAgreement.md
│ │ ├── EmployeeHandbook.md
│ │ ├── EULA.md
│ │ ├── ExecutiveSummary.md
│ │ ├── IntellectualPropertyAssignmentAgreement.md
│ │ ├── Non-CompeteAndNon-SolicitationAgreement.md
│ │ ├── oil_oracle.md
│ │ ├── OperatingAgreement.md
│ │ ├── PartnershipAgreement.md
│ │ ├── SoftwareDevelopmentAndLicensingAgreements.md
│ │ └── TradeSecretPolicy.md
│ ├── CodingPlans/
│ │ └── MidasV1Docs.md
│ ├── LegalDocs/
│ │ └── MidasTechNologiesLLCBylaws.md
│ └── LICENSE
├── policies_standards/
── coding_standards.md
│ ├── code_review_policy.md
│ ├── documentation_standards.md
│ └── file_path_standards.md
├── ManPages/
── midasv1.1
── man_pages/
── overall_code_documentation.md
── PoliciesAndStandards/
── CodingStandards.md
│ ├── CommunicationStandards.md
│ ├── DocumentationStandards.md
│ ├── FilePathStandards.md
│ ├── GitAndGithubStandards.md
│ └── README.md
└── README.md
```
---
@@ -30,26 +55,52 @@ docs/
### 1. Business Documentation
- **Purpose**: Contains all relevant business-related documentation, legal filings, and operational plans. This section helps ensure that we keep a clear record of our companys structural and strategic information.
- **Purpose**: Contains all business-related documentation, legal filings, and operational plans. This section ensures a clear record of our companys structural and strategic information.
- **Contents**:
- `business_plan.md`: Outlines our companys mission, vision, target market, competitive analysis, and growth strategies.
- `lcc_documentation.md`: Contains LLC formation details, ownership structure, and any legal requirements.
- `legal_license.md`: Provides a summary of licenses, terms, and legal disclaimers for our software products.
- `BusinessPlans/`:
- **AUP.md**: Acceptable Use Policy outlining permitted and prohibited activities.
- **ConfidentialityAgreementForThirdPartyContractorsAndVendors.md**: Agreements ensuring confidentiality with third-party contractors and vendors.
- **ContributorAgreement.md**: Terms and conditions for contributors to the project.
- **CyberSecurityAgreement.md**: Policies related to cybersecurity measures and protocols.
- **DataRetentionPolicy.md**: Guidelines on data retention and disposal.
- **DataUseAdPrivacyPolicy.md**: Policies governing data usage and privacy.
- **DisasterRecoveryAndBusinessContinuityPlan.md**: Plans for disaster recovery and maintaining business operations during disruptions.
- **EmployeeConsultantOnboardingAgreement.md**: Agreements for onboarding employees and consultants.
- **EmployeeHandbook.md**: Comprehensive guide for employees covering company policies, procedures, and culture.
- **EULA.md**: End-User License Agreement detailing usage terms for software products.
- **ExecutiveSummary.md**: High-level overview of the company's mission, vision, and strategic goals.
- **IntellectualPropertyAssignmentAgreement.md**: Agreements ensuring assignment of intellectual property rights.
- **Non-CompeteAndNon-SolicitationAgreement.md**: Agreements preventing competition and solicitation of clients or employees.
- **oil_oracle.md**: Specific documentation related to the Oil Oracle project/component.
- **OperatingAgreement.md**: Operational guidelines for the companys management.
- **PartnershipAgreement.md**: Agreements detailing the terms of partnerships.
- **SoftwareDevelopmentAndLicensingAgreements.md**: Agreements related to software development and licensing.
- **TradeSecretPolicy.md**: Policies protecting trade secrets and sensitive information.
- `CodingPlans/`:
- **MidasV1Docs.md**: Documentation related to the coding plans and strategies for MidasV1.
- `LegalDocs/`:
- **MidasTechNologiesLLCBylaws.md**: Bylaws governing the operations of Midas Technologies LLC.
- `LICENSE`: Licensing information for the project.
### 2. Policies and Standards
- **Purpose**: This section includes all coding, collaboration, and workflow guidelines to maintain consistency and quality across the project. It also contains standard operating procedures (SOPs) for code quality and collaboration, fostering a productive and unified development environment.
- **Purpose**: Includes all coding, collaboration, and workflow guidelines to maintain consistency and quality across the project. It also contains standard operating procedures (SOPs) for code quality and collaboration, fostering a productive and unified development environment.
- **Contents**:
- `coding_standards.md`: Outlines coding conventions and best practices for this project.
- `code_review_policy.md`: Details our policies for reviewing code and handling pull requests.
- `documentation_standards.md`: Specifies standards for documenting code and creating README files.
- `file_path_standards.md`: Establishes naming conventions and organization standards for files and directories.
- `CodingStandards.md`: Outlines coding conventions and best practices for this project.
- `CommunicationStandards.md`: Defines standards for team communication and collaboration.
- `DocumentationStandards.md`: Specifies standards for documenting code and creating README files.
- `FilePathStandards.md`: Establishes naming conventions and organization standards for files and directories.
- `GitAndGithubStandards.md`: Details best practices for using Git and GitHub, including branching strategies and commit messages.
- `README.md`: Overview and guidelines specific to the Policies and Standards section.
### 3. Man Pages
- **Purpose**: Acts as an accessible, high-level guide to overall code structure, intended to assist both new and existing team members in understanding the projects architecture. This section contains **man pages** for broader code documentation, while specific functionality and module-level details can be found in `src/` README files.
- **Purpose**: Provides accessible, high-level guides and detailed documentation for the codebase. This section contains **man pages** for broader code documentation, assisting both new and existing team members in understanding the projects architecture and functionalities.
- **Contents**:
- `overall_code_documentation.md`: Offers a high-level overview of the codebase, including descriptions of major components, workflows, and integrations within the project.
- `midasv1.1`: The manual page for MidasV1, detailing its usage, options, and functionalities. This man page can be accessed using the `man` command.
---
@@ -57,13 +108,48 @@ docs/
1. **Check the Directory**:
- Ensure you are adding files to the correct subdirectory according to the documents purpose.
- **Business Documentation**: Add business-related and legal documents.
- **Policies and Standards**: Add coding, communication, and workflow policies.
- **Man Pages**: Add manual pages and advanced code documentation.
2. **Naming Conventions**:
- Use clear, concise, and descriptive file names for new documents.
- File names should be lowercase and use underscores instead of spaces (e.g., `new_policy_doc.md`).
- File names should be lowercase with underscores instead of spaces (e.g., `new_policy_doc.md`).
3. **Update Section Summaries**:
- When adding new files, briefly update this `README.md` to reflect any changes within each section.
- Ensure consistency in documentation style and formatting across all files.
4. **Maintain Consistency**:
- Follow existing structures and templates when creating new documentation.
- Adhere to the standards outlined in the `PoliciesAndStandards` section to ensure uniformity.
5. **Review Before Adding**:
- Before adding a new document, verify that it does not duplicate existing content.
- Ensure that all new documentation is reviewed for accuracy and completeness.
---
Each contributor should refer to this directory and structure before adding or modifying documentation to maintain clarity and organization throughout the project. For specific questions on policies or code documentation, refer to the relevant files in **Policies and Standards** or **Man Pages**.
---
## Additional Documentation
Beyond the primary sections, the `docs/` directory may include additional documentation as needed. Ensure that any new documentation aligns with the existing structure and adheres to the guidelines outlined above.
---
**Note**: The **Man Pages** section is dedicated to actual manpages and advanced code documentation. Ensure that manpages are formatted correctly using the appropriate tools (e.g., `groff`) to maintain readability and functionality when accessed via the `man` command.
---
## Contact
For any questions or further assistance regarding the documentation structure or adding new documents, please reach out to the project maintainer.
---
## License
Please refer to the `LICENSE` file within the `BusinessDocumentation` directory for licensing information pertaining to the MidasV1 project.