1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

バイナリーオプションの推定をAIで行う-その1;5分足データの作成

Last updated at Posted at 2019-10-06

目的:バイナリーオプションの推定行う

頭に置いておくべきは、
相場は
順張り: Market follow
逆張り: Contrarian
に分別される事
これも証明したい。

解析データの対象ペア

5minあるいは15minでのレンジを使用する予定なので、5分足のCSVデータを入手する。
分布回帰特性の観点からAUDJPYを対象とする。

解析用データの収集

$ wget http://tools.fxdd.com/tools/M1Data/AUDJPY.zip

収集データの確認

import read_hst as rh
df = rh.read_hst('AUDJPY.zip')  
df.tail
df.head()

	open	high	low	close	volume
time					
2005-04-11 01:33:00	83.54	83.54	83.54	83.54	2.0
2005-04-11 01:34:00	83.55	83.55	83.55	83.55	2.0
2005-04-11 01:36:00	83.54	83.54	83.54	83.54	2.0
2005-04-11 01:37:00	83.53	83.53	83.53	83.53	2.0
2005-04-11 01:38:00	83.54	83.55	83.54	83.54	6.0

df.tail()
	open	high	low	close	volume
time					
2019-09-27 23:52:00	73.013	73.016	73.009	73.009	70.0
2019-09-27 23:53:00	73.009	73.013	73.009	73.009	44.0
2019-09-27 23:54:00	73.008	73.021	73.006	73.018	57.0
2019-09-27 23:55:00	73.017	73.017	73.008	73.010	16.0
2019-09-28 00:12:00	73.010	73.010	73.010	73.010	1.0

2005年からの1分足データですが、テストには向かないのでまず直近い1日分、その後1週間、1ヶ月でのテスト予定
open,high,low,close のcloseデータにて解析を行う。

import pandas as pd
df['close'].tail()

time
2019-09-27 23:52:00    73.009
2019-09-27 23:53:00    73.009
2019-09-27 23:54:00    73.018
2019-09-27 23:55:00    73.010
2019-09-28 00:12:00    73.010
Name: close, dtype: float64
df.loc["2019-09-27"].head(11)

	open	high	low	close	volume
time					
2019-09-27 00:01:00	72.745	72.748	72.728	72.748	10.0
2019-09-27 00:02:00	72.748	72.748	72.727	72.735	12.0
2019-09-27 00:03:00	72.735	72.735	72.734	72.734	16.0
2019-09-27 00:04:00	72.734	72.734	72.728	72.734	20.0
2019-09-27 00:05:00	72.734	72.735	72.729	72.735	27.0
2019-09-27 00:06:00	72.735	72.735	72.731	72.735	61.0
2019-09-27 00:07:00	72.731	72.745	72.729	72.733	93.0
2019-09-27 00:08:00	72.735	72.741	72.724	72.735	83.0
2019-09-27 00:09:00	72.735	72.737	72.727	72.732	67.0
2019-09-27 00:10:00	72.732	72.734	72.728	72.732	65.0
2019-09-27 00:11:00	72.732	72.733	72.728	72.732	56.0
df.loc["2019-09-27"].tail(10)

	open	high	low	close	volume
time					
2019-09-27 23:46:00	73.001	73.001	72.997	72.998	57.0
2019-09-27 23:47:00	72.998	73.000	72.997	72.999	46.0
2019-09-27 23:48:00	72.999	73.006	72.999	73.005	47.0
2019-09-27 23:49:00	73.005	73.015	73.004	73.014	50.0
2019-09-27 23:50:00	73.014	73.021	73.014	73.021	64.0
2019-09-27 23:51:00	73.021	73.023	73.010	73.013	47.0
2019-09-27 23:52:00	73.013	73.016	73.009	73.009	70.0
2019-09-27 23:53:00	73.009	73.013	73.009	73.009	44.0
2019-09-27 23:54:00	73.008	73.021	73.006	73.018	57.0
2019-09-27 23:55:00	73.017	73.017	73.008	73.010	16.0
df_20190927_c = df.loc["2019-09-27"]['close']
print(df_20190927_c)

time
2019-09-27 00:01:00    72.748
2019-09-27 00:02:00    72.735
2019-09-27 00:03:00    72.734
2019-09-27 00:04:00    72.734
2019-09-27 00:05:00    72.735
2019-09-27 00:06:00    72.735
2019-09-27 00:07:00    72.733
2019-09-27 00:08:00    72.735
2019-09-27 00:09:00    72.732
2019-09-27 00:10:00    72.732
2019-09-27 00:11:00    72.732
2019-09-27 00:12:00    72.732

5分足データに変換

df_20190927_c=df_20190927_c[::-5]
print(df_20190927_c)

time
2019-09-27 23:55:00    73.010
2019-09-27 23:50:00    73.021
2019-09-27 23:45:00    73.001
2019-09-27 23:40:00    73.036
2019-09-27 23:35:00    73.029
2019-09-27 23:30:00    73.015
2019-09-27 23:25:00    73.004
2019-09-27 23:20:00    72.993
2019-09-27 23:15:00    72.964
2019-09-27 23:10:00    72.976
2019-09-27 23:05:00    72.990

逆順になったので戻すのは、

df_20190927_c5=df_20190927_c[::-1]
print(df_20190927_c5)

time
2019-09-27 00:05:00    72.735
2019-09-27 00:10:00    72.732
2019-09-27 00:15:00    72.746
2019-09-27 00:20:00    72.738
2019-09-27 00:25:00    72.741
2019-09-27 00:30:00    72.742
2019-09-27 00:35:00    72.738
2019-09-27 00:40:00    72.740
2019-09-27 00:45:00    72.742
2019-09-27 00:50:00    72.750
2019-09-27 00:55:00    72.752
2019-09-27 01:00:00    72.761

5分足データの完成です

参考;

http://swdrsker.hatenablog.com/entry/2018/05/18/070000
https://qiita.com/u1and0/items/6a690f6b0080b8efc2c7
https://qiita.com/shizuma/items/8616bbe3ebe8ab0b6ca1

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?