Hi! Great work!
But, in my opinion, there is a problem in the current code:
$ python train.py --config configs/experiments/itransformer_hybrid_origin.py
2026-04-24 20:13:40 | Experiment : itransformer_hybrid
2026-04-24 20:13:40 | Device : cpu
2026-04-24 20:13:40 | Backbone : itransformer
2026-04-24 20:13:40 | Loss : hybrid
2026-04-24 20:13:40 | Output : output/itransformer_hybrid
2026-04-24 20:13:40 | PolicyNetwork created — backbone=itransformer params=52.4K
2026-04-24 20:13:40 | ====================================================
2026-04-24 20:13:40 | SANITY CHECKS
2026-04-24 20:13:40 | ====================================================
2026-04-24 20:13:40 | PASS gradient_flow all params receive gradient
2026-04-24 20:13:45 | PASS long_bias mean_position=+0.1503 expected_sign=+
2026-04-24 20:13:50 | PASS short_bias mean_position=-0.1933 expected_sign=-
2026-04-24 20:13:50 | ALL PASSED
2026-04-24 20:13:50 | ====================================================
2026-04-24 20:13:50 | Building dataset [diffquant_f1ceafda6404]
ts shape: (2629440,)
ts[:5]: [1609459200000 1609459260000 1609459320000 1609459380000 1609459440000]
2026-04-24 20:13:50 | Source: btcusdt_1min_2021_2025.npz bars=2,629,440 2021-01-01 00:00 → 2025-12-31 23:59
2026-04-24 20:13:51 | Aggregated to 30-min: 87,648 bars
ts shape: (87648,)
ts[:5]: [1609461 1609462 1609464 1609466 1609468]
2026-04-24 20:13:51 | Features: shape=(87647, 6) channels=['open', 'high', 'low', 'close', 'volume', 'rolling_vol']
2026-04-24 20:13:51 | Slicing: accepted=0 skipped_gap=0 skipped_align=87,528
2026-04-24 20:13:51 | Samples: 0 stride=24
2026-04-24 20:13:51 | train 0 samples [2024-01-01 → 2025-03-31]
2026-04-24 20:13:51 | val 0 samples [2025-03-31 → 2025-06-30]
2026-04-24 20:13:51 | test 0 samples [2025-06-30 → 2025-09-30]
2026-04-24 20:13:51 | backtest 0 samples [2025-09-30 → 2025-12-31]
2026-04-24 20:13:51 | Cached → data_cache/diffquant_f1ceafda6404.npz
2026-04-24 20:13:51 | Dataset — train: 0 samples | val raw: 0 bars
2026-04-24 20:13:52 | PolicyNetwork created — backbone=itransformer params=52.4K
2026-04-24 20:13:52 | PolicyNetwork: 52,354 params | backbone=itransformer | loss=hybrid | n_features=6
Traceback (most recent call last):
File "/home/ec2-user/diffquant/train.py", line 133, in <module>
main()
File "/home/ec2-user/diffquant/train.py", line 126, in main
trainer.train(
File "/home/ec2-user/diffquant/training/trainer.py", line 263, in train
loader = DataLoader(
^^^^^^^^^^^
File "/home/ec2-user/.local/lib/python3.12/site-packages/torch/utils/data/dataloader.py", line 394, in __init__
sampler = RandomSampler(dataset, generator=generator) # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ec2-user/.local/lib/python3.12/site-packages/torch/utils/data/sampler.py", line 149, in __init__
raise ValueError(
ValueError: num_samples should be a positive integer value, but got num_samples=0
which was resolved after I made the following fix:
diff --git a/data/aggregator.py b/data/aggregator.py
- ts_out = (agg.index.view(np.int64) // 1_000_000).astype(np.int64)
+ ts_out = (agg.index.view(np.int64)).astype(np.int64)
Unfortunately, I was unable to achieve the same results as in your article: https://habr.com/en/articles/1022254/
Is this the correct approach to reproduce the results:
-
Search for model hyperparameters and edit configs/experiments/itransformer_hybrid.py to set the obtained parameters
python optimize.py --config configs/experiments/itransformer_hybrid.py --trials 50
-
Train the model
python train.py --config configs/experiments/itransformer_hybrid.py
-
Optimize thresholds and edit configs/experiments/itransformer_hybrid.py to set the obtained parameters
python optimize_thresholds.py --config configs/experiments/itransformer_hybrid.py --trials 50 --objective sharpe
-
Run test and backtest
python evaluate.py --config configs/experiments/itransformer_hybrid.py --mode test
python evaluate.py --config configs/experiments/itransformer_hybrid.py --mode backtest
Hi! Great work!
But, in my opinion, there is a problem in the current code:
which was resolved after I made the following fix:
Unfortunately, I was unable to achieve the same results as in your article: https://habr.com/en/articles/1022254/
Is this the correct approach to reproduce the results:
Search for model hyperparameters and edit configs/experiments/itransformer_hybrid.py to set the obtained parameters
python optimize.py --config configs/experiments/itransformer_hybrid.py --trials 50Train the model
python train.py --config configs/experiments/itransformer_hybrid.pyOptimize thresholds and edit configs/experiments/itransformer_hybrid.py to set the obtained parameters
python optimize_thresholds.py --config configs/experiments/itransformer_hybrid.py --trials 50 --objective sharpeRun test and backtest