-
Notifications
You must be signed in to change notification settings - Fork 21
Refactor/modernize 2025 #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SL-Mar
wants to merge
8
commits into
main
Choose a base branch
from
refactor/modernize-2025
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Major Changes ### OpenAI SDK Migration (0.28 → 1.x+) - Created LLMClient abstraction layer (quantcli/llm_client.py) - Migrated all openai.ChatCompletion.create() calls to new SDK - Removed global openai.api_key configuration - Added LLMResponse dataclass for standardized responses - Improved error handling and logging for LLM calls ### Dependency Updates - Bumped Python requirement to >= 3.9 - Updated OpenAI SDK to >= 1.0.0 - Added modern dependencies: rich, pytest, mypy, ruff - Created clean requirements.txt (replaced legacy freeze) - Updated setup.py to v1.0.0 with enhanced metadata ### Testing Infrastructure - Added pytest configuration (pytest.ini) - Created test suite for LLMClient (tests/test_llm_client.py) - Configured coverage reporting - Added test markers (unit/integration/slow) ### Documentation - Completely rewrote README.md (removed "legacy" branding) - Added CHANGELOG.md with migration guide - Updated installation instructions - Added badges and modern formatting - Highlighted v1.0.0 improvements ### Code Quality - Added LLMClient with proper type hints - Improved logging in processor.py - Token usage tracking for cost monitoring - Structured error handling ## Breaking Changes - Requires OpenAI SDK >= 1.0.0 (incompatible with 0.28) - Python >= 3.9 required (was 3.8) ## Migration Path Users can upgrade seamlessly: ```bash pip install --upgrade openai>=1.0.0 pip install -e . ``` No code changes required - LLMClient handles SDK differences internally. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Move tkinter imports from module level to function level in processor.py - Make GUI imports conditional in cli.py - CLI commands now work without python3-tk system package - Interactive mode shows helpful error message if tkinter unavailable - All other CLI commands (search, list, download, etc.) fully functional
PROBLEM: Generated algorithms had 3 runtime errors on first backtest - NoneType comparison in max/min operations - Division by zero in position sizing - Missing null guards before trading logic SOLUTION: Multi-layered quality improvements 1. Enhanced Code Generation Prompt - Added explicit defensive programming requirements - Included safety pattern examples (None checks, division guards) - Emphasized PRODUCTION-READY code generation 2. Enhanced Refinement Prompt - Added safety checklist to refinement process - Ensures all defensive patterns are present 3. New QuantConnectValidator Class - Runtime safety validation layer - Detects: division by zero, None comparisons, missing IsReady checks - Provides actionable fix suggestions - File: quantcli/qc_validator.py 4. CLI Improvements - Fixed None return value handling in generate-code command - Better error messages for failed code generation IMPACT: - Improves generated code reliability - Reduces manual fixes required - Moves toward production-ready algorithms TODO (v1.1.0): - Integrate validator into generation pipeline - Add test suite - Document in CHANGELOG Issue: See /tmp/github_issue_quality.md for full details
## Security Enhancements - Add missing `requests` import in utils.py (CRITICAL BUG FIX) - Implement URL validation before webbrowser.open() calls - Add validate_url() function to check URL safety - Replace hardcoded email with UNPAYWALL_EMAIL environment variable ## Configuration - Create .env.example documenting all environment variables - Add support for UNPAYWALL_EMAIL configuration ## Changes - quantcli/utils.py: Add requests import, urlparse, validate_url() - quantcli/cli.py: Add URL validation to browser operations - quantcli/gui.py: Add URL validation to browser operations - .env.example: Document all configurable environment variables These changes improve security by validating all URLs before opening them in the browser and fix the critical missing requests import bug.
- Installation verification steps - Security testing procedures - Example workflows - Troubleshooting guide - Complete CLI command reference
…V1sadPRrxj5sPHjWp7Wa Claude/refactor modernize 2025 011 cv1sad p rrxj5s p hj wp7 wa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactoring to improve algo generation