wip model CP storage/loading,

models are aware of current position
fix kill stale procc task
This commit is contained in:
Dobromir Popov
2025-07-29 14:51:40 +03:00
parent f34b2a46a2
commit afde58bc40
7 changed files with 472 additions and 82 deletions

View File

@ -103,6 +103,9 @@ class BaseDataInput:
# Market microstructure data
market_microstructure: Dict[str, Any] = field(default_factory=dict)
# Position and trading state information
position_info: Dict[str, Any] = field(default_factory=dict)
def get_feature_vector(self) -> np.ndarray:
"""
Convert BaseDataInput to standardized feature vector for models
@ -174,7 +177,7 @@ class BaseDataInput:
features.extend(indicator_values[:100]) # Take first 100 indicators
features.extend([0.0] * max(0, 100 - len(indicator_values))) # Pad to exactly 100
# Last predictions from other models (FIXED SIZE: 50 features)
# Last predictions from other models (FIXED SIZE: 45 features)
prediction_features = []
for model_output in self.last_predictions.values():
prediction_features.extend([
@ -184,8 +187,18 @@ class BaseDataInput:
model_output.predictions.get('hold_probability', 0.0),
model_output.predictions.get('expected_reward', 0.0)
])
features.extend(prediction_features[:50]) # Take first 50 prediction features
features.extend([0.0] * max(0, 50 - len(prediction_features))) # Pad to exactly 50
features.extend(prediction_features[:45]) # Take first 45 prediction features
features.extend([0.0] * max(0, 45 - len(prediction_features))) # Pad to exactly 45
# Position and trading state information (FIXED SIZE: 5 features)
position_features = [
1.0 if self.position_info.get('has_position', False) else 0.0,
self.position_info.get('position_pnl', 0.0),
self.position_info.get('position_size', 0.0),
self.position_info.get('entry_price', 0.0),
self.position_info.get('time_in_position_minutes', 0.0)
]
features.extend(position_features) # Exactly 5 position features
# CRITICAL: Ensure EXACTLY the fixed feature size
if len(features) > FIXED_FEATURE_SIZE: