Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 49 additions & 14 deletions .cursorrules
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This file provides guidance to Cursor AI when working with code in this repository.

## Project Status: v3.1.1 - Stable Production Release
## Project Status: v3.2.0 - Enhanced Type Safety Release

**IMPORTANT**: This project uses a fully asynchronous architecture. All APIs are async-only, optimized for high-performance futures trading.

Expand All @@ -27,27 +27,62 @@ Example approach:
- ❌ DON'T: Remove deprecated features without proper notice period

### Deprecation Process
1. Mark as deprecated with `warnings.warn()` and `@deprecated` decorator
2. Document replacement in deprecation message
1. Use the standardized `@deprecated` decorator from `project_x_py.utils.deprecation`
2. Provide clear reason, version info, and replacement path
3. Keep deprecated feature for at least 2 minor versions
4. Remove only in major version releases (4.0.0, 5.0.0, etc.)

Example:
```python
import warnings
from typing import deprecated

@deprecated("Use new_method() instead. Will be removed in v4.0.0")
from project_x_py.utils.deprecation import deprecated, deprecated_class

# For functions/methods
@deprecated(
reason="Method renamed for clarity",
version="3.1.14", # When deprecated
removal_version="4.0.0", # When it will be removed
replacement="new_method()" # What to use instead
)
def old_method(self):
warnings.warn(
"old_method() is deprecated, use new_method() instead. "
"Will be removed in v4.0.0",
DeprecationWarning,
stacklevel=2
)
return self.new_method()

# For classes
@deprecated_class(
reason="Integrated into TradingSuite",
version="3.1.14",
removal_version="4.0.0",
replacement="TradingSuite"
)
class OldManager:
pass
```

The standardized deprecation utilities provide:
- Consistent warning messages across the SDK
- Automatic docstring updates with deprecation info
- IDE support through the `deprecated` package
- Metadata tracking for deprecation management
- Support for functions, methods, classes, and parameters

## Development Documentation

### Important: Keep Project Clean - Use External Documentation

**DO NOT create project files for**:
- Personal development notes
- Temporary planning documents
- Testing logs and results
- Work-in-progress documentation
- Meeting notes or discussions

**Instead, use**:
- External documentation tools (Obsidian, Notion, etc.)
- GitHub Issues for bug tracking
- GitHub Discussions for architecture decisions
- Pull Request descriptions for implementation details

This keeps the project repository clean and focused on production code.

## Development Commands

### Package Management (UV)
Expand Down Expand Up @@ -96,7 +131,7 @@ uv run python -m build # Alternative build command

## Project Architecture

### Core Components (v3.0.1 - Multi-file Packages)
### Core Components (v3.0.2 - Multi-file Packages)

**ProjectX Client (`src/project_x_py/client/`)**
- Main async API client for TopStepX ProjectX Gateway
Expand Down
85 changes: 85 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,91 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Migration guides will be provided for all breaking changes
- Semantic versioning (MAJOR.MINOR.PATCH) is strictly followed

## [3.2.0] - 2025-08-17

### Added
- **🎯 Comprehensive Type System Overhaul**: Major improvements to type safety across the SDK
- Added TypedDict definitions for all API responses and callback data structures
- Created comprehensive Protocol definitions for all major SDK components
- Implemented proper type hints for all async/await patterns
- Added type-safe event data structures for the EventBus system

- **πŸ“Š StatsTrackingMixin**: New mixin for comprehensive error and memory tracking
- Automatic error history tracking with configurable limits
- Memory usage statistics for all managers
- Performance metrics collection
- Integrated into OrderManager, PositionManager, OrderBook, and RiskManager

- **πŸ“‹ Standardized Deprecation System**: Unified deprecation handling across SDK
- New `@deprecated` and `@deprecated_class` decorators
- Consistent version tracking and removal schedules
- Clear migration paths in all deprecation messages
- Metadata tracking for deprecated features

- **πŸ§ͺ Comprehensive Test Coverage**: Added 47 new tests for type system
- Full test coverage for new TypedDict definitions
- Protocol compliance testing
- Task management mixin testing
- Increased overall test coverage significantly

### Fixed
- **πŸ”§ Type Hierarchy Issues**: Resolved all client mixin type conflicts
- Fixed incompatible type hierarchy between ProjectXBase and ProjectXClientProtocol
- Corrected mixin method signatures to work properly with base class
- Added proper attribute declarations in mixins
- Fixed all "self" type annotations in mixin methods

- **βœ… Response Type Handling**: Fixed union type issues in API responses
- Added isinstance checks before calling .get() on API responses
- Properly handle dict|list union types from _make_request
- Fixed all "Item 'list[Any]' has no attribute 'get'" errors
- Improved error handling for malformed API responses

- **πŸ§‘ Task Management**: Fixed async task lifecycle issues
- Properly handle task cleanup on cancellation
- Fixed WeakSet usage for garbage collection
- Resolved all asyncio deprecation warnings
- Improved error propagation in background tasks

### Improved
- **πŸ“¦ Code Organization**: Major structural improvements
- Consolidated duplicate order tracking functionality
- Removed dead code and unused features
- Cleaned up imports and removed unnecessary TYPE_CHECKING blocks
- Standardized error handling patterns

- **πŸ“ Type Safety**: Dramatically improved type checking
- Reduced type errors from 100+ to just 13 edge cases
- All core modules now pass strict type checking
- Better IDE support with proper type hints
- Improved code completion and static analysis

- **🎯 API Consistency**: Standardized patterns across SDK
- Consistent use of async/await patterns
- Unified event handling through EventBus
- Standardized error messages and logging
- Consistent method naming conventions

### Performance
- Memory tracking now integrated into all major components
- Better garbage collection with proper weak references
- Optimized event emission to prevent handler deadlocks
- Improved type checking performance with better annotations

### Breaking Changes
- None - Full backward compatibility maintained

### Deprecations
- Legacy callback methods in OrderTrackingMixin (use EventBus instead)
- Several internal utility functions marked for removal in v4.0.0

### Migration Notes
No migration required from v3.1.x. The type system improvements are fully backward compatible.
If you experience any type checking issues in your code:
1. Update your type hints to match the new Protocol definitions
2. Use the provided TypedDict types for API responses
3. Follow the examples in the documentation for proper async patterns

## [3.1.13] - 2025-08-15

### Fixed
Expand Down
Loading
Loading