This commit is contained in:
dosangyoon
2021-09-22 23:52:54 +09:00
parent d566813399
commit 77c1fb98b9

View File

@@ -1,7 +1,9 @@
#import win32com.client #import win32com.client
import time
import os import os
from datetime import datetime, timedelta from datetime import datetime, timedelta
import pandas as pd import pandas as pd
import schedule
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import plotly.graph_objects as go import plotly.graph_objects as go
@@ -292,6 +294,7 @@ class HTS:
int_day = objStockChart.GetDataValue(0, i) int_day = objStockChart.GetDataValue(0, i)
int_time = objStockChart.GetDataValue(1, i) int_time = objStockChart.GetDataValue(1, i)
print (int_day, int_time) print (int_day, int_time)
if int_day < int_given_day: if int_day < int_given_day:
continue continue
time = datetime.strptime(str(int_day)+" "+str(objStockChart.GetDataValue(1, i)).zfill(4)+"00", '%Y%m%d %H%M%S') time = datetime.strptime(str(int_day)+" "+str(objStockChart.GetDataValue(1, i)).zfill(4)+"00", '%Y%m%d %H%M%S')
@@ -475,6 +478,21 @@ class HTS:
return return
def checkRealTime(self, stock_code, given_day, result):
# 데이터를 가지고 온다.
self.getRealTime(stock_code, given_day, result)
# 가져온 만큼 데이터를 누적해서 파일로 작성한다.
self.write(given_day, result)
# 분석을 통해서 볼린저밴드 상/하단을 계산한다.
data, upper, lower, buy_line, sell_line = self.analyze(result)
# 주문 및 매도 처리
# self.draw(given_day, data, upper, lower, buy_line, sell_line)
return
def buyRealTime(self, stock_code, given_day): def buyRealTime(self, stock_code, given_day):
result = {"check": set(), result = {"check": set(),
"time": [], "time": [],
@@ -484,17 +502,22 @@ class HTS:
"low": [], "low": [],
"vol": []} "vol": []}
# 데이터를 가지고 온다. schedule.every().hour.at(":0:5").do(self.checkRealTime(stock_code, given_day, result)) # 매시간 0분 5초에 작업 실행
self.getRealTime(stock_code, given_day, result) schedule.every().hour.at(":5:5").do(self.checkRealTime(stock_code, given_day, result)) # 매시간 5분 5초에 작업 실행
schedule.every().hour.at(":10:5").do(self.checkRealTime(stock_code, given_day, result)) # 매시간 10분 5초에 작업 실행
schedule.every().hour.at(":15:5").do(self.checkRealTime(stock_code, given_day, result)) # 매시간 15분 5초에 작업 실행
schedule.every().hour.at(":20:5").do(self.checkRealTime(stock_code, given_day, result)) # 매시간 20분 5초에 작업 실행
schedule.every().hour.at(":25:5").do(self.checkRealTime(stock_code, given_day, result)) # 매시간 25분 5초에 작업 실행
schedule.every().hour.at(":30:5").do(self.checkRealTime(stock_code, given_day, result)) # 매시간 30분 5초에 작업 실행
schedule.every().hour.at(":35:5").do(self.checkRealTime(stock_code, given_day, result)) # 매시간 35분 5초에 작업 실행
schedule.every().hour.at(":40:5").do(self.checkRealTime(stock_code, given_day, result)) # 매시간 40분 5초에 작업 실행
schedule.every().hour.at(":45:5").do(self.checkRealTime(stock_code, given_day, result)) # 매시간 45분 5초에 작업 실행
schedule.every().hour.at(":50:5").do(self.checkRealTime(stock_code, given_day, result)) # 매시간 50분 5초에 작업 실행
schedule.every().hour.at(":55:5").do(self.checkRealTime(stock_code, given_day, result)) # 매시간 55분 5초에 작업 실행
# 가져온 만큼 데이터를 누적해서 파일로 작성한다. while datetime.now() < datetime.strptime(given_day + " 151500", '%Y%m%d %H%M%S'):
self.write(given_day, result) schedule.run_pending()
time.sleep(1)
# 분석을 통해서 볼린저밴드 상/하단을 계산한다.
#data, upper, lower, buy_line, sell_line = self.analyze(result)
# 그래프를 그린다.
#self.draw(given_day, data, upper, lower, buy_line, sell_line)
return return
@@ -532,7 +555,7 @@ if __name__ == "__main__":
""" """
given_day = '20210917' given_day = '20210917'
hts.simulate(stock_code, given_day) #hts.simulate(stock_code, given_day)
#hts.buyRealTime(stock_code, given_day) hts.buyRealTime(stock_code, given_day)
print ("done...") print ("done...")