forked from ranaroussi/yfinance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtest.py
42 lines (32 loc) · 1.04 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
#!/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():
for symbol in ['MSFT', 'IWO', 'VFINX', '^GSPC', 'BTC-USD']:
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
ticker.cashflow
ticker.balance_sheet
ticker.financials
ticker.sustainability
ticker.major_holders
ticker.institutional_holders
print("OK")
if __name__ == "__main__":
test_yfinance()