import win32com.client
#최근 10일간 code(str)종목의 시/고/저/종가, 거래량을 가져옵니다
#가장최근날짜부터
def sigojujonggu(n_day,code):
# Create object
instStockChart = win32com.client.Dispatch("CpSysDib.StockChart")
# SetInputValue
instStockChart.SetInputValue(0, code)
instStockChart.SetInputValue(1, ord('2'))
instStockChart.SetInputValue(4, n_day)
instStockChart.SetInputValue(5, (0, 2, 3, 4, 5, 8))
instStockChart.SetInputValue(6, ord('D'))
instStockChart.SetInputValue(9, ord('1'))
# BlockRequest
instStockChart.BlockRequest()
# GetHeaderValue
numData = instStockChart.GetHeaderValue(3)
numField = instStockChart.GetHeaderValue(1)
# GetDataValue
result=[]
for i in range(numData):
temp=[]
for j in range(numField):
temp.append(instStockChart.GetDataValue(j, i))
result.append(temp)
return result
print(sigojujonggu(2,"A003540"))