Toggle navigation
Toggle navigation
This project
Loading...
Sign in
박하늘
/
stock_chatbot
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-06-03 23:01:27 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
878c88d24981cc70d364f2274805293e2094b2d6
878c88d2
1 parent
72a8ad48
basic.py : fuzzy string
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
server/basic.py
server/basic.py
View file @
878c88d
import
FinanceDataReader
as
fdr
import
pandas
as
pd
import
sys
from
fuzzywuzzy
import
process
def
get_matches
(
query
,
choices
,
limit
=
3
):
result
=
process
.
extract
(
query
,
choices
,
limit
=
limit
)
return
result
def
basicinform
(
input
):
stocks
=
pd
.
read_csv
(
'stockcodename.csv'
,
index_col
=
0
)
stocks
=
pd
.
read_csv
(
'stockcodename.csv'
,
names
=
[
'Symbol'
,
'Market'
,
'Name'
,
'Sector'
,
'Industry'
,
'ListingDate'
,
'SettleMonth'
,
'Represetitive'
,
'HomePage'
,
'Region'
],
index_col
=
0
)
symbol
=
''
for
i
in
enumerate
(
stocks
.
Name
):
if
i
[
1
]
==
input
:
symbol
=
(
stocks
.
iloc
[
i
[
0
]]
.
Symbol
)
break
if
(
symbol
==
''
):
fuzzy
=
get_matches
(
input
,
stocks
[
'Name'
])
cand
=
''
for
i
in
fuzzy
:
cand
+=
i
[
0
]
cand
+=
" "
cand
+=
"중 찾는게 있으신가요?
\n
다시 입력해주세요."
return
cand
df
=
fdr
.
DataReader
(
symbol
)
ror_df
=
df
.
Close
.
pct_change
()
volume
=
df
.
Volume
.
iloc
[
-
1
]
...
...
@@ -25,7 +41,7 @@ def basicinform(input):
return
value
# print(basicinform('
삼성전자
'))
# print(basicinform('
신라호텔
'))
args
=
sys
.
argv
print
(
basicinform
(
args
[
1
]))
...
...
Please
register
or
login
to post a comment