LoginSignup
0

posted at

updated at

【v28】マージしたチャートデータからテクニカル指標を計算する(Pivot編)

はじめに

過去記事は「auカブコム証券のkabuステーションREST APIに関する記事一覧」。

テクニカル指標を4種類計算したが、さらにPivotを追加する。

前回のクラスの流用

33番目の記事で、1まとめにしたが、MainCalcIndicator_r3の中でインジケータークラスをハードコードしているため、MainCalcIndicator_r4にコピーした。
ただし、変わっていない部分はv27のまま使う。
したがって、以下のようにほとんどをimportする。

import v27.CalcIndicator_r3;
import v27.MainCalcIndicator1_r3;
import v27.MainCalcIndicator2_r3;
import v27.MainCalcIndicator3_r3;
import v27.MainCalcIndicator4_r3;
import v27.MainCalcIndicator_r3.ChartInfo;
import v27.MainCalcIndicator_r3.IndicatorInfo;

将来、CalcIndicator、ChartInfo、IndicatorInfoを独立させて、インジケータークラスを動的にクラスロードできるようにする。

Pivotの計算

Pivotは1つの前のhigh, low, closeの3変数があれば計算できる。
中間結果のp, d1, d2, d3の4変数をリストに保管して、lbop, b2, b1, s1, s2, hbopを計算して出力する。

検証

4本値

2022/08/09 23:59:00	27845 27860 27845 27860  p=27855,     d1=5    , d2=10    , d3=15
2022/08/10 00:00:00	27855 27855 27840 27845  p=27846.666, d1=8.333, d2=23.333, d3=15
2022/08/10 00:01:00	27845 27850 27825 27825

計算値

2022/08/10 00:00:00,27845,2,27835.00,27840.00,27850.00,27855.00,27865.00,27870.00,27880.00
2022/08/10 00:01:00,27825,2,27823.33,27831.67,27838.33,27846.67,27853.33,27861.67,27868.33

chart_20220810

※なぜかlbop, hbopの値が表示されない。
lbop=p-d1-d3=2p-2high-low=b1-(p-b2)なので、00:00:00は27850-(27855-27840)=27835。
hbop=p+d2+d3=2p-2low+high=s1+(s2-p)なので、00:00:00は27865+(27870-27855)=27880。
要は、p-b2=s2-p=d3なので、±15遠くになる。

追記:v27.MainCalcIndicator_r3.ChartInfoをv27.CalcIndicatorChartInfo_r3に変更

v28以降でもChartInfoを共通に使用したいため、クラスを独立させる。

追記:v27.MainCalcIndicator_r3.IndicatorInfoをv27.CalcIndicatorIndicatorInfo_r3に変更

v28以降でもChartInfoを共通に使用したいため、クラスを独立させる。

追記:ソースをarchiveブランチへ移動

最新版に移行し、もう使われることはないので、アーカイブする。

githubソース

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
What you can do with signing up
0