|
1 | 1 | # A Python Wrapper for the NY Federal Reserve
|
2 | 2 |
|
| 3 | +## Primary Dealer Statistics |
| 4 | + |
| 5 | +This module (WIP) takes the raw data from the RESTful API and parses it into Pandas DataFrames. |
| 6 | +Individual time series can be returned, or grouped like the website. All values are in millions of US dollars. |
| 7 | + |
| 8 | +https://www.newyorkfed.org/markets/counterparties/primary-dealers-statistics |
| 9 | + |
| 10 | + |
| 11 | +### How to Use |
| 12 | + |
| 13 | +Import it: |
| 14 | + |
| 15 | +```python |
| 16 | +from primary_dealer_statistics import search_pds_descriptions,get_pds_series,get_dealer_financing,DealerPositioning,Fails |
| 17 | +``` |
| 18 | + |
| 19 | +Initialize the classes: |
| 20 | + |
| 21 | +```python |
| 22 | +dp = DealerPositioning() |
| 23 | +fails = Fails() |
| 24 | +``` |
| 25 | + |
| 26 | +Search the descriptions: |
| 27 | + |
| 28 | +```python |
| 29 | + |
| 30 | +help(search_pds_descriptions) |
| 31 | + |
| 32 | +Signature: search_pds_descriptions(description: str = '') -> pandas.core.frame.DataFrame |
| 33 | +Docstring: |
| 34 | +Search for Primary Dealer Statistics descriptions. Results are case sensitive. |
| 35 | + |
| 36 | +Parameters |
| 37 | +---------- |
| 38 | +description : str = "" |
| 39 | + Keywords to search for. Results are case sensitive. |
| 40 | + |
| 41 | +Returns |
| 42 | +------- |
| 43 | +pd.DataFrame: Pandas DataFrame with Series IDs and descriptions. |
| 44 | + |
| 45 | +Examples |
| 46 | +-------- |
| 47 | +>>> results = search_pds_descriptions(description = "FAILS") |
| 48 | + |
| 49 | +>>> results = search_pds_descriptions(description = "ASSET-BACKED") |
| 50 | +``` |
| 51 | + |
| 52 | +```python |
| 53 | +search_pds_descriptions(description = "ASSET-BACKED").head(1) |
| 54 | +``` |
| 55 | + |
| 56 | +| Description | Series ID | |
| 57 | +|:-------------------------------------------------------------------------------------------------------------------------------------------|:------------| |
| 58 | +| Total - ASSET-BACKED SECURITIES: DEALER TRANSACTIONS WITH INTER-DEALER BROKERS. + ASSET-BACKED SECURITIES: DEALER TRANSACTIONS WITH OTHER. | PDABTOT | |
| 59 | + |
| 60 | + |
| 61 | +Lookup individual series: |
| 62 | + |
| 63 | +```python |
| 64 | +get_pds_series('PDABTOT').tail(5) |
| 65 | +``` |
| 66 | + |
| 67 | +| As Of Date | PDABTOT | |
| 68 | +|:-------------|----------:| |
| 69 | +| 2023-03-15 | 1818 | |
| 70 | +| 2023-03-22 | 1476 | |
| 71 | +| 2023-03-29 | 2765 | |
| 72 | +| 2023-04-05 | 2193 | |
| 73 | +| 2023-04-12 | 2097 | |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | +```python |
| 78 | +dp.tips().tail(5) |
| 79 | +``` |
| 80 | + |
| 81 | +| As Of Date | <= 2 Years | > 2 Years <= 6 Years | > 6 Years <= 11 Years | > 11 Years | Total TIPS | |
| 82 | +|:-------------|-------------:|-----------------------:|------------------------:|-------------:|-------------:| |
| 83 | +| 2023-03-15 | 11320 | 6485 | 1348 | 530 | 19683 | |
| 84 | +| 2023-03-22 | 10752 | 6571 | 1328 | 289 | 18940 | |
| 85 | +| 2023-03-29 | 10852 | 6823 | 1511 | 310 | 19496 | |
| 86 | +| 2023-04-05 | 12827 | 7630 | 1215 | 667 | 22339 | |
| 87 | +| 2023-04-12 | 11397 | 7433 | 570 | 290 | 19690 | |
| 88 | + |
| 89 | +```python |
| 90 | +fails.mbs_fails(mbs_class = 'c').tail(5) |
| 91 | +``` |
| 92 | + |
| 93 | +| As Of Date | <2.5% | 2.5% | 3.0% | 3.5% | 4.0% | 4.5% | 5.0% | 5.5% | 6.0% | >6.0% | |
| 94 | +|:-------------|--------:|-------:|-------:|-------:|-------:|-------:|-------:|-------:|-------:|--------:| |
| 95 | +| 2022-11-21 | 23468 | 49853 | 61728 | 43598 | 73162 | 121508 | 122199 | 92571 | 28146 | 3957 | |
| 96 | +| 2022-12-20 | 20403 | 47651 | 45153 | 33914 | 64548 | 81273 | 101005 | 96802 | 64589 | 25892 | |
| 97 | +| 2023-01-23 | 21386 | 44707 | 45006 | 34015 | 59571 | 77182 | 93820 | 83301 | 71046 | 32967 | |
| 98 | +| 2023-02-21 | 27093 | 49499 | 44586 | 36300 | 60985 | 89913 | 145910 | 102226 | 59099 | 19205 | |
| 99 | +| 2023-03-21 | 23438 | 42656 | 48508 | 33781 | 46644 | 79600 | 119420 | 95710 | 63744 | 18605 | |
| 100 | + |
| 101 | + |
3 | 102 | ## RESTful API
|
4 | 103 |
|
5 | 104 | All data available from the RESTful API (https://markets.newyorkfed.org/static/docs/markets-api.html) is accessible via Python functions.
|
|
0 commit comments