semvec/pypi-packages huggingface dataset:
stfm 0.1.2
Wrapper for STFM API
Requires Python: >=3.6

# STFM

`stfm` is a wrapper for STFM API, publicly accessible [here](https://www.financialresearch.gov/short-term-funding-monitor/api-specs/api-info-query/).

STFM (Short-term Funding Monitor) is a data product provided by the Office of Financial Research, Department of Treasury. 
This data products provides more than 300 data series covering different aspects of short-term funding in the United States of America.

# Installation
You can simply use `pip` to install stfm:

`$ pip install stfm`

# Requirements

* `pandas`
* `requests`
* `urllibs3`

# Usage
Start by importing the package and then creating an instance of the STFM:
```python

from stfm.api import STFM

stfm = STFM()

```
optional parameters are `base_url`, `proxies` and `retries`. 
If you're behind a proxy, set the proxies as a dictionary and pass it to your call to STFM.

`STFM` has 6 functions for accessibn the api:

* [`get_mnemonics`](#get_mnemonics) returns full list of all the available data series.
* [`get_mnemonic`](#get_mnemonic) returns detailed information for a specific data series.
* [`search`](#search) can be used for searching meta data including names.
* [`get_spread`](#get_spread) calculate the spread between two data series.
* `get_disclosure_edits` returns a list of date for which no data provided.

### get_mnemonics
You can get a list of all available mnemonics or 
ask for mnemonics under a specific dataset.

```python
from stfm.api import STFM

stfm = STFM()
all_mnemonics = stfm.get_mnemonics()

repo_mnemonics = stfm.get_mnemonics('repo')

print(
    f"All Mnemonics:\n{all_mnemonics}\nRepo Mnemonics:{repo_mnemonics}"
)
```

### get_mnemonic
This method returns meta data for a specific mnemonic.

```python
from stfm.api import STFM

stfm = STFM()

meta_data = stfm.get_mnemonic('NYPD-PD_RRP_OS_OO-A')

print(meta_data)
```

### search
You can search for any phrase using wildcard characters such as * & ? in all meta data fields.
This method returns a pandas dataframe.

```python
from stfm.api import STFM

stfm = STFM()

df = stfm.search('*Treasury*')
print(df)
```


### get_spread
This method calculates the spread between two mnemonics:

```python
from stfm.api import STFM

stfm = STFM()

spread = stfm.get_spread('NYPD-PD_SL_ABS_GE30-A', 'NYPD-PD_SB_TIPS_OO-A')
print(spread)
```

### get_disclosure_edits
Some of the data points are excluded from output to protect 
business-confidential information. 
This method returns a list of dates that data have been excluded because of disclosure edits.

```python
from stfm.api import STFM

stfm = STFM()

disclosure_edits = stfm.get_disclosure_edits('NYPD-PD_SL_T_L30-A')

```

# Maintainer
This package is developed and maintained by Mehdi Zare. You can reach him on his LinkedIn profile [here](https://www.linkedin.com/in/mehdizare/)