diff --git a/Simulation.py b/Simulation.py index 7963ac2..91837b0 100644 --- a/Simulation.py +++ b/Simulation.py @@ -1,3 +1,4 @@ +import time from math import nan import pandas as pd import plotly.graph_objects as go @@ -68,7 +69,7 @@ class Simulation (HTS): buy_line[i] = nan buy_size.append(0) else: - buy_colors.append("#DA8913") + buy_colors.append("#00ced1") buy_size.append(10 + (5 * buy_weight_line[i])) sell_colors = [] @@ -77,7 +78,7 @@ class Simulation (HTS): sell_colors.append("#ffffff") sell_line[i] = nan else: - sell_colors.append("#00ced1") + sell_colors.append("#D87D0F") # 그래프를 설정한다. buy_check = go.Scatter(x=data['date'], y=buy_line, mode='markers', name="buy", marker=dict(size=buy_size, color=buy_colors, line_width=0)) diff --git a/hts/BuySellChecker.py b/hts/BuySellChecker.py index d012b4b..1388df1 100644 --- a/hts/BuySellChecker.py +++ b/hts/BuySellChecker.py @@ -222,7 +222,13 @@ class BuySellChecker: return buy, weight # 3분선이 5분선이 돌파가 이전보다 높은 경우 매수 - if data["avg3"][i - 1] < data["avg5"][i - 1] and data["avg3"][i] > data["avg5"][i]: + if data["slow_k"][i] < 20 and data["avg3"][i - 1] < data["avg5"][i - 1] and data["avg3"][i] > data["avg5"][i]: + buy = int((data["open"][i] + data["close"][i]) / 2) + weight = 1 + return buy, weight + + # 3분선이 5분선이 돌파가 이전보다 높은 경우 매수 + if data["slow_k"][i] < 70 and data["avg3"][i - 1] < data["avg5"][i - 1] and data["avg3"][i] > data["avg5"][i]: max_avg3 = 0 p_avg3 = 999999 for c in range(1, 50): @@ -236,7 +242,8 @@ class BuySellChecker: if i == 382 or i == 383: if data["close"][i] != data["high"][i]: return -1, -1 - buy = int((data["open"][i] + data["close"][i]) / 2) + #buy = int((data["open"][i] + data["close"][i]) / 2) + buy = data["low"][i] weight = 1 return buy, weight @@ -444,12 +451,11 @@ class BuySellChecker: # 매도 분석 # 10분선 위에서 3분선이 5분선을 하향 돌파 하는 경우 매도 - if data["avg3"][i - 1] >= data["avg5"][i - 1] and data["avg3"][i] < data["avg5"][i]: - if min(data["avg3"][i], data["avg5"][i]) > data["avg10"][i]: - if data["slow_k"][i] > 80: - sell = int((data["high"][i] + data["low"][i]) / 2) - weight = 1 - return sell, weight + if data["slow_k"][i - 1] > 60 and data["avg3"][i - 1] >= data["avg5"][i - 1] and data["avg3"][i] < data["avg5"][i]: + if max(data["avg3"][i], data["avg5"][i]) < data["avg10"][i]: + sell = int((data["high"][i] + data["low"][i]) / 2) + weight = 1 + return sell, weight """ # 3분선이 5분 이상 5분선 위에 있다가 5분선 아래로 내려옴 if i >= 381 + 5: @@ -1303,8 +1309,8 @@ class BuySellChecker: sell, weight = self.getSellPriceAndWeight_3000(data, last_index) buy, weight = self.getBuyPriceAndWeight_3000(data, last_index) else: - sell, weight = self.getSellPriceAndWeight_15000(data, last_index) - buy, weight = self.getBuyPriceAndWeight_15000(data, last_index) + sell, weight = self.getBuyPriceAndWeight_3000(data, last_index) + buy, weight = self.getBuyPriceAndWeight_3000(data, last_index) bsLine['buy'] = [buy] bsLine['buy_weight'] = [weight]