wip dqn state
This commit is contained in:
@ -3660,9 +3660,24 @@ class TradingOrchestrator:
|
|||||||
# Check if dictionary is empty - this is the main issue!
|
# Check if dictionary is empty - this is the main issue!
|
||||||
if not model_input:
|
if not model_input:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"Empty dictionary passed as model_input for {model_name}, using data provider fallback"
|
f"Empty dictionary passed as model_input for {model_name}, using build_base_data_input fallback"
|
||||||
)
|
)
|
||||||
# Use data provider to build proper state as fallback
|
# Use the same data source as the new training system
|
||||||
|
try:
|
||||||
|
# Try to get symbol from the record context or use default
|
||||||
|
symbol = "ETH/USDT" # Default symbol
|
||||||
|
base_data = self.build_base_data_input(symbol)
|
||||||
|
if base_data and hasattr(base_data, "get_feature_vector"):
|
||||||
|
state = base_data.get_feature_vector()
|
||||||
|
if isinstance(state, np.ndarray) and state.size > 0:
|
||||||
|
logger.info(
|
||||||
|
f"Generated fresh state for {model_name} from build_base_data_input: shape={state.shape}"
|
||||||
|
)
|
||||||
|
return state
|
||||||
|
except Exception as e:
|
||||||
|
logger.debug(f"build_base_data_input fallback failed for {model_name}: {e}")
|
||||||
|
|
||||||
|
# Fallback to data provider method
|
||||||
return self._generate_fresh_state_fallback(model_name)
|
return self._generate_fresh_state_fallback(model_name)
|
||||||
|
|
||||||
# Try to extract features from dictionary
|
# Try to extract features from dictionary
|
||||||
@ -3719,7 +3734,23 @@ class TradingOrchestrator:
|
|||||||
def _generate_fresh_state_fallback(self, model_name: str) -> np.ndarray:
|
def _generate_fresh_state_fallback(self, model_name: str) -> np.ndarray:
|
||||||
"""Generate a fresh state from current market data when model_input is empty/invalid"""
|
"""Generate a fresh state from current market data when model_input is empty/invalid"""
|
||||||
try:
|
try:
|
||||||
# Try to use data provider to build fresh state
|
# Try to use build_base_data_input first (same as new training system)
|
||||||
|
try:
|
||||||
|
symbol = "ETH/USDT" # Default symbol
|
||||||
|
base_data = self.build_base_data_input(symbol)
|
||||||
|
if base_data and hasattr(base_data, "get_feature_vector"):
|
||||||
|
state = base_data.get_feature_vector()
|
||||||
|
if isinstance(state, np.ndarray) and state.size > 0:
|
||||||
|
logger.info(
|
||||||
|
f"Generated fresh state for {model_name} from build_base_data_input: shape={state.shape}"
|
||||||
|
)
|
||||||
|
return state
|
||||||
|
except Exception as e:
|
||||||
|
logger.debug(
|
||||||
|
f"build_base_data_input fresh state generation failed for {model_name}: {e}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Fallback to data provider method
|
||||||
if hasattr(self, "data_provider") and self.data_provider:
|
if hasattr(self, "data_provider") and self.data_provider:
|
||||||
try:
|
try:
|
||||||
# Build fresh BaseDataInput with current market data
|
# Build fresh BaseDataInput with current market data
|
||||||
|
Reference in New Issue
Block a user