-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstock_list.py
31 lines (24 loc) · 1.06 KB
/
stock_list.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import win32com.client
# 연결 여부 체크
objCpCybos = win32com.client.Dispatch("CpUtil.CpCybos")
bConnect = objCpCybos.IsConnect
if (bConnect == 0):
print("PLUS가 정상적으로 연결되지 않음. ")
exit()
# 종목코드 리스트 구하기
objCpCodeMgr = win32com.client.Dispatch("CpUtil.CpCodeMgr")
codeList = objCpCodeMgr.GetStockListByMarket(1) #거래소
codeList2 = objCpCodeMgr.GetStockListByMarket(2) #코스닥
print("거래소 종목코드", len(codeList))
for i, code in enumerate(codeList):
secondCode = objCpCodeMgr.GetStockSectionKind(code)
name = objCpCodeMgr.CodeToName(code)
stdPrice = objCpCodeMgr.GetStockStdPrice(code)
print(i, code, secondCode, stdPrice, name)
print("코스닥 종목코드", len(codeList2))
for i, code in enumerate(codeList2):
secondCode = objCpCodeMgr.GetStockSectionKind(code)
name = objCpCodeMgr.CodeToName(code)
stdPrice = objCpCodeMgr.GetStockStdPrice(code)
print(i, code, secondCode, stdPrice, name)
print("거래소 + 코스닥 종목코드 ",len(codeList) + len(codeList2))