forked from ranaroussi/yfinance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntest.py
44 lines (34 loc) · 1.41 KB
/
runtest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
# Yahoo! Finance market data downloader (+fix for Pandas Datareader)
# https://github.com/ranaroussi/yfinance
"""
Sanity check for most common library uses all working
- Stock: Microsoft
- ETF: Russell 2000 Growth
- Mutual fund: Vanguard 500 Index fund
- Index: S&P500
- Currency BTC-USD
"""
from __future__ import print_function
import yfinance as yf
def test_yfinance():
#symbol_list = ['MSFT', 'IWO', 'VFINX', '^GSPC', 'BTC-USD']
symbol_list = ['MSFT']
for symbol in symbol_list:
print(">>", symbol, end=' ... ')
ticker = yf.Ticker(symbol)
# always should have info and history for valid symbols
assert(ticker.info is not None and ticker.info != {})
assert(ticker.history(period="max").empty is False)
# following should always gracefully handled, no crashes
print('==================cashflow===============\n',ticker.cashflow)
print('===============balance_sheet=============\n',ticker.balance_sheet)
print('=================financials==============\n',ticker.financials)
print('===============sustainability============\n',ticker.sustainability)
print('===============marjor_holders============\n',ticker.major_holders)
print('==========institutional_holders==========\n',ticker.institutional_holders)
print("OK")
if __name__ == "__main__":
test_yfinance()