This commit is contained in:
dosangyoon
2021-09-19 11:32:36 +09:00
parent 07b19060dd
commit 7289676ab7
4 changed files with 2890 additions and 741 deletions

View File

@@ -204,8 +204,9 @@ class HTS:
# 주식 현재가 조회
def checkRealTime(self, stock_code):
# 연결 여부 체크
def getRealTime(self, stock_code, day):
day = '20210917'
objCpCybos = win32com.client.Dispatch("CpUtil.CpCybos")
bConnect = objCpCybos.IsConnect
if (bConnect == 0):
@@ -217,7 +218,7 @@ class HTS:
objStockChart.SetInputValue(0, 'A'+stock_code) # 종목 코드
objStockChart.SetInputValue(1, ord('2')) # 1: 기간으로 조회, 2: 개수로 조회
objStockChart.SetInputValue(2, '20210917')
objStockChart.SetInputValue(2, day)
#objStockChart.SetInputValue(3, '20210915')
objStockChart.SetInputValue(4, 100000) # 최근 n개 치
objStockChart.SetInputValue(5, [0, 1, 2, 3, 4, 5, 8]) # 날짜,시간,시가,고가,저가,종가,거래량
@@ -231,6 +232,7 @@ class HTS:
print("날짜", "시간", "시가", "고가", "저가", "종가", "거래량")
print("==============================================-")
result = []
for i in range(len):
day = objStockChart.GetDataValue(0, i)
time = objStockChart.GetDataValue(1, i)
@@ -240,8 +242,9 @@ class HTS:
close = objStockChart.GetDataValue(5, i)
vol = objStockChart.GetDataValue(6, i)
print(day, time, open, high, low, close, vol)
result.append([time, close])
return
return result
if __name__ == "__main__":
@@ -258,5 +261,7 @@ if __name__ == "__main__":
#hts.currentStock(stock_code)
hts.checkRealTime(stock_code)
day = datetime.today().strftime("%Y%m%d")
result = hts.getRealTime(stock_code, day)
print (result)
print ("done...")