Skip to content

Instantly share code, notes, and snippets.

@esstory
Last active March 2, 2020 07:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esstory/dd965a21a2422414463703a58103ce19 to your computer and use it in GitHub Desktop.
Save esstory/dd965a21a2422414463703a58103ce19 to your computer and use it in GitHub Desktop.
PLUS API EX - 파이썬 - #7223 업종별 투자자 매매 현황 조회 샘플
import win32com.client
# 연결 여부 체크
objCpCybos = win32com.client.Dispatch("CpUtil.CpCybos")
bConnect = objCpCybos.IsConnect
if (bConnect == 0):
print("PLUS가 정상적으로 연결되지 않음. ")
exit()
obj7223= win32com.client.Dispatch("DsCbo1.CpSvr7223")
obj7223.SetInputValue(0, ord('4')) # 일자별
obj7223.SetInputValue(1, "001")
obj7223.SetInputValue(2, ord('1')) # 1: 누적, 2: 증감
obj7223.BlockRequest()
rqStatus = obj7223.GetDibStatus()
rqRet = obj7223.GetDibMsg1()
print("통신상태", rqStatus, rqRet)
if rqStatus != 0:
exit()
time = obj7223.GetHeaderValue(0) # time
count = obj7223.GetHeaderValue(1) # 데이터 개수
print( count)
for i in range(count) :
date = obj7223.GetDataValue(0, i) # 일자
invest_1 = obj7223.GetDataValue(1, i) # 개인
invest_2 = obj7223.GetDataValue(2, i) # 외국인
invest_3 = obj7223.GetDataValue(3, i) # 기관
print(date, invest_1, invest_2, invest_3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment