Created
January 4, 2018 17:08
-
-
Save skynettw/062c6b9f94d2a0918994d5161f4049c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%matplotlib inline | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
url="http://www.twse.com.tw/indicesReport/MI_5MINS_HIST?response=csv&date=20170101" | |
stocks = pd.read_csv(url, encoding='big5', skiprows=1, thousands=',') | |
stocks = stocks.drop(stocks.columns[5], axis=1) | |
stocks.columns = ['Date', 'Open', 'High', 'Low', 'Close'] | |
stocks = stocks.set_index('Date') | |
for i in range(2,13): | |
url="http://www.twse.com.tw/indicesReport/MI_5MINS_HIST?response=csv&date=2017{:02}01".format(i) | |
stock = pd.read_csv(url, encoding='big5', skiprows=1, thousands=',') | |
stock = stock.drop(stock.columns[5], axis=1) | |
stock.columns = ['Date', 'Open', 'High', 'Low', 'Close'] | |
stock = stock.set_index('Date') | |
stocks = pd.concat([stocks,stock]) | |
stocks.plot() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment