diff --git a/hts/20210923.csv b/hts/20210923.csv index b6b8949..529fadc 100644 --- a/hts/20210923.csv +++ b/hts/20210923.csv @@ -379,4 +379,4 @@ 20210923,1518,2090,2090,2085,2090,38388 20210923,1519,2090,2090,2085,2090,24505 20210923,1520,2090,2090,2085,2090,374841 -20210923,1530,2085,2085,2085,2085,2073594 \ No newline at end of file +20210923,1530,2085,2085,2085,2085,2073594 diff --git a/hts/20210924.csv b/hts/20210924.csv index a3c0516..34ad943 100644 --- a/hts/20210924.csv +++ b/hts/20210924.csv @@ -379,4 +379,4 @@ 20210924,1518,2090,2095,2090,2095,3415133 20210924,1519,2090,2095,2085,2095,651271 20210924,1520,2095,2095,2085,2090,309685 -20210924,1530,2095,2095,2095,2095,3249650 \ No newline at end of file +20210924,1530,2095,2095,2095,2095,3249650 diff --git a/hts/HTS.py b/hts/HTS.py index f532ccf..fe9c2be 100644 --- a/hts/HTS.py +++ b/hts/HTS.py @@ -1,10 +1,10 @@ -import win32com.client +#import win32com.client import time import os from datetime import datetime, timedelta import pandas as pd from enum import Enum -#import plotly.graph_objects as go +import plotly.graph_objects as go # enum 주문 상태 세팅용 @@ -569,9 +569,11 @@ class HTS: fig.show() return - def checkTransaction(self, data, lower): + def checkTransaction(self, data, upper, lower): low = data["Low"] + high = data["High"] close = data["Close"] + open = data["Open"] # 살 시점인지 체크 # 볼린저밴드 하단에 연속으로 같은 가격이 왔을 때, @@ -588,6 +590,11 @@ class HTS: buy_line[i+1] = low[i] + 5 check = False + if low[i-2] < lower[i-2] and low[i-1] < lower[i-1] and low[i] < open[i] == close[i] < high[i] and open[i] - low[i] == high [i] - open[i]: + if not (open[i-2] < close[i-2] and open[i-1] < close[i-1]) and not (open[i-2] == close[i-2] or open[i-1] == close[i-1]): + buy_line[i+1] = high[i] + + # 팔 시점 체크 # 산 가격에 5원 위로 매도를 건다. sell_line = [-1 for i in range(len(lower))] @@ -620,7 +627,7 @@ class HTS: data, upper, lower = self.analyze(result) # 사야 할 시점과 팔아야 할 시점을 체크한다. - buy_line, sell_line = self.checkTransaction(data, lower) + buy_line, sell_line = self.checkTransaction(data, upper, lower) # 그래프를 그린다. self.draw(given_day, data, upper, lower, buy_line, sell_line) @@ -659,7 +666,7 @@ class HTS: data, upper, lower = self.analyze(result) # 사야 할 시점과 팔아야 할 시점을 체크한다. - buy_line, sell_line = self.checkTransaction(data, lower) + buy_line, sell_line = self.checkTransaction(data, upper, lower) # 주문 및 매도 처리 price = buy_line[len(buy_line)-1] @@ -739,7 +746,6 @@ if __name__ == "__main__": #hts.currentStock(stock_code) #hts.printStockData(stock_code, given_day) - """ given_day = '20210909' hts.simulate(stock_code, given_day) given_day = '20210910' @@ -754,8 +760,17 @@ if __name__ == "__main__": hts.simulate(stock_code, given_day) given_day = '20210917' hts.simulate(stock_code, given_day) - """ + given_day = '20210923' + hts.simulate(stock_code, given_day) + given_day = '20210924' + hts.simulate(stock_code, given_day) + given_day = '20210927' + hts.simulate(stock_code, given_day) - hts.buyRealTime(stock_code, given_day) + """ + given_day = '20210915' + hts.simulate(stock_code, given_day) + """ + #hts.buyRealTime(stock_code, given_day) print ("done...")