TAYU Academy course material · Machine Learning for Trading
Text walkthrough
Features for financial ML
A self-paced text walkthrough, without video or audio. See the article below for worked examples and materials.
Course Notes
1. Understand the core idea of “Features for financial ML” 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
Financial ML features should be available for prediction at the time of point. Yield, momentum, and rolling volatility are price transformations. The sample unit, frequency, and treatment of missing data must be clearly defined, and future labels or full-sample standardized results should not be included.
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.
For each column, write the formula/ window/ available time points → split by time → only train and fit → delete starting missing values → isolate feature labels.
Explanation for columns r1, momentum3, and vol5: Which historical rows do they require, and which starting rows cannot be used for training.
r1 must be at least 2 prices, momentum3 must be at least 4 prices, vol5 follows a script of 5 gains needing 6 prices; rows with insufficient starting values should be excluded, not filled with future values. The exact degrees of freedom should follow the script.
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.