boj's Issues
test
`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 코스피 종목
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 코스닥 종목
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)
`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.