This commit is contained in:
dosangyoon
2021-09-27 22:05:35 +09:00
parent 488b1c187a
commit 32b7a5fa55
3 changed files with 25 additions and 10 deletions

View File

@@ -1,10 +1,10 @@
import win32com.client #import win32com.client
import time import time
import os import os
from datetime import datetime, timedelta from datetime import datetime, timedelta
import pandas as pd import pandas as pd
from enum import Enum from enum import Enum
#import plotly.graph_objects as go import plotly.graph_objects as go
# enum 주문 상태 세팅용 # enum 주문 상태 세팅용
@@ -569,9 +569,11 @@ class HTS:
fig.show() fig.show()
return return
def checkTransaction(self, data, lower): def checkTransaction(self, data, upper, lower):
low = data["Low"] low = data["Low"]
high = data["High"]
close = data["Close"] close = data["Close"]
open = data["Open"]
# 살 시점인지 체크 # 살 시점인지 체크
# 볼린저밴드 하단에 연속으로 같은 가격이 왔을 때, # 볼린저밴드 하단에 연속으로 같은 가격이 왔을 때,
@@ -588,6 +590,11 @@ class HTS:
buy_line[i+1] = low[i] + 5 buy_line[i+1] = low[i] + 5
check = False 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원 위로 매도를 건다. # 산 가격에 5원 위로 매도를 건다.
sell_line = [-1 for i in range(len(lower))] sell_line = [-1 for i in range(len(lower))]
@@ -620,7 +627,7 @@ class HTS:
data, upper, lower = self.analyze(result) 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) self.draw(given_day, data, upper, lower, buy_line, sell_line)
@@ -659,7 +666,7 @@ class HTS:
data, upper, lower = self.analyze(result) 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] price = buy_line[len(buy_line)-1]
@@ -739,7 +746,6 @@ if __name__ == "__main__":
#hts.currentStock(stock_code) #hts.currentStock(stock_code)
#hts.printStockData(stock_code, given_day) #hts.printStockData(stock_code, given_day)
"""
given_day = '20210909' given_day = '20210909'
hts.simulate(stock_code, given_day) hts.simulate(stock_code, given_day)
given_day = '20210910' given_day = '20210910'
@@ -754,8 +760,17 @@ if __name__ == "__main__":
hts.simulate(stock_code, given_day) hts.simulate(stock_code, given_day)
given_day = '20210917' given_day = '20210917'
hts.simulate(stock_code, given_day) 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...") print ("done...")