This repository has been archived by the owner on Feb 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3ec79d
commit 34d1c23
Showing
1 changed file
with
8 additions
and
18 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,16 @@ | ||
financial_fundamentals | ||
====================== | ||
|
||
Cache prices from yahoo and accounting metrics from SEC filings. | ||
Find XBRL filings on the SEC's edgar and extract accounting metrics. | ||
See the blog @ [http://andrewonfinance.blogspot.com/](http://andrewonfinance.blogspot.com/). | ||
Caching is provided by my vector_cache package, https:/andrewkittredge/vector_cache. | ||
|
||
|
||
import pytz | ||
import datetime | ||
import pandas as pd | ||
import financial_fundamentals as ff | ||
from financial_fundamentals.accounting_metrics import EPS | ||
from financial_fundamentals.indicies import DOW_TICKERS | ||
|
||
|
||
start = datetime.datetime(2009, 1, 1, tzinfo=pytz.UTC) | ||
end = datetime.datetime(2013, 11, 26, tzinfo=pytz.UTC) | ||
eps_cache = ff.sqlite_fundamentals_cache(metric=EPS.quarterly()) | ||
price_cache = ff.sqlite_price_cache() | ||
args = {'stocks' : ['GOOG', 'YHOO', 'MSFT', 'IBM'], 'start' : start, 'end' : end} | ||
|
||
# The first load_from_cache calls will take a long time as data is downloaded from | ||
# yahoo and edgar.sec.gov, thereafter data will be loaded from cache. | ||
earnings_per_share = eps_cache.load_from_cache(**args) | ||
price = price_cache.load_from_cache(**args) | ||
price_to_earnings = price / (earnings_per_share * 4) | ||
price_to_earnings.plot() | ||
date_range = pd.date_range('2012-1-1', '2013-12-31') | ||
required_data = pd.DataFrame(columns=['MSFT', 'GOOG', 'YHOO', 'IBM'], index=date_range) | ||
|
||
eps = ff.accounting_metrics.earnings_per_share(required_data) | ||
print eps |