Coder Social home page Coder Social logo

trading-rules-using-machine-learning's Introduction

Trading rules using machine learning

This is my financial trading using ML.

Momentum prediction and enhancing the strategy with machine learning

  1. Financial Data and Bars

    • Form time/dollar bars with tick data
  2. Get Buy/Sell Signals

    • Momentum strategy (RSI..)
    • Additional ML regime detector
  3. Trading Rules

    • Set enter rules with trading signals from classifiers
    • Set exit rules with profit-taking, stop-loss rate, and maximum holding period
    • (For enhancing the strategy) Label the binary outcome (Profit or Loss)
  4. Strategy-Enhancing ML Model

  • Get Features (X)

    • Market data & Technical analysis
    • Microstructure features
    • Macroeconomic variables
    • Fundamentals
    • news/public sentiments (in progress)
  • Feature Engineering

    • Feature selection, dimension reduction
  • Machine Learning Model Optmization

    • Cross-validation (time-series cv / Purged k-fold)
    • Hyperparameter tuning
    • AutoML with autogluon (or simply using ensemble methods such as Random forest, LightGBM, or XGBoost)
    • Metrics (accuracy, f1 score, roc-auc)
  • Outcome

    • Bet confidence (probability to accept a single trading signal)
  1. Trading Decision

    • Decide to bet or pass for each trading signal from the momentum strategy. The ML model above will help you.
    • Bet sizing with some advanced models (in progress)
  2. Backtesting

    • Cumulative returns, Sharpe ratio, max drawdown, win ratio

References:

  • Advances in Financial Machine Learning, Lopez de Prado (2018)

Flowchart

ML Trade Networks

trading-rules-using-machine-learning's People

Contributors

jo-cho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

trading-rules-using-machine-learning's Issues

Error when reading kospi

hello, very interesting work you've done. I have a problem when runing your code. When runing the following code:
import FinanceDataReader as fdr
import datetime as dt
start_date = dt.datetime(2011,1,1)
end_date = dt.datetime(2021,1,1)

kospi = fdr.DataReader('KS11',start_date,end_date)

I get the following error message, any solution?
Traceback (most recent call last):
File "e:/myquant/Adv_Fin_ML/trading-rules-using-machine-learning-main/test.py", line 7, in
kospi = fdr.DataReader('KS11',start_date,end_date)
File "e:\myquant\venv_quant389\lib\site-packages\FinanceDataReader\data.py", line 41, in DataReader
df = reader(symbol, start, end, exchange, data_source).read()
File "e:\myquant\venv_quant389\lib\site-packages\FinanceDataReader\investing\data.py", line 62, in read
curr_id = self._get_currid_investing(self.symbol, self.exchange, self.data_source)
File "e:\myquant\venv_quant389\lib\site-packages\FinanceDataReader\investing\data.py", line 30, in get_currid_investing
jo = json.loads(r.text)
File "E:\ProgramFiles\Python\Python38\lib\json_init
.py", line 357, in loads
return _default_decoder.decode(s)
File "E:\ProgramFiles\Python\Python38\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "E:\ProgramFiles\Python\Python38\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

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.