Skip to content

Commit bcfadd9

Browse files
authored
Merge pull request #47 from TexasCoding/patching_v3.1.14
Release v3.2.0: Enhanced Type Safety & Developer Experience
2 parents 5c7f8ff + ea05ed0 commit bcfadd9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+3971
-922
lines changed

.cursorrules

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

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

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

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

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

3535
Example:
3636
```python
37-
import warnings
38-
from typing import deprecated
39-
40-
@deprecated("Use new_method() instead. Will be removed in v4.0.0")
37+
from project_x_py.utils.deprecation import deprecated, deprecated_class
38+
39+
# For functions/methods
40+
@deprecated(
41+
reason="Method renamed for clarity",
42+
version="3.1.14", # When deprecated
43+
removal_version="4.0.0", # When it will be removed
44+
replacement="new_method()" # What to use instead
45+
)
4146
def old_method(self):
42-
warnings.warn(
43-
"old_method() is deprecated, use new_method() instead. "
44-
"Will be removed in v4.0.0",
45-
DeprecationWarning,
46-
stacklevel=2
47-
)
4847
return self.new_method()
48+
49+
# For classes
50+
@deprecated_class(
51+
reason="Integrated into TradingSuite",
52+
version="3.1.14",
53+
removal_version="4.0.0",
54+
replacement="TradingSuite"
55+
)
56+
class OldManager:
57+
pass
4958
```
5059

60+
The standardized deprecation utilities provide:
61+
- Consistent warning messages across the SDK
62+
- Automatic docstring updates with deprecation info
63+
- IDE support through the `deprecated` package
64+
- Metadata tracking for deprecation management
65+
- Support for functions, methods, classes, and parameters
66+
67+
## Development Documentation
68+
69+
### Important: Keep Project Clean - Use External Documentation
70+
71+
**DO NOT create project files for**:
72+
- Personal development notes
73+
- Temporary planning documents
74+
- Testing logs and results
75+
- Work-in-progress documentation
76+
- Meeting notes or discussions
77+
78+
**Instead, use**:
79+
- External documentation tools (Obsidian, Notion, etc.)
80+
- GitHub Issues for bug tracking
81+
- GitHub Discussions for architecture decisions
82+
- Pull Request descriptions for implementation details
83+
84+
This keeps the project repository clean and focused on production code.
85+
5186
## Development Commands
5287

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

97132
## Project Architecture
98133

99-
### Core Components (v3.0.1 - Multi-file Packages)
134+
### Core Components (v3.0.2 - Multi-file Packages)
100135

101136
**ProjectX Client (`src/project_x_py/client/`)**
102137
- Main async API client for TopStepX ProjectX Gateway

CHANGELOG.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,91 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Migration guides will be provided for all breaking changes
1515
- Semantic versioning (MAJOR.MINOR.PATCH) is strictly followed
1616

17+
## [3.2.0] - 2025-08-17
18+
19+
### Added
20+
- **🎯 Comprehensive Type System Overhaul**: Major improvements to type safety across the SDK
21+
- Added TypedDict definitions for all API responses and callback data structures
22+
- Created comprehensive Protocol definitions for all major SDK components
23+
- Implemented proper type hints for all async/await patterns
24+
- Added type-safe event data structures for the EventBus system
25+
26+
- **📊 StatsTrackingMixin**: New mixin for comprehensive error and memory tracking
27+
- Automatic error history tracking with configurable limits
28+
- Memory usage statistics for all managers
29+
- Performance metrics collection
30+
- Integrated into OrderManager, PositionManager, OrderBook, and RiskManager
31+
32+
- **📋 Standardized Deprecation System**: Unified deprecation handling across SDK
33+
- New `@deprecated` and `@deprecated_class` decorators
34+
- Consistent version tracking and removal schedules
35+
- Clear migration paths in all deprecation messages
36+
- Metadata tracking for deprecated features
37+
38+
- **🧪 Comprehensive Test Coverage**: Added 47 new tests for type system
39+
- Full test coverage for new TypedDict definitions
40+
- Protocol compliance testing
41+
- Task management mixin testing
42+
- Increased overall test coverage significantly
43+
44+
### Fixed
45+
- **🔧 Type Hierarchy Issues**: Resolved all client mixin type conflicts
46+
- Fixed incompatible type hierarchy between ProjectXBase and ProjectXClientProtocol
47+
- Corrected mixin method signatures to work properly with base class
48+
- Added proper attribute declarations in mixins
49+
- Fixed all "self" type annotations in mixin methods
50+
51+
- **✅ Response Type Handling**: Fixed union type issues in API responses
52+
- Added isinstance checks before calling .get() on API responses
53+
- Properly handle dict|list union types from _make_request
54+
- Fixed all "Item 'list[Any]' has no attribute 'get'" errors
55+
- Improved error handling for malformed API responses
56+
57+
- **🧑 Task Management**: Fixed async task lifecycle issues
58+
- Properly handle task cleanup on cancellation
59+
- Fixed WeakSet usage for garbage collection
60+
- Resolved all asyncio deprecation warnings
61+
- Improved error propagation in background tasks
62+
63+
### Improved
64+
- **📦 Code Organization**: Major structural improvements
65+
- Consolidated duplicate order tracking functionality
66+
- Removed dead code and unused features
67+
- Cleaned up imports and removed unnecessary TYPE_CHECKING blocks
68+
- Standardized error handling patterns
69+
70+
- **📝 Type Safety**: Dramatically improved type checking
71+
- Reduced type errors from 100+ to just 13 edge cases
72+
- All core modules now pass strict type checking
73+
- Better IDE support with proper type hints
74+
- Improved code completion and static analysis
75+
76+
- **🎯 API Consistency**: Standardized patterns across SDK
77+
- Consistent use of async/await patterns
78+
- Unified event handling through EventBus
79+
- Standardized error messages and logging
80+
- Consistent method naming conventions
81+
82+
### Performance
83+
- Memory tracking now integrated into all major components
84+
- Better garbage collection with proper weak references
85+
- Optimized event emission to prevent handler deadlocks
86+
- Improved type checking performance with better annotations
87+
88+
### Breaking Changes
89+
- None - Full backward compatibility maintained
90+
91+
### Deprecations
92+
- Legacy callback methods in OrderTrackingMixin (use EventBus instead)
93+
- Several internal utility functions marked for removal in v4.0.0
94+
95+
### Migration Notes
96+
No migration required from v3.1.x. The type system improvements are fully backward compatible.
97+
If you experience any type checking issues in your code:
98+
1. Update your type hints to match the new Protocol definitions
99+
2. Use the provided TypedDict types for API responses
100+
3. Follow the examples in the documentation for proper async patterns
101+
17102
## [3.1.13] - 2025-08-15
18103

19104
### Fixed

0 commit comments

Comments
 (0)