knox / yfinance-10.py
0 likes
0 forks
1 files
Last active
1 | import requests_cache |
2 | session = requests_cache.CachedSession('yfinance.cache') |
3 | session.headers['User-agent'] = 'my-program/1.0' |
4 | ticker = yf.Ticker('msft', session=session) |
5 | # The scraped response will be stored in the cache |
6 | ticker.actions |
knox / yfinance-9.py
0 likes
0 forks
1 files
Last active
1 | import yfinance as yf |
2 | |
3 | # Ticker to Sector and Industry |
4 | msft = yf.Ticker('MSFT') |
5 | tech = yf.Sector(msft.info.get('sectorKey')) |
6 | software = yf.Industry(msft.info.get('industryKey')) |
7 | |
8 | # Sector and Industry to Ticker |
9 | tech_ticker = tech.ticker |
10 | tech_ticker.info |
knox / yfinance-8.py
0 likes
0 forks
1 files
Last active
1 | import yfinance as yf |
2 | |
3 | tech = yf.Sector('technology') |
4 | software = yf.Industry('software-infrastructure') |
5 | |
6 | # Common information |
7 | tech.key |
8 | tech.name |
9 | tech.symbol |
10 | tech.ticker |
knox / yfinance-7.py
0 likes
0 forks
1 files
Last active
1 | import yfinance as yf |
2 | data = yf.download("SPY AAPL", period="1mo") |
knox / yfinance-6.py
0 likes
0 forks
1 files
Last active
1 | import yfinance as yf |
2 | |
3 | tickers = yf.Tickers('msft aapl goog') |
4 | |
5 | # access each ticker using (example) |
6 | tickers.tickers['MSFT'].info |
7 | tickers.tickers['AAPL'].history(period="1mo") |
8 | tickers.tickers['GOOG'].actions |
knox / yfinance-5.py
0 likes
0 forks
1 files
Last active
1 | import yfinance as yf |
2 | |
3 | msft = yf.Ticker("MSFT") |
4 | |
5 | msft.history(..., proxy="PROXY_SERVER") |
6 | msft.get_actions(proxy="PROXY_SERVER") |
7 | msft.get_dividends(proxy="PROXY_SERVER") |
8 | msft.get_splits(proxy="PROXY_SERVER") |
9 | msft.get_capital_gains(proxy="PROXY_SERVER") |
10 | msft.get_balance_sheet(proxy="PROXY_SERVER") |
knox / yfinance-4.py
0 likes
0 forks
1 files
Last active
1 | import yfinance as yf |
2 | spy = yf.Ticker('SPY') |
3 | data = spy.funds_data |
4 | |
5 | # show fund description |
6 | data.description |
7 | |
8 | # show operational information |
9 | data.fund_overview |
10 | data.fund_operations |
knox / yfinance-3.py
0 likes
0 forks
1 files
Last active
1 | import yfinance as yf |
2 | |
3 | msft = yf.Ticker("MSFT") |
4 | |
5 | # get all stock info |
6 | msft.info |
7 | |
8 | # get historical market data |
9 | hist = msft.history(period="1mo") |
knox / yfinance-2.sh
0 likes
0 forks
1 files
Last active
1 | $ pip install "yfinance[optional]" |
knox / yfinance-1.sh
0 likes
0 forks
1 files
Last active
1 | $ pip install yfinance --upgrade --no-cache-dir |