TAYU Academy course material · Quant Risk Framework
Course Notes
1. Understand the core idea of “Coding risk control rules” and explain it in your own words
2. Master this module's focus: Expected shortfall (ES) and drawdown limits
3. Complete the assignment on your own and check it against the reference answer
Risk control coding must test the threshold boundaries, error types, and fail-closed. If function exceptions are defaulted to allow, they will turn data faults into infinite risk.
Expected Shortfall (ES) is the average loss when exceeding Value at Risk (VaR), better reflecting tail risks. Drawdown constraints can be set as tiered rules: reducing risk when a certain drawdown is reached, and stopping trading when a larger drawdown is reached.
Worst 5% average daily loss is 2.6%, i.e., ES=2.6%; risk is reduced when the drawdown reaches 6%, and trading is stopped when it reaches 10%.
First, list normal/equals/overlimit/NaN/negative/expired/unknown→implement pure function→assert reason→confirm rejection will not send order.
Write a paper testing table: Risk 100 and upper limit 100, 100.01, −1, and NaN; note the comparison rule as ≤ and risk non-negative finite.
Valid up to 100, and 100.01 exceeds the limit. −1 and NaN are invalid. Compare after validation; return rejection and reason for errors, do not return null as valid at upper level.
Fictional limit: total size ≤ 1000 units, existing 600, new order 500, total 1100, so it should be rejected; a stale quote time is also an independent reason to reject. Checking only that each 500 order is below 1000 is not enough. A NaN risk input must not be treated as 0 and let through.
Fail-open treats an unknown state as safe; after a restart, restore or re-verify the risk baseline instead of resetting it to zero.
This dependency-free script contains small labs for rank correlation, time folds, inventory valuation, covariance risk and rejection paths. The grid part only models buy-on-the-way-down inventory, with no sell-side recycling or real fills; the risk-parity part only demonstrates a given covariance and is not a general optimiser. Work from the report, and do not treat a small lab as a complete production strategy.
python strategy_labs.py1. ES adds a view of tail risk
2. Drawdown limits should be tiered
3. Rules must be written in advance
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.
Risk control coding must test the threshold boundaries, error types, and fail-closed. If function exceptions are defaulted to allow, they will turn data faults into infinite risk.
Record your work and compare the reference result. Self-checks are not verified competence.
Completion records your own study, not verified competence. Exercises use fictional data; no real account or deposit is required.