106 lines
3.9 KiB
Markdown
Executable File
106 lines
3.9 KiB
Markdown
Executable File
# SimpleStockData
|
||
|
||
SimpleStockData is a wrapper around the yfinance library providing very easy, high-level
|
||
access to the yahoo finance data. It does NOT WRAP all features of yfinance, as this
|
||
would obviously make the whole thing unnecessary. It only provides very basic functionality,
|
||
which is:
|
||
|
||
1. Grap the history of a specific stock
|
||
2. Select a specific period of time
|
||
3. Directly convert the data to another currency¹
|
||
4. CLI and library accessibility
|
||
|
||
That's pretty much all. And all this just very convenient.
|
||
|
||
–––––––<br>
|
||
¹ for example, the given stocks are in different currencies, and you want all of your stocks
|
||
be written to your diagram in the same currency
|
||
|
||
|
||
## 0. Legal Disclaimer
|
||
*** IMPORTANT LEGAL DISCLAIMER ***
|
||
|
||
Yahoo!, Y!Finance, and Yahoo! finance are registered trademarks of Yahoo, Inc.
|
||
|
||
SimpleStockData is not affiliated, endorsed, or vetted by Yahoo, Inc. It's an open-source tool that uses Yahoo's publicly available APIs, and is intended for research and educational purposes.
|
||
|
||
You should refer to Yahoo!'s terms of use ([here](https://policies.yahoo.com/us/en/yahoo/terms/product-atos/apiforydn/index.htm), [here](https://legal.yahoo.com/us/en/yahoo/terms/otos/index.html) and [here](https://policies.yahoo.com/us/en/yahoo/terms/index.htm)) for details on your rights to use the actual data downloaded. Remember - the Yahoo! finance API is intended for personal use only.
|
||
|
||
[[see also]](https://pypi.org/project/yfinance/)
|
||
## 1. Installation
|
||
|
||
### 1.1 Requirements
|
||
|
||
Python >= 2.7, 3.4+
|
||
Pandas >= 1.3.0
|
||
Numpy >= 1.16.5
|
||
requests >= 2.31
|
||
lxml >= 4.9.1
|
||
appdirs >= 1.4.4
|
||
pytz >=2022.5
|
||
frozendict >= 2.3.4
|
||
beautifulsoup4 >= 4.11.1
|
||
html5lib >= 1.1
|
||
peewee >= 3.16.2
|
||
|
||
Requirements from yfinance
|
||
[[see also]](https://pypi.org/project/yfinance/)
|
||
|
||
### 1.2 Installing these
|
||
To get started using the library, the pip packages named in 1.1 have to be
|
||
installed. To do this, type in the following:
|
||
```shell
|
||
pip3 install numpy pandas yfinance requests lxml
|
||
```
|
||
|
||
## 2. Usage
|
||
|
||
|
||
### 2.1 If used as a Module in Python (via `import`):
|
||
|
||
If used as a module, all you have to do to access every share you own is
|
||
typing this:
|
||
|
||
```python
|
||
from SimpleStockData import SSD
|
||
ssd1 = SSD(["EXAMPLE", "ANOTHER TICKER", "..."], "2011-11-11", "2022-02-22", "USD", "Close")
|
||
ssd2 = SSD(["EXAMPLE", "ANOTHER TICKER", "..."], "2011-11-11", "2022-02-22", "USD") # also working
|
||
ssd3 = SSD(ticker_list = ["EXAMPLE", "ANOTHER TICKER", "..."], period_start="2011-11-11",
|
||
period_end="2022-02-22", to_currency="USD", ohcl="Close") # again working
|
||
```
|
||
|
||
where...
|
||
|
||
- `["EXAMPLE", "ANOTHER TICKER", "..."]` is a list of Ticker names (from Yahoo! finance)
|
||
- `2011-11-11` is the start date when accessing price history
|
||
- `2022-02-22` is the end date when accessing price history
|
||
- `USD` is the currency to convert to, later, when dumping history
|
||
- `Close` is **optional**. It specifies which price should be taken per day.<br>
|
||
Valid values are: `High`, `Low`, `Open`, `Close`
|
||
|
||
Then you can access the history of the stock just by calling the methods `get_info(index, [key]`
|
||
and `get_history(index, [interval="1d"], [convert=True]`.
|
||
|
||
It's just that easy.
|
||
|
||
---
|
||
For more details, look into the [examples](examples) folder at this project's root.
|
||
|
||
### 2.2 If used as a CLI:
|
||
TODO; also mention the strange but working GBp thing
|
||
|
||
This feature is currently in progress and will soon be available.
|
||
|
||
## 3. Thanks to
|
||
- [yfinance](https://pypi.org/project/yfinance/) - the library used in the background
|
||
to get stock prices and exchange rates from Yahoo Finance.
|
||
|
||
- [Pandas](https://pypi.org/project/pandas/) - the powerful Python data analysis toolkit
|
||
|
||
- [Numpy](https://pypi.org/project/numpy/) - used in combination with pandas for
|
||
precise calculations
|
||
|
||
|
||
## 4. License (Unlicense)
|
||
|
||
SimpleStockData is licensed under GPLv3, a copy of it can be found in LICENSE.md. |