Code Monkey home page Code Monkey logo

candlestick_model's Introduction

20日間のローソク足画像からCNNで株価の上下を予想するモデル

img_sample.png

ラベルの分け方かえていくつかモデル作ったが、以下のラベルを採用した

  • 予測実行日の1日後の始値 > 2日後の始値なら「0」
  • 予測実行日の1日後の始値 < 2日後の始値なら「1」
  • 予測実行日の1日後の始値 * 1.05 < 2日後の始値なら「2」
  • ※上がり下がりを予測するバイナリラベルだとvalidationの正解率>0.9になるが、最近のデータで試すとあまり当たらない感じだったのでこうした(validation setの切り方が悪いためtest setの分布と合ってないのか?)
  • 予測実行日の終値 < 1日後の始値 and 予測ラベル=1or2 and 確信度>0.8 のデータは良さそう

CM_without_normalize_optuna_best_trial_accuracy.png

行った手順

1. notebook/*.ipynb でデータ作成、モデル作成試す

2. 時系列の分け方でデータセット作成

  • train setは2000-2017年まで、test setは2018-2020年までのデータを使う
# 画像作成
$ python make_candlestick.py --is_mav_png --is_2day_label -o D:\work\candlestick_model\output\orig_image_all_2day_label
※画像200万枚ぐらいつくるため48時間近くかかる

# train/test setに分割
$ python make_dataset.py -i D:\work\candlestick_model\output\orig_image_all_2day_label -o D:\work\candlestick_model\output\ts_dataset_all_2day_label --is_test_only --is_not_equalize

3. code/tf_base_class*.py でモデル作成(パラメータチューニングも可能。少量データ版では試した)

$ python tf_base_class_all_data_2day_label.py -m train

4. bestモデルで予測

# JPX日経インデックス400 + 日経225 + 日経500種について
$ python tf_predict_best_model.py --is_2day_label

# 7269:スズキについて数日さかのぼって実行。下記は10日さかのぼる(2020/07/31からさかのぼって10日間毎日予測)
$ python tf_predict_best_model.py -c 7269 -d 2020-07-31 -t_d 10 --is_2day_label

candlestick_model's People

Contributors

riron1206 avatar

Stargazers

Macit Giray Gökırmak avatar  avatar Daeho  Kang avatar  avatar  avatar SSBakh avatar  avatar  avatar  avatar Arsyad avatar Reihaneh Gh.Roshan avatar Lê Việt Tiến avatar  avatar Kyle (Jun Seo) Lee avatar skylinepro avatar  avatar  avatar Christoph Mittermaier avatar  avatar xixnin luo  avatar TrongDuyNguyen.611 avatar  avatar

Watchers

James Cloos avatar Hafizul Hasni Bin Manab avatar  avatar  avatar paper2code - bot avatar

candlestick_model's Issues

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.