training WIP

This commit is contained in:
Dobromir Popov
2025-12-10 01:40:03 +02:00
parent 9c59b3e0c6
commit 199235962b
3 changed files with 355 additions and 33 deletions

View File

@@ -4090,20 +4090,37 @@ class RealTrainingAdapter:
return None
# Override the future candle target with actual candle data
actual = prediction_sample['actual_candle'] # [O, H, L, C]
actual = prediction_sample['actual_candle'] # [O, H, L, C, V] or [O, H, L, C]
# Create target tensor for the specific timeframe
import torch
device = batch['prices_1m'].device if 'prices_1m' in batch else torch.device('cpu')
# Get device from any available tensor in batch
device = torch.device('cpu')
for key in ['price_data_1m', 'price_data_1h', 'price_data_1d', 'prices_1m']:
if key in batch and batch[key] is not None:
device = batch[key].device
break
# Target candle: [O, H, L, C, V] - we don't have actual volume, use predicted
target_candle = [
actual[0], # Open
actual[1], # High
actual[2], # Low
actual[3], # Close
prediction_sample['predicted_candle'][4] # Volume (from prediction)
]
# Target candle: [O, H, L, C, V]
# Use actual volume if available, otherwise use predicted volume
if len(actual) >= 5:
target_candle = [
float(actual[0]), # Open
float(actual[1]), # High
float(actual[2]), # Low
float(actual[3]), # Close
float(actual[4]) # Volume (from actual)
]
else:
# Fallback: use predicted volume if actual doesn't have it
predicted = prediction_sample.get('predicted_candle', [0, 0, 0, 0, 0])
target_candle = [
float(actual[0]), # Open
float(actual[1]), # High
float(actual[2]), # Low
float(actual[3]), # Close
float(predicted[4] if len(predicted) > 4 else 0.0) # Volume (from prediction)
]
# Add to batch based on timeframe
if timeframe == '1s':