Skip to content

Commit

Permalink
Update readme, fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmysitu committed Nov 4, 2023
1 parent 7d1e77e commit a438ba5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 0 additions & 5 deletions example/get_sp500.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
9 changes: 5 additions & 4 deletions msfinance/stocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a438ba5

Please sign in to comment.