Yoontae6719 / Stop-loss-adjusted-labels

Official Implementation of Stop-loss adjusted labels for machine learning-based trading of risky assets

Home Page:https://www.sciencedirect.com/science/article/pii/S1544612323006578

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stop-loss adjusted labels for machine learning-based trading of risky assets

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.

image

Get Started

  1. Install Python 3.6, PyTorch 1.9.0.
  2. Download data.
  3. Run Stop-loss adjusted labels.

Reproduce with Docker

To easily reproduce the results using Docker, conda and Make, you can follow the next steps:

  1. Initialize the docker image using: make init.
  2. Download the datasets using: make data.
  3. Download the datasets using: make coin data.
  4. Run each script in runfile/ using make run_module module="bash runfile/btc_runfile.sh" for each script.
  5. Alternatively, run all the scripts at once:
for file in `ls scripts`; do make run_module module="bash runfile/runfile"; done

Stop-loss adjusted labels (Python Code Description)

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

Baselines

We will keep adding Predicting movements of asset prices models to expand this repo:

  • SVM
  • KNN
  • MLP
  • Catboost
  • Random Forest
  • Extra tree

Citation

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.

Contact

If you have any questions or want to use the code, please contact yoontae@unist.ac.kr

SPDX-FileCopyrightText: © 2023 yoontae hwang yoontae@unist.ac.kr

SPDX-License-Identifier: BSD-3-Clause

About

Official Implementation of Stop-loss adjusted labels for machine learning-based trading of risky assets

https://www.sciencedirect.com/science/article/pii/S1544612323006578

License:MIT License


Languages

Language:Jupyter Notebook 99.6%Language:Python 0.4%