Created
September 13, 2019 03:59
-
-
Save why-not/51084838fa3e1ff8d16a68af8e11f907 to your computer and use it in GitHub Desktop.
pandas data reader for stock data.
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
# command to install this library. | |
# conda install pandas-datareader | |
# example 1 | |
import pandas_datareader as pdr | |
tsla = pdr.DataReader('tsla', data_source='google', start='2017-1-1') | |
# example 2 | |
# calculates the trailing stop order price, can be used for weight loss like time series as well. | |
# Cumulative functions are nice. | |
def set_trailing_loss(symbol, purchase_date, perc): | |
close = pdr.DataReader(symbol, 'google', start=purchase_date)['Close'] | |
return close.cummax() * perc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment