We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
`import ctypes import win32com.client import pandas as pd import time
t = time.localtime() if 9 <= t.tm_hour <= 16: sleep_time = 7 / (10 - 2) else: sleep_time = 15 / (20 - 2)
codeMgr = win32com.client.Dispatch('CpUtil.CpCodeMgr')
def codeToName(code): codeName = win32com.client.Dispatch('CpUtil.CpStockCode') return codeName.CodeToName(code)
def get_Chart(code): codeChart = win32com.client.Dispatch('CpSysDib.StockChart')
codeChart.setInputValue(0, code) codeChart.setInputValue(1, ord('2')) codeChart.setInputValue(4, 100) codeChart.setInputValue(5, [0, 5]) codeChart.setInputValue(6, ord('D')) codeChart.BlockRequest() chart_num = codeChart.GetHeaderValue(3) chart = [] for i in range(chart_num): data = (codeChart.GetDataValue(0, i), codeChart.GetDataValue(1, i)) # DATE - Price chart.append(data) return chart
kospi = pd.DataFrame() kospi.index.name = 'DATE'
kosdaq = pd.DataFrame() kosdaq.index.name = 'DATE'
kospi_Codes = codeMgr.GetStockListByMarket(1)
for code in kospi_Codes: name = codeToName(code) print(code, name) chart = get_Chart(code)
for date, price in chart: kospi.at[date, name] = price time.sleep(sleep_time)
kosdaq_Codes = codeMgr.GetStockListByMarket(2)
for code in kosdaq_Codes: name = codeToName(code) print(code, name) chart = get_Chart(code)
for date, price in chart: kosdaq.at[date, name] = price time.sleep(0.1)
kospi.to_csv('./KOSPI.csv', encoding='utf-8-sig', index=False) kosdaq.to_csv('./KOSDAQ.csv', encoding='utf-8-sig', index=False) `
The text was updated successfully, but these errors were encountered:
No branches or pull requests
`import ctypes
import win32com.client
import pandas as pd
import time
t = time.localtime()
if 9 <= t.tm_hour <= 16:
sleep_time = 7 / (10 - 2)
else:
sleep_time = 15 / (20 - 2)
codeMgr = win32com.client.Dispatch('CpUtil.CpCodeMgr')
def codeToName(code):
codeName = win32com.client.Dispatch('CpUtil.CpStockCode')
return codeName.CodeToName(code)
def get_Chart(code):
codeChart = win32com.client.Dispatch('CpSysDib.StockChart')
kospi = pd.DataFrame()
kospi.index.name = 'DATE'
kosdaq = pd.DataFrame()
kosdaq.index.name = 'DATE'
KOSPI 코스피 종목
kospi_Codes = codeMgr.GetStockListByMarket(1)
for code in kospi_Codes:
name = codeToName(code)
print(code, name)
chart = get_Chart(code)
KOSDAQ 코스닥 종목
kosdaq_Codes = codeMgr.GetStockListByMarket(2)
for code in kosdaq_Codes:
name = codeToName(code)
print(code, name)
chart = get_Chart(code)
kospi.to_csv('./KOSPI.csv', encoding='utf-8-sig', index=False)
kosdaq.to_csv('./KOSDAQ.csv', encoding='utf-8-sig', index=False)
`
The text was updated successfully, but these errors were encountered: