Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design1
/
HCG_Project1
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
양지수
2021-05-19 13:24:46 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
448126c9abc0921e716255b0bd5dc51b7c913d24
448126c9
1 parent
bd38d0c5
주가시세에 맞춰서 극성조절
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
95 additions
and
15 deletions
knu/KnuSentiLex/KNU_edit.py
knu/KnuSentiLex/KNU_edit.py
View file @
448126c
...
...
@@ -137,39 +137,119 @@ for i in range(len(Stock_data)):
del
Stock_data
[
i
][
7
]
#시가 총액 삭제
for
i
in
range
(
len
(
Stock_data
)):
del
Stock_data
[
i
][
7
]
#상장주식 수 삭제 / 결과:'일자', '종가', '등락률', '시가', '고가', '저가', '거래량'
print
(
Stock_data
)
#
print(Stock_data)
def
Calpercentage
(
a
,
b
):
#시초가 대비 고점/저점 비율
return
abs
(
a
-
b
)
/
a
*
100
####아래로 수정 필요 (미완성)####
for
i
in
range
(
len
(
Stock_data
)
-
1
):
for
k
in
range
(
len
(
Setlist
)):
if
(
Stock_data
[
i
][
0
]
.
split
(
'/'
)
==
Setlist
[
k
][
0
]
.
split
(
'.'
)[:
3
]):
# 날짜 비교
i
=
0
for
k
in
range
(
len
(
Setlist
)):
if
(
Stock_data
[
i
][
0
]
.
split
(
'/'
)
==
Setlist
[
k
][
0
]
.
split
(
'.'
)[:
3
]):
# 날짜 비교 날짜가 같다면
if
Calpercentage
(
Stock_data
[
i
][
3
],
Stock_data
[
i
][
4
])
>
2
:
#당일 시가 대비 고가가 2퍼 높을때
for
j
in
range
(
1
,
len
(
Setlist
[
k
])):
if
Setlist
[
0
][
j
][
1
]
==
0
:
Setlist
[
0
][
j
][
1
]
=
1
if
Setlist
[
k
][
j
][
1
]
==
0
:
Setlist
[
k
][
j
][
1
]
=
1
else
:
Setlist
[
0
][
j
][
1
]
+=
1
elif
Calpercentage
(
Stock_data
[
i
][
3
],
Stock_data
[
i
][
5
])
<
-
2
:
#당일 시가 대비 저가가 2퍼 낮을 때
for
j
in
range
(
1
,
len
(
Setlist
[
k
])):
if
Setlist
[
0
][
j
][
1
]
==
0
:
Setlist
[
0
][
j
][
1
]
=
-
1
if
Setlist
[
k
][
j
][
1
]
==
0
:
Setlist
[
k
][
j
][
1
]
=
-
1
else
:
Setlist
[
0
][
j
][
1
]
-=
1
else
:
if
Stock_data
[
i
+
1
][
2
]
>
0
:
# 다음날 주가 등락률이 양수면
for
j
in
range
(
1
,
len
(
Setlist
[
k
])):
#어제뉴스는 호재 취급
if
Setlist
[
0
][
j
][
1
]
==
0
:
Setlist
[
0
][
j
][
1
]
=
1
if
Setlist
[
k
][
j
][
1
]
==
0
:
Setlist
[
k
][
j
][
1
]
=
1
else
:
Setlist
[
0
][
j
][
1
]
+=
1
Setlist
[
k
][
j
][
1
]
+=
1
elif
Stock_data
[
i
+
1
][
2
]
<
0
:
for
j
in
range
(
1
,
len
(
Setlist
[
k
])):
# 음수면 어제 뉴스는 악재 취급
if
Setlist
[
0
][
j
][
1
]
==
0
:
Setlist
[
0
][
j
][
1
]
=
-
1
if
Setlist
[
k
][
j
][
1
]
==
0
:
Setlist
[
k
][
j
][
1
]
=
-
1
else
:
Setlist
[
0
][
j
][
1
]
-=
1
print
(
Setlist
)
Setlist
[
k
][
j
][
1
]
-=
1
i
+=
1
else
:
if
Calpercentage
(
Stock_data
[
i
][
3
],
Stock_data
[
i
][
4
])
>
2
:
# 당일 시가 대비 고가가 2퍼 높을때
for
j
in
range
(
1
,
len
(
Setlist
[
k
])):
if
Setlist
[
k
][
j
][
1
]
==
0
:
Setlist
[
k
][
j
][
1
]
=
1
else
:
Setlist
[
k
][
j
][
1
]
+=
1
elif
Calpercentage
(
Stock_data
[
i
][
3
],
Stock_data
[
i
][
5
])
<
-
2
:
# 당일 시가 대비 저가가 2퍼 낮을 때
for
j
in
range
(
1
,
len
(
Setlist
[
k
])):
if
Setlist
[
k
][
j
][
1
]
==
0
:
Setlist
[
k
][
j
][
1
]
=
-
1
else
:
Setlist
[
k
][
j
][
1
]
-=
1
else
:
if
Stock_data
[
i
+
1
][
2
]
>
0
:
# 다음날 주가 등락률이 양수면
for
j
in
range
(
1
,
len
(
Setlist
[
k
])):
# 어제뉴스는 호재 취급
if
Setlist
[
k
][
j
][
1
]
==
0
:
Setlist
[
k
][
j
][
1
]
=
1
else
:
Setlist
[
k
][
j
][
1
]
+=
1
elif
Stock_data
[
i
+
1
][
2
]
<
0
:
for
j
in
range
(
1
,
len
(
Setlist
[
k
])):
# 음수면 어제 뉴스는 악재 취급
if
Setlist
[
k
][
j
][
1
]
==
0
:
Setlist
[
k
][
j
][
1
]
=
-
1
else
:
Setlist
[
k
][
j
][
1
]
-=
1
i
+=
1
#print(Setlist)
df_Setlist
=
pd
.
DataFrame
(
Setlist
)
df_Setlist
.
to_excel
(
Stockfilename
+
' KNU_New.xlsx'
,
sheet_name
=
'sheet1'
)
'''
for i in range(len(Stock_data)-1):
for k in range(len(Setlist)):
if (Stock_data[i][0].split('/') == Setlist[k][0].split('.')[:3]): # 날짜 비교
if Calpercentage(Stock_data[i][3], Stock_data[i][4]) > 2 : #당일 시가 대비 고가가 2퍼 높을때
for j in range(1, len(Setlist[k])):
if Setlist[k][j][1] == 0:
Setlist[k][j][1] = 1
else:
Setlist[k][j][1] += 1
elif Calpercentage(Stock_data[i][3], Stock_data[i][5]) < -2 : #당일 시가 대비 저가가 2퍼 낮을 때
for j in range(1, len(Setlist[k])):
if Setlist[k][j][1] == 0:
Setlist[k][j][1] = -1
else:
Setlist[k][j][1] -= 1
else:
if Stock_data[i+1][2] > 0: # 다음날 주가 등락률이 양수면
for j in range(1, len(Setlist[k])): #어제뉴스는 호재 취급
if Calpercentage(Stock_data[i+1][3], Stock_data[i+1][5]) < -2 :
for j in range(1, len(Setlist[k])):
if Setlist[k][j][1] == 0:
Setlist[k][j][1] = -1
else:
Setlist[k][j][1] -= 1
else:
if Setlist[k][j][1] == 0:
Setlist[k][j][1] = 1
else:
Setlist[k][j][1] += 1
elif Stock_data[i+1][2] < 0:
if Calpercentage(Stock_data[i+1][3], Stock_data[i+1][4]) > 2 :
for j in range(1, len(Setlist[k])):
if Setlist[k][j][1] == 0:
Setlist[k][j][1] = 1
else:
Setlist[k][j][1] += 1
else:
for j in range(1, len(Setlist[k])): # 음수면 어제 뉴스는 악재 취급
if Setlist[k][j][1] == 0:
Setlist[k][j][1] = -1
else:
Setlist[k][j][1] -= -1
else:
print(Setlist)
'''
...
...
Please
register
or
login
to post a comment