• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisionfe7ef08ec9971cc997d69d12b86093c81c888b5b (tree)
Time2023-02-03 10:51:33
Authorkazuhiro_kondow <simauma.circus@gmai...>
Commiterkazuhiro_kondow

Log Message

MACDインジケータの判定バグを修正

Change Summary

Incremental Difference

--- a/investigation_study/mt5_api_rate_test.py
+++ b/investigation_study/mt5_api_rate_test.py
@@ -21,6 +21,9 @@ count = 68 * 2
2121
2222 rates = mt5.copy_rates_from_pos(cp, mt5.TIMEFRAME_M1, 0, count)
2323
24+type(rates)
25+# <class 'numpy.ndarray'>
26+
2427 print(rates)
2528 # array([(1675201440, 130.104, 130.109, 130.098, 130.101, 47, 3, 0),
2629 # (1675201500, 130.1 , 130.1 , 130.08 , 130.083, 23, 4, 0),
--- a/src/config/setting.ini
+++ b/src/config/setting.ini
@@ -36,7 +36,7 @@ Allowablespread = 0.01
3636 # 1銭は0.01円
3737 OpenMergin = 0.007
3838 # 利益確定(円)
39-ProfitTaking = 0.5
39+ProfitTaking = 1.0
4040 # 損切(円)
4141 LossCut = 0.5
4242
--- a/src/exchange_rate_info.py
+++ b/src/exchange_rate_info.py
@@ -63,7 +63,6 @@ class ExchangeRateInfo():
6363 0,
6464 count
6565 )
66-
6766 return rates['close']
6867
6968 def __crossover(self, series1: np.ndarray, series2: np.ndarray) -> bool:
@@ -157,7 +156,7 @@ class ExchangeRateInfo():
157156
158157 # MACDテクニカル分析に必要なデータ件数
159158 # mt5アプリの表示と数値の乖離があるので件数を増やしてみる
160- count = (self.__n2 + self.__ns) * 3
159+ count = (self.__n2 + self.__ns) * 20
161160
162161 # 終値履歴を取得
163162 closes = self.__get_history_closes(
@@ -173,17 +172,16 @@ class ExchangeRateInfo():
173172 signalperiod=self.__ns
174173 )
175174
176- # MACDの結果を端数処理(少数点以下4)
177- macd = np.around(macd, 4)
178- macdsignal = np.around(macdsignal, 4)
179-
180- # 前回の暫定判断の答え合わせ
181- conf_macd = macd[-1]
182- conf_macdsig = macdsignal[-1]
183- msg = (
184- f'Confirm MACD: {conf_macd}, Signal: {conf_macdsig} .'
185- )
186- logger.debug(msg)
175+ # MACDの結果を端数処理(少数点以下5)
176+ macd = np.around(macd, 5)
177+ macdsignal = np.around(macdsignal, 5)
178+
179+ # for debug
180+ for i in range(-4, 0, 1):
181+ msg = (
182+ f'num[{i}]: MACD: {macd[i]}, MACDSignal: {macdsignal[i]}'
183+ )
184+ logger.debug(msg)
187185
188186 # 最新bidを暫定終わり値としてclosesに追加
189187 # closes = np.append(closes, self.__get_latest_bid())
@@ -208,22 +206,30 @@ class ExchangeRateInfo():
208206 # logger.debug(msg)
209207
210208 # 指標判定
211- if self.__crossover(macd, macdsignal):
209+ if self.__crossover(macd, macdsignal) and macd[-1] < 0.0:
212210 # GoldenCross 上昇転換サイン
213211 s.technical_indicator = DEF.TECHNICAL_GOLDEN_CROSS
214212 msg = 'Technical Indicator: GoldenCross.'
215- elif self.__crossover(macdsignal, macd):
213+ elif self.__crossover(macdsignal, macd) and macd[-1] > 0.0:
216214 # DeadCross 降下転換サイン
217215 s.technical_indicator = DEF.TECHNICAL_DEAD_CROSS
218216 msg = 'Technical Indicator: DeadCross.'
219- elif macd[-1] > macdsignal[-1]:
220- # 上昇トレンド
217+ elif macd[-1] > macdsignal[-1] and macd[-1] < 0.0:
218+ # 弱い上昇トレンド
219+ s.technical_indicator = DEF.TECHNICAL_UPTREND
220+ msg = 'Technical Indicator: Weak Uptrend.'
221+ elif macd[-1] > macdsignal[-1] and macd[-1] > 0.0:
222+ # 強い上昇トレンド
221223 s.technical_indicator = DEF.TECHNICAL_UPTREND
222- msg = 'Technical Indicator: Up Trand.'
223- elif macdsignal[-1] > macd[-1]:
224- # 降下トレンド
224+ msg = 'Technical Indicator: Strong Uptrend.'
225+ elif macd[-1] < macdsignal[-1] and macd[-1] > 0.0:
226+ # 弱い降下トレンド
227+ s.technical_indicator = DEF.TECHNICAL_DOWNTREND
228+ msg = 'Technical Indicator: Weak Downtrand.'
229+ elif macd[-1] < macdsignal[-1] and macd[-1] < 0.0:
230+ # 強い降下トレンド
225231 s.technical_indicator = DEF.TECHNICAL_DOWNTREND
226- msg = 'Technical Indicator: Down Trand.'
232+ msg = 'Technical Indicator: Strong Downtrand.'
227233 else:
228234 # いずれにも該当しない
229235 s.technical_indicator = DEF.TECHNICAL_UNCHANGED
--- a/src/main.py
+++ b/src/main.py
@@ -65,9 +65,9 @@ def main():
6565 # PositionMngは長期ポジションに対応する
6666 logger.debug("set schedule.")
6767 schedule.every().minute.at(":00").do(em.execute)
68- schedule.every().minute.at(":02").do(pm.execute)
69- schedule.every().minute.at(":04").do(ac.execute)
70- schedule.every().minute.at(":06").do(rt.execute)
68+ schedule.every().minute.at(":02").do(rt.execute)
69+ schedule.every().minute.at(":04").do(pm.execute)
70+ schedule.every().minute.at(":06").do(ac.execute)
7171 schedule.every().minute.at(":08").do(tm.execute)
7272
7373 logger.debug("start loop.")