dogwood008の開発メモ!

最近のマイブームは機械学習, Ruby on Rails。中でも機械学習を使った金融商品の自動取引に興味があります。

Deep Learning, TensorFlow, Keras, DQN を使ってFXの自動取引をする その6

今回は試しに学習させてみたところ、途中でエラーが出て止まってしまった。再帰的に直前の存在する日時インデックスを取得するメソッドにバグがあったので、この機会にもっとシンプルな実装へ変更した。

(前略)
[2017-04-01 15:05:29,613] before
2010-09-04T16:01:00.000000+0000
[2017-04-01 15:05:29,613] 2010-09-04T16:01:00.000000+0000
1283616000.0
[2017-04-01 15:05:29,613] 1283616000.0
after
[2017-04-01 15:05:29,614] after2010-09-04T16:01:00.000000+0000
[2017-04-01 15:05:29,614] 2010-09-04T16:01:00.000000+0000
1283616060.0
[2017-04-01 15:05:29,614] 1283616060.0
Fatal Python error: Cannot recover from stack overflow.

Current thread 0x00007f451c9c2700 (most recent call first):
  File "/opt/conda/lib/python3.5/site-packages/pandas/core/base.py", line 877 in _values
  File "/opt/conda/lib/python3.5/site-packages/pandas/indexes/base.py", line 1305 in <lambda>
  File "/opt/conda/lib/python3.5/site-packages/pandas/indexes/base.py", line 1084 in is_monotonic_increasing
  File "/opt/conda/lib/python3.5/site-packages/pandas/tseries/frequencies.py", line 755 in __init__
  File "/opt/conda/lib/python3.5/site-packages/pandas/tseries/frequencies.py", line 724 in infer_freq
  File "/opt/conda/lib/python3.5/site-packages/pandas/tseries/base.py", line 303 in inferred_freq
  File "/opt/conda/lib/python3.5/site-packages/pandas/tseries/index.py", line 1466 in _get_string_slice
  File "/opt/conda/lib/python3.5/site-packages/pandas/tseries/index.py", line 1414 in get_loc
  File "/opt/conda/lib/python3.5/site-packages/pandas/tseries/base.py", line 234 in __contains__
  File "/opt/conda/lib/python3.5/site-packages/pandas/core/indexing.py", line 1410 in _has_valid_type
  File "/opt/conda/lib/python3.5/site-packages/pandas/core/indexing.py", line 1482 in _getitem_axis
  File "/opt/conda/lib/python3.5/site-packages/pandas/core/indexing.py", line 1312 in __getitem__
  File "Keras-RL_DQN_FX.py", line 60 in get_last_exist_datetime_recursively
  File "Keras-RL_DQN_FX.py", line 65 in get_last_exist_datetime_recursively
  File "Keras-RL_DQN_FX.py", line 65 in get_last_exist_datetime_recursively
  File "Keras-RL_DQN_FX.py", line 65 in get_last_exist_datetime_recursively
  File "Keras-RL_DQN_FX.py", line 65 in get_last_exist_datetime_recursively
  File "Keras-RL_DQN_FX.py", line 65 in get_last_exist_datetime_recursively
(後略)

現在の問題点その4

試しに学習させたところ、 HistData.get_last_exist_datetime_recursively() に 2010-09-04T16:01:00 を与えるとスタックオーバーフローで終了するバグがあった。

現在の問題点その4に対する解

もっとシンプルな実装に変更する。

github.com