Comments (4)
http://francescopochetti.com/scrapying-around-web/
http://francescopochetti.com/pythonic-cross-validation-time-series-pandas-scikit-learn/
http://francescopochetti.com/stock-market-prediction-part-introduction/
def getStock(symbol, start, end):
"""
Downloads Stock from Yahoo Finance.
Computes daily Returns based on Adj Close.
Returns pandas dataframe.
"""
df = web.DataReader(symbol, 'yahoo',start, end)
df.columns.values[-1] = 'AdjClose'
df.columns = df.columns + '_' + symbol
df['Return_%s' %symbol] = df['AdjClose_%s' %symbol].pct_change()
return df
def getStockFromQuandl(symbol, name, start, end):
"""
Downloads Stock from Quandl.
Computes daily Returns based on Adj Close.
Returns pandas dataframe.
"""
import Quandl
df = Quandl.get(symbol, trim_start = start, trim_end = end, authtoken="your token")
df.columns.values[-1] = 'AdjClose'
df.columns = df.columns + '_' + name
df['Return_%s' %name] = df['AdjClose_%s' %name].pct_change()
return df
def getStockDataFromWeb(fout, start_string, end_string):
"""
Collects predictors data from Yahoo Finance and Quandl.
Returns a list of dataframes.
"""
start = parser.parse(start_string)
end = parser.parse(end_string)
nasdaq = getStock('^IXIC', start, end)
frankfurt = getStock('^GDAXI', start, end)
london = getStock('^FTSE', start, end)
paris = getStock('^FCHI', start, end)
hkong = getStock('^HSI', start, end)
nikkei = getStock('^N225', start, end)
australia = getStock('^AXJO', start, end)
djia = getStockFromQuandl("YAHOO/INDEX_DJI", 'Djia', start_string, end_string)
out = pd.io.data.get_data_yahoo(fout, start, end)
out.columns.values[-1] = 'AdjClose'
out.columns = out.columns + '_Out'
out['Return_Out'] = out['AdjClose_Out'].pct_change()
return [out, nasdaq, djia, frankfurt, london, paris, hkong, nikkei, australia]
from alphapy.
Thank you. We'll test this out and add Quandl as a data source as well.
from alphapy.
Google Finance URL is acting flaky, even for daily data. Unfortunately, all free sources of financial data are disappearing.
from alphapy.
Please refer to #15.
from alphapy.
Related Issues (20)
- Error in Binary Encoding
- IEX Cloud Migration HOT 3
- Model.yml encoding error HOT 3
- AttributeError: type object 'DataFrame' has no attribute 'from_items' HOT 2
- ValueError: max() arg is an empty sequence and NameError: name 'search_path' is not defined HOT 1
- Transforms Dictionary Error HOT 1
- ValueError: model.yml features:encoding:type target unrecognized HOT 21
- Can't get --predict working HOT 3
- features.py get_text_features pandas 1x support HOT 2
- Features Generation BugFixes HOT 1
- variables.vexec inconsistent with docs HOT 2
- Support Multiple Systems HOT 1
- Trading System phigh/plow etc HOT 2
- Error in importing BalanceCascade from imblearn.ensemble HOT 4
- Error During save_predictions HOT 2
- Error while Trading Model example running HOT 1
- Error while making a prediction with sflow
- Index out of range when running sportflow
- How to use saved model HOT 1
- How to adapt custom market datasource (another market)? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alphapy.