This is the origin Pytorch implementation of stop-loss adjusted label in the following paper: Stop-loss adjusted labels for machine learning-based trading of risky assets
News(July 31): Accepted to Finance Research Letters, 2023.
- Install Python 3.6, PyTorch 1.9.0.
- Download data.
- Run Stop-loss adjusted labels.
To easily reproduce the results using Docker, conda and Make, you can follow the next steps:
- Initialize the docker image using:
make init
. - Download the datasets using:
make data
. - Download the datasets using:
make coin data
. - Run each script in
runfile/
usingmake run_module module="bash runfile/btc_runfile.sh"
for each script. - Alternatively, run all the scripts at once:
for file in `ls scripts`; do make run_module module="bash runfile/runfile"; done
def ST_labels(data, delta):
"""
Calculate the stop-loss adjusted label.
Parameters:
- data: DataFrame containing historical asset prices.
- delta: Maximum tolerance level for stop-loss trading.
Returns:
- Index of rows where the label is 1.
"""
return data[
(data["Close"] / data["Close"].shift(1) > 1) &
((data["Low"] / data["Close"].shift(1) - 1) * 100 >= -delta)
].index
We will keep adding Predicting movements of asset prices models to expand this repo:
- SVM
- KNN
- MLP
- Catboost
- Random Forest
- Extra tree
If you find this repo useful, please cite our paper.
Hwang, Y., Park, J., Lee, Y., & Lim, D. Y. (2023). Stop-loss adjusted labels for machine learning-based trading of risky assets. Finance Research Letters, 104285.
If you have any questions or want to use the code, please contact [email protected]
SPDX-FileCopyrightText: © 2023 yoontae hwang [email protected]
SPDX-License-Identifier: BSD-3-Clause