examples | ||
LICENSE.md | ||
README.md | ||
SimpleStockData.py |
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:
- Grap the history of a specific stock
- Select a specific period of time (via parameters
start
andend
) - Directly convert the data to another currency¹
- CLI and library accessibility
That's pretty much all. And all this just very convenient.
–––––––
¹ 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, here and here) for details on your rights to use the actual data downloaded. Remember - the Yahoo! finance API is intended for personal use only.
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]
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:
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:
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 history2022-02-22
is the end date when accessing price historyUSD
is the currency to convert to, later, when dumping historyClose
is optional. It specifies which price should be taken per day.
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 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 - the library used in the background to get stock prices and exchange rates from Yahoo Finance.
-
Pandas - the powerful Python data analysis toolkit
-
Numpy - used in combination with pandas for precise calculations
4. License (Unlicense)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>