Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-2-capstone-design2
/
2015104491
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
이하영
2020-11-04 12:01:13 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
18da410c0068abb2c4a3c9f206e0ebc17644be46
18da410c
1 parent
f989a46f
기업목록 받아오기
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
proj/itemList.py
proj/itemList.py
0 → 100644
View file @
18da410
import
pandas
as
pd
class
itemList
():
def
__init__
(
self
):
self
.
get_kospi
()
print
(
"코스피 종목 수 : "
,
len
(
self
.
code_df_kospi
))
print
(
self
.
code_df_kospi
)
self
.
get_kosdaq
()
print
(
"코스닥 종목 수 : "
,
len
(
self
.
code_df_kosdaq
))
print
(
self
.
code_df_kosdaq
)
def
get_download_stock
(
self
,
market_type
=
None
):
stock_type
=
{
'kospi'
:
'stockMkt'
,
'kosdaq'
:
'kosdaqMkt'
}
market_type
=
stock_type
[
market_type
]
# 한국거래소 - 상장공시시스템 링크를 이용
# searchType=13 : 상장기업을 대상으로 조회
download_link
=
'http://kind.krx.co.kr/corpgeneral/corpList.do?method=download&searchType=13'
download_link
=
download_link
+
'&marketType='
+
market_type
df
=
pd
.
read_html
(
download_link
,
header
=
0
)[
0
]
return
df
def
get_kospi
(
self
):
self
.
code_df_kospi
=
self
.
get_download_stock
(
'kospi'
)
self
.
code_df_kospi
.
종목코드
=
self
.
code_df_kospi
.
종목코드
.
map
(
'{:06d}'
.
format
)
# 종목코드는 6자리
self
.
code_df_kospi
=
self
.
code_df_kospi
[[
'회사명'
,
'종목코드'
]]
self
.
code_df_kospi
=
self
.
code_df_kospi
.
rename
(
columns
=
{
'회사명'
:
'code_name'
,
'종목코드'
:
'code'
})
# 한글 컬럼명을 영어로 변경
return
self
.
code_df_kospi
def
get_kosdaq
(
self
):
self
.
code_df_kosdaq
=
self
.
get_download_stock
(
'kosdaq'
)
self
.
code_df_kosdaq
.
종목코드
=
self
.
code_df_kosdaq
.
종목코드
.
map
(
'{:06d}'
.
format
)
self
.
code_df_kosdaq
=
self
.
code_df_kosdaq
[[
'회사명'
,
'종목코드'
]]
self
.
code_df_kosdaq
=
self
.
code_df_kosdaq
.
rename
(
columns
=
{
'회사명'
:
'code_name'
,
'종목코드'
:
'code'
})
return
self
.
code_df_kosdaq
if
__name__
==
"__main__"
:
itemList
()
\ No newline at end of file
Please
register
or
login
to post a comment