Tidying things up

This commit is contained in:
jeroen
2023-02-22 17:40:44 +01:00
parent 09b1934379
commit 747371ff64
4 changed files with 63 additions and 67 deletions

View File

@@ -1093,27 +1093,21 @@ class FixedIncomeController(BaseController):
parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES, raw=True
)
if ns_parser:
if ns_parser.options:
print_rich_table(
pd.DataFrame.from_dict(fred_view.ICE_BOFA_TO_OPTIONS, orient='index').T.fillna("-"),
show_index=False,
title="Available options for each parameter",
)
else:
fred_view.plot_icebofa(
data_type=ns_parser.data_type,
category=ns_parser.category,
area=ns_parser.area,
grade=ns_parser.grade,
description=ns_parser.description,
start_date=ns_parser.start_date,
end_date=ns_parser.end_date,
raw=ns_parser.raw,
export=ns_parser.export,
sheet_name=" ".join(ns_parser.sheet_name)
if ns_parser.sheet_name
else None,
)
fred_view.plot_icebofa(
data_type=ns_parser.data_type,
category=ns_parser.category,
area=ns_parser.area,
grade=ns_parser.grade,
options=ns_parser.options,
description=ns_parser.description,
start_date=ns_parser.start_date,
end_date=ns_parser.end_date,
raw=ns_parser.raw,
export=ns_parser.export,
sheet_name=" ".join(ns_parser.sheet_name)
if ns_parser.sheet_name
else None,
)
@log_start_end(log=logger)
def call_moody(self, other_args: List[str]):
@@ -1261,26 +1255,20 @@ class FixedIncomeController(BaseController):
parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES, raw=True
)
if ns_parser:
if ns_parser.options:
print_rich_table(
pd.DataFrame.from_dict(fred_view.CP_TO_OPTIONS, orient='index').T.fillna("-"),
show_index=False,
title="Available options for each parameter",
)
else:
fred_view.plot_cp(
maturity=ns_parser.maturity,
category=ns_parser.category,
grade=ns_parser.grade,
description=ns_parser.description,
start_date=ns_parser.start_date,
end_date=ns_parser.end_date,
raw=ns_parser.raw,
export=ns_parser.export,
sheet_name=" ".join(ns_parser.sheet_name)
if ns_parser.sheet_name
else None,
)
fred_view.plot_cp(
maturity=ns_parser.maturity,
category=ns_parser.category,
grade=ns_parser.grade,
options=ns_parser.options,
description=ns_parser.description,
start_date=ns_parser.start_date,
end_date=ns_parser.end_date,
raw=ns_parser.raw,
export=ns_parser.export,
sheet_name=" ".join(ns_parser.sheet_name)
if ns_parser.sheet_name
else None,
)
@log_start_end(log=logger)
def call_spot(self, other_args: List[str]):
@@ -1482,28 +1470,22 @@ class FixedIncomeController(BaseController):
parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES, raw=True
)
if ns_parser:
if ns_parser.options:
print_rich_table(
pd.DataFrame.from_dict(fred_view.ICE_BOFA_TO_OPTIONS, orient='index').drop('Type').T.fillna("-"),
show_index=False,
title="Available options for each parameter",
)
else:
fred_view.plot_icebofa(
data_type='spread',
category=ns_parser.category,
area=ns_parser.area,
grade=ns_parser.grade,
description=ns_parser.description,
start_date=ns_parser.start_date,
end_date=ns_parser.end_date,
raw=ns_parser.raw,
export=ns_parser.export,
sheet_name=" ".join(ns_parser.sheet_name)
if ns_parser.sheet_name
else None,
)
fred_view.plot_icebofa(
data_type='spread',
category=ns_parser.category,
area=ns_parser.area,
grade=ns_parser.grade,
options=ns_parser.options,
description=ns_parser.description,
start_date=ns_parser.start_date,
end_date=ns_parser.end_date,
raw=ns_parser.raw,
export=ns_parser.export,
sheet_name=" ".join(ns_parser.sheet_name)
if ns_parser.sheet_name
else None,
)
@log_start_end(log=logger)
def call_tbffr(self, other_args: List[str]):
"""Process tbffr command"""

View File

@@ -771,7 +771,7 @@ def plot_ameribor(
else:
ylabel = "Yield (%)"
ax.set_title(ID_TO_NAME_AMERIBOR[series_id])
ax.set_title(ID_TO_NAME_AMERIBOR[series_id], fontsize=15)
ax.set_ylabel(ylabel)
theme.style_primary_axis(ax)
@@ -1837,6 +1837,7 @@ def plot_icebofa(
category: str = "all",
area: str = "us",
grade: str = "non_sovereign",
options: bool = False,
description: bool = False,
start_date: Optional[str] = None,
end_date: Optional[str] = None,
@@ -1920,13 +1921,20 @@ def plot_icebofa(
series = pd.read_excel(ice_bofa_path)
if options:
return print_rich_table(
series.drop(
['Frequency', 'Units', 'Asset Class', 'FRED Series ID', 'Description'], axis=1)
[series['Type'].isin(['yield', 'yield_to_worst', 'total_return'] if data_type != 'spread' else ['spread'])]
)
series = series[
(series['Type'] == data_type) &
(series['Units'] == units) &
(series['Frequency'] == 'daily') &
(series['Category'] == 'bonds') &
(series['Subcategory'] == category) &
(series['Region'] == area) &
(series['Asset Class'] == 'bonds') &
(series['Category'] == category) &
(series['Area'] == area) &
(series['Grade'] == grade)
]
@@ -2090,6 +2098,7 @@ def plot_cp(
maturity: str = "30d",
category: str = "financial",
grade: str = "aa",
options: bool = False,
description: bool = False,
start_date: Optional[str] = None,
end_date: Optional[str] = None,
@@ -2130,6 +2139,11 @@ def plot_cp(
series = pd.read_excel(commercial_paper_path)
if options:
return print_rich_table(
series.drop(['Description', 'FRED Series ID'], axis=1)
)
series = series[
(series['Maturity'] == maturity) &
(series['Category'] == category) &

Binary file not shown.

Binary file not shown.