diff --git a/README.md b/README.md index 4a91cfe..b596fdb 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,50 @@ # msfinance msfinance offers Pythonic way to download stocks financial data from [morningstar.com/stocks](https://www.morningstar.com/stocks) +![PyPI - Python Version](https://img.shields.io/pypi/pyversions/msfinance) +![PyPI - Version](https://img.shields.io/pypi/v/msfinance) +![PyPI - Downloads](https://img.shields.io/pypi/dm/msfinance) + + +## Install +```bash +pip install msfinance +``` + +## Quick Start +```python +#!/usr/bin/python3 -u +import msfinance as msf + +stock = msf.Stock( + session='msf_database.sql3', +) + + +print(stock.get_income_statement('aapl', 'xnas')) +print(stock.get_balance_sheet_statement('aapl', 'xnas')) +print(stock.get_cash_flow_statement('aapl', 'xnas')) + +print(stock.get_growth('aapl', 'xnas')) +print(stock.get_operating_and_efficiency('aapl', 'xnas')) +print(stock.get_financial_health('aapl', 'xnas')) +print(stock.get_cash_flow('aapl', 'xnas')) +``` +- More example is placed in [example](https://github.com/jimmysitu/msfinance/tree/main/example) directory + ## US Tickers and Exchanges - Get all tickers symbol of each exchange [here](https://www.nasdaq.com/market-activity/stocks/screener) ## HK Tickers and Exchanges - +- TBD ## TODO - [x] Add 'Last Updated' to database record - [ ] Add docs in docs directory for readthedoc.io -- [ ] Add setup.py for pip package +- [x] Add support for pip package - [ ] Add multiprocessing for speed up - [ ] More robust error handling - [ ] Add tickers from HK exchanges diff --git a/example/get_sp500.py b/example/get_sp500.py index a60d7e5..c66f378 100755 --- a/example/get_sp500.py +++ b/example/get_sp500.py @@ -1,12 +1,7 @@ #!/usr/bin/python3 -u -import pandas as pd -import os - import msfinance as msf - - proxy = 'socks5://127.0.0.1:1088' stock = msf.Stock( diff --git a/msfinance/stocks.py b/msfinance/stocks.py index 2e9cfa6..cb955f8 100644 --- a/msfinance/stocks.py +++ b/msfinance/stocks.py @@ -40,6 +40,7 @@ class StockBase: def __init__(self, debug=False, browser='firefox', session='/tmp/msfinance/msfinance.db', proxy=None): self.debug = debug if('chrome' == browser): + # TODO: Add chrome support pass else: # Default: firefox @@ -134,7 +135,7 @@ def _check_database(self, unique_id): else: return None - def _upgate_database(self, unique_id, df): + def _update_database(self, unique_id, df): ''' Update database with unique_id as table name, using DataFrame format data. Add 'Last Updated' column to each record @@ -198,7 +199,7 @@ def _get_valuation(self, ticker, exchange, statistics, update=False): # Update database df = pd.read_excel(statistics_file) if self.db: - self._upgate_database(unique_id, df) + self._update_database(unique_id, df) return df @@ -278,7 +279,7 @@ def _get_financials(self, ticker, exchange, statement, period='Annual', stage='A # Update datebase df = pd.read_excel(statement_file) if self.db: - self._upgate_database(unique_id, df) + self._update_database(unique_id, df) return df @@ -306,7 +307,7 @@ def _get_us_exchange_tickers(self, exchange, update=False): # Update datebase if self.db: - self._upgate_database(unique_id, df) + self._update_database(unique_id, df) symbols = df['symbol'].tolist() return symbols