Added some docs about using SimpleStockData as a library. Some small refactorings.
This commit is contained in:
parent
273b2010d7
commit
9be1b992e6
37
README.md
37
README.md
@ -55,12 +55,41 @@ pip3 install numpy pandas yfinance requests lxml
|
||||
|
||||
## 2. Usage
|
||||
|
||||
### 2.1 If used as a CLI:
|
||||
|
||||
### 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
|
||||
|
||||
### 2.2 If used as a Module in Python (via `import`):
|
||||
TODO;
|
||||
|
||||
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
|
||||
|
@ -2,7 +2,7 @@ import yfinance as yf
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class SimpleStockData:
|
||||
class SSD:
|
||||
def __init__(self, ticker_list: list, period_start: str, period_end: str, to_currency: str, ohcl: str = "Close"):
|
||||
"""
|
||||
:param period_start:
|
||||
|
@ -1,6 +1,6 @@
|
||||
from SimpleStockData import SimpleStockData
|
||||
from SimpleStockData import SSD
|
||||
|
||||
ssd = SimpleStockData(["RHM.DE", "BAS.DE", "AZN.L"], "2024-01-02", "2024-01-18", "EUR")
|
||||
ssd = SSD(["RHM.DE", "BAS.DE", "AZN.L"], "2024-01-02", "2024-01-18", "EUR")
|
||||
|
||||
print(ssd.get_info(0))
|
||||
print(ssd.get_history(0))
|
Loading…
Reference in New Issue
Block a user