10

I am trying to find stock data to practice with, is there a good resource for this? I found this but it only has the current year.

I already have a way of parsing the protocol, but would like to have some more data to compare with. It doesn't have to be in the same format, as long as it has price, trades, and date statistics.

Zephyr
  • 997
  • 4
  • 10
  • 20
Marin
  • 103
  • 5

3 Answers3

7

You can pull stock data very easyly in python and R (probably other languages as well) with the following packages:

In python with ystockquote

This is also a really nice tutorial in iPython which shows you how to pull the stock data and play with it

In R with quantmod

HTH.

Zephyr
  • 997
  • 4
  • 10
  • 20
mike1886
  • 933
  • 9
  • 17
2

There are multiple platforms (like quandl, iex, yahoo) that provide such data and pandas_datareader gives you even better interface to collect data from these platforms.

Check out this blog for a quick example.

Toros91
  • 2,392
  • 3
  • 15
  • 32
Kyle
  • 121
  • 2
1

A lot of data providers have been disabled over time. This one still works

import datetime
import pandas as pd
import numpy as np
import pylab as pl
import datetime
from sklearn.cluster import AffinityPropagation
from sklearn import metrics
from matplotlib.collections import LineCollection
from pandas_datareader import data as wb
from sklearn import cluster, covariance, manifold


start = '2019-02-01'
end = '2020-02-01'

tickers = ['MMM',
'ABT',
'ABBV',
'ABMD',
'ACN',
'ATVI']

thelen = len(tickers)

price_data = []
for ticker in tickers:
    prices = wb.DataReader(ticker, start = start, end = end, data_source='yahoo')[['Open','Adj Close']]
    price_data.append(prices.assign(ticker=ticker)[['ticker', 'Open', 'Adj Close']])

#names = np.reshape(price_data, (len(price_data), 1))

names = pd.concat(price_data)
names.reset_index()
ASH
  • 615
  • 3
  • 9