init
This commit is contained in:
99
hts/HTS.py
99
hts/HTS.py
@@ -749,6 +749,105 @@ class HTS:
|
||||
|
||||
return result
|
||||
|
||||
def getRealTime_DailyCheck(self, today, stock_code, stock):
|
||||
objCpCybos = win32com.client.Dispatch("CpUtil.CpCybos")
|
||||
bConnect = objCpCybos.IsConnect
|
||||
if (bConnect == 0):
|
||||
print("PLUS가 정상적으로 연결되지 않음. ")
|
||||
exit()
|
||||
|
||||
# 차트 객체 구하기
|
||||
objStockChart = win32com.client.Dispatch("CpSysDib.StockChart")
|
||||
|
||||
objStockChart.SetInputValue(0, 'A'+stock_code) # 종목 코드
|
||||
objStockChart.SetInputValue(1, ord('1')) # 1: 기간으로 조회, 2: 개수로 조회
|
||||
objStockChart.SetInputValue(2, today) # 기간 조회 시, 시작일
|
||||
objStockChart.SetInputValue(3, today) # 기간 조회 시, 종료일
|
||||
objStockChart.SetInputValue(4, 400) # 조회 시 가져오는 Line 개수
|
||||
objStockChart.SetInputValue(5, [0, 1, 2, 3, 4, 5, 8]) # 날짜,시간,시가,고가,저가,종가,거래량
|
||||
objStockChart.SetInputValue(6, ord('m')) # '차트 주가 - 월(M), 주(W), 일(D), 시(H), 분(m), 초(S) 차트 요청
|
||||
objStockChart.SetInputValue(7, 1)
|
||||
objStockChart.SetInputValue(9, ord('1')) # 수정주가 사용
|
||||
objStockChart.BlockRequest()
|
||||
|
||||
size = objStockChart.GetHeaderValue(3)
|
||||
|
||||
today_str = ""
|
||||
open, close, high, low, volume = 0, 0, 0, 9999999990, 0
|
||||
|
||||
#print("날짜", "시간", "시가", "고가", "저가", "종가", "거래량")
|
||||
start_time = datetime.strptime(today + " 090000", '%Y%m%d %H%M%S')
|
||||
#
|
||||
# 역순으로 결과가 오는지 확인이 필요함
|
||||
#
|
||||
for i in range(size-1, -1, -1):
|
||||
int_day = objStockChart.GetDataValue(0, i)
|
||||
int_time = objStockChart.GetDataValue(1, i)
|
||||
# ymd: '2022.03.29'
|
||||
# time = datetime.strptime(str(int_day)+" "+str(int_time).zfill(4)+"00", '%Y%m%d %H%M%S')
|
||||
# time_str = time.strftime('%Y.%m.%d')
|
||||
today_str = today[0:4] + "." + today[4:6] + "." + today[6:8]
|
||||
|
||||
if i == 0:
|
||||
open = objStockChart.GetDataValue(2, i)
|
||||
if i == size - 1:
|
||||
close = objStockChart.GetDataValue(5, i)
|
||||
high = max(high, objStockChart.GetDataValue(3, i))
|
||||
low = min(low, objStockChart.GetDataValue(4, i))
|
||||
volume = volume + objStockChart.GetDataValue(6, i)
|
||||
|
||||
stock['PRICE'].append(
|
||||
{
|
||||
"ymd": today_str,
|
||||
"close": close,
|
||||
"diff": -1,
|
||||
"open": open,
|
||||
"high": high,
|
||||
"low": low,
|
||||
"volume": volume,
|
||||
"avg3": -1,
|
||||
"avg4": -1,
|
||||
"avg5": -1,
|
||||
"avg6": -1,
|
||||
"avg10": -1,
|
||||
"avg12": -1,
|
||||
"avg20": -1,
|
||||
"avg36": -1,
|
||||
"avg40": -1,
|
||||
"avg48": -1,
|
||||
"avg60": -1,
|
||||
"avg120": -1,
|
||||
"avg200": -1,
|
||||
"avg240": -1,
|
||||
"avg300": -1,
|
||||
"disparity_avg5": -1,
|
||||
"disparity_avg10": -1,
|
||||
"disparity_avg20": -1,
|
||||
"disparity_avg60": -1,
|
||||
"disparity_avg120": -1,
|
||||
"bolingerband_upper": -1,
|
||||
"bolingerband_lower": -1,
|
||||
"bolingerband_middle": -1,
|
||||
"envelope_upper": -1,
|
||||
"envelope_lower": -1,
|
||||
"envelope_middle": -1,
|
||||
"ichimokucloud_changeLine": -1,
|
||||
"ichimokucloud_baseLine": -1,
|
||||
"ichimokucloud_leadingSpan1": -1,
|
||||
"ichimokucloud_leadingSpan2": -1,
|
||||
"stochastic_fast_k": -1,
|
||||
"stochastic_slow_k": -1,
|
||||
"stochastic_slow_d": -1,
|
||||
"rsi": -1,
|
||||
"rsis": -1,
|
||||
"macd": -1,
|
||||
"macds": -1,
|
||||
"macdo": -1,
|
||||
}
|
||||
)
|
||||
|
||||
return
|
||||
|
||||
def getClosePrice_realtime(self, stock_code, today):
|
||||
result = {"open": [], "close": [], "high": [], "low": [], "vol": []}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user