Skip to content

Instantly share code, notes, and snippets.

@skynettw
Created January 4, 2018 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skynettw/062c6b9f94d2a0918994d5161f4049c3 to your computer and use it in GitHub Desktop.
Save skynettw/062c6b9f94d2a0918994d5161f4049c3 to your computer and use it in GitHub Desktop.
%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