Created
May 31, 2022 12:48
-
-
Save 84adam/528e58eb12ebec4ff9c4bfd31df0727d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import io | |
import pandas as pd | |
# SEE: https://fred.stlouisfed.org/series/T5YIFR/#0 | |
url = """https://fred.stlouisfed.org/graph/fredgraph.csv?bgcolor=%23e1e9f0&chart_type=line&drp=0&fo=open%20sans&graph_bgcolor=%23ffffff&height=450&mode=fred&recession_bars=on&txtcolor=%23444444&ts=12&tts=12&width=1168&nt=0&thu=0&trc=0&show_legend=yes&show_axis_titles=yes&show_tooltip=yes&id=T5YIFR&scale=left&cosd=2003-01-02&line_color=%234572a7&link_values=false&line_style=solid&mark_type=none&mw=3&lw=2&ost=-99999&oet=99999&mma=0&fml=a&fq=Daily&fam=avg&fgst=lin&fgsnd=2020-02-01&line_index=1&transformation=lin&nd=2003-01-02 | |
""" | |
s = requests.get(url).content | |
df = pd.read_csv(io.StringIO(s.decode('utf-8'))) | |
print(df[-10::]) |
10 Year Inflation Breakevens -- https://fred.stlouisfed.org/series/T10YIE
url = """https://fred.stlouisfed.org/graph/fredgraph.csv?bgcolor=%23e1e9f0&chart_type=line&drp=0&fo=open%20sans&graph_bgcolor=%23ffffff&height=450&mode=fred&recession_bars=on&txtcolor=%23444444&ts=12&tts=12&width=1168&nt=0&thu=0&trc=0&show_legend=yes&show_axis_titles=yes&show_tooltip=yes&id=T10YIE&scale=left&cosd=2003-01-02&line_color=%234572a7&link_values=false&line_style=solid&mark_type=none&mw=3&lw=2&ost=-99999&oet=99999&mma=0&fml=a&fq=Daily&fam=avg&fgst=lin&fgsnd=2020-02-01&line_index=1&transformation=lin&nd=2003-01-02
"""
s = requests.get(url).content
df = pd.read_csv(io.StringIO(s.decode('utf-8')))
print(df[-10::])
example output:
DATE T10YIE
5064 2022-06-01 2.65
5065 2022-06-02 2.66
5066 2022-06-03 2.74
5067 2022-06-06 2.76
5068 2022-06-07 2.73
5069 2022-06-08 2.75
5070 2022-06-09 2.75
5071 2022-06-10 2.76
5072 2022-06-13 2.74
5073 2022-06-14 2.6
5 Year Inflation Breakevens -- https://fred.stlouisfed.org/series/T5YIE
url = """https://fred.stlouisfed.org/graph/fredgraph.csv?bgcolor=%23e1e9f0&chart_type=line&drp=0&fo=open%20sans&graph_bgcolor=%23ffffff&height=450&mode=fred&recession_bars=on&txtcolor=%23444444&ts=12&tts=12&width=1168&nt=0&thu=0&trc=0&show_legend=yes&show_axis_titles=yes&show_tooltip=yes&id=T5YIE&scale=left&cosd=2003-01-02&line_color=%234572a7&link_values=false&line_style=solid&mark_type=none&mw=3&lw=2&ost=-99999&oet=99999&mma=0&fml=a&fq=Daily&fam=avg&fgst=lin&fgsnd=2020-02-01&line_index=1&transformation=lin&nd=2003-01-02
"""
s = requests.get(url).content
df = pd.read_csv(io.StringIO(s.decode('utf-8')))
print(df[-10::])
example output:
DATE T5YIE
5064 2022-06-01 2.96
5065 2022-06-02 2.97
5066 2022-06-03 3.04
5067 2022-06-06 3.05
5068 2022-06-07 3.03
5069 2022-06-08 3.06
5070 2022-06-09 3.08
5071 2022-06-10 3.13
5072 2022-06-13 3.11
5073 2022-06-14 2.88
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example output: