Skip to content

Commit

Permalink
version 0.9 push
Browse files Browse the repository at this point in the history
  • Loading branch information
JECSand committed Aug 14, 2018
1 parent d3eebd7 commit 1d906cf
Show file tree
Hide file tree
Showing 4 changed files with 306 additions and 62 deletions.
4 changes: 3 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
0.1, 10/13/2017 -- Initial release.
0.1 10/13/2017 -- Initial release.
0.2 10/20/2017 -- Added New Methods and Restructured Module Classes
0.3 10/25/2017 -- Added New Methods and Calculated Measures
0.4 03/06/2018 -- Fixed reported bug on line 470 of init.py by adding a try and except with suggested line of code.
Expand All @@ -9,3 +9,5 @@
0.7 08/03/2018 -- Added 10 new income statement history methods beginning at line 567.
0.7 08/03/2018 -- Added a fix for trevorwelch's open issue involving the unnecessary sys.exit(1) on line 286 by replacing it with return None.
0.8 08/11/2018 -- Added a new method to get the current day's shares outstanding called get_num_shares_outstanding() starting on line 617.
0.9 08/14/2018 -- Added a new method called get_historical_price_data() to get price data for commodity futures, indexes, currencies, and cryptos in addition to stocks.
0.9 08/14/2018 -- Depreciated the get_historical_stock_data() method and scheduled it's removal for version 1.0.
205 changes: 168 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# yahoofinancials
Welcome to Yahoo Financials!

Current Version: v0.8

Version Released: 08/11/2018
Current Version: v0.9

Version Released: 08/14/2018

New Contributers Welcomed!

Email [email protected] with YAHOOFINANCIALS-{Your-Name} as email title if interested.

## Overview
A powerful financial data module used for pulling both fundamental and technical stock data from Yahoo Finance.
The module uses a web scraping technique for retrieving the data, thus eliminating the need for the now discontinued Yahoo Finance API.
A powerful financial data module used for pulling both fundamental and technical data from Yahoo Finance.
* As of Version 0.9, Yahoo Financials now returns historical pricing data for commodity futures, cryptocurrencies, currencies, indexes, and stocks.


## Installation
* yahoofinancials runs fine on most versions of python 2 and 3.
* It was built and tested using versions 2.7 and 3.4
* the package depends on beautifulsoup4 and requests to work
* The package depends on beautifulsoup4 and requests to work.

1. Installation using pip:
* Linux/Mac:
Expand All @@ -44,8 +44,8 @@ $ python demo.py WFC C BAC

## Module Methods
* The financial data from all methods is returned as JSON.
* You can run multiple stocks at once using an inputted array or run an individual stock using an inputted string.
* YahooFinancials works on most versions of python 2 and 3 and runs on all operating systems. (Windows, Mac, Linux)
* You can run multiple symbols at once using an inputted array or run an individual symbol using an inputted string.
* YahooFinancials works on most versions of python 2 and 3 and runs on all operating systems. (Windows, Mac, Linux).

### Featured Methods
1. get_financial_stmts(frequency, statement_type, reformat=True)
Expand All @@ -59,14 +59,19 @@ $ python demo.py WFC C BAC
4. get_stock_summary_data(reformat=True)
* reformat optional value defaulted to true. Enter False for unprocessed raw data from Yahoo Finance.
5. get_stock_quote_type_data()
6. get_historical_stock_data(start_date, end_date, time_interval)
* start_date should be entered in the 'YYYY-MM-DD' format. First day that stock data will be pulled.
* end_date should be entered in the 'YYYY-MM-DD' format. Last day that stock data will be pulled.
* time_interval can be either 'daily', 'weekly', or 'monthly'. Parameter determines the time period interval.
6. get_historical_price_data(start_date, end_date, time_interval)
* New in v0.9.
* This method will pull historical pricing data for stocks, currencies, cryptocurrencies, commodities, and indexes.
* start_date should be entered in the 'YYYY-MM-DD' format and is the first day that data will be pulled for.
* end_date should be entered in the 'YYYY-MM-DD' format and is the last day that data will be pulled for.
* time_interval can be either 'daily', 'weekly', or 'monthly'. This variable determines the time period interval for your pull.
* Data response includes relevant pricing event data such as dividends and stock splits.
7. get_num_shares_outstanding(price_type='current'):
* price_type can also be set to 'average' to calculate the shares outstanding with the daily average price.

### New Module Method Added in v0.8
* get_num_shares_outstanding(price_type='current'):
- price_type can also be set to 'average' to calculate the shares outstanding with the daily average price.
### Methods Depreciated in v0.9
* get_historical_stock_data():
- Scheduled for removal in v1.0

### Additional Module Methods
* get_interest_expense():
Expand Down Expand Up @@ -113,8 +118,8 @@ $ python demo.py WFC C BAC

## Usage Examples
* The class constructor can take either a single ticker or a list of tickers as it's parameter.
* This makes it easy to construct multiple classes for different groupings of stocks
* Quarterly statement data returns the last 4 periods of data, while annual returns the past 3.
* This makes it easy to initiate multiple classes for different groupings of financial assets.
* Quarterly statement data returns the last 4 periods of data, while annual returns the last 3.

### Single Ticker Example
```R
Expand All @@ -128,7 +133,7 @@ income_statement_data_qt = yahoo_financials.get_financial_stmts('quarterly', 'in
all_statement_data_qt = yahoo_financials.get_financial_stmts('quarterly', ['income', 'cash', 'balance'])
apple_earnings_data = yahoo_financials.get_stock_earnings_data()
apple_net_income = yahoo_financials.get_net_income()
historical_stock_prices = yahoo_financials.get_historical_stock_data('2015-01-15', '2017-10-15', 'weekly')
historical_stock_prices = yahoo_financials.get_historical_price_data('2015-01-15', '2017-10-15', 'weekly')
```

### Lists of Tickers Example
Expand All @@ -137,16 +142,25 @@ from yahoofinancials import YahooFinancials

tech_stocks = ['AAPL', 'MSFT', 'INTC']
bank_stocks = ['WFC', 'BAC', 'C']
commodity_futures = ['GC=F', 'SI=F', 'CL=F']
cryptocurrencies = ['BTC-USD', 'ETH-USD', 'XRP-USD']
currencies = ['EURUSD=X', 'JPY=X', 'GBPUSD=X']

yahoo_financials_tech = YahooFinancials(tech_stocks)
yahoo_financials_banks = YahooFinancials(bank_stocks)
yahoo_financials_commodities = YahooFinancials(commodity_futures)
yahoo_financials_cryptocurrencies = YahooFinancials(cryptocurrencies)
yahoo_financials_currencies = YahooFinancials(currencies)

tech_cash_flow_data_an = yahoo_financials_tech.get_financial_stmts('annual', 'cash')
bank_cash_flow_data_an = yahoo_financials_banks.get_financial_stmts('annual', 'cash')

banks_net_ebit = yahoo_financials_banks.get_ebit()
tech_stock_price_data = tech_cash_flow_data.get_stock_price_data()
daily_bank_stock_prices = yahoo_financials_banks.get_historical_stock_data('2008-09-15', '2017-09-15', 'daily')
tech_stock_price_data = yahoo_financials_tech.get_stock_price_data()
daily_bank_stock_prices = yahoo_financials_banks.get_historical_price_data('2008-09-15', '2017-09-15', 'daily')
daily_commodity_prices = yahoo_financials_commodities.get_historical_price_data('2008-09-15', '2017-09-15', 'daily')
daily_crypto_prices = yahoo_financials_cryptocurrencies.get_historical_price_data('2008-09-15', '2017-09-15', 'daily')
daily_currency_prices = yahoo_financials_currencies.get_historical_price_data('2008-09-15', '2017-09-15', 'daily')
```

## Examples of Returned JSON Data
Expand Down Expand Up @@ -265,40 +279,157 @@ print(yahoo_financials.get_financial_stmts('quarterly', 'cash'))
}
}
```
4. Monthly Stock Price History Data for Wells Fargo:
4. Monthly Historical Stock Price Data for Wells Fargo:
```R
yahoo_financials = YahooFinancials('WFC')
print(yahoo_financials.get_historical_stock_data("2017-09-10", "2017-10-10", "monthly"))
print(yahoo_financials.get_historical_price_data("2018-07-10", "2018-08-10", "monthly"))
```
```javascript
{
"WFC": {
"prices": [
{
"volume": 260271600,
"formatted_date": "2017-09-30",
"high": 55.77000045776367,
"adjclose": 54.91999816894531,
"low": 52.84000015258789,
"date": 1506830400,
"close": 54.91999816894531,
"open": 55.15999984741211
"currency": "USD",
"eventsData": {
"dividends": {
"2018-08-01": {
"amount": 0.43,
"date": 1533821400,
"formatted_date": "2018-08-09"
}
}
],
"eventsData": [],
},
"firstTradeDate": {
"date": 76233600,
"formatted_date": "1972-06-01"
},
"isPending": false,
"instrumentType": "EQUITY",
"prices": [
{
"adjclose": 57.19147872924805,
"close": 57.61000061035156,
"date": 1533096000,
"formatted_date": "2018-08-01",
"high": 59.5,
"low": 57.08000183105469,
"open": 57.959999084472656,
"volume": 138922900
}
],
"timeZone": {
"gmtOffset": -14400
}
}
}
```
5. Monthly Historical Price Data for EURUSD:
```R
yahoo_financials = YahooFinancials('EURUSD=X')
print(yahoo_financials.get_historical_price_data("2018-07-10", "2018-08-10", "monthly"))
```
```javascript
{
"EURUSD=X": {
"currency": "USD",
"eventsData": {},
"firstTradeDate": {
"date": 1070236800,
"formatted_date": "2003-12-01"
},
"instrumentType": "CURRENCY",
"prices": [
{
"adjclose": 1.1394712924957275,
"close": 1.1394712924957275,
"date": 1533078000,
"formatted_date": "2018-07-31",
"high": 1.169864296913147,
"low": 1.1365960836410522,
"open": 1.168961763381958,
"volume": 0
}
],
"timeZone": {
"gmtOffset": 3600
}
}
}
```
6. Monthly Historical Price Data for BTC-USD:
```R
yahoo_financials = YahooFinancials('BTC-USD')
print(yahoo_financials.get_historical_price_data("2018-07-10", "2018-08-10", "monthly"))
```
```javascript
{
"BTC-USD": {
"currency": "USD",
"eventsData": {},
"firstTradeDate": {
"date": 1279321200,
"formatted_date": "2010-07-16"
},
"id": "1mo15050196001507611600"
"instrumentType": "CRYPTOCURRENCY",
"prices": [
{
"adjclose": 6285.02001953125,
"close": 6285.02001953125,
"date": 1533078000,
"formatted_date": "2018-07-31",
"high": 7760.740234375,
"low": 6133.02978515625,
"open": 7736.25,
"volume": 4334347882
}
],
"timeZone": {
"gmtOffset": 3600
}
}
}
```
7. Weekly Historical Price Data for Crude Oil Futures:
```R
yahoo_financials = YahooFinancials('CL=F')
print(yahoo_financials.get_historical_price_data("2018-08-01", "2018-08-10", "weekly"))
```
```javascript
{
"CL=F": {
"currency": "USD",
"eventsData": {},
"firstTradeDate": {
"date": 1522555200,
"formatted_date": "2018-04-01"
},
"instrumentType": "FUTURE",
"prices": [
{
"adjclose": 68.58999633789062,
"close": 68.58999633789062,
"date": 1532923200,
"formatted_date": "2018-07-30",
"high": 69.3499984741211,
"low": 66.91999816894531,
"open": 68.37000274658203,
"volume": 683048039
},
{
"adjclose": 67.75,
"close": 67.75,
"date": 1533528000,
"formatted_date": "2018-08-06",
"high": 69.91999816894531,
"low": 66.13999938964844,
"open": 68.76000213623047,
"volume": 1102357981
}
],
"timeZone": {
"gmtOffset": -14400
}
}
}
```
5. Apple Stock Quote Data:
8. Apple Stock Quote Data:
```R
yahoo_financials = YahooFinancials('AAPL')
print(yahoo_financials.get_stock_quote_type_data())
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

setup(
name='yahoofinancials',
version='0.8',
description='A powerful financial data module used for pulling fundamental and technical stock data from Yahoo Finance',
version='0.9',
description='A powerful financial data module used for pulling both fundamental and technical data from Yahoo Finance',
url='https://github.com/JECSand/yahoofinancials',
download_url='https://github.com/JECSand/yahoofinancials/archive/0.8.tar.gz',
download_url='https://github.com/JECSand/yahoofinancials/archive/0.9.tar.gz',
author='Connor Sanders',
author_email='[email protected]',
license='MIT',
keywords = ['finance data', 'stocks', 'yahoo finance'],
keywords = ['finance data', 'stocks', 'commodities', 'cryptocurrencies', 'currencies', 'forex', 'yahoo finance'],
packages=['yahoofinancials'],
install_requires=[
"requests",
Expand Down
Loading

0 comments on commit 1d906cf

Please sign in to comment.