TAYU Academy course material · Machine Learning for Trading
Course Notes
1. Understand the core idea of “Label design” and explain it in your own words
2. Master this module's focus: Feature engineering
3. Complete the assignment on your own and check it against the reference answer
Labels can define future outcomes, but the sample split must consider the label endpoint. Future 5-step return labels will cross temporal boundaries, and simple splitting by features may still leak information.
Common features include lagging returns, volatility, technical indicators, and timeframes. All features can only use data available at the time, and labels (such as future N candles' up and down) cannot be leaked into the features. The training set and test set are divided in chronological order, and they cannot be randomly shuffled.
Example: Features use the 5- and 20-day returns and ATR from the past 5, 20 K lines, with labels for the future 4 H1 returns direction; training set from 2019-2022, testing set from 2023.
Specify the start point t and the end point t+5 → only freeze the training labels before the test start point → freeze the threshold → record the end of training and the start of testing points.
The test features start from 168, with a label span of 5. The training label endpoint must be less than 168. What is the latest training feature allowed?
t+5<168, so t≤162; if t>163, then the endpoint of the last training label is 168 and the initial test is 168. Record the final training label endpoint as 167 and the initial test as 168, and verify against the actual retained samples.
Label definition: close[t+5]/close[t]−1>0. Training ends at 100, testing starts at 101, so t=96…100. Labels touching the testing period should be removed. The last 5 rows do not have complete labels and cannot be used by comparing NaN and getting False to treat them as negative class.
Samples with adjacent time periods are highly correlated; random splitting will overestimate independence. It cannot be claimed that all leakage has been eliminated simply by adding one shift.
Install the dependencies listed for this lab in the README first. If a dependency or platform is unavailable, mark the lab as not run; downloading the source is not evidence of running it.
python ml_lab.py1. Use only information known at the time
2. Prevent label leakage
3. Split the data in time order
Risk warning: leveraged trading in forex, precious metals and similar products carries a high level of risk and you may lose all of your capital, or more. This course is for education only. It is not investment advice and does not promise any return. Example prices and contract specifications are teaching assumptions; always use what your own platform discloses. Past performance and backtests do not indicate future results.
All values, prices, accounts and cases in this course are teaching assumptions; the fixed materials can be reproduced offline. Marking a lesson complete only records your study. It is not a certification, a service approval or a promise of returns. Workbooks and answer files are currently provided in Chinese.
Key Takeaways
Completion records your own study, not verified competence. Exercises use fictional data; no real account or deposit is required.