박하늘

basic.py : fuzzy string

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]))
......