김승훈

project

import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
from bs4 import BeautifulSoup
import urllib
from urllib import request
import re
import json
from datetime import datetime
import plotly.offline as py
py.init_notebook_mode(connected=True)
import plotly.graph_objs as go
import plotly.tools as tls
import matplotlib.pyplot as plt
from random import shuffle
import random
#Setup
#load dataset
print("start read_csv")
df = pd.read_csv("trendresult.csv")
df = pd.DataFrame(df)
fig, axes = plt.subplots(nrows=3, ncols=2)
#df.plot(title = "Naver Trend - Stock-Daily", figsize = (20, 10), legend = False)
print("start read_csv_1")
df2 = pd.read_csv("finace_285130.csv")
df2 = pd.DataFrame(df2)
print(df2)
df["SK케미칼"].plot(title = "SK-chemical", figsize = (20,10), legend = False,ax=axes[0,0])
print(df["SK케미칼"])
df2.plot(title = "SK-chemical - Stock-Daily", figsize = (20, 10), legend = False,ax=axes[0,1])
df3 = pd.read_csv("finace_307070.csv")
df3 = pd.DataFrame(df3)
df["삼성머스트스팩3호"].plot(title = "삼성머스트스팩3호", figsize = (20,10), legend = False,ax=axes[1,0])
print(df3)
print(df["삼성머스트스팩3호"])
df3.plot(title = "SK hos - Stock-Daily", figsize = (20, 10), legend = False,ax=axes[1,1])
df4 = pd.read_csv("finace_309930.csv")
df4 = pd.DataFrame(df4)
df["SK4호스팩"].plot(title = "SK-호스팩", figsize = (20,10), legend = False,ax=axes[2,0])
print(df4)
print(df["SK4호스팩"])
df4.plot(title = "samsung - Stock-Daily", figsize = (20, 10), legend = False,ax=axes[2,1])
date,finance
2020.05.07,78800
2020.05.06,77700
2020.05.04,75500
2020.04.29,77700
2020.04.28,78600
2020.04.27,77700
2020.04.24,77300
2020.04.23,77800
2020.04.22,78900
2020.04.21,77700
2020.04.20,79200
2020.04.17,79300
2020.04.16,80200
2020.04.14,82400
2020.04.13,83900
2020.04.10,81000
2020.04.09,80700
2020.04.08,79100
2020.04.07,80600
2020.04.06,82000
2020.04.03,81000
2020.04.02,80500
2020.04.01,81500
2020.03.31,84600
2020.03.30,87300
2020.03.27,76800
2020.03.26,71600
2020.03.25,64800
2020.03.24,64800
2020.03.23,63400
2020.03.20,62800
2020.03.19,56700
2020.03.18,64300
2020.03.17,61000
2020.03.16,54300
2020.03.13,52500
2020.03.12,57000
2020.03.11,59900
2020.03.10,62000
2020.03.09,64100
2020.03.06,60600
2020.03.05,61900
2020.03.04,62100
2020.03.03,61000
2020.03.02,60000
2020.02.28,57500
2020.02.27,60100
2020.02.26,61600
2020.02.25,63900
2020.02.24,63600
2020.02.21,67100
2020.02.20,68400
2020.02.19,66900
2020.02.18,67100
2020.02.17,68000
2020.02.14,68900
2020.02.13,70000
2020.02.12,70700
2020.02.11,69900
2020.02.10,68300
2020.02.07,69900
2020.02.06,69900
2020.02.05,66800
2020.02.04,59800
2020.02.03,58000
2020.01.31,57900
2020.01.30,60600
2020.01.29,62700
2020.01.28,64100
2020.01.23,66200
2020.01.22,66300
2020.01.21,66200
2020.01.20,67500
2020.01.17,66200
2020.01.16,66100
2020.01.15,66200
2020.01.14,67000
2020.01.13,66500
2020.01.10,69000
2020.01.09,65100
2020.01.08,63100
2020.01.07,65800
2020.01.06,66400
2020.01.03,67000
2020.01.02,66700
2019.12.30,64000
2019.12.27,63000
2019.12.26,62200
2019.12.24,63100
2019.12.23,61100
2019.12.20,60500
2019.12.19,60600
2019.12.18,60500
2019.12.17,60900
2019.12.16,62000
2019.12.13,62300
2019.12.12,62200
2019.12.11,61600
2019.12.10,61400
2019.12.09,61200
2019.12.06,62700
2019.12.05,62500
2019.12.04,63800
2019.12.03,65200
2019.12.02,66800
2019.11.29,70200
2019.11.28,77200
2019.11.27,73400
2019.11.26,56500
2019.11.25,57100
2019.11.22,54400
2019.11.21,52100
2019.11.20,52300
2019.11.19,53200
2019.11.18,53900
2019.11.15,54200
2019.11.14,54800
2019.11.13,54000
2019.11.12,54800
2019.11.11,53400
2019.11.08,52500
2019.11.07,51000
2019.11.06,50400
2019.11.05,51000
2019.11.04,50900
2019.11.01,47600
2019.10.31,47200
2019.10.30,47400
2019.10.29,47700
2019.10.28,47450
2019.10.25,46950
2019.10.24,47400
2019.10.23,47300
2019.10.22,47200
2019.10.21,47400
2019.10.18,47300
2019.10.17,47550
2019.10.16,47850
2019.10.15,48200
2019.10.14,47150
2019.10.11,45450
2019.10.10,44500
2019.10.08,44700
2019.10.07,44250
2019.10.04,44250
2019.10.02,45350
2019.10.01,46550
2019.09.30,45300
2019.09.27,46150
2019.09.26,46900
2019.09.25,47000
2019.09.24,48300
2019.09.23,47850
2019.09.20,48100
2019.09.19,47750
2019.09.18,48100
2019.09.17,48200
2019.09.16,48100
2019.09.11,45950
2019.09.10,45700
2019.09.09,43500
2019.09.06,44200
2019.09.05,45000
2019.09.04,44750
2019.09.03,44700
2019.09.02,43900
2019.08.30,43550
2019.08.29,42950
2019.08.28,43300
2019.08.27,43050
2019.08.26,43400
2019.08.23,44150
2019.08.22,44200
2019.08.21,43600
2019.08.20,44100
2019.08.19,43550
2019.08.16,42050
2019.08.14,42550
2019.08.13,42500
2019.08.12,42150
2019.08.09,42600
2019.08.08,42650
2019.08.07,41750
2019.08.06,40200
2019.08.05,41550
2019.08.02,42700
2019.08.01,44050
2019.07.31,44500
2019.07.30,45500
2019.07.29,45550
2019.07.26,47000
2019.07.25,47650
2019.07.24,49000
2019.07.23,49100
2019.07.22,49800
2019.07.19,49300
2019.07.18,48700
2019.07.17,49150
2019.07.16,51100
2019.07.15,50600
2019.07.12,52400
2019.07.11,53400
2019.07.10,53200
2019.07.09,52700
2019.07.08,53600
2019.07.05,55900
2019.07.04,55900
2019.07.03,56900
2019.07.02,57800
2019.07.01,58300
2019.06.28,57500
2019.06.27,58000
2019.06.26,56900
2019.06.25,57400
2019.06.24,58300
2019.06.21,59000
2019.06.20,58000
2019.06.19,57100
2019.06.18,56500
2019.06.17,56300
2019.06.14,57900
2019.06.13,59100
2019.06.12,59200
2019.06.11,59400
2019.06.10,58400
2019.06.07,58300
2019.06.05,57400
2019.06.04,57500
2019.06.03,56300
2019.05.31,56900
2019.05.30,56400
2019.05.29,57000
2019.05.28,58300
2019.05.27,59100
2019.05.24,58200
2019.05.23,57800
2019.05.22,59600
2019.05.21,59300
2019.05.20,59900
2019.05.17,60400
2019.05.16,61000
2019.05.15,61300
2019.05.14,60400
2019.05.13,61000
2019.05.10,63400
2019.05.09,64100
2019.05.08,65300
2019.05.07,65400
2019.05.03,67200
2019.05.02,67500
2019.04.30,67700
2019.04.29,67700
2019.04.26,66000
2019.04.25,67400
2019.04.24,68500
2019.04.23,69800
2019.04.22,69900
2019.04.19,71600
2019.04.18,70900
2019.04.17,72800
2019.04.16,70600
2019.04.15,71100
2019.04.12,70600
2019.04.11,71200
2019.04.10,69800
2019.04.09,68200
2019.04.08,69000
2019.04.05,69800
2019.04.04,70400
2019.04.03,70400
2019.04.02,69000
2019.04.01,70400
2019.03.29,69300
2019.03.28,69200
2019.03.27,67800
2019.03.26,68100
2019.03.25,67500
2019.03.22,67900
2019.03.21,70200
2019.03.20,71900
2019.03.19,71600
2019.03.18,73100
2019.03.15,70600
2019.03.14,70600
2019.03.13,72500
2019.03.12,71900
2019.03.11,72400
2019.03.08,73000
2019.03.07,74000
2019.03.06,75900
2019.03.05,75800
2019.03.04,77300
2019.02.28,73700
2019.02.27,73200
2019.02.26,72600
2019.02.25,73000
2019.02.22,72600
2019.02.21,73500
2019.02.20,73700
2019.02.19,74900
2019.02.18,75100
2019.02.15,74900
2019.02.14,75000
2019.02.13,74300
2019.02.12,72400
2019.02.11,71400
2019.02.08,70800
2019.02.07,66800
2019.02.01,67500
2019.01.31,68500
2019.01.30,68000
2019.01.29,67900
2019.01.28,68300
2019.01.25,67700
2019.01.24,67200
2019.01.23,67100
2019.01.22,67300
2019.01.21,65700
2019.01.18,64000
2019.01.17,63700
2019.01.16,64200
2019.01.15,65000
2019.01.14,66600
2019.01.11,67600
2019.01.10,68700
2019.01.09,67700
2019.01.08,66700
2019.01.07,66200
2019.01.04,66500
2019.01.03,69100
2019.01.02,69700
2018.12.28,70000
2018.12.27,69800
2018.12.26,70500
2018.12.24,71300
2018.12.21,72100
2018.12.20,72500
2018.12.19,73100
2018.12.18,70700
2018.12.17,71700
2018.12.14,71300
2018.12.13,73600
2018.12.12,73100
2018.12.11,69900
2018.12.10,72200
2018.12.07,72500
2018.12.06,73800
2018.12.05,75300
2018.12.04,76600
2018.12.03,78400
2018.11.30,77700
2018.11.29,78000
2018.11.28,78800
2018.11.27,78600
2018.11.26,79800
2018.11.23,78500
2018.11.22,79100
2018.11.21,77800
2018.11.20,72800
2018.11.19,71600
2018.11.16,70700
2018.11.15,70600
2018.11.14,69900
2018.11.13,70200
2018.11.12,70900
2018.11.09,72700
2018.11.08,70000
2018.11.07,64600
2018.11.06,66300
2018.11.05,65000
2018.11.02,64500
2018.11.01,60800
2018.10.31,60400
2018.10.30,60200
2018.10.29,58000
2018.10.26,63500
2018.10.25,65700
2018.10.24,66400
2018.10.23,65500
2018.10.22,67500
2018.10.19,69800
2018.10.18,70600
2018.10.17,71700
2018.10.16,70600
2018.10.15,71700
2018.10.12,72000
2018.10.11,72200
2018.10.10,73200
2018.10.08,77600
2018.10.05,80000
2018.10.04,80900
2018.10.02,84100
2018.10.01,85000
2018.09.28,85200
2018.09.27,85200
2018.09.21,84400
2018.09.20,82800
2018.09.19,82500
2018.09.18,84100
2018.09.17,86200
2018.09.14,86600
2018.09.13,87100
2018.09.12,88400
2018.09.11,88800
2018.09.10,90700
2018.09.07,90000
2018.09.06,89000
2018.09.05,87800
2018.09.04,88100
2018.09.03,86700
2018.08.31,86600
2018.08.30,86000
2018.08.29,85200
2018.08.28,82600
2018.08.27,82400
2018.08.24,81800
2018.08.23,79800
2018.08.22,80500
2018.08.21,82500
2018.08.20,81300
2018.08.17,82000
2018.08.16,82600
2018.08.14,84400
2018.08.13,85500
2018.08.10,88000
2018.08.09,87500
2018.08.08,88200
2018.08.07,89000
2018.08.06,90000
2018.08.03,88800
2018.08.02,88400
2018.08.01,90100
2018.07.31,89700
2018.07.30,87100
2018.07.27,88100
2018.07.26,88400
2018.07.25,87600
2018.07.24,90400
2018.07.23,89900
2018.07.20,92400
2018.07.19,93200
2018.07.18,94200
2018.07.17,94400
2018.07.16,94400
2018.07.13,95100
2018.07.12,94000
2018.07.11,94000
2018.07.10,93300
2018.07.09,92900
2018.07.06,93800
2018.07.05,90600
2018.07.04,92200
2018.07.03,91500
2018.07.02,92500
2018.06.29,92900
2018.06.28,92800
2018.06.27,91800
2018.06.26,92700
2018.06.25,92300
2018.06.22,93000
2018.06.21,92300
2018.06.20,92000
2018.06.19,88700
2018.06.18,93000
2018.06.15,96300
2018.06.14,91100
2018.06.12,90100
2018.06.11,89700
2018.06.08,88700
2018.06.07,88000
2018.06.05,86400
2018.06.04,85700
2018.06.01,88100
2018.05.31,88900
2018.05.30,87300
2018.05.29,88600
2018.05.28,85100
2018.05.25,84500
2018.05.24,87900
2018.05.23,90200
2018.05.21,91900
2018.05.18,93800
2018.05.17,94500
2018.05.16,96600
2018.05.15,96700
2018.05.14,98000
2018.05.11,98100
2018.05.10,97700
2018.05.09,98400
2018.05.08,98700
2018.05.04,100500
2018.05.03,102500
2018.05.02,100500
2018.04.30,101500
2018.04.27,102500
2018.04.26,105000
2018.04.25,105000
2018.04.24,105000
2018.04.23,106000
2018.04.20,103000
2018.04.19,102500
2018.04.18,103500
2018.04.17,106000
2018.04.16,107000
2018.04.13,106500
2018.04.12,106500
2018.04.11,107000
2018.04.10,104500
2018.04.09,105000
2018.04.06,101500
2018.04.05,101500
2018.04.04,103000
2018.04.03,104000
2018.04.02,103500
2018.03.30,105000
2018.03.29,104000
2018.03.28,102000
2018.03.27,104500
2018.03.26,105000
2018.03.23,105000
2018.03.22,110500
2018.03.21,109000
2018.03.20,108000
2018.03.19,110500
2018.03.16,110500
2018.03.15,112000
2018.03.14,113000
2018.03.13,110500
2018.03.12,109500
2018.03.09,109000
2018.03.08,109000
2018.03.07,106000
2018.03.06,105000
2018.03.05,104500
2018.03.02,106500
2018.02.28,109000
2018.02.27,109000
2018.02.26,110000
2018.02.23,113500
2018.02.22,111000
2018.02.21,113000
2018.02.20,109500
2018.02.19,109500
2018.02.14,105000
2018.02.13,107000
2018.02.12,103000
2018.02.09,100500
2018.02.08,100000
2018.02.07,99200
2018.02.06,101500
2018.02.05,102500
2018.02.02,109000
2018.02.01,112000
2018.01.31,115000
2018.01.30,115500
2018.01.29,112000
2018.01.26,112500
2018.01.25,115000
2018.01.24,115000
2018.01.23,111000
2018.01.22,109500
2018.01.19,111000
2018.01.18,111500
2018.01.17,112500
2018.01.16,120000
2018.01.15,122000
2018.01.12,118500
2018.01.11,114000
2018.01.10,114000
2018.01.09,116000
2018.01.08,101000
2018.01.05,107500
date,finance
2020.05.07,2020
2020.05.06,2020
2020.05.04,2020
2020.04.29,2025
2020.04.28,2010
2020.04.27,2020
2020.04.24,2020
2020.04.23,2010
2020.04.22,2010
2020.04.21,2010
2020.04.20,2010
2020.04.17,2010
2020.04.16,2025
2020.04.14,2025
2020.04.13,2020
2020.04.10,2020
2020.04.09,2020
2020.04.08,2015
2020.04.07,2005
2020.04.06,2010
2020.04.03,2010
2020.04.02,2000
2020.04.01,2000
2020.03.31,2005
2020.03.30,2010
2020.03.27,2010
2020.03.26,2010
2020.03.25,2010
2020.03.24,2000
2020.03.23,2010
2020.03.20,2010
2020.03.19,2005
2020.03.18,2015
2020.03.17,2015
2020.03.16,2030
2020.03.13,2030
2020.03.12,2035
2020.03.11,2025
2020.03.10,2050
2020.03.09,2050
2020.03.06,2050
2020.03.05,2050
2020.03.04,2050
2020.03.03,2040
2020.03.02,2020
2020.02.28,2050
2020.02.27,2050
2020.02.26,2050
2020.02.25,2045
2020.02.24,2050
2020.02.21,2050
2020.02.20,2050
2020.02.19,2045
2020.02.18,2050
2020.02.17,2050
2020.02.14,2040
2020.02.13,2045
2020.02.12,2045
2020.02.11,2040
2020.02.10,2040
2020.02.07,2015
2020.02.06,2040
2020.02.05,2050
2020.02.04,2030
2020.02.03,2050
2020.01.31,2040
2020.01.30,2040
2020.01.29,2035
2020.01.28,2035
2020.01.23,2050
2020.01.22,2040
2020.01.21,2040
2020.01.20,2030
2020.01.17,2025
2020.01.16,2030
2020.01.15,2025
2020.01.14,2035
2020.01.13,2025
2020.01.10,2035
2020.01.09,2035
2020.01.08,2025
2020.01.07,2045
2020.01.06,2030
2020.01.03,2045
2020.01.02,2035
2019.12.30,2045
2019.12.27,2045
2019.12.26,2035
2019.12.24,2040
2019.12.23,2035
2019.12.20,2045
2019.12.19,2045
2019.12.18,2045
2019.12.17,2040
2019.12.16,2065
2019.12.13,2075
2019.12.12,2065
2019.12.11,2055
2019.12.10,2070
2019.12.09,2070
2019.12.06,2075
2019.12.05,2075
2019.12.04,2075
2019.12.03,2080
2019.12.02,2080
2019.11.29,2070
2019.11.28,2050
2019.11.27,2080
2019.11.26,2075
2019.11.25,2070
2019.11.22,2070
2019.11.21,2070
2019.11.20,2075
2019.11.19,2060
2019.11.18,2060
2019.11.15,2055
2019.11.14,2075
2019.11.13,2060
2019.11.12,2065
2019.11.11,2070
2019.11.08,2075
2019.11.07,2070
2019.11.06,2055
2019.11.05,2065
2019.11.04,2065
2019.11.01,2080
2019.10.31,2070
2019.10.30,2060
2019.10.29,2080
2019.10.28,2070
2019.10.25,2060
2019.10.24,2085
2019.10.23,2085
2019.10.22,2090
2019.10.21,2095
2019.10.18,2095
2019.10.17,2085
2019.10.16,2080
2019.10.15,2085
2019.10.14,2090
2019.10.11,2095
2019.10.10,2095
2019.10.08,2095
2019.10.07,2095
2019.10.04,2100
2019.10.02,2100
2019.10.01,2095
2019.09.30,2090
2019.09.27,2095
2019.09.26,2100
2019.09.25,2095
2019.09.24,2090
2019.09.23,2090
2019.09.20,2095
2019.09.19,2085
2019.09.18,2100
2019.09.17,2105
2019.09.16,2115
2019.09.11,2100
2019.09.10,2090
2019.09.09,2100
2019.09.06,2100
2019.09.05,2080
2019.09.04,2095
2019.09.03,2075
2019.09.02,2095
2019.08.30,2090
2019.08.29,2095
2019.08.28,2100
2019.08.27,2090
2019.08.26,2075
2019.08.23,2080
2019.08.22,2080
2019.08.21,2090
2019.08.20,2090
2019.08.19,2080
2019.08.16,2095
2019.08.14,2100
2019.08.13,2090
2019.08.12,2075
2019.08.09,2080
2019.08.08,2095
2019.08.07,2090
2019.08.06,2085
2019.08.05,2095
2019.08.02,2100
2019.08.01,2110
2019.07.31,2115
2019.07.30,2090
2019.07.29,2085
2019.07.26,2085
2019.07.25,2090
2019.07.24,2095
2019.07.23,2090
2019.07.22,2095
2019.07.19,2100
2019.07.18,2095
2019.07.17,2100
2019.07.16,2110
2019.07.15,2115
2019.07.12,2115
2019.07.11,2120
2019.07.10,2125
2019.07.09,2105
2019.07.08,2125
2019.07.05,2135
2019.07.04,2120
2019.07.03,2140
2019.07.02,2140
2019.07.01,2160
2019.06.28,2140
2019.06.27,2145
2019.06.26,2135
2019.06.25,2140
2019.06.24,2235
2019.06.21,2270
2019.06.20,2165
2019.06.19,2150
2019.06.18,2170
2019.06.17,2120
2019.06.14,2100
2019.06.13,2100
2019.06.12,2090
2019.06.11,2090
2019.06.10,2085
2019.06.07,2085
2019.06.05,2090
2019.06.04,2090
2019.06.03,2080
2019.05.31,2090
2019.05.30,2080
2019.05.29,2070
2019.05.28,2065
2019.05.27,2060
2019.05.24,2075
2019.05.23,2070
2019.05.22,2080
2019.05.21,2075
2019.05.20,2055
2019.05.17,2060
2019.05.16,2085
2019.05.15,2050
2019.05.14,2115
2019.05.13,2115
2019.05.10,2075
2019.05.09,2085
2019.05.08,2085
2019.05.07,2080
2019.05.03,2070
2019.05.02,2070
2019.04.30,2075
2019.04.29,2065
2019.04.26,2065
2019.04.25,2055
2019.04.24,2055
2019.04.23,2055
2019.04.22,2055
2019.04.19,2045
2019.04.18,2050
2019.04.17,2040
2019.04.16,2040
2019.04.15,2025
2019.04.12,2040
2019.04.11,2030
2019.04.10,2035
2019.04.09,2030
2019.04.08,2030
2019.04.05,2030
2019.04.04,2020
2019.04.03,2020
2019.04.02,2020
2019.04.01,2020
2019.03.29,2025
2019.03.28,2020
2019.03.27,2020
2019.03.26,2020
2019.03.25,2015
2019.03.22,2020
2019.03.21,2020
2019.03.20,2030
2019.03.19,2025
2019.03.18,2025
2019.03.15,2020
2019.03.14,2015
2019.03.13,2015
2019.03.12,2020
2019.03.11,2020
2019.03.08,2015
2019.03.07,2010
2019.03.06,2010
2019.03.05,2010
2019.03.04,2010
2019.02.28,2010
2019.02.27,2010
2019.02.26,2010
2019.02.25,2010
2019.02.22,2035
2019.02.21,2010
2019.02.20,2020
2019.02.19,2020
2019.02.18,2020
2019.02.15,2025
2019.02.14,2020
2019.02.13,2020
2019.02.12,2025
2019.02.11,2020
2019.02.08,2020
2019.02.07,2020
2019.02.01,2015
2019.01.31,2010
2019.01.30,2015
2019.01.29,2015
2019.01.28,2010
2019.01.25,2010
2019.01.24,2015
2019.01.23,2015
2019.01.22,2015
2019.01.21,2015
2019.01.18,2015
2019.01.17,2010
2019.01.16,2010
2019.01.15,2010
2019.01.14,2025
2019.01.11,2030
2019.01.10,2010
2019.01.09,2020
2019.01.08,2025
2019.01.07,2010
2019.01.04,2010
2019.01.03,2010
2019.01.02,2010
2018.12.28,2010
2018.12.27,2010
2018.12.26,2020
2018.12.24,2025
2018.12.21,2000
2018.12.20,2005
2018.12.19,2005
2018.12.18,2005
2018.12.17,2010
2018.12.14,2005
2018.12.13,2010
2018.12.12,2005
2018.12.11,2010
2018.12.10,2015
2018.12.07,2010
date,finance
2020.05.07,2090
2020.05.06,2090
2020.05.04,2090
2020.04.29,2090
2020.04.28,2090
2020.04.27,2090
2020.04.24,2100
2020.04.23,2095
2020.04.22,2085
2020.04.21,2070
2020.04.20,2060
2020.04.17,2060
2020.04.16,2055
2020.04.14,2045
2020.04.13,2040
2020.04.10,2035
2020.04.09,2035
2020.04.08,2030
2020.04.07,2030
2020.04.06,2015
2020.04.03,2005
2020.04.02,2005
2020.04.01,2010
2020.03.31,2015
2020.03.30,2020
2020.03.27,2020
2020.03.26,2000
2020.03.25,2000
2020.03.24,1995
2020.03.23,2005
2020.03.20,2020
2020.03.19,2020
2020.03.18,2025
2020.03.17,2030
2020.03.16,2035
2020.03.13,2045
2020.03.12,2050
2020.03.11,2035
2020.03.10,2055
2020.03.09,2055
2020.03.06,2055
2020.03.05,2055
2020.03.04,2055
2020.03.03,2055
2020.03.02,2040
2020.02.28,2055
2020.02.27,2050
2020.02.26,2050
2020.02.25,2040
2020.02.24,2070
2020.02.21,2095
2020.02.20,2095
2020.02.19,2085
2020.02.18,2105
2020.02.17,2080
2020.02.14,2070
2020.02.13,2075
2020.02.12,2060
2020.02.11,2055
2020.02.10,2055
2020.02.07,2060
2020.02.06,2060
2020.02.05,2055
2020.02.04,2050
2020.02.03,2050
2020.01.31,2050
2020.01.30,2055
2020.01.29,2050
2020.01.28,2035
2020.01.23,2060
2020.01.22,2050
2020.01.21,2050
2020.01.20,2050
2020.01.17,2055
2020.01.16,2055
2020.01.15,2055
2020.01.14,2055
2020.01.13,2055
2020.01.10,2050
2020.01.09,2055
2020.01.08,2050
2020.01.07,2050
2020.01.06,2055
2020.01.03,2050
2020.01.02,2045
2019.12.30,2035
2019.12.27,2045
2019.12.26,2045
2019.12.24,2045
2019.12.23,2045
2019.12.20,2045
2019.12.19,2050
2019.12.18,2055
2019.12.17,2060
2019.12.16,2065
2019.12.13,2060
2019.12.12,2055
2019.12.11,2050
2019.12.10,2060
2019.12.09,2055
2019.12.06,2065
2019.12.05,2085
2019.12.04,2075
2019.12.03,2080
2019.12.02,2080
2019.11.29,2080
2019.11.28,2060
2019.11.27,2060
2019.11.26,2060
2019.11.25,2045
2019.11.22,2045
2019.11.21,2060
2019.11.20,2060
2019.11.19,2065
2019.11.18,2060
2019.11.15,2080
2019.11.14,2085
2019.11.13,2110
2019.11.12,2110
2019.11.11,2060
2019.11.08,2060
2019.11.07,2070
2019.11.06,2070
2019.11.05,2070
2019.11.04,2070
2019.11.01,2075
2019.10.31,2100
2019.10.30,2110
2019.10.29,2120
2019.10.28,2120
2019.10.25,2090
2019.10.24,2085
2019.10.23,2095
2019.10.22,2110
2019.10.21,2115
2019.10.18,2100
2019.10.17,2100
2019.10.16,2110
2019.10.15,2130
2019.10.14,2150
2019.10.11,2120
2019.10.10,2155
2019.10.08,2125
2019.10.07,2125
2019.10.04,2125
2019.10.02,2185
2019.10.01,2180
2019.09.30,2190
2019.09.27,2195
2019.09.26,2185
2019.09.25,2170
2019.09.24,2190
2019.09.23,2190
2019.09.20,2195
2019.09.19,2190
2019.09.18,2195
2019.09.17,2185
2019.09.16,2215
2019.09.11,2215
2019.09.10,2200
2019.09.09,2160
2019.09.06,2165
2019.09.05,2165
2019.09.04,2175
2019.09.03,2130
2019.09.02,2130
2019.08.30,2155
2019.08.29,2185
2019.08.28,2150
2019.08.27,2195
2019.08.26,2145
2019.08.23,2145
2019.08.22,2150
2019.08.21,2140
2019.08.20,2140
2019.08.19,2120
2019.08.16,2120
2019.08.14,2130
2019.08.13,2130
2019.08.12,2150
2019.08.09,2145
2019.08.08,2150
2019.08.07,2160
2019.08.06,2130
2019.08.05,2125
2019.08.02,2180
2019.08.01,2205
2019.07.31,2235
2019.07.30,2190
2019.07.29,2150
2019.07.26,2190
2019.07.25,2185
2019.07.24,2180
2019.07.23,2185
2019.07.22,2185
2019.07.19,2160
2019.07.18,2160
2019.07.17,2180
2019.07.16,2190
2019.07.15,2175
2019.07.12,2180
2019.07.11,2190
2019.07.10,2190
2019.07.09,2190
2019.07.08,2170
2019.07.05,2195
2019.07.04,2175
2019.07.03,2200
2019.07.02,2140
2019.07.01,2170
2019.06.28,2170
2019.06.27,2175
2019.06.26,2175
2019.06.25,2180
2019.06.24,2180
2019.06.21,2185
2019.06.20,2185
2019.06.19,2145
2019.06.18,2150
2019.06.17,2165
2019.06.14,2130
2019.06.13,2120
2019.06.12,2130
2019.06.11,2115
2019.06.10,2110
2019.06.07,2130
2019.06.05,2125
2019.06.04,2105
2019.06.03,2130
2019.05.31,2115
2019.05.30,2085
2019.05.29,2105
2019.05.28,2095
2019.05.27,2100
2019.05.24,2095
2019.05.23,2080
2019.05.22,2080
2019.05.21,2070
2019.05.20,2070
2019.05.17,2080
2019.05.16,2080
2019.05.15,2075
2019.05.14,2085
2019.05.13,2120
2019.05.10,2110
2019.05.09,2100
2019.05.08,2100
2019.05.07,2080
2019.05.03,2070
2019.05.02,2100
2019.04.30,2100
2019.04.29,2105
2019.04.26,2100
2019.04.25,2100
2019.04.24,2110
2019.04.23,2095
2019.04.22,2070
2019.04.19,2075
2019.04.18,2055
2019.04.17,2050
2019.04.16,2060
2019.04.15,2040
2019.04.12,2060
2019.04.11,2050
2019.04.10,2055
2019.04.09,2040
2019.04.08,2040
2019.04.05,2040
2019.04.04,2040
2019.04.03,2030
2019.04.02,2020
2019.04.01,2025
2019.03.29,2030
2019.03.28,2035
2019.03.27,2020
2019.03.26,2040
2019.03.25,2035
2019.03.22,2035
2019.03.21,2035
2019.03.20,2025
2019.03.19,2030
2019.03.18,2030
2019.03.15,2020
2019.03.14,2030
2019.03.13,2030
2019.03.12,2025
2019.03.11,2025
2019.03.08,2020
2019.03.07,2015
2019.03.06,2015
2019.03.05,2025
2019.03.04,2025
2019.02.28,2025
2019.02.27,2025
2019.02.26,2010
2019.02.25,2015
2019.02.22,2010
2019.02.21,2015
2019.02.20,2015
2019.02.19,2020
2019.02.18,2020
2019.02.15,2030
2019.02.14,2030
2019.02.13,2025
2019.02.12,2025
2019.02.11,2020
2019.02.08,2030
2019.02.07,2030
2019.02.01,2030
2019.01.31,2025
2019.01.30,2025
2019.01.29,2025
2019.01.28,2020
2019.01.25,2020
2019.01.24,2020
2019.01.23,2020
2019.01.22,2020
2019.01.21,2020
2019.01.18,2020
2019.01.17,2015
2019.01.16,2015
2019.01.15,2015
2019.01.14,2010
2019.01.11,2015
2019.01.10,2020
2019.01.09,2025
2019.01.08,2020
2019.01.07,2020
2019.01.04,2020
2019.01.03,2020
2019.01.02,2010
2018.12.28,2010
2018.12.27,2025
2018.12.26,2020
2018.12.24,2025
2018.12.21,2005
2018.12.20,2000
No preview for this file type
import urllib
import time
from urllib.request import urlopen
from bs4 import BeautifulSoup
from urllib import request
import re
import json
from datetime import datetime
import os
import boto3
import time
import sys
import plotly.offline as py
import plotly.graph_objs as go
import plotly.tools as tls
import matplotlib
from random import shuffle
import numpy as np
import pandas as pd
stockItem = ['285130','309930','307070' ]
for k in range(0,3):
url = 'http://finance.naver.com/item/sise_day.nhn?code='+ stockItem[k]
html = urlopen(url)
source = BeautifulSoup(html.read(), "html.parser")
maxPage=source.find_all("table",align="center")
mp = maxPage[0].find_all("td",class_="pgRR")
mpNum = int(mp[0].a.get('href')[-2:])
date = []
finance = []
df = {}
for page in range(1, mpNum+1):
print (page )
print (mpNum+1)
url = 'http://finance.naver.com/item/sise_day.nhn?code=' + stockItem[k] +'&page='+ str(page)
html = urlopen(url)
source = BeautifulSoup(html.read(), "html.parser")
srlists=source.find_all("tr")
isCheckNone = None
if((page % 1) == 0):
time.sleep(0.1)
for i in range(1,len(srlists)-1):
if(srlists[i].span != isCheckNone):
srlists[i].td.text
date.append(srlists[i].find_all("td",align="center")[0].text)
finance.append(int(srlists[i].find_all("td",class_="num")[0].text.replace(',','')))
if(page == mpNum):
date = np.array(date)
finance = np.array(finance)
df = pd.DataFrame(df)
df["finance"] = finance
df["date"] = date
df.set_index("date", inplace=True, drop=True)
print(df)
df.to_csv("finace_"+stockItem[k]+".csv",encoding = "utf-8")
import numpy as np
import pandas as pd
from bs4 import BeautifulSoup
import urllib
from urllib import request
import re
import json
from datetime import datetime
import os
import boto3
import time
import sys
import plotly.offline as py
import plotly.graph_objs as go
import plotly.tools as tls
import matplotlib
from random import shuffle
py.init_notebook_mode(connected=True)
def upload(s3, local_file_path, bucket, obj):
s3.upload_file(local_file_path,bucket,obj)
def make_public_read(s3,bucket,key):
s3.put_object_acl(ACL="public-read",Bucket=bucket, Key=key)
def download(s3,bucket, obj, local_file_path):
s3.download_file(bucket,obj, local_file_path)
client_id = "sYcWggwUdtmXwGqUrzzN"
client_secret = "oxUqDSa22I"
link = "https://openapi.naver.com/v1/datalab/search"
requested = request.Request(link)
requested.add_header("X-Naver-Client-Id",client_id)
requested.add_header("X-Naver-Client-Secret",client_secret)
requested.add_header("Content-Type","application/json")
df = pd.read_excel("index.xls")
names = df.회사명.values
now = datetime.now().strftime("%Y-%m-%d")
body_dict = {"startDate":"2017-01-01",
"endDate":"2020-05-07",
"timeUnit":"date"}
v_list = [{"groupName" : i, "keywords" : [i]} for i in names]
df["대표자명"] = df["대표자명"].apply(lambda x: re.sub(r'\(.*\)', '', x))
df["대표자명"] = df["대표자명"].apply(lambda x: [re.compile('[^ㄱ-ㅣ가-힣]+').sub("",x)] if len(re.compile('[^ㄱ-ㅣ가-힣]+').sub("",x)) < 5 else re.findall(r"[\w']+", x))
for i in range(0, df.shape[0]):
for j in df["대표자명"].values[i]:
if "대표" not in j and j!= "":
v_list[i]["keywords"].append(j)
shuffle(v_list)
standard = v_list[0]
standard_keyword = standard["groupName"]
list_use = v_list[1:]
split_list = [list_use[i:i+4] for i in range(0, len(list_use), 4)]
for i in split_list:
i.append(standard)
sample_body = body_dict
sample_body["keywordGroups"] = split_list[0]
sample_body = json.dumps(sample_body, ensure_ascii=False)
sample_response = request.urlopen(requested, data=sample_body.encode("utf-8"))
code = sample_response.getcode()
if code == 200:
sample_response_body = sample_response.read()
sample_scraped = sample_response_body.decode("utf-8")
else:
print ("Error Code:", code)
sample_result = json.loads(sample_scraped)
for i in sample_result["results"] :
if i["title"] == standard_keyword:
sample_standard = i["data"]
scale = sample_standard[0]["ratio"]
df = {}
df[standard_keyword] = np.array([i["ratio"] for i in sample_standard])
length = len(df[standard_keyword])
date = np.array([i["period"] for i in sample_standard])
for i in split_list:
body_dict["keywordGroups"] = i
body = json.dumps(body_dict, ensure_ascii=False)
print(i)
response = request.urlopen(requested, data=body.encode("utf-8"))
code = response.getcode()
if code == 200:
response_body = response.read()
scraped = response_body.decode("utf-8")
else:
print ("Error Code:", code)
result = json.loads(scraped)
for i in result["results"]:
if i["title"] == standard_keyword:
compare = i["data"]
compare = compare[0]["ratio"]
scaling = scale/compare
for i in result["results"]:
if i["title"]!=standard_keyword:
value = [j["ratio"]*scaling for j in i["data"]]
if len(value)!=length:
value+=np.abs(length-len(value)) * [value[-1]]
df[i["title"]] = np.array(value)
df = pd.DataFrame(df)
df["date"] = date
df = df.set_index("date")
df.to_csv("trend.xls", encoding = "utf-8")
session = boto3.Session(profile_name = "class")
s3 = session.client("s3")
bucket = 'khu-big-data-ksh'
path = sys.argv[1].replace('\\','/')
filelist = os.listdir(path)
date = time.localtime()
if(path[len(path)-1] != '/'):
path +='/'
year = str(date.tm_year)
month = str(date.tm_mon)
day = str(date.tm_mday)
if(len(month) ==1):
month = '0'+month
if(len(day) ==1):
day = '0'+day
current_date = year+"/"+month+"-"+day
try:
if(sys.argv[3] =='1'):
os.mkdir(path+'downloads/')
except:
print("")
for element in filelist:
if(os.path.isdir(path+element)):
continue
upload(s3, path+element, bucket, current_date+"/"+element)
make_public_read(s3,bucket,current_date+"/"+element)
df.plot(title = "Naver Trend - Stock-Daily", figsize = (20, 10), legend = False)
This diff could not be displayed because it is too large.