Giter Site home page Giter Site logo

xjcheam / portfolio-optimization-qts-trend-ratio Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 15 KB

This is a project of portfolio optimization using Quantum-inspired Tabu Search and Trend Ratio

Python 100.00%
evolutionary-algorithms metaheuristic-algorithms metaheuristic-optimisation optimization-algorithms qts quantum-inspired-algorithm stock stock-selection trend-ratio

portfolio-optimization-qts-trend-ratio's Introduction

Table of Contents

  1. Introduction
    1. Supported Stock Combinations
  2. How to use the code
    1. Dependencies
    2. config.py
    3. Guide
  3. References

Introduction

This paper proposed to use Quantum-inspired Tabu Search algorithm improved by the quantum-not-gate (GNQTS) and trend ratio to approache portfolio optimization problem.

This is a replication of the the paper for real time investment portfolio optimization, uses GNQTS and trend ratio. The code acquire up-to-date stock price data to train and test. Users could define prefered investment date and the best training result will be saved. When investment interval starts, users could use the code to check current investment return.

However, the source of data and the stocks combinations to choose from might be different from the paper, therefore, the results of this code might not be consistant with the result of the paper. The data are acquired from yahoo finance, and the supported stocks combinations are shown below.

Supported Stock Combinations

  1. KLSE

How to use the code

Dependencies

  1. beautifulsoup4
  2. yfinance
  3. QTS

config.py

  1. Change setting in config.py to fit your preference.
    • Mode: The mode to run. Supports three modes.

      • All: Run train then test.
      • Train: Run train only.
      • Test: Run Test only.
    • Investment_start_date: The start date of your investment period. A reference for all other date, including train start date, train end date and investment end date.

    • Train_test_mode: The mode of train and test interval.

      • continuous: This mode uses the data from an interval before investment start date to train. Refer cited reference M2M, Q2Q, H2H, Y2Y, etc.
      • year-on-year: This mode uses the data a year before as the investment start date. Refer cited reference M*, Q*, H*.
    • Training_interval: The interval of train. Supports 3 training interval for year-on-year train test mode, and 4 training interval for continuous mode.

      • 1M: 1 month, takes one month data to train. Available for both train test mode.
      • 3M: 3 months, take three months data to train. Available for both train test mode.
      • 6M: 6 months, take six months data to train. Available for two train test mode.
      • 1Y: 1 year, take one year datat to train. Only available for "Continuous" type train test mode. Uses the data one year before from the investment start date.
    • Initial_fund: The initial fund of investment.

    • Experiment: The amount of experiment in one execution. Choose the best from totoal experiments.

    • Generation: Total generation in one experiment.

    • Solution_each_generation: The amount of solution in one generation (iteration).

    • theta: The size of step to update beta-matrix, use in QTS, NQTS, GQTS and GNQTS.

    • theta_upper: The upper bound of the size of step to update beta-matrix, use in ANQTS and ANGQTS.

    • theta_lower: The lower bound of the size of step to update beta-matrix, use in ANQTS and ANGQTS.

Guide

  1. Git clone the repository to your local computer.
  2. Install the dependencies if you have not.
   > pip install beautifulsoup4
   > pip install yfinance
  1. Follow QTS package installation.
  2. Navigate to the directory in terminal, change config.py details to match your experiment preferences and run.
   > python main.py

* Users do not require to download stock price manually. When the code is executed, it automatically acquire stock data according to details in config.py.

References

  1. Y. -C. Jiang, X. J. Cheam, C. -Y. Chen, S. -Y. Kuo and Y. -H. Chou, "A Novel Portfolio Optimization with Short Selling Using GNQTS and Trend Ratio," 2018 IEEE International Conference on Systems, Man, and Cybernetics (SMC), 2018, pp. 1564-1569, doi: 10.1109/SMC.2018.00271.

portfolio-optimization-qts-trend-ratio's People

Contributors

xjcheam avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

scorpxoy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.